posthog-js 1.435.2 → 1.435.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/conversations.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/dead-clicks-autocapture.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/exception-autocapture.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/lazy-recorder.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.cjs +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.cjs +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.no-external.cjs +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.no-external.js +1 -1
- package/dist/posthog-recorder.d.ts +1 -0
- package/dist/posthog-recorder.js +1 -1
- package/dist/posthog-recorder.js.map +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/recorder-v2.js +1 -1
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.d.ts +1 -0
- package/dist/recorder.js +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/rrweb.d.ts +1 -0
- package/dist/rrweb.js +1 -1
- package/dist/rrweb.js.map +1 -1
- package/dist/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +6 -0
- package/dist/src/extensions/replay/types/rrweb.d.ts +1 -0
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +6 -0
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +26 -3
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
- package/lib/src/extensions/replay/types/rrweb.d.ts +1 -0
- package/package.json +6 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){const t="0.9.0",i={DEBUG:(!1,!1),LIB_VERSION:(t,"1.435.2"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:t};var e=i;const s="$people_distinct_id",n="distinct_id",r="$device_id",o="$device_model",l="__alias",a="__cmpns",h="$fbc",u="$fbc_persistence",d="$fbp",c="$fbp_persistence",v="__timers",f="$autocapture_disabled_server_side",p="$heatmaps_enabled_server_side",g="$exception_capture_enabled_server_side",_="$error_tracking_suppression_rules",m="$error_tracking_capture_extension_exceptions",b="$web_vitals_enabled_server_side",y="$dead_clicks_enabled_server_side",w="$product_tours_enabled_server_side",x="$logs_capture_enabled_server_side",S="$web_vitals_allowed_metrics",k="$session_recording_remote_config",E="$session_recording_enabled_server_side",P="$replay_sample_rate",T="$replay_override_sampling",C="$replay_override_linked_flag",F="$replay_override_url_trigger",M="$replay_override_event_trigger",I="$sesid",O="$session_is_sampled",A="$session_past_minimum_duration",R="$session_recording_url_trigger_activated_session",D="$session_recording_event_trigger_activated_session",j="$debug_first_full_snapshot_timestamp",B="$sess_rec_flush_size",N="$enabled_feature_flags",L="$active_feature_flags",z="$early_access_features",H="$feature_flag_details",U="$feature_flag_payloads",q="$feature_flag_request_id",V="$minimal_flag_called_events",W="$override_feature_flags",G="$override_feature_flag_payloads",K="$stored_person_properties",J="$stored_group_properties",Y="$groups",X="$surveys",Z="$surveys_loaded_at",Q="$surveys_activated",tt="$surveys_activated_session",it="$surveys_activated_timestamps",et="ph_product_tours",st="$product_tours_activated",nt="$product_tours_activated_session",rt="$conversations_widget_session_id",ot="$conversations_ticket_id",lt="$conversations_widget_state",at="$conversations_user_traits",ht="$flag_call_reported",ut="$flag_call_reported_session_id",dt="$feature_flag_errors",ct="$feature_flag_evaluated_at",vt="$user_state",ft="$client_session_props",pt="$capture_rate_limit",gt="$initial_campaign_params",_t="$initial_referrer_info",mt="$initial_person_info",bt="$epp",yt="$posthog_cookieless",wt="$cookieless_mode",$t="$sdk_debug_extensions_init_method",xt="$sdk_debug_extensions_init_time_ms",St="$sdk_debug_recording_script_not_loaded",kt="$sdk_debug_replay_stale_config",Et="$sdk_debug_replay_event_trigger_status",Pt="$sdk_debug_replay_linked_flag_trigger_status",Tt="$sdk_debug_replay_matched_recording_trigger_groups",Ct="$sdk_debug_replay_pending_trigger_conditions",Ft="$sdk_debug_replay_remote_trigger_matching_config",Mt="$sdk_debug_replay_trigger_groups_count",It="$sdk_debug_replay_url_trigger_status",Ot="$session_recording_start_reason",At="PostHog loadExternalDependency extension not found.",Rt="anonymous",Dt="identified",jt="identified_only",Bt="visibilitychange",Nt="beforeunload",Lt="$pageview",zt="$pageleave",Ht="$identify",Ut="$groupidentify",qt="u">typeof window?window:void 0,Vt="u">typeof globalThis?globalThis:qt,Wt=null==Vt?void 0:Vt.navigator,Gt=null==Vt?void 0:Vt.document,Kt=null==Vt?void 0:Vt.location,Jt=null==Vt?void 0:Vt.fetch,Yt=(null==Vt?void 0:Vt.XMLHttpRequest)&&"withCredentials"in new Vt.XMLHttpRequest?Vt.XMLHttpRequest:void 0,Xt=null==Vt?void 0:Vt.AbortController,Zt=null==Vt?void 0:Vt.CompressionStream,Qt=null==Wt?void 0:Wt.userAgent;function ti(){return!(!qt||!1===qt.navigator.onLine)}const ii="undefined"!=typeof globalThis?globalThis:qt;ii&&"undefined"==typeof self&&(ii.self=ii),ii&&"undefined"==typeof File&&(ii.File=function(){});const ei=null!=qt?qt:{};var si=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),ni=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({});const ri=["$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"],oi=["token"];function li(t,i){return-1!==t.indexOf(i)}const ai=function(t){return t.trim()},hi=function(t){return t.replace(/^\$/,"")};function ui(t){var i;const e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}const di=Object.prototype,ci=di.hasOwnProperty,vi=di.toString,fi=Array.isArray||function(t){return"[object Array]"===vi.call(t)},pi=t=>"function"==typeof t,gi=t=>t===Object(t)&&!fi(t),_i=t=>{if(gi(t)){for(const i in t)if(ci.call(t,i))return!1;return!0}return!1},mi=t=>void 0===t,bi=t=>"[object String]"==vi.call(t),yi=t=>bi(t)&&0===t.trim().length,wi=t=>null===t,$i=t=>mi(t)||wi(t),xi=t=>"[object Number]"==vi.call(t)&&t==t,Si=t=>xi(t)&&t>0,ki=t=>"[object Boolean]"===vi.call(t),Ei=t=>li(ri,t),Pi=t=>li(oi,t);function Ti(t){return null===t||"object"!=typeof t}function Ci(t,i){return{}.toString.call(t)===`[object ${i}]`}function Fi(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Ii(t,Error)}}function Mi(t){return"u">typeof Event&&Ii(t,Event)}function Ii(t,i){try{return t instanceof i}catch(t){return!1}}const Oi=[!0,"true",1,"1","yes"],Ai=t=>li(Oi,t),Ri=[!1,"false",0,"0","no"];function Di(t,i,e,s,n,r,o){try{var l=t[r](o),a=l.value}catch(t){return void e(t)}l.done?i(a):Promise.resolve(a).then(s,n)}function ji(t){return function(){var i=this,e=arguments;return new Promise(function(s,n){var r=t.apply(i,e);function o(t){Di(r,s,n,o,l,"next",t)}function l(t){Di(r,s,n,o,l,"throw",t)}o(void 0)})}}const Bi=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Ni=function(t,i=[]){if(!t)return!1;const e=t.toLowerCase();return Bi.concat(i).some(t=>{const i=t.toLowerCase();return-1!==e.indexOf(i)})};function Li(t,i,e,s,n){return i>e&&(s.warn("min cannot be greater than max."),i=e),xi(t)?t>e?(s.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(s.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(s.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+n),Li(null!=n?n:e,i,e,s))}var zi=class{constructor(t){this.C={},this.I=t.I,this.R=Li(t.bucketSize,0,100,t.A),this.$=Li(t.refillRate,0,this.R,t.A),this.O=Li(t.refillInterval,0,864e5,t.A)}F(t,i){const e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.$,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i;const e=Date.now(),s=String(t);let n=this.C[s];return n?this.F(n,e):(n={tokens:this.R,lastAccess:e},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(i=this.I)||void 0===i||i.call(this,t)),0===n.tokens)}stop(){this.C={}}};const Hi="Mobile",Ui="Android",qi="Tablet",Vi="Android Tablet",Wi="iPad",Gi="Apple Watch",Ki="Safari",Ji="BlackBerry",Yi="Samsung Internet",Xi="Chrome",Zi="Chrome iOS",Qi="Internet Explorer",te="Internet Explorer Mobile",ie="Opera",ee="Microsoft Edge",se="Firefox",ne="Firefox iOS",re="Nintendo",oe="PlayStation",le="Xbox",ae="Android Mobile",he="Mobile Safari",ue="Windows",de="Windows Phone",ce="Nokia",ve="Ouya",fe="Generic "+Hi.toLowerCase(),pe="Generic "+qi.toLowerCase(),ge="Konqueror",_e="Oculus Browser",me="Vivaldi",be="Yandex",ye="Whale",we="DuckDuckGo",$e="Pale Moon",xe="Waterfox",Se="Brave",ke="Claude",Ee="Codex",Pe="ChatGPT",Te="Google Search App",Ce=new RegExp("Version/(\\d+(\\.\\d+)?)"),Fe=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Me=new RegExp(le,"i"),Ie=new RegExp("PlayStation \\w+","i"),Oe=new RegExp("Nintendo \\w+","i"),Ae=new RegExp("BlackBerry|PlayBook|BB10","i"),Re={"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"},De=function(t,i,e,s){i=i||"";const n=function(t){return(null==t?void 0:t.brave)?Se:null}(e);return n||((null==s?void 0:s.detectGoogleSearchApp)&&li(t,"GSA/")?Te:li(t," OPR/")&&li(t,"Mini")?"Opera Mini":li(t," OPR/")?ie:Ae.test(t)?Ji:li(t,"IEMobile")||li(t,"WPDesktop")?te:li(t,"OculusBrowser")?_e:li(t,"SamsungBrowser")?Yi:li(t,"Edge")||li(t,"Edg/")?ee:li(t,"Vivaldi/")?me:li(t,"YaBrowser/")?be:li(t,"Whale/")?ye:li(t,"DuckDuckGo/")||li(t,"Ddg/")?we:li(t,"Claude/")?ke:li(t,"Codex/")?Ee:li(t,"ChatGPT/")?Pe:li(t,"FBIOS")?"Facebook Mobile":li(t,"UCWEB")||li(t,"UCBrowser")?"UC Browser":li(t,"CriOS")?Zi:li(t,"CrMo")||li(t,Xi)?Xi:li(t,Ui)&&li(t,Ki)?ae:li(t,"FxiOS")?ne:li(t.toLowerCase(),ge.toLowerCase())?ge:li(t,"Brave/")?Se:((t,i)=>i&&li(i,"Apple")||function(t){return li(t,Ki)&&!li(t,Xi)&&!li(t,Ui)}(t))(t,i)?li(t,Hi)?he:Ki:li(t,"PaleMoon/")?$e:li(t,"Waterfox/")?xe:li(t,se)?se:li(t,"MSIE")||li(t,"Trident/")?Qi:li(t,"Gecko")?se:"")},je={[te]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ee]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Xi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Zi]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ki]:[Ce],[he]:[Ce],[ie]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[se]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ne]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[ge]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Ji]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ce],[ae]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Yi]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[_e]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[me]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[be]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ye]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Se]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[ke]:[Fe],[Ee]:[Fe],[Pe]:[Fe],[we]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[$e]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[xe]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Te]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Qi]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Be=function(t,i,e,s){const n=De(t,i,e,s),r=je[n];if(mi(r))return null;for(let i=0;r.length>i;i++){const e=t.match(r[i]);if(e)return parseFloat(e[e.length-2])}return null},Ne=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[le,t&&t[1]||""]],[new RegExp(re,"i"),[re,""]],[new RegExp(oe,"i"),[oe,""]],[Ae,[Ji,""]],[new RegExp(ue,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[de,""];if(new RegExp(Hi).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];const e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){let t=Re[e[1]]||"";return/arm/i.test(i)&&(t="RT"),[ue,t]}return[ue,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let i="";return t&&t.length>=3&&(i=mi(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[Ui,[t[2],t[3],t[4]||"0"].join(".")]:[Ui,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Le=function(t){for(let i=0;Ne.length>i;i++){const[e,s]=Ne[i],n=e.exec(t),r=n&&(pi(s)?s(n,t):s);if(r)return r}return["",""]},ze=function(t){return Oe.test(t)?re:Ie.test(t)?oe:Me.test(t)?le:new RegExp(ve,"i").test(t)?ve:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?de:/iPad/.test(t)?Wi:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Gi:Ae.test(t)?Ji:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(ce,"i").test(t)?ce:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Hi).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Ui:Vi:new RegExp("(pda|Mobile)","i").test(t)?fe:new RegExp(qi,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?pe:""},He=function(t,i){var e;const s=ze(t);return s===Wi||s===Vi||"Kobo"===s||"Kindle Fire"===s||s===pe?qi:s===re||s===le||s===oe||s===ve?"Console":s===Gi?"Wearable":s?Hi:"Android"===(null==i?void 0:i.userAgentDataPlatform)&&(null!==(e=null==i?void 0:i.maxTouchPoints)&&void 0!==e?e:0)>0?600>Math.min(null!==(n=null==i?void 0:i.screenWidth)&&void 0!==n?n:0,null!==(r=null==i?void 0:i.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==i?void 0:i.devicePixelRatio)&&void 0!==o?o:1)?Hi:qi:"Desktop";var n,r,o},Ue=/\bFBAV\/(\d+(?:\.\d+)*)/i,qe=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Ue],[/\bFBAN\/EMA\b/i,"Facebook Lite",Ue],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Ue],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Ve="[Truncated]",We="[Unserializable]";function Ge(t){let i="";for(let e=0;t.length>e;e++){const s=t.charCodeAt(e);if(55296>s||s>56319)i+=56320>s||s>57343?t[e]:"�";else{const s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}function Ke(t,i){if(!i)return t;let e=[];try{e=Object.keys(i)}catch(t){e=[]}for(const s of e){let e;try{e=i[s]}catch(t){e=We}Object.defineProperty(t,s,{value:e,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;const Je=3e5;var Ye=class{record(t){if("too-large"===t.kind)return;if("retry-later"!==t.kind)return void this.reset();if(!t.retryAfterMs)return;const i=this.isOpen(),e=Date.now(),s=Math.min(t.retryAfterMs,Je);if(!i)return this.ts=e,void(this.es=e+s);this.es=Math.max(this.es,Math.min(e+s,this.ts+Je))}remainingMs(){const t=Date.now();if(this.ts-5e3>t)return this.reset(),0;const i=Math.min(Je,Math.max(0,this.es-t));return 0===i&&this.reset(),i}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const Xe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ze(t,i){return"string"==typeof(e=t)&&Xe.test(e)?t:i();var e}function Qe(t,i){const e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function ts(t){return t?t.split("#")[0]:t}function is(t){try{return t()}catch(t){return}}function es(t,i){const e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function ss(t,i,e){return ns.apply(this,arguments)}function ns(){return(ns=ji(function*(t,i,e){let s;try{return yield Promise.race([t,new Promise((t,n)=>{s=es(()=>{try{null==e||e(),t()}catch(t){n(t)}},i)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let rs,os,ls;function as(t){const i=globalThis._posthogChunkIds;if(!i)return;const e=Object.keys(i);return ls&&e.length===os||(os=e.length,ls=e.reduce((e,s)=>{rs||(rs={});const n=rs[s];if(n)e[n[0]]=n[1];else{const n=t(s);for(let t=n.length-1;t>=0;t--){const r=n[t],o=null==r?void 0:r.filename,l=i[s];if(o&&l){e[o]=l,rs[s]=[o,l];break}}}return e},{})),ls}function hs(t){return hs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hs(t)}function us(t,i,e){return(i=function(t){var i=function(t){if("object"!=hs(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var e=i.call(t,"string");if("object"!=hs(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hs(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function ds(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,s)}return e}function cs(t){for(var i=1;arguments.length>i;i++){var e=null!=arguments[i]?arguments[i]:{};i%2?ds(Object(e),!0).forEach(function(i){us(t,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ds(Object(e)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}return t}var vs=class{constructor(t,i,e=[]){this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i={}){const e=i&&i.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(e,i,0).apply(t),n=this.buildParsingContext(i),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,e),$exception_level:"error"}}modifyFrames(t){var i=this;return ji(function*(){for(const e of t)e.stacktrace&&e.stacktrace.frames&&fi(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e;let s,n;if(null!=t.cause&&(s=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)}catch(t){}return cs(cs({},t),{},{cause:s,stack:n,errors:null===(e=t.errors)||void 0===e?void 0:e.map(t=>this.parseStacktrace(t,i))})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(const e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return ji(function*(){let e=t;for(const t of i.modifiers)e=yield t(e);return e})()}convertToExceptionList(t,i){const e=[],s=(t,n,r)=>{var o;const l=e.length,a=void 0===n?cs(cs({type:"string"==typeof i.type&&i.type.length>0?i.type:"generic"},"boolean"==typeof i.handled?{handled:i.handled}:void 0===i.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof i.synthetic?i.synthetic:t.synthetic,exception_id:l}):{type:"chained",source:r,synthetic:t.synthetic,exception_id:l,parent_id:n},h={type:t.type,value:t.value,mechanism:a};t.stack&&(h.stacktrace={type:"raw",frames:t.stack}),e.push(h),t.cause&&s(t.cause,l,"cause");for(const i of null!==(o=t.errors)&&void 0!==o?o:[])s(i,l,"member")};return s(t),e}buildParsingContext(t){var i;return{chunkIdMap:as(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}getAggregateErrors(t){try{if(Fi(t)){let e=Object.getPrototypeOf(t);for(let s=0;e&&100>s;s++){var i;const s=null===(i=Object.getOwnPropertyDescriptor(e,"constructor"))||void 0===i?void 0:i.value;if("function"==typeof s&&"AggregateError"===s.name){const i=t.errors;return fi(i)?i:void 0}e=Object.getPrototypeOf(e)}}}catch(t){}}buildCoercingContext(t,i,e=0){let s=0,n=0,r=!1;const o=new Set,l=[],a={},h=(t,i,e=0)=>{const h=u(i,e),d=h.apply;if(h.apply=i=>{l.push(t);try{return d(i)}finally{l.pop()}},e>4||e>0&&-1!==l.indexOf(t))return this.coerceFallback(h);const c="object"==typeof t&&null!==t||"function"==typeof t;if(0===e&&s>=50||c&&o.has(t))return;c&&o.add(t),0===e&&s++;const v=this.getAggregateErrors(t);let f,p;r||(r=!!v);try{if(f=this.applyCoercers(t,h),!f)throw a}catch(t){if(t===a)return void(0===e&&s--);if(!r)throw t;f=this.coerceFallback(h)}if(!v||s>=50)return f;try{p=v.length}catch(t){return f}if(!Number.isInteger(p)||0>p||p>4294967295)return f;const g=[];for(let t=0;50>s&&1e3>n&&p>t;t++){let e;n++;try{e=h.next(v[t])}catch(t){s++,e=this.coerceFallback(u(i+1))}e&&g.push(e)}return cs(cs({},f),{},{errors:g})},u=(e,s=0)=>cs(cs({},i),{},{syntheticException:0==e?i.syntheticException:void 0,mechanism:0==e?t:{},apply(t){const i=h(t,e,s+1);if(!i)throw a;return i},next:t=>h(t,e+1)}),d=u(e);return cs(cs({},d),{},{apply:t=>{var i;return null!==(i=h(t,e))&&void 0!==i?i:this.coerceFallback(d)}})}};const fs=/^([a-z][a-z0-9.+-]+):/i,ps=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function gs(t){if(!t||"<anonymous>"===t)return!1;const i=fs.exec(t);return!i||ps.includes(i[1].toLowerCase())}function _s(t,i,e,s,n){const r={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:gs(i)};return mi(s)||(r.lineno=s),mi(n)||(r.colno=n),r}const ms=(t,i)=>{const e=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return e||s?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?`safari-extension:${i}`:`safari-web-extension:${i}`]:[t,i]},bs=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ys=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ws=/\((\S*)(?::(\d+))(?::(\d+))\)/,$s=(t,i)=>{const e=bs.exec(t);if(e){const[,t,s,n]=e;return _s(i,t,"?",+s,+n)}const s=ys.exec(t);if(s){if(s[2]&&0===s[2].indexOf("eval")){const t=ws.exec(s[2]);t&&(s[2]=t[1],s[3]=t[2],s[4]=t[3])}const[t,e]=ms(s[1]||"?",s[2]);return _s(i,e,t,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},xs=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ss=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ks=(t,i)=>{const e=xs.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=Ss.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],s=e[1]||"?";return[s,t]=ms(s,t),_s(i,t,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Es=/\(error: (.*)\)/;function Ps(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function Ts(t){for(let i=1;10>=i;i++){const e=t.length-2*i;if(0>e)break;let s=!0;for(let n=0;i>n;n++)if(!Ps(t[e+n],t[e+i+n])){s=!1;break}if(s){for(let s=0;i>s;s++)t[e+s]=t[e+i+s];return t.length=e+i,{start:e,length:i}}}}function Cs(t,i){const e=i.start+i.length,s=Ms(t,i);s&&t.splice(e+s===t.length?e:i.start,s)}function Fs(t,i){let e=i.start;for(;e>0&&Ps(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function Ms(t,i){const e=i.start+i.length;let s=e;for(;t.length>s&&Ps(t[s],t[s-i.length]);)s++;return s-e}function Is(t,i){const e=i[0];let s=t.length-(e?Fs(t,e):0);for(const e of i)s-=Ms(t,e);return s}function Os(t,i,e){for(let s=0;t.length>s;s++){const n=t[(i+s)%t.length],r=t[(e+s)%t.length];if(n!==r)return r>n}return!1}var As=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){const e=bi(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){const i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${i}: ${t.message}`:i}isDOMException(t){return Ci(t,"DOMException")}isDOMError(t){return Ci(t,"DOMError")}},Rs=class{match(t){return Fi(t)}coerce(t,i){var e;const s=this.getStack(t),n=void 0===s?null===(e=i.syntheticException)||void 0===e?void 0:e.stack:void 0,r=!!n;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=s?s:n,cause:t.cause?i.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,i){const e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){try{const i=t.stacktrace;if("string"==typeof i&&i.length>0)return i;const e=t.stack;return"string"==typeof e&&e.length>0?e:void 0}catch(t){return}}},Ds=class{match(t){return!!Ci(t,"ErrorEvent")&&(null!=t.error||this.sr(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);const s=i.apply(t.message);return cs(cs({},s),{},{stack:null!==(e=this.ar(t))&&void 0!==e?e:s.stack,synthetic:!0})}sr(t){return bi(t.message)&&t.message.length>0}ar(t){var i,e;const s=t,n=null!==(i=s.lineno)&&void 0!==i?i:0,r=null!==(e=s.colno)&&void 0!==e?e:0;if(bi(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const js=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Bs=class{match(t){return"string"==typeof t}coerce(t,i){var e;const[s,n]=this.getInfos(t);return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}getInfos(t){let i="Error",e=t;const s=t.match(js);return s&&(i=s[1],e=s[2]),[i,e]}};const Ns=["fatal","error","warning","log","info","debug"];function Ls(t,i=40){const e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(let t=e.length;t>0;t--){const s=e.slice(0,t).join(", ");if(i>=s.length)return t===e.length?s:s.length>i?`${s.slice(0,i)}...`:s}return""}var zs=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,s;const n=this.getErrorPropertyFromObject(t);return n?i.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null===(s=i.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(Mi(t))return t.constructor.name;const i="name"in t?t.name:void 0;return bi(i)&&!yi(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){let i=`'${t.name}' captured as exception`;return"message"in t&&"string"==typeof t.message&&(i+=` with message: '${t.message}'`),i}if("message"in t&&"string"==typeof t.message)return t.message;const i=this.getObjectClassName(t);return`${i&&"Object"!==i?`'${i}'`:"Object"} captured as exception with keys: ${Ls(t)}`}isSeverityLevel(t){return bi(t)&&!yi(t)&&Ns.indexOf(t)>=0}getStack(t){try{return bi(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:bi(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(const i in t)if({}.hasOwnProperty.call(t,i)){const e=t[i];if(Fi(e))return e}}getObjectClassName(t){try{const i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},Hs=class{match(t){return Mi(t)}coerce(t,i){var e;const s=t.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Ls(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},Us=class{match(t){return Ti(t)}coerce(t,i){var e;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},qs=class{match(t){return Ci(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!Mi(t))return!1;try{const i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e;const s=this.getUnhandledRejectionReason(t);return Ti(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}:i.apply(s)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}};const Vs="$message",Ws="$timestamp",Gs=new Set([Vs,Ws]),Ks={enabled:!0,max_bytes:32768};function Js(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Ks.enabled,max_bytes:Xs(t.max_bytes,Ks.max_bytes)}:cs({},Ks)}var Ys=class{constructor(t){this.ns=[],this.ss=0,this.Mr=Js(t)}setConfig(t){this.Mr=Js(t),this.rs()}add(t){const i=function(t){let i;try{i=ui(t)}catch(t){return}try{const t=JSON.parse(i);if(!gi(t))return;const e=t,s=e[Vs],n=e[Ws];if(!bi(s)||0===s.trim().length)return;if(!bi(n)&&!xi(n))return;return{step:e,json:i}}catch(t){return}}(t);if(!i)return;const e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;const i=encodeURIComponent(t);let e=0;for(let t=0;i.length>t;t++)"%"===i[t]?(e+=1,t+=2):e+=1;return e}(i.json);e>this.Mr.max_bytes||(this.ns.push({step:i.step,bytes:e}),this.ss+=e,this.rs())}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){const t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function Xs(t,i){if(!xi(t)||1/0===t||-1/0===t)return i;const e=Math.floor(t);return 0>e?i:e}const Zs=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Qs(t){return"string"==typeof t||t}function tn(t){return"string"==typeof t?t:void 0}const en=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],sn="NativeGzipValidationError",nn=t=>t.length>=2&&31===t[0]&&139===t[1],rn=(t,i)=>t===ni.GZipJS||i===ni.GZipJS||"gzip"===i,on=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):"");let ln;const an=t=>{throw Qe(sn,`Native gzip produced invalid output: ${t}`)},hn=(un=ji(function*(t,i){18>t.size&&an("too-short");const e=new Uint8Array(yield t.slice(0,10).arrayBuffer());nn(e)&&8===e[2]||an("invalid-header");const s=new DataView(yield t.slice(t.size-8).arrayBuffer());s.getUint32(0,!0)!==(t=>{const i=(()=>{if(ln)return ln;ln=[];for(let t=0;256>t;t++){let i=t;for(let t=0;8>t;t++)i=1&i?3988292384^i>>>1:i>>>1;ln[t]=i>>>0}return ln})();let e=4294967295;for(let s=0;t.length>s;s++)e=i[255&(e^t[s])]^e>>>8;return(4294967295^e)>>>0})(i)&&an("invalid-crc");const n=i.length>>>0;s.getUint32(4,!0)!==n&&an("invalid-size")}),function(t,i){return un.apply(this,arguments)});var un;function dn(){return dn=ji(function*(t,i=!0,e){try{const i=(new TextEncoder).encode(t),e=new globalThis.CompressionStream("gzip"),n=e.writable.getWriter(),r=n.write(i).then(()=>n.close()).catch((s=ji(function*(t){try{yield n.abort(t)}catch(t){}throw t}),function(t){return s.apply(this,arguments)})),o=new Response(e.readable).blob(),[l]=yield Promise.all([o,r]);return yield hn(l,i),l}catch(t){if(null==e?void 0:e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}var s}),dn.apply(this,arguments)}function cn(t,i){if(null==t)return{};var e,s,n=function(t,i){if(null==t)return{};var e={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(i.includes(s))continue;e[s]=t[s]}return e}(t,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(s=0;r.length>s;s++)i.includes(e=r[s])||{}.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}const vn={}.propertyIsEnumerable;function fn(t,i){try{return _n(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function pn(t,i,e,s){if(0>=e.remainingNodes)return{stringValue:Ve};if(e.remainingNodes--,ki(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){const e=t.toString(),s=BigInt("9223372036854775808");return t>=s||-s>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const e=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:Ge(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:Ve};if(t instanceof Date){const i=t.getTime(),e=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:"string"==typeof e?Ge(e):String(e)}}e.ancestors.add(t);try{try{const n=t.toJSON;if("function"==typeof n)return pn(n.call(t),i,e,s+1)}catch(t){}return fi(t)?{arrayValue:{values:gn(t,i,e,s+1)}}:{kvlistValue:{values:_n(t,i,e,s+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:Ge(String(t))}}function gn(t,i,e,s){const n=[],r=Math.min(t.length,1e3);let o=0;for(;r>o&&e.remainingNodes>0;o++)try{const r=o in t?t[o]:void 0;if($i(r))continue;n.push(pn(r,i,e,s))}catch(t){n.push({stringValue:We})}return t.length>o&&n.push({stringValue:Ve}),n}function _n(t,i,e,s){const n=[];for(const r in t)if(vn.call(t,r)){if(!r){null==i||i.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=t[r];if(wi(o)||mi(o))continue;n.push({key:Ge(r),value:pn(o,i,e,s)})}catch(t){n.push({key:Ge(r),value:{stringValue:We}})}}return n}function mn(t,i,e){return cs(cs(cs(cs({},Ke({},t.resourceAttributes)),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}const bn=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function yn(t,i){const e=Ke({},t),s={};for(const t of bn)({}).hasOwnProperty.call(e,t)&&(s[t]=e[t],delete e[t]);return[...fn(e,i),...fn(s,i)]}const wn={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const $n={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},xn=$n.info;function Sn(t){try{return Ge(String(t))}catch(t){return We}}function kn(t,i,e,s){const n=t.level||"info",{text:r,number:o}=$n[n]||xn,l=function(t=Date.now()){return String(t)+"000000"}(xi(s)?s:void 0),a={};i.distinctId&&(a.posthogDistinctId=i.distinctId),i.sessionId&&(a.sessionId=i.sessionId),i.windowId&&(a["window.id"]=i.windowId),$i(i.sessionStartTimestamp)||(a.sessionStartTimestamp=String(i.sessionStartTimestamp)),$i(i.lastActivityTimestamp)||(a.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(a["url.full"]=i.currentUrl),i.screenName&&(a["screen.name"]=i.screenName),i.appState&&(a["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(a.feature_flags=i.activeFeatureFlags);const h=cs({},a),u=t.attributes;if(u){let t=[];try{t=Object.keys(u)}catch(i){t=[]}for(const i of t){let t;try{t=u[i]}catch(i){t=We}Object.defineProperty(h,i,{value:t,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:o,severityText:r,body:{stringValue:Sn(t.body)},attributes:fn(h,e)};return t.trace_id&&(d.traceId=t.trace_id),t.span_id&&(d.spanId=t.span_id),mi(t.trace_flags)||(d.flags=t.trace_flags),d}function En(t,i,e){return mn(t,i,e)}function Pn(t,i,e,s){return{resourceLogs:[{resource:{attributes:yn(i)},scopeLogs:[{scope:{name:e,version:s},logRecords:t}]}]}}var Tn=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.hs}arm(t){this.clear(),this.us=Date.now()+t,this.hs=es(()=>{this.hs=void 0,this.ls()},t)}armNoEarlierThan(t){this.hs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function Cn(){return.75+.5*Math.random()}function Fn(t,i,e,s){const n=Math.min(Math.max(0,i-1),6),r=t*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,t)))*e)}var Mn=class{constructor(t,i,e,s,n,r=()=>Promise.resolve(),o){var l;this._instance=t,this.Mr=i,this.A=e,this.cs=s,this.ds=n,this.vs=r,this.fs=o,this.ps=new Tn(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Ye,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=i.maxBufferSize,this.Is=Math.max(null!==(l=i.maxQueueSize)&&void 0!==l?l:i.maxBufferSize,i.maxBufferSize),this.Ms=i.flushIntervalMs,this.Es=i.maxBatchRecordsPerPost,this.Ps=i.rateCapWindowMs,this.Rs=i.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(si.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,i){var e;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==t?void 0:t.body))return;const s=this.Os(t);if(null===s)return;if(!s.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const n={record:kn(s,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.cs(),this.A,null==i?void 0:i.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(t){const i=this.Mr.beforeSend;if(!i)return t;const e=fi(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.A.info("Log was rejected in beforeSend function"),null;s=i}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return s}Ds(){if(void 0===this.Rs)return!0;const t=Date.now(),i=t-this.xs;return this.Ps>i&&i>=0||(this.xs=t,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.$s=!0),!1)}flush(){var t=this;return ji(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return ji(function*(){var i;t.ps.clear();let e=null!==(i=t._instance.getPersistedProperty(si.LogsQueue))&&void 0!==i?i:[];if(0===e.length)return;const s=e.length;let n=0;for(;e.length>0&&s>n;){var r,o;const i=t._s;t.bs=0;const s=Math.min(e.length,t.Es),l=e.slice(0,s),a=Pn(l.map(t=>t.record),t.qs(),null!==(r=t.fs)&&void 0!==r?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.js(a);if(t._s!==i)return;if("too-large"===h.kind&&l.length>1)t.Es=Math.max(1,Math.floor(l.length/2)),t.A.warn(`Logs batch of size ${l.length} was too large for the ingestion endpoint, reducing batch size to ${t.Es}`);else{if(t.ws.record(h),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),"retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===h.kind&&t.Mr.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Mr.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(l.length),e=null!==(o=t._instance.getPersistedProperty(si.LogsQueue))&&void 0!==o?o:[],n+=l.length,"fatal"===h.kind)throw h.error}}})()}Bs(t){var i=this;return ji(function*(){var e;const s=Math.max(0,t-i.bs),n=null!==(e=i._instance.getPersistedProperty(si.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(si.LogsQueue,n.slice(s)),yield i.vs()})()}qs(){return En(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var i;if(this._instance.optedOut)return;const e=null!==(i=this._instance.getPersistedProperty(si.LogsQueue))&&void 0!==i?i:[];this.Is>e.length||(e.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(si.LogsQueue,e),this.Ts>e.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(Fn(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const t=this._instance.getPersistedProperty(si.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return ji(function*(){i.ps.clear();const e=i.flush().catch(()=>{});void 0!==t?yield ss(e,t):yield e})()}flushWithTimeout(t){var i=this;return ji(function*(){const e=i.flush();yield ss(e,t,()=>{e.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=Cn(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const In=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function On(t){return String(t)+"000000"}function An(t,i,e,s){let n="";return s&&(n=Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${JSON.stringify(s[t])}`).join(",")),`${t}\0${i}\0${null!=e?e:""}\0${n}`}var Rn=class{constructor(t,i,e){this._instance=t,this.Mr=i,this.A=e,this.zs=new Map,this.ps=new Tn(()=>this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Ye,this.ks=0,this.Ss=1,this.Gs=0}count(t,i=1,e){this.Zs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Zs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Zs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this;const i=this.ys,e=function(){var e=ji(function*(){i&&(yield i.catch(()=>{})),yield t.Qs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.ys===e&&(this.ys=null)});return this.ys=e,e}drainWindow(){if(0===this.zs.size)return null;const t=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(t){if(this._instance.isDisabled||this._instance.optedOut)return;const i=this.Os(t);if(null===i)return;if(!i.name||"string"!=typeof i.name)return void this.A.warn("Dropping metric with empty name");if("number"!=typeof i.value||!Number.isFinite(i.value))return void this.A.warn(`Dropping metric '${i.name}': value must be a finite number`);if("count"===i.type&&0>i.value)return void this.A.warn(`Dropping count '${i.name}': counters are monotonic, value must be >= 0`);let e,s;try{e=i.attributes?cs({},i.attributes):void 0,s=An(i.type,i.name,i.unit,e)}catch(t){return void this.A.warn(`Dropping metric '${i.name}': attributes could not be serialized`,t)}let n=this.zs.get(s);if(!n){if(!this.Ks())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.zs.set(s,n)}const r=this.Ws.get(i.name);void 0===r?this.Ws.set(i.name,i.type):r===i.type||this.Vs.has(i.name)||(this.Vs.add(i.name),this.A.warn(`Metric name '${i.name}' is already used as a ${r}; recording it as a ${i.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,i.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(t,i){switch(t.type){case"count":var e;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(In.length+1).fill(0)});const e=t.hist;e.count+=1,e.sum+=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.bucketCounts[function(t,i){for(let e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,In)]+=1;break}}}Os(t){const i=this.Mr.beforeSend;if(!i)return t;const e=fi(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.A.info("Metric was rejected in beforeSend function"),null;s=i}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return s}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(Fn(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var t=this;return ji(function*(){if(t.ps.clear(),0===t.zs.size)return;const i=t.zs;t.zs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;const e=t.Gs,s=yield t._instance.Ys(t.Js(i));if(e===t.Gs)switch(t.ws.record(s),"retry-later"===s.kind?(t.ks++,t.Ss=Cn()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.Hs()),s.kind){case"ok":return;case"retry-later":return t.uo(i),void t.ps.armNoEarlierThan(t.Hs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",s.error)}})()}Js(t){return i=this.ho(t),e=function(t,i,e){return mn(t,i,e)}(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:yn(e)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,e,s,n}ho(t){const i=On(Date.now()),e=new Map;for(const o of t.values()){var s;const t=An(o.type,o.name,o.unit,void 0);let l=e.get(t);l||(l=cs({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},e.set(t,l));const a=fn(null!==(s=o.attributes)&&void 0!==s?s:{},this.A),h=On(o.windowStartMs);if("count"===o.type){var n;const t={attributes:a,startTimeUnixNano:h,timeUnixNano:i,asDouble:null!==(n=o.total)&&void 0!==n?n:0};l.sum.dataPoints.push(t)}else if("gauge"===o.type){var r;const t={attributes:a,timeUnixNano:i,asDouble:null!==(r=o.last)&&void 0!==r?r:0};l.gauge.dataPoints.push(t)}else o.hist&&l.histogram.dataPoints.push({attributes:a,startTimeUnixNano:h,timeUnixNano:i,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:In})}return Array.from(e.values())}uo(t){for(const[s,n]of t){const t=this.zs.get(s);if(t)switch(t.windowStartMs=Math.min(t.windowStartMs,n.windowStartMs),t.type){case"count":var i,e;t.total=(null!==(i=t.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(t.hist){t.hist.count+=n.hist.count,t.hist.sum+=n.hist.sum,t.hist.min=Math.min(t.hist.min,n.hist.min),t.hist.max=Math.max(t.hist.max,n.hist.max);for(let i=0;t.hist.bucketCounts.length>i;i++)t.hist.bucketCounts[i]+=n.hist.bucketCounts[i]}else t.hist=n.hist}else this.Ks()&&this.zs.set(s,n)}}};const Dn=(t,{debugEnabled:e}={})=>{const s={N(s,...n){qt&&(i.DEBUG||qt.POSTHOG_DEBUG||e)&&!mi(qt.console)&&qt.console&&("__rrweb_original__"in qt.console[s]?qt.console[s].__rrweb_original__:qt.console[s])(t,...n)},debug(...t){s.N("debug",...t)},info(...t){s.N("log",...t)},warn(...t){s.N("warn",...t)},error(...t){s.N("error",...t)},critical(...i){console.error(t,...i)},uninitializedWarning(t){s.error(`You must initialize PostHog before calling ${t}`)},createLogger:(i,e)=>Dn(`${t} ${i}`,e)};return s},jn=Dn("[PostHog.js]"),Bn=jn.createLogger;function Nn(t,i){fi(t)&&t.forEach(i)}function Ln(t,i){if(!$i(t))if(fi(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(const e in t)ci.call(t,e)&&i(t[e],e)}const zn=function(t,...i){for(const e of i)for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t};function Hn(t){const i=Object.keys(t);let e=i.length;const s=new Array(e);for(;e--;)s[e]=[i[e],t[i[e]]];return s}const Un=function(t){return function(...i){try{return t.apply(this,i)}catch(t){jn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),jn.critical(t)}}},qn=function(t){const i={};return Ln(t,function(t,e){(bi(t)&&t.length>0||xi(t))&&(i[e]=t)}),i};function Vn(t){const i=cs({},t);for(const e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}const Wn=["herokuapp.com","vercel.app","netlify.app"];function Gn(t){const i=null==t?void 0:t.hostname;if(!bi(i))return!1;const e=i.split(".").slice(-2).join(".");for(const t of Wn)if(e===t)return!1;return!0}function Kn(t,i,e,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==t||t.addEventListener(i,e,{capture:n,passive:r})}function Jn(t){return"ph_toolbar_internal"===t.name}const Yn=t=>{if(Gt){try{const i=t+"=",e=Gt.cookie.split(";").filter(t=>t.length);for(let t=0;e.length>t;t++){let s=e[t];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return xi(t)&&isFinite(t)&&Math.floor(t)===t});var Xn=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,s,n){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(n)||0>i||0>e||0>s||0>n||i>0xffffffffffff||e>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=i/Math.pow(2,40),r[1]=i/Math.pow(2,32),r[2]=i/Math.pow(2,24),r[3]=i/Math.pow(2,16),r[4]=i/256,r[5]=i,r[6]=112|e>>>8,r[7]=e,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new t(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(let i=0;16>i;i++){const e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Zn=class{generate(){const t=this.generateOrAbort();if(!mi(t))return t;{this.Ct=0;const t=this.generateOrAbort();if(mi(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const t=(()=>{const t=Date.now();return xi(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.Mt();else{if(this.Ct>=t+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return Xn.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(2,30)-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new tr}};let Qn=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};qt&&!mi(qt.crypto)&&crypto.getRandomValues&&(Qn=t=>crypto.getRandomValues(t));var tr=class{nextUint32(){return this.Rt.length>this.Et||(Qn(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let ir;const er=()=>sr().toString(),sr=()=>(ir||(ir=new Zn)).generate();let nr="";const rr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let or=null;const lr={At(){if(!wi(or))return or;if(or=!1,Gt)try{const t=`__ph_cookie_support_${er()}`;lr.$t(t,"xyz"),or='"xyz"'===Yn(t),lr.Lt(t)}catch(t){or=!1}return or},Pt(t){jn.error("cookieStore error: "+t)},Ot:Yn,Dt(t){let i;try{i=JSON.parse(lr.Ot(t))||{}}catch(t){}return i},$t(t,i,e,s,n){if(!Gt)return!1;try{let r="",o="";const l=function(t,i){if(i){let i=function(t,i=Gt){if(nr)return nr;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";const e=t.split(".");let s=Math.min(e.length,8);const n="dmn_chk_"+er();for(;!nr&&s--;){const t=e.slice(s).join("."),r=n+"=1;domain=."+t+";path=/";i.cookie=r+";max-age=3",i.cookie.includes(n)&&(i.cookie=r+";max-age=0",nr=t)}return nr}(t);if(!i){const e=(t=>{const i=t.match(rr);return i?i[0]:""})(t);e!==i&&jn.info("Warning: cookie subdomain discovery mismatch",e,i),i=e}return i?"; domain=."+i:""}return""}(Gt.location.hostname,s);if(e){const t=new Date;t.setTime(t.getTime()+864e5*e),r="; expires="+t.toUTCString()}n&&(o="; secure");const a=t+"="+encodeURIComponent(JSON.stringify(i))+r+"; SameSite=Lax; path=/"+l+o;return a.length>3686.4&&jn.warn("cookieStore warning: large cookie, len="+a.length),Gt.cookie=a,!0}catch(t){return!1}},Lt(t,i){if((null==Gt?void 0:Gt.cookie)&&(!i||!wi(Yn(t))))try{lr.$t(t,"",-1,i)}catch(t){return}}};let ar=null;const hr={At(){if(!wi(ar))return ar;let t=!0;if(mi(qt))t=!1;else try{const i="__mplssupport__";hr.$t(i,"xyz"),'"xyz"'!==hr.Ot(i)&&(t=!1),hr.Lt(i)}catch(i){t=!1}return t||jn.error("localStorage unsupported; falling back to cookie store"),ar=t,t},Pt(t){jn.error("localStorage error: "+t)},Ot(t){try{return null==qt?void 0:qt.localStorage.getItem(t)}catch(t){hr.Pt(t)}return null},Dt(t){try{return JSON.parse(hr.Ot(t))||{}}catch(t){}return null},$t(t,i){try{return null==qt||qt.localStorage.setItem(t,JSON.stringify(i)),!0}catch(t){hr.Pt(t)}return!1},Lt(t){try{null==qt||qt.localStorage.removeItem(t)}catch(t){hr.Pt(t)}}},ur=[K,L,N,H,U,q,ct,dt,ht],dr=[r,n,I,O,bt,mt,u,vt],cr=t=>t+"_cpm",vr=["__proto__","constructor","prototype"],fr=t=>{if(!gi(t))return{};const i={};return Object.keys(t).forEach(e=>{-1===vr.indexOf(e)&&(i[e]=t[e])}),i},pr=(t,i=[])=>{const e={};return[...dr,...i].forEach(i=>{const s=t[i];mi(s)||wi(s)||""===s||(e[i]=s)}),e},gr=t=>{let i=5381,e=2166136261;for(let s=0;t.length>s;s++){const n=t.charCodeAt(s);i=33*i^n,e=Math.imul(e^n,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},_r=(t,i)=>({p:i,f:gr(JSON.stringify(t))}),mr=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{const e=lr.Dt(cr(t)),s=(null==e?void 0:e.f)===gr(i)&&fi(e.p);return{properties:s?e.p:[],isValid:s}}catch(t){return{properties:[],isValid:!1}}},br=(t,i)=>i+"|"+(lr.Ot(cr(t))||""),yr={},wr={At:()=>!0,Pt(t){jn.error("memoryStorage error: "+t)},Ot:t=>t in yr?yr[t]:null,Dt:t=>t in yr?yr[t]:null,$t:(t,i)=>(yr[t]=i,!0),Lt(t){delete yr[t]}};let $r=null;const xr={At(){if(!wi($r))return $r;if($r=!0,mi(qt))$r=!1;else try{const t="__support__";xr.$t(t,"xyz"),'"xyz"'!==xr.Ot(t)&&($r=!1),xr.Lt(t)}catch(t){$r=!1}return $r},Pt(t){jn.error("sessionStorage error: ",t)},Ot(t){try{return null==qt?void 0:qt.sessionStorage.getItem(t)}catch(t){xr.Pt(t)}return null},Dt(t){try{return JSON.parse(xr.Ot(t))||null}catch(t){}return null},$t(t,i){try{return null==qt||qt.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(t){xr.Pt(t)}return!1},Lt(t){try{null==qt||qt.sessionStorage.removeItem(t)}catch(t){xr.Pt(t)}}};var Sr=class{constructor(t){this._instance=t}get Mr(){return this._instance.config}get consent(){return this.Oo()?0:this.Do}isOptedOut(){return"always"===this.Mr.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Mr.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Mr.opt_out_capturing_by_default}optInOut(t){this.Lo.$t(this.No,t?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.Lo.Lt(this.No,this.Mr.cross_subdomain_cookie)}get No(){const{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get Do(){const t=this.Lo.Ot(this.No);return Ai(t)?1:li(Ri,t)?0:-1}get Lo(){const t=this.Mr.opt_out_capturing_persistence_type,i="localStorage"===t?hr:lr,e=i.At()?i:wr;if(!this.qo||this.qo!==e){this.qo=e;const i="localStorage"===t?lr:hr;i.Ot(this.No)&&(this.qo.Ot(this.No)||this.optInOut(Ai(i.Ot(this.No))),i.Lt(this.No,this.Mr.cross_subdomain_cookie))}return this.qo}Oo(){return!!this.Mr.respect_dnt&&[null==Wt?void 0:Wt.doNotTrack,null==Wt?void 0:Wt.msDoNotTrack,ei.doNotTrack,null==Wt?void 0:Wt.globalPrivacyControl].some(t=>Ai(t))}};function kr(t,i){var e;const s=null==t||null===(e=t.config)||void 0===e?void 0:e.get_current_url;if(!pi(s))return i;try{const t=s(i);return bi(t)&&t?t:i}catch(t){return jn.error("Error in get_current_url, falling back to window.location.href",t),i}}function Er(t){var i;return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!!(null===(i=t.closest)||void 0===i?void 0:i.call(t,".toolbar-global-fade-container")))}function Pr(t){return!!t&&1===t.nodeType}function Tr(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Cr(t){return!!t&&3===t.nodeType}function Fr(t){return!!t&&11===t.nodeType&&Pr(t.host)}function Mr(t){return t?ai(t).split(/\s+/):[]}function Ir(t,i){const e=function(t){var i;const e=null==qt||null===(i=qt.location)||void 0===i?void 0:i.href;return mi(e)?void 0:kr(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Or(t){let i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return Mr(i)}function Ar(t){return $i(t)?null:ai(t).split(/(\s+)/).filter(t=>ro(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Rr(t){let i="";return Yr(t)&&!Xr(t)&&t.childNodes&&t.childNodes.length&&Ln(t.childNodes,function(t){var e;Cr(t)&&t.textContent&&(i+=null!==(e=Ar(t.textContent))&&void 0!==e?e:"")}),ai(i)}function Dr(t){var i;return mi(t.target)?t.srcElement||null:(null===(i=t.target)||void 0===i?void 0:i.shadowRoot)?t.composedPath()[0]||null:t.target||null}const jr=["a","button","form","input","select","textarea","label"];function Br(t,i){const e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function Nr(t,i){if(mi(i))return!0;for(const e of t)if(i.some(t=>Br(e,t)))return!0;return!1}function Lr(t){const i=t.parentNode;return!(!i||!Pr(i))&&i}const zr=[".ph-no-autocapture","[data-ph-no-autocapture]"],Hr=["next","previous","prev",">","<"],Ur=[...Hr,"+","-","−","–"],qr=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Vr=[".ph-no-rageclick",".ph-no-capture"],Wr=["","text","search","email","password","url","tel","number"];function Gr(t,i){if(!qt||Kr(t))return!1;let e,s,n;var r,o;if(ki(i)?(e=!!i&&Vr,s=void 0,n=!1):(e=null!==(r=null==i?void 0:i.css_selector_ignorelist)&&void 0!==r?r:Vr,s=null==i?void 0:i.content_ignorelist,n=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(n&&function(t){return!(!t||!Pr(t))&&(!!Tr(t,"textarea")||(Tr(t,"input")?li(Wr,(t.getAttribute("type")||"").toLowerCase()):function(t){var i;if(t.isContentEditable)return!0;const e=null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"contenteditable");return"true"===e||""===e}(t)))}(t))return!1;const{targetElementList:l}=Jr(t,!1);return!function(t,i){if(!1===t||mi(t))return!1;let e;if(!0===t)e=Hr;else{if(!fi(t))return!1;if(t.length>10)return jn.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(({safeText:t,ariaLabel:i})=>e.some(e=>qr(t,e)||qr(i,e)))}(s,l.map(t=>{var i;return{safeText:Rr(t).toLowerCase(),ariaLabel:(null===(i=t.getAttribute("aria-label"))||void 0===i?void 0:i.toLowerCase().trim())||""}}))&&!Nr(l,e)}const Kr=t=>!t||Tr(t,"html")||!Pr(t),Jr=(t,i)=>{if(!qt||Kr(t))return{parentIsUsefulElement:!1,targetElementList:[]};let e=!1;const s=[t];let n=t;for(;n.parentNode&&!Tr(n,"body");){if(Fr(n.parentNode)){s.push(n.parentNode.host),n=n.parentNode.host;continue}const t=Lr(n);if(!t)break;if(i||jr.indexOf(t.tagName.toLowerCase())>-1)e=!0;else try{const i=qt.getComputedStyle(t);i&&"pointer"===i.getPropertyValue("cursor")&&(e=!0)}catch(t){}s.push(t),n=t}return{parentIsUsefulElement:e,targetElementList:s}};function Yr(t){const i=new Set;let e=0;for(let s=t;s.parentNode&&!Tr(s,"body");s=s.parentNode){if(e++>=1e3||i.has(s))return!1;i.add(s);const t=Or(s);if(li(t,"ph-sensitive")||li(t,"ph-no-capture"))return!1}if(li(Or(t),"ph-include"))return!0;const s=t.type||"";if(bi(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=t.name||t.id||"";return!bi(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Xr(t){return!!(Tr(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Tr(t,"select")||Tr(t,"textarea")||"true"===t.getAttribute("contenteditable"))}const Zr=new RegExp("^(?:(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}))$"),Qr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,to=[16,15,14,13],io=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),eo=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),so=/[0-9A-Za-z_]/;function no(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function ro(t,i=!0){if($i(t))return!1;if(bi(t)){if(t=ai(t),i?Zr.test((t||"").replace(/[- ]/g,"")):function(t){let i;for(Qr.lastIndex=0;i=Qr.exec(t);){const t=i[2];if(!t)continue;const e=t.replace(/[- ]/g,"");for(let t=0;e.length>t;t++)for(const i of to){const s=t+i;if(e.length>=s){const i=e.slice(t,s);if(Zr.test(i)&&no(i))return!0}}}return!1}(t))return!1;if(i?io.test(t):function(t){let i;for(eo.lastIndex=0;i=eo.exec(t);){const t=i[1],e=i[3];if(!(t&&e&&so.test(t)&&so.test(e)))return!0}return!1}(t))return!1}return!0}function oo(t){let i=Rr(t);return i=`${i} ${lo(t)}`.trim(),ro(i)?i:""}function lo(t){let i="";return t&&t.childNodes&&t.childNodes.length&&Ln(t.childNodes,function(t){var e;if(t&&"span"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()))try{const e=Rr(t);i=`${i} ${e}`.trim(),t.childNodes&&t.childNodes.length&&(i=`${i} ${lo(t)}`.trim())}catch(t){jn.error("[AutoCapture]",t)}}),i}function ao(t){return t.replace(/"|\\"/g,'\\"')}function ho(t){const i=t.attr__class;if(i)return fi(i)?i:Mr(i)}const uo=Bn("[Dead Clicks]"),co=()=>!0,vo=t=>{var i;const e=!!(null===(i=t.instance.persistence)||void 0===i?void 0:i.get_property(y)),s=t.instance.config.capture_dead_clicks;return ki(s)?s:!!gi(s)||e};var fo=class{get lazyLoadedDeadClicksAutocapture(){return this.jo}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[y]:i.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Bo(()=>{this.Ho()}):this.stop()}Bo(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.initDeadClicksAutocapture)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this.instance,"dead-clicks-autocapture",i=>{i?uo.error("failed to load script",i):t()})}Ho(){var t;if(Gt){if(!this.jo&&(null===(t=ei.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)){const t=gi(this.instance.config.capture_dead_clicks)?cs({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.jo=ei.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.jo.start(Gt),uo.info("starting...")}}else uo.error("`document` not found. Cannot start.")}stop(){this.jo&&(this.jo.stop(),this.jo=void 0,uo.info("stopping..."))}};const po=Bn("[SegmentIntegration]");function go(t,i,e=!0){const s=t.config.segment;if(!s)return i();const{analytics:n,filterProperties:r}=(t=>pi(t.register))(o=s)?{analytics:o}:o;var o;!function(t,i,e,s){const n=i=>{const n=()=>i.anonymousId()||er();t.config.get_device_id=n,s&&i.id()&&(t.register({distinct_id:i.id(),$device_id:n()}),t.persistence.set_property(vt,Dt)),e(s?void 0:i.anonymousId()||void 0)},r=i.user();"then"in r&&pi(r.then)?r.then(n):n(r)}(t,n,e=>{n.register(((t,i,{filterProperties:e}={})=>{"undefined"!=typeof Promise&&Promise.resolve||po.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!i&&s.event.anonymousId===i&&!s.event.userId;r||s.event.userId||s.event.anonymousId===t.get_distinct_id()||(po.info("No userId set, resetting PostHog"),t.reset()),r||(i=void 0),s.event.userId&&s.event.userId!==t.get_distinct_id()&&(po.info("UserId set, identifying with PostHog"),t.identify(s.event.userId));let o=t.calculateEventProperties(n,s.event.properties);if(!$i(e)){const t=s.event.properties||{},i={};for(const e of Object.keys(o))ci.call(t,e)||(i[e]=o[e]);const n=((t,i)=>{const e=fi(t)?t:[t];let s=cs({},i);for(const t of e)try{if(s=t(s),$i(s))return null}catch(t){return po.error("Error in Segment filterProperties:",t),null}return s})(e,i);if($i(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return s(t,t.event.event)},page(t){return s(t,Lt)},identify(t){return s(t,Ht)},screen(t){return s(t,"$screen")}}})(t,e,{filterProperties:r})).then(()=>{i()},t=>{po.error("Failed to register the Segment integration",t),i()})},e)}const _o="posthog-js";function mo(t,{organization:i,projectId:e,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var l,a,h,u,d;if("*"!==n&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});const c=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=c,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const v=(null===(l=o.exception)||void 0===l?void 0:l.values)||[],f=v.map(t=>cs(cs({},t),{},{stacktrace:t.stacktrace?cs(cs({},t.stacktrace),{},{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>cs(cs({},t),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:(null===(a=v[0])||void 0===a?void 0:a.value)||o.message,$exception_type:null===(h=v[0])||void 0===h?void 0:h.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=v[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=v[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var g;return i&&e&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+e+"&query="+o.event_id),r&&(null===(g=t.exceptions)||void 0===g||g.sendExceptionEvent(p)),o}}var bo=class{constructor(t,i,e,s,n,r){this.name=_o,this.setupOnce=function(o){o(mo(t,{organization:i,projectId:e,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},yo=class{constructor(t){this.zo=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(jn.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Uo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Wo()}Wo(){var t;this.Vo=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.onSessionId(this.zo)}destroy(){var t;null===(t=this.Vo)||void 0===t||t.call(this),this.Vo=void 0}doPageView(t,i){var e;const s=this.Go(t,i);return this.Uo={pathname:null!==(e=null==qt?void 0:qt.location.pathname)&&void 0!==e?e:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var i;return this.Go(t,null===(i=this.Uo)||void 0===i?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null===(t=this.Uo)||void 0===t?void 0:t.pageViewId}}Go(t,i){const e=this.Uo;if(!e)return{$pageview_id:i};let s={$pageview_id:i,$prev_pageview_id:e.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:t,lastScrollY:i,maxScrollY:e,maxContentHeight:r,lastContentY:o,maxContentY:l}=n;if(!(mi(t)||mi(i)||mi(e)||mi(r)||mi(o)||mi(l))){t=Math.ceil(t),i=Math.ceil(i),e=Math.ceil(e),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l);const n=t>1?Li(i/t,0,1,jn):1,a=t>1?Li(e/t,0,1,jn):1,h=r>1?Li(o/r,0,1,jn):1,u=r>1?Li(l/r,0,1,jn):1;s=zn(s,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:e,$prev_pageview_max_scroll_percentage:a,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:l,$prev_pageview_max_content_percentage:u})}}return e.pathname&&(s.$prev_pageview_pathname=e.pathname),e.timestamp&&(s.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),s}};const wo=["flags","surveys"],$o={[s]:{exposure:"hidden"},[l]:{exposure:"hidden"},[a]:{exposure:"hidden"},[v]:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"hidden"},[f]:{exposure:"event"},[p]:{exposure:"hidden"},[x]:{exposure:"hidden"},[g]:{exposure:"event"},[_]:{exposure:"hidden"},[m]:{exposure:"event"},[b]:{exposure:"event"},[y]:{exposure:"event"},[w]:{exposure:"hidden"},[S]:{exposure:"event"},[k]:{exposure:"hidden"},[E]:{exposure:"hidden"},[I]:{exposure:"hidden"},[O]:{exposure:"event"},[P]:{exposure:"event",shouldSkipFromEventProperties:t=>wi(t)},[A]:{exposure:"event"},[R]:{exposure:"event"},[D]:{exposure:"event"},[j]:{exposure:"event"},[B]:{exposure:"hidden"},[N]:{exposure:"hidden",storageGroup:"flags"},[L]:{exposure:"hidden",storageGroup:"flags"},[z]:{exposure:"hidden"},[H]:{exposure:"hidden",storageGroup:"flags"},[U]:{exposure:"hidden",storageGroup:"flags"},[q]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[V]:{exposure:"hidden",storageGroup:"flags"},[W]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[X]:{exposure:"hidden",storageGroup:"surveys"},[Z]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Q]:{exposure:"event"},[tt]:{exposure:"hidden"},[it]:{exposure:"hidden"},[et]:{exposure:"hidden"},[st]:{exposure:"hidden"},[nt]:{exposure:"hidden"},[rt]:{exposure:"event"},[ot]:{exposure:"event"},[lt]:{exposure:"event"},[at]:{exposure:"event"},[ht]:{exposure:"hidden"},[ut]:{exposure:"hidden"},[Y]:{exposure:"event"},[dt]:{exposure:"hidden"},[ct]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[vt]:{exposure:"hidden"},[ft]:{exposure:"hidden"},[pt]:{exposure:"hidden"},[gt]:{exposure:"hidden"},[_t]:{exposure:"hidden"},[mt]:{exposure:"hidden"},[bt]:{exposure:"hidden"},[T]:{exposure:"event"},[C]:{exposure:"event"},[F]:{exposure:"event"},[M]:{exposure:"event"},[$t]:{exposure:"event"},[xt]:{exposure:"event"},[St]:{exposure:"hidden"},[kt]:{exposure:"hidden"},[Et]:{exposure:"hidden"},[Pt]:{exposure:"hidden"},[Tt]:{exposure:"hidden"},[Ct]:{exposure:"hidden"},[Ft]:{exposure:"hidden"},[Mt]:{exposure:"hidden"},[It]:{exposure:"hidden"},[Ot]:{exposure:"event"}},xo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],So=t=>{const i=$o[t];if(i)return i;for(const[i,e]of xo)if(0===t.indexOf(i))return e},ko=(t,i)=>{try{let e;return JSON.stringify(t,(t,i)=>{var s;return Fi(i)?(null!==(s=e)&&void 0!==s||(e=new WeakMap),e.has(i)||e.set(i,Vn(i)),e.get(i)):"bigint"==typeof i?i.toString():i},i)}catch(i){return ui(t)}},Eo=t=>{const i=null==Gt?void 0:Gt.createElement("a");return mi(i)?null:(i.href=t,i)},Po=function(t,i){const e=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let t=0;e.length>t;t++){const n=e[t].split("=");if(n[0]===i){s=n;break}}if(!fi(s)||2>s.length)return"";{let t=s[1];try{t=decodeURIComponent(t)}catch(i){jn.error("Skipping decoding for malformed query param: "+t)}return t.replace(/\+/g," ")}},To=function(t,i,e){if(!t||!i||!i.length)return t;const s=t.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],l=r[0],a=(o||"").split("&"),h=[];for(let t=0;a.length>t;t++){const s=a[t].split("=");fi(s)&&(i.includes(s[0])?h.push(s[0]+"="+e):h.push(a[t]))}let u=l;return null!=o&&(u+="?"+h.join("&")),null!=n&&(u+="#"+n),u},Co=function(t,i){const e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Fo=(t,i)=>t>=i&&ti(),Mo=(t,i,e,s)=>{if(0===t){if(ti()){const t=i+1;return t===e&&s(),t}return i}return 0},Io=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Oo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Io],Ao="<masked>",Ro=["li_fat_id"];function Do(t,i,e){if(!Gt)return{};const s=i?[...Io,...e||[]]:[],n=jo(To(Gt.URL,s,Ao),t),r=function(){const t={};return Ln(Ro,function(i){const e=Yn(i);t[i]=e||null}),t}();return zn(r,n)}function jo(t,i){const e=Oo.concat(i||[]),s={};return Ln(e,function(i){const e=Po(t,i);s[i]=e||null}),s}function Bo(t){const i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",s={};if(!wi(i)){s.$search_engine=i;const t=Gt?Po(Gt.referrer,e):"";t.length&&(s.ph_keyword=t)}return s}function No(){return navigator.language||navigator.userLanguage}function Lo(){const t=No();return"string"==typeof t?t.split("-")[0]:void 0}const zo="$direct";function Ho(){return(null==Gt?void 0:Gt.referrer)||zo}function Uo(t,i,e=!1){const s=t?[...Io,...i||[]]:[],n=e?ts(null==Kt?void 0:Kt.href):null==Kt?void 0:Kt.href,r=null==n?void 0:n.substring(0,1e3);return{r:Ho().substring(0,1e3),u:r?To(r,s,Ao):void 0}}function qo(t,i=!1){var e;const{r:s,u:n}=t,r=i?ts(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==zo?zo:null===(e=Eo(s))||void 0===e?void 0:e.host};if(r){o.$current_url=r;const t=Eo(r);o.$host=null==t?void 0:t.host,o.$pathname=null==t?void 0:t.pathname;const i=jo(r);zn(o,i)}if(s){const t=Bo(s);zn(o,t)}return o}function Vo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function Wo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}const Go={flags:ct,surveys:Z},Ko=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Jo=t=>`${t}_cookie_identity_change_pending`,Yo=t=>{let i="",e=0;for(const s of t){const t=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(e+t>1e3)break;i+=s,e+=t}return i},Xo="main",Zo=[N,L,H,U,q,ct,V,K],Qo=t=>-1!==Zo.indexOf(t),tl=[u,c],il=t=>-1!==tl.indexOf(t),el=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},sl=t=>{if(!t)return{};const i=JSON.parse(t);return gi(i)?i:{}},nl=(t,i)=>{Ln(t,(e,s)=>{const n=So(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(i,s)||delete t[s]})};var rl=class{constructor(t,i,e=!0){if(this.Zo={},this.Qo=!1,this.Jo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=new Map,this.ea=!1,this.ia=!1,this.na=!1,this.sa=new Set,this.ra=new Set,this.Mr=t,this.oa=e,this.props={},this.aa=void 0,this.la=(t=>{let i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(t),this.hi=t.disable_persistence||!!i,this.Lo=this.ua(t),this.Ko=this.ha(t),this.load(),this.ca(),t.debug&&jn.info("Persistence loaded",t.persistence,cs({},this.props)),this.update_config(t,t,i),this.save(),qt){const t=()=>this.flush();Kn(qt,"beforeunload",t,{capture:!1}),Kn(qt,"pagehide",t,{capture:!1}),this.da=t=>{if(this.Qo&&(!t.storageArea||t.storageArea===(null==qt?void 0:qt.localStorage))&&t.key)if(t.key!==this.la){if(this.Ko){const i=wo.find(i=>t.key===this.va(i));i&&this.fa(t.key,i)}}else this.fa(t.key,Xo)},Kn(qt,"storage",this.da)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([t,i])=>{const e=this.ta.get(t);if(!Qo(t)||!0===e)return;if(!0===i)return void this.pa(t,!0);const s=new Set(e||[]);i.forEach(t=>s.add(t)),s.size&&this.pa(t,s)})}onCrossTabFeatureFlagChange(t){return this.ra.add(t),()=>this.ra.delete(t)}destroy(){this.da&&qt&&(qt.removeEventListener("storage",this.da),this.da=void 0),this.ra.clear()}fa(t,i,e=!0){if(this.hi)return!1;let s,n;try{if(n=hr.Ot(t),wi(n)){const t=this.ga(i);return t.storageValue=null,i!==Xo&&(t.persisted=!1),!1}s=sl(n)}catch(t){return!1}const r=i===Xo?s:hr.Dt(this.la);if(r&&this.ma(r))return!1;const o=this.ya(s,i,e);return i===Xo&&this.Ko&&!el(this.ba().main,s)||this._a(s,i,!0,n),o}ma(t){const i=this.props[n],e=t[n];return!mi(i)&&!mi(e)&&i!==e}_a(t,i,e,s){const n=this.ga(i);n.storageValue=s,i!==Xo&&(n.persisted=e);try{n.fingerprint=this.wa(t,i)}catch(t){n.fingerprint=void 0}}ya(t,i,e){let s=!1;return Zo.forEach(e=>{var n;const r=null===(n=So(e))||void 0===n?void 0:n.storageGroup;if(i===Xo&&this.Ko&&r||i!==Xo&&r!==i)return;const o=e in t,l=this.ka(e,o?t[e]:void 0),a=this.ta.has(e)?e in this.props:o;a===e in this.props&&el(l,this.props[e])||(a?this.Sa(e,l,!1):this.xa(e,!1),s=!0)}),s&&e&&this.ra.forEach(t=>t()),s}Ca(){if(!this.Qo)return!1;try{this.na=!1;const t=hr.Ot(this.la),i=this.ga(Xo);let e,s=!1,n=!1;if(t!==i.storageValue)if(wi(t))i.storageValue=null;else{if(e=sl(t),this.na=!this.ia&&this.ma(e),this.na)return!1;n=this.ya(e,Xo,!1),!this.Ko||el(this.ba().main,e)?this._a(e,Xo,!0,t):i.storageValue=t,s=!0}return this.Ko&&wo.forEach(t=>{const i=hr.Ot(this.va(t)),r=this.ga(t),o=e||{},l=s&&Zo.some(i=>{var e;return(null===(e=So(i))||void 0===e?void 0:e.storageGroup)===t&&i in o});if(i===r.storageValue&&!l)return;if(wi(i))return r.storageValue=null,r.persisted=!1,void(l&&(n=this.ya(o,t,!1)||n));const a=sl(i);n=this.ya(a,t,!1)||n,this._a(a,t,!0,i)}),n}catch(t){return!1}}pa(t,i){this.ta.set(t,i);const e=So(t);(null==e?void 0:e.volatile)||(this.ga((this.Ko?null==e?void 0:e.storageGroup:void 0)||Xo).fingerprint=void 0,this.$a(t))}Ta(){Zo.forEach(t=>this.ta.set(t,!0))}ca(){if(this.Qo)try{const t=hr.Ot(this.la),i=sl(t);this.ga(Xo).storageValue=t,Zo.forEach(t=>{var e;const s=this.Ko?null===(e=So(t))||void 0===e?void 0:e.storageGroup:void 0,n=s?hr.Ot(this.va(s)):null;if(s){const t=this.ga(s);t.storageValue=n,t.persisted=!wi(n)}const r=s&&!wi(n)?sl(n):i;t in this.props?this.Ia(t,r[t],this.props[t]):t in r&&this.pa(t,!0)})}catch(t){}}ka(t,i){const e=this.ta.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){const s=new Set(fi(i)?i:[]),n=new Set(fi(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}const s=gi(i)?cs({},i):{},n=gi(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in n?s[t]=n[t]:delete s[t]}),s}Ia(t,i,e){if(!Qo(t))return;const s=this.ta.get(t);if(!0===s)return;let n=i;if(this.Qo)try{var r;const i=this.Ko?null===(r=So(t))||void 0===r?void 0:r.storageGroup:void 0,e=i?this.va(i):this.la;n=sl(hr.Ot(e))[t]}catch(t){}const o=new Set(s||[]);if("$active_feature_flags"===t){if(!mi(i)&&!fi(i)||!mi(n)&&!fi(n)||!fi(e))return void this.pa(t,!0);const s=new Set(i||[]),r=new Set(n||[]),l=new Set(e);new Set([...s,...l]).forEach(t=>{s.has(t)!==l.has(t)&&o.add(t)}),o.forEach(t=>{r.has(t)===l.has(t)&&o.delete(t)})}else{if(!gi(e))return void(el(n,e)?this.ta.delete(t):this.pa(t,!0));{if(!mi(i)&&!gi(i)||mi(i)&&_i(e)&&mi(n))return void this.pa(t,!0);const s=gi(i)?i:{},r=gi(n)?n:{};new Set([...Object.keys(s),...Object.keys(e)]).forEach(t=>{t in s==t in e&&el(s[t],e[t])||o.add(t)}),o.forEach(t=>{t in r==t in e&&el(r[t],e[t])&&o.delete(t)})}}o.size?this.pa(t,o):this.ta.delete(t)}Ma(){var t;const i=null===(t=this.Mr)||void 0===t?void 0:t.persistence_save_debounce_ms;return xi(i)&&i>0?i:0}Ea(t){if(this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase())if(t)try{const i=pr(t,this.Mr.cookie_persisted_properties||[]),e=_r(i,this.Mr.cookie_persisted_properties||[]),s=JSON.stringify(i)+"|"+JSON.stringify(e),n=lr.Ot(this.la)||void 0;n&&br(this.la,n)===s&&(this.Pa=s,this.Ra=n)}catch(t){}else try{const t=lr.Ot(this.la)||void 0;this.Pa=t?br(this.la,t):void 0,this.Ra=t}catch(t){}}syncCookieProperties(){return this.Aa(this.Mr)}Aa(t,i=!1){if(this.hi&&!i||this.Yo||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;let e;try{e=lr.Ot(this.la)||void 0}catch(t){}if(!e||e===this.Ra)return!1;const s=br(this.la,e);let r;try{r=fr(JSON.parse(e))}catch(t){return!1}if((lr.Ot(this.la)||void 0)!==e)return!1;this.Pa=s,this.Ra=e;const o=mr(this.la,e),a=[...dr,...o.properties],h={};if(Object.keys(r).forEach(t=>{const i=r[t];(mi(i)||wi(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(h[t]=!0,delete r[t])}),_i(r))return!1;const u="distinct_id"in r||"anonymous"===r.$user_state||"identified"===r.$user_state,d=this.props,c=d[n],v=d[vt],f=zn({},d);[...dr,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==a.indexOf(t)&&!(t in r)&&!h[t]&&(u||"distinct_id"!==t&&"$user_state"!==t)){const i=f[t];(o.isValid||-1===dr.indexOf(t)||!1!==i&&0!==i)&&delete f[t]}}),this.props=zn(f,r),Zo.forEach(t=>{const i=t in this.props;t in d===i&&el(d[t],this.props[t])||(i?this.Ia(t,d[t],this.props[t]):this.pa(t,!0))}),!u||"$user_state"in r||"$user_state"in this.props||this.Sa(vt,Rt);const p=this.props[n],g=this.props[vt];return!u||p===c&&g===v||(this.ia=!0,this.Xo=!0,xr.$t(Jo(this.la),!0),this.xa(K),this.xa(L),this.xa(N),this.xa(H),this.xa(U),this.xa(q),this.xa(ct),this.xa(dt),this.xa(ht),"anonymous"!==g||"identified"!==v&&"anonymous"!==r.$user_state&&(mi(c)||p===c)||(nl(this.props,r),this.xa(J)),"identified"===g?this.props.$user_id=p:delete this.props.$user_id,this.xa(l)),!0}consumeCookieIdentityChange(){const t=Jo(this.la),i=this.Xo||!!xr.Ot(t);return this.Xo=!1,i&&xr.Lt(t),i}Fa(t=!1){return!(this.Yo||this.hi&&!t||!this.Mr.cookieWinsOnConflict||"localstorage+cookie"!==this.Mr.persistence.toLowerCase()||(this.Yo=!0,0))}Oa(){this.Yo&&(mi(this.Da)||(clearTimeout(this.Da),this.Da=void 0),delete this.Zo[Xo],this.La(!0))}Na(t=!0){if(this.Yo)try{t?this.Oa():mi(this.Da)||(clearTimeout(this.Da),this.Da=void 0)}finally{this.Yo=!1}}isDisabled(){return!!this.hi}ua(t){-1===Ko.indexOf(t.persistence.toLowerCase())&&(jn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");const i=((t=[],i=!1)=>{const e=[...dr,...t];return cs(cs({},hr),{},{Dt(t){try{let r,o={};try{r=lr.Ot(t)||void 0,o=r?fr(JSON.parse(r)):{}}catch(t){}const l=JSON.parse(hr.Ot(t)||"{}");let a;if(i){const i=mr(t,r),h=[...dr,...i.properties],u={};Object.keys(o).forEach(t=>{const i=o[t];wi(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(u[t]=i)});const d="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var s;const t=l[n],r=null!==(s=l.$user_state)&&void 0!==s?s:Rt;e.forEach(t=>{if(-1!==h.indexOf(t)&&!(t in o)&&(d||"distinct_id"!==t&&"$user_state"!==t)){const e=l[t];(i.isValid||-1===dr.indexOf(t)||!1!==e&&0!==e)&&delete l[t]}}),!d||"$user_state"in o||"$user_state"in l||(l[vt]=Rt),!d||("distinct_id"in u?u[n]:l[n])===t&&("$user_state"in u?u[vt]:l[vt])===r||(ur.forEach(t=>delete l[t]),"identified"===u.$user_state&&"distinct_id"in u?l.$user_id=u[n]:delete l.$user_id,"identified"!==u.$user_state&&(delete l[Y],delete l[J]),delete l.__alias)}a=zn(l,u)}else a=zn(o,l);return hr.$t(t,a),a}catch(t){}return null},$t(e,s,n,r,o,l){const a=hr.$t(e,s,void 0,void 0,l);try{const h=pr(s,t);if(Object.keys(h).length){if(i){const i=cr(e),u=_r(h,t);if(lr.$t(i,u,n,r,o,l),lr.Ot(i)!==JSON.stringify(u)){lr.Lt(i,r);const t=pr(s);return lr.$t(e,t,n,r,o,l),a}}lr.$t(e,h,n,r,o,l)}}catch(t){hr.Pt(t)}return a},Lt(t,i){try{null==qt||qt.localStorage.removeItem(t),lr.Lt(t,i),lr.Lt(cr(t),i)}catch(t){hr.Pt(t)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict);let e,s=!1,r=!1;const o=t.persistence.toLowerCase();return"localstorage"===o&&hr.At()?(e=hr,r=!0):"localstorage+cookie"===o&&i.At()?(e=i,r=!0,s=!0):"sessionstorage"===o&&xr.At()?e=xr:"memory"===o?e=wr:"cookie"===o&&lr.At()?(e=lr,s=!0):i.At()?(e=i,r=!0,s=!0):lr.At()?(e=lr,s=!0):e=wr,this.Qo=r,this.Jo=s,e}va(t){return`${this.la}__${t}`}ha(t){return this.Qo&&!!t.split_storage}properties(){const t={};return Ln(this.props,(i,e)=>{const s=So(e);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,i))return;t[e]=i}}),t}load(t=!1){if(this.hi&&!t)return;const i=this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase(),e=i?hr.Dt(this.la):null;let s={};if(i)try{s=fr(lr.Dt(this.la)),Ln(s,(t,i)=>{(mi(t)||wi(t)||""===t)&&delete s[i]})}catch(t){}const r=this.Lo.Dt(this.la);if(r&&(this.props=zn({},r)),this.Ko&&this.qa(),i&&r){var o,l;const t=null==e?void 0:e[n],i=null!==(o=null==e?void 0:e.$user_state)&&void 0!==o?o:Rt,a=r[n],h=null!==(l=r.$user_state)&&void 0!==l?l:Rt;if(a!==t||h!==i){this.Xo=!0,xr.$t(Jo(this.la),!0);const e=zn({},this.props);ur.forEach(t=>delete e[t]),"anonymous"!==h||"identified"!==i&&"anonymous"!==s.$user_state&&(mi(t)||a===t)||(nl(e,s),delete e[J]),this.props=e;const n=new Set;ur.forEach(t=>{var i;const e=null===(i=So(t))||void 0===i?void 0:i.storageGroup;e&&n.add(e)}),n.forEach(t=>{const i={};Ln(this.props,(e,s)=>{var n;(null===(n=So(s))||void 0===n?void 0:n.storageGroup)===t&&(i[s]=e)}),_i(i)?(hr.Lt(this.va(t)),this.Zo[t]={}):hr.$t(this.va(t),i)&&(this.Zo[t]={persisted:!0,fingerprint:this.wa(i,t)})})}}xr.Ot(Jo(this.la))&&(this.Xo=!0)}qa(){for(const t of wo){const i=hr.Dt(this.va(t));if(i&&!_i(i)){const e=this.ga(t);e.persisted=!0,this.ja(t)||(e.fingerprint=this.wa(i,t)),this.Ba(t,i)||zn(this.props,i)}}}ja(t){return Object.keys(this.props).some(i=>{var e;return(null===(e=So(i))||void 0===e?void 0:e.storageGroup)===t})}Ba(t,i){const e=Go[t];if(!e)return!1;const s=i[e],n=this.props[e];return xi(s)&&xi(n)&&n>s}refreshKey(t){var i;if(this.hi)return;if(this.sa.has(t))return;const e=this.Ko?null===(i=So(t))||void 0===i?void 0:i.storageGroup:void 0,s=e?hr.Dt(this.va(e)):this.Lo.Dt(this.la);if(s&&t in s)this.Sa(t,s[t],!1);else{if(e){const i=this.Lo.Dt(this.la);if(i&&t in i)return void this.Sa(t,i[t],!1)}this.xa(t,!1)}}save(){if(this.hi)return;const t=this.Ma();t>0?mi(this.Da)&&(this.Da=setTimeout(()=>{this.Da=void 0,this.La()},t)):this.La()}flush(){mi(this.Da)||(clearTimeout(this.Da),this.Da=void 0,this.La())}La(t=!1){if(this.hi||this.Yo&&!t)return;t||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase()||tl.forEach(t=>this.refreshKey(t)));const i=!t&&!this.ea;i||(this.na=!1);const e=!!i&&this.Ca();if(this.na)return void(this.Mr.debug&&jn.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Ko)return this.Ha(),void(e&&this.ra.forEach(t=>t()));const s=this.za(this.Lo,this.la,this.props,Xo);"written"===s&&this.Ea(this.props),"failed"!==s&&(this.ta.clear(),this.ia=!1,this.sa.clear()),e&&this.ra.forEach(t=>t())}Ha(){const{main:t,groups:i}=this.ba(),e=this.za(this.Lo,this.la,t,Xo);"written"===e&&this.Ea(t),"failed"!==e&&(this.ia=!1,this.sa.clear(),Zo.forEach(t=>{var i;(null===(i=So(t))||void 0===i?void 0:i.storageGroup)||this.ta.delete(t)}));for(const t of wo){var s;const e=i[t];if(_i(e)&&!(null===(s=this.Zo[t])||void 0===s?void 0:s.persisted)){Zo.forEach(i=>{var e;(null===(e=So(i))||void 0===e?void 0:e.storageGroup)===t&&this.ta.delete(i)});continue}const n=this.za(hr,this.va(t),e,t);"failed"!==n&&Zo.forEach(i=>{const e=So(i);(null==e?void 0:e.storageGroup)!==t||"written"!==n&&e.volatile||this.ta.delete(i)})}}ba(){const t={},i={flags:{},surveys:{}};return Ln(this.props,(e,s)=>{var n;const r=null===(n=So(s))||void 0===n?void 0:n.storageGroup;r?i[r][s]=e:t[s]=e}),{main:t,groups:i}}wa(t,i){if(i===Xo)return JSON.stringify(t)+"|"+this.Ua+"|"+this.Wa+"|"+this.Va;const e={};return Ln(t,(t,i)=>{var s;e[i]=(null===(s=So(i))||void 0===s?void 0:s.volatile)?"__volatile__":t}),JSON.stringify(e)}za(t,i,e,s){const n=this.ga(s);if(s!==Xo&&!n.dirty&&!mi(n.fingerprint))return"skipped";let r;try{if(r=this.wa(e,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){r=void 0}return t.$t(i,e,this.Ua,this.Wa,this.Va,this.Mr.debug)?(n.dirty=!1,s!==Xo&&(n.persisted=!0),mi(r)||(n.fingerprint=r),this.Qo&&(n.storageValue=hr.Ot(i)),"written"):(this.Mr.debug&&jn.warn(`failed to persist storage entry "${i}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.Ta(),mi(this.Da)||(clearTimeout(this.Da),this.Da=void 0),this.Lo.Lt(this.la,!1),this.Lo.Lt(this.la,!0),!t&&this.oa)for(const t of wo)hr.Lt(this.va(t));t?delete this.Zo[Xo]:this.Zo={},this.Pa=void 0,this.Ra=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(gi(t)){this.syncCookieProperties(),mi(i)&&(i="None"),this.Ua=mi(e)?this.Ga:e;let s=!1;if(Ln(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.Sa(e,t),s=!0)}),s)return this.save(),!0}return!1}register(t,i){if(gi(t)){this.syncCookieProperties(),this.Ua=mi(i)?this.Ga:i;let e=!1;if(Ln(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||gi(i)||fi(i))&&(this.Sa(s,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();const i="string"==typeof t?[t]:t;let e=!1;for(const t of i)t in this.props&&(this.xa(t),e=!0);e&&this.save()}update_campaign_params(){const t=null==Gt?void 0:Gt.URL;if(t===this.aa)return;const i=Do(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),e=!_i(qn(i));return e&&this.register(i),this.aa=t,e?i:void 0}update_search_keyword(){this.register(function(){const t=null==Gt?void 0:Gt.referrer;return t?Bo(t):{}}())}update_referrer_info(){var t;this.register_once({$referrer:Ho(),$referring_domain:(null==Gt?void 0:Gt.referrer)&&(null===(t=Eo(Gt.referrer))||void 0===t?void 0:t.host)||zo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const t=Uo(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[mt]:this.Jo?{r:Yo(t.r),u:t.u?Yo(t.u):void 0}:t},void 0)}get_initial_props(){const t={};Ln([_t,gt],i=>{const e=this.props[i];e&&Ln(e,function(i,e){t["$initial_"+hi(e)]=i})});const i=this.props[mt];if(i){const e=function(t,i=!1){const e=qo(t,i),s={};return Ln(e,function(t,i){s[`$initial_${hi(i)}`]=t}),s}(i,this.Mr.disable_capture_url_hashes);zn(t,e)}return t}safe_merge(t){return Ln(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){const s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;const e=[...t].sort(),s=[...i].sort();return e.every((t,i)=>t===s[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),r=s||n,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,a=!!this.hi&&!l;l||this.Aa(i,a),this.Mr=t,!l&&(s||n||o)&&(this.Pa=void 0,this.Ra=void 0,this.Aa(cs(cs({},t),{},{cookie_persisted_properties:i.cookie_persisted_properties}),a));const h=r||o?this.ua(t):this.Lo;this.Za();const u=this.ha(t),d=r||u!==this.Ko,c=!l&&(d||t.cross_subdomain_cookie!==this.Wa||t.secure_cookie!==this.Va)&&this.Fa(a);this.ea=d;try{if(this.Ga=this.Ua=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){const t=this.props;this.clear(),this.Lo=h,this.Ko=u,this.props=t,this.save()}else o&&(this.Lo=h,l||(delete this.Zo[Xo],this.La()))}finally{this.ea=!1,c&&this.Na()}}Za(){const t=this.props[mt];if(!this.Jo||!gi(t)||"string"!=typeof t.r)return;const i=Yo(t.r),e="string"==typeof t.u?Yo(t.u):t.u;i===t.r&&e===t.u||this.Sa(mt,cs(cs({},t),{},{r:i,u:e}))}set_disabled(t){this.hi=t,this.hi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Wa&&(this.Wa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Va&&(this.Va=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){const e=this.props.__timers||{};e[t]=i,this.Sa(v,e),this.save()}remove_event_timer(t){const i=this.props.__timers||{},e=i[t];return mi(e)||(delete i[t],this.Sa(v,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.Sa(t,i),this.save()}Sa(t,i,e=!0){var s;const n=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||n===i||(this.ia=!0),il(t)&&!el(n,i)&&this.sa.add(t),this.Ia(t,n,i),(null===(s=So(t))||void 0===s?void 0:s.volatile)||this.$a(t))}xa(t,i=!0){delete this.props[t],i&&(Qo(t)&&this.pa(t,!0),il(t)&&this.sa.add(t),this.$a(t))}$a(t){var i;const e=null===(i=So(t))||void 0===i?void 0:i.storageGroup;e&&(this.ga(e).dirty=!0)}ga(t){return this.Zo[t]||(this.Zo[t]={})}};const ol="gzip-js",ll="base64",al="events",hl="cancelEvents",ul="survey shown",dl="survey dismissed",cl="survey sent",vl="$survey_last_seen_date",fl="popover";function pl(t){let i=!0;return{dispose(){if(i){i=!1;const e=t();e&&pi(e.then)&&e.then(void 0,()=>{})}}}}const gl=Bn("[RateLimiter]");var _l=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{gl.info(`${t||"events"} is quota limited.`),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void gl.warn(`could not rate limit - continuing. Error: "${null==t?void 0:t.message}"`,{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var i,e,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),l=null!==(i=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*r,l.last=o,l.tokens>n&&(l.tokens=n);const a=1>l.tokens;if(a||t||(l.tokens=Math.max(0,l.tokens-1)),a&&!t){const t=(xi(l.dropped)?l.dropped:0)+1;l.dropped=t,!this.lastEventRateLimited&&this.Qa(t)&&(l.dropped=0)}return this.lastEventRateLimited=a,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",l),{isRateLimited:a,remainingTokens:l.tokens}}Ja(t){const i=this.instance.config.property_denylist;return!fi(i)||!i.includes(t)}Ka(){var t;if(this.Ja("$current_url")&&this.Ja("$pathname")&&(null==Kt?void 0:Kt.pathname))return`${null!==(t=Kt.origin)&&void 0!==t?t:""}${Kt.pathname}`}Qa(t){var i,e;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Ka(),o=this.Ja("$session_id")?null===(i=(e=this.instance).get_session_id)||void 0===i?void 0:i.call(e):void 0,l=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${l}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){const i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}};const ml=Bn("[RemoteConfig]");var bl=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null===(t=ei._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.config}Xa(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.loadExternalDependency)?null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Ya(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return ml.info("Using preloaded remote config",this.remoteConfig),void this.tl(this.remoteConfig);if(this._instance.el())return void ml.warn("Remote config is disabled. Falling back to local config.");this.Xa(t=>{if(!t)return ml.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ya(t=>{this.tl(t.json,t)});this.tl(t)})}catch(t){ml.error("Error loading remote config",t),this.tl()}}tl(t,i){!t&&i&&(0===i.statusCode?i.error||ml.warn("Failed to fetch remote config from PostHog."):ml.error("Failed to fetch remote config from PostHog."));try{this._instance.tl(t?{ok:!0,config:t}:{ok:!1})}catch(t){ml.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null===(e=this._instance.featureFlags)||void 0===e||e.ensureFlagsLoaded()}catch(t){ml.error("Error loading feature flags",t)}}},yl=Uint8Array,wl=Uint16Array,$l=Uint32Array,xl=new yl([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]),Sl=new yl([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]),kl=new yl([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),El=function(t,i){for(var e=new wl(31),s=0;31>s;++s)e[s]=i+=1<<t[s-1];var n=new $l(e[30]);for(s=1;30>s;++s)for(var r=e[s];e[s+1]>r;++r)n[r]=r-e[s]<<5|s;return[e,n]},Pl=El(xl,2),Tl=Pl[1];Pl[0][28]=258,Tl[258]=28;for(var Cl=El(Sl,0)[1],Fl=new wl(32768),Ml=0;32768>Ml;++Ml){var Il=(43690&Ml)>>>1|(21845&Ml)<<1;Fl[Ml]=((65280&(Il=(61680&(Il=(52428&Il)>>>2|(13107&Il)<<2))>>>4|(3855&Il)<<4))>>>8|(255&Il)<<8)>>>1}var Ol=function(t,i,e){for(var s=t.length,n=0,r=new wl(i);s>n;++n)++r[t[n]-1];var o,l=new wl(i);for(n=0;i>n;++n)l[n]=l[n-1]+r[n-1]<<1;if(e){o=new wl(1<<i);var a=15-i;for(n=0;s>n;++n)if(t[n])for(var h=n<<4|t[n],u=i-t[n],d=l[t[n]-1]++<<u,c=d|(1<<u)-1;c>=d;++d)o[Fl[d]>>>a]=h}else for(o=new wl(s),n=0;s>n;++n)o[n]=Fl[l[t[n]-1]++]>>>15-t[n];return o},Al=new yl(288);for(Ml=0;144>Ml;++Ml)Al[Ml]=8;for(Ml=144;256>Ml;++Ml)Al[Ml]=9;for(Ml=256;280>Ml;++Ml)Al[Ml]=7;for(Ml=280;288>Ml;++Ml)Al[Ml]=8;var Rl=new yl(32);for(Ml=0;32>Ml;++Ml)Rl[Ml]=5;var Dl=Ol(Al,9,0),jl=Ol(Rl,5,0),Bl=function(t){return(t/8|0)+(7&t&&1)},Nl=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var s=new(t instanceof wl?wl:t instanceof $l?$l:yl)(e-i);return s.set(t.subarray(i,e)),s},Ll=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8},zl=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8,t[s+2]|=e>>>16},Hl=function(t,i){for(var e=[],s=0;t.length>s;++s)t[s]&&e.push({s:s,f:t[s]});var n=e.length,r=e.slice();if(!n)return[new yl(0),0];if(1==n){var o=new yl(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var l=e[0],a=e[1],h=0,u=1,d=2;for(e[0]={s:-1,f:l.f+a.f,l:l,r:a};u!=n-1;)l=e[e[d].f>e[h].f?h++:d++],a=e[h!=u&&e[d].f>e[h].f?h++:d++],e[u++]={s:-1,f:l.f+a.f,l:l,r:a};var c=r[0].s;for(s=1;n>s;++s)r[s].s>c&&(c=r[s].s);var v=new wl(c+1),f=Ul(e[u-1],v,0);if(f>i){s=0;var p=0,g=f-i,_=1<<g;for(r.sort(function(t,i){return v[i.s]-v[t.s]||t.f-i.f});n>s;++s){var m=r[s].s;if(i>=v[m])break;p+=_-(1<<f-v[m]),v[m]=i}for(p>>>=g;p>0;){var b=r[s].s;i>v[b]?p-=1<<i-v[b]++-1:++s}for(;s>=0&&p;--s){var y=r[s].s;v[y]==i&&(--v[y],++p)}f=i}return[new yl(v),f]},Ul=function(t,i,e){return-1==t.s?Math.max(Ul(t.l,i,e+1),Ul(t.r,i,e+1)):i[t.s]=e},ql=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new wl(++i),s=0,n=t[0],r=1,o=function(t){e[s++]=t},l=1;i>=l;++l)if(t[l]==n&&l!=i)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[l]}return[e.subarray(0,s),i]},Vl=function(t,i){for(var e=0,s=0;i.length>s;++s)e+=t[s]*i[s];return e},Wl=function(t,i,e){var s=e.length,n=Bl(i+2);t[n]=255&s,t[n+1]=s>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;s>r;++r)t[n+r+4]=e[r];return 8*(n+4+s)},Gl=function(t,i,e,s,n,r,o,l,a,h,u){Ll(i,u++,e),++n[256];for(var d=Hl(n,15),c=d[0],v=d[1],f=Hl(r,15),p=f[0],g=f[1],_=ql(c),m=_[0],b=_[1],y=ql(p),w=y[0],x=y[1],S=new wl(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=Hl(S,7),P=E[0],T=E[1],C=19;C>4&&!P[kl[C-1]];--C);var F,M,I,O,A=h+5<<3,R=Vl(n,Al)+Vl(r,Rl)+o,D=Vl(n,c)+Vl(r,p)+o+14+3*C+Vl(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(R>=A&&D>=A)return Wl(i,u,t.subarray(a,a+h));if(Ll(i,u,1+(R>D)),u+=2,R>D){F=Ol(c,v,0),M=c,I=Ol(p,g,0),O=p;var j=Ol(P,T,0);for(Ll(i,u,b-257),Ll(i,u+5,x-1),Ll(i,u+10,C-4),u+=14,k=0;C>k;++k)Ll(i,u+3*k,P[kl[k]]);u+=3*C;for(var B=[m,w],N=0;2>N;++N){var L=B[N];for(k=0;L.length>k;++k)Ll(i,u,j[z=31&L[k]]),u+=P[z],z>15&&(Ll(i,u,L[k]>>>5&127),u+=L[k]>>>12)}}else F=Dl,M=Al,I=jl,O=Rl;for(k=0;l>k;++k)if(s[k]>255){var z;zl(i,u,F[257+(z=s[k]>>>18&31)]),u+=M[z+257],z>7&&(Ll(i,u,s[k]>>>23&31),u+=xl[z]);var H=31&s[k];zl(i,u,I[H]),u+=O[H],H>3&&(zl(i,u,s[k]>>>5&8191),u+=Sl[H])}else zl(i,u,F[s[k]]),u+=M[s[k]];return zl(i,u,F[256]),u+M[256]},Kl=new $l([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Jl=new yl(0),Yl=function(){for(var t=new $l(256),i=0;256>i;++i){for(var e=i,s=9;--s;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),Xl=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function Zl(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,s=0;i.length>s;++s)e=Yl[255&e^i[s]]^e>>>8;t=e},d(){return 4294967295^t}}}(),s=t.length;e.p(t);var n,r,o,l,a,h,u=(l=10+((n=i).filename&&n.filename.length+1||0),a=8,function(t,i,e,s,n,r){var o=t.length,l=new yl(s+o+5*(1+Math.floor(o/7e3))+n),a=l.subarray(s,l.length-n),h=0;if(!i||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?h=Wl(a,h,t.subarray(u,d)):(a[u]=r,h=Wl(a,h,t.subarray(u,o)))}else{for(var c=Kl[i-1],v=c>>>13,f=8191&c,p=(1<<e)-1,g=new wl(32768),_=new wl(p+1),m=Math.ceil(e/3),b=2*m,y=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<b)&p},w=new $l(25e3),x=new wl(288),S=new wl(32),k=0,E=0,P=(u=0,0),T=0,C=0;o>u;++u){var F=y(u),M=32767&u,I=_[F];if(g[M]=I,_[F]=M,u>=T){var O=o-u;if((k>7e3||P>24576)&&O>423){h=Gl(t,a,0,w,x,S,E,P,C,u-C,h),P=k=E=0,C=u;for(var A=0;286>A;++A)x[A]=0;for(A=0;30>A;++A)S[A]=0}var R=2,D=0,j=f,B=M-I&32767;if(O>2&&F==y(u-B))for(var N=Math.min(v,O)-1,L=Math.min(32767,u),z=Math.min(258,O);L>=B&&--j&&M!=I;){if(t[u+R]==t[u+R-B]){for(var H=0;z>H&&t[u+H]==t[u+H-B];++H);if(H>R){if(R=H,D=B,H>N)break;var U=Math.min(B,H-2),q=0;for(A=0;U>A;++A){var V=u-B+A+32768&32767,W=V-g[V]+32768&32767;W>q&&(q=W,I=V)}}}B+=(M=I)-(I=g[M])+32768&32767}if(D){w[P++]=268435456|Tl[R]<<18|Cl[D];var G=31&Tl[R],K=31&Cl[D];E+=xl[G]+Sl[K],++x[257+G],++S[K],T=u+R,++k}else w[P++]=t[u],++x[t[u]]}}h=Gl(t,a,r,w,x,S,E,P,C,u-C,h),r||(h=Wl(a,h,Jl))}return Nl(l,0,s+Bl(h)+n)}(r=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,l,a,!h)),d=u.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&Xl(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var s=0;e.length>=s;++s)t[s+10]=e.charCodeAt(s)}}(u,i),Xl(u,d-8,e.d()),Xl(u,d-4,s),u}const Ql=!!Yt||!!Jt,ta=new WeakMap,ia="text/plain";let ea=0,sa=!1;const na=(t,i)=>{const[e,s]=t.split("#"),[n,r]=e.split("?");if(!r)return t;const o=r.split("&").filter(t=>t.split("=")[0]!==i).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},ra=(t,i,e=!0)=>{var s;const[n,r]=t.split("?"),o=cs({},i),l=null!==(s=null==r?void 0:r.split("&").map(t=>{var i;const[s,n]=t.split("="),r=e&&null!==(i=o[s])&&void 0!==i?i:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],a=function(t,i="&"){let e,s;const n=[];return Ln(t,function(t,i){mi(t)||mi(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),s=encodeURIComponent(i),n[n.length]=s+"="+e)}),n.join(i)}(o);return a&&l.push(a),l.length>0?`${n}?${l.join("&")}`:n},oa=t=>{if(t.il)return t.il;const{data:i,compression:e}=t;if(!i)return;if(e===ol){const t=Zl(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new yl(t.length+(t.length>>>1)),s=0,n=function(t){e[s++]=t},r=0;i>r;++r){if(s+5>e.length){var o=new yl(s+8+(i-r<<1));o.set(e),e=o}var l=t.charCodeAt(r);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Nl(e,0,s)}(ko(i)),{mtime:0});return{contentType:ia,body:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),estimatedSize:t.byteLength}}if(e===ll){const t=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(ko(i)),e=(t=>"data="+encodeURIComponent("string"==typeof t?t:ko(t)))(t);return{contentType:"application/x-www-form-urlencoded",body:e,estimatedSize:new Blob([e]).size}}const s=ko(i);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},la=t=>{const i=()=>"sendBeacon"===t.transport?{url:ra(t.url,{compression:ll}),encodedBody:oa(cs(cs({},t),{},{compression:ll,il:void 0}))}:{url:na(t.url,"compression"),encodedBody:oa(cs(cs({},t),{},{compression:void 0,il:void 0}))};let e;try{e=oa(t)}catch(e){if(rn(t.compression,Po(t.url,"compression")))return jn.error("Failed to gzip request body, sending uncompressed payload",e),i();throw e}return e&&rn(t.compression,Po(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?nn(new Uint8Array(s)):ArrayBuffer.isView(s)&&nn(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(sa=!0,i()):{url:t.url,encodedBody:e};var s},aa=t=>{try{return la(t)}catch(e){var i;return jn.error(e),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0,error:e}))}},ha=function(){var t=ji(function*(t){const i=yield function(t){return dn.apply(this,arguments)}(ko(t.data),e.DEBUG,{rethrow:!0});if(!i)return t;const s=yield i.arrayBuffer();return cs(cs({},t),{},{il:{contentType:ia,body:s,estimatedSize:s.byteLength}})});return function(i){return t.apply(this,arguments)}}(),ua=/Failed to fetch|NetworkError|Load failed/i,da=t=>"TypeError"===(null==t?void 0:t.name)&&ua.test((null==t?void 0:t.message)||""),ca=t=>{try{const i=function(t,i=Date.now()){if("string"!=typeof t||!t)return;const e=t.trim(),s=/^\d+\s*,/.test(e)?e.slice(0,e.indexOf(",")).trim():e;if(/^\d+$/.test(s)){const t=1e3*Math.min(Number(s),300);return t>0?t:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,r=Date.parse(n)-i;return Number.isFinite(r)&&r>0?Math.min(r,Je):void 0}(t());return mi(i)?void 0:Math.min(i,3e4)}catch(t){return}},va=t=>{const i=aa(t);if(!i)return;const e=new Yt;ta.set(e,!0);const{url:s,encodedBody:n}=i;e.open(t.method||"GET",s,!0);const{contentType:r,body:o}=null!=n?n:{};Ln(t.headers,function(t,i){e.setRequestHeader(i,t)}),r&&e.setRequestHeader("Content-Type",r),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i;const s={statusCode:e.status,text:e.responseText};if(200===e.status)try{s.json=JSON.parse(e.responseText)}catch(t){}null===(i=t.callback)||void 0===i||i.call(t,s,ca(()=>e.getResponseHeader("Retry-After")))}},e.send(o)},fa=t=>{const i=aa(t);if(!i)return;const{url:e,encodedBody:s}=i,{contentType:n,body:r,estimatedSize:o}=null!=s?s:{},l=new Headers;Ln(t.headers,function(t,i){l.append(i,t)}),n&&l.append("Content-Type",n);let a=null,h=!1;if(Xt){const i=new Xt;a={signal:i.signal,timeout:setTimeout(()=>{h=!0;try{i.abort(Qe("AbortError","PostHog request timed out"+((e=t.timeout)?` after ${e}ms`:"")))}catch(t){d(t)}var e},t.timeout)}}let u=!1;const d=i=>{var e;u||(u=!0,h&&"AbortError"===(null==i?void 0:i.name)||da(i)?jn.warn(i):jn.error(i),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0,error:i}))};let c=0;const v=()=>{ea-=c,c=0,a&&clearTimeout(a.timeout)};try{const i=cs({method:(null==t?void 0:t.method)||"GET",headers:l,referrerPolicy:"strict-origin",body:r,signal:null==a?void 0:a.signal},t.fetchOptions),s=null!=o?o:mi(r)?0:void 0;i.keepalive="POST"===i.method&&!t.nl&&!1!==i.keepalive&&i.body===r&&!mi(s)&&s>=0&&52428.8>ea+s,i.keepalive&&(c=s,ea+=c),Jt(e,i).then(i=>i.text().then(e=>{var s;if(u)return;const n={statusCode:i.status,text:e};if(200===i.status)try{n.json=JSON.parse(e)}catch(t){jn.error(t)}u=!0,v(),null===(s=t.callback)||void 0===s||s.call(t,n,ca(()=>i.headers.get("Retry-After")))})).catch(t=>{v(),d(t)}).finally(v)}catch(t){v(),d(t)}},pa=t=>{try{var i;const{url:e,encodedBody:s}=la(t),{contentType:n,body:r,estimatedSize:o}=null!=s?s:{};if(!r)return;const l=r instanceof Blob?r:new Blob([r],{type:n});if(Wt.sendBeacon(e,l))return;const a=fi(t.data)?t.data:null===(i=t.data)||void 0===i?void 0:i.batch;if(fi(a)&&a.length>1&&(null!=o?o:0)>16384){const i=Math.ceil(a.length/2),e=i=>fi(t.data)?i:cs(cs({},t.data),{},{batch:i});return pa(cs(cs({},t),{},{data:e(a.slice(0,i))})),void pa(cs(cs({},t),{},{data:e(a.slice(i))}))}jn.warn(`Beacon of ~${null!=o?o:0} bytes was rejected by the browser, falling back to ${Jt?"fetch":"XHR"}`),Jt?fa(cs(cs({},t),{},{nl:!0})):va(t)}catch(t){jn.warn("Beacon send failed",t)}},ga=(t,i,e,s)=>{const n="query"===s?"POST"===i?"sent_at":"_":void 0;return ra(e===ol?na(t,"compression"):t,cs(cs({},n?{[n]:Date.now().toString()}:{}),e===ol?{}:{compression:e}))},_a=(()=>{const t=[];return Jt&&t.push({transport:"fetch",method:fa}),Yt&&t.push({transport:"XHR",method:va}),(null==Wt?void 0:Wt.sendBeacon)&&t.push({transport:"sendBeacon",method:pa}),t})();let ma=!Ql&&-1===(null==Qt?void 0:Qt.indexOf("MSIE"))&&-1===(null==Qt?void 0:Qt.indexOf("Mozilla"));function ba(t,i,e){var s,n,r;e&&(i=cs(cs({},i),{},{callback:t=>e(t)})),t.__loaded?ma?t.__request_queue.push(i):t.rateLimiter.isServerRateLimited(i.batchKey)?i.fireCallbackOnDrop&&(null===(n=i.callback)||void 0===n||n.call(i,{statusCode:429})):(i.transport=i.transport||t.config.api_transport,i.headers=cs(cs({},t.config.request_headers),i.headers),i.compression="best-available"===i.compression?null!==(s=t.compression)&&void 0!==s?s:i.compressionFallback:i.compression,(mi(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(i.disableTransport=["sendBeacon"]),i.fetchOptions=i.fetchOptions||t.config.fetch_options,((t,i)=>{var e,s,n;const r=cs(cs({},t),{},{callback:null!=i?i:i=>{var e;return null===(e=t.callback)||void 0===e?void 0:e.call(t,i)}});r.timeout=r.timeout||6e4;const o=null!==(e=r.transport)&&void 0!==e?e:"fetch";"sendBeacon"===o&&mi(r.compression)&&r.data&&(r.compression=ll),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(t=>{var i,e;const s=(fi(t)?t:[t]).map(t=>cs(cs({},t),t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(i=null==n||null===(e=n.properties)||void 0===e?void 0:e.token)&&void 0!==i?i:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((t,i=(new Date).toISOString())=>fi(t)?t.map(t=>cs(cs({},t),{},{sent_at:i})):cs(cs({},t),{},{sent_at:i}))(r.data))),r.url=ga(r.url,r.method,r.compression,r.timestampMode);const l=_a.filter(t=>!r.disableTransport||!t.transport||!r.disableTransport.includes(t.transport)),a=null!==(s=null===(n=function(t,i){for(let e=0;t.length>e;e++)if(i(t[e]))return t[e]}(l,t=>t.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:l[0].method;if(!a)throw new Error("No available transport method");const h=t=>{try{a(t)}catch(t){var i;da(t)?jn.warn(t):jn.error(t),null===(i=r.callback)||void 0===i||i.call(r,{statusCode:0,error:t})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===ol&&Zt&&"undefined"!=typeof Promise&&!sa?ha(r).then(t=>{h(t)}).catch(i=>{if(on(i))return sa=!0,void h(cs(cs({},r),{},{compression:void 0,url:ga(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;const i="name"in t?String(t.name):"";return on(t)||i===sn})(i)&&(sa=!0),h(r)}):h(r)})(i,(s,n)=>{var r,o,l;t.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=t.config).on_request_error)||void 0===r||r.call(o,s),e?e(s,n):null===(l=i.callback)||void 0===l||l.call(i,s)})):i.fireCallbackOnDrop&&(null===(r=i.callback)||void 0===r||r.call(i,{statusCode:0}))}var ya=class{constructor(t,i){this.sl=!0,this.rl=[],this.ol=Li((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,jn.createLogger("flush interval"),3e3),this.al=t}enqueue(t){this.rl.push(t),this.ll||this.ul()}unload(){this.hl();const t=this.rl.length>0?this.cl():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.dl(t,"sendBeacon")})}enable(){this.sl=!1,this.ul()}ul(){this.sl||(this.ll=setTimeout(()=>{if(this.hl(),this.rl.length>0){const t=this.cl();for(const i in t)this.dl(t[i])}},this.ol))}dl(t,i){try{this.al(t,i)}catch(t){jn.error(t)}}hl(){clearTimeout(this.ll),this.ll=void 0}cl(){const t={};return Ln(this.rl,i=>{var e;const s=i,n=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");mi(t[n])&&(t[n]=cs(cs({},s),{},{data:[]})),null===(e=t[n].data)||void 0===e||e.push(s.data)}),this.rl=[],t}};const wa=["retriesPerformedSoFar"];var $a=class{constructor(t){this._instance=t,this.vl=!1,this.fl=3e3,this.rl=[],this.rl=[],this.pl=!0,this.resume()}resume(){if(!mi(qt)&&"onLine"in qt.navigator){if(this.pl=qt.navigator.onLine,this.gl)return;this.gl=()=>{this.pl=!0,this.ml()},this.yl=()=>{this.pl=!1},Kn(qt,"online",this.gl),Kn(qt,"offline",this.yl)}}get length(){return this.rl.length}retriableRequest(t,i){let{retriesPerformedSoFar:e}=t,s=cn(t,wa);Si(e)&&(s.url=ra(s.url,{retry_count:e})),ba(this._instance,i?cs(cs({},s),{},{transport:i}):s,(t,i)=>{var n;if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.Ls(cs({retriesPerformedSoFar:e},s),i);0===t.statusCode&&jn.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=e?e:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,t)})}Ls(t,i){const e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;const s=Math.max(function(t){const i=3e3*Math.pow(2,t),e=i/2,s=Math.min(18e5,i),n=(Math.random()-.5)*(s-e);return Math.ceil(s+n)}(e),null!=i?i:0),n=Date.now()+s;this.rl.push({retryAt:n,requestOptions:t});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),jn.warn(r),this.vl||(this.vl=!0,this.bl())}bl(){if(this._l&&clearTimeout(this._l),0===this.rl.length)return this.vl=!1,void(this._l=void 0);this._l=setTimeout(()=>{this.pl&&this.rl.length>0&&this.ml(),this.bl()},this.fl)}ml(){const t=Date.now(),i=[],e=this.rl.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.rl=i,e.length>0)for(const{requestOptions:t}of e)this.retriableRequest(t)}unload(){this._l&&(clearTimeout(this._l),this._l=void 0),this.vl=!1,mi(qt)||(this.gl&&(qt.removeEventListener("online",this.gl),this.gl=void 0),this.yl&&(qt.removeEventListener("offline",this.yl),this.yl=void 0));for(const{requestOptions:t}of this.rl)try{this._instance._send_request(cs(cs({},t),{},{transport:"sendBeacon"}))}catch(t){jn.error(t)}this.rl=[]}},xa=class{constructor(t){this._instance=t,this.wl=()=>{var t,i,e,s;this.kl||(this.kl={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=r+((null==n?void 0:n.clientHeight)||0),a=(null==n?void 0:n.scrollHeight)||0;this.kl.lastScrollY=Math.ceil(r),this.kl.maxScrollY=Math.max(r,null!==(t=this.kl.maxScrollY)&&void 0!==t?t:0),this.kl.maxScrollHeight=Math.max(o,null!==(i=this.kl.maxScrollHeight)&&void 0!==i?i:0),this.kl.lastContentY=l,this.kl.maxContentY=Math.max(l,null!==(e=this.kl.maxContentY)&&void 0!==e?e:0),this.kl.maxContentHeight=Math.max(a,null!==(s=this.kl.maxContentHeight)&&void 0!==s?s:0)}}get Sl(){return this._instance.config.scroll_root_selector}getContext(){return this.kl}resetContext(){const t=this.kl;return this.kl=void 0,setTimeout(this.wl,0),t}startMeasuringScrollPosition(){Kn(qt,"scroll",this.wl,{capture:!0}),Kn(qt,"scrollend",this.wl,{capture:!0}),Kn(qt,"resize",this.wl)}scrollElement(){if(this.Sl){const i=fi(this.Sl)?this.Sl:[this.Sl];for(const e of i){var t;const i=null==qt||null===(t=qt.document)||void 0===t?void 0:t.querySelector(e);if(i)return i}return}var i;return null==qt||null===(i=qt.document)||void 0===i?void 0:i.documentElement}xl(t){var i,e;const s="y"===t?"scrollTop":"scrollLeft";if(this.Sl){const t=this.scrollElement();return t&&t[s]||0}return qt?"y"===t?qt.scrollY||qt.pageYOffset||(null===(i=qt.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollTop)||0:qt.scrollX||qt.pageXOffset||(null===(e=qt.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.scrollLeft)||0:0}scrollY(){return this.xl("y")}scrollX(){return this.xl("x")}};const Sa=t=>Uo(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);var ka=class{constructor(t,i,e,s){this.qe=t=>{const i=this.Cl();if(i&&i.sessionId===t)return;const e={sessionId:t,props:this.$l(this._instance)};this.Tl.register({[ft]:e})},this._instance=t,this.Il=i,this.Tl=e,this.$l=s||Sa,this.Il.onSessionId(this.qe)}Cl(){return this.Tl.props[ft]}getSetOnceProps(){var t;const i=null===(t=this.Cl())||void 0===t?void 0:t.props;return i?"r"in i?qo(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){const t={};return Ln(qn(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t[`$session_entry_${hi(e)}`]=i}),t}},Ea=class{on(t,i){return this.Ml[t]||(this.Ml[t]=[]),this.Ml[t].push(i),()=>{this.Ml[t]=this.Ml[t].filter(t=>t!==i)}}emit(t,i){for(const e of this.Ml[t]||[])e(i);for(const e of this.Ml["*"]||[])e(t,i)}constructor(){this.Ml={}}};const Pa=Bn("[SessionId]"),Ta=864e5;var Ca=class{on(t,i){return this.El.on(t,i)}constructor(t,i,e){var s;if(this.Pl=null,this.Rl=null,this.Al=[],this.Fl=void 0,this.Ol=!1,this.El=new Ea,this.Dl=(t,i)=>!(!Si(t)||!Si(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=t.config,this.Tl=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Ll=void 0,this._sessionActivityTimestamp=null,this.Nl=i||er,this.ql=e||er;const n=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Li(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Pa.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.jl(),this.Bl="ph_"+n+"_window_id",this.Hl="ph_"+n+"_primary_window_exists",this.zl()){const t=xr.Dt(this.Bl),i=xr.Dt(this.Hl);t&&!i?this.je=t:xr.Lt(this.Bl),xr.$t(this.Hl,!0)}(null===(s=this.Mr.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Ul()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return mi(this.Al)&&(this.Al=[]),this.Al.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.Al=this.Al.filter(i=>i!==t)}}zl(){return"memory"!==this.Mr.persistence&&!this.Tl.hi&&xr.At()}Wl(t){t!==this.je&&(this.je=t,this.zl()&&xr.$t(this.Bl,t))}Vl(){return this.je?this.je:this.zl()?xr.Dt(this.Bl):null}Gl(t){const i=this.Pl;return!wi(i)&&!wi(t)&&5e3>Math.abs(t-i)}Zl(t,i,e){const s=i!==this._sessionActivityTimestamp,n=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,n&&!s||n&&this.Gl(i)||(this.Pl=i,this.Tl.register({[I]:[i,t,e]}))}Ql(){var t;const i=null===(t=this.Mr)||void 0===t?void 0:t.persistence_save_debounce_ms;return Si(i)&&i>0}Jl(){this.Ql()?this.Tl.refreshKey(I):(this.Tl.flush(),this.Tl.load())}Kl(){var t;if(wi(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Pl)return;this.Jl();const[,i,e]=this.Xl();i===this.Xt&&e===this._sessionStartTimestamp&&(this.Pl=this._sessionActivityTimestamp,this.Tl.register({[I]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Tl.flush())}Yl(){const[t]=this.Xl(),i=Si(t)?t:0,e=Si(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}tu(t){return this.Jl(),this.Dl(t,this.Yl())}Xl(){const t=this.Tl.props[I];return fi(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Pl=null,this.Ll=void 0,clearTimeout(this.eu),this.eu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(t,i=!1){const e=((t,i=(new Date).getTime())=>{try{const e=(t=>{const i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void Pa.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void Pa.error("Invalid sessionID in bootstrap",t)}})(t);return!mi(e)&&(i?this.Ll={sessionId:t,sessionStartTimestamp:e}:this.Zl(t,(new Date).getTime(),e),!0)}destroy(){this.Ol=!0,this.Kl(),clearTimeout(this.eu),this.eu=void 0,this.Fl&&qt&&(qt.removeEventListener(Nt,this.Fl,{capture:!1}),this.Fl=void 0),this.Al=[]}Ul(){this.Fl=()=>{this.Kl(),this.zl()&&xr.Lt(this.Hl)},Kn(qt,Nt,this.Fl,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,i=null,e=!1){if("always"===this.Mr.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=i||(new Date).getTime(),n=this.Xt;if(e)this.Rl=s;else if(wi(this.Rl)||this.Rl>s||s-this.Rl>=1e3){var r,o;null===(r=(o=this.Tl).syncCookieProperties)||void 0===r||r.call(o),this.Rl=s}let[,l,a]=this.Xl();const h=!mi(n)&&l!==n,u=this.Yl();let d=this.Vl();const c=this.Ll,v=!!c&&(c.sessionStartTimestamp>s+6e4||s-c.sessionStartTimestamp>Ta),f=c?v:Si(a)&&Math.abs(s-a)>Ta;let p=!1,g=h,_=!l||!!c;const m=l;let b=!_&&!t&&this.Dl(s,u);if(b&&(b=this.tu(s),b||Pa.info("cross-tab refresh kept the session alive",{sessionId:l}),[,l,a]=this.Xl(),b||(_=!l||!!c)),_||b||f){g=!1;const t=c&&!v;l=t?c.sessionId:this.Nl(),d=this.ql(),Pa.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!t,changeReason:{noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f}}),a=t?c.sessionStartTimestamp:s,this.Ll=void 0,p=!0}else d||(d=this.ql(),p=!0),g=g||l!==m,g&&(Pa.info("adopted cross-tab session id",{sessionId:l,windowId:d}),p=!0);const y=Si(u)&&t&&!f?u:s,w=Si(a)?a:(new Date).getTime();this.Wl(d),this.Zl(l,y,w),t||this.jl();const x={noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f,crossTabAdoption:g};return p&&this.Al.forEach(t=>t(l,d,x)),{sessionId:l,windowId:d,sessionStartTimestamp:w,changeReason:p?x:void 0,lastActivityTimestamp:u}}jl(){this.Ol||(clearTimeout(this.eu),this.eu=setTimeout(()=>{if(!this.Ol)if(this.tu((new Date).getTime())){const t=this.Xt;this.resetSessionId(),this.El.emit("forcedIdleReset",{idleSessionId:t})}else this.jl()},1.1*this.sessionTimeoutMs))}};const Fa=function(t,i){if(!t)return!1;const e=t.userAgent;if(e&&Ni(e,i))return!0;try{const e=null==t?void 0:t.userAgentData;if((null==e?void 0:e.brands)&&e.brands.some(t=>Ni(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function Ma(){return(Ma=ji(function*(){const t=null==Wt?void 0:Wt.userAgentData;if(null==t?void 0:t.getHighEntropyValues)try{const i=yield t.getHighEntropyValues(["model"]),e=null==i?void 0:i.model;return bi(e)&&e.length>0?e:void 0}catch(t){return void jn.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function Ia(t,i){let e=`$survey_${i}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(e=`$survey_${i}/${t.id}/${t.current_iteration}`),e}function Oa(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}const Aa=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Ra=t=>t.toLowerCase(),Da={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>Aa(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!Aa(i,t))),icontains:(t,i)=>i.map(Ra).some(i=>t.map(Ra).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Ra).every(i=>t.map(Ra).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function ja(t,i){return!t||Object.entries(t).every(([t,e])=>{const s=null==i?void 0:i[t];if(null==s)return!1;const n=Da[e.operator];return!!n&&n(e.values.map(String),[String(s)])})}function Ba(t,i,e){return ko({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}const Na="custom",La="i.posthog.com",za=/^\/static\//,Ha=["/s/","/e/","/i/"];var Ua=class{constructor(t){this.iu={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let i=null===(t=this.instance.config.ui_host)||void 0===t?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace(`.${La}`,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.iu[this.apiHost]||(this.iu[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Na),this.iu[this.apiHost]}nu(t){if(!za.test(t))return;const i=this.instance.config.asset_host;return"string"==typeof i&&i.trim().replace(/\/$/,"")||void 0}su(t){const i=Eo(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}ru(t,i,e){if("ui"===t)return e;let s=e;const n=this.instance.config.rewriteRequestPath;if(n){var r;const t=(null===(r=Eo(e))||void 0===r?void 0:r.href)||e;s=n(new URL(t)).toString()}if(n&&"api"===t&&Ha.some(t=>0===i.indexOf(t))){const t=this.su(s);if(t){const i=this.apiHost;let e=this.ou;(null==e?void 0:e.apiHost)===i&&e.rewriteRequestPath===n||(e={apiHost:i,rewriteRequestPath:n,urls:new Set},this.ou=e),e.urls.add(t)}}return s}isIngestionEndpoint(t){const i=this.ou,e=this.su(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i=""){if(i&&(i="/"===i[0]?i:`/${i}`),"ui"===t)return this.ru(t,i,this.uiHost+i);if("flags"===t)return this.ru(t,i,this.flagsApiHost+i);if("assets"===t){const e=this.nu(i);if(e)return this.ru(t,i,`${e}${i}`)}if(this.region===Na)return this.ru(t,i,this.apiHost+i);const e=La+i;switch(t){case"assets":return this.ru(t,i,`https://${this.region}-assets.${e}`);case"api":return this.ru(t,i,`https://${this.region}.${e}`)}}};const qa=Bn("[Surveys]"),Va=t=>{try{const i=(t=>((t,i)=>`seenSurvey_${function(t){return t.current_iteration&&t.current_iteration>0?`${t.id}_${t.current_iteration}`:t.id}(i)}`)(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){qa.error("Failed to persist survey seen state",t)}},Wa=["popover","widget","api"],Ga={ignoreConditions:!1,ignoreDelay:!1,displayType:fl},Ka=Bn("[PostHog ExternalIntegrations]"),Ja={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Ya=class{constructor(t){this._instance=t}Bo(t,i){var e,s;null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,t,t=>{if(t)return Ka.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t;for(const[n,r]of Object.entries(null!==(t=this._instance.config.integrations)&&void 0!==t?t:{})){var i,e,s;r&&!(null===(i=ei.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&this.Bo(Ja[n],()=>{var t;null===(t=ei.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t||null===(t=t[n])||void 0===t||t.start(this._instance)}),!r&&(null===(e=ei.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e?void 0:e[n])&&(null===(s=ei.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},Xa=class{constructor(t,i){this.A=t,this.yo=i,this.au=new Map,this.$o=!1}add(t){var i=this;return ji(function*(){if(i.$o)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.au.has(t.name))throw new Error(`Browser extension "${t.name}" is already registered`);i.au.set(t.name,t);try{const e=t.setup(i.yo);e&&(yield e)}catch(e){const s=i.au.get(t.name)===t;s&&i.au.delete(t.name),i.A.error(`Failed to set up browser extension "${t.name}"`,e),s&&i.lu(t)}})()}getExtension(t){return this.au.get(t)}dispose(){if(this.$o)return;this.$o=!0;const t=Array.from(this.au.values()).reverse();this.au.clear();for(const i of t)this.lu(i)}lu(t){try{var i;const e=null===(i=t.dispose)||void 0===i?void 0:i.call(t);e&&pi(e.then)&&e.then(void 0,i=>{this.A.error(`Failed to dispose browser extension "${t.name}"`,i)})}catch(i){this.A.error(`Failed to dispose browser extension "${t.name}"`,i)}}},Za=class{constructor(t){this._instance=t}initialize(){}get(t){const i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);const e={};for(const s of t){const t=null==i?void 0:i.get_property(s);mi(t)||(e[s]=t)}return e}set(t,i){var e;null===(e=this._instance.persistence)||void 0===e||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null===(i=this._instance.persistence)||void 0===i||i.unregister(t)}};const Qa="extensionsRemoteConfig";var th=class{constructor(t){this.instance=t,this.$o=!1,this.A=jn,this.uu=t.hu,this.kv=new Za(t),this.onEvent=t=>pl(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.A.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{if(this.$o)return pl(()=>{});const i=i=>{try{t(i)}catch(t){this.A.error("Browser extension remote config listener failed",t)}},e=this.instance.cu.on(Qa,i);return this.uu&&i(this.uu),pl(e)},this.du=new Xa(jn.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){const t=this.instance.get_property(r);return"string"==typeof t?t:void 0}get library(){return{name:e.LIB_NAME,version:e.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,s;const n=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==n?void 0:n.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==n?void 0:n.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.sessionStartTimestamp)&&void 0!==s?s:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.du.add(t)}getExtension(t){return this.du.getExtension(t)}capture(t,i,e){e?this.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):this.instance.capture(t,i)}registerDynamicEventProperties(t){return pl(this.instance.vu(t))}handleRemoteConfig(t){this.$o||(this.uu=t,this.instance.cu.emit(Qa,t))}sendRequest(t){var i=this;return ji(function*(t,e={}){var s;const n=i.instance.requestRouter.endpointFor(null!==(s=e.target)&&void 0!==s?s:"api",t),r={method:e.method,url:e.query?ra(n,e.query):n,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:"flags"===e.target&&"best-available"===e.compression?ni.Base64:void 0,timestampMode:e.sentAt};return"sendBeacon"===e.transport?(i.instance._send_request(r),{statusCode:202}):new Promise(t=>{r.callback=t,i.instance._send_request(r)})}).apply(this,arguments)}dispose(){this.$o||(this.$o=!0,this.du.dispose())}};const ih={};let eh=0;const sh=()=>{},nh='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',rh="Surveys module not available",oh="sanitize_properties is deprecated. Use before_send instead",lh="Invalid value for property_denylist config: ",ah=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],hh=["$feature_flag_called","$$heatmap","$snapshot"],uh=t=>"$"===t.charAt(0)&&!li(hh,t),dh=/^[A-Za-z0-9_-]{1,400}$/,ch=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,vh=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,fh=["token","distinct_id",wt],ph="posthog",gh=t=>{const i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},_h=t=>{var i;return cs({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Gn(null==Gt?void 0:Gt.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:sh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Kt&&bi(null==Kt?void 0:Kt.search)&&-1!==Kt.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==qt||null===(i=qt.location)||void 0===i?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(t){jn.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:jt,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:sh},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Ur,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:gh(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(t))},mh=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],bh=t=>{const i={};for(const[e,s]of mh)mi(t[e])||(i[s]=t[e]);const e=zn({},i,t),s=t.__preview_external_dependency_versioned_paths;return mi(s)||(mi(t.strict_script_versioning)&&(e.strict_script_versioning=!!s),bi(s)&&mi(t.asset_host)&&(e.asset_host=s)),fi(t.property_blacklist)&&(mi(t.property_denylist)?e.property_denylist=t.property_blacklist:fi(t.property_denylist)?e.property_denylist=[...t.property_blacklist,...t.property_denylist]:jn.error(lh+t.property_denylist)),e};var yh=class{constructor(){this.__forceAllowLocalhost=!1}get fu(){return this.__forceAllowLocalhost}set fu(t){jn.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},wh=class t{pu(t){if(!t)return;const i=this.au.indexOf(t);-1!==i&&this.au.splice(i,1)}gu(t,i){var e;return this.pu(t),this.au.push(i),null===(e=i.initialize)||void 0===e||e.call(i),i}mu(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}yu(){if(this.bu)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.mu())return;const t="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!t&&!this.config.disable_persistence)return;if(this._u)return;let i,e,s;t?(i=`persistence is set to '${this.config.persistence}'`,e="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(i="persistence is disabled (disable_persistence is true)",e="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.bu=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${e}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}wu(){if(this.mu()||"$posthog_cookieless"!==this.get_distinct_id())return;const t=this.persistence;if(!t)return;this.ku()||t.load(!0);const i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){const i=this.config.get_device_id(er());this.register({distinct_id:i,$device_id:i}),t.set_property(vt,Rt)}this.Su()}get decideEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var i;this.xu=!1,this.Cu=!1,this.webPerformance=new yh,this.$u=!1,this.version=e.LIB_VERSION,this.Tu=new Set,this.Iu="",this.cu=new Ea,this.au=[],this.Mu=[],this.Eu=!1,this._u=!1,this.bu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=_h(),this.SentryIntegration=bo,this.sentryIntegration=t=>function(t,i){const e=mo(t,i);return{name:_o,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Pu=!1,this.Ru=null,this.Au=null,this.Fu=null,this.scrollManager=new xa(this),this.pageViewManager=new yo(this),this.rateLimiter=new _l(this),this.requestRouter=new Ua(this),this.consent=new Sr(this),this.externalIntegrations=new Ya(this);const s=null!==(i=t.__defaultExtensionClasses)&&void 0!==i?i:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(t,i,e)=>{const s=bi(t)?{[t]:i}:t;this.setPersonProperties(s),null==e||e({})},set_once:(t,i,e)=>{const s=bi(t)?{[t]:i}:t;this.setPersonProperties(void 0,s),null==e||e({})}},this.on("eventCaptured",t=>jn.info(`send "${null==t?void 0:t.event}"`,t))}init(i,e,s){if(s&&s!==ph){var n;const r=null!==(n=ih[s])&&void 0!==n?n:new t;return r._init(i,e,s),ih[s]=r,ih[ph][s]=r,r}return this._init(i,e,s)}_init(t,i={},s){var n,r,l;const a=bi(t)?t.trim():"";if(!a)return jn.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var h;if(this.__loaded)return a!==(null===(h=this.config)||void 0===h?void 0:h.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=_h(i.defaults),i.debug=this.Ou(i.debug),this.Du=i,this.Lu=[],i.person_profiles?this.Au=i.person_profiles:i.process_person&&(this.Au=i.process_person);const u=_h(i.defaults),d=bh(i),c=zn({},u,d,{name:s,token:a});gi(u.rageclick)&&gi(d.rageclick)&&(c.rageclick=zn({},u.rageclick,d.rageclick)),gi(u.session_recording)&&gi(d.session_recording)&&(c.session_recording=zn({},u.session_recording,d.session_recording)),this.set_config(c),this.config.on_xhr_error&&jn.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:ol;const v=this.ku();if(this.persistence=new rl(this.config,v),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new rl(cs(cs({},this.config),{},{persistence:"sessionStorage"}),v,!1),this.Iu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!v&&xr.At()){const t=xr.Dt(this.Iu);fi(t)&&t.forEach(t=>{bi(t)&&this.Tu.add(t)})}else xr.Lt(this.Iu);const f=cs({},this.persistence.props),p=cs({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Nu=new ya((t,i)=>this.qu(t,i),this.config.request_queue_config),this.ju=new $a(this),this.__request_queue=[];const g=this.mu();g||(this.sessionManager=new Ca(this),this.sessionPropsManager=new ka(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{((null==e?void 0:e.activityTimeout)||(null==e?void 0:e.sessionPastMaximumLength)||(null==e?void 0:e.crossTabAdoption))&&this.Bu()})),this.Hu(),this.config.__preview_deferred_init_extensions?(jn.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.zu(g)},0)):(jn.info("Initializing extensions synchronously"),this.zu(g)),e.DEBUG=e.DEBUG||this.config.debug,e.DEBUG&&jn.info("Starting in debug mode",{this:this,config:i,thisC:cs({},this.config),p:f,s:p}),this.config.identity_distinct_id&&!(null===(n=i.bootstrap)||void 0===n?void 0:n.distinctID)&&(i.bootstrap=cs(cs({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const _=null===(r=i.bootstrap)||void 0===r?void 0:r.distinctID;if(this._u=!!_&&!yi(_),null===(l=i.bootstrap)||void 0===l?void 0:l.distinctID){const t=i.bootstrap.distinctID,e=this.get_distinct_id(),s=this.persistence.get_property(vt);if(i.bootstrap.isIdentifiedID&&null!=e&&e!==t&&"anonymous"===s)this.identify(t);else if(i.bootstrap.isIdentifiedID&&null!=e&&e!==t&&"identified"===s)jn.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const e=this.config.get_device_id(er()),s=i.bootstrap.isIdentifiedID?e:t;this.persistence.set_property(vt,i.bootstrap.isIdentifiedID?Dt:Rt),this.register({distinct_id:t,$device_id:s})}}if(g)this.register_once({distinct_id:yt,$device_id:null},"");else if(!this.get_distinct_id()){const t=this.config.get_device_id(er());this.register_once({distinct_id:t,$device_id:t},""),this.persistence.set_property(vt,Rt)}return Kn(qt,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Kn(qt,"pageshow",()=>{var t;this.xu=!1,this.Cu||null===(t=this.ju)||void 0===t||t.resume()}),i.segment?go(this,()=>this.Uu()):this.Uu(),pi(this.config._onCapture)&&this.config._onCapture!==sh&&(jn.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&jn.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return Ma.apply(this,arguments)}().then(t=>{t&&this.register({[o]:t})}).catch(sh),this}Wu(t){const i=t;return bi(i.name)&&pi(i.setup)}Vu(t,i){this.Wu(t)?i.push(()=>{this.Gu().add(t).catch(()=>{var i;return null===(i=t.dispose)||void 0===i?void 0:i.call(t)}).catch(i=>{jn.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.au.push(t)}Hu(){var i,e,s;const n=null!==(i=null===(e=this.config.__extensionClasses)||void 0===e?void 0:e.featureFlags)&&void 0!==i?i:null===(s=t.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,l;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this.Zu)||void 0===r||r.call(this),this.Zu=void 0,this.featureFlags=new n(this)),pi(this.featureFlags.onReloading)&&pi(this.featureFlags.setup)?this.Zu||(this.Zu=this.featureFlags.onReloading(()=>{this.cu.emit("featureFlagsReloading",!0)}),this.Gu().add(this.featureFlags)):null===(o=(l=this.featureFlags).initialize)||void 0===o||o.call(l))}zu(i){const e=performance.now(),s=cs(cs({},t.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,l,a,h,u,d;s.exceptions&&this.au.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.au.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.au.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.au.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!i&&this.au.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Vu(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Vu(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Vu(this.logs=null!==(l=this.logs)&&void 0!==l?l:new s.logs(this),n),s.metrics&&this.au.push(this.metrics=null!==(a=this.metrics)&&void 0!==a?a:new s.metrics(this)),s.conversations&&this.au.push(this.conversations=null!==(h=this.conversations)&&void 0!==h?h:new s.conversations(this)),s.productTours&&this.au.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.au.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.au.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.au.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.au.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,vo)),s.toolbar&&this.au.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this.au.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this.au.forEach(t=>{t.initialize&&n.push(()=>{var i;null===(i=t.initialize)||void 0===i||i.call(t)})}),n.push(()=>{if(this.Qu){const t=this.Qu;this.Qu=void 0,this.au.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}}),this.Ju(n,e)}Ju(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.Ju(t,i)},0);const e=t.shift();if(e)try{e()}catch(t){jn.error("Error initializing extension:",t)}}const e=Math.round(performance.now()-i);this.register_for_session({[$t]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[xt]:e}),this.config.__preview_deferred_init_extensions&&jn.info(`PostHog extensions initialized (${e}ms)`)}tl(t){var i;if(!Gt||!Gt.body)return jn.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.tl(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Qu=t),this.hu=t,this.compression=void 0,t.ok){var e;const i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=li(i.supportedCompression,ol)?ol:li(i.supportedCompression,ll)?ll:void 0),(null===(e=i.analytics)||void 0===e?void 0:e.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Au?this.Au:jt}),null===(i=this.Ku)||void 0===i||i.handleRemoteConfig(t),this.au.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}Uu(){try{this.config.loaded(this)}catch(t){jn.critical("`loaded` function failed",t)}if(this.Xu(),this.config.internal_or_test_user_hostname&&(null==Kt?void 0:Kt.hostname)){const t=Kt.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.mu())&&this.Yu()},1),this.th=new bl(this),this.th.load()}Xu(){var t;this.is_capturing()&&this.config.request_batching&&(null===(t=this.Nu)||void 0===t||t.enable())}_dom_loaded(){this.is_capturing()&&Nn(this.__request_queue,t=>this.qu(t)),this.__request_queue=[],this.Xu()}_handle_unload(){var t,i,e,s,n,r;this.xu=!0,null===(t=this.surveys)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t),null===(e=this.metrics)||void 0===e||e.flush("sendBeacon"),this.config.request_batching?(this.eh()&&this.capture(zt),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this.Nu)||void 0===n||n.unload(),null===(r=this.ju)||void 0===r||r.unload()):this.eh()&&this.capture(zt,null,{transport:"sendBeacon"})}_send_request(t){ba(this,t)}qu(t,i){this.ju?this.ju.retriableRequest(t,i):this._send_request(i?cs(cs({},t),{},{transport:i}):t)}_execute_array(t){eh++;try{let i;const e=[],s=[],n=[];Nn(t,t=>{if(t)if(i=t[0],fi(i))n.push(t);else if(pi(t))try{t.call(this)}catch(i){jn.error("Error executing queued PostHog call",t,i)}else fi(t)&&"alias"===i?e.push(t):fi(t)&&-1!==i.indexOf("capture")&&pi(this[i])?n.push(t):s.push(t)});const r=function(t,i){Nn(t,function(t){try{if(fi(t[0])){let e=i;Ln(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){jn.error("Error executing queued PostHog call",t,i)}})};r(e,this),r(s,this),r(n,this)}finally{eh--}}push(i){if(eh>0&&fi(i)&&bi(i[0])){const e=t.prototype[i[0]];return void(pi(e)&&e.apply(this,i.slice(1)))}this._execute_array([i])}get ih(){return{property:h,persistenceKey:u,cookieName:"_fbc",pattern:ch,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[u]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(u)}}}get nh(){return{property:d,persistenceKey:c,cookieName:"_fbp",pattern:vh,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[c]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(c)}}}sh(t){var i;const e=null===(i=this.persistence)||void 0===i?void 0:i.get_property(t.persistenceKey);return bi(e)&&t.pattern.test(e)?{value:e,delivered:!1}:gi(e)&&bi(e.value)&&t.pattern.test(e.value)?{value:e.value,delivered:!0===e.delivered}:void 0}rh(t,i,e){return i===(null==e?void 0:e.value)?{value:i,pending:!e.delivered}:(t.register(i,!1),{value:i,pending:!0})}oh(t){if(!this.config.save_campaign_params||this.mu())return;const i=Yn(t.cookieName);return bi(i)&&t.pattern.test(i)?i:void 0}ah(t,i,e,s){if(!this.persistence)return;const n=this.ih;this.persistence.refreshKey(n.persistenceKey);const r=this.sh(n);if(s)return void n.unregister();if(e)return bi(i)&&ch.test(i)?this.rh(n,i,r):void n.unregister();const o=bi(t)&&dh.test(t)?t:void 0,l=this.oh(n);return l&&((t,i,e)=>{const s=t.split(".");if(i)return s[3]===i;if(!e)return!0;const n=e.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(l,o,r)?this.rh(n,l,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this.rh(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}uh(t,i,e){if(!this.persistence)return;const s=this.nh;this.persistence.refreshKey(s.persistenceKey);const n=this.sh(s);if(e)return void s.unregister();if(i)return bi(t)&&vh.test(t)?this.rh(s,t,n):void s.unregister();const r=this.oh(s);return r?this.rh(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}hh(t,i){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const e=this.sh(t);(null==e?void 0:e.value)!==i||e.delivered||t.register(i,!0)}capture(t,i,e){var s,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Nu))return void jn.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(mi(t)||!bi(t))return void jn.error("No event name provided to posthog.capture");this.wu();const r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;const o=(null==e?void 0:e.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==o?void 0:o.isRateLimited)return void jn.critical("This capture call is ignored due to client rate limiting.");let l;(null==i?void 0:i.$current_url)&&!bi(null==i?void 0:i.$current_url)&&(jn.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||(null==e?void 0:e.dh)||jn.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const a=new Date,u=(null==e?void 0:e.timestamp)||a,c=Ze(null==e?void 0:e.uuid,er);let v={uuid:c,event:t,properties:this.calculateEventProperties(t,i||{},u,c)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&r&&(v.event="$bot_pageview",v.properties.$browser_type="bot"),o&&(v.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens);const f="$feature_flag_called"===t&&!1===v.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==e?void 0:e.$set)&&!f&&(v.$set=null==e?void 0:e.$set);const p=gi(null==i?void 0:i.$set)?i.$set:void 0,g=fi(null==i?void 0:i.$unset)?i.$unset:[],_=(null==e?void 0:e.$unset)||[],m=t=>{var i;const s=!!(null==e?void 0:e.$set)&&t in e.$set;return{hasProvided:s||!!p&&t in p,provided:s?null==e||null===(i=e.$set)||void 0===i?void 0:i[t]:null==p?void 0:p[t],unset:-1!==g.indexOf(t)||-1!==_.indexOf(t)}},b=m(h),y=m(d),w=[{channel:this.ih,hasProvided:b.hasProvided,update:this.ah(null==l?void 0:l.fbclid,b.provided,b.hasProvided,b.unset)},{channel:this.nh,hasProvided:y.hasProvided,update:this.uh(y.provided,y.hasProvided,y.unset)}];for(const{channel:t,hasProvided:i,update:e}of w)e&&!0===v.properties.$process_person_profile&&e.pending&&!i&&!f&&(v.$set=cs({[t.property]:e.value},v.$set));const x=null==e?void 0:e.$unset;x&&(v.$unset=x);const S=f?void 0:this.fh(null==e?void 0:e.$set_once,t!==Ut,t===Ht);if(S&&(v.$set_once=S),(null==e?void 0:e._noTruncate)||(k=this.config.properties_string_max_length,v=function(t,i){const e=new Set;return function t(s,n){if(s!==Object(s))return i?i(s):s;if(e.has(s))return;let r;if(e.add(s),fi(s))r=[],Nn(s,i=>{r.push(t(i))});else{const i={};Ln(Fi(s)?Vn(s):s,(s,n)=>{e.has(s)||(i[n]=t(s,n))}),r=i}return r}(t)}(v,t=>bi(t)?t.slice(0,k):t)),v.timestamp=u,mi(null==e?void 0:e.timestamp)||(v.properties.$event_time_override_provided=!0,v.properties.$event_time_override_system_time=a),f&&(v.properties=((t,i=[])=>{const e={},s=i=>{void 0!==t[i]&&(e[i]=t[i])};return en.forEach(s),i.forEach(s),e})(v.properties,fh)),t===dl||t===cl){const e=null==i?void 0:i.$survey_id,s=null==i?void 0:i.$survey_iteration;Va({id:e,current_iteration:s}),v.$set=cs(cs({},v.$set),{},{[Ia({id:e,current_iteration:s},t===cl?"responded":"dismissed")]:!0})}else t===ul&&(v.$set=cs(cs({},v.$set),{},{[vl]:(new Date).toISOString()}));var k;if("product tour shown"===t){const t=null==i?void 0:i.$product_tour_type;t&&(v.$set=cs(cs({},v.$set),{},{[`$product_tour_last_seen_date/${t}`]:(new Date).toISOString()}))}const E=cs(cs({},v.properties.$set),v.$set);if(_i(E)||this.setPersonPropertiesForFlags(E),!$i(this.config.before_send)){const t=this.Os(v);if(!t)return;v=t,v.uuid=Ze(v.uuid,er)}this.sessionRecording&&!this.Eu&&uh(t)&&(this.Eu=!0,setTimeout(()=>this.Eu=!1,3e4));const P=w.filter(({channel:t,update:i})=>{var e,s,n;const r=null!==(e=null===(s=v.$set)||void 0===s?void 0:s[t.property])&&void 0!==e?e:gi(null===(n=v.properties)||void 0===n?void 0:n.$set)?v.properties.$set[t.property]:void 0;return(null==i?void 0:i.pending)&&r===i.value});this.cu.emit("eventCaptured",v);const T=null!==(s=null==e?void 0:e._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),C="recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(T),F=cs(cs(cs({method:"POST",url:T,data:v,compression:"best-available",preferSyncCompression:null==e?void 0:e.send_instantly,timestampMode:C?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},C&&(null===(n=v.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:v.properties.$session_id+(v.properties.$window_id?`-${v.properties.$window_id}`:"")}:{}),(null==e?void 0:e.transport)?{transport:e.transport}:{}),P.length?{fireCallbackOnDrop:!0,callback:t=>{if(t.statusCode>=200&&300>t.statusCode)for(const{channel:t,update:i}of P)this.hh(t,i.value)}}:{});if(!this.config.request_batching||e&&!(null==e?void 0:e._batchKey)||(null==e?void 0:e.send_instantly)||P.length){var M;let t;!F.transport&&!F.callback&&_i(null!==(M=this.config.request_headers)&&void 0!==M?M:{})&&this.xu&&(t="sendBeacon"),this.qu(F,t)}else this.Nu.enqueue(F);return v}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null===(i=this.Ku)||void 0===i?void 0:i.getExtension(t)}Gu(){var t;return null!==(t=this.Ku)&&void 0!==t?t:this.Ku=new th(this)}vu(t){this.Mu.push(t);let i=!0;return()=>{if(!i)return;i=!1;const e=this.Mu.indexOf(t);-1!==e&&this.Mu.splice(e,1)}}ph(t=!0){var i,e,s;return!!(null===(i=this.persistence)||void 0===i?void 0:i.consumeCookieIdentityChange())&&(this.Fu=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.Tu.clear(),this.gh()),null===(e=this.featureFlags)||void 0===e||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,e,s,n,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return e;this.persistence.syncCookieProperties(),this.ph();const o=r?void 0:this.persistence.remove_event_timer(t);let l=cs({},e);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this.mu()&&(l[wt]=!0),"$snapshot"===t){const t=cs(cs({},this.persistence.properties()),this.sessionPersistence.properties());return l.distinct_id=t.distinct_id,(!bi(l.distinct_id)&&!xi(l.distinct_id)||yi(l.distinct_id))&&jn.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}const a=function(t,e,s,n=!1){var r,o,l,a;if(!Qt)return{};const h=t?[...Io,...e||[]]:[],[u,d]=Le(Qt),[c,v]=function(t){for(let i=0;qe.length>i;i++){const[e,s,n]=qe[i],r=t.match(e);if(r){const i=n&&t.match(n)||r;return[s,(null==i?void 0:i[1])||""]}}return["",""]}(Qt),f=function(){const t="u">typeof navigator?navigator:void 0;return(null==t?void 0:t.brave)?{brave:!0}:{}}(),p={};mi(s)||(p.detectGoogleSearchApp=s);const g={},_=null===(r=navigator)||void 0===r||null===(r=r.userAgentData)||void 0===r?void 0:r.platform,m=null===(o=navigator)||void 0===o?void 0:o.maxTouchPoints,b=null==qt||null===(l=qt.screen)||void 0===l?void 0:l.width,y=null==qt||null===(a=qt.screen)||void 0===a?void 0:a.height,w=null==qt?void 0:qt.devicePixelRatio;mi(_)||(g.userAgentDataPlatform=_),mi(m)||(g.maxTouchPoints=m),mi(b)||(g.screenWidth=b),mi(y)||(g.screenHeight=y),mi(w)||(g.devicePixelRatio=w);const x=zn(qn({$os:u,$os_version:d,$browser:De(Qt,navigator.vendor,f,p),$webview_app:c,$webview_app_version:v,$device:ze(Qt),$device_type:He(Qt,g),$timezone:Vo(),$timezone_offset:Wo()}),{$current_url:To(n?ts(null==Kt?void 0:Kt.href):null==Kt?void 0:Kt.href,h,Ao),$host:null==Kt?void 0:Kt.host,$pathname:null==Kt?void 0:Kt.pathname,$raw_user_agent:Qt.length>1e3?Qt.substring(0,997)+"...":Qt,$browser_version:Be(Qt,navigator.vendor,f,p),$browser_language:No(),$browser_language_prefix:Lo(),$screen_height:null==qt?void 0:qt.screen.height,$screen_width:null==qt?void 0:qt.screen.width,$viewport_height:null==qt?void 0:qt.innerHeight,$viewport_width:null==qt?void 0:qt.innerWidth,$lib:i.LIB_NAME,$lib_version:i.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return i.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=i.SDK_DIST_CHANNEL),x}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId(r,s.getTime(),!0);l.$session_id=t,l.$window_id=i}this.sessionPropsManager&&zn(l,this.sessionPropsManager.getSessionProps());try{var h;if(this.sessionRecording){const i=this.sessionRecording.sdkDebugProperties,e=!this.Eu&&uh(t);for(const t in i)(e||li(ah,t))&&(l[t]=i[t])}l.$sdk_debug_retry_queue_size=null===(h=this.ju)||void 0===h?void 0:h.length}catch(t){l.$sdk_debug_error_capturing_properties=String(t)}let u;if(this.requestRouter.region===Na&&(l.$lib_custom_api_host=this.config.api_host),u="$pageview"!==t||r?"$pageleave"!==t||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,n),l=zn(l,u),"$pageview"===t&&Gt&&(l.title=Gt.title),!mi(o)){const t=s.getTime()-o;l.$duration=parseFloat((t/1e3).toFixed(3))}Qt&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),c=this.sessionPersistence.properties(),v=l.$groups,f=d.$groups;gi(v)&&!_i(v)&&(l.$groups=cs(cs({},gi(f)?f:{}),v)),Ln(["$referrer","$referring_domain"],t=>{t in d&&delete c[t]});const p={};if(this.Mu.length>0)for(const t of this.Mu.slice())try{zn(p,t())}catch(t){jn.error("Failed to produce browser extension event properties",t)}l=zn({},a,d,c,cs(cs({},p),l)),l.$is_identified=this._isIdentified(),fi(this.config.property_denylist)?Ln(this.config.property_denylist,function(t){delete l[t]}):jn.error(lh+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const g=this.config.sanitize_properties;g&&(jn.error(oh),l=g(l,t));const _=this.mh();return l.$process_person_profile=_,_&&!r&&this.yh("_calculate_event_properties"),l}fh(t,i=!0,e=!1){var s;if(!this.persistence||!this.mh())return t;if(this.$u&&!e)return t;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=zn({},n,r||{},t||{});const l=this.config.sanitize_properties;return l&&(jn.error(oh),o=l(o,"$set_once")),i&&(this.$u=!0),_i(o)?void 0:o}register(t,i){var e;null===(e=this.persistence)||void 0===e||e.register(t,i)}register_once(t,i,e){var s;null===(s=this.persistence)||void 0===s||s.register_once(t,i,e)}register_for_session(t){var i,e;null===(i=this.persistence)||void 0===i||i.syncCookieProperties(),this.ph(),null===(e=this.sessionPersistence)||void 0===e||e.register(t),Object.keys(t).forEach(t=>this.Tu.add(t)),this.gh()}unregister(t){var i;null===(i=this.persistence)||void 0===i||i.unregister(t)}unregister_for_session(t){var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t),this.Tu.delete(t),this.gh()}bh(t,i){this.register({[t]:i})}Bu(){this.Tu.forEach(t=>{var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t)}),this.Tu.clear(),this.gh()}gh(){var t;if(!this.Iu)return;if("memory"===this.config.persistence||(null===(t=this.sessionPersistence)||void 0===t?void 0:t.hi)||!xr.At())return void xr.Lt(this.Iu);const i=[];this.Tu.forEach(t=>i.push(t)),i.length>0?xr.$t(this.Iu,i):xr.Lt(this.Iu)}getFeatureFlag(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,s;return null!==(e=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null===(t=this.featureFlags)||void 0===t||t.reloadFeatureFlags()}updateFlags(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i=!1,e){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.cu.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:rh}),()=>{})}onSessionId(t){var i,e;return null!==(i=null===(e=this.sessionManager)||void 0===e?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:rh})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:rh})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:rh}),()=>{})}renderSurvey(t,i){var e;null===(e=this.surveys)||void 0===e||e.renderSurvey(t,i)}displaySurvey(t,i=Ga){var e;null===(e=this.surveys)||void 0===e||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null===(i=this.surveys)||void 0===i||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null===(e=this.surveys)||void 0===e?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:rh}}canRenderSurveyAsync(t,i=!1){var e,s;return null!==(e=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:rh})}_h(t){return!t||yi(t)?(jn.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(jn.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(jn.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return jn.uninitializedWarning("posthog.identify");if(xi(t)&&(t=t.toString(),jn.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._h(t))return;if(!this.yh("posthog.identify"))return;this.wu();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.ph(!1),o=this.persistence.Fa();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),t!==s&&t!==this.get_property("__alias")&&(this.unregister(l),this.register({distinct_id:t}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Rt,u=t!==s,d=!u&&o;if(u&&o){var h;const n=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:s};this.persistence.set_property(vt,Dt),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Oa(),this.capture("$identify",n,{$set:i||{},$set_once:e||{}})&&(this.Fu=Ba(t,i,e)),null===(h=this.featureFlags)||void 0===h||h.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(d){this.persistence.set_property(vt,Dt);const s=i||{},n=e||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.Oa(),this.capture("$set",{$set:s,$set_once:n})&&(this.Fu=Ba(t,i,e))}else(i||e)&&this.setPersonProperties(i,e);u||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ht)):d&&(i||e)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.Na(a)}}setPersonProperties(t,i){if(!t&&!i)return;if(!this.yh("posthog.setPersonProperties"))return;const e=Ba(this.get_distinct_id(),t,i);this.Fu!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}})&&(this.Fu=e)):jn.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;const e=(fi(t)?t:[t]).filter(t=>bi(t)&&t.length>0);0!==e.length&&this.yh("posthog.unsetPersonProperties")&&(null===(i=this.featureFlags)||void 0===i||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.Fu=null)}group(t,i,e){var s;if(!t||!i)return void jn.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.ph();const n=this.getGroups(),r=n[t]!==i;if(r&&this.resetGroupPropertiesForFlags(t),this.register({$groups:cs(cs({},n),{},{[t]:i})}),(r||e)&&this.mh()){const s={$group_type:t,$group_key:i};e&&(s.$group_set=e),this.capture(Ut,s)}e&&this.setGroupPropertiesForFlags({[t]:e}),r&&!e&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var e;null===(e=this.featureFlags)||void 0===e||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var e;this.yh("posthog.setGroupPropertiesForFlags")&&(null===(e=this.featureFlags)||void 0===e||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null===(i=this.featureFlags)||void 0===i||i.resetGroupPropertiesForFlags(t)}reset(t){const i=ki(t)?t:null==t?void 0:t.resetDeviceID,e=ki(t)||null==t?void 0:t.bootstrap;this.wh(i,!1,e)}wh(t,i=!1,e){var s,n,l,a,h,u;if(jn.info("reset"),!this.__loaded)return jn.uninitializedWarning("posthog.reset");const d=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null===(s=this.Du)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(l=n.updateConfig)||void 0===l||l.call(n,this.config,this.el());const c=this.get_property(r),v=this.get_property(o),f=this.get_property(k);null===(a=this.sessionRecording)||void 0===a||a.flushBeforeIdentityReset();const p=this.is_capturing();this.consent.reset(),i||!p||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const g=null===(h=this.persistence)||void 0===h||null===(u=h.Fa)||void 0===u?void 0:u.call(h);let _=!1;try{var m,b,y,w,x,S,E,P,T,C,F,M,I;if(null===(m=this.persistence)||void 0===m||m.clear(),null===(b=this.sessionPersistence)||void 0===b||b.clear(),this.Tu.clear(),this.gh(),mi(f)||null===(C=this.persistence)||void 0===C||C.register({$session_recording_remote_config:f}),null===(y=this.surveys)||void 0===y||y.reset(),null===(w=this.featureFlags)||void 0===w||w.reset(),null===(x=this.conversations)||void 0===x||x.reset(),null===(S=this.logs)||void 0===S||S.reset(),null===(E=this.metrics)||void 0===E||E.reset(),null===(P=this.persistence)||void 0===P||P.set_property("$user_state","anonymous"),null===(T=this.sessionManager)||void 0===T||T.resetSessionId(),this.Fu=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:yt,$device_id:null},"");else{const i=this.config.get_device_id(er());this.register_once({distinct_id:i,$device_id:t?i:c},""),t||mi(v)||this.register({[o]:v})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(e.distinctID&&!this.mu()&&(null===(I=this.persistence)||void 0===I||I.set_property("$user_state",e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:e.distinctID})),null===(F=this.featureFlags)||void 0===F||F.initialize(),!$i(d)&&!(null===(M=this.sessionManager)||void 0===M?void 0:M.setBootstrapSessionId(d,!0))){const t=cs({},e);delete t.sessionID,this.config.bootstrap=t}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var O,A;g&&(null===(O=this.persistence)||void 0===O||null===(A=O.Na)||void 0===A||A.call(O,_))}this.reloadFeatureFlags()}shutdown(t){var i=this;return ji(function*(){var t,e,s,n,r,o,l,a;if(i.__loaded){i.Cu=!0,i.Gu().dispose(),null===(t=i.sessionRecording)||void 0===t||t.dispose(),null===(e=i.logs)||void 0===e||e.flushLogs("sendBeacon"),null===(s=i.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=i.metrics)||void 0===n||n.dispose(),null===(r=i.Nu)||void 0===r||r.unload(),null===(o=i.ju)||void 0===o||o.unload();try{var h;null===(h=i.featureFlags)||void 0===h||h.destroy()}catch(t){jn.error("Error while destroying feature flags",t)}null===(l=i.persistence)||void 0===l||l.destroy(),null===(a=i.sessionPersistence)||void 0===a||a.destroy()}else jn.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null===(e=this.conversations)||void 0===e||e.kh()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(t=this.conversations)||void 0===t||t.Sh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:i,sessionStartTimestamp:e}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if((null==t?void 0:t.withTimestamp)&&e){var n;const i=null!==(n=t.timestampLookBack)&&void 0!==n?n:10;if(!e)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-e)/1e3)-i,0)}`}return s}alias(t,i){return t===this.get_property("$people_distinct_id")?(jn.critical("Attempting to create alias for existing People user - aborting."),-2):this.yh("posthog.alias")?(mi(i)&&(i=this.get_distinct_id()),t!==i?(this.bh(l,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(jn.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const i=cs({},this.config);if(gi(t)){var s,n,r,o,l,a,h,u,d,c,v,f,p,g;zn(this.config,bh(t));const m=this.ku();null===(s=this.persistence)||void 0===s||s.update_config(this.config,i,m),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new rl(cs(cs({},this.config),{},{persistence:"sessionStorage"}),m,!1);const b=this.Ou(this.config.debug);var _;ki(b)&&(this.config.debug=b),ki(this.config.debug)&&(this.config.debug?(e.DEBUG=!0,hr.At()&&hr.$t("ph_debug",!0),jn.info("set_config",{config:t,oldConfig:i,newConfig:cs({},this.config)})):(e.DEBUG=!1,hr.At()&&hr.Lt("ph_debug"))),null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.el()),null===(o=this.exceptionObserver)||void 0===o||o.onConfigChange(),null===(l=this.exceptions)||void 0===l||l.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(h=this.sessionRecording)||void 0===h||h.startIfEnabledOrStop(),null===(u=this.tracingHeaders)||void 0===u||u.startIfEnabledOrStop(),null===(d=this.autocapture)||void 0===d||d.startIfEnabled(),null===(c=this.heatmaps)||void 0===c||c.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null===(_=this.historyAutocapture)||void 0===_||_.startIfEnabledOrStop()),null===(v=this.exceptionObserver)||void 0===v||v.startIfEnabledOrStop(),null===(f=this.deadClicksAutocapture)||void 0===f||f.startIfEnabledOrStop(),null===(p=this.surveys)||void 0===p||p.loadIfEnabled(),this.Su(),null===(g=this.externalIntegrations)||void 0===g||g.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&go(this,sh,!1)}}_overrideSDKInfo(t,i){e.LIB_NAME=t,e.LIB_VERSION=i}startSessionRecording(t){const i=!0===t,e={sampling:i||!!(null==t?void 0:t.sampling),linked_flag:i||!!(null==t?void 0:t.linked_flag),url_trigger:i||!!(null==t?void 0:t.url_trigger),event_trigger:i||!!(null==t?void 0:t.event_trigger)};var s,n,r,o,l;Object.values(e).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),e.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),e.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),e.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),e.event_trigger&&(null===(l=this.sessionRecording)||void 0===l||l.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(null===(t=this.sessionRecording)||void 0===t?void 0:t.started)}captureException(t,i){try{if(!this.exceptions)return;const e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(cs(cs({},e),i))}catch(t){return}}addExceptionStep(t,i){var e;null===(e=this.exceptions)||void 0===e||e.addExceptionStep(t,i)}captureLog(t){var i;null===(i=this.logs)||void 0===i||i.captureLog(t)}get logger(){var i,e;return null!==(i=null===(e=this.logs)||void 0===e?void 0:e.logger)&&void 0!==i?i:t.xh}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null===(e=this.toolbar)||void 0===e?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null===(i=this.persistence)||void 0===i?void 0:i.props[t]}getSessionProperty(t){var i;return null===(i=this.sessionPersistence)||void 0===i?void 0:i.props[t]}toString(){var t;let i=null!==(t=this.config.name)&&void 0!==t?t:ph;return i!==ph&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))||"identified"===(null===(i=this.sessionPersistence)||void 0===i?void 0:i.get_property("$user_state"))}mh(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&_i(this.getGroups())&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.__alias)&&!(null===(i=this.persistence)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.$epp))}eh(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.mh()||this.yh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.yh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}yh(t){return"never"===this.config.person_profiles?(jn.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.yu(),this.bh(bt,!0),!0)}ku(){if("always"===this.config.cookieless_mode)return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}Su(){var t,i;const e=this.ku();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.Ch(),(null===(t=this.persistence)||void 0===t?void 0:t.hi)!==e&&(null===(n=this.persistence)||void 0===n||n.set_disabled(e)),(null===(i=this.sessionPersistence)||void 0===i?void 0:i.hi)!==e&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(e)),e&&(this.Tu.clear(),this.gh()),e}opt_in_capturing(i){var e;if("always"!==this.config.cookieless_mode){if(this.mu()){var s,n,r,o,l,a;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.wh(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Ca(this),this.pageViewManager=new yo(this),this.persistence&&(this.sessionPropsManager=new ka(this,this.sessionManager,this.persistence));const i=null!==(o=null===(l=this.config.__extensionClasses)||void 0===l?void 0:l.sessionRecording)&&void 0!==o?o:null===(a=t.__defaultExtensionClasses)||void 0===a?void 0:a.sessionRecording;var h,u;i&&(this.sessionRecording=this.gu(this.sessionRecording,new i(this)),this.hu&&(null===(h=this.sessionRecording)||void 0===h||null===(u=h.onRemoteConfig)||void 0===u||u.call(h,this.hu)))}var d,c;this.consent.optInOut(!0),this.Su(),this.Xu(),null===(e=this.sessionRecording)||void 0===e||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(mi(null==i?void 0:i.captureEventName)||(null==i?void 0:i.captureEventName))&&this.capture(null!==(c=null==i?void 0:i.captureEventName)&&void 0!==c?c:"$opt_in",null==i?void 0:i.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Yu()}else jn.warn(nh)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void jn.warn(nh);const t="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var i,e;null==t||t.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.wh(!0,!0),this.consent.optInOut(!1),this.Su(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:yt,$device_id:null}),this.pu(t),this.sessionRecording=void 0,null===(i=this.sessionManager)||void 0===i||i.destroy(),null===(e=this.pageViewManager)||void 0===e||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Yu(),this.Xu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Su()}_is_bot(){return Wt?Fa(Wt,this.config.custom_blocked_useragents):void 0}Yu(){Gt&&("visible"===Gt.visibilityState?this.Pu||(this.Pu=!0,this.capture(Lt,{title:Gt.title},{send_instantly:!0}),this.Ru&&(Gt.removeEventListener(Bt,this.Ru),this.Ru=null)):this.Ru||(this.Ru=this.Yu.bind(this),Kn(Gt,Bt,this.Ru)))}debug(t){!1===t?(null==qt||qt.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==qt||qt.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}el(){const t=this.Du||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(jn.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(t,i,e,s,n){const r=i in t&&!$i(t[i]),o=e in t&&!$i(t[e]);return r?t[i]:!!o&&(n&&n.warn(`Config field '${e}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,jn)}Os(t){var i;if($i(this.config.before_send))return t;const e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(Pi),s=fi(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const i of s)try{if(n=i(n),$i(n)){const i=`Event '${t.event}' was rejected in beforeSend function`;return Ei(t.event)?jn.warn(`${i}. This can cause unexpected behavior.`):jn.info(i),null}n.properties&&!_i(n.properties)||jn.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(i){return jn.error(`Error in beforeSend function for event '${t.event}':`,i),null}for(const i of e)if(n.properties&&$i(n.properties[i]))return jn.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return null===(t=this.pageViewManager.Uo)||void 0===t?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Ou(t){const i=ki(t)&&!t,e=hr.At()&&"true"===hr.Ot("ph_debug");return!i&&(!!e||t)}};wh.__defaultExtensionClasses={},wh.xh=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(let e=0;i.length>e;e++)t.prototype[i[e]]=Un(t.prototype[i[e]])}(wh,["identify"]);var $h=class{constructor(t){this.disabled=!1===t;const i=gi(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(t-s.x)+Math.abs(i-s.y)<this.thresholdPx&&this.timeoutMs>e-s.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}};const xh="$copy_autocapture",Sh=Bn("[AutoCapture]");function kh(t,i){return i.length>t?i.slice(0,t)+"...":i}function Eh(t){if(t.previousElementSibling)return t.previousElementSibling;let i=t;do{i=i.previousSibling}while(i&&!Pr(i));return i}function Ph(t,{e:i,maskAllElementAttributes:e,maskAllText:s,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var l,a;if(!Pr(t))return{props:{}};const h=[t],u=new Set([t]);let d=t;for(;d.parentNode&&!Tr(d,"body")&&1e3>h.length;){if(Fr(d.parentNode)){const t=d.parentNode.host;if(u.has(t))break;u.add(t),h.push(t),d=t;continue}if(!Pr(d.parentNode))break;if(u.has(d.parentNode))break;u.add(d.parentNode),h.push(d.parentNode),d=d.parentNode}const c="click"===i.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?h.findIndex(t=>Tr(t,"button")||Tr(t,"a")):-1;c>0&&(s=s||h.slice(0,c+1).some(t=>!Yr(t)||Xr(t)));const v=[],f={};let p,g=!1,_=!1;if(Ln(h,t=>{const i=Yr(t);if(Tr(t,"a")&&!e&&!(null==n?void 0:n.includes("href"))){const e=t.getAttribute("href");g=!!(i&&e&&ro(e))&&(o?ts(e):e)}li(Or(t),"ph-no-capture")&&(_=!0),v.push(function(t,i,e,s,n=!1){const r=t.tagName.toLowerCase(),o={tag_name:r};jr.indexOf(r)>-1&&!e&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?kh(1024,oo(t)):kh(1024,Rr(t)));const l=Or(t);i||(null==s?void 0:s.includes("class"))||0>=l.length||(o.classes=l.filter(function(t){return""!==t})),Ln(t.attributes,function(e){var r;if((!Xr(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&!(null==s?void 0:s.includes(e.name))&&!i&&ro(e.value)&&(!bi(r=e.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let t=e.value;"class"===e.name&&(t=Mr(t).join(" ")),o["attr__"+e.name]=kh(1024,"href"===e.name&&n?ts(t):t)}});let a=1,h=1,u=t;for(;u=Eh(u);)a++,u.tagName===t.tagName&&h++;return o.nth_child=a,o.nth_of_type=h,o}(t,e,s,n,o)),Ln(function(t){if(!Yr(t))return{};const i={};return Ln(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){const e=t.name.replace("data-ph-capture-attribute-",""),s=t.value;e&&s&&ro(s)&&(i[e]=s)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(f,i)||(f[i]=t)})}),_)return{props:{},explicitNoCapture:_};if(c>0&&(t=h[c],v.splice(0,c)),s||(v[0].$el_text=Tr(t,"a")||Tr(t,"button")?oo(t):Rr(t)),g){var m,b;v[0].attr__href=g;const t=null===(m=Eo(g))||void 0===m?void 0:m.host,i=null==qt||null===(b=qt.location)||void 0===b?void 0:b.host;t&&i&&t!==i&&(p=g)}return{props:zn((w=i.type,{$event_type:w,$ce_version:1}),r?{}:{$elements:v},{$elements_chain:(y=v,fi(y)?function(t){return t.map(t=>{var i,e;let s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class){t.attr_class.sort();for(const i of t.attr_class)s+=`.${i.replace(/"/g,"")}`}const n=cs(cs(cs(cs({},t.text?{text:t.text}:{}),{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{}),t.attr_id?{attr_id:t.attr_id}:{}),t.attributes),r={};return Hn(n).sort(([t],[i])=>function(t,i){return i>t?-1:t>i?1:0}(t,i)).forEach(([t,i])=>r[ao(t.toString())]=ao(i.toString())),s+=":",s+=Hn(r).map(([t,i])=>`${t}="${i}"`).join(""),s}).join(";")}(function(t){return t.map(t=>{var i,e;const s={text:null===(i=t.$el_text)||void 0===i?void 0:i.slice(0,400),tag_name:t.tag_name,href:null===(e=t.attr__href)||void 0===e?void 0:e.slice(0,2048),attr_class:ho(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Hn(t).filter(([t])=>0===t.indexOf("attr__")).forEach(([t,i])=>s.attributes[t]=i),s})}(y)):"")},(null===(l=v[0])||void 0===l?void 0:l.$el_text)?{$el_text:null===(a=v[0])||void 0===a?void 0:a.$el_text}:{},p&&"click"===i.type?{$external_click_url:p}:{},f),target:t};var y,w}var Th=class{co(){this.do=void 0,clearTimeout(this.vo),this.vo=void 0}fo(t){var i;if(!Yr(t))return!0;const e=null!==(i=this.po().css_selector_ignorelist)&&void 0!==i?i:zr,s=new Set;let n=t;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const t=n,i=Or(t);if(li(i,"ph-no-capture")||li(i,"ph-sensitive")||Xr(t)||e.some(i=>Br(t,i)))return!0;const r=n.parentNode;n=Fr(r)?r.host:r&&Pr(r)?r:null}return!1}mo(t){if(!this.isEnabled||"pointercancel"===t.type)return void this.co();if("pointerdown"===t.type){this.co();const e=Dr(t);var i;return void(t.isPrimary&&0===t.button&&!t.ctrlKey&&e&&Pr(e)&&(this.do={target:e,excluded:this.fo(e),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null===(i=this.yo)||void 0===i?void 0:i.distinctId}))}const e=this.do;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.co():"pointerup"===t.type&&(e.released=!0,this.vo=setTimeout(()=>this.co(),0)))}bo(t){var i;const e=this.do;this.co();const s=Dr(t);if((null==e?void 0:e.released)&&e.target.isConnected&&e.distinctId===(null===(i=this.yo)||void 0===i?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&s&&(Tr(s,"html")||Tr(s,"body"))){var n;if(e.excluded)return null;const t=null!==(n=this.po().css_selector_ignorelist)&&void 0!==n?n:zr;return[s,null==Gt?void 0:Gt.documentElement,null==Gt?void 0:Gt.body].some(i=>{if(!i)return!1;const e=Or(i);return li(e,"ph-no-capture")||li(e,"ph-sensitive")||!Yr(i)||Xr(i)||t.some(t=>Br(i,t))})?null:e.target}}constructor(t){this._o=t,this.name="autocapture",this.wo=!1,this.ko=null,this.So=!1,this.xo=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.$o=!1,this._o.refresh(this.Mr),this.rageclicks=new $h(this.Mr.rageclick),this.To=null}setup(t){this.Io(),this.yo=t;const i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.$o?i.dispose():(this.Mo=i,this.startIfEnabled())}dispose(){var t;this.$o||(this.$o=!0,this.yo=void 0,null===(t=this.Mo)||void 0===t||t.dispose(),this.Mo=void 0,this.xo.clear(),this.To=null,this.Eo())}po(){return this._o.refresh(this.Mr),this.Mr}Io(){var t,i;return this.po(),this.Mr.url_allowlist=null===(t=this.Mr.url_allowlist)||void 0===t?void 0:t.map(t=>new RegExp(t)),this.Mr.url_ignorelist=null===(i=this.Mr.url_ignorelist)||void 0===i?void 0:i.map(t=>new RegExp(t)),this.Mr}Po(){if(!this.isBrowserSupported())return void Sh.info("Disabling Automatic Event Collection because this browser is not supported");if(!qt||!Gt)return;const t=this.Ro=t=>{t=t||(null==qt?void 0:qt.event);try{if("blur"===t.type)return void this.co();if(0===t.type.indexOf("pointer"))return void this.mo(t);const i="click"===t.type?this.bo(t):void 0;if(wi(i))return;this.Ao(t,"$autocapture",i)}catch(t){Sh.error("Failed to capture event",t)}};if(Kn(qt,"blur",t),Kn(Gt,"submit",t,{capture:!0}),Kn(Gt,"change",t,{capture:!0}),Kn(Gt,"click",t,{capture:!0}),Ln(["pointerdown","pointermove","pointerup","pointercancel"],i=>{Kn(Gt,i,t,{capture:!0})}),this.po().capture_copied_text){const t=this.Fo=t=>{t=t||(null==qt?void 0:qt.event);try{this.Ao(t,xh)}catch(t){Sh.error("Failed to capture clipboard event",t)}};Kn(Gt,"copy",t,{capture:!0}),Kn(Gt,"cut",t,{capture:!0}),Kn(Gt,"paste",t,{capture:!0})}}Eo(){this.co(),this.Ro&&(null==qt||qt.removeEventListener("blur",this.Ro),Ln(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==Gt||Gt.removeEventListener(t,this.Ro,!0)}),null==Gt||Gt.removeEventListener("submit",this.Ro,!0),null==Gt||Gt.removeEventListener("change",this.Ro,!0),null==Gt||Gt.removeEventListener("click",this.Ro,!0),this.Ro=void 0),this.Fo&&(null==Gt||Gt.removeEventListener("copy",this.Fo,!0),null==Gt||Gt.removeEventListener("cut",this.Fo,!0),null==Gt||Gt.removeEventListener("paste",this.Fo,!0),this.Fo=void 0),this.wo=!1}startIfEnabled(){this.isEnabled||this.co(),!this.$o&&this.yo&&this.isEnabled&&!this.wo&&(this.Po(),this.wo=!0)}onRemoteConfig(t){if(this.$o)return;if(this.So=!0,!t.ok)return void this.startIfEnabled();const i=t.config;i.elementsChainAsString&&(this.Co=i.elementsChainAsString);const e=i.autocapture_opt_out;var s;ki(e)&&(null===(s=this.yo)||void 0===s||s.kv.set("$autocapture_disabled_server_side",e),this.ko=e),this.startIfEnabled()}setElementSelectors(t,i=this){if(this.$o)return;t.size?this.xo.set(i,new Set(t)):this.xo.delete(i);const e=new Set;this.xo.forEach(t=>{t.forEach(t=>e.add(t))}),this.To=e}getElementSelectors(t,i){var e;const s=[];return null===(e=this.To)||void 0===e||e.forEach(e=>{const n=null==Gt?void 0:Gt.querySelectorAll(e);null==n||n.forEach(n=>{t!==n&&i!==n||li(s,e)||s.push(e)})}),s}get isEnabled(){var t,i;if(this.$o)return!1;const e=null===(t=this.yo)||void 0===t?void 0:t.kv.get(f),s=this.ko,n=this.po();if(!n.remoteRequestsDisabled&&!this.So)return!1;const r=n.remoteRequestsDisabled&&!this.So;if(wi(s)&&!ki(e)&&!r)return!1;const o=null!==(i=this.ko)&&void 0!==i?i:!!e;return!!n.enabled&&!o}Ao(t,i="$autocapture",e){if(!this.isEnabled)return void this.co();let s=e||Dr(t);Cr(s)&&(s=s.parentNode||null);const n=this.Io();var r;"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&n.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime()))&&Gr(s,n.rageclick)&&this.Ao(t,"$rageclick",e);const o=i===xh,l=o?cs(cs({},n),{},{dom_event_allowlist:void 0}):n;if(s&&function(t,i,e,s,n,r){var o;if(!qt||Kr(t))return!1;if((null==e?void 0:e.url_allowlist)&&!Ir(e.url_allowlist,r))return!1;if((null==e?void 0:e.url_ignorelist)&&Ir(e.url_ignorelist,r))return!1;if(null==e?void 0:e.dom_event_allowlist){const t=e.dom_event_allowlist;if(t&&!t.some(t=>i.type===t))return!1}const{parentIsUsefulElement:l,targetElementList:a}=Jr(t,s);if(!function(t,i){const e=null==i?void 0:i.element_allowlist;if(mi(e))return!0;for(const i of t)if(e.some(t=>i.tagName.toLowerCase()===t))return!0;return!1}(a,e))return!1;if(!Nr(a,null==e?void 0:e.css_selector_allowlist))return!1;if(Nr(a,null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:zr))return!1;try{const e=qt.getComputedStyle(t);if(e&&"pointer"===e.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}const h=t.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return l?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(jr.indexOf(h)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var a;const{props:e,explicitNoCapture:r,target:o}=Ph(s,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(r)return!1;const l=this.getElementSelectors(s,o);if(l&&l.length>0&&(e.$element_selectors=l),i===xh){const i=t.type||"clipboard";if("paste"!==i){var h,u;const t=null==qt||null===(h=qt.getSelection())||void 0===h?void 0:h.toString(),i=Ar(t);if(!i)return!1;e.$selected_content=i,e.$clipboard_text_length=null!==(u=null==t?void 0:t.length)&&void 0!==u?u:0}e.$copy_type=i}return null===(a=this.yo)||void 0===a||a.capture(i,e),!0}}isBrowserSupported(){return pi(null==Gt?void 0:Gt.querySelectorAll)}},Ch=class{constructor(t){this._instance=t}refresh(t){const i=this._instance.config,e=gi(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.el(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}};const Fh=Bn("[ExceptionAutocapture]"),Mh=()=>{},Ih=t=>{var i;if(pi(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function Oh(t,i,e){try{if(!(i in t))return Mh;const s={next:t[i]},n=e(function(...t){return s.next.apply(this,t)});return pi(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),t[i]=n,()=>{if(t[i]===n)return void(t[i]=s.next);let e=t[i],r=Ih(e);for(;r;){if(r.next===n)return void(r.next=s.next);e=r.next,r=Ih(e)}}}catch(t){return Mh}}const Ah=Bn("[TracingHeaders]"),Rh=Bn("[Web Vitals]"),Dh=9e5,jh=["CLS","FCP","INP","LCP"],Bh=["INP","LCP"],Nh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Lh="disabled",zh="lazy_loading",Hh=Bn("[SessionRecording]"),Uh=[St,kt,Et,Pt,Tt,Ct,Ft,Mt,It],qh=Bn("[Heatmaps]");function Vh(t){return gi(t)&&"clientX"in t&&"clientY"in t&&xi(t.clientX)&&xi(t.clientY)}const Wh=Bn("[Product Tours]"),Gh=t=>{var i;return!t.config.disable_product_tours&&!!(null===(i=t.persistence)||void 0===i?void 0:i.get_property(w))},Kh=["$set_once","$set"],Jh=Bn("[SiteApps]"),Yh="Error while initializing PostHog app with config id ",Xh=(t,i)=>(null==t?void 0:t.then)?t.then(i):i(t),Zh="SDK is not enabled or survey functionality is not yet loaded",Qh="Disabled. Not loading surveys.";var tu=class{constructor(t,i){this._o=t,this.$h=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Th=!1,this.Ih=!1,this.Mh=[],this.Eh=[],this.Ph=null,this.Rh=null,this.$o=!1,this.Ah=new Set,this.onRemoteConfig=t=>{if(this.$o)return;if(this.Mr.disableSurveys)return;if(!t.ok)return this.Ih=!0,this.Fh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),qa.warn("Remote config unavailable. Not loading surveys.");const i=t.config.surveys;if($i(i))return qa.warn("Flags not loaded yet. Not loading surveys.");this.Oh=ki(i)?i:i.length>0,qa.info(`flags response received, isSurveysEnabled: ${this.Oh}`),this.loadIfEnabled()},this.Fh=t=>{this.Eh.slice().forEach(i=>this.Dh(i,t))}}setup(t){if(!this.$o)return this.Lh=t,Xh(t.kv.initialize(),()=>{if(this.Lh!==t||this.$o)return;this.Lh=void 0,this.yo=t;const i=t.onRemoteConfig(this.onRemoteConfig);this.$o?i.dispose():(this.Mo=i,this.loadIfEnabled())})}dispose(){var t,i,e,s,n;this.$o||(this.$o=!0,this.Lh=void 0,this.yo=void 0,null===(t=this.Mo)||void 0===t||t.dispose(),this.Mo=void 0,null===(i=this._surveyEventReceiver)||void 0===i||i.dispose(),this._surveyEventReceiver=null,null===(e=this._surveyManager)||void 0===e||null===(s=e.dispose)||void 0===s||s.call(e),this._surveyManager=null,this.Mh=[],this.Eh.forEach(t=>{t.active=!1}),this.Eh=[],null===(n=this.Nh)||void 0===n||n.call(this),this.Nh=void 0,this.Ph=null,this.Ah.forEach(t=>clearTimeout(t)),this.Ah.clear())}get Mr(){return this._o.get()}initialize(){this.loadIfEnabled()}reset(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.clearInMemoryInProgressSurveyState)||void 0===i||i.call(t);try{var e;null===(e=this._surveyEventReceiver)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let i=0;i<localStorage.length;i++){const e=localStorage.key(i);((null==e?void 0:e.startsWith("seenSurvey_"))||(null==e?void 0:e.startsWith("inProgressSurvey_")))&&t.push(e)}t.forEach(t=>localStorage.removeItem(t))}catch(t){}this.Fh()}loadIfEnabled(){if(this.$o||!this.yo)return;const t=this.Mr;if(this._surveyManager)return;if(this.Th)return void qa.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void qa.info(Qh);if(t.cookielessMode&&this._o.isOptedOut())return void qa.info("Not loading surveys in cookieless mode without consent.");const i=this._o.getExtensions();if(!i)return void this.qh("PostHog Extensions not found.");if(mi(this.Oh)&&!t.advancedEnableSurveys)return;const e=this.Oh||t.advancedEnableSurveys;this.Th=!0,this.Ih=!1;try{const t=i.generateSurveys;if(t)return this.jh(t,e),void(this.Th=!1);const s=i.loadExternalDependency;if(!s)return this.qh(At),void(this.Th=!1);s(t=>{try{if(this.$o)return;const i=this._o.getExtensions();t||!(null==i?void 0:i.generateSurveys)?this.qh("Could not load surveys script",t):this.jh(i.generateSurveys,e)}finally{this.Th=!1}})}catch(t){throw this.Th=!1,this.qh("Error initializing surveys",t),t}}jh(t,i){var e,s;if(this.$o)return;this._surveyManager=t(i),this._surveyEventReceiver=this._o.createEventReceiver(this.Fh);const n=null===(e=null!==(s=this.yo)&&void 0!==s?s:this.$h)||void 0===e?void 0:e.kv.get(X);n&&this.Bh(n),qa.info("Surveys loaded successfully"),this.Hh(),this.Fh(),this.zh({isLoaded:!0})}qh(t,i){this.Ih=!0,qa.error(t,i),this.Fh({isLoaded:!1,error:t}),this.zh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Mh.push(t),this._surveyManager&&this.zh({isLoaded:!0}),()=>{this.Mh=this.Mh.filter(i=>i!==t)}}getSurveys(t,i=!1){var e;const s=null!==(e=this.yo)&&void 0!==e?e:this.$h;if(!s||this.$o)return;if(this.Mr.disableSurveys)return qa.info(Qh),t([]);const n=s.kv.get(X);if(n&&!i)return t(n,{isLoaded:!0}),void(this.Uh()&&this.getSurveys(()=>{},!0));if(this.Ph)return void this.Ph.then(({surveys:i,context:e})=>{this.$o||t(i,e)}).catch(t=>qa.error("Error in survey callback",t));const r=this.Wh("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{try{return this.Vh(s,t)}catch(t){return qa.error("Error processing surveys response",t),this.Vh(s,{statusCode:0,error:t})}},t=>this.Vh(s,{statusCode:0,error:t}));this.Ph=r;const o=()=>{this.Ph===r&&(this.Ph=null)};r.then(i=>{o(),this.$o||(this.Fh(i.context),t(i.surveys,i.context))},o).catch(t=>qa.error("Error in survey callback",t))}Wh(t,i){const e=this.yo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(Zh)}))}Vh(t,i){if(this.$o)return{surveys:[],context:{isLoaded:!1,error:Zh}};const e=i.statusCode;if(200!==e||!i.json){const t=`Surveys API could not be loaded, status: ${e}`;return 0!==e?qa.error(t):i.error||qa.warn(t),this.Rh=Date.now(),{surveys:[],context:{isLoaded:!1,error:t}}}this.Rh=null;const s=i.json.surveys||[];return t.kv.set({[X]:s,[Z]:Date.now()}),this.Bh(s),{surveys:s,context:{isLoaded:!0}}}Bh(t){var i;const e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Oa(t)||function(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}(t)));null===(i=this._surveyEventReceiver)||void 0===i||i.replace(e)}Uh(){return this.Gh()&&!this.Ph&&!this.Zh()}Gh(){var t,i;const e=null===(t=null!==(i=this.yo)&&void 0!==i?i:this.$h)||void 0===t?void 0:t.kv.get(Z);return xi(e)&&Date.now()-e>3e5}Zh(){return xi(this.Rh)&&3e5>Date.now()-this.Rh}markSurveyAsSeen(t,i){var e;const s={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};Va(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Fh()}zh(t){for(const i of this.Mh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){qa.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i=!1){if(!$i(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);qa.warn("init was not called")}onActiveMatchingSurveysChanged(t){var i,e;if(this.$o)return()=>{};const s={callback:t,active:!0,revision:0};this.Eh.push(s),this.Hh();const n=null===(i=null!==(e=this.yo)&&void 0!==e?e:this.$h)||void 0===i?void 0:i.kv.get(X);return this.Mr.disableSurveys||!this._surveyManager&&this.Ih&&!this.Th||!n&&!$i(this.Rh)&&!this.Ph?this.Dh(s,{isLoaded:!1}):this._surveyManager&&this.Dh(s),()=>{var t;s.active=!1,this.Eh=this.Eh.filter(t=>t!==s),0===this.Eh.length&&(null===(t=this.Nh)||void 0===t||t.call(this),this.Nh=void 0)}}Hh(){var t,i,e;this._surveyManager&&this.Eh.length>0&&(null!==(t=this.Nh)&&void 0!==t||(this.Nh=null===(i=(e=this._o).onMatchingConditionsChanged)||void 0===i?void 0:i.call(e,this.Fh)))}Dh(t,i){if(this.$o||!t.active)return;const e=++t.revision,s=s=>{if(!this.$o&&t.active&&e===t.revision)try{const e=null!=i?i:{isLoaded:!0},n=JSON.stringify([s,e]);if(n===t.lastResult)return;t.lastResult=n,t.callback(s,e)}catch(t){qa.error("Error in active matching surveys callback",t)}};try{i&&!i.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(t){qa.error("Error in active matching surveys callback",t)}}Qh(t){let i=null;return this.getSurveys(e=>{var s;i=null!==(s=e.find(i=>i.id===t))&&void 0!==s?s:null}),i}Jh(t){if($i(this._surveyManager))return{eligible:!1,reason:Zh};const i="string"==typeof t?this.Qh(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Kh(t){if(!this._o.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if($i(this._surveyManager))return{eligible:!1,reason:Zh};const i="string"==typeof t?this.Qh(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if($i(this._surveyManager))return qa.warn("init was not called"),{visible:!1,disabledReason:Zh};const i=this.Kh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return $i(this._surveyManager)?(qa.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Zh})):new Promise(e=>{this.getSurveys(i=>{var s;const n=null!==(s=i.find(i=>i.id===t))&&void 0!==s?s:null;if(n){const t=this.Kh(n);e({visible:t.eligible,disabledReason:t.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var s;if(!this._o.isCapturing())return;if($i(this._surveyManager))return void qa.warn("init was not called");const n="string"==typeof t?this.Qh(t):t;if(!(null==n?void 0:n.id))return void qa.warn("Survey not found");if(!Wa.includes(n.type))return void qa.warn(`Surveys of type ${n.type} cannot be rendered in the app`);const r=null==Gt?void 0:Gt.querySelector(i);if(r){if(null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds){qa.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);const t=setTimeout(()=>{var i,s;this.Ah.delete(t),!this.$o&&this._o.isCapturing()&&(qa.info(`Rendering survey ${n.id} with delay of ${null===(i=n.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(n,r,e),qa.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.Ah.add(t)}this._surveyManager.renderSurvey(n,r,e)}else qa.warn("Survey element not found")}displaySurvey(t,i){var e;if(!this._o.isCapturing())return;if($i(this._surveyManager))return void qa.warn("init was not called");const s=this.Qh(t);if(!s)return void qa.warn("Survey not found");let n=s;if((null===(e=s.appearance)||void 0===e?void 0:e.surveyPopupDelaySeconds)&&i.ignoreDelay&&(n=cs(cs({},s),{},{appearance:cs(cs({},s.appearance),{},{surveyPopupDelaySeconds:0})})),i.displayType!==fl&&i.initialResponses&&qa.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){const t=this.Jh(s);if(!t.eligible)return void qa.warn("Survey is not eligible to be displayed: ",t.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}cancelPendingSurvey(t){$i(this._surveyManager)?qa.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t)}};function iu(t,i,e){if($i(t))return!1;switch(e){case"exact":return t===i;case"contains":{const e=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(e,"i").test(t)}case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var eu=class{constructor(t){this._instance=t,this.Xh=new Set,this.Yh=new Set,this.tc=new Ea,this.ec=(t,i)=>this.nc(t,i)&&this.sc(t,i)&&this.rc(t,i)&&this.oc(t,i),this.nc=(t,i)=>!(null==i?void 0:i.event)||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;mi(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)||(this.ac=null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t,i;null===(t=this.ac)||void 0===t||t.call(this),this.ac=void 0,null===(i=this._instance)||void 0===i||null===(i=i.autocapture)||void 0===i||i.setElementSelectors(new Set,this),this.tc=new Ea}register(t){var i,e;if(!mi(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Xh.add(t),null===(i=t.steps)||void 0===i||i.forEach(t=>{this.Yh.add((null==t?void 0:t.event)||"")})}),null===(e=this._instance)||void 0===e?void 0:e.autocapture)){const t=new Set;this.Xh.forEach(i=>{var e;null===(e=i.steps)||void 0===e||e.forEach(i=>{(null==i?void 0:i.selector)&&t.add(i.selector)})}),this._instance.autocapture.setElementSelectors(t,this)}}replace(t){this.Xh.clear(),this.Yh.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Yh.has(t)||this.Yh.has(i.event))&&this.Xh.forEach(t=>{this.lc(i,t)&&this.tc.emit("actionCaptured",t.name)})}uc(t){this.onAction("actionCaptured",i=>t(i))}lc(t,i){if(null==(null==i?void 0:i.steps))return!1;for(const e of i.steps)if(this.ec(t,e))return!0;return!1}onAction(t,i){return this.tc.on(t,i)}sc(t,i){if(null==i?void 0:i.url){var e;const s=null==t||null===(e=t.properties)||void 0===e?void 0:e.$current_url;if(!s||"string"!=typeof s)return!1;if(!iu(s,i.url,i.url_matching||"contains"))return!1}return!0}rc(t,i){return!!this.hc(t,i)&&!!this.cc(t,i)&&!!this.dc(t,i)}hc(t,i){var e;if(!(null==i?void 0:i.href))return!0;const s=this.vc(t);if(s.length>0)return s.some(t=>iu(t.href,i.href,i.href_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&iu(function(t){const i=t.match(/(?::|")href="(.*?)"/);return i?i[1]:""}(n),i.href,i.href_matching||"exact")}cc(t,i){var e;if(!(null==i?void 0:i.text))return!0;const s=this.vc(t);if(s.length>0)return s.some(t=>iu(t.text,i.text,i.text_matching||"exact")||iu(t.$el_text,i.text,i.text_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&(r=function(t){const i=[],e=/(?::|")text="(.*?)"/g;let s;for(;!$i(s=e.exec(t));)i.includes(s[1])||i.push(s[1]);return i}(n),o=i.text,l=i.text_matching||"exact",r.some(t=>iu(t,o,l)));var r,o,l}dc(t,i){var e,s;if(!(null==i?void 0:i.selector))return!0;const n=null==t||null===(e=t.properties)||void 0===e?void 0:e.$element_selectors;if(null==n?void 0:n.includes(i.selector))return!0;const r=(null==t||null===(s=t.properties)||void 0===s?void 0:s.$elements_chain)||"";if(i.selector_regex&&r)try{return new RegExp(i.selector_regex).test(r)}catch(t){return!1}return!1}vc(t){var i;return null==(null==t||null===(i=t.properties)||void 0===i?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}oc(t,i){return!(null==i?void 0:i.properties)||0===i.properties.length||ja(i.properties.reduce((t,i)=>{const e=fi(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},su=class{constructor(t,i){var e,s;this.fc=[],this._instance=t,this.gc=i,this.mc=new Map,this.yc=new Map,this.bc=new Map,this._c=null===(e=this._instance)||void 0===e||null===(s=e.onSessionId)||void 0===s?void 0:s.call(e,t=>this.wc(t))}kc(t){return!1}Sc(){return null}xc(t){}Cc(){}$c(t,i){return!!t&&ja(t.propertyFilters,null==i?void 0:i.properties)}Tc(t,i){const e=new Map;return t.forEach(t=>{var s;null===(s=t.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(i=>{if(null==i?void 0:i.name){const s=e.get(i.name)||[];s.push(t.id),e.set(i.name,s)}})}),e}Ic(t,i,e){const s=(e===al?this.mc:this.yc).get(t);let n=[];return this.Mc(t=>{n=t.filter(t=>null==s?void 0:s.includes(t.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[e])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(i=>i.name===t);return this.$c(r,i)})}register(t){this.Ec(t,!1)}replace(t){this.Ec(t,!0)}Ec(t,i){var e;mi(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this.Pc(t,i),this.Rc(t,i))}Rc(t,i){const e=t.filter(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length});var s;if(i&&this.bc.clear(),0===e.length)return void(i&&(null===(s=this.Ac)||void 0===s||s.replace([])));this.Ac||(this.Ac=new eu(this._instance),this.Ac.init(),this.Ac.uc(t=>this.onAction(t)));const n=[];e.forEach(t=>{var i;null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||i.values.forEach(i=>{if(n.push(i),i.name){var e;const s=null!==(e=this.bc.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.bc.set(i.name,s)}})}),i?this.Ac.replace(n):this.Ac.register(n)}Fc(t,i){i.forEach((i,e)=>{var s;const n=null!==(s=t.get(e))&&void 0!==s?s:[];i.forEach(t=>{n.includes(t)||n.push(t)}),t.set(e,n)})}Pc(t,i){var e,s;const n=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.events)&&(null===(e=t.conditions)||void 0===e||null===(e=e.events)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),r=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.cancelEvents)&&(null===(e=t.conditions)||void 0===e||null===(e=e.cancelEvents)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),o=this.Tc(t,al),l=this.Tc(t,hl);i?(this.mc=o,this.yc=l):(this.Fc(this.mc,o),this.Fc(this.yc,l)),(0!==n.length||0!==r.length||t.some(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length}))&&(null!==(e=this.ac)&&void 0!==e||(this.ac=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,s;const n=this.Oc(),r=(null==i||null===(e=i.properties)||void 0===e?void 0:e.$survey_id)||(null==i||null===(s=i.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const e=this.Dc(t,r,i);if("consume"===e)return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.Lc([r]);if("persist"===e)return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.Nc(r),void this.qc([r])}if(this.yc.has(t)){const e=this.Ic(t,i,hl);e.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:e.map(t=>t.id)}),this.Lc(e.map(t=>t.id)),e.forEach(t=>this.jc(t.id)))}if(!this.mc.has(t))return;n.info("event name matched",{event:t,eventPayload:i,items:this.mc.get(t)});const o=this.Ic(t,i,al);this.Bc(o.map(t=>t.id))}onAction(t){this.bc.has(t)&&this.Bc(this.bc.get(t)||[])}Bc(t){var i,e;if(0===t.length)return;const s=!!(null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i)),n=[];for(const i of t)s&&this.kc(i)?this.Nc(i)&&this.Hc(i):n.push(i);n.length>0&&(this.fc=[...new Set([...this.fc,...n])]),this.Oc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.zc()}Nc(t){this.fc=this.fc.filter(i=>i!==t);const i=this.Uc();return!i.includes(t)&&(this.Wc([...i,t]),this.Vc(),!0)}Lc(t){const i=new Set(t);this.fc=this.fc.filter(t=>!i.has(t));const e=this.Gc(),s=e.filter(t=>!i.has(t));s.length!==e.length&&(this.Wc(s),0===s.length&&this.Zc()),this.qc(t),this.zc()}zc(){try{var t;null===(t=this.gc)||void 0===t||t.call(this)}catch(t){this.Oc().error("Error while handling activated items change",t)}}Qc(){var t;const i=this.Sc();if(!i)return{};const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Hc(t){if(!this.Sc())return;const i=this.Qc();this.xc(cs(cs({},i),{},{[t]:Date.now()}))}qc(t){if(!this.Sc())return;const i=this.Qc(),e={};let s=!1;for(const[n,r]of Object.entries(i))t.includes(n)?s=!0:e[n]=r;s&&(_i(e)?this.Cc():this.xc(e))}Jc(){this.Sc()&&this.Cc()}getActivationTimestamp(t){if(!this.Uc().includes(t))return;const i=this.Qc()[t];return xi(i)?i:void 0}Gc(){var t;const i=this.Kc();return(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i])||[]}Uc(){var t,i,e;const s=this.Gc();if(0===s.length)return[];const n=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this.Xc()],r=null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i);return r&&n===r?s:[]}Vc(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);e&&this.Yc(e)}Zc(){this.td()}wc(t){var i;const e=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.props[this.Xc()];if(e&&e!==t){const t=this.Gc(),i=this.Qc();t.length>0&&(this.Wc([]),t.filter(t=>xi(i[t])).forEach(t=>this.jc(t))),this.Zc(),this.Jc(),t.length>0&&this.zc()}}getActivatedIds(){return[...new Set([...this.Uc(),...this.fc])].filter(t=>!this.ed(t))}dispose(){var t,i,e;null===(t=this._c)||void 0===t||t.call(this),this._c=void 0,null===(i=this.ac)||void 0===i||i.call(this),this.ac=void 0,null===(e=this.Ac)||void 0===e||e.dispose(),this.Ac=void 0}reset(){this.fc=[],this.Gc().length>0&&this.Wc([]),this.Zc(),this.Jc(),this.zc()}getEventToItemsMap(){return this.mc}nd(){return this.Ac}},nu=class extends su{constructor(t,i){super(t,i)}Kc(){return Q}Xc(){return tt}Sc(){return it}xc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_timestamps:t})}Cc(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_timestamps")}kc(t){var i;let e;this.Mc(i=>{e=i.find(i=>i.id===t)});const s=null==e||null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds;return xi(s)&&s>0}sd(){return ul}Mc(t){var i;null===(i=this._instance)||void 0===i||i.getSurveys(t)}jc(t){var i;null===(i=this._instance)||void 0===i||i.cancelPendingSurvey(t)}Oc(){return qa}Wc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated:t})}Yc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_session:t})}td(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_session")}ed(){return!1}Dc(t,i,e){var s;if(t===cl&&!1===(null==e||null===(s=e.properties)||void 0===s?void 0:s.$survey_completed))return"ignore";let n;return this.Mc(t=>{n=t.find(t=>t.id===i)}),!n||function(t){var i;return Oa(t)&&!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i?void 0:i.repeatedActivation)||"always"===t.schedule}(n)?t===ul?"consume":"ignore":t===ul?"persist":t===dl||t===cl?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},ru=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);const i={};for(const e of t){const t=this._instance.get_property(e);mi(t)||(i[e]=t)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},ou=class{constructor(t){this._instance=t}get(){const t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const t=null==ei?void 0:ei.__PosthogExtensions__;if(!t)return;const{generateSurveys:i,loadExternalDependency:e}=t;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}createEventReceiver(t){return new nu(this._instance,t)}onMatchingConditionsChanged(t){const i=this._instance._addCaptureHook(i=>{"$pageview"!==i&&i!==ul&&i!==dl&&i!==cl||t()}),e=()=>t();Kn(qt,"PHSurveyShown",e);let s=!1;const n=this._instance.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,i(),n(),null==qt||qt.removeEventListener("PHSurveyShown",e)}}};const lu=(null==qt?void 0:qt.location)?Co(qt.location.hash,"__posthog")||Co(location.hash,"state"):null,au="_postHogToolbarParams",hu=Bn("[Toolbar]"),uu=Bn("[FeatureFlags]");var du=class{constructor(t,i=!1){this.rd=!1,this.update(t,i)}update(t,i){this.od=((t,i)=>{var e,s,n,r,o,l,a,h;return{bootstrap:{featureFlags:null!==(e=null===(s=t.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(n=null===(r=t.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=t.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:mi(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(l=t.feature_flag_request_max_retries)&&void 0!==l?l:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(h=t.evaluation_contexts)&&void 0!==h?h:t.evaluation_environments)&&void 0!==a?a:[],flagKeys:fi(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.rd||(uu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.rd=!0),mi(t.flag_keys)||fi(t.flag_keys)||uu.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.od}};const cu=Bn("[FeatureFlags]"),vu=Bn("[FeatureFlags]",{debugEnabled:!0}),fu="\" failed. Feature flags didn't load in time.",pu=[502,504],gu=["click","keydown","wheel","touchstart","pointerdown"],_u="connection_error",mu=t=>{const i={};for(let e=0;t.length>e;e++)i[t[e]]=!0;return i},bu=t=>{const i={};for(const[e,s]of Hn(t||{}))s&&(i[e]=s);return i},yu=t=>Fi(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),wu=Bn("[Error tracking]"),$u="webkit-masked-url:",xu=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Su=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",$u],ku=["__firefox__","__gCrWeb"],Eu="Refusing to render web experiment since the viewer is a likely bot",Pu={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Aa(i,t),not_regex:(t,i)=>!Aa(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},Tu=Bn("[Conversations]"),Cu="Conversations not available yet.";function Fu(t,i){var e,s,n,r,o,l,a;const h=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=(null==i?void 0:i.consoleCapture)?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=mi(d)?Math.max(u,2048):Math.max(u,d),v=cs(cs({},function(){let t="",i="";try{const e=null==Wt?void 0:Wt.userAgent;e&&([t,i]=Le(e))}catch(t){}return function(t,i){const e=function(t){if(t)return{}.hasOwnProperty.call(wn,t)?wn[t]:t}(t);return cs(cs({},e?{"os.name":e}:{}),i?{"os.version":i}:{})}(t,i)}()),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==v?void 0:v["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==r?r:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==v?void 0:v["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(a=null==v?void 0:v["deployment.environment"])&&void 0!==a?a:null==t?void 0:t.environment,resourceAttributes:v,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:u,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Mu=["debug","log","warn","error","info"],Iu=t=>{for(;null==t?void 0:t.__rrweb_original__;)t=t.__rrweb_original__;return t},Ou="console",Au="__posthogHandledLogsRequestError",Ru=(t,i)=>{const e=t instanceof Error?t:new Error(i);return e[Au]=!0,e},Du=t=>!!t&&"object"==typeof t&&!0===t[Au],ju=Bn("[NetworkMetrics]"),Bu=()=>{var t;return(null==qt||null===(t=qt.performance)||void 0===t?void 0:t.now)?qt.performance.now():Date.now()},Nu={"http:":80,"https:":443},Lu=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),zu=(t,i)=>{var e;const s=String(i);return{method:String(t).toUpperCase(),url:(null===(e=Eo(s))||void 0===e?void 0:e.href)||s}},Hu=(t,i,e,s,n,r,o=!1)=>{try{var l,a;const h=n();if(!h)return;const u=e||void 0,d=Bu()-s,c=Eo(i.url);if(c&&"http:"!==c.protocol&&"https:"!==c.protocol)return;const v={url:(null==c?void 0:c.href)||i.url,method:i.method},f=pi(h.name)?h.name(v):bi(h.name)?h.name:"http.client.request.duration";if(!f)return;const p=o&&!u?void 0:((t,i)=>t?400>t?void 0:String(t):(null==i?void 0:i.name)||"_OTHER")(u,r),g=cs(cs(cs(cs(cs({},(t=>{const i=Lu.has(t)?t:"_OTHER";return cs({"http.request.method":i},"_OTHER"===i&&t!==i?{"http.request.method_original":t}:{})})(v.method)),c?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Nu[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(i=t.pathname,i.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var i})(c):{}),u?{"http.response.status_code":u}:{}),p?{"error.type":p}:{}),null===(l=h.attributes)||void 0===l?void 0:l.call(h,v,{status:u,durationMs:d}));null===(a=t.metrics)||void 0===a||a.histogram(f,d,{unit:"ms",attributes:g})}catch(t){ju.error("Failed to record network metric",t)}},Uu=()=>{},qu=(t,i)=>pi(null==qt?void 0:qt.fetch)?Oh(qt,"fetch",e=>function(...s){const n=Bu(),r=e.apply(this,s);if(!i())return r;try{var o,l,a;const[e,h]=s,u=zu(null!==(o=null!==(l=null==h?void 0:h.method)&&void 0!==l?l:null==e?void 0:e.method)&&void 0!==o?o:"GET",null!==(a=null==e?void 0:e.url)&&void 0!==a?a:e);return r.then(e=>(Hu(t,u,null==e?void 0:e.status,n,i,void 0,!0),e),e=>{throw Hu(t,u,void 0,n,i,e),e})}catch(t){return ju.error("Failed to observe fetch",t),r}}):Uu,Vu=(t,i)=>{var e;const s=null==qt||null===(e=qt.XMLHttpRequest)||void 0===e?void 0:e.prototype;if(!s)return Uu;const n=new WeakMap,r=Oh(s,"open",t=>function(...i){try{(()=>ta.has(this))()||n.set(this,zu(i[0],i[1]))}catch(t){ju.error("Failed to observe XHR open",t)}return t.apply(this,i)}),o=Oh(s,"send",e=>function(...s){let r;try{const e=n.get(this);if(e&&i()){const s=Bu();r=()=>{this.removeEventListener("loadend",r),Hu(t,e,this.status,s,i)},Kn(this,"loadend",r)}}catch(t){ju.error("Failed to observe XHR send",t)}try{return e.apply(this,s)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{r(),o()}},Wu={featureFlags:class{constructor(t){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.A=cu,this.ld={},this.ud={},this.hd=[],this.dd=!1,this.vd=!1,this.fd=0,this.pd=!1,this.gd=!1,this.md=!1,this.yd=!1,this.bd=0,this._d=!1,this.rn=()=>{const t=this.wd();this.bd=0,t&&this.reloadFeatureFlags()},this.kd=()=>{var t,i;const e=this.Sd,s=null!==(t=this.xd)&&void 0!==t?t:e;mi(e)||mi(s)||this.Mr.remoteRequestsDisabled||!Gt||"hidden"===Gt.visibilityState||Date.now()-(null!==(i=this.Cd)&&void 0!==i?i:0)<s||(this.xd=this._d||!this.Mr.idleRefreshBackoff?e:Math.min(2*s,36e5),this._d=!1,this.reloadFeatureFlags(),this.$d())},this.Td=()=>{this._d&&this.xd===this.Sd||this.Id()},this.sn=()=>{"visible"===(null==Gt?void 0:Gt.visibilityState)&&this.Id()},"get"in t?this._o=t:(this._instance=t,this.Md=new du(t.config,t.el()),this._o=this.Md)}updateConfig(t,i){var e;null===(e=this.Md)||void 0===e||e.update(t,i),this.yo&&this.Ed()}setup(t){return this.Lh=t,this.A=t.logger.createLogger("[FeatureFlags]"),Xh(t.kv.initialize(),()=>{this.Lh===t&&(this.Lh=void 0,this.yo=t,this.Pd(t))})}Pd(t){var i;if(this.yo===t)return qt&&Kn(qt,"online",this.rn),this.Ed(),this.Rd=t.registerDynamicEventProperties(()=>this.Ad()?this.ld:this.ud),this.Fd=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.onCrossTabFeatureFlagChange(()=>{this.Od(),this.Dd(),this.Ld()}),this.Dd(),this.initialize()}Id(){this._d=!0,this.xd=this.Sd,this.kd()}Ed(){const t=this.Mr.refreshIntervalMs,i=!this.Mr.remoteRequestsDisabled&&Gt&&!mi(t)&&t>0?t:void 0;this.Mr.idleRefreshBackoff||(this.xd=i),i!==this.Sd&&(this.Nd(),mi(i)||(this.Sd=i,this.xd=i,this.$d(),(null==Gt?void 0:Gt.addEventListener)&&(Kn(Gt,Bt,this.sn),Nn(gu,t=>{Kn(Gt,t,this.Td,{capture:!0})}))))}$d(){mi(this.Sd)||(mi(this.qd)||clearInterval(this.qd),this.Cd=Date.now(),this.qd=setInterval(this.kd,this.Sd))}Nd(){var t;mi(this.qd)||(clearInterval(this.qd),this.qd=void 0,null==Gt||null===(t=Gt.removeEventListener)||void 0===t||t.call(Gt,"visibilitychange",this.sn),Nn(gu,t=>{var i;null==Gt||null===(i=Gt.removeEventListener)||void 0===i||i.call(Gt,t,this.Td,{capture:!0})})),this.Sd=void 0,this.xd=void 0,this._d=!1,this.Cd=void 0}destroy(){this.jd()}dispose(){this.jd()}jd(){var t,i;this.Nd(),this.fd++,this.gd=!1,this.Lh=void 0,this.yo&&(this.Bd(),null===(t=this.Rd)||void 0===t||t.dispose(),this.Rd=void 0,null===(i=this.Fd)||void 0===i||i.call(this),this.Fd=void 0,this.hd=[],null==qt||qt.removeEventListener("online",this.rn),this.yo=void 0)}get Mr(){return this._o.get()}Hd(t){var i;return this.zd&&t in this.zd?this.zd[t]:null===(i=this.yo)||void 0===i?void 0:i.kv.get(t)}Od(){return!!this.zd&&(this.zd=void 0,!0)}Ud(){var t;return!mi(null===(t=this.yo)||void 0===t?void 0:t.kv.get("$enabled_feature_flags"))&&this.Od()}$t(t){this.Wd(()=>{var i;return null===(i=this.yo)||void 0===i?void 0:i.kv.set(t)})}Vd(t,i,e){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!t.$enabled_feature_flags)return;const n=this.Hd("$enabled_feature_flags")||{},r=t.$enabled_feature_flags||{},o=i.flags||i.featureFlags,l=i.flags?Object.entries(i.flags).filter(([,t])=>!(null==t?void 0:t.failed)).map(([t])=>t):[],a=!!i.errorsWhileComputingFlags&&!!i.flags,h=a?l:e&&!fi(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),u=this.Hd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=a||e?h:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),v=!a&&!e,f=!!v||h,p=!!v||c,g={[L]:f,[N]:f,[U]:p};t.$feature_flag_details&&(g[H]=f);for(const i of[q,ct,V])mi(t[i])||(g[i]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}Lt(t){this.Wd(()=>{var i;return null===(i=this.yo)||void 0===i?void 0:i.kv.remove(t)})}Wd(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Dd(){const t={};for(const i of[L,U,q,W]){const e=this.Hd(i);mi(e)||(t[i]=e)}this.ld=t;const i=cs({},t),e=this.Hd(N);if(e)for(const[t,s]of Object.entries(e))i[`$feature/${t}`]=s;this.ud=i}Ad(){const t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;const i=this.Hd(ct);return"number"!=typeof i||Date.now()-i>t}Gd(){return!!this.Ad()&&(this.yd||this.vd||(this.yd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Zd(){const t=this.Mr.evaluationContexts;return(null==t?void 0:t.length)?t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}Qd(){const t=this.Mr.flagKeys;if(!mi(t))return t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i;const e=this.Mr,s=null!==(t=null===(i=e.bootstrap)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(s).length){var n,r;const t=null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},i=Object.keys(s).filter(t=>!mi(s[t])).reduce((t,i)=>(t[i]=s[i],t),{}),o=Object.keys(t).filter(t=>i[t]).reduce((i,e)=>(i[e]=t[e],i),{});return this.Jd({featureFlags:i,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n;const r=(null==e?void 0:e.merge)&&null!==(s=this.Hd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==e?void 0:e.merge)&&null!==(n=this.Hd("$feature_flag_payloads"))&&void 0!==n?n:{},l=cs(cs({},r),t),a=cs(cs({},o),i),h={};for(const[t,i]of Object.entries(l))h[t]={key:t,enabled:Qs(i),variant:tn(i),reason:void 0,metadata:mi(null==a?void 0:a[t])?void 0:{id:0,version:void 0,description:void 0,payload:a[t]}};this.Jd({flags:h})}get hasLoadedFlags(){return this.dd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.Hd(H),i=this.Hd(W),e=this.Hd(G);if(!e&&!i)return t||{};const s=zn({},t||{}),n=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(const t of n){var r;const n=s[t],l=null==i?void 0:i[t],a=mi(l)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!l,h=mi(l)?null==n?void 0:n.variant:"string"==typeof l?l:void 0,u=null==e?void 0:e[t],d=cs(cs({},n),{},{enabled:a,variant:a?null!=h?h:null==n?void 0:n.variant:void 0});var o;a!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),h!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=cs(cs({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[t]=d}return this.ad||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.ad=!0),s}getAllFeatureFlags(){const t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{const s=t[e];return{key:e,enabled:Qs(s),variant:tn(s),payload:Zs(i[e])}})}getFlagVariants(){const t=this.Hd(N),i=this.Hd(W);if(!i)return t||{};const e=zn({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ad||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.ad=!0),e}getFlagPayloads(){const t=this.Hd(U),i=this.Hd(G);if(!i)return t||{};const e=zn({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ad||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.ad=!0),e}reloadFeatureFlags(){this.pd||this.Mr.featureFlagsDisabled||this.wd()||(this.vd&&(this.gd=!0),this.Kd||(this.hd.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.Kd=setTimeout(()=>{this.Xd()},5)))}Bd(){clearTimeout(this.Kd),this.Kd=void 0}onReloading(t){return this.hd.push(t),()=>{this.hd=this.hd.filter(i=>i!==t)}}ensureFlagsLoaded(){this.dd||this.vd||this.Kd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.pd=t}resetFlagCallReported(){this.Lt(ht)}Xd(t){this.Bd();const i=this.yo;if(!i||this.Mr.remoteRequestsDisabled||this.wd())return;if(this.vd)return void(this.gd=!0);const e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:cs(cs(cs({},i.initialPersonProperties),this.Hd("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.Hd(J),timezone:Vo()};mi(i.deviceId)||(e.$device_id=i.deviceId),((null==t?void 0:t.disableFlags)||this.Mr.featureFlagsDisabled)&&(e.disable_flags=!0);const s=this.Zd();s.length&&(e.evaluation_contexts=s);const n=this.Qd();mi(n)||(e.flag_keys=n);const r=this.Mr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),l=this.fd;this.vd=!0;const a=()=>{this.gd&&(this.gd=!1,this.Xd())},h=t=>{var i,s;const n=null!==(i=t.json)&&void 0!==i?i:{},o=200!==t.statusCode;if(this.vd=!1,l!==this.fd)return void a();if(this.Yd(t.statusCode),o||this.gd||(this.$anon_distinct_id=void 0),e.disable_flags&&!this.gd)return;this.md=!o;const h=[];t.error?h.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?_u:"unknown_error"):200!==t.statusCode&&h.push(`api_error_${t.statusCode}`),n.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");const u=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));u&&h.push("quota_limited"),this.$t({[dt]:h}),u?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):e.disable_flags||this.Jd(n,o,{partialResponse:r}),a()},u=t=>{this.vd=!1,l===this.fd?(this.$t({[dt]:[_u]}),this.A.error("Feature flag request failed",t),this.Ud()&&this.Ld(!0),a()):a()};let d=this.Mr.requestMaxRetries;const c=()=>d>0&&l===this.fd,v=()=>{if(l!==this.fd||!this.yo||this.Mr.remoteRequestsDisabled)return this.vd=!1,void a();try{i.sendRequest(o,{target:"flags",method:"POST",body:e,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{if((t=>pu.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&c())return d--,void setTimeout(v,500);h(t)}).catch(u)}catch(t){u(t)}};v()}wd(){return Fo(this.bd,3)}Yd(t){this.bd=Mo(t,this.bd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i={}){var e;if(i.fresh&&!this.md)return;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+t+fu);if(this.Gd())return;const s=this.getFeatureFlagResult(t,i);return null!==(e=null==s?void 0:s.variant)&&void 0!==e?e:null==s?void 0:s.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i={}){if(i.fresh&&!this.md)return;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+t+fu);if(this.Gd())return;const e=this.getFlagVariants(),s=t in e,n=e[t],r=this.getFlagPayloads()[t],o=String(n),l=this.Hd("$feature_flag_request_id")||void 0,a=this.Hd("$feature_flag_evaluated_at")||void 0;let h,u=this.Hd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var d;const t=null===(d=this.yo)||void 0===d?void 0:d.session.sessionId,i=this.Hd(ut);t&&t!==i&&(u={},h=t)}if(i.send_event||!("send_event"in i))if(t in u&&u[t].includes(o))h&&this.$t({[ht]:u,[ut]:h});else{var c,v,f,p,g,_,m,b,y,w,x,S;fi(u[t])?u[t].push(o):u[t]=[o],this.$t(cs({[ht]:u},h?{[ut]:h}:{}));const i=this.getFeatureFlagDetails(t),e=[...null!==(c=this.Hd("$feature_flag_errors"))&&void 0!==c?c:[]];mi(n)&&e.push("flag_missing");const s={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:null!==(v=null===(f=this.Mr.bootstrap)||void 0===f||null===(f=f.featureFlags)||void 0===f?void 0:f[t])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(p=null===(g=this.Mr.bootstrap)||void 0===g||null===(g=g.featureFlagPayloads)||void 0===g?void 0:g[t])&&void 0!==p?p:null,$used_bootstrap_value:!this.md};mi(null==i||null===(_=i.metadata)||void 0===_?void 0:_.has_experiment)||(s.$feature_flag_has_experiment=i.metadata.has_experiment),mi(null==i||null===(m=i.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=i.metadata.version);const d=null!==(b=null==i||null===(y=i.reason)||void 0===y?void 0:y.description)&&void 0!==b?b:null==i||null===(w=i.reason)||void 0===w?void 0:w.code;var k;d&&(s.$feature_flag_reason=d),(null==i||null===(x=i.metadata)||void 0===x?void 0:x.id)&&(s.$feature_flag_id=i.metadata.id),mi(null==i?void 0:i.original_variant)&&mi(null==i?void 0:i.original_enabled)||(s.$feature_flag_original_response=mi(i.original_variant)?i.original_enabled:i.original_variant),(null==i||null===(S=i.metadata)||void 0===S?void 0:S.original_payload)&&(s.$feature_flag_original_payload=null==i||null===(k=i.metadata)||void 0===k?void 0:k.original_payload),e.length&&(s.$feature_flag_error=e.join(",")),this.tv(s)}else h&&this.$t({[ht]:u,[ut]:h});return s?{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:Zs(r)}:void 0}tv(t){try{var i;null===(i=this.yo)||void 0===i||i.capture("$feature_flag_called",t)}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.ev(t,i)}ev(t,i){var e=this;return ji(function*(){const s=e.yo;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=e.Zd();r.length&&(n.evaluation_contexts=r);const o=e.Qd();let l;mi(o)||(n.flag_keys=o);try{var a;const i=null===(a=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:e.Mr.compression,sentAt:"body",timeoutMs:e.Mr.requestTimeoutMs})).json)||void 0===a?void 0:a.featureFlagPayloads;l=(null==i?void 0:i[t])||void 0}catch(t){return void e.A.error("Remote config feature flag request failed",t)}try{i(l)}catch(t){e.A.error("Remote config feature flag callback failed",t)}})()}isFeatureEnabled(t,i={}){if(i.fresh&&!this.md)return i.defaultValue;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+fu),i.defaultValue;const e=this.getFeatureFlag(t,i);return mi(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.Jd(t,i,e)}Jd(t,i,e){if(!this.yo)return;this.dd=!0;const s=((t,i={},e={},s={},n,r=cu)=>{const o=((t,i)=>{const e=t.flags;if(e){const i=Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),s=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!mi(null===(i=e[t].metadata)||void 0===i?void 0:i.payload)}).map(t=>{var i;return[t,null===(i=e[t].metadata)||void 0===i?void 0:i.payload]}));return cs(cs({},t),{},{featureFlags:i,featureFlagPayloads:s})}return t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t,r),l=o.flags,a=o.featureFlags,h=o.featureFlagPayloads;if(!a)return;const u=t.requestId,d=t.evaluatedAt;if(fi(a)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const t={};if(a)for(let i=0;a.length>i;i++)t[a[i]]=!0;return{[L]:a,[N]:t,[V]:!1}}let c=a,v=h,f=l;if(null==n?void 0:n.partialResponse){const t=Object.keys(c),n=v||{};c=cs(cs({},i),c),v=cs(cs({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=cs(cs({},s),f)}else if(t.errorsWhileComputingFlags)if(l){const t=new Set(Object.keys(l).filter(t=>{var i;return!(null===(i=l[t])||void 0===i?void 0:i.failed)}));c=cs(cs({},i),Object.fromEntries(Object.entries(c).filter(([i])=>t.has(i))));const n=Object.fromEntries(Object.entries(v||{}).filter(([i])=>t.has(i)));v=cs(cs({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=cs(cs({},s),Object.fromEntries(Object.entries(f||{}).filter(([i])=>t.has(i))))}else c=cs(cs({},i),c),v=cs(cs({},e),v),f=cs(cs({},s),f);return cs(cs({[L]:Object.keys(bu(c)),[N]:c||{},[U]:v||{},[H]:f||{},[V]:!0===t.minimalFlagCalledEvents},u?{[q]:u}:{}),d?{[ct]:d}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.A);if(s)if(!1===(null==e?void 0:e.persist)){const t=!mi(this.yo.kv.get(N));this.zd=s,t||this.$t(s)}else this.Od(),this.Vd(s,t,!!(null==e?void 0:e.partialResponse)),this.$t(s);else i&&this.Ud();i||(this.yd=!1),this.Ld(i)}override(t,i=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.iv(t)}iv(t){if(this.yo){if(!1===t)return this.Lt([W,G]),this.Ld(),void vu.info("All overrides cleared");if(fi(t))return this.$t({[W]:mu(t)}),this.Ld(),void vu.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i;const e=t;this.ad=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);const s={},n=e.flags,r=e.payloads;return n&&(s[W]=fi(n)?mu(n):n),r&&(s[G]=r),Object.keys(s).length&&this.$t(s),!1===n&&!1===r?this.Lt([W,G]):!1===n?this.Lt(W):!1===r&&this.Lt(G),this.Ld(),!1===n?vu.info("Flag overrides cleared"):n&&vu.info("Flag overrides set",{flags:n}),void(!1===r?vu.info("Payload overrides cleared"):r&&vu.info("Payload overrides set",{payloads:r}))}if(t&&"object"==typeof t)return this.$t({[W]:t}),this.Ld(),void vu.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.dd){const{flags:i,flagVariants:e}=this.nv();try{t(i,e)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;const n=(this.Hd("$early_access_features")||[]).find(i=>i.flagKey===t),r={[`$feature_enrollment/${t}`]:i},o={$feature_flag:t,$feature_enrollment:i,$set:r};n&&(o.$early_access_feature_name=n.name),e&&(o.$feature_enrollment_stage=e);const l=cs(cs({},this.getFlagVariants()),{},{[t]:i});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.$t({[L]:Object.keys(bu(l)),[N]:l,[K]:cs(cs({},this.Hd("$stored_person_properties")||{}),r)}),this.Ld();try{var a;null===(a=this.yo)||void 0===a||a.capture("$feature_enrollment_update",o)}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i=!1,e){const s=this.Hd(z);!s||i?this.sv(t,e):t(s)}sv(t,i){var e=this;return ji(function*(){const s=e.yo;if(!s)return;const n=i?`&${i.map(t=>`stage=${t}`).join("&")}`:"";let r;try{const t=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!t.json)return;r=t.json.earlyAccessFeatures,e.$t({[z]:r})}catch(t){return void e.A.error("Early access feature request failed",t)}try{t(r)}catch(t){e.A.error("Early access feature callback failed",t)}})()}nv(){const t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}Ld(t){this.Dd();const{flags:i,flagVariants:e}=this.nv();this.featureFlagEventHandlers.forEach(s=>{try{s(i,e,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i=!0){this.rv(t,i)}rv(t,i=!0){const e=this.Hd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||((null==t?void 0:t.$set_once)?{}:t),n=null==t?void 0:t.$set_once,r={};if(n)for(const t in n)({}).hasOwnProperty.call(n,t)&&(t in e||(r[t]=n[t]));this.$t({[K]:cs(cs(cs({},e),r),s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i=!0){const e=cs({},this.Hd("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.$t({[K]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Lt(K),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i=!0){const e=this.Hd("$stored_group_properties")||{},s=cs({},e);for(const i of Object.keys(t))s[i]=cs(cs({},e[i]),t[i]);this.$t({[J]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const i=this.Hd("$stored_group_properties")||{};this.$t({[J]:cs(cs({},i),{},{[t]:{}})})}else this.Lt(J)}reset(){this.fd++,this.gd=!1,this.ld={},this.ud={},this.zd=void 0,this.dd=!1,this.pd=!1,this.md=!1,this.$anon_distinct_id=void 0,this.Bd(),this.ad=!1,this.bd=0}}},Gu={sessionRecording:class{get Mr(){return this._instance.config}get Tl(){return this._instance.persistence}get started(){var t;return!!(null===(t=this.ov)||void 0===t?void 0:t.isStarted)}get status(){var t,i;return"awaiting_config"===this.av||"missing_config"===this.av?this.av:null!==(t=null===(i=this.ov)||void 0===i?void 0:i.status)&&void 0!==t?t:this.av}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.av=Lh,this.lv=void 0,this.uv=!1,this.Je=(()=>{var t,i;if(!(null==Gt?void 0:Gt.visibilityState)||"visible"===Gt.visibilityState)return!0;const e=null==qt||null===(t=qt.performance)||void 0===t||null===(i=t.getEntriesByType)||void 0===i?void 0:i.call(t,"visibility-state");return!(null==e?void 0:e.length)||e.some(t=>"visible"===t.name)})(),this.sn=()=>{var t,i;"visible"===(null==Gt?void 0:Gt.visibilityState)&&(this.Je=!0,null===(t=this.ov)||void 0===t||null===(i=t.setDocumentWasEverVisible)||void 0===i||i.call(t,!0))},!this._instance.sessionManager)throw Hh.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Mr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==Gt?void 0:Gt.addEventListener)&&Kn(Gt,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var i;this.uv=!0,null==Gt||null===(i=Gt.removeEventListener)||void 0===i||i.call(Gt,"visibilitychange",this.sn),t?this.hv(!0):this.stopRecording()}get dv(){var t;const i=!!(null===(t=this._instance.get_property("$session_recording_remote_config"))||void 0===t?void 0:t.enabled),e=!this.Mr.disable_session_recording,s=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return qt&&i&&e&&!s}startIfEnabledOrStop(t){var i;if(this.uv)return;if(this.dv&&(null===(i=this.ov)||void 0===i?void 0:i.isStarted))return;const e=!mi(Object.assign)&&!mi(Array.from);this.dv&&e?(this.vv(t),Hh.info("starting")):(this.av=Lh,this.stopRecording())}vv(t){var i,e;if(this.dv)if("awaiting_config"!==this.av&&"missing_config"!==this.av&&(this.av=zh),(null==ei||null===(i=ei.__PosthogExtensions__)||void 0===i||null===(i=i.rrweb)||void 0===i?void 0:i.record)&&(null===(e=ei.__PosthogExtensions__)||void 0===e?void 0:e.initSessionRecording))this.fv(t);else{var s,n;const i=this._instance.sessionManager;null===(s=ei.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.pv,e=>{if(!this.uv&&this.dv&&this._instance.sessionManager===i)return e?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Hh.error("could not load recorder",e)):void this.fv(t);this.av="disabled"})}}stopRecording(){var t,i;null===(t=this.lv)||void 0===t||t.call(this),this.lv=void 0,null===(i=this.ov)||void 0===i||i.stop()}hv(t=!1){var i,e;null===(i=this.lv)||void 0===i||i.call(this),this.lv=void 0,null===(e=this.ov)||void 0===e||e.discard({discardProducerEvents:t})}gv(){var t,i;null===(t=this.Tl)||void 0===t||t.unregister("$session_is_sampled"),null===(i=this.Tl)||void 0===i||i.unregister("$replay_sample_rate")}mv(t,i){if($i(t))return null;const e=xi(t)?t:parseFloat(t);return"number"!=typeof(s=e)||!Number.isFinite(s)||0>s||s>1?(Hh.warn(`${i} must be between 0 and 1. Ignoring invalid value:`,t),null):e;var s}yv(t){if(this.Tl){var i,e;const s=this.Tl,n=()=>{var i;const e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.mv(null===(i=this.Mr.session_recording)||void 0===i?void 0:i.sampleRate,"session_recording.sampleRate"),r=this.mv(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=n?n:r;$i(o)&&this.gv();const l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[k]:cs(cs({cache_timestamp:Date.now(),enabled:!!e},e),{},{networkPayloadCapture:cs({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:mi(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null===(i=this.lv)||void 0===i||i.call(this),this.lv=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(n)}}onRemoteConfig(t){const i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.yv(i),void this.hv()):(this.yv(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.av&&(this.av="missing_config",this._instance.register_for_session({[kt]:!0}),Hh.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i="log"){var e;(null===(e=this.ov)||void 0===e?void 0:e.log)?this.ov.log(t,i):Hh.warn("log called before recorder was ready")}get pv(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.get_property(k);return(null==e||null===(i=e.scriptConfig)||void 0===i?void 0:i.script)||"lazy-recorder"}bv(){const t=this._instance.get_property(k);if(!t)return!1;let i;try{i="object"==typeof t?t:JSON.parse(t)}catch(t){return Hh.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!$i(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}fv(t){var i,e,s;if(!this.uv&&this.dv&&this._instance.sessionManager){if(!(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))return Hh.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[St]:!0});var n;if(this.ov||(this.ov=null===(n=ei.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Je),this.ov._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.bv()){if("missing_config"===this.av||"awaiting_config"===this.av)return;return this.av="awaiting_config",Hh.info("persisted remote config is stale, requesting fresh config before starting"),void new bl(this._instance).load()}this.av=zh,null===(e=(s=this.ov).setDocumentWasEverVisible)||void 0===e||e.call(s,this.Je),this.ov.start(t)}else this.av=Lh}onRRwebEmit(t){var i,e;null===(i=this.ov)||void 0===i||null===(e=i.onRRwebEmit)||void 0===e||e.call(i,t)}overrideLinkedFlag(){var t,i;this.ov||null===(i=this.Tl)||void 0===i||i.register({$replay_override_linked_flag:!0}),null===(t=this.ov)||void 0===t||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.ov||null===(i=this.Tl)||void 0===i||i.register({$replay_override_sampling:!0}),null===(t=this.ov)||void 0===t||t.overrideSampling()}overrideTrigger(t){var i,e;this.ov||null===(e=this.Tl)||void 0===e||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(i=this.ov)||void 0===i||i.overrideTrigger(t)}get sdkDebugProperties(){var t;const i={};for(const t of Uh){var e;const s=null===(e=this._instance.sessionPersistence)||void 0===e?void 0:e.get_property(t);mi(s)||(i[t]=s)}return cs(cs({},i),(null===(t=this.ov)||void 0===t?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,i){var e;return!!(null===(e=this.ov)||void 0===e?void 0:e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t,i;null===(t=this.ov)||void 0===t||null===(i=t.flushBeforeIdentityReset)||void 0===i||i.call(t)}}},Ku={autocapture:class extends Th{constructor(t){super(new Ch(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._v=!1,this._instance=t,this.wv=this.Sv()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.xv();return!!(t.path||t.search||this.Cv(t))}startIfEnabled(){this.isEnabled&&(jn.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.wv=this.Sv(),this.startIfEnabled()}stop(){this.$v&&this.$v(),this.$v=void 0,this.Tv&&this.Tv(),this.Tv=void 0,jn.info("History API monitoring stopped")}monitorHistoryChanges(){qt&&qt.history&&(this.Iv("pushState"),this.Iv("replaceState"),this.Mv(),this.Cv()&&this.Ev())}Iv(t){var i;if(!qt||(null===(i=qt.history[t])||void 0===i?void 0:i.__posthog_wrapped__))return;const e=this;Oh(qt.history,t,i=>function(s,n,r){var o;e.Pv(r)&&e.Rv(),i.call(this,s,n,r),e.Av(t,!e._v&&"popstate"!==(null==qt||null===(o=qt.event)||void 0===o?void 0:o.type))})}Sv(){const t=null==qt?void 0:qt.location;if(null==t?void 0:t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}xv(){const t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:gi(t)?t:{}}Cv(t=this.xv()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Fv(t){const i=this.xv(),e=this.wv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Cv(i)&&t.hash!==e.hash))}Av(t,i=!1){try{i||this.Rv();const e=this.Sv();if(!e)return;if(this.Fv(e)){const e=()=>this._instance.capture(Lt,{navigation_type:t});i?(this.Ov=e,Promise.resolve().then(()=>this.Rv())):e()}this.wv=e}catch(i){jn.error(`Error capturing ${t} pageview`,i)}}Pv(t){var i,e;return!($i(t)||!qt)&&(null===(i=Eo(String(t)))||void 0===i?void 0:i.href)!==(null===(e=qt.location)||void 0===e?void 0:e.href)}Rv(){const t=this.Ov;if(t){this.Ov=void 0,this._v=!0;try{t()}catch(t){jn.error("Error capturing deferred pageview",t)}finally{this._v=!1}this.wv=this.Sv()}}Mv(){if(this.$v)return;const t=()=>{this.Av("popstate")};Kn(qt,"popstate",t),this.$v=()=>{qt&&qt.removeEventListener("popstate",t)}}Ev(){if(this.Tv)return;const t=()=>{this.Av("hashchange")};Kn(qt,"hashchange",t),this.Tv=()=>{qt&&qt.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var i;this.Dv=!1,this.wo=!1,this.Lv=null,this.instance=t,this.Dv=!!(null===(i=this.instance.persistence)||void 0===i?void 0:i.props[p]),this.rageclicks=new $h(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return gi(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return $i(this.Mr.capture_heatmaps)?$i(this.Mr.enable_heatmaps)?this.Dv:this.Mr.enable_heatmaps:!1!==this.Mr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.wo)return;qh.info("starting..."),this.Nv(),this.sn()}else{var t;clearInterval(null!==(t=this.Lv)&&void 0!==t?t:void 0),this.qv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("heatmaps"in i))return;const e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[p]:e}),this.Dv=e,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}jv(t){Vh(t.originalEvent)&&this.Cr(t.originalEvent,"deadclick")}sn(){this.Lv&&clearInterval(this.Lv),this.Lv=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(Gt)?setInterval(this.ml.bind(this),this.flushIntervalMilliseconds):null}Nv(){qt&&Gt&&(this.Bv=this.ml.bind(this),Kn(qt,Nt,this.Bv),this.Hv=t=>this.Cr(t||(null==qt?void 0:qt.event)),Kn(Gt,"click",this.Hv,{capture:!0}),this.zv=t=>this.Uv(t||(null==qt?void 0:qt.event)),Kn(Gt,"mousemove",this.zv,{capture:!0}),this.Wv=new fo(this.instance,co,this.jv.bind(this)),this.Wv.startIfEnabledOrStop(),this.Vv=this.sn.bind(this),Kn(Gt,Bt,this.Vv),this.wo=!0)}qv(){var t;qt&&Gt&&(this.Bv&&qt.removeEventListener(Nt,this.Bv),this.Hv&&Gt.removeEventListener("click",this.Hv,{capture:!0}),this.zv&&Gt.removeEventListener("mousemove",this.zv,{capture:!0}),this.Vv&&Gt.removeEventListener(Bt,this.Vv),clearTimeout(this.Gv),null===(t=this.Wv)||void 0===t||t.stop(),this.wo=!1)}Zv(t,i){const e=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=function(t,i,e){let s=t;for(;s&&Pr(s)&&!Tr(s,"body");){if(s===e)return!1;let t;try{var n,r,o;t=null===(n=null!==(r=null===(o=s.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==r?r:qt)||void 0===n?void 0:n.getComputedStyle(s).position}catch(t){return!1}if(li(i,t))return!0;s=Lr(s)}return!1}(Dr(t),["fixed","sticky"],n);return{x:t.clientX+(r?0:s),y:t.clientY+(r?0:e),target_fixed:r,type:i}}Cr(t,i="click"){var e;if(Er(t.target)||!Vh(t))return;const s=this.Zv(t,i);(null===(e=this.rageclicks)||void 0===e?void 0:e.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&Gr(Dr(t),this.instance.config.rageclick)&&this.Zs(cs(cs({},s),{},{type:"rageclick"})),this.Zs(s)}Uv(t){!Er(t.target)&&Vh(t)&&(clearTimeout(this.Gv),this.Gv=setTimeout(()=>{this.Zs(this.Zv(t,"mousemove"))},500))}Zs(t){if(!qt)return;const i=this.Mr.disable_capture_url_hashes?ts(qt.location.href):qt.location.href,e=this.Mr.custom_personal_data_properties,s=this.Mr.mask_personal_data_properties?[...Io,...e||[]]:[],n=To(i,s,Ao);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(t)}ml(){this.Rt&&!_i(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:fo,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this.Dv=!1,this.wo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Qv=()=>{clearTimeout(this.Jv),this.Jv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",cs({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>cs(cs({},t),{},{[`$web_vitals_${i.name}_event`]:cs({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Kv=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},$i(null==t?void 0:t.name)||$i(null==t?void 0:t.value))return void Rh.error("Invalid metric received",t);const e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Xv(e);if(mi(s))return;const n=xi(t.navigationId)||"string"==typeof t.navigationId?`navigation:${t.navigationId}`:`url:${s}`;if(this.Yv&&t.value>=this.Yv)return void Rh.error("Ignoring metric with value >= "+this.Yv,t);this.Rt.navigationKey!==n&&(this.Qv(),this.Jv=setTimeout(this.Qv,this.flushToCaptureTimeoutMs)),mi(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=mi(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0),o=cs(cs(cs({},t),e?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,gi(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){const i={};for(const e of Nh){const s="url"===e&&"string"==typeof t.attribution[e]?this.Xv(t.attribution[e]):t.attribution[e];mi(s)||(i[e]=s)}o.attribution=i}else delete o.attribution;mi(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Qv()},this.tf=()=>{if(this.wo)return;let t,i,e,s,n=!1;const r=ei.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.ef])||("web-vitals"===this.ef&&mi(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!mi(l)){const r=l.withoutAttribution,o=this.attributionMetrics;n=!mi(r),t=o.indexOf("LCP")>-1?l.onLCP:(null==r?void 0:r.onLCP)||l.onLCP,i=o.indexOf("CLS")>-1?l.onCLS:(null==r?void 0:r.onCLS)||l.onCLS,e=o.indexOf("FCP")>-1?l.onFCP:(null==r?void 0:r.onFCP)||l.onFCP,s=o.indexOf("INP")>-1?l.onINP:(null==r?void 0:r.onINP)||l.onINP}if(!(t&&i&&e&&s))return void Rh.error("web vitals callbacks not loaded - not starting");const a={reportSoftNavs:this.useSoftNavs},h=n&&this.attributionMetrics.indexOf("INP")>-1?cs(cs({},a),{},{includeProcessedEventEntries:!1}):a;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Kv.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Kv.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&e(this.Kv.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&s(this.Kv.bind(this),h),this.wo=!0},this.Dv=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[b]),this.startIfEnabled()}get if(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i;const e=gi(this.if)?null===(t=this.if)||void 0===t?void 0:t.web_vitals_allowed_metrics:void 0;return $i(e)?(null===(i=this._instance.persistence)||void 0===i?void 0:i.props.$web_vitals_allowed_metrics)||jh:e}get flushToCaptureTimeoutMs(){return(gi(this.if)?this.if.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=gi(this.if)?this.if.web_vitals_attribution:void 0;return ki(t)?t?jh:[]:fi(t)?t:Bh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=gi(this.if)?this.if.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Yv(){const t=gi(this.if)&&xi(this.if.__web_vitals_max_value)?this.if.__web_vitals_max_value:Dh;return t>0&&6e4>=t?Dh:t}get isEnabled(){const t=null==Kt?void 0:Kt.protocol;if("http:"!==t&&"https:"!==t)return Rh.info("Web Vitals are disabled on non-http/https protocols"),!1;const i=gi(this.if)?this.if.web_vitals:ki(this.if)?this.if:void 0;return ki(i)?i:this.Dv}startIfEnabled(){this.isEnabled&&!this.wo&&(Rh.info("enabled, starting..."),this.Bo(this.tf))}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("capturePerformance"in i))return;const e=gi(i.capturePerformance)&&!!i.capturePerformance.web_vitals,s=gi(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[b]:e}),this._instance.persistence.register({[S]:s})),this.Dv=e,this.startIfEnabled()}get ef(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Bo(t){var i;const e=ei.__PosthogExtensions__,s=this.ef,n=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&mi(n)&&(null==e?void 0:e.postHogWebVitalsCallbacks)?t():null==e||null===(i=e.loadExternalDependency)||void 0===i||i.call(e,this._instance,s,i=>{i?Rh.error("failed to load script",i):t()})}Xv(t){const i=t||(null==qt?void 0:qt.location.href);if(!i)return void Rh.error("Could not determine current URL");const e=this._instance.config.disable_capture_url_hashes?ts(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Io,...s||[]]:[];return To(e,n,Ao)}}},Ju={exceptionObserver:class{constructor(t){var i;this.tf=()=>{var t;if(!qt||!this.isEnabled||!(null===(t=ei.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions))return;const i=ei.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=ei.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=ei.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.nf&&this.Mr.capture_unhandled_errors&&(this.nf=i(this.captureException.bind(this))),!this.sf&&this.Mr.capture_unhandled_rejections&&(this.sf=e(this.captureException.bind(this))),!this.rf&&this.Mr.capture_console_errors&&(this.rf=s(this.captureException.bind(this)))}catch(t){Fh.error("failed to start",t),this.af()}},this._instance=t,this.lf=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[g]),this.wt=new zi(cs(cs({},function(t={}){var i,e,s,n;return{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:Fh})),this.Mr=this.uf(),this.startIfEnabledOrStop()}uf(){const t=this._instance.config.capture_exceptions;let i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return gi(t)?i=cs(cs({},i),t):(mi(t)?this.lf:t)&&(i=cs(cs({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Fh.info("enabled"),this.af(),this.Bo(this.tf)):this.af()}Bo(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"exception-autocapture",i=>{if(i)return Fh.error("failed to load script",i);t()})}af(){var t,i,e;null===(t=this.nf)||void 0===t||t.call(this),this.nf=void 0,null===(i=this.sf)||void 0===i||i.call(this),this.sf=void 0,null===(e=this.rf)||void 0===e||e.call(this),this.rf=void 0}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"autocaptureExceptions"in i&&(this.lf=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[g]:this.lf}),this.Mr=this.uf(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.uf()}captureException(t){try{var i,e,s;const n=null!==(i=null==t||null===(e=t.$exception_list)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(n))return void Fh.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.hf=[],this.cf=new vs([new As,new qs,new Ds,new Rs,new Hs,new zs,new Bs,new Us],function(t,...i){return(e,s=0)=>{const n=[],r=e.split("\n"),o=Math.min(r.length,s+1e3),l=[];for(let e=s;o>e;e++){const s=r[e];if(s.length>1024)continue;const o=Es.test(s)?s.replace(Es,"$1"):s;if(!o.match(/\S*Error: /)){for(const e of i){const i=e(o,t);if(i){n.push(i);const t=Ts(n);if(t){for(let i=l.length-1;i>=0;i--){const e=l[i];if(t.start>=e.start+e.length)break;l.pop()}l.push(t)}break}}if(Is(n,l)>=50)break}}const a=[...l].sort((t,i)=>i.start-t.start),h=a[a.length-1];if(h){const t=Fs(n,h);n.splice(h.start-t,t);for(const i of a)i.start-=t}for(const t of a)Cs(n,t);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){const i=t.map(t=>`${t.function}|${t.filename}|${t.lineno}|${t.colno}|${t.module}`);let e=0;for(let t=1;i.length>t;t++)Os(i,t,e)&&(e=t);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];const i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return cs(cs({},t),{},{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",$s,ks)),this._instance=t,this.hf=null!==(i=null===(e=this._instance.persistence)||void 0===e?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.df=Js(this.vf()),this.ff=new Ys(this.df)}onConfigChange(){this.df=Js(this.vf()),this.ff.setConfig(this.df)}onRemoteConfig(t){var i,e,s;if(!t.ok)return;const n=t.config;if(!("errorTracking"in n))return;const r=null!==(i=null===(e=n.errorTracking)||void 0===e?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.hf=r,this._instance.persistence&&this._instance.persistence.register({[_]:this.hf,[m]:o})}get pf(){var t;const i=!!this._instance.get_property(m),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.cf.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.df.enabled)try{if(!bi(t)||0===t.trim().length)return void wu.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:e,droppedKeys:s}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};const i=[];return{sanitizedProperties:Object.keys(t).reduce((e,s)=>Gs.has(s)?(i.push(s),e):(e[s]=t[s],e),{}),droppedKeys:i}}(this.gf(i));s.length>0&&wu.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.ff.add(cs({[Vs]:t,[Ws]:(new Date).toISOString()},e))}catch(t){wu.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{const i=t.$exception_list;if(this.mf(i)){if(this.yf(i))return this.bf("Exception dropped: matched a suppression rule"),void wu.info("Skipping exception capture because a suppression rule matched");if(!this.pf&&this._f(i))return this.bf("Exception dropped: thrown by a browser extension"),void wu.info("Skipping exception capture because it was thrown by an extension");if(!this.pf&&this.wf(i))return this.bf("Exception dropped: thrown by an injected browser script"),void wu.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.kf(i))return this.bf("Exception dropped: thrown by the PostHog SDK"),void wu.info("Skipping exception capture because it was thrown by the PostHog SDK")}const e=this.df.enabled&&$i(t.$exception_steps)?this.Sf(t):t,s=function(){const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();s&&(e.$release_id=s);try{const t=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",dh:!0});return t&&this.ff.clear(),t}catch(t){return yu(t)||wu.error("Failed to capture exception event. Dropping this exception.",t),void this.ff.clear()}}catch(t){return void(yu(t)||wu.error("Failed to process exception event. Ignoring this exception.",t))}}Sf(t){try{const i=this.ff.getAttachable();return 0===i.length?t:cs(cs({},t),{},{$exception_steps:i})}catch(i){return wu.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}bf(t){this.df.enabled&&this.ff.add({[Vs]:t,[Ws]:(new Date).toISOString()})}gf(t){return gi(t)?cs({},t):{}}vf(){var t,i;return null!==(t=null===(i=this._instance.config.error_tracking)||void 0===i?void 0:i.exception_steps)&&void 0!==t?t:{}}yf(t){if(0===t.length)return!1;try{const i=t.reduce((t,{type:i,value:e})=>(bi(i)&&i.length>0&&t.$exception_types.push(i),bi(e)&&e.length>0&&t.$exception_values.push(e),t),{$exception_types:[],$exception_values:[]});return this.hf.some(t=>{const e=t.values.map(t=>{const e=Da[t.operator],s=i[t.key];if(!e||!s)return!1;const n=fi(t.value)?t.value:[t.value];return n.length>0&&e(n,s)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return wu.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}_f(t){const i=t.flatMap(t=>{var i,e;return null!==(i=null===(e=t.stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(({filename:t})=>!!t&&Su.some(i=>t.startsWith(i)));return 0!==e.length&&(!e.every(({filename:t})=>!!t&&t.startsWith($u))||t.some(({type:t,value:i})=>"NoResponse"===t||bi(i)&&xu.some(({value:t,exact:e})=>e?i===t:i.includes(t)))&&!i.some(({in_app:t,filename:i})=>t&&!(null==i?void 0:i.startsWith($u))))}wf(t){return t.some(({value:t})=>bi(t)&&ku.some(i=>t.includes(i)))}kf(t){if(t.length>0){var i,e,s,n;const r=null!==(i=null===(e=t[0].stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}mf(t){return!$i(t)&&fi(t)}}},Yu=cs({productTours:class{get Tl(){return this._instance.persistence}constructor(t){this.xf=null,this.Cf=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if("productTours"in i){var e,s;if(this.Tl&&this.Tl.register({[w]:!!i.productTours}),!Gh(this._instance))return!this.xf&&$i(null===(e=this.Tl)||void 0===e?void 0:e.props.ph_product_tours)||Wh.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.xf)||void 0===s||s.stop(),this.xf=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.xf&&Gh(this._instance)&&this.Bo(()=>this.$f())}Bo(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.generateProductTours)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"product-tours",i=>{i?Wh.error("Could not load product tours script",i):t()})}$f(){var t;!this.xf&&(null===(t=ei.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)&&(this.xf=ei.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i=!1){if(fi(this.Cf)&&!i)return void t(this.Cf,{isLoaded:!0});const e=this.Tl;if(e){const s=e.props[et];if(fi(s)&&!i)return this.Cf=s,void t(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!Gh(this._instance))return void t([],{isLoaded:!0});const s=i.statusCode;if(200!==s||!i.json){const e=`Product Tours API could not be loaded, status: ${s}`;return 0===s?i.error||Wh.warn(e):Wh.error(e),void t([],{isLoaded:!1,error:e})}const n=fi(i.json.product_tours)?i.json.product_tours:[];this.Cf=n,e&&e.register({[et]:n}),t(n,{isLoaded:!0})}})}getActiveProductTours(t){$i(this.xf)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.xf.getActiveProductTours(t)}showProductTour(t){var i;null===(i=this.xf)||void 0===i||i.showTourById(t)}previewTour(t){this.xf?this.xf.previewTour(t):this.Bo(()=>{var i;this.$f(),null===(i=this.xf)||void 0===i||i.previewTour(t)})}dismissProductTour(){var t;null===(t=this.xf)||void 0===t||t.dismissTour("user_clicked_skip")}nextStep(){var t;null===(t=this.xf)||void 0===t||t.nextStep()}previousStep(){var t;null===(t=this.xf)||void 0===t||t.previousStep()}clearCache(){var t;this.Cf=null,null===(t=this.Tl)||void 0===t||t.unregister("ph_product_tours")}resetTour(t){var i;null===(i=this.xf)||void 0===i||i.resetTour(t)}resetAllTours(){var t;null===(t=this.xf)||void 0===t||t.resetAllTours()}cancelPendingTour(t){var i;null===(i=this.xf)||void 0===i||i.cancelPendingTour(t)}}},Wu),Xu={siteApps:class{constructor(t){this._instance=t,this.Tf=0,this.If=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Mf(t,i){if(!i)return;const e=this.globalsForEvent(i);this.If.push(e),this.If.length>1e3&&(this.If=this.If.slice(10))}get siteAppLoaders(){var t;return null===(t=ei._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.Mf.bind(this));this.Ef=()=>{t(),this.If=[],this.Ef=void 0}}}globalsForEvent(t){var i,e,s,n,r,o,l;if(!t)throw new Error("Event payload is required");const a={},h=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[t,i]of Object.entries(u))a[t]={id:h[t],type:t,properties:i};const{$set_once:d,$set:c}=t;return{event:cs(cs({},cn(t,Kh)),{},{properties:cs(cs(cs({},t.properties),c?{$set:cs(cs({},null!==(i=null===(e=t.properties)||void 0===e?void 0:e.$set)&&void 0!==i?i:{}),c)}:{}),d?{$set_once:cs(cs({},null!==(s=null===(n=t.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=t.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(l=t.properties)||void 0===l?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Pf(t){var i;const e=null===(i=t.tagName)||void 0===i?void 0:i.toLowerCase();if("style"===e&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(t)||(Jh.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===e&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(t)||(Jh.error("prepare_external_dependency_script returned null"),null)}return t}Rf(){var t,i,e,s,n,r,o,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const a=null==Gt?void 0:Gt.defaultView,h=null==a||null===(t=a.Node)||void 0===t?void 0:t.prototype;if(!a||!h)return()=>{};if(this.Tf++,this.Af)return this.Ff();const u=[],d=this,c=new WeakSet,v=(t,i,e)=>{if(!(null==t?void 0:t[i]))return;const s=t[i];t[i]=e(s),u.push(()=>{t[i]=s})},f=t=>{if(c.has(t))return t;const i=d.Pf(t);return i&&c.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!wi(t));return v(h,"appendChild",t=>function(i){const e=f(i);return e?t.call(this,e):i}),v(h,"insertBefore",t=>function(i,e){const s=f(i);return s?t.call(this,s,e):i}),v(h,"replaceChild",t=>function(i,e){const s=f(i);return s?t.call(this,s,e):e}),[null===(i=a.Element)||void 0===i?void 0:i.prototype,null===(e=a.Document)||void 0===e?void 0:e.prototype,null===(s=a.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(t=>{v(t,"append",t=>function(...i){return t.apply(this,p(i))}),v(t,"prepend",t=>function(...i){return t.apply(this,p(i))})}),[null===(n=a.Element)||void 0===n?void 0:n.prototype,null===(r=a.CharacterData)||void 0===r?void 0:r.prototype,null===(o=a.DocumentType)||void 0===o?void 0:o.prototype].forEach(t=>{v(t,"before",t=>function(...i){return t.apply(this,p(i))}),v(t,"after",t=>function(...i){return t.apply(this,p(i))}),v(t,"replaceWith",t=>function(...i){const e=p(i);return i.length&&!e.length?void 0:t.apply(this,e)})}),v(null===(l=a.Element)||void 0===l?void 0:l.prototype,"insertAdjacentElement",t=>function(i,e){const s=f(e);return s?t.call(this,i,s):null}),this.Af=()=>{u.forEach(t=>t()),this.Af=void 0},this.Ff()}Ff(){let t=!1;return()=>{var i;t||(t=!0,this.Tf--,0===this.Tf&&(null===(i=this.Af)||void 0===i||i.call(this)))}}Of(t,i=!0){const e=this.Rf();try{const s=t(e);return i&&e(),s}catch(t){throw e(),t}}setupSiteApp(t){const i=this.apps[t.id],e=()=>{var e;!i.errored&&this.If.length&&(Jh.info(`Processing ${this.If.length} events for site app with id ${t.id}`),this.If.forEach(t=>this.Of(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null===(e=this.Ef)||void 0===e||e.call(this))};let s=!1;const n=n=>{i.errored=!n,i.loaded=!0,Jh.info(`Site app with id ${t.id} ${n?"loaded":"errored"}`),s&&e()};try{const{processEvent:e}=this.Of(i=>t.init({posthog:this._instance,callback(t){i(),n(t)}}),!1);e&&(i.processEvent=e),s=!0}catch(i){Jh.error(Yh+t.id,i),n(!1)}if(s&&i.loaded)try{e()}catch(e){Jh.error(`Error while processing buffered events PostHog app with config id ${t.id}`,e),i.errored=!0}}Df(){const t=this.siteAppLoaders||[];for(const i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(const i of t)this.setupSiteApp(i)}Lf(t){if(0===Object.keys(this.apps).length)return;const i=this.globalsForEvent(t);for(const e of Object.values(this.apps))try{this.Of(()=>{var t;return null===(t=e.processEvent)||void 0===t?void 0:t.call(e,i)})}catch(i){Jh.error(`Error while processing event ${t.event} for site app ${e.id}`,i)}}onRemoteConfig(t){var i,e,s;if(null===(i=this.siteAppLoaders)||void 0===i?void 0:i.length)return this.isEnabled?(this.Df(),void this._instance.on("eventCaptured",t=>this.Lf(t))):void Jh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(e=this.Ef)||void 0===e||e.call(this),!t.ok)return;const n=t.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:t,url:i}of n.siteApps){var r,o;ei[`__$$ph_site_app_${t}`]=this._instance,null===(r=ei.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,i,i=>{if(i)return Jh.error(Yh+t,i)})}else Jh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Zu={tracingHeaders:class{constructor(t){this._instance=t,this.Nf=void 0,this.qf=void 0,this.jf=void 0,this.tf=()=>{const t=this.Bf();var i,e;t?(mi(this.Nf)&&(this.Nf=null===(i=ei.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),mi(this.qf)&&(this.qf=null===(e=ei.__PosthogExtensions__)||void 0===e||null===(e=e.tracingHeadersPatchFns)||void 0===e?void 0:e._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.af()}}initialize(){this.startIfEnabledOrStop()}Bo(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.tracingHeadersPatchFns)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"tracing-headers",i=>{if(i)return Ah.error("failed to load script",i);t()})}Hf(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Bf(){const t=this.Hf();return fi(t)?(fi(this.jf)?this.jf.splice(0,this.jf.length,...t):this.jf=[...t],t.length>0?this.jf:void 0):(fi(this.jf)&&this.jf.splice(0),this.jf=t||void 0,this.jf)}af(){var t,i;null===(t=this.Nf)||void 0===t||t.call(this),null===(i=this.qf)||void 0===i||i.call(this),this.Nf=void 0,this.qf=void 0}startIfEnabledOrStop(){this.Bf()?this.Bo(this.tf):this.af()}}},Qu=cs({surveys:class extends tu{constructor(t){var i;super(new ou(t),(i=t,{get projectToken(){return i.config.token},kv:new ru(i)})),this._instance=t}Wh(t,i){const e=i.query?ra(t,i.query):t;return new Promise(t=>{var s;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})})}}},Wu),td={toolbar:class{constructor(t){this.instance=t}zf(t){ei.ph_toolbar_state=t}Uf(){var t;return null!==(t=ei.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,i=void 0,e=void 0){var s,n;if(Jn(this.instance.config))return!1;if(!qt||!Gt)return!1;t=null!==(s=t)&&void 0!==s?s:qt.location,e=null!==(n=e)&&void 0!==n?n:qt.history;try{if(!i){try{qt.localStorage.setItem("test","test"),qt.localStorage.removeItem("test")}catch(t){return!1}i=null==qt?void 0:qt.localStorage}const s=lu||Co(t.hash,"__posthog")||Co(t.hash,"state");let n;const r=s?is(()=>JSON.parse(atob(decodeURIComponent(s))))||is(()=>JSON.parse(decodeURIComponent(s))):null;return r&&"ph_authorize"===r.action?(n=r,n.source="url",n&&Object.keys(n).length>0&&(r.desiredHash?t.hash=r.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):(n=JSON.parse(i.getItem(au)||"{}"),n.source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}Wf(t){const i=ei.ph_load_toolbar||ei.ph_load_editor;!$i(i)&&pi(i)?i(t,this.instance):hu.warn("No toolbar load function found")}loadToolbar(t){const i=!!(null==Gt?void 0:Gt.getElementById("__POSTHOG_TOOLBAR__"));if(!qt||i)return!1;const e="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=cs(cs({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},e?{instrument:!1}:{});if(qt.localStorage.setItem(au,JSON.stringify(cs(cs({},s),{},{source:void 0}))),2===this.Uf())this.Wf(s);else if(0===this.Uf()){var n,r;this.zf(1),null===(n=ei.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",t=>{if(t)return hu.error("[Toolbar] Failed to load",t),void this.zf(0);this.zf(2),this.Wf(s)}),Kn(qt,"turbolinks:load",()=>{this.zf(0),this.loadToolbar(s)})}return!0}Vf(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,i=void 0,e=void 0){return this.maybeLoadToolbar(t,i,e)}}},id=cs({experiments:class t{get Mr(){return this._instance.config}constructor(i){this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=(i=!1)=>{this.getWebExperiments(i=>{t.Gf("retrieved web experiments from the server"),this.Zf=new Map,i.forEach(i=>{if(i.feature_flag_key){var e;this.Zf&&(t.Gf("setting flag key ",i.feature_flag_key," to web experiment ",i),null===(e=this.Zf)||void 0===e||e.set(i.feature_flag_key,i));const s=this._instance.getFeatureFlag(i.feature_flag_key);bi(s)&&i.variants[s]&&this.Qf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(const e in i.variants){const s=i.variants[e];t.Jf(s,this._instance)&&this.Qf(i.name,e,s.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.Gf(Eu);else if(!this.Mr.disable_web_experiments){if($i(this.Zf))return this.Zf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Gf("applying feature flags",i),i.forEach(t=>{var i;if(this.Zf&&(null===(i=this.Zf)||void 0===i?void 0:i.has(t))){var e;const i=this._instance.getFeatureFlag(t),s=null===(e=this.Zf)||void 0===e?void 0:e.get(t);i&&(null==s?void 0:s.variants[i])&&this.Qf(s.name,i,s.variants[i].transforms)}})}}previewWebExperiment(){const i=t.getWindowLocation();if(null==i?void 0:i.search){const e=Po(null==i?void 0:i.search,"__experiment_id"),s=Po(null==i?void 0:i.search,"__experiment_variant");e&&s&&(t.Gf(`previewing web experiments ${e} && ${s}`),this.getWebExperiments(t=>{this.Kf(parseInt(e),s,t)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Mr.disable_web_experiments&&!e)return t([]);const s=this._instance.get_property("$web_experiments");if(s&&!i)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}Kf(i,e,s){const n=s.filter(t=>t.id===i);n&&n.length>0&&(t.Gf(`Previewing web experiment [${n[0].name}] with variant [${e}]`),this.Qf(n[0].name,e,n[0].variants[e].transforms))}static Jf(i,e){return!$i(i.conditions)&&t.Xf(i,e)&&t.Yf(i)}static Xf(i,e){var s;if($i(i.conditions)||$i(null===(s=i.conditions)||void 0===s?void 0:s.url))return!0;const n=t.getWindowLocation();if(n){var r,o,l;const t=kr(e,n.href);return!(null===(r=i.conditions)||void 0===r?void 0:r.url)||Pu[null!==(o=null===(l=i.conditions)||void 0===l?void 0:l.urlMatchType)&&void 0!==o?o:"icontains"](i.conditions.url,t)}return!1}static getWindowLocation(){return null==qt?void 0:qt.location}static Yf(t){var i;if($i(t.conditions)||$i(null===(i=t.conditions)||void 0===i?void 0:i.utm))return!0;const e=Do();if(e.utm_source){var s,n,r,o,l,a,h,u;const i=!(null===(s=t.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=t.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==e.utm_campaign,d=!(null===(r=t.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=t.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==e.utm_source,c=!(null===(l=t.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)||(null===(a=t.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)==e.utm_medium,v=!(null===(h=t.conditions)||void 0===h||null===(h=h.utm)||void 0===h?void 0:h.utm_term)||(null===(u=t.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==e.utm_term;return i&&c&&v&&d}return!1}static Gf(t,...i){jn.info(`[WebExperiments] ${t}`,i)}Qf(i,e,s){this._is_bot()?t.Gf(Eu):"control"!==e?s.forEach(s=>{if(s.selector){var n;t.Gf(`applying transform of variant ${e} for experiment ${i} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(t=>{const i=t;s.html&&(i.innerHTML=s.html),s.css&&i.setAttribute("style",s.css)})}}):t.Gf("Control variants leave the page unmodified.")}_is_bot(){return Wt&&this._instance?Fa(Wt,this.Mr.custom_blocked_useragents):void 0}}},Wu),ed={conversations:class{constructor(t){this._instance=t,this.tp=void 0,this._conversationsManager=null,this.ep=!1,this.ne=null,this.np=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)return;if(this.sp=t.ok,!t.ok)return;const i=t.config.conversations;$i(i)||(ki(i)?this.tp=i:(this.tp=i.enabled,this.ne=i),this.loadIfEnabled())}reset(){var t;null===(t=this._conversationsManager)||void 0===t||t.reset(),this._conversationsManager=null,this.tp=void 0,this.ne=null,this.sp=void 0,this.np=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.ep)return;if(this._instance.config.disable_conversations)return;if(Jn(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=null==ei?void 0:ei.__PosthogExtensions__;if(t&&!mi(this.tp)&&this.tp)if(this.ne&&this.ne.token){this.ep=!0;try{const i=t.initConversations;if(i)return this.rp(i),void(this.ep=!1);const e=t.loadExternalDependency;if(!e)return void this.op(At);e(this._instance,"conversations",i=>{i||!t.initConversations?this.op("Could not load conversations script",i):this.rp(t.initConversations),this.ep=!1})}catch(t){this.op("Error initializing conversations",t),this.ep=!1}}else Tu.error("Conversations enabled but missing token in remote config.")}rp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.np=!1,Tu.info("Conversations loaded successfully")}catch(t){this.op("Error completing conversations initialization",t)}else Tu.error("Cannot complete initialization: remote config is null")}op(t,i){Tu.error(t,i),this._conversationsManager=null,this.ep=!1,this.np=!0}show(){this._conversationsManager?this._conversationsManager.show():Tu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.tp&&!wi(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Jn(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.sp?"remote_config_failed":mi(this.tp)?this.sp?"disabled_in_project":"remote_config_pending":this.tp?$i(this.ne)||!this.ne.token?"missing_token":(null==ei?void 0:ei.__PosthogExtensions__)?this.ep?"initializing":this.np?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return ji(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(Tu.warn(Cu),null)})()}getMessages(t,i){var e=this;return ji(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Tu.warn(Cu),null)})()}markAsRead(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Tu.warn(Cu),null)})()}getTickets(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Tu.warn(Cu),null)})()}requestRestoreLink(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Tu.warn(Cu),null)})()}restoreFromToken(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Tu.warn(Cu),null)})()}restoreFromUrlToken(){var t=this;return ji(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Tu.warn(Cu),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}kh(){var t;null===(t=this._conversationsManager)||void 0===t||t.setIdentity()}Sh(){var t;null===(t=this._conversationsManager)||void 0===t||t.clearIdentity()}}},sd={logs:class{constructor(t){var i;this._instance=t,this.name="logs",this.ap=!1,this.lp=!1,this.up=!1,this.A=Bn("[logs]"),this.hp=cs(cs({},this.A),{},{error:(...t)=>{t.some(Du)||this.A.error(...t)}}),this.rl=[],this.cp=[],this.bd=0,this.$o=!1,this.dp=[],this.vp=[],this.fp=!1,this.pp=!1,this.gp=()=>{var t,i;this.$o||(this.bd=0,null===(t=this.mp)||void 0===t||t.onReconnect(),null===(i=this.yp)||void 0===i||i.onReconnect())},this._instance&&(null===(i=this._instance.config.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this.ap=!0),qt&&Kn(qt,"online",this.gp)}bp(t,i,e,s){var n;const r=Fu(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,e);return[new Mn(this._p(t,i),r,this.hp,()=>this.wp(),t=>t(),void 0,s),r]}kp(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.mp&&this.Sp===i||(null===(e=this.mp)||void 0===e||e.reset(),this.Sp=i,[this.mp,this.xp]=this.bp(()=>this.rl,t=>{this.rl=t})),this.mp}Cp(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.yp&&this.$p===i||(null===(e=this.yp)||void 0===e||e.reset(),this.$p=i,[this.yp,this.Tp]=this.bp(()=>this.cp,t=>{this.cp=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Ou)),this.yp}setup(t){var i;if(this.$o)return;this.yo=t,(null===(i=this._instance)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this.ap=!0),(this.ap||this.Ip()&&this.Mp())&&this.Ep();let e=!1;const s=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.$o?s.dispose():(this.Mo=s,e||this.loadIfEnabled())}dispose(){var t,i,e,s;this.$o||(this.$o=!0,this.Pp(),null===(t=this.Mo)||void 0===t||t.dispose(),this.Mo=void 0,this.yo=void 0,this.up=!1,null==qt||qt.removeEventListener("online",this.gp),null===(i=this.Rp)||void 0===i||i.call(this),this.Rp=void 0,null===(e=this.mp)||void 0===e||e.reset(),null===(s=this.yp)||void 0===s||s.reset())}onRemoteConfig(t){var i,e;if(this.$o)return;const s=t.ok?null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs:void 0;$i(s)?this.Ap():(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.register({$logs_capture_enabled_server_side:!!s}),s?(this.ap=!0,this.lp||this.Ep(),this.loadIfEnabled()):this.Ap())}reset(){var t,i,e,s;this.Pp(),null===(t=this.mp)||void 0===t||t.clearQueue(),this.rl=[],null===(i=this.mp)||void 0===i||i.reset(),null===(e=this.yp)||void 0===e||e.clearQueue(),this.cp=[],null===(s=this.yp)||void 0===s||s.reset(),this.bd=0}captureLog(t){this.$o||this.kp().captureLog(t)}captureConsoleLog(t){this.$o||this.Cp().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.$o||this.Cp().captureLog(t,{context:i,occurredAtMs:e})}Mp(){var t;return!!(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t[x])}Ip(){var t,i,e;return!(null===(t=this._instance)||void 0===t||null===(i=t.el)||void 0===i?void 0:i.call(t))||!!(null===(e=ei._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config)}Ch(){var t;this.Pp(),null===(t=this.yp)||void 0===t||t.clearQueue(),this.cp=[]}Ap(){this.ap||this.Pp()}Ep(){var t;if(this.fp||!(null==ei?void 0:ei.console))return;const i=Fu(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs).maxBufferSize;let e=!0;this.vp.push(()=>{e=!1});for(const t of Mu){let s;try{s=Iu(ei.console[t])}catch(t){continue}s&&this.vp.push(Oh(ei.console,t,n=>{const r=(...s)=>{try{e&&this.Fp(t,s,i)}catch(t){}return n.apply(ei.console,s)};return r.__rrweb_original__=s,r}))}this.fp=!0,this.Op=setTimeout(()=>{this.Pp()},3e4)}Fp(t,i,e){var s;if(this.fp&&!this.pp&&0!==i.length)if(null===(s=this._instance)||void 0===s?void 0:s.is_capturing()){if(e>this.dp.length){this.pp=!0;try{this.dp.push({level:t,args:i,occurredAtMs:Date.now(),context:this.wp()})}finally{this.pp=!1}}}else this.Pp()}Pp(){if(this.dp=[],this.fp){this.fp=!1,this.Op&&(clearTimeout(this.Op),this.Op=void 0);for(const t of this.vp)t();this.vp=[]}}Dp(){const t=this.dp;return this.Pp(),t}get logger(){return this.Lp||(this.Lp={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.Lp}flushLogs(t){t?this.Np(t):(this.mp&&this.mp.flush().catch(t=>this.qp(t)),this.yp&&this.yp.flush().catch(t=>this.qp(t)))}qp(t){Du(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.$o||!this.ap||this.lp||this.up)return;const t=null==ei?void 0:ei.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Pp();const i=t.loadExternalDependency;if(!i)return this.A.error(At),void this.Pp();this.up=!0;try{i(this._instance,"logs",i=>{if(this.up=!1,this.$o||!this.ap)return;const e=t.logs;if(i||!(null==e?void 0:e.initializeLogs))this.A.error("Could not load logs script",i),this.Pp();else{var s;const t=this.Dp();var n,r;this.Rp=e.initializeLogs(null!==(s=this.yo)&&void 0!==s?s:this._instance),this.lp=!0,t.length>0&&(null===(n=e.replayConsoleBuffer)||void 0===n||n.call(e,null!==(r=this.yo)&&void 0!==r?r:this._instance,t))}})}catch(t){throw this.up=!1,t}}_p(t,i){const s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===si.LogsQueue?t():void 0,setPersistedProperty(t,e){var s;t===si.LogsQueue&&i(null!==(s=e)&&void 0!==s?s:[])},js:t=>this.js(t),getLibraryId:()=>e.LIB_NAME,getLibraryVersion:()=>e.LIB_VERSION}}js(t){return new Promise(i=>{if(Fo(this.bd,3))return void i({kind:"fatal",error:Ru(void 0,"logs endpoint is unreachable, dropping batch")});let e=!1;const s=t=>{e||(e=!0,clearTimeout(n),i(t))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Ru(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.jp(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{const i=t.statusCode;if(this.Bp(i),i>=200&&300>i)s({kind:"ok"});else if(413===i)s({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)s({kind:"fatal",error:new Error(`logs request failed with status ${i}`)});else{var e;0===i?(t.error||this.A.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Ru(t.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`logs request failed with status ${i}`)})}}})})}Bp(t){(0!==t||this._instance.__loaded)&&(this.bd=Mo(t,this.bd,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Np(t){this.rl.length>0&&this.Hp(t,this.rl,this.xp,e.LIB_NAME,t=>{this.rl=t}),this.cp.length>0&&this.Hp(t,this.cp,this.Tp,Ou,t=>{this.cp=t})}Hp(t,i,s,n,r){if(0===i.length)return;const o=i.map(t=>t.record);r([]);const l=Pn(o,En(s,e.LIB_NAME,e.LIB_VERSION),n,e.LIB_VERSION);this._instance._send_request({method:"POST",url:this.jp(),data:l,compression:"best-available",batchKey:"logs",transport:t})}jp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}wp(){var t;const i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:t,windowId:e,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=e,$i(s)||(i.sessionStartTimestamp=s),$i(n)||(i.lastActivityTimestamp=n)}if((null==ei||null===(t=ei.location)||void 0===t?void 0:t.href)&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?ts(ei.location.href):ei.location.href),this._instance.featureFlags){const t=this._instance.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}}},nd={metrics:class{constructor(t){this._instance=t,this.A=Bn("[metrics]"),this.$o=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.$o)return;const i=!!(null===(t=this._instance.config.metrics)||void 0===t?void 0:t.network);i&&!this.zp?this.zp=(t=>{let i=!0;const e=()=>i?(t=>{var i;const e=null===(i=t.config.metrics)||void 0===i?void 0:i.network;return!0===e?{}:e||void 0})(t):void 0,s=qu(t,e),n=Vu(t,e);return()=>{i=!1,s(),n()}})(this._instance):!i&&this.zp&&(this.zp(),this.zp=void 0)}kp(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.metrics;var e;return this.mp&&this.Sp===i||(null===(e=this.mp)||void 0===e||e.reset(),this.Sp=i,this.mp=new Rn(this._p(),function(t){var i,e,s,n,r;const o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(i),this.A)),this.mp}count(t,i=1,e){this.kp().count(t,i,e)}gauge(t,i,e){this.kp().gauge(t,i,e)}histogram(t,i,e){this.kp().histogram(t,i,e)}flush(t){if(!this.mp)return Promise.resolve();if(t){const i=this.mp.drainWindow();return i&&this.Ys(i,t),Promise.resolve()}return this.mp.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null===(t=this.mp)||void 0===t||t.reset()}dispose(){var t,i;this.$o=!0,null===(t=this.zp)||void 0===t||t.call(this),this.zp=void 0,null===(i=this.mp)||void 0===i||i.reset()}_p(){const t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:t=>i.Ys(t),getLibraryId:()=>e.LIB_NAME,getLibraryVersion:()=>e.LIB_VERSION}}Ys(t,i){return new Promise(e=>{let s=!1;const n=t=>{s||(s=!0,clearTimeout(r),e(t))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(cs(cs({method:"POST",url:this.Up(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i}),{},{fireCallbackOnDrop:!0,callback(t){const i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error(`metrics request failed with status ${i}`)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`metrics request failed with status ${i}`)})}}}))})}Up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};wh.__defaultExtensionClasses=cs({},cs(cs(cs(cs(cs(cs(cs(cs(cs(cs(cs(cs(cs({},Wu),Gu),Ku),Ju),Yu),Xu),Qu),Zu),td),id),ed),sd),nd))}();
|
|
1
|
+
!function(){const t="0.9.0",i={DEBUG:(!1,!1),LIB_VERSION:(t,"1.435.3"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:t};var e=i;const s="$people_distinct_id",n="distinct_id",r="$device_id",o="$device_model",l="__alias",a="__cmpns",h="$fbc",u="$fbc_persistence",d="$fbp",c="$fbp_persistence",v="__timers",f="$autocapture_disabled_server_side",p="$heatmaps_enabled_server_side",g="$exception_capture_enabled_server_side",_="$error_tracking_suppression_rules",m="$error_tracking_capture_extension_exceptions",b="$web_vitals_enabled_server_side",y="$dead_clicks_enabled_server_side",w="$product_tours_enabled_server_side",x="$logs_capture_enabled_server_side",S="$web_vitals_allowed_metrics",k="$session_recording_remote_config",E="$session_recording_enabled_server_side",P="$replay_sample_rate",T="$replay_override_sampling",C="$replay_override_linked_flag",F="$replay_override_url_trigger",M="$replay_override_event_trigger",I="$sesid",O="$session_is_sampled",A="$session_past_minimum_duration",R="$session_recording_url_trigger_activated_session",D="$session_recording_event_trigger_activated_session",j="$debug_first_full_snapshot_timestamp",B="$sess_rec_flush_size",N="$enabled_feature_flags",L="$active_feature_flags",z="$early_access_features",H="$feature_flag_details",U="$feature_flag_payloads",q="$feature_flag_request_id",V="$minimal_flag_called_events",W="$override_feature_flags",G="$override_feature_flag_payloads",K="$stored_person_properties",J="$stored_group_properties",Y="$groups",X="$surveys",Z="$surveys_loaded_at",Q="$surveys_activated",tt="$surveys_activated_session",it="$surveys_activated_timestamps",et="ph_product_tours",st="$product_tours_activated",nt="$product_tours_activated_session",rt="$conversations_widget_session_id",ot="$conversations_ticket_id",lt="$conversations_widget_state",at="$conversations_user_traits",ht="$flag_call_reported",ut="$flag_call_reported_session_id",dt="$feature_flag_errors",ct="$feature_flag_evaluated_at",vt="$user_state",ft="$client_session_props",pt="$capture_rate_limit",gt="$initial_campaign_params",_t="$initial_referrer_info",mt="$initial_person_info",bt="$epp",yt="$posthog_cookieless",wt="$cookieless_mode",$t="$sdk_debug_extensions_init_method",xt="$sdk_debug_extensions_init_time_ms",St="$sdk_debug_recording_script_not_loaded",kt="$sdk_debug_replay_stale_config",Et="$sdk_debug_replay_event_trigger_status",Pt="$sdk_debug_replay_linked_flag_trigger_status",Tt="$sdk_debug_replay_matched_recording_trigger_groups",Ct="$sdk_debug_replay_pending_trigger_conditions",Ft="$sdk_debug_replay_remote_trigger_matching_config",Mt="$sdk_debug_replay_trigger_groups_count",It="$sdk_debug_replay_url_trigger_status",Ot="$session_recording_start_reason",At="PostHog loadExternalDependency extension not found.",Rt="anonymous",Dt="identified",jt="identified_only",Bt="visibilitychange",Nt="beforeunload",Lt="$pageview",zt="$pageleave",Ht="$identify",Ut="$groupidentify",qt="u">typeof window?window:void 0,Vt="u">typeof globalThis?globalThis:qt,Wt=null==Vt?void 0:Vt.navigator,Gt=null==Vt?void 0:Vt.document,Kt=null==Vt?void 0:Vt.location,Jt=null==Vt?void 0:Vt.fetch,Yt=(null==Vt?void 0:Vt.XMLHttpRequest)&&"withCredentials"in new Vt.XMLHttpRequest?Vt.XMLHttpRequest:void 0,Xt=null==Vt?void 0:Vt.AbortController,Zt=null==Vt?void 0:Vt.CompressionStream,Qt=null==Wt?void 0:Wt.userAgent;function ti(){return!(!qt||!1===qt.navigator.onLine)}const ii="undefined"!=typeof globalThis?globalThis:qt;ii&&"undefined"==typeof self&&(ii.self=ii),ii&&"undefined"==typeof File&&(ii.File=function(){});const ei=null!=qt?qt:{};var si=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),ni=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({});const ri=["$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"],oi=["token"];function li(t,i){return-1!==t.indexOf(i)}const ai=function(t){return t.trim()},hi=function(t){return t.replace(/^\$/,"")};function ui(t){var i;const e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}const di=Object.prototype,ci=di.hasOwnProperty,vi=di.toString,fi=Array.isArray||function(t){return"[object Array]"===vi.call(t)},pi=t=>"function"==typeof t,gi=t=>t===Object(t)&&!fi(t),_i=t=>{if(gi(t)){for(const i in t)if(ci.call(t,i))return!1;return!0}return!1},mi=t=>void 0===t,bi=t=>"[object String]"==vi.call(t),yi=t=>bi(t)&&0===t.trim().length,wi=t=>null===t,$i=t=>mi(t)||wi(t),xi=t=>"[object Number]"==vi.call(t)&&t==t,Si=t=>xi(t)&&t>0,ki=t=>"[object Boolean]"===vi.call(t),Ei=t=>li(ri,t),Pi=t=>li(oi,t);function Ti(t){return null===t||"object"!=typeof t}function Ci(t,i){return{}.toString.call(t)===`[object ${i}]`}function Fi(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Ii(t,Error)}}function Mi(t){return"u">typeof Event&&Ii(t,Event)}function Ii(t,i){try{return t instanceof i}catch(t){return!1}}const Oi=[!0,"true",1,"1","yes"],Ai=t=>li(Oi,t),Ri=[!1,"false",0,"0","no"];function Di(t,i,e,s,n,r,o){try{var l=t[r](o),a=l.value}catch(t){return void e(t)}l.done?i(a):Promise.resolve(a).then(s,n)}function ji(t){return function(){var i=this,e=arguments;return new Promise(function(s,n){var r=t.apply(i,e);function o(t){Di(r,s,n,o,l,"next",t)}function l(t){Di(r,s,n,o,l,"throw",t)}o(void 0)})}}const Bi=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Ni=function(t,i=[]){if(!t)return!1;const e=t.toLowerCase();return Bi.concat(i).some(t=>{const i=t.toLowerCase();return-1!==e.indexOf(i)})};function Li(t,i,e,s,n){return i>e&&(s.warn("min cannot be greater than max."),i=e),xi(t)?t>e?(s.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(s.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(s.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+n),Li(null!=n?n:e,i,e,s))}var zi=class{constructor(t){this.C={},this.I=t.I,this.R=Li(t.bucketSize,0,100,t.A),this.$=Li(t.refillRate,0,this.R,t.A),this.O=Li(t.refillInterval,0,864e5,t.A)}F(t,i){const e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.$,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i;const e=Date.now(),s=String(t);let n=this.C[s];return n?this.F(n,e):(n={tokens:this.R,lastAccess:e},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(i=this.I)||void 0===i||i.call(this,t)),0===n.tokens)}stop(){this.C={}}};const Hi="Mobile",Ui="Android",qi="Tablet",Vi="Android Tablet",Wi="iPad",Gi="Apple Watch",Ki="Safari",Ji="BlackBerry",Yi="Samsung Internet",Xi="Chrome",Zi="Chrome iOS",Qi="Internet Explorer",te="Internet Explorer Mobile",ie="Opera",ee="Microsoft Edge",se="Firefox",ne="Firefox iOS",re="Nintendo",oe="PlayStation",le="Xbox",ae="Android Mobile",he="Mobile Safari",ue="Windows",de="Windows Phone",ce="Nokia",ve="Ouya",fe="Generic "+Hi.toLowerCase(),pe="Generic "+qi.toLowerCase(),ge="Konqueror",_e="Oculus Browser",me="Vivaldi",be="Yandex",ye="Whale",we="DuckDuckGo",$e="Pale Moon",xe="Waterfox",Se="Brave",ke="Claude",Ee="Codex",Pe="ChatGPT",Te="Google Search App",Ce=new RegExp("Version/(\\d+(\\.\\d+)?)"),Fe=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Me=new RegExp(le,"i"),Ie=new RegExp("PlayStation \\w+","i"),Oe=new RegExp("Nintendo \\w+","i"),Ae=new RegExp("BlackBerry|PlayBook|BB10","i"),Re={"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"},De=function(t,i,e,s){i=i||"";const n=function(t){return(null==t?void 0:t.brave)?Se:null}(e);return n||((null==s?void 0:s.detectGoogleSearchApp)&&li(t,"GSA/")?Te:li(t," OPR/")&&li(t,"Mini")?"Opera Mini":li(t," OPR/")?ie:Ae.test(t)?Ji:li(t,"IEMobile")||li(t,"WPDesktop")?te:li(t,"OculusBrowser")?_e:li(t,"SamsungBrowser")?Yi:li(t,"Edge")||li(t,"Edg/")?ee:li(t,"Vivaldi/")?me:li(t,"YaBrowser/")?be:li(t,"Whale/")?ye:li(t,"DuckDuckGo/")||li(t,"Ddg/")?we:li(t,"Claude/")?ke:li(t,"Codex/")?Ee:li(t,"ChatGPT/")?Pe:li(t,"FBIOS")?"Facebook Mobile":li(t,"UCWEB")||li(t,"UCBrowser")?"UC Browser":li(t,"CriOS")?Zi:li(t,"CrMo")||li(t,Xi)?Xi:li(t,Ui)&&li(t,Ki)?ae:li(t,"FxiOS")?ne:li(t.toLowerCase(),ge.toLowerCase())?ge:li(t,"Brave/")?Se:((t,i)=>i&&li(i,"Apple")||function(t){return li(t,Ki)&&!li(t,Xi)&&!li(t,Ui)}(t))(t,i)?li(t,Hi)?he:Ki:li(t,"PaleMoon/")?$e:li(t,"Waterfox/")?xe:li(t,se)?se:li(t,"MSIE")||li(t,"Trident/")?Qi:li(t,"Gecko")?se:"")},je={[te]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ee]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Xi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Zi]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ki]:[Ce],[he]:[Ce],[ie]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[se]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ne]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[ge]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Ji]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ce],[ae]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Yi]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[_e]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[me]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[be]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ye]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Se]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[ke]:[Fe],[Ee]:[Fe],[Pe]:[Fe],[we]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[$e]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[xe]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Te]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Qi]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Be=function(t,i,e,s){const n=De(t,i,e,s),r=je[n];if(mi(r))return null;for(let i=0;r.length>i;i++){const e=t.match(r[i]);if(e)return parseFloat(e[e.length-2])}return null},Ne=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[le,t&&t[1]||""]],[new RegExp(re,"i"),[re,""]],[new RegExp(oe,"i"),[oe,""]],[Ae,[Ji,""]],[new RegExp(ue,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[de,""];if(new RegExp(Hi).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];const e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){let t=Re[e[1]]||"";return/arm/i.test(i)&&(t="RT"),[ue,t]}return[ue,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let i="";return t&&t.length>=3&&(i=mi(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[Ui,[t[2],t[3],t[4]||"0"].join(".")]:[Ui,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Le=function(t){for(let i=0;Ne.length>i;i++){const[e,s]=Ne[i],n=e.exec(t),r=n&&(pi(s)?s(n,t):s);if(r)return r}return["",""]},ze=function(t){return Oe.test(t)?re:Ie.test(t)?oe:Me.test(t)?le:new RegExp(ve,"i").test(t)?ve:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?de:/iPad/.test(t)?Wi:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Gi:Ae.test(t)?Ji:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(ce,"i").test(t)?ce:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Hi).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Ui:Vi:new RegExp("(pda|Mobile)","i").test(t)?fe:new RegExp(qi,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?pe:""},He=function(t,i){var e;const s=ze(t);return s===Wi||s===Vi||"Kobo"===s||"Kindle Fire"===s||s===pe?qi:s===re||s===le||s===oe||s===ve?"Console":s===Gi?"Wearable":s?Hi:"Android"===(null==i?void 0:i.userAgentDataPlatform)&&(null!==(e=null==i?void 0:i.maxTouchPoints)&&void 0!==e?e:0)>0?600>Math.min(null!==(n=null==i?void 0:i.screenWidth)&&void 0!==n?n:0,null!==(r=null==i?void 0:i.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==i?void 0:i.devicePixelRatio)&&void 0!==o?o:1)?Hi:qi:"Desktop";var n,r,o},Ue=/\bFBAV\/(\d+(?:\.\d+)*)/i,qe=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Ue],[/\bFBAN\/EMA\b/i,"Facebook Lite",Ue],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Ue],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Ve="[Truncated]",We="[Unserializable]";function Ge(t){let i="";for(let e=0;t.length>e;e++){const s=t.charCodeAt(e);if(55296>s||s>56319)i+=56320>s||s>57343?t[e]:"�";else{const s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}function Ke(t,i){if(!i)return t;let e=[];try{e=Object.keys(i)}catch(t){e=[]}for(const s of e){let e;try{e=i[s]}catch(t){e=We}Object.defineProperty(t,s,{value:e,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;const Je=3e5;var Ye=class{record(t){if("too-large"===t.kind)return;if("retry-later"!==t.kind)return void this.reset();if(!t.retryAfterMs)return;const i=this.isOpen(),e=Date.now(),s=Math.min(t.retryAfterMs,Je);if(!i)return this.ts=e,void(this.es=e+s);this.es=Math.max(this.es,Math.min(e+s,this.ts+Je))}remainingMs(){const t=Date.now();if(this.ts-5e3>t)return this.reset(),0;const i=Math.min(Je,Math.max(0,this.es-t));return 0===i&&this.reset(),i}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const Xe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ze(t,i){return"string"==typeof(e=t)&&Xe.test(e)?t:i();var e}function Qe(t,i){const e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function ts(t){return t?t.split("#")[0]:t}function is(t){try{return t()}catch(t){return}}function es(t,i){const e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function ss(t,i,e){return ns.apply(this,arguments)}function ns(){return(ns=ji(function*(t,i,e){let s;try{return yield Promise.race([t,new Promise((t,n)=>{s=es(()=>{try{null==e||e(),t()}catch(t){n(t)}},i)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let rs,os,ls;function as(t){const i=globalThis._posthogChunkIds;if(!i)return;const e=Object.keys(i);return ls&&e.length===os||(os=e.length,ls=e.reduce((e,s)=>{rs||(rs={});const n=rs[s];if(n)e[n[0]]=n[1];else{const n=t(s);for(let t=n.length-1;t>=0;t--){const r=n[t],o=null==r?void 0:r.filename,l=i[s];if(o&&l){e[o]=l,rs[s]=[o,l];break}}}return e},{})),ls}function hs(t){return hs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hs(t)}function us(t,i,e){return(i=function(t){var i=function(t){if("object"!=hs(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var e=i.call(t,"string");if("object"!=hs(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hs(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function ds(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,s)}return e}function cs(t){for(var i=1;arguments.length>i;i++){var e=null!=arguments[i]?arguments[i]:{};i%2?ds(Object(e),!0).forEach(function(i){us(t,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ds(Object(e)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}return t}var vs=class{constructor(t,i,e=[]){this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i={}){const e=i&&i.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(e,i,0).apply(t),n=this.buildParsingContext(i),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,e),$exception_level:"error"}}modifyFrames(t){var i=this;return ji(function*(){for(const e of t)e.stacktrace&&e.stacktrace.frames&&fi(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e;let s,n;if(null!=t.cause&&(s=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)}catch(t){}return cs(cs({},t),{},{cause:s,stack:n,errors:null===(e=t.errors)||void 0===e?void 0:e.map(t=>this.parseStacktrace(t,i))})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(const e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return ji(function*(){let e=t;for(const t of i.modifiers)e=yield t(e);return e})()}convertToExceptionList(t,i){const e=[],s=(t,n,r)=>{var o;const l=e.length,a=void 0===n?cs(cs({type:"string"==typeof i.type&&i.type.length>0?i.type:"generic"},"boolean"==typeof i.handled?{handled:i.handled}:void 0===i.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof i.synthetic?i.synthetic:t.synthetic,exception_id:l}):{type:"chained",source:r,synthetic:t.synthetic,exception_id:l,parent_id:n},h={type:t.type,value:t.value,mechanism:a};t.stack&&(h.stacktrace={type:"raw",frames:t.stack}),e.push(h),t.cause&&s(t.cause,l,"cause");for(const i of null!==(o=t.errors)&&void 0!==o?o:[])s(i,l,"member")};return s(t),e}buildParsingContext(t){var i;return{chunkIdMap:as(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}getAggregateErrors(t){try{if(Fi(t)){let e=Object.getPrototypeOf(t);for(let s=0;e&&100>s;s++){var i;const s=null===(i=Object.getOwnPropertyDescriptor(e,"constructor"))||void 0===i?void 0:i.value;if("function"==typeof s&&"AggregateError"===s.name){const i=t.errors;return fi(i)?i:void 0}e=Object.getPrototypeOf(e)}}}catch(t){}}buildCoercingContext(t,i,e=0){let s=0,n=0,r=!1;const o=new Set,l=[],a={},h=(t,i,e=0)=>{const h=u(i,e),d=h.apply;if(h.apply=i=>{l.push(t);try{return d(i)}finally{l.pop()}},e>4||e>0&&-1!==l.indexOf(t))return this.coerceFallback(h);const c="object"==typeof t&&null!==t||"function"==typeof t;if(0===e&&s>=50||c&&o.has(t))return;c&&o.add(t),0===e&&s++;const v=this.getAggregateErrors(t);let f,p;r||(r=!!v);try{if(f=this.applyCoercers(t,h),!f)throw a}catch(t){if(t===a)return void(0===e&&s--);if(!r)throw t;f=this.coerceFallback(h)}if(!v||s>=50)return f;try{p=v.length}catch(t){return f}if(!Number.isInteger(p)||0>p||p>4294967295)return f;const g=[];for(let t=0;50>s&&1e3>n&&p>t;t++){let e;n++;try{e=h.next(v[t])}catch(t){s++,e=this.coerceFallback(u(i+1))}e&&g.push(e)}return cs(cs({},f),{},{errors:g})},u=(e,s=0)=>cs(cs({},i),{},{syntheticException:0==e?i.syntheticException:void 0,mechanism:0==e?t:{},apply(t){const i=h(t,e,s+1);if(!i)throw a;return i},next:t=>h(t,e+1)}),d=u(e);return cs(cs({},d),{},{apply:t=>{var i;return null!==(i=h(t,e))&&void 0!==i?i:this.coerceFallback(d)}})}};const fs=/^([a-z][a-z0-9.+-]+):/i,ps=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function gs(t){if(!t||"<anonymous>"===t)return!1;const i=fs.exec(t);return!i||ps.includes(i[1].toLowerCase())}function _s(t,i,e,s,n){const r={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:gs(i)};return mi(s)||(r.lineno=s),mi(n)||(r.colno=n),r}const ms=(t,i)=>{const e=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return e||s?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?`safari-extension:${i}`:`safari-web-extension:${i}`]:[t,i]},bs=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ys=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ws=/\((\S*)(?::(\d+))(?::(\d+))\)/,$s=(t,i)=>{const e=bs.exec(t);if(e){const[,t,s,n]=e;return _s(i,t,"?",+s,+n)}const s=ys.exec(t);if(s){if(s[2]&&0===s[2].indexOf("eval")){const t=ws.exec(s[2]);t&&(s[2]=t[1],s[3]=t[2],s[4]=t[3])}const[t,e]=ms(s[1]||"?",s[2]);return _s(i,e,t,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},xs=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ss=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ks=(t,i)=>{const e=xs.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=Ss.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],s=e[1]||"?";return[s,t]=ms(s,t),_s(i,t,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Es=/\(error: (.*)\)/;function Ps(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function Ts(t){for(let i=1;10>=i;i++){const e=t.length-2*i;if(0>e)break;let s=!0;for(let n=0;i>n;n++)if(!Ps(t[e+n],t[e+i+n])){s=!1;break}if(s){for(let s=0;i>s;s++)t[e+s]=t[e+i+s];return t.length=e+i,{start:e,length:i}}}}function Cs(t,i){const e=i.start+i.length,s=Ms(t,i);s&&t.splice(e+s===t.length?e:i.start,s)}function Fs(t,i){let e=i.start;for(;e>0&&Ps(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function Ms(t,i){const e=i.start+i.length;let s=e;for(;t.length>s&&Ps(t[s],t[s-i.length]);)s++;return s-e}function Is(t,i){const e=i[0];let s=t.length-(e?Fs(t,e):0);for(const e of i)s-=Ms(t,e);return s}function Os(t,i,e){for(let s=0;t.length>s;s++){const n=t[(i+s)%t.length],r=t[(e+s)%t.length];if(n!==r)return r>n}return!1}var As=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){const e=bi(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){const i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${i}: ${t.message}`:i}isDOMException(t){return Ci(t,"DOMException")}isDOMError(t){return Ci(t,"DOMError")}},Rs=class{match(t){return Fi(t)}coerce(t,i){var e;const s=this.getStack(t),n=void 0===s?null===(e=i.syntheticException)||void 0===e?void 0:e.stack:void 0,r=!!n;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=s?s:n,cause:t.cause?i.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,i){const e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){try{const i=t.stacktrace;if("string"==typeof i&&i.length>0)return i;const e=t.stack;return"string"==typeof e&&e.length>0?e:void 0}catch(t){return}}},Ds=class{match(t){return!!Ci(t,"ErrorEvent")&&(null!=t.error||this.ar(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);const s=i.apply(t.message);return cs(cs({},s),{},{stack:null!==(e=this.lr(t))&&void 0!==e?e:s.stack,synthetic:!0})}ar(t){return bi(t.message)&&t.message.length>0}lr(t){var i,e;const s=t,n=null!==(i=s.lineno)&&void 0!==i?i:0,r=null!==(e=s.colno)&&void 0!==e?e:0;if(bi(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const js=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Bs=class{match(t){return"string"==typeof t}coerce(t,i){var e;const[s,n]=this.getInfos(t);return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}getInfos(t){let i="Error",e=t;const s=t.match(js);return s&&(i=s[1],e=s[2]),[i,e]}};const Ns=["fatal","error","warning","log","info","debug"];function Ls(t,i=40){const e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(let t=e.length;t>0;t--){const s=e.slice(0,t).join(", ");if(i>=s.length)return t===e.length?s:s.length>i?`${s.slice(0,i)}...`:s}return""}var zs=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,s;const n=this.getErrorPropertyFromObject(t);return n?i.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null===(s=i.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(Mi(t))return t.constructor.name;const i="name"in t?t.name:void 0;return bi(i)&&!yi(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){let i=`'${t.name}' captured as exception`;return"message"in t&&"string"==typeof t.message&&(i+=` with message: '${t.message}'`),i}if("message"in t&&"string"==typeof t.message)return t.message;const i=this.getObjectClassName(t);return`${i&&"Object"!==i?`'${i}'`:"Object"} captured as exception with keys: ${Ls(t)}`}isSeverityLevel(t){return bi(t)&&!yi(t)&&Ns.indexOf(t)>=0}getStack(t){try{return bi(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:bi(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(const i in t)if({}.hasOwnProperty.call(t,i)){const e=t[i];if(Fi(e))return e}}getObjectClassName(t){try{const i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},Hs=class{match(t){return Mi(t)}coerce(t,i){var e;const s=t.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Ls(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},Us=class{match(t){return Ti(t)}coerce(t,i){var e;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},qs=class{match(t){return Ci(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!Mi(t))return!1;try{const i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e;const s=this.getUnhandledRejectionReason(t);return Ti(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}:i.apply(s)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}};const Vs="$message",Ws="$timestamp",Gs=new Set([Vs,Ws]),Ks={enabled:!0,max_bytes:32768};function Js(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Ks.enabled,max_bytes:Xs(t.max_bytes,Ks.max_bytes)}:cs({},Ks)}var Ys=class{constructor(t){this.ns=[],this.ss=0,this.Ir=Js(t)}setConfig(t){this.Ir=Js(t),this.rs()}add(t){const i=function(t){let i;try{i=ui(t)}catch(t){return}try{const t=JSON.parse(i);if(!gi(t))return;const e=t,s=e[Vs],n=e[Ws];if(!bi(s)||0===s.trim().length)return;if(!bi(n)&&!xi(n))return;return{step:e,json:i}}catch(t){return}}(t);if(!i)return;const e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;const i=encodeURIComponent(t);let e=0;for(let t=0;i.length>t;t++)"%"===i[t]?(e+=1,t+=2):e+=1;return e}(i.json);e>this.Ir.max_bytes||(this.ns.push({step:i.step,bytes:e}),this.ss+=e,this.rs())}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Ir.max_bytes&&this.ns.length>0;){const t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function Xs(t,i){if(!xi(t)||1/0===t||-1/0===t)return i;const e=Math.floor(t);return 0>e?i:e}const Zs=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Qs(t){return"string"==typeof t||t}function tn(t){return"string"==typeof t?t:void 0}const en=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],sn="NativeGzipValidationError",nn=t=>t.length>=2&&31===t[0]&&139===t[1],rn=(t,i)=>t===ni.GZipJS||i===ni.GZipJS||"gzip"===i,on=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):"");let ln;const an=t=>{throw Qe(sn,`Native gzip produced invalid output: ${t}`)},hn=(un=ji(function*(t,i){18>t.size&&an("too-short");const e=new Uint8Array(yield t.slice(0,10).arrayBuffer());nn(e)&&8===e[2]||an("invalid-header");const s=new DataView(yield t.slice(t.size-8).arrayBuffer());s.getUint32(0,!0)!==(t=>{const i=(()=>{if(ln)return ln;ln=[];for(let t=0;256>t;t++){let i=t;for(let t=0;8>t;t++)i=1&i?3988292384^i>>>1:i>>>1;ln[t]=i>>>0}return ln})();let e=4294967295;for(let s=0;t.length>s;s++)e=i[255&(e^t[s])]^e>>>8;return(4294967295^e)>>>0})(i)&&an("invalid-crc");const n=i.length>>>0;s.getUint32(4,!0)!==n&&an("invalid-size")}),function(t,i){return un.apply(this,arguments)});var un;function dn(){return dn=ji(function*(t,i=!0,e){try{const i=(new TextEncoder).encode(t),e=new globalThis.CompressionStream("gzip"),n=e.writable.getWriter(),r=n.write(i).then(()=>n.close()).catch((s=ji(function*(t){try{yield n.abort(t)}catch(t){}throw t}),function(t){return s.apply(this,arguments)})),o=new Response(e.readable).blob(),[l]=yield Promise.all([o,r]);return yield hn(l,i),l}catch(t){if(null==e?void 0:e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}var s}),dn.apply(this,arguments)}function cn(t,i){if(null==t)return{};var e,s,n=function(t,i){if(null==t)return{};var e={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(i.includes(s))continue;e[s]=t[s]}return e}(t,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(s=0;r.length>s;s++)i.includes(e=r[s])||{}.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}const vn={}.propertyIsEnumerable;function fn(t,i){try{return _n(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function pn(t,i,e,s){if(0>=e.remainingNodes)return{stringValue:Ve};if(e.remainingNodes--,ki(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){const e=t.toString(),s=BigInt("9223372036854775808");return t>=s||-s>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const e=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:Ge(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:Ve};if(t instanceof Date){const i=t.getTime(),e=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:"string"==typeof e?Ge(e):String(e)}}e.ancestors.add(t);try{try{const n=t.toJSON;if("function"==typeof n)return pn(n.call(t),i,e,s+1)}catch(t){}return fi(t)?{arrayValue:{values:gn(t,i,e,s+1)}}:{kvlistValue:{values:_n(t,i,e,s+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:Ge(String(t))}}function gn(t,i,e,s){const n=[],r=Math.min(t.length,1e3);let o=0;for(;r>o&&e.remainingNodes>0;o++)try{const r=o in t?t[o]:void 0;if($i(r))continue;n.push(pn(r,i,e,s))}catch(t){n.push({stringValue:We})}return t.length>o&&n.push({stringValue:Ve}),n}function _n(t,i,e,s){const n=[];for(const r in t)if(vn.call(t,r)){if(!r){null==i||i.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=t[r];if(wi(o)||mi(o))continue;n.push({key:Ge(r),value:pn(o,i,e,s)})}catch(t){n.push({key:Ge(r),value:{stringValue:We}})}}return n}function mn(t,i,e){return cs(cs(cs(cs({},Ke({},t.resourceAttributes)),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}const bn=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function yn(t,i){const e=Ke({},t),s={};for(const t of bn)({}).hasOwnProperty.call(e,t)&&(s[t]=e[t],delete e[t]);return[...fn(e,i),...fn(s,i)]}const wn={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const $n={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},xn=$n.info;function Sn(t){try{return Ge(String(t))}catch(t){return We}}function kn(t,i,e,s){const n=t.level||"info",{text:r,number:o}=$n[n]||xn,l=function(t=Date.now()){return String(t)+"000000"}(xi(s)?s:void 0),a={};i.distinctId&&(a.posthogDistinctId=i.distinctId),i.sessionId&&(a.sessionId=i.sessionId),i.windowId&&(a["window.id"]=i.windowId),$i(i.sessionStartTimestamp)||(a.sessionStartTimestamp=String(i.sessionStartTimestamp)),$i(i.lastActivityTimestamp)||(a.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(a["url.full"]=i.currentUrl),i.screenName&&(a["screen.name"]=i.screenName),i.appState&&(a["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(a.feature_flags=i.activeFeatureFlags);const h=cs({},a),u=t.attributes;if(u){let t=[];try{t=Object.keys(u)}catch(i){t=[]}for(const i of t){let t;try{t=u[i]}catch(i){t=We}Object.defineProperty(h,i,{value:t,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:o,severityText:r,body:{stringValue:Sn(t.body)},attributes:fn(h,e)};return t.trace_id&&(d.traceId=t.trace_id),t.span_id&&(d.spanId=t.span_id),mi(t.trace_flags)||(d.flags=t.trace_flags),d}function En(t,i,e){return mn(t,i,e)}function Pn(t,i,e,s){return{resourceLogs:[{resource:{attributes:yn(i)},scopeLogs:[{scope:{name:e,version:s},logRecords:t}]}]}}var Tn=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.hs}arm(t){this.clear(),this.us=Date.now()+t,this.hs=es(()=>{this.hs=void 0,this.ls()},t)}armNoEarlierThan(t){this.hs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function Cn(){return.75+.5*Math.random()}function Fn(t,i,e,s){const n=Math.min(Math.max(0,i-1),6),r=t*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,t)))*e)}var Mn=class{constructor(t,i,e,s,n,r=()=>Promise.resolve(),o){var l;this._instance=t,this.Ir=i,this.A=e,this.cs=s,this.ds=n,this.vs=r,this.fs=o,this.ps=new Tn(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Ye,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=i.maxBufferSize,this.Is=Math.max(null!==(l=i.maxQueueSize)&&void 0!==l?l:i.maxBufferSize,i.maxBufferSize),this.Ms=i.flushIntervalMs,this.Es=i.maxBatchRecordsPerPost,this.Ps=i.rateCapWindowMs,this.Rs=i.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(si.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Ir.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,i){var e;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==t?void 0:t.body))return;const s=this.Os(t);if(null===s)return;if(!s.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const n={record:kn(s,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.cs(),this.A,null==i?void 0:i.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(t){const i=this.Ir.beforeSend;if(!i)return t;const e=fi(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.A.info("Log was rejected in beforeSend function"),null;s=i}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return s}Ds(){if(void 0===this.Rs)return!0;const t=Date.now(),i=t-this.xs;return this.Ps>i&&i>=0||(this.xs=t,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.$s=!0),!1)}flush(){var t=this;return ji(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return ji(function*(){var i;t.ps.clear();let e=null!==(i=t._instance.getPersistedProperty(si.LogsQueue))&&void 0!==i?i:[];if(0===e.length)return;const s=e.length;let n=0;for(;e.length>0&&s>n;){var r,o;const i=t._s;t.bs=0;const s=Math.min(e.length,t.Es),l=e.slice(0,s),a=Pn(l.map(t=>t.record),t.qs(),null!==(r=t.fs)&&void 0!==r?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.js(a);if(t._s!==i)return;if("too-large"===h.kind&&l.length>1)t.Es=Math.max(1,Math.floor(l.length/2)),t.A.warn(`Logs batch of size ${l.length} was too large for the ingestion endpoint, reducing batch size to ${t.Es}`);else{if(t.ws.record(h),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),"retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===h.kind&&t.Ir.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Ir.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(l.length),e=null!==(o=t._instance.getPersistedProperty(si.LogsQueue))&&void 0!==o?o:[],n+=l.length,"fatal"===h.kind)throw h.error}}})()}Bs(t){var i=this;return ji(function*(){var e;const s=Math.max(0,t-i.bs),n=null!==(e=i._instance.getPersistedProperty(si.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(si.LogsQueue,n.slice(s)),yield i.vs()})()}qs(){return En(this.Ir,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var i;if(this._instance.optedOut)return;const e=null!==(i=this._instance.getPersistedProperty(si.LogsQueue))&&void 0!==i?i:[];this.Is>e.length||(e.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(si.LogsQueue,e),this.Ts>e.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(Fn(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const t=this._instance.getPersistedProperty(si.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return ji(function*(){i.ps.clear();const e=i.flush().catch(()=>{});void 0!==t?yield ss(e,t):yield e})()}flushWithTimeout(t){var i=this;return ji(function*(){const e=i.flush();yield ss(e,t,()=>{e.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=Cn(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const In=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function On(t){return String(t)+"000000"}function An(t,i,e,s){let n="";return s&&(n=Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${JSON.stringify(s[t])}`).join(",")),`${t}\0${i}\0${null!=e?e:""}\0${n}`}var Rn=class{constructor(t,i,e){this._instance=t,this.Ir=i,this.A=e,this.zs=new Map,this.ps=new Tn(()=>this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Ye,this.ks=0,this.Ss=1,this.Gs=0}count(t,i=1,e){this.Zs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Zs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Zs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this;const i=this.ys,e=function(){var e=ji(function*(){i&&(yield i.catch(()=>{})),yield t.Qs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.ys===e&&(this.ys=null)});return this.ys=e,e}drainWindow(){if(0===this.zs.size)return null;const t=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(t){if(this._instance.isDisabled||this._instance.optedOut)return;const i=this.Os(t);if(null===i)return;if(!i.name||"string"!=typeof i.name)return void this.A.warn("Dropping metric with empty name");if("number"!=typeof i.value||!Number.isFinite(i.value))return void this.A.warn(`Dropping metric '${i.name}': value must be a finite number`);if("count"===i.type&&0>i.value)return void this.A.warn(`Dropping count '${i.name}': counters are monotonic, value must be >= 0`);let e,s;try{e=i.attributes?cs({},i.attributes):void 0,s=An(i.type,i.name,i.unit,e)}catch(t){return void this.A.warn(`Dropping metric '${i.name}': attributes could not be serialized`,t)}let n=this.zs.get(s);if(!n){if(!this.Ks())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.zs.set(s,n)}const r=this.Ws.get(i.name);void 0===r?this.Ws.set(i.name,i.type):r===i.type||this.Vs.has(i.name)||(this.Vs.add(i.name),this.A.warn(`Metric name '${i.name}' is already used as a ${r}; recording it as a ${i.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,i.value),this.Fs()}Ks(){return this.Ir.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Ir.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(t,i){switch(t.type){case"count":var e;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(In.length+1).fill(0)});const e=t.hist;e.count+=1,e.sum+=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.bucketCounts[function(t,i){for(let e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,In)]+=1;break}}}Os(t){const i=this.Ir.beforeSend;if(!i)return t;const e=fi(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.A.info("Metric was rejected in beforeSend function"),null;s=i}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return s}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(Fn(this.Ir.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var t=this;return ji(function*(){if(t.ps.clear(),0===t.zs.size)return;const i=t.zs;t.zs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;const e=t.Gs,s=yield t._instance.Ys(t.Js(i));if(e===t.Gs)switch(t.ws.record(s),"retry-later"===s.kind?(t.ks++,t.Ss=Cn()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.Hs()),s.kind){case"ok":return;case"retry-later":return t.ho(i),void t.ps.armNoEarlierThan(t.Hs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",s.error)}})()}Js(t){return i=this.co(t),e=function(t,i,e){return mn(t,i,e)}(this.Ir,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:yn(e)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,e,s,n}co(t){const i=On(Date.now()),e=new Map;for(const o of t.values()){var s;const t=An(o.type,o.name,o.unit,void 0);let l=e.get(t);l||(l=cs({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},e.set(t,l));const a=fn(null!==(s=o.attributes)&&void 0!==s?s:{},this.A),h=On(o.windowStartMs);if("count"===o.type){var n;const t={attributes:a,startTimeUnixNano:h,timeUnixNano:i,asDouble:null!==(n=o.total)&&void 0!==n?n:0};l.sum.dataPoints.push(t)}else if("gauge"===o.type){var r;const t={attributes:a,timeUnixNano:i,asDouble:null!==(r=o.last)&&void 0!==r?r:0};l.gauge.dataPoints.push(t)}else o.hist&&l.histogram.dataPoints.push({attributes:a,startTimeUnixNano:h,timeUnixNano:i,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:In})}return Array.from(e.values())}ho(t){for(const[s,n]of t){const t=this.zs.get(s);if(t)switch(t.windowStartMs=Math.min(t.windowStartMs,n.windowStartMs),t.type){case"count":var i,e;t.total=(null!==(i=t.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(t.hist){t.hist.count+=n.hist.count,t.hist.sum+=n.hist.sum,t.hist.min=Math.min(t.hist.min,n.hist.min),t.hist.max=Math.max(t.hist.max,n.hist.max);for(let i=0;t.hist.bucketCounts.length>i;i++)t.hist.bucketCounts[i]+=n.hist.bucketCounts[i]}else t.hist=n.hist}else this.Ks()&&this.zs.set(s,n)}}};const Dn=(t,{debugEnabled:e}={})=>{const s={N(s,...n){qt&&(i.DEBUG||qt.POSTHOG_DEBUG||e)&&!mi(qt.console)&&qt.console&&("__rrweb_original__"in qt.console[s]?qt.console[s].__rrweb_original__:qt.console[s])(t,...n)},debug(...t){s.N("debug",...t)},info(...t){s.N("log",...t)},warn(...t){s.N("warn",...t)},error(...t){s.N("error",...t)},critical(...i){console.error(t,...i)},uninitializedWarning(t){s.error(`You must initialize PostHog before calling ${t}`)},createLogger:(i,e)=>Dn(`${t} ${i}`,e)};return s},jn=Dn("[PostHog.js]"),Bn=jn.createLogger;function Nn(t,i){fi(t)&&t.forEach(i)}function Ln(t,i){if(!$i(t))if(fi(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(const e in t)ci.call(t,e)&&i(t[e],e)}const zn=function(t,...i){for(const e of i)for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t};function Hn(t){const i=Object.keys(t);let e=i.length;const s=new Array(e);for(;e--;)s[e]=[i[e],t[i[e]]];return s}const Un=function(t){return function(...i){try{return t.apply(this,i)}catch(t){jn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),jn.critical(t)}}},qn=function(t){const i={};return Ln(t,function(t,e){(bi(t)&&t.length>0||xi(t))&&(i[e]=t)}),i};function Vn(t){const i=cs({},t);for(const e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}const Wn=["herokuapp.com","vercel.app","netlify.app"];function Gn(t){const i=null==t?void 0:t.hostname;if(!bi(i))return!1;const e=i.split(".").slice(-2).join(".");for(const t of Wn)if(e===t)return!1;return!0}function Kn(t,i,e,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==t||t.addEventListener(i,e,{capture:n,passive:r})}function Jn(t){return"ph_toolbar_internal"===t.name}const Yn=t=>{if(Gt){try{const i=t+"=",e=Gt.cookie.split(";").filter(t=>t.length);for(let t=0;e.length>t;t++){let s=e[t];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return xi(t)&&isFinite(t)&&Math.floor(t)===t});var Xn=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,s,n){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(n)||0>i||0>e||0>s||0>n||i>0xffffffffffff||e>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=i/Math.pow(2,40),r[1]=i/Math.pow(2,32),r[2]=i/Math.pow(2,24),r[3]=i/Math.pow(2,16),r[4]=i/256,r[5]=i,r[6]=112|e>>>8,r[7]=e,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new t(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(let i=0;16>i;i++){const e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Zn=class{generate(){const t=this.generateOrAbort();if(!mi(t))return t;{this.Ct=0;const t=this.generateOrAbort();if(mi(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const t=(()=>{const t=Date.now();return xi(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.Mt();else{if(this.Ct>=t+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return Xn.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(2,30)-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new tr}};let Qn=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};qt&&!mi(qt.crypto)&&crypto.getRandomValues&&(Qn=t=>crypto.getRandomValues(t));var tr=class{nextUint32(){return this.Rt.length>this.At||(Qn(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}};let ir;const er=()=>sr().toString(),sr=()=>(ir||(ir=new Zn)).generate();let nr="";const rr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let or=null;const lr={Et(){if(!wi(or))return or;if(or=!1,Gt)try{const t=`__ph_cookie_support_${er()}`;lr.$t(t,"xyz"),or='"xyz"'===Yn(t),lr.Lt(t)}catch(t){or=!1}return or},Pt(t){jn.error("cookieStore error: "+t)},Ot:Yn,Dt(t){let i;try{i=JSON.parse(lr.Ot(t))||{}}catch(t){}return i},$t(t,i,e,s,n){if(!Gt)return!1;try{let r="",o="";const l=function(t,i){if(i){let i=function(t,i=Gt){if(nr)return nr;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";const e=t.split(".");let s=Math.min(e.length,8);const n="dmn_chk_"+er();for(;!nr&&s--;){const t=e.slice(s).join("."),r=n+"=1;domain=."+t+";path=/";i.cookie=r+";max-age=3",i.cookie.includes(n)&&(i.cookie=r+";max-age=0",nr=t)}return nr}(t);if(!i){const e=(t=>{const i=t.match(rr);return i?i[0]:""})(t);e!==i&&jn.info("Warning: cookie subdomain discovery mismatch",e,i),i=e}return i?"; domain=."+i:""}return""}(Gt.location.hostname,s);if(e){const t=new Date;t.setTime(t.getTime()+864e5*e),r="; expires="+t.toUTCString()}n&&(o="; secure");const a=t+"="+encodeURIComponent(JSON.stringify(i))+r+"; SameSite=Lax; path=/"+l+o;return a.length>3686.4&&jn.warn("cookieStore warning: large cookie, len="+a.length),Gt.cookie=a,!0}catch(t){return!1}},Lt(t,i){if((null==Gt?void 0:Gt.cookie)&&(!i||!wi(Yn(t))))try{lr.$t(t,"",-1,i)}catch(t){return}}};let ar=null;const hr={Et(){if(!wi(ar))return ar;let t=!0;if(mi(qt))t=!1;else try{const i="__mplssupport__";hr.$t(i,"xyz"),'"xyz"'!==hr.Ot(i)&&(t=!1),hr.Lt(i)}catch(i){t=!1}return t||jn.error("localStorage unsupported; falling back to cookie store"),ar=t,t},Pt(t){jn.error("localStorage error: "+t)},Ot(t){try{return null==qt?void 0:qt.localStorage.getItem(t)}catch(t){hr.Pt(t)}return null},Dt(t){try{return JSON.parse(hr.Ot(t))||{}}catch(t){}return null},$t(t,i){try{return null==qt||qt.localStorage.setItem(t,JSON.stringify(i)),!0}catch(t){hr.Pt(t)}return!1},Lt(t){try{null==qt||qt.localStorage.removeItem(t)}catch(t){hr.Pt(t)}}},ur=[K,L,N,H,U,q,ct,dt,ht],dr=[r,n,I,O,bt,mt,u,vt],cr=t=>t+"_cpm",vr=["__proto__","constructor","prototype"],fr=t=>{if(!gi(t))return{};const i={};return Object.keys(t).forEach(e=>{-1===vr.indexOf(e)&&(i[e]=t[e])}),i},pr=(t,i=[])=>{const e={};return[...dr,...i].forEach(i=>{const s=t[i];mi(s)||wi(s)||""===s||(e[i]=s)}),e},gr=t=>{let i=5381,e=2166136261;for(let s=0;t.length>s;s++){const n=t.charCodeAt(s);i=33*i^n,e=Math.imul(e^n,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},_r=(t,i)=>({p:i,f:gr(JSON.stringify(t))}),mr=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{const e=lr.Dt(cr(t)),s=(null==e?void 0:e.f)===gr(i)&&fi(e.p);return{properties:s?e.p:[],isValid:s}}catch(t){return{properties:[],isValid:!1}}},br=(t,i)=>i+"|"+(lr.Ot(cr(t))||""),yr={},wr={Et:()=>!0,Pt(t){jn.error("memoryStorage error: "+t)},Ot:t=>t in yr?yr[t]:null,Dt:t=>t in yr?yr[t]:null,$t:(t,i)=>(yr[t]=i,!0),Lt(t){delete yr[t]}};let $r=null;const xr={Et(){if(!wi($r))return $r;if($r=!0,mi(qt))$r=!1;else try{const t="__support__";xr.$t(t,"xyz"),'"xyz"'!==xr.Ot(t)&&($r=!1),xr.Lt(t)}catch(t){$r=!1}return $r},Pt(t){jn.error("sessionStorage error: ",t)},Ot(t){try{return null==qt?void 0:qt.sessionStorage.getItem(t)}catch(t){xr.Pt(t)}return null},Dt(t){try{return JSON.parse(xr.Ot(t))||null}catch(t){}return null},$t(t,i){try{return null==qt||qt.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(t){xr.Pt(t)}return!1},Lt(t){try{null==qt||qt.sessionStorage.removeItem(t)}catch(t){xr.Pt(t)}}};var Sr=class{constructor(t){this._instance=t}get Ir(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return"always"===this.Ir.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Ir.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Ir.opt_out_capturing_by_default}optInOut(t){this.No.$t(this.qo,t?1:0,this.Ir.cookie_expiration,this.Ir.cross_subdomain_cookie,this.Ir.secure_cookie)}reset(){this.No.Lt(this.qo,this.Ir.cross_subdomain_cookie)}get qo(){const{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get Lo(){const t=this.No.Ot(this.qo);return Ai(t)?1:li(Ri,t)?0:-1}get No(){const t=this.Ir.opt_out_capturing_persistence_type,i="localStorage"===t?hr:lr,e=i.Et()?i:wr;if(!this.jo||this.jo!==e){this.jo=e;const i="localStorage"===t?lr:hr;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(Ai(i.Ot(this.qo))),i.Lt(this.qo,this.Ir.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Ir.respect_dnt&&[null==Wt?void 0:Wt.doNotTrack,null==Wt?void 0:Wt.msDoNotTrack,ei.doNotTrack,null==Wt?void 0:Wt.globalPrivacyControl].some(t=>Ai(t))}};function kr(t,i){var e;const s=null==t||null===(e=t.config)||void 0===e?void 0:e.get_current_url;if(!pi(s))return i;try{const t=s(i);return bi(t)&&t?t:i}catch(t){return jn.error("Error in get_current_url, falling back to window.location.href",t),i}}function Er(t){var i;return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!!(null===(i=t.closest)||void 0===i?void 0:i.call(t,".toolbar-global-fade-container")))}function Pr(t){return!!t&&1===t.nodeType}function Tr(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Cr(t){return!!t&&3===t.nodeType}function Fr(t){return!!t&&11===t.nodeType&&Pr(t.host)}function Mr(t){return t?ai(t).split(/\s+/):[]}function Ir(t,i){const e=function(t){var i;const e=null==qt||null===(i=qt.location)||void 0===i?void 0:i.href;return mi(e)?void 0:kr(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Or(t){let i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return Mr(i)}function Ar(t){return $i(t)?null:ai(t).split(/(\s+)/).filter(t=>ro(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Rr(t){let i="";return Yr(t)&&!Xr(t)&&t.childNodes&&t.childNodes.length&&Ln(t.childNodes,function(t){var e;Cr(t)&&t.textContent&&(i+=null!==(e=Ar(t.textContent))&&void 0!==e?e:"")}),ai(i)}function Dr(t){var i;return mi(t.target)?t.srcElement||null:(null===(i=t.target)||void 0===i?void 0:i.shadowRoot)?t.composedPath()[0]||null:t.target||null}const jr=["a","button","form","input","select","textarea","label"];function Br(t,i){const e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function Nr(t,i){if(mi(i))return!0;for(const e of t)if(i.some(t=>Br(e,t)))return!0;return!1}function Lr(t){const i=t.parentNode;return!(!i||!Pr(i))&&i}const zr=[".ph-no-autocapture","[data-ph-no-autocapture]"],Hr=["next","previous","prev",">","<"],Ur=[...Hr,"+","-","−","–"],qr=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Vr=[".ph-no-rageclick",".ph-no-capture"],Wr=["","text","search","email","password","url","tel","number"];function Gr(t,i){if(!qt||Kr(t))return!1;let e,s,n;var r,o;if(ki(i)?(e=!!i&&Vr,s=void 0,n=!1):(e=null!==(r=null==i?void 0:i.css_selector_ignorelist)&&void 0!==r?r:Vr,s=null==i?void 0:i.content_ignorelist,n=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(n&&function(t){return!(!t||!Pr(t))&&(!!Tr(t,"textarea")||(Tr(t,"input")?li(Wr,(t.getAttribute("type")||"").toLowerCase()):function(t){var i;if(t.isContentEditable)return!0;const e=null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"contenteditable");return"true"===e||""===e}(t)))}(t))return!1;const{targetElementList:l}=Jr(t,!1);return!function(t,i){if(!1===t||mi(t))return!1;let e;if(!0===t)e=Hr;else{if(!fi(t))return!1;if(t.length>10)return jn.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(({safeText:t,ariaLabel:i})=>e.some(e=>qr(t,e)||qr(i,e)))}(s,l.map(t=>{var i;return{safeText:Rr(t).toLowerCase(),ariaLabel:(null===(i=t.getAttribute("aria-label"))||void 0===i?void 0:i.toLowerCase().trim())||""}}))&&!Nr(l,e)}const Kr=t=>!t||Tr(t,"html")||!Pr(t),Jr=(t,i)=>{if(!qt||Kr(t))return{parentIsUsefulElement:!1,targetElementList:[]};let e=!1;const s=[t];let n=t;for(;n.parentNode&&!Tr(n,"body");){if(Fr(n.parentNode)){s.push(n.parentNode.host),n=n.parentNode.host;continue}const t=Lr(n);if(!t)break;if(i||jr.indexOf(t.tagName.toLowerCase())>-1)e=!0;else try{const i=qt.getComputedStyle(t);i&&"pointer"===i.getPropertyValue("cursor")&&(e=!0)}catch(t){}s.push(t),n=t}return{parentIsUsefulElement:e,targetElementList:s}};function Yr(t){const i=new Set;let e=0;for(let s=t;s.parentNode&&!Tr(s,"body");s=s.parentNode){if(e++>=1e3||i.has(s))return!1;i.add(s);const t=Or(s);if(li(t,"ph-sensitive")||li(t,"ph-no-capture"))return!1}if(li(Or(t),"ph-include"))return!0;const s=t.type||"";if(bi(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=t.name||t.id||"";return!bi(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Xr(t){return!!(Tr(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Tr(t,"select")||Tr(t,"textarea")||"true"===t.getAttribute("contenteditable"))}const Zr=new RegExp("^(?:(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}))$"),Qr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,to=[16,15,14,13],io=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),eo=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),so=/[0-9A-Za-z_]/;function no(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function ro(t,i=!0){if($i(t))return!1;if(bi(t)){if(t=ai(t),i?Zr.test((t||"").replace(/[- ]/g,"")):function(t){let i;for(Qr.lastIndex=0;i=Qr.exec(t);){const t=i[2];if(!t)continue;const e=t.replace(/[- ]/g,"");for(let t=0;e.length>t;t++)for(const i of to){const s=t+i;if(e.length>=s){const i=e.slice(t,s);if(Zr.test(i)&&no(i))return!0}}}return!1}(t))return!1;if(i?io.test(t):function(t){let i;for(eo.lastIndex=0;i=eo.exec(t);){const t=i[1],e=i[3];if(!(t&&e&&so.test(t)&&so.test(e)))return!0}return!1}(t))return!1}return!0}function oo(t){let i=Rr(t);return i=`${i} ${lo(t)}`.trim(),ro(i)?i:""}function lo(t){let i="";return t&&t.childNodes&&t.childNodes.length&&Ln(t.childNodes,function(t){var e;if(t&&"span"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()))try{const e=Rr(t);i=`${i} ${e}`.trim(),t.childNodes&&t.childNodes.length&&(i=`${i} ${lo(t)}`.trim())}catch(t){jn.error("[AutoCapture]",t)}}),i}function ao(t){return t.replace(/"|\\"/g,'\\"')}function ho(t){const i=t.attr__class;if(i)return fi(i)?i:Mr(i)}const uo=Bn("[Dead Clicks]"),co=()=>!0,vo=t=>{var i;const e=!!(null===(i=t.instance.persistence)||void 0===i?void 0:i.get_property(y)),s=t.instance.config.capture_dead_clicks;return ki(s)?s:!!gi(s)||e};var fo=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[y]:i.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ho(()=>{this.zo()}):this.stop()}Ho(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.initDeadClicksAutocapture)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this.instance,"dead-clicks-autocapture",i=>{i?uo.error("failed to load script",i):t()})}zo(){var t;if(Gt){if(!this.Bo&&(null===(t=ei.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)){const t=gi(this.instance.config.capture_dead_clicks)?cs({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Bo=ei.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Bo.start(Gt),uo.info("starting...")}}else uo.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,uo.info("stopping..."))}};const po=Bn("[SegmentIntegration]");function go(t,i,e=!0){const s=t.config.segment;if(!s)return i();const{analytics:n,filterProperties:r}=(t=>pi(t.register))(o=s)?{analytics:o}:o;var o;!function(t,i,e,s){const n=i=>{const n=()=>i.anonymousId()||er();t.config.get_device_id=n,s&&i.id()&&(t.register({distinct_id:i.id(),$device_id:n()}),t.persistence.set_property(vt,Dt)),e(s?void 0:i.anonymousId()||void 0)},r=i.user();"then"in r&&pi(r.then)?r.then(n):n(r)}(t,n,e=>{n.register(((t,i,{filterProperties:e}={})=>{"undefined"!=typeof Promise&&Promise.resolve||po.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!i&&s.event.anonymousId===i&&!s.event.userId;r||s.event.userId||s.event.anonymousId===t.get_distinct_id()||(po.info("No userId set, resetting PostHog"),t.reset()),r||(i=void 0),s.event.userId&&s.event.userId!==t.get_distinct_id()&&(po.info("UserId set, identifying with PostHog"),t.identify(s.event.userId));let o=t.calculateEventProperties(n,s.event.properties);if(!$i(e)){const t=s.event.properties||{},i={};for(const e of Object.keys(o))ci.call(t,e)||(i[e]=o[e]);const n=((t,i)=>{const e=fi(t)?t:[t];let s=cs({},i);for(const t of e)try{if(s=t(s),$i(s))return null}catch(t){return po.error("Error in Segment filterProperties:",t),null}return s})(e,i);if($i(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return s(t,t.event.event)},page(t){return s(t,Lt)},identify(t){return s(t,Ht)},screen(t){return s(t,"$screen")}}})(t,e,{filterProperties:r})).then(()=>{i()},t=>{po.error("Failed to register the Segment integration",t),i()})},e)}const _o="posthog-js";function mo(t,{organization:i,projectId:e,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var l,a,h,u,d;if("*"!==n&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});const c=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=c,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const v=(null===(l=o.exception)||void 0===l?void 0:l.values)||[],f=v.map(t=>cs(cs({},t),{},{stacktrace:t.stacktrace?cs(cs({},t.stacktrace),{},{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>cs(cs({},t),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:(null===(a=v[0])||void 0===a?void 0:a.value)||o.message,$exception_type:null===(h=v[0])||void 0===h?void 0:h.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=v[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=v[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var g;return i&&e&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+e+"&query="+o.event_id),r&&(null===(g=t.exceptions)||void 0===g||g.sendExceptionEvent(p)),o}}var bo=class{constructor(t,i,e,s,n,r){this.name=_o,this.setupOnce=function(o){o(mo(t,{organization:i,projectId:e,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},yo=class{constructor(t){this.Uo=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(jn.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Vo()}Vo(){var t;this.Go=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.onSessionId(this.Uo)}destroy(){var t;null===(t=this.Go)||void 0===t||t.call(this),this.Go=void 0}doPageView(t,i){var e;const s=this.Zo(t,i);return this.Wo={pathname:null!==(e=null==qt?void 0:qt.location.pathname)&&void 0!==e?e:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var i;return this.Zo(t,null===(i=this.Wo)||void 0===i?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null===(t=this.Wo)||void 0===t?void 0:t.pageViewId}}Zo(t,i){const e=this.Wo;if(!e)return{$pageview_id:i};let s={$pageview_id:i,$prev_pageview_id:e.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:t,lastScrollY:i,maxScrollY:e,maxContentHeight:r,lastContentY:o,maxContentY:l}=n;if(!(mi(t)||mi(i)||mi(e)||mi(r)||mi(o)||mi(l))){t=Math.ceil(t),i=Math.ceil(i),e=Math.ceil(e),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l);const n=t>1?Li(i/t,0,1,jn):1,a=t>1?Li(e/t,0,1,jn):1,h=r>1?Li(o/r,0,1,jn):1,u=r>1?Li(l/r,0,1,jn):1;s=zn(s,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:e,$prev_pageview_max_scroll_percentage:a,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:l,$prev_pageview_max_content_percentage:u})}}return e.pathname&&(s.$prev_pageview_pathname=e.pathname),e.timestamp&&(s.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),s}};const wo=["flags","surveys"],$o={[s]:{exposure:"hidden"},[l]:{exposure:"hidden"},[a]:{exposure:"hidden"},[v]:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"hidden"},[f]:{exposure:"event"},[p]:{exposure:"hidden"},[x]:{exposure:"hidden"},[g]:{exposure:"event"},[_]:{exposure:"hidden"},[m]:{exposure:"event"},[b]:{exposure:"event"},[y]:{exposure:"event"},[w]:{exposure:"hidden"},[S]:{exposure:"event"},[k]:{exposure:"hidden"},[E]:{exposure:"hidden"},[I]:{exposure:"hidden"},[O]:{exposure:"event"},[P]:{exposure:"event",shouldSkipFromEventProperties:t=>wi(t)},[A]:{exposure:"event"},[R]:{exposure:"event"},[D]:{exposure:"event"},[j]:{exposure:"event"},[B]:{exposure:"hidden"},[N]:{exposure:"hidden",storageGroup:"flags"},[L]:{exposure:"hidden",storageGroup:"flags"},[z]:{exposure:"hidden"},[H]:{exposure:"hidden",storageGroup:"flags"},[U]:{exposure:"hidden",storageGroup:"flags"},[q]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[V]:{exposure:"hidden",storageGroup:"flags"},[W]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[X]:{exposure:"hidden",storageGroup:"surveys"},[Z]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Q]:{exposure:"event"},[tt]:{exposure:"hidden"},[it]:{exposure:"hidden"},[et]:{exposure:"hidden"},[st]:{exposure:"hidden"},[nt]:{exposure:"hidden"},[rt]:{exposure:"event"},[ot]:{exposure:"event"},[lt]:{exposure:"event"},[at]:{exposure:"event"},[ht]:{exposure:"hidden"},[ut]:{exposure:"hidden"},[Y]:{exposure:"event"},[dt]:{exposure:"hidden"},[ct]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[vt]:{exposure:"hidden"},[ft]:{exposure:"hidden"},[pt]:{exposure:"hidden"},[gt]:{exposure:"hidden"},[_t]:{exposure:"hidden"},[mt]:{exposure:"hidden"},[bt]:{exposure:"hidden"},[T]:{exposure:"event"},[C]:{exposure:"event"},[F]:{exposure:"event"},[M]:{exposure:"event"},[$t]:{exposure:"event"},[xt]:{exposure:"event"},[St]:{exposure:"hidden"},[kt]:{exposure:"hidden"},[Et]:{exposure:"hidden"},[Pt]:{exposure:"hidden"},[Tt]:{exposure:"hidden"},[Ct]:{exposure:"hidden"},[Ft]:{exposure:"hidden"},[Mt]:{exposure:"hidden"},[It]:{exposure:"hidden"},[Ot]:{exposure:"event"}},xo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],So=t=>{const i=$o[t];if(i)return i;for(const[i,e]of xo)if(0===t.indexOf(i))return e},ko=(t,i)=>{try{let e;return JSON.stringify(t,(t,i)=>{var s;return Fi(i)?(null!==(s=e)&&void 0!==s||(e=new WeakMap),e.has(i)||e.set(i,Vn(i)),e.get(i)):"bigint"==typeof i?i.toString():i},i)}catch(i){return ui(t)}},Eo=t=>{const i=null==Gt?void 0:Gt.createElement("a");return mi(i)?null:(i.href=t,i)},Po=function(t,i){const e=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let t=0;e.length>t;t++){const n=e[t].split("=");if(n[0]===i){s=n;break}}if(!fi(s)||2>s.length)return"";{let t=s[1];try{t=decodeURIComponent(t)}catch(i){jn.error("Skipping decoding for malformed query param: "+t)}return t.replace(/\+/g," ")}},To=function(t,i,e){if(!t||!i||!i.length)return t;const s=t.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],l=r[0],a=(o||"").split("&"),h=[];for(let t=0;a.length>t;t++){const s=a[t].split("=");fi(s)&&(i.includes(s[0])?h.push(s[0]+"="+e):h.push(a[t]))}let u=l;return null!=o&&(u+="?"+h.join("&")),null!=n&&(u+="#"+n),u},Co=function(t,i){const e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Fo=(t,i)=>t>=i&&ti(),Mo=(t,i,e,s)=>{if(0===t){if(ti()){const t=i+1;return t===e&&s(),t}return i}return 0},Io=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Oo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Io],Ao="<masked>",Ro=["li_fat_id"];function Do(t,i,e){if(!Gt)return{};const s=i?[...Io,...e||[]]:[],n=jo(To(Gt.URL,s,Ao),t),r=function(){const t={};return Ln(Ro,function(i){const e=Yn(i);t[i]=e||null}),t}();return zn(r,n)}function jo(t,i){const e=Oo.concat(i||[]),s={};return Ln(e,function(i){const e=Po(t,i);s[i]=e||null}),s}function Bo(t){const i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",s={};if(!wi(i)){s.$search_engine=i;const t=Gt?Po(Gt.referrer,e):"";t.length&&(s.ph_keyword=t)}return s}function No(){return navigator.language||navigator.userLanguage}function Lo(){const t=No();return"string"==typeof t?t.split("-")[0]:void 0}const zo="$direct";function Ho(){return(null==Gt?void 0:Gt.referrer)||zo}function Uo(t,i,e=!1){const s=t?[...Io,...i||[]]:[],n=e?ts(null==Kt?void 0:Kt.href):null==Kt?void 0:Kt.href,r=null==n?void 0:n.substring(0,1e3);return{r:Ho().substring(0,1e3),u:r?To(r,s,Ao):void 0}}function qo(t,i=!1){var e;const{r:s,u:n}=t,r=i?ts(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==zo?zo:null===(e=Eo(s))||void 0===e?void 0:e.host};if(r){o.$current_url=r;const t=Eo(r);o.$host=null==t?void 0:t.host,o.$pathname=null==t?void 0:t.pathname;const i=jo(r);zn(o,i)}if(s){const t=Bo(s);zn(o,t)}return o}function Vo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function Wo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}const Go={flags:ct,surveys:Z},Ko=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Jo=t=>`${t}_cookie_identity_change_pending`,Yo=t=>{let i="",e=0;for(const s of t){const t=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(e+t>1e3)break;i+=s,e+=t}return i},Xo="main",Zo=[N,L,H,U,q,ct,V,K],Qo=t=>-1!==Zo.indexOf(t),tl=[u,c],il=t=>-1!==tl.indexOf(t),el=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},sl=t=>{if(!t)return{};const i=JSON.parse(t);return gi(i)?i:{}},nl=(t,i)=>{Ln(t,(e,s)=>{const n=So(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(i,s)||delete t[s]})};var rl=class{constructor(t,i,e=!0){if(this.Qo={},this.Jo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Ir=t,this.aa=e,this.props={},this.la=void 0,this.ua=(t=>{let i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(t),this.hi=t.disable_persistence||!!i,this.No=this.ha(t),this.Xo=this.ca(t),this.load(),this.da(),t.debug&&jn.info("Persistence loaded",t.persistence,cs({},this.props)),this.update_config(t,t,i),this.save(),qt){const t=()=>this.flush();Kn(qt,"beforeunload",t,{capture:!1}),Kn(qt,"pagehide",t,{capture:!1}),this.va=t=>{if(this.Jo&&(!t.storageArea||t.storageArea===(null==qt?void 0:qt.localStorage))&&t.key)if(t.key!==this.ua){if(this.Xo){const i=wo.find(i=>t.key===this.fa(i));i&&this.pa(t.key,i)}}else this.pa(t.key,Xo)},Kn(qt,"storage",this.va)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([t,i])=>{const e=this.ea.get(t);if(!Qo(t)||!0===e)return;if(!0===i)return void this.ga(t,!0);const s=new Set(e||[]);i.forEach(t=>s.add(t)),s.size&&this.ga(t,s)})}onCrossTabFeatureFlagChange(t){return this.oa.add(t),()=>this.oa.delete(t)}destroy(){this.va&&qt&&(qt.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(t,i,e=!0){if(this.hi)return!1;let s,n;try{if(n=hr.Ot(t),wi(n)){const t=this.ma(i);return t.storageValue=null,i!==Xo&&(t.persisted=!1),!1}s=sl(n)}catch(t){return!1}const r=i===Xo?s:hr.Dt(this.ua);if(r&&this.ya(r))return!1;const o=this.ba(s,i,e);return i===Xo&&this.Xo&&!el(this._a().main,s)||this.wa(s,i,!0,n),o}ya(t){const i=this.props[n],e=t[n];return!mi(i)&&!mi(e)&&i!==e}wa(t,i,e,s){const n=this.ma(i);n.storageValue=s,i!==Xo&&(n.persisted=e);try{n.fingerprint=this.ka(t,i)}catch(t){n.fingerprint=void 0}}ba(t,i,e){let s=!1;return Zo.forEach(e=>{var n;const r=null===(n=So(e))||void 0===n?void 0:n.storageGroup;if(i===Xo&&this.Xo&&r||i!==Xo&&r!==i)return;const o=e in t,l=this.Sa(e,o?t[e]:void 0),a=this.ea.has(e)?e in this.props:o;a===e in this.props&&el(l,this.props[e])||(a?this.xa(e,l,!1):this.Ca(e,!1),s=!0)}),s&&e&&this.oa.forEach(t=>t()),s}$a(){if(!this.Jo)return!1;try{this.sa=!1;const t=hr.Ot(this.ua),i=this.ma(Xo);let e,s=!1,n=!1;if(t!==i.storageValue)if(wi(t))i.storageValue=null;else{if(e=sl(t),this.sa=!this.na&&this.ya(e),this.sa)return!1;n=this.ba(e,Xo,!1),!this.Xo||el(this._a().main,e)?this.wa(e,Xo,!0,t):i.storageValue=t,s=!0}return this.Xo&&wo.forEach(t=>{const i=hr.Ot(this.fa(t)),r=this.ma(t),o=e||{},l=s&&Zo.some(i=>{var e;return(null===(e=So(i))||void 0===e?void 0:e.storageGroup)===t&&i in o});if(i===r.storageValue&&!l)return;if(wi(i))return r.storageValue=null,r.persisted=!1,void(l&&(n=this.ba(o,t,!1)||n));const a=sl(i);n=this.ba(a,t,!1)||n,this.wa(a,t,!0,i)}),n}catch(t){return!1}}ga(t,i){this.ea.set(t,i);const e=So(t);(null==e?void 0:e.volatile)||(this.ma((this.Xo?null==e?void 0:e.storageGroup:void 0)||Xo).fingerprint=void 0,this.Ta(t))}Ia(){Zo.forEach(t=>this.ea.set(t,!0))}da(){if(this.Jo)try{const t=hr.Ot(this.ua),i=sl(t);this.ma(Xo).storageValue=t,Zo.forEach(t=>{var e;const s=this.Xo?null===(e=So(t))||void 0===e?void 0:e.storageGroup:void 0,n=s?hr.Ot(this.fa(s)):null;if(s){const t=this.ma(s);t.storageValue=n,t.persisted=!wi(n)}const r=s&&!wi(n)?sl(n):i;t in this.props?this.Ma(t,r[t],this.props[t]):t in r&&this.ga(t,!0)})}catch(t){}}Sa(t,i){const e=this.ea.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){const s=new Set(fi(i)?i:[]),n=new Set(fi(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}const s=gi(i)?cs({},i):{},n=gi(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in n?s[t]=n[t]:delete s[t]}),s}Ma(t,i,e){if(!Qo(t))return;const s=this.ea.get(t);if(!0===s)return;let n=i;if(this.Jo)try{var r;const i=this.Xo?null===(r=So(t))||void 0===r?void 0:r.storageGroup:void 0,e=i?this.fa(i):this.ua;n=sl(hr.Ot(e))[t]}catch(t){}const o=new Set(s||[]);if("$active_feature_flags"===t){if(!mi(i)&&!fi(i)||!mi(n)&&!fi(n)||!fi(e))return void this.ga(t,!0);const s=new Set(i||[]),r=new Set(n||[]),l=new Set(e);new Set([...s,...l]).forEach(t=>{s.has(t)!==l.has(t)&&o.add(t)}),o.forEach(t=>{r.has(t)===l.has(t)&&o.delete(t)})}else{if(!gi(e))return void(el(n,e)?this.ea.delete(t):this.ga(t,!0));{if(!mi(i)&&!gi(i)||mi(i)&&_i(e)&&mi(n))return void this.ga(t,!0);const s=gi(i)?i:{},r=gi(n)?n:{};new Set([...Object.keys(s),...Object.keys(e)]).forEach(t=>{t in s==t in e&&el(s[t],e[t])||o.add(t)}),o.forEach(t=>{t in r==t in e&&el(r[t],e[t])&&o.delete(t)})}}o.size?this.ga(t,o):this.ea.delete(t)}Ea(){var t;const i=null===(t=this.Ir)||void 0===t?void 0:t.persistence_save_debounce_ms;return xi(i)&&i>0?i:0}Pa(t){if(this.Ir.cookieWinsOnConflict&&"localstorage+cookie"===this.Ir.persistence.toLowerCase())if(t)try{const i=pr(t,this.Ir.cookie_persisted_properties||[]),e=_r(i,this.Ir.cookie_persisted_properties||[]),s=JSON.stringify(i)+"|"+JSON.stringify(e),n=lr.Ot(this.ua)||void 0;n&&br(this.ua,n)===s&&(this.Ra=s,this.Aa=n)}catch(t){}else try{const t=lr.Ot(this.ua)||void 0;this.Ra=t?br(this.ua,t):void 0,this.Aa=t}catch(t){}}syncCookieProperties(){return this.Fa(this.Ir)}Fa(t,i=!1){if(this.hi&&!i||this.ta||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;let e;try{e=lr.Ot(this.ua)||void 0}catch(t){}if(!e||e===this.Aa)return!1;const s=br(this.ua,e);let r;try{r=fr(JSON.parse(e))}catch(t){return!1}if((lr.Ot(this.ua)||void 0)!==e)return!1;this.Ra=s,this.Aa=e;const o=mr(this.ua,e),a=[...dr,...o.properties],h={};if(Object.keys(r).forEach(t=>{const i=r[t];(mi(i)||wi(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(h[t]=!0,delete r[t])}),_i(r))return!1;const u="distinct_id"in r||"anonymous"===r.$user_state||"identified"===r.$user_state,d=this.props,c=d[n],v=d[vt],f=zn({},d);[...dr,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==a.indexOf(t)&&!(t in r)&&!h[t]&&(u||"distinct_id"!==t&&"$user_state"!==t)){const i=f[t];(o.isValid||-1===dr.indexOf(t)||!1!==i&&0!==i)&&delete f[t]}}),this.props=zn(f,r),Zo.forEach(t=>{const i=t in this.props;t in d===i&&el(d[t],this.props[t])||(i?this.Ma(t,d[t],this.props[t]):this.ga(t,!0))}),!u||"$user_state"in r||"$user_state"in this.props||this.xa(vt,Rt);const p=this.props[n],g=this.props[vt];return!u||p===c&&g===v||(this.na=!0,this.Yo=!0,xr.$t(Jo(this.ua),!0),this.Ca(K),this.Ca(L),this.Ca(N),this.Ca(H),this.Ca(U),this.Ca(q),this.Ca(ct),this.Ca(dt),this.Ca(ht),"anonymous"!==g||"identified"!==v&&"anonymous"!==r.$user_state&&(mi(c)||p===c)||(nl(this.props,r),this.Ca(J)),"identified"===g?this.props.$user_id=p:delete this.props.$user_id,this.Ca(l)),!0}consumeCookieIdentityChange(){const t=Jo(this.ua),i=this.Yo||!!xr.Ot(t);return this.Yo=!1,i&&xr.Lt(t),i}Oa(t=!1){return!(this.ta||this.hi&&!t||!this.Ir.cookieWinsOnConflict||"localstorage+cookie"!==this.Ir.persistence.toLowerCase()||(this.ta=!0,0))}Da(){this.ta&&(mi(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Qo[Xo],this.Na(!0))}qa(t=!0){if(this.ta)try{t?this.Da():mi(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ha(t){-1===Ko.indexOf(t.persistence.toLowerCase())&&(jn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");const i=((t=[],i=!1)=>{const e=[...dr,...t];return cs(cs({},hr),{},{Dt(t){try{let r,o={};try{r=lr.Ot(t)||void 0,o=r?fr(JSON.parse(r)):{}}catch(t){}const l=JSON.parse(hr.Ot(t)||"{}");let a;if(i){const i=mr(t,r),h=[...dr,...i.properties],u={};Object.keys(o).forEach(t=>{const i=o[t];wi(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(u[t]=i)});const d="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var s;const t=l[n],r=null!==(s=l.$user_state)&&void 0!==s?s:Rt;e.forEach(t=>{if(-1!==h.indexOf(t)&&!(t in o)&&(d||"distinct_id"!==t&&"$user_state"!==t)){const e=l[t];(i.isValid||-1===dr.indexOf(t)||!1!==e&&0!==e)&&delete l[t]}}),!d||"$user_state"in o||"$user_state"in l||(l[vt]=Rt),!d||("distinct_id"in u?u[n]:l[n])===t&&("$user_state"in u?u[vt]:l[vt])===r||(ur.forEach(t=>delete l[t]),"identified"===u.$user_state&&"distinct_id"in u?l.$user_id=u[n]:delete l.$user_id,"identified"!==u.$user_state&&(delete l[Y],delete l[J]),delete l.__alias)}a=zn(l,u)}else a=zn(o,l);return hr.$t(t,a),a}catch(t){}return null},$t(e,s,n,r,o,l){const a=hr.$t(e,s,void 0,void 0,l);try{const h=pr(s,t);if(Object.keys(h).length){if(i){const i=cr(e),u=_r(h,t);if(lr.$t(i,u,n,r,o,l),lr.Ot(i)!==JSON.stringify(u)){lr.Lt(i,r);const t=pr(s);return lr.$t(e,t,n,r,o,l),a}}lr.$t(e,h,n,r,o,l)}}catch(t){hr.Pt(t)}return a},Lt(t,i){try{null==qt||qt.localStorage.removeItem(t),lr.Lt(t,i),lr.Lt(cr(t),i)}catch(t){hr.Pt(t)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict);let e,s=!1,r=!1;const o=t.persistence.toLowerCase();return"localstorage"===o&&hr.Et()?(e=hr,r=!0):"localstorage+cookie"===o&&i.Et()?(e=i,r=!0,s=!0):"sessionstorage"===o&&xr.Et()?e=xr:"memory"===o?e=wr:"cookie"===o&&lr.Et()?(e=lr,s=!0):i.Et()?(e=i,r=!0,s=!0):lr.Et()?(e=lr,s=!0):e=wr,this.Jo=r,this.Ko=s,e}fa(t){return`${this.ua}__${t}`}ca(t){return this.Jo&&!!t.split_storage}properties(){const t={};return Ln(this.props,(i,e)=>{const s=So(e);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,i))return;t[e]=i}}),t}load(t=!1){if(this.hi&&!t)return;const i=this.Ir.cookieWinsOnConflict&&"localstorage+cookie"===this.Ir.persistence.toLowerCase(),e=i?hr.Dt(this.ua):null;let s={};if(i)try{s=fr(lr.Dt(this.ua)),Ln(s,(t,i)=>{(mi(t)||wi(t)||""===t)&&delete s[i]})}catch(t){}const r=this.No.Dt(this.ua);if(r&&(this.props=zn({},r)),this.Xo&&this.ja(),i&&r){var o,l;const t=null==e?void 0:e[n],i=null!==(o=null==e?void 0:e.$user_state)&&void 0!==o?o:Rt,a=r[n],h=null!==(l=r.$user_state)&&void 0!==l?l:Rt;if(a!==t||h!==i){this.Yo=!0,xr.$t(Jo(this.ua),!0);const e=zn({},this.props);ur.forEach(t=>delete e[t]),"anonymous"!==h||"identified"!==i&&"anonymous"!==s.$user_state&&(mi(t)||a===t)||(nl(e,s),delete e[J]),this.props=e;const n=new Set;ur.forEach(t=>{var i;const e=null===(i=So(t))||void 0===i?void 0:i.storageGroup;e&&n.add(e)}),n.forEach(t=>{const i={};Ln(this.props,(e,s)=>{var n;(null===(n=So(s))||void 0===n?void 0:n.storageGroup)===t&&(i[s]=e)}),_i(i)?(hr.Lt(this.fa(t)),this.Qo[t]={}):hr.$t(this.fa(t),i)&&(this.Qo[t]={persisted:!0,fingerprint:this.ka(i,t)})})}}xr.Ot(Jo(this.ua))&&(this.Yo=!0)}ja(){for(const t of wo){const i=hr.Dt(this.fa(t));if(i&&!_i(i)){const e=this.ma(t);e.persisted=!0,this.Ba(t)||(e.fingerprint=this.ka(i,t)),this.Ha(t,i)||zn(this.props,i)}}}Ba(t){return Object.keys(this.props).some(i=>{var e;return(null===(e=So(i))||void 0===e?void 0:e.storageGroup)===t})}Ha(t,i){const e=Go[t];if(!e)return!1;const s=i[e],n=this.props[e];return xi(s)&&xi(n)&&n>s}refreshKey(t){var i;if(this.hi)return;if(this.ra.has(t))return;const e=this.Xo?null===(i=So(t))||void 0===i?void 0:i.storageGroup:void 0,s=e?hr.Dt(this.fa(e)):this.No.Dt(this.ua);if(s&&t in s)this.xa(t,s[t],!1);else{if(e){const i=this.No.Dt(this.ua);if(i&&t in i)return void this.xa(t,i[t],!1)}this.Ca(t,!1)}}save(){if(this.hi)return;const t=this.Ea();t>0?mi(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},t)):this.Na()}flush(){mi(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(t=!1){if(this.hi||this.ta&&!t)return;t||(this.syncCookieProperties(),this.Ir.cookieWinsOnConflict&&"localstorage+cookie"===this.Ir.persistence.toLowerCase()||tl.forEach(t=>this.refreshKey(t)));const i=!t&&!this.ia;i||(this.sa=!1);const e=!!i&&this.$a();if(this.sa)return void(this.Ir.debug&&jn.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.za(),void(e&&this.oa.forEach(t=>t()));const s=this.Ua(this.No,this.ua,this.props,Xo);"written"===s&&this.Pa(this.props),"failed"!==s&&(this.ea.clear(),this.na=!1,this.ra.clear()),e&&this.oa.forEach(t=>t())}za(){const{main:t,groups:i}=this._a(),e=this.Ua(this.No,this.ua,t,Xo);"written"===e&&this.Pa(t),"failed"!==e&&(this.na=!1,this.ra.clear(),Zo.forEach(t=>{var i;(null===(i=So(t))||void 0===i?void 0:i.storageGroup)||this.ea.delete(t)}));for(const t of wo){var s;const e=i[t];if(_i(e)&&!(null===(s=this.Qo[t])||void 0===s?void 0:s.persisted)){Zo.forEach(i=>{var e;(null===(e=So(i))||void 0===e?void 0:e.storageGroup)===t&&this.ea.delete(i)});continue}const n=this.Ua(hr,this.fa(t),e,t);"failed"!==n&&Zo.forEach(i=>{const e=So(i);(null==e?void 0:e.storageGroup)!==t||"written"!==n&&e.volatile||this.ea.delete(i)})}}_a(){const t={},i={flags:{},surveys:{}};return Ln(this.props,(e,s)=>{var n;const r=null===(n=So(s))||void 0===n?void 0:n.storageGroup;r?i[r][s]=e:t[s]=e}),{main:t,groups:i}}ka(t,i){if(i===Xo)return JSON.stringify(t)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;const e={};return Ln(t,(t,i)=>{var s;e[i]=(null===(s=So(i))||void 0===s?void 0:s.volatile)?"__volatile__":t}),JSON.stringify(e)}Ua(t,i,e,s){const n=this.ma(s);if(s!==Xo&&!n.dirty&&!mi(n.fingerprint))return"skipped";let r;try{if(r=this.ka(e,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){r=void 0}return t.$t(i,e,this.Wa,this.Va,this.Ga,this.Ir.debug)?(n.dirty=!1,s!==Xo&&(n.persisted=!0),mi(r)||(n.fingerprint=r),this.Jo&&(n.storageValue=hr.Ot(i)),"written"):(this.Ir.debug&&jn.warn(`failed to persist storage entry "${i}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.Ia(),mi(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Lt(this.ua,!1),this.No.Lt(this.ua,!0),!t&&this.aa)for(const t of wo)hr.Lt(this.fa(t));t?delete this.Qo[Xo]:this.Qo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(gi(t)){this.syncCookieProperties(),mi(i)&&(i="None"),this.Wa=mi(e)?this.Za:e;let s=!1;if(Ln(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.xa(e,t),s=!0)}),s)return this.save(),!0}return!1}register(t,i){if(gi(t)){this.syncCookieProperties(),this.Wa=mi(i)?this.Za:i;let e=!1;if(Ln(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||gi(i)||fi(i))&&(this.xa(s,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();const i="string"==typeof t?[t]:t;let e=!1;for(const t of i)t in this.props&&(this.Ca(t),e=!0);e&&this.save()}update_campaign_params(){const t=null==Gt?void 0:Gt.URL;if(t===this.la)return;const i=Do(this.Ir.custom_campaign_params,this.Ir.mask_personal_data_properties,this.Ir.custom_personal_data_properties),e=!_i(qn(i));return e&&this.register(i),this.la=t,e?i:void 0}update_search_keyword(){this.register(function(){const t=null==Gt?void 0:Gt.referrer;return t?Bo(t):{}}())}update_referrer_info(){var t;this.register_once({$referrer:Ho(),$referring_domain:(null==Gt?void 0:Gt.referrer)&&(null===(t=Eo(Gt.referrer))||void 0===t?void 0:t.host)||zo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const t=Uo(this.Ir.mask_personal_data_properties,this.Ir.custom_personal_data_properties,this.Ir.disable_capture_url_hashes);this.register_once({[mt]:this.Ko?{r:Yo(t.r),u:t.u?Yo(t.u):void 0}:t},void 0)}get_initial_props(){const t={};Ln([_t,gt],i=>{const e=this.props[i];e&&Ln(e,function(i,e){t["$initial_"+hi(e)]=i})});const i=this.props[mt];if(i){const e=function(t,i=!1){const e=qo(t,i),s={};return Ln(e,function(t,i){s[`$initial_${hi(i)}`]=t}),s}(i,this.Ir.disable_capture_url_hashes);zn(t,e)}return t}safe_merge(t){return Ln(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){const s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;const e=[...t].sort(),s=[...i].sort();return e.every((t,i)=>t===s[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),r=s||n,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,a=!!this.hi&&!l;l||this.Fa(i,a),this.Ir=t,!l&&(s||n||o)&&(this.Ra=void 0,this.Aa=void 0,this.Fa(cs(cs({},t),{},{cookie_persisted_properties:i.cookie_persisted_properties}),a));const h=r||o?this.ha(t):this.No;this.Qa();const u=this.ca(t),d=r||u!==this.Xo,c=!l&&(d||t.cross_subdomain_cookie!==this.Va||t.secure_cookie!==this.Ga)&&this.Oa(a);this.ia=d;try{if(this.Za=this.Wa=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){const t=this.props;this.clear(),this.No=h,this.Xo=u,this.props=t,this.save()}else o&&(this.No=h,l||(delete this.Qo[Xo],this.Na()))}finally{this.ia=!1,c&&this.qa()}}Qa(){const t=this.props[mt];if(!this.Ko||!gi(t)||"string"!=typeof t.r)return;const i=Yo(t.r),e="string"==typeof t.u?Yo(t.u):t.u;i===t.r&&e===t.u||this.xa(mt,cs(cs({},t),{},{r:i,u:e}))}set_disabled(t){this.hi=t,this.hi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Va&&(this.Va=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Ga&&(this.Ga=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){const e=this.props.__timers||{};e[t]=i,this.xa(v,e),this.save()}remove_event_timer(t){const i=this.props.__timers||{},e=i[t];return mi(e)||(delete i[t],this.xa(v,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.xa(t,i),this.save()}xa(t,i,e=!0){var s;const n=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||n===i||(this.na=!0),il(t)&&!el(n,i)&&this.ra.add(t),this.Ma(t,n,i),(null===(s=So(t))||void 0===s?void 0:s.volatile)||this.Ta(t))}Ca(t,i=!0){delete this.props[t],i&&(Qo(t)&&this.ga(t,!0),il(t)&&this.ra.add(t),this.Ta(t))}Ta(t){var i;const e=null===(i=So(t))||void 0===i?void 0:i.storageGroup;e&&(this.ma(e).dirty=!0)}ma(t){return this.Qo[t]||(this.Qo[t]={})}};const ol="gzip-js",ll="base64",al="events",hl="cancelEvents",ul="survey shown",dl="survey dismissed",cl="survey sent",vl="$survey_last_seen_date",fl="popover";function pl(t){let i=!0;return{dispose(){if(i){i=!1;const e=t();e&&pi(e.then)&&e.then(void 0,()=>{})}}}}const gl=Bn("[RateLimiter]");var _l=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{gl.info(`${t||"events"} is quota limited.`),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void gl.warn(`could not rate limit - continuing. Error: "${null==t?void 0:t.message}"`,{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var i,e,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),l=null!==(i=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*r,l.last=o,l.tokens>n&&(l.tokens=n);const a=1>l.tokens;if(a||t||(l.tokens=Math.max(0,l.tokens-1)),a&&!t){const t=(xi(l.dropped)?l.dropped:0)+1;l.dropped=t,!this.lastEventRateLimited&&this.Ja(t)&&(l.dropped=0)}return this.lastEventRateLimited=a,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",l),{isRateLimited:a,remainingTokens:l.tokens}}Ka(t){const i=this.instance.config.property_denylist;return!fi(i)||!i.includes(t)}Xa(){var t;if(this.Ka("$current_url")&&this.Ka("$pathname")&&(null==Kt?void 0:Kt.pathname))return`${null!==(t=Kt.origin)&&void 0!==t?t:""}${Kt.pathname}`}Ja(t){var i,e;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Xa(),o=this.Ka("$session_id")?null===(i=(e=this.instance).get_session_id)||void 0===i?void 0:i.call(e):void 0,l=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${l}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){const i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}};const ml=Bn("[RemoteConfig]");var bl=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null===(t=ei._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.config}Ya(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.loadExternalDependency)?null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}tl(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return ml.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void ml.warn("Remote config is disabled. Falling back to local config.");this.Ya(t=>{if(!t)return ml.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(t=>{this.el(t.json,t)});this.el(t)})}catch(t){ml.error("Error loading remote config",t),this.el()}}el(t,i){!t&&i&&(0===i.statusCode?i.error||ml.warn("Failed to fetch remote config from PostHog."):ml.error("Failed to fetch remote config from PostHog."));try{this._instance.el(t?{ok:!0,config:t}:{ok:!1})}catch(t){ml.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null===(e=this._instance.featureFlags)||void 0===e||e.ensureFlagsLoaded()}catch(t){ml.error("Error loading feature flags",t)}}},yl=Uint8Array,wl=Uint16Array,$l=Uint32Array,xl=new yl([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]),Sl=new yl([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]),kl=new yl([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),El=function(t,i){for(var e=new wl(31),s=0;31>s;++s)e[s]=i+=1<<t[s-1];var n=new $l(e[30]);for(s=1;30>s;++s)for(var r=e[s];e[s+1]>r;++r)n[r]=r-e[s]<<5|s;return[e,n]},Pl=El(xl,2),Tl=Pl[1];Pl[0][28]=258,Tl[258]=28;for(var Cl=El(Sl,0)[1],Fl=new wl(32768),Ml=0;32768>Ml;++Ml){var Il=(43690&Ml)>>>1|(21845&Ml)<<1;Fl[Ml]=((65280&(Il=(61680&(Il=(52428&Il)>>>2|(13107&Il)<<2))>>>4|(3855&Il)<<4))>>>8|(255&Il)<<8)>>>1}var Ol=function(t,i,e){for(var s=t.length,n=0,r=new wl(i);s>n;++n)++r[t[n]-1];var o,l=new wl(i);for(n=0;i>n;++n)l[n]=l[n-1]+r[n-1]<<1;if(e){o=new wl(1<<i);var a=15-i;for(n=0;s>n;++n)if(t[n])for(var h=n<<4|t[n],u=i-t[n],d=l[t[n]-1]++<<u,c=d|(1<<u)-1;c>=d;++d)o[Fl[d]>>>a]=h}else for(o=new wl(s),n=0;s>n;++n)o[n]=Fl[l[t[n]-1]++]>>>15-t[n];return o},Al=new yl(288);for(Ml=0;144>Ml;++Ml)Al[Ml]=8;for(Ml=144;256>Ml;++Ml)Al[Ml]=9;for(Ml=256;280>Ml;++Ml)Al[Ml]=7;for(Ml=280;288>Ml;++Ml)Al[Ml]=8;var Rl=new yl(32);for(Ml=0;32>Ml;++Ml)Rl[Ml]=5;var Dl=Ol(Al,9,0),jl=Ol(Rl,5,0),Bl=function(t){return(t/8|0)+(7&t&&1)},Nl=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var s=new(t instanceof wl?wl:t instanceof $l?$l:yl)(e-i);return s.set(t.subarray(i,e)),s},Ll=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8},zl=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8,t[s+2]|=e>>>16},Hl=function(t,i){for(var e=[],s=0;t.length>s;++s)t[s]&&e.push({s:s,f:t[s]});var n=e.length,r=e.slice();if(!n)return[new yl(0),0];if(1==n){var o=new yl(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var l=e[0],a=e[1],h=0,u=1,d=2;for(e[0]={s:-1,f:l.f+a.f,l:l,r:a};u!=n-1;)l=e[e[d].f>e[h].f?h++:d++],a=e[h!=u&&e[d].f>e[h].f?h++:d++],e[u++]={s:-1,f:l.f+a.f,l:l,r:a};var c=r[0].s;for(s=1;n>s;++s)r[s].s>c&&(c=r[s].s);var v=new wl(c+1),f=Ul(e[u-1],v,0);if(f>i){s=0;var p=0,g=f-i,_=1<<g;for(r.sort(function(t,i){return v[i.s]-v[t.s]||t.f-i.f});n>s;++s){var m=r[s].s;if(i>=v[m])break;p+=_-(1<<f-v[m]),v[m]=i}for(p>>>=g;p>0;){var b=r[s].s;i>v[b]?p-=1<<i-v[b]++-1:++s}for(;s>=0&&p;--s){var y=r[s].s;v[y]==i&&(--v[y],++p)}f=i}return[new yl(v),f]},Ul=function(t,i,e){return-1==t.s?Math.max(Ul(t.l,i,e+1),Ul(t.r,i,e+1)):i[t.s]=e},ql=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new wl(++i),s=0,n=t[0],r=1,o=function(t){e[s++]=t},l=1;i>=l;++l)if(t[l]==n&&l!=i)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[l]}return[e.subarray(0,s),i]},Vl=function(t,i){for(var e=0,s=0;i.length>s;++s)e+=t[s]*i[s];return e},Wl=function(t,i,e){var s=e.length,n=Bl(i+2);t[n]=255&s,t[n+1]=s>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;s>r;++r)t[n+r+4]=e[r];return 8*(n+4+s)},Gl=function(t,i,e,s,n,r,o,l,a,h,u){Ll(i,u++,e),++n[256];for(var d=Hl(n,15),c=d[0],v=d[1],f=Hl(r,15),p=f[0],g=f[1],_=ql(c),m=_[0],b=_[1],y=ql(p),w=y[0],x=y[1],S=new wl(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=Hl(S,7),P=E[0],T=E[1],C=19;C>4&&!P[kl[C-1]];--C);var F,M,I,O,A=h+5<<3,R=Vl(n,Al)+Vl(r,Rl)+o,D=Vl(n,c)+Vl(r,p)+o+14+3*C+Vl(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(R>=A&&D>=A)return Wl(i,u,t.subarray(a,a+h));if(Ll(i,u,1+(R>D)),u+=2,R>D){F=Ol(c,v,0),M=c,I=Ol(p,g,0),O=p;var j=Ol(P,T,0);for(Ll(i,u,b-257),Ll(i,u+5,x-1),Ll(i,u+10,C-4),u+=14,k=0;C>k;++k)Ll(i,u+3*k,P[kl[k]]);u+=3*C;for(var B=[m,w],N=0;2>N;++N){var L=B[N];for(k=0;L.length>k;++k)Ll(i,u,j[z=31&L[k]]),u+=P[z],z>15&&(Ll(i,u,L[k]>>>5&127),u+=L[k]>>>12)}}else F=Dl,M=Al,I=jl,O=Rl;for(k=0;l>k;++k)if(s[k]>255){var z;zl(i,u,F[257+(z=s[k]>>>18&31)]),u+=M[z+257],z>7&&(Ll(i,u,s[k]>>>23&31),u+=xl[z]);var H=31&s[k];zl(i,u,I[H]),u+=O[H],H>3&&(zl(i,u,s[k]>>>5&8191),u+=Sl[H])}else zl(i,u,F[s[k]]),u+=M[s[k]];return zl(i,u,F[256]),u+M[256]},Kl=new $l([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Jl=new yl(0),Yl=function(){for(var t=new $l(256),i=0;256>i;++i){for(var e=i,s=9;--s;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),Xl=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function Zl(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,s=0;i.length>s;++s)e=Yl[255&e^i[s]]^e>>>8;t=e},d(){return 4294967295^t}}}(),s=t.length;e.p(t);var n,r,o,l,a,h,u=(l=10+((n=i).filename&&n.filename.length+1||0),a=8,function(t,i,e,s,n,r){var o=t.length,l=new yl(s+o+5*(1+Math.floor(o/7e3))+n),a=l.subarray(s,l.length-n),h=0;if(!i||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?h=Wl(a,h,t.subarray(u,d)):(a[u]=r,h=Wl(a,h,t.subarray(u,o)))}else{for(var c=Kl[i-1],v=c>>>13,f=8191&c,p=(1<<e)-1,g=new wl(32768),_=new wl(p+1),m=Math.ceil(e/3),b=2*m,y=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<b)&p},w=new $l(25e3),x=new wl(288),S=new wl(32),k=0,E=0,P=(u=0,0),T=0,C=0;o>u;++u){var F=y(u),M=32767&u,I=_[F];if(g[M]=I,_[F]=M,u>=T){var O=o-u;if((k>7e3||P>24576)&&O>423){h=Gl(t,a,0,w,x,S,E,P,C,u-C,h),P=k=E=0,C=u;for(var A=0;286>A;++A)x[A]=0;for(A=0;30>A;++A)S[A]=0}var R=2,D=0,j=f,B=M-I&32767;if(O>2&&F==y(u-B))for(var N=Math.min(v,O)-1,L=Math.min(32767,u),z=Math.min(258,O);L>=B&&--j&&M!=I;){if(t[u+R]==t[u+R-B]){for(var H=0;z>H&&t[u+H]==t[u+H-B];++H);if(H>R){if(R=H,D=B,H>N)break;var U=Math.min(B,H-2),q=0;for(A=0;U>A;++A){var V=u-B+A+32768&32767,W=V-g[V]+32768&32767;W>q&&(q=W,I=V)}}}B+=(M=I)-(I=g[M])+32768&32767}if(D){w[P++]=268435456|Tl[R]<<18|Cl[D];var G=31&Tl[R],K=31&Cl[D];E+=xl[G]+Sl[K],++x[257+G],++S[K],T=u+R,++k}else w[P++]=t[u],++x[t[u]]}}h=Gl(t,a,r,w,x,S,E,P,C,u-C,h),r||(h=Wl(a,h,Jl))}return Nl(l,0,s+Bl(h)+n)}(r=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,l,a,!h)),d=u.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&Xl(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var s=0;e.length>=s;++s)t[s+10]=e.charCodeAt(s)}}(u,i),Xl(u,d-8,e.d()),Xl(u,d-4,s),u}const Ql=!!Yt||!!Jt,ta=new WeakMap,ia="text/plain";let ea=0,sa=!1;const na=(t,i)=>{const[e,s]=t.split("#"),[n,r]=e.split("?");if(!r)return t;const o=r.split("&").filter(t=>t.split("=")[0]!==i).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},ra=(t,i,e=!0)=>{var s;const[n,r]=t.split("?"),o=cs({},i),l=null!==(s=null==r?void 0:r.split("&").map(t=>{var i;const[s,n]=t.split("="),r=e&&null!==(i=o[s])&&void 0!==i?i:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],a=function(t,i="&"){let e,s;const n=[];return Ln(t,function(t,i){mi(t)||mi(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),s=encodeURIComponent(i),n[n.length]=s+"="+e)}),n.join(i)}(o);return a&&l.push(a),l.length>0?`${n}?${l.join("&")}`:n},oa=t=>{if(t.nl)return t.nl;const{data:i,compression:e}=t;if(!i)return;if(e===ol){const t=Zl(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new yl(t.length+(t.length>>>1)),s=0,n=function(t){e[s++]=t},r=0;i>r;++r){if(s+5>e.length){var o=new yl(s+8+(i-r<<1));o.set(e),e=o}var l=t.charCodeAt(r);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Nl(e,0,s)}(ko(i)),{mtime:0});return{contentType:ia,body:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),estimatedSize:t.byteLength}}if(e===ll){const t=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(ko(i)),e=(t=>"data="+encodeURIComponent("string"==typeof t?t:ko(t)))(t);return{contentType:"application/x-www-form-urlencoded",body:e,estimatedSize:new Blob([e]).size}}const s=ko(i);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},la=t=>{const i=()=>"sendBeacon"===t.transport?{url:ra(t.url,{compression:ll}),encodedBody:oa(cs(cs({},t),{},{compression:ll,nl:void 0}))}:{url:na(t.url,"compression"),encodedBody:oa(cs(cs({},t),{},{compression:void 0,nl:void 0}))};let e;try{e=oa(t)}catch(e){if(rn(t.compression,Po(t.url,"compression")))return jn.error("Failed to gzip request body, sending uncompressed payload",e),i();throw e}return e&&rn(t.compression,Po(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?nn(new Uint8Array(s)):ArrayBuffer.isView(s)&&nn(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(sa=!0,i()):{url:t.url,encodedBody:e};var s},aa=t=>{try{return la(t)}catch(e){var i;return jn.error(e),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0,error:e}))}},ha=function(){var t=ji(function*(t){const i=yield function(t){return dn.apply(this,arguments)}(ko(t.data),e.DEBUG,{rethrow:!0});if(!i)return t;const s=yield i.arrayBuffer();return cs(cs({},t),{},{nl:{contentType:ia,body:s,estimatedSize:s.byteLength}})});return function(i){return t.apply(this,arguments)}}(),ua=/Failed to fetch|NetworkError|Load failed/i,da=t=>"TypeError"===(null==t?void 0:t.name)&&ua.test((null==t?void 0:t.message)||""),ca=t=>{try{const i=function(t,i=Date.now()){if("string"!=typeof t||!t)return;const e=t.trim(),s=/^\d+\s*,/.test(e)?e.slice(0,e.indexOf(",")).trim():e;if(/^\d+$/.test(s)){const t=1e3*Math.min(Number(s),300);return t>0?t:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,r=Date.parse(n)-i;return Number.isFinite(r)&&r>0?Math.min(r,Je):void 0}(t());return mi(i)?void 0:Math.min(i,3e4)}catch(t){return}},va=t=>{const i=aa(t);if(!i)return;const e=new Yt;ta.set(e,!0);const{url:s,encodedBody:n}=i;e.open(t.method||"GET",s,!0);const{contentType:r,body:o}=null!=n?n:{};Ln(t.headers,function(t,i){e.setRequestHeader(i,t)}),r&&e.setRequestHeader("Content-Type",r),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i;const s={statusCode:e.status,text:e.responseText};if(200===e.status)try{s.json=JSON.parse(e.responseText)}catch(t){}null===(i=t.callback)||void 0===i||i.call(t,s,ca(()=>e.getResponseHeader("Retry-After")))}},e.send(o)},fa=t=>{const i=aa(t);if(!i)return;const{url:e,encodedBody:s}=i,{contentType:n,body:r,estimatedSize:o}=null!=s?s:{},l=new Headers;Ln(t.headers,function(t,i){l.append(i,t)}),n&&l.append("Content-Type",n);let a=null,h=!1;if(Xt){const i=new Xt;a={signal:i.signal,timeout:setTimeout(()=>{h=!0;try{i.abort(Qe("AbortError","PostHog request timed out"+((e=t.timeout)?` after ${e}ms`:"")))}catch(t){d(t)}var e},t.timeout)}}let u=!1;const d=i=>{var e;u||(u=!0,h&&"AbortError"===(null==i?void 0:i.name)||da(i)?jn.warn(i):jn.error(i),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0,error:i}))};let c=0;const v=()=>{ea-=c,c=0,a&&clearTimeout(a.timeout)};try{const i=cs({method:(null==t?void 0:t.method)||"GET",headers:l,referrerPolicy:"strict-origin",body:r,signal:null==a?void 0:a.signal},t.fetchOptions),s=null!=o?o:mi(r)?0:void 0;i.keepalive="POST"===i.method&&!t.sl&&!1!==i.keepalive&&i.body===r&&!mi(s)&&s>=0&&52428.8>ea+s,i.keepalive&&(c=s,ea+=c),Jt(e,i).then(i=>i.text().then(e=>{var s;if(u)return;const n={statusCode:i.status,text:e};if(200===i.status)try{n.json=JSON.parse(e)}catch(t){jn.error(t)}u=!0,v(),null===(s=t.callback)||void 0===s||s.call(t,n,ca(()=>i.headers.get("Retry-After")))})).catch(t=>{v(),d(t)}).finally(v)}catch(t){v(),d(t)}},pa=t=>{try{var i;const{url:e,encodedBody:s}=la(t),{contentType:n,body:r,estimatedSize:o}=null!=s?s:{};if(!r)return;const l=r instanceof Blob?r:new Blob([r],{type:n});if(Wt.sendBeacon(e,l))return;const a=fi(t.data)?t.data:null===(i=t.data)||void 0===i?void 0:i.batch;if(fi(a)&&a.length>1&&(null!=o?o:0)>16384){const i=Math.ceil(a.length/2),e=i=>fi(t.data)?i:cs(cs({},t.data),{},{batch:i});return pa(cs(cs({},t),{},{data:e(a.slice(0,i))})),void pa(cs(cs({},t),{},{data:e(a.slice(i))}))}jn.warn(`Beacon of ~${null!=o?o:0} bytes was rejected by the browser, falling back to ${Jt?"fetch":"XHR"}`),Jt?fa(cs(cs({},t),{},{sl:!0})):va(t)}catch(t){jn.warn("Beacon send failed",t)}},ga=(t,i,e,s)=>{const n="query"===s?"POST"===i?"sent_at":"_":void 0;return ra(e===ol?na(t,"compression"):t,cs(cs({},n?{[n]:Date.now().toString()}:{}),e===ol?{}:{compression:e}))},_a=(()=>{const t=[];return Jt&&t.push({transport:"fetch",method:fa}),Yt&&t.push({transport:"XHR",method:va}),(null==Wt?void 0:Wt.sendBeacon)&&t.push({transport:"sendBeacon",method:pa}),t})();let ma=!Ql&&-1===(null==Qt?void 0:Qt.indexOf("MSIE"))&&-1===(null==Qt?void 0:Qt.indexOf("Mozilla"));function ba(t,i,e){var s,n,r;e&&(i=cs(cs({},i),{},{callback:t=>e(t)})),t.__loaded?ma?t.__request_queue.push(i):t.rateLimiter.isServerRateLimited(i.batchKey)?i.fireCallbackOnDrop&&(null===(n=i.callback)||void 0===n||n.call(i,{statusCode:429})):(i.transport=i.transport||t.config.api_transport,i.headers=cs(cs({},t.config.request_headers),i.headers),i.compression="best-available"===i.compression?null!==(s=t.compression)&&void 0!==s?s:i.compressionFallback:i.compression,(mi(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(i.disableTransport=["sendBeacon"]),i.fetchOptions=i.fetchOptions||t.config.fetch_options,((t,i)=>{var e,s,n;const r=cs(cs({},t),{},{callback:null!=i?i:i=>{var e;return null===(e=t.callback)||void 0===e?void 0:e.call(t,i)}});r.timeout=r.timeout||6e4;const o=null!==(e=r.transport)&&void 0!==e?e:"fetch";"sendBeacon"===o&&mi(r.compression)&&r.data&&(r.compression=ll),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(t=>{var i,e;const s=(fi(t)?t:[t]).map(t=>cs(cs({},t),t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(i=null==n||null===(e=n.properties)||void 0===e?void 0:e.token)&&void 0!==i?i:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((t,i=(new Date).toISOString())=>fi(t)?t.map(t=>cs(cs({},t),{},{sent_at:i})):cs(cs({},t),{},{sent_at:i}))(r.data))),r.url=ga(r.url,r.method,r.compression,r.timestampMode);const l=_a.filter(t=>!r.disableTransport||!t.transport||!r.disableTransport.includes(t.transport)),a=null!==(s=null===(n=function(t,i){for(let e=0;t.length>e;e++)if(i(t[e]))return t[e]}(l,t=>t.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:l[0].method;if(!a)throw new Error("No available transport method");const h=t=>{try{a(t)}catch(t){var i;da(t)?jn.warn(t):jn.error(t),null===(i=r.callback)||void 0===i||i.call(r,{statusCode:0,error:t})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===ol&&Zt&&"undefined"!=typeof Promise&&!sa?ha(r).then(t=>{h(t)}).catch(i=>{if(on(i))return sa=!0,void h(cs(cs({},r),{},{compression:void 0,url:ga(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;const i="name"in t?String(t.name):"";return on(t)||i===sn})(i)&&(sa=!0),h(r)}):h(r)})(i,(s,n)=>{var r,o,l;t.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=t.config).on_request_error)||void 0===r||r.call(o,s),e?e(s,n):null===(l=i.callback)||void 0===l||l.call(i,s)})):i.fireCallbackOnDrop&&(null===(r=i.callback)||void 0===r||r.call(i,{statusCode:0}))}var ya=class{constructor(t,i){this.rl=!0,this.ol=[],this.al=Li((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,jn.createLogger("flush interval"),3e3),this.ll=t}enqueue(t){this.ol.push(t),this.ul||this.hl()}unload(){this.cl();const t=this.ol.length>0?this.dl():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.vl(t,"sendBeacon")})}enable(){this.rl=!1,this.hl()}hl(){this.rl||(this.ul=setTimeout(()=>{if(this.cl(),this.ol.length>0){const t=this.dl();for(const i in t)this.vl(t[i])}},this.al))}vl(t,i){try{this.ll(t,i)}catch(t){jn.error(t)}}cl(){clearTimeout(this.ul),this.ul=void 0}dl(){const t={};return Ln(this.ol,i=>{var e;const s=i,n=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");mi(t[n])&&(t[n]=cs(cs({},s),{},{data:[]})),null===(e=t[n].data)||void 0===e||e.push(s.data)}),this.ol=[],t}};const wa=["retriesPerformedSoFar"];var $a=class{constructor(t){this._instance=t,this.fl=!1,this.pl=3e3,this.ol=[],this.ol=[],this.gl=!0,this.resume()}resume(){if(!mi(qt)&&"onLine"in qt.navigator){if(this.gl=qt.navigator.onLine,this.ml)return;this.ml=()=>{this.gl=!0,this.yl()},this.bl=()=>{this.gl=!1},Kn(qt,"online",this.ml),Kn(qt,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(t,i){let{retriesPerformedSoFar:e}=t,s=cn(t,wa);Si(e)&&(s.url=ra(s.url,{retry_count:e})),ba(this._instance,i?cs(cs({},s),{},{transport:i}):s,(t,i)=>{var n;if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.Ls(cs({retriesPerformedSoFar:e},s),i);0===t.statusCode&&jn.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=e?e:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,t)})}Ls(t,i){const e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;const s=Math.max(function(t){const i=3e3*Math.pow(2,t),e=i/2,s=Math.min(18e5,i),n=(Math.random()-.5)*(s-e);return Math.ceil(s+n)}(e),null!=i?i:0),n=Date.now()+s;this.ol.push({retryAt:n,requestOptions:t});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),jn.warn(r),this.fl||(this.fl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),0===this.ol.length)return this.fl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.gl&&this.ol.length>0&&this.yl(),this._l()},this.pl)}yl(){const t=Date.now(),i=[],e=this.ol.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.ol=i,e.length>0)for(const{requestOptions:t}of e)this.retriableRequest(t)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.fl=!1,mi(qt)||(this.ml&&(qt.removeEventListener("online",this.ml),this.ml=void 0),this.bl&&(qt.removeEventListener("offline",this.bl),this.bl=void 0));for(const{requestOptions:t}of this.ol)try{this._instance._send_request(cs(cs({},t),{},{transport:"sendBeacon"}))}catch(t){jn.error(t)}this.ol=[]}},xa=class{constructor(t){this._instance=t,this.kl=()=>{var t,i,e,s;this.Sl||(this.Sl={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=r+((null==n?void 0:n.clientHeight)||0),a=(null==n?void 0:n.scrollHeight)||0;this.Sl.lastScrollY=Math.ceil(r),this.Sl.maxScrollY=Math.max(r,null!==(t=this.Sl.maxScrollY)&&void 0!==t?t:0),this.Sl.maxScrollHeight=Math.max(o,null!==(i=this.Sl.maxScrollHeight)&&void 0!==i?i:0),this.Sl.lastContentY=l,this.Sl.maxContentY=Math.max(l,null!==(e=this.Sl.maxContentY)&&void 0!==e?e:0),this.Sl.maxContentHeight=Math.max(a,null!==(s=this.Sl.maxContentHeight)&&void 0!==s?s:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){const t=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),t}startMeasuringScrollPosition(){Kn(qt,"scroll",this.kl,{capture:!0}),Kn(qt,"scrollend",this.kl,{capture:!0}),Kn(qt,"resize",this.kl)}scrollElement(){if(this.xl){const i=fi(this.xl)?this.xl:[this.xl];for(const e of i){var t;const i=null==qt||null===(t=qt.document)||void 0===t?void 0:t.querySelector(e);if(i)return i}return}var i;return null==qt||null===(i=qt.document)||void 0===i?void 0:i.documentElement}Cl(t){var i,e;const s="y"===t?"scrollTop":"scrollLeft";if(this.xl){const t=this.scrollElement();return t&&t[s]||0}return qt?"y"===t?qt.scrollY||qt.pageYOffset||(null===(i=qt.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollTop)||0:qt.scrollX||qt.pageXOffset||(null===(e=qt.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.scrollLeft)||0:0}scrollY(){return this.Cl("y")}scrollX(){return this.Cl("x")}};const Sa=t=>Uo(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);var ka=class{constructor(t,i,e,s){this.qe=t=>{const i=this.$l();if(i&&i.sessionId===t)return;const e={sessionId:t,props:this.Tl(this._instance)};this.Il.register({[ft]:e})},this._instance=t,this.Ml=i,this.Il=e,this.Tl=s||Sa,this.Ml.onSessionId(this.qe)}$l(){return this.Il.props[ft]}getSetOnceProps(){var t;const i=null===(t=this.$l())||void 0===t?void 0:t.props;return i?"r"in i?qo(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){const t={};return Ln(qn(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t[`$session_entry_${hi(e)}`]=i}),t}},Ea=class{on(t,i){return this.El[t]||(this.El[t]=[]),this.El[t].push(i),()=>{this.El[t]=this.El[t].filter(t=>t!==i)}}emit(t,i){for(const e of this.El[t]||[])e(i);for(const e of this.El["*"]||[])e(t,i)}constructor(){this.El={}}};const Pa=Bn("[SessionId]"),Ta=864e5;var Ca=class{on(t,i){return this.Pl.on(t,i)}constructor(t,i,e){var s;if(this.Rl=null,this.Al=null,this.Fl=[],this.Ol=void 0,this.Dl=!1,this.Pl=new Ea,this.Ll=(t,i)=>!(!Si(t)||!Si(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Ir=t.config,this.Il=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=i||er,this.jl=e||er;const n=this.Ir.persistence_name||this.Ir.token;if(this._sessionTimeoutMs=1e3*Li(this.Ir.session_idle_timeout_seconds||1800,60,36e3,Pa.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.Hl="ph_"+n+"_window_id",this.zl="ph_"+n+"_primary_window_exists",this.Ul()){const t=xr.Dt(this.Hl),i=xr.Dt(this.zl);t&&!i?this.je=t:xr.Lt(this.Hl),xr.$t(this.zl,!0)}(null===(s=this.Ir.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Ir.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return mi(this.Fl)&&(this.Fl=[]),this.Fl.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.Fl=this.Fl.filter(i=>i!==t)}}Ul(){return"memory"!==this.Ir.persistence&&!this.Il.hi&&xr.Et()}Vl(t){t!==this.je&&(this.je=t,this.Ul()&&xr.$t(this.Hl,t))}Gl(){return this.je?this.je:this.Ul()?xr.Dt(this.Hl):null}Zl(t){const i=this.Rl;return!wi(i)&&!wi(t)&&5e3>Math.abs(t-i)}Ql(t,i,e){const s=i!==this._sessionActivityTimestamp,n=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,n&&!s||n&&this.Zl(i)||(this.Rl=i,this.Il.register({[I]:[i,t,e]}))}Jl(){var t;const i=null===(t=this.Ir)||void 0===t?void 0:t.persistence_save_debounce_ms;return Si(i)&&i>0}Kl(){this.Jl()?this.Il.refreshKey(I):(this.Il.flush(),this.Il.load())}Xl(){var t;if(wi(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();const[,i,e]=this.Yl();i===this.Xt&&e===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[I]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){const[t]=this.Yl(),i=Si(t)?t:0,e=Si(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}eu(t){return this.Kl(),this.Ll(t,this.tu())}Yl(){const t=this.Il.props[I];return fi(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Ql(null,null,null)}setBootstrapSessionId(t,i=!1){const e=((t,i=(new Date).getTime())=>{try{const e=(t=>{const i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void Pa.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void Pa.error("Invalid sessionID in bootstrap",t)}})(t);return!mi(e)&&(i?this.Nl={sessionId:t,sessionStartTimestamp:e}:this.Ql(t,(new Date).getTime(),e),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Ol&&qt&&(qt.removeEventListener(Nt,this.Ol,{capture:!1}),this.Ol=void 0),this.Fl=[]}Wl(){this.Ol=()=>{this.Xl(),this.Ul()&&xr.Lt(this.zl)},Kn(qt,Nt,this.Ol,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,i=null,e=!1){if("always"===this.Ir.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=i||(new Date).getTime(),n=this.Xt;if(e)this.Al=s;else if(wi(this.Al)||this.Al>s||s-this.Al>=1e3){var r,o;null===(r=(o=this.Il).syncCookieProperties)||void 0===r||r.call(o),this.Al=s}let[,l,a]=this.Yl();const h=!mi(n)&&l!==n,u=this.tu();let d=this.Gl();const c=this.Nl,v=!!c&&(c.sessionStartTimestamp>s+6e4||s-c.sessionStartTimestamp>Ta),f=c?v:Si(a)&&Math.abs(s-a)>Ta;let p=!1,g=h,_=!l||!!c;const m=l;let b=!_&&!t&&this.Ll(s,u);if(b&&(b=this.eu(s),b||Pa.info("cross-tab refresh kept the session alive",{sessionId:l}),[,l,a]=this.Yl(),b||(_=!l||!!c)),_||b||f){g=!1;const t=c&&!v;l=t?c.sessionId:this.ql(),d=this.jl(),Pa.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!t,changeReason:{noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f}}),a=t?c.sessionStartTimestamp:s,this.Nl=void 0,p=!0}else d||(d=this.jl(),p=!0),g=g||l!==m,g&&(Pa.info("adopted cross-tab session id",{sessionId:l,windowId:d}),p=!0);const y=Si(u)&&t&&!f?u:s,w=Si(a)?a:(new Date).getTime();this.Vl(d),this.Ql(l,y,w),t||this.Bl();const x={noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f,crossTabAdoption:g};return p&&this.Fl.forEach(t=>t(l,d,x)),{sessionId:l,windowId:d,sessionStartTimestamp:w,changeReason:p?x:void 0,lastActivityTimestamp:u}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu((new Date).getTime())){const t=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:t})}else this.Bl()},1.1*this.sessionTimeoutMs))}};const Fa=function(t,i){if(!t)return!1;const e=t.userAgent;if(e&&Ni(e,i))return!0;try{const e=null==t?void 0:t.userAgentData;if((null==e?void 0:e.brands)&&e.brands.some(t=>Ni(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function Ma(){return(Ma=ji(function*(){const t=null==Wt?void 0:Wt.userAgentData;if(null==t?void 0:t.getHighEntropyValues)try{const i=yield t.getHighEntropyValues(["model"]),e=null==i?void 0:i.model;return bi(e)&&e.length>0?e:void 0}catch(t){return void jn.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function Ia(t,i){let e=`$survey_${i}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(e=`$survey_${i}/${t.id}/${t.current_iteration}`),e}function Oa(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}const Aa=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Ra=t=>t.toLowerCase(),Da={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>Aa(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!Aa(i,t))),icontains:(t,i)=>i.map(Ra).some(i=>t.map(Ra).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Ra).every(i=>t.map(Ra).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function ja(t,i){return!t||Object.entries(t).every(([t,e])=>{const s=null==i?void 0:i[t];if(null==s)return!1;const n=Da[e.operator];return!!n&&n(e.values.map(String),[String(s)])})}function Ba(t,i,e){return ko({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}const Na="custom",La="i.posthog.com",za=/^\/static\//,Ha=["/s/","/e/","/i/"];var Ua=class{constructor(t){this.nu={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let i=null===(t=this.instance.config.ui_host)||void 0===t?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace(`.${La}`,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.nu[this.apiHost]||(this.nu[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Na),this.nu[this.apiHost]}su(t){if(!za.test(t))return;const i=this.instance.config.asset_host;return"string"==typeof i&&i.trim().replace(/\/$/,"")||void 0}ru(t){const i=Eo(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}ou(t,i,e){if("ui"===t)return e;let s=e;const n=this.instance.config.rewriteRequestPath;if(n){var r;const t=(null===(r=Eo(e))||void 0===r?void 0:r.href)||e;s=n(new URL(t)).toString()}if(n&&"api"===t&&Ha.some(t=>0===i.indexOf(t))){const t=this.ru(s);if(t){const i=this.apiHost;let e=this.au;(null==e?void 0:e.apiHost)===i&&e.rewriteRequestPath===n||(e={apiHost:i,rewriteRequestPath:n,urls:new Set},this.au=e),e.urls.add(t)}}return s}isIngestionEndpoint(t){const i=this.au,e=this.ru(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i=""){if(i&&(i="/"===i[0]?i:`/${i}`),"ui"===t)return this.ou(t,i,this.uiHost+i);if("flags"===t)return this.ou(t,i,this.flagsApiHost+i);if("assets"===t){const e=this.su(i);if(e)return this.ou(t,i,`${e}${i}`)}if(this.region===Na)return this.ou(t,i,this.apiHost+i);const e=La+i;switch(t){case"assets":return this.ou(t,i,`https://${this.region}-assets.${e}`);case"api":return this.ou(t,i,`https://${this.region}.${e}`)}}};const qa=Bn("[Surveys]"),Va=t=>{try{const i=(t=>((t,i)=>`seenSurvey_${function(t){return t.current_iteration&&t.current_iteration>0?`${t.id}_${t.current_iteration}`:t.id}(i)}`)(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){qa.error("Failed to persist survey seen state",t)}},Wa=["popover","widget","api"],Ga={ignoreConditions:!1,ignoreDelay:!1,displayType:fl},Ka=Bn("[PostHog ExternalIntegrations]"),Ja={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Ya=class{constructor(t){this._instance=t}Ho(t,i){var e,s;null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,t,t=>{if(t)return Ka.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t;for(const[n,r]of Object.entries(null!==(t=this._instance.config.integrations)&&void 0!==t?t:{})){var i,e,s;r&&!(null===(i=ei.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&this.Ho(Ja[n],()=>{var t;null===(t=ei.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t||null===(t=t[n])||void 0===t||t.start(this._instance)}),!r&&(null===(e=ei.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e?void 0:e[n])&&(null===(s=ei.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},Xa=class{constructor(t,i){this.A=t,this.bo=i,this.lu=new Map,this.To=!1}add(t){var i=this;return ji(function*(){if(i.To)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.lu.has(t.name))throw new Error(`Browser extension "${t.name}" is already registered`);i.lu.set(t.name,t);try{const e=t.setup(i.bo);e&&(yield e)}catch(e){const s=i.lu.get(t.name)===t;s&&i.lu.delete(t.name),i.A.error(`Failed to set up browser extension "${t.name}"`,e),s&&i.uu(t)}})()}getExtension(t){return this.lu.get(t)}dispose(){if(this.To)return;this.To=!0;const t=Array.from(this.lu.values()).reverse();this.lu.clear();for(const i of t)this.uu(i)}uu(t){try{var i;const e=null===(i=t.dispose)||void 0===i?void 0:i.call(t);e&&pi(e.then)&&e.then(void 0,i=>{this.A.error(`Failed to dispose browser extension "${t.name}"`,i)})}catch(i){this.A.error(`Failed to dispose browser extension "${t.name}"`,i)}}},Za=class{constructor(t){this._instance=t}initialize(){}get(t){const i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);const e={};for(const s of t){const t=null==i?void 0:i.get_property(s);mi(t)||(e[s]=t)}return e}set(t,i){var e;null===(e=this._instance.persistence)||void 0===e||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null===(i=this._instance.persistence)||void 0===i||i.unregister(t)}};const Qa="extensionsRemoteConfig";var th=class{constructor(t){this.instance=t,this.To=!1,this.A=jn,this.hu=t.cu,this.kv=new Za(t),this.onEvent=t=>pl(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.A.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{if(this.To)return pl(()=>{});const i=i=>{try{t(i)}catch(t){this.A.error("Browser extension remote config listener failed",t)}},e=this.instance.du.on(Qa,i);return this.hu&&i(this.hu),pl(e)},this.vu=new Xa(jn.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){const t=this.instance.get_property(r);return"string"==typeof t?t:void 0}get library(){return{name:e.LIB_NAME,version:e.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,s;const n=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==n?void 0:n.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==n?void 0:n.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.sessionStartTimestamp)&&void 0!==s?s:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.vu.add(t)}getExtension(t){return this.vu.getExtension(t)}capture(t,i,e){e?this.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):this.instance.capture(t,i)}registerDynamicEventProperties(t){return pl(this.instance.fu(t))}handleRemoteConfig(t){this.To||(this.hu=t,this.instance.du.emit(Qa,t))}sendRequest(t){var i=this;return ji(function*(t,e={}){var s;const n=i.instance.requestRouter.endpointFor(null!==(s=e.target)&&void 0!==s?s:"api",t),r={method:e.method,url:e.query?ra(n,e.query):n,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:"flags"===e.target&&"best-available"===e.compression?ni.Base64:void 0,timestampMode:e.sentAt};return"sendBeacon"===e.transport?(i.instance._send_request(r),{statusCode:202}):new Promise(t=>{r.callback=t,i.instance._send_request(r)})}).apply(this,arguments)}dispose(){this.To||(this.To=!0,this.vu.dispose())}};const ih={};let eh=0;const sh=()=>{},nh='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',rh="Surveys module not available",oh="sanitize_properties is deprecated. Use before_send instead",lh="Invalid value for property_denylist config: ",ah=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],hh=["$feature_flag_called","$$heatmap","$snapshot"],uh=t=>"$"===t.charAt(0)&&!li(hh,t),dh=/^[A-Za-z0-9_-]{1,400}$/,ch=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,vh=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,fh=["token","distinct_id",wt],ph="posthog",gh=t=>{const i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},_h=t=>{var i;return cs({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Gn(null==Gt?void 0:Gt.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:sh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Kt&&bi(null==Kt?void 0:Kt.search)&&-1!==Kt.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==qt||null===(i=qt.location)||void 0===i?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(t){jn.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:jt,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:sh},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Ur,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:gh(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(t))},mh=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],bh=t=>{const i={};for(const[e,s]of mh)mi(t[e])||(i[s]=t[e]);const e=zn({},i,t),s=t.__preview_external_dependency_versioned_paths;return mi(s)||(mi(t.strict_script_versioning)&&(e.strict_script_versioning=!!s),bi(s)&&mi(t.asset_host)&&(e.asset_host=s)),fi(t.property_blacklist)&&(mi(t.property_denylist)?e.property_denylist=t.property_blacklist:fi(t.property_denylist)?e.property_denylist=[...t.property_blacklist,...t.property_denylist]:jn.error(lh+t.property_denylist)),e};var yh=class{constructor(){this.__forceAllowLocalhost=!1}get pu(){return this.__forceAllowLocalhost}set pu(t){jn.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},wh=class t{gu(t){if(!t)return;const i=this.lu.indexOf(t);-1!==i&&this.lu.splice(i,1)}mu(t,i){var e;return this.gu(t),this.lu.push(i),null===(e=i.initialize)||void 0===e||e.call(i),i}yu(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}bu(){if(this._u)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.yu())return;const t="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!t&&!this.config.disable_persistence)return;if(this.wu)return;let i,e,s;t?(i=`persistence is set to '${this.config.persistence}'`,e="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(i="persistence is disabled (disable_persistence is true)",e="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._u=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${e}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}ku(){if(this.yu()||"$posthog_cookieless"!==this.get_distinct_id())return;const t=this.persistence;if(!t)return;this.Su()||t.load(!0);const i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){const i=this.config.get_device_id(er());this.register({distinct_id:i,$device_id:i}),t.set_property(vt,Rt)}this.xu()}get decideEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var i;this.Cu=!1,this.$u=!1,this.webPerformance=new yh,this.Tu=!1,this.version=e.LIB_VERSION,this.Iu=new Set,this.Mu="",this.du=new Ea,this.lu=[],this.Eu=[],this.Pu=!1,this.wu=!1,this._u=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=_h(),this.SentryIntegration=bo,this.sentryIntegration=t=>function(t,i){const e=mo(t,i);return{name:_o,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ru=!1,this.Au=null,this.Fu=null,this.Ou=null,this.scrollManager=new xa(this),this.pageViewManager=new yo(this),this.rateLimiter=new _l(this),this.requestRouter=new Ua(this),this.consent=new Sr(this),this.externalIntegrations=new Ya(this);const s=null!==(i=t.__defaultExtensionClasses)&&void 0!==i?i:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(t,i,e)=>{const s=bi(t)?{[t]:i}:t;this.setPersonProperties(s),null==e||e({})},set_once:(t,i,e)=>{const s=bi(t)?{[t]:i}:t;this.setPersonProperties(void 0,s),null==e||e({})}},this.on("eventCaptured",t=>jn.info(`send "${null==t?void 0:t.event}"`,t))}init(i,e,s){if(s&&s!==ph){var n;const r=null!==(n=ih[s])&&void 0!==n?n:new t;return r._init(i,e,s),ih[s]=r,ih[ph][s]=r,r}return this._init(i,e,s)}_init(t,i={},s){var n,r,l;const a=bi(t)?t.trim():"";if(!a)return jn.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var h;if(this.__loaded)return a!==(null===(h=this.config)||void 0===h?void 0:h.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=_h(i.defaults),i.debug=this.Du(i.debug),this.Lu=i,this.Nu=[],i.person_profiles?this.Fu=i.person_profiles:i.process_person&&(this.Fu=i.process_person);const u=_h(i.defaults),d=bh(i),c=zn({},u,d,{name:s,token:a});gi(u.rageclick)&&gi(d.rageclick)&&(c.rageclick=zn({},u.rageclick,d.rageclick)),gi(u.session_recording)&&gi(d.session_recording)&&(c.session_recording=zn({},u.session_recording,d.session_recording)),this.set_config(c),this.config.on_xhr_error&&jn.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:ol;const v=this.Su();if(this.persistence=new rl(this.config,v),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new rl(cs(cs({},this.config),{},{persistence:"sessionStorage"}),v,!1),this.Mu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!v&&xr.Et()){const t=xr.Dt(this.Mu);fi(t)&&t.forEach(t=>{bi(t)&&this.Iu.add(t)})}else xr.Lt(this.Mu);const f=cs({},this.persistence.props),p=cs({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.qu=new ya((t,i)=>this.ju(t,i),this.config.request_queue_config),this.Bu=new $a(this),this.__request_queue=[];const g=this.yu();g||(this.sessionManager=new Ca(this),this.sessionPropsManager=new ka(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{((null==e?void 0:e.activityTimeout)||(null==e?void 0:e.sessionPastMaximumLength)||(null==e?void 0:e.crossTabAdoption))&&this.Hu()})),this.zu(),this.config.__preview_deferred_init_extensions?(jn.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Uu(g)},0)):(jn.info("Initializing extensions synchronously"),this.Uu(g)),e.DEBUG=e.DEBUG||this.config.debug,e.DEBUG&&jn.info("Starting in debug mode",{this:this,config:i,thisC:cs({},this.config),p:f,s:p}),this.config.identity_distinct_id&&!(null===(n=i.bootstrap)||void 0===n?void 0:n.distinctID)&&(i.bootstrap=cs(cs({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const _=null===(r=i.bootstrap)||void 0===r?void 0:r.distinctID;if(this.wu=!!_&&!yi(_),null===(l=i.bootstrap)||void 0===l?void 0:l.distinctID){const t=i.bootstrap.distinctID,e=this.get_distinct_id(),s=this.persistence.get_property(vt);if(i.bootstrap.isIdentifiedID&&null!=e&&e!==t&&"anonymous"===s)this.identify(t);else if(i.bootstrap.isIdentifiedID&&null!=e&&e!==t&&"identified"===s)jn.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const e=this.config.get_device_id(er()),s=i.bootstrap.isIdentifiedID?e:t;this.persistence.set_property(vt,i.bootstrap.isIdentifiedID?Dt:Rt),this.register({distinct_id:t,$device_id:s})}}if(g)this.register_once({distinct_id:yt,$device_id:null},"");else if(!this.get_distinct_id()){const t=this.config.get_device_id(er());this.register_once({distinct_id:t,$device_id:t},""),this.persistence.set_property(vt,Rt)}return Kn(qt,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Kn(qt,"pageshow",()=>{var t;this.Cu=!1,this.$u||null===(t=this.Bu)||void 0===t||t.resume()}),i.segment?go(this,()=>this.Wu()):this.Wu(),pi(this.config._onCapture)&&this.config._onCapture!==sh&&(jn.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&jn.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return Ma.apply(this,arguments)}().then(t=>{t&&this.register({[o]:t})}).catch(sh),this}Vu(t){const i=t;return bi(i.name)&&pi(i.setup)}Gu(t,i){this.Vu(t)?i.push(()=>{this.Zu().add(t).catch(()=>{var i;return null===(i=t.dispose)||void 0===i?void 0:i.call(t)}).catch(i=>{jn.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.lu.push(t)}zu(){var i,e,s;const n=null!==(i=null===(e=this.config.__extensionClasses)||void 0===e?void 0:e.featureFlags)&&void 0!==i?i:null===(s=t.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,l;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this.Qu)||void 0===r||r.call(this),this.Qu=void 0,this.featureFlags=new n(this)),pi(this.featureFlags.onReloading)&&pi(this.featureFlags.setup)?this.Qu||(this.Qu=this.featureFlags.onReloading(()=>{this.du.emit("featureFlagsReloading",!0)}),this.Zu().add(this.featureFlags)):null===(o=(l=this.featureFlags).initialize)||void 0===o||o.call(l))}Uu(i){const e=performance.now(),s=cs(cs({},t.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,l,a,h,u,d;s.exceptions&&this.lu.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.lu.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.lu.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.lu.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!i&&this.lu.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Gu(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Gu(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Gu(this.logs=null!==(l=this.logs)&&void 0!==l?l:new s.logs(this),n),s.metrics&&this.lu.push(this.metrics=null!==(a=this.metrics)&&void 0!==a?a:new s.metrics(this)),s.conversations&&this.lu.push(this.conversations=null!==(h=this.conversations)&&void 0!==h?h:new s.conversations(this)),s.productTours&&this.lu.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.lu.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.lu.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.lu.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.lu.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,vo)),s.toolbar&&this.lu.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this.lu.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this.lu.forEach(t=>{t.initialize&&n.push(()=>{var i;null===(i=t.initialize)||void 0===i||i.call(t)})}),n.push(()=>{if(this.Ju){const t=this.Ju;this.Ju=void 0,this.lu.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}}),this.Ku(n,e)}Ku(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.Ku(t,i)},0);const e=t.shift();if(e)try{e()}catch(t){jn.error("Error initializing extension:",t)}}const e=Math.round(performance.now()-i);this.register_for_session({[$t]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[xt]:e}),this.config.__preview_deferred_init_extensions&&jn.info(`PostHog extensions initialized (${e}ms)`)}el(t){var i;if(!Gt||!Gt.body)return jn.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ju=t),this.cu=t,this.compression=void 0,t.ok){var e;const i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=li(i.supportedCompression,ol)?ol:li(i.supportedCompression,ll)?ll:void 0),(null===(e=i.analytics)||void 0===e?void 0:e.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Fu?this.Fu:jt}),null===(i=this.Xu)||void 0===i||i.handleRemoteConfig(t),this.lu.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}Wu(){try{this.config.loaded(this)}catch(t){jn.critical("`loaded` function failed",t)}if(this.Yu(),this.config.internal_or_test_user_hostname&&(null==Kt?void 0:Kt.hostname)){const t=Kt.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.yu())&&this.th()},1),this.eh=new bl(this),this.eh.load()}Yu(){var t;this.is_capturing()&&this.config.request_batching&&(null===(t=this.qu)||void 0===t||t.enable())}_dom_loaded(){this.is_capturing()&&Nn(this.__request_queue,t=>this.ju(t)),this.__request_queue=[],this.Yu()}_handle_unload(){var t,i,e,s,n,r;this.Cu=!0,null===(t=this.surveys)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t),null===(e=this.metrics)||void 0===e||e.flush("sendBeacon"),this.config.request_batching?(this.ih()&&this.capture(zt),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this.qu)||void 0===n||n.unload(),null===(r=this.Bu)||void 0===r||r.unload()):this.ih()&&this.capture(zt,null,{transport:"sendBeacon"})}_send_request(t){ba(this,t)}ju(t,i){this.Bu?this.Bu.retriableRequest(t,i):this._send_request(i?cs(cs({},t),{},{transport:i}):t)}_execute_array(t){eh++;try{let i;const e=[],s=[],n=[];Nn(t,t=>{if(t)if(i=t[0],fi(i))n.push(t);else if(pi(t))try{t.call(this)}catch(i){jn.error("Error executing queued PostHog call",t,i)}else fi(t)&&"alias"===i?e.push(t):fi(t)&&-1!==i.indexOf("capture")&&pi(this[i])?n.push(t):s.push(t)});const r=function(t,i){Nn(t,function(t){try{if(fi(t[0])){let e=i;Ln(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){jn.error("Error executing queued PostHog call",t,i)}})};r(e,this),r(s,this),r(n,this)}finally{eh--}}push(i){if(eh>0&&fi(i)&&bi(i[0])){const e=t.prototype[i[0]];return void(pi(e)&&e.apply(this,i.slice(1)))}this._execute_array([i])}get nh(){return{property:h,persistenceKey:u,cookieName:"_fbc",pattern:ch,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[u]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(u)}}}get sh(){return{property:d,persistenceKey:c,cookieName:"_fbp",pattern:vh,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[c]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(c)}}}rh(t){var i;const e=null===(i=this.persistence)||void 0===i?void 0:i.get_property(t.persistenceKey);return bi(e)&&t.pattern.test(e)?{value:e,delivered:!1}:gi(e)&&bi(e.value)&&t.pattern.test(e.value)?{value:e.value,delivered:!0===e.delivered}:void 0}oh(t,i,e){return i===(null==e?void 0:e.value)?{value:i,pending:!e.delivered}:(t.register(i,!1),{value:i,pending:!0})}ah(t){if(!this.config.save_campaign_params||this.yu())return;const i=Yn(t.cookieName);return bi(i)&&t.pattern.test(i)?i:void 0}uh(t,i,e,s){if(!this.persistence)return;const n=this.nh;this.persistence.refreshKey(n.persistenceKey);const r=this.rh(n);if(s)return void n.unregister();if(e)return bi(i)&&ch.test(i)?this.oh(n,i,r):void n.unregister();const o=bi(t)&&dh.test(t)?t:void 0,l=this.ah(n);return l&&((t,i,e)=>{const s=t.split(".");if(i)return s[3]===i;if(!e)return!0;const n=e.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(l,o,r)?this.oh(n,l,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this.oh(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}hh(t,i,e){if(!this.persistence)return;const s=this.sh;this.persistence.refreshKey(s.persistenceKey);const n=this.rh(s);if(e)return void s.unregister();if(i)return bi(t)&&vh.test(t)?this.oh(s,t,n):void s.unregister();const r=this.ah(s);return r?this.oh(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}dh(t,i){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const e=this.rh(t);(null==e?void 0:e.value)!==i||e.delivered||t.register(i,!0)}capture(t,i,e){var s,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.qu))return void jn.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(mi(t)||!bi(t))return void jn.error("No event name provided to posthog.capture");this.ku();const r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;const o=(null==e?void 0:e.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==o?void 0:o.isRateLimited)return void jn.critical("This capture call is ignored due to client rate limiting.");let l;(null==i?void 0:i.$current_url)&&!bi(null==i?void 0:i.$current_url)&&(jn.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||(null==e?void 0:e.fh)||jn.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const a=new Date,u=(null==e?void 0:e.timestamp)||a,c=Ze(null==e?void 0:e.uuid,er);let v={uuid:c,event:t,properties:this.calculateEventProperties(t,i||{},u,c)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&r&&(v.event="$bot_pageview",v.properties.$browser_type="bot"),o&&(v.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens);const f="$feature_flag_called"===t&&!1===v.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==e?void 0:e.$set)&&!f&&(v.$set=null==e?void 0:e.$set);const p=gi(null==i?void 0:i.$set)?i.$set:void 0,g=fi(null==i?void 0:i.$unset)?i.$unset:[],_=(null==e?void 0:e.$unset)||[],m=t=>{var i;const s=!!(null==e?void 0:e.$set)&&t in e.$set;return{hasProvided:s||!!p&&t in p,provided:s?null==e||null===(i=e.$set)||void 0===i?void 0:i[t]:null==p?void 0:p[t],unset:-1!==g.indexOf(t)||-1!==_.indexOf(t)}},b=m(h),y=m(d),w=[{channel:this.nh,hasProvided:b.hasProvided,update:this.uh(null==l?void 0:l.fbclid,b.provided,b.hasProvided,b.unset)},{channel:this.sh,hasProvided:y.hasProvided,update:this.hh(y.provided,y.hasProvided,y.unset)}];for(const{channel:t,hasProvided:i,update:e}of w)e&&!0===v.properties.$process_person_profile&&e.pending&&!i&&!f&&(v.$set=cs({[t.property]:e.value},v.$set));const x=null==e?void 0:e.$unset;x&&(v.$unset=x);const S=f?void 0:this.ph(null==e?void 0:e.$set_once,t!==Ut,t===Ht);if(S&&(v.$set_once=S),(null==e?void 0:e._noTruncate)||(k=this.config.properties_string_max_length,v=function(t,i){const e=new Set;return function t(s,n){if(s!==Object(s))return i?i(s):s;if(e.has(s))return;let r;if(e.add(s),fi(s))r=[],Nn(s,i=>{r.push(t(i))});else{const i={};Ln(Fi(s)?Vn(s):s,(s,n)=>{e.has(s)||(i[n]=t(s,n))}),r=i}return r}(t)}(v,t=>bi(t)?t.slice(0,k):t)),v.timestamp=u,mi(null==e?void 0:e.timestamp)||(v.properties.$event_time_override_provided=!0,v.properties.$event_time_override_system_time=a),f&&(v.properties=((t,i=[])=>{const e={},s=i=>{void 0!==t[i]&&(e[i]=t[i])};return en.forEach(s),i.forEach(s),e})(v.properties,fh)),t===dl||t===cl){const e=null==i?void 0:i.$survey_id,s=null==i?void 0:i.$survey_iteration;Va({id:e,current_iteration:s}),v.$set=cs(cs({},v.$set),{},{[Ia({id:e,current_iteration:s},t===cl?"responded":"dismissed")]:!0})}else t===ul&&(v.$set=cs(cs({},v.$set),{},{[vl]:(new Date).toISOString()}));var k;if("product tour shown"===t){const t=null==i?void 0:i.$product_tour_type;t&&(v.$set=cs(cs({},v.$set),{},{[`$product_tour_last_seen_date/${t}`]:(new Date).toISOString()}))}const E=cs(cs({},v.properties.$set),v.$set);if(_i(E)||this.setPersonPropertiesForFlags(E),!$i(this.config.before_send)){const t=this.Os(v);if(!t)return;v=t,v.uuid=Ze(v.uuid,er)}this.sessionRecording&&!this.Pu&&uh(t)&&(this.Pu=!0,setTimeout(()=>this.Pu=!1,3e4));const P=w.filter(({channel:t,update:i})=>{var e,s,n;const r=null!==(e=null===(s=v.$set)||void 0===s?void 0:s[t.property])&&void 0!==e?e:gi(null===(n=v.properties)||void 0===n?void 0:n.$set)?v.properties.$set[t.property]:void 0;return(null==i?void 0:i.pending)&&r===i.value});this.du.emit("eventCaptured",v);const T=null!==(s=null==e?void 0:e._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),C="recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(T),F=cs(cs(cs({method:"POST",url:T,data:v,compression:"best-available",preferSyncCompression:null==e?void 0:e.send_instantly,timestampMode:C?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},C&&(null===(n=v.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:v.properties.$session_id+(v.properties.$window_id?`-${v.properties.$window_id}`:"")}:{}),(null==e?void 0:e.transport)?{transport:e.transport}:{}),P.length?{fireCallbackOnDrop:!0,callback:t=>{if(t.statusCode>=200&&300>t.statusCode)for(const{channel:t,update:i}of P)this.dh(t,i.value)}}:{});if(!this.config.request_batching||e&&!(null==e?void 0:e._batchKey)||(null==e?void 0:e.send_instantly)||P.length){var M;let t;!F.transport&&!F.callback&&_i(null!==(M=this.config.request_headers)&&void 0!==M?M:{})&&this.Cu&&(t="sendBeacon"),this.ju(F,t)}else this.qu.enqueue(F);return v}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null===(i=this.Xu)||void 0===i?void 0:i.getExtension(t)}Zu(){var t;return null!==(t=this.Xu)&&void 0!==t?t:this.Xu=new th(this)}fu(t){this.Eu.push(t);let i=!0;return()=>{if(!i)return;i=!1;const e=this.Eu.indexOf(t);-1!==e&&this.Eu.splice(e,1)}}gh(t=!0){var i,e,s;return!!(null===(i=this.persistence)||void 0===i?void 0:i.consumeCookieIdentityChange())&&(this.Ou=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.Iu.clear(),this.mh()),null===(e=this.featureFlags)||void 0===e||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,e,s,n,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return e;this.persistence.syncCookieProperties(),this.gh();const o=r?void 0:this.persistence.remove_event_timer(t);let l=cs({},e);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this.yu()&&(l[wt]=!0),"$snapshot"===t){const t=cs(cs({},this.persistence.properties()),this.sessionPersistence.properties());return l.distinct_id=t.distinct_id,(!bi(l.distinct_id)&&!xi(l.distinct_id)||yi(l.distinct_id))&&jn.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}const a=function(t,e,s,n=!1){var r,o,l,a;if(!Qt)return{};const h=t?[...Io,...e||[]]:[],[u,d]=Le(Qt),[c,v]=function(t){for(let i=0;qe.length>i;i++){const[e,s,n]=qe[i],r=t.match(e);if(r){const i=n&&t.match(n)||r;return[s,(null==i?void 0:i[1])||""]}}return["",""]}(Qt),f=function(){const t="u">typeof navigator?navigator:void 0;return(null==t?void 0:t.brave)?{brave:!0}:{}}(),p={};mi(s)||(p.detectGoogleSearchApp=s);const g={},_=null===(r=navigator)||void 0===r||null===(r=r.userAgentData)||void 0===r?void 0:r.platform,m=null===(o=navigator)||void 0===o?void 0:o.maxTouchPoints,b=null==qt||null===(l=qt.screen)||void 0===l?void 0:l.width,y=null==qt||null===(a=qt.screen)||void 0===a?void 0:a.height,w=null==qt?void 0:qt.devicePixelRatio;mi(_)||(g.userAgentDataPlatform=_),mi(m)||(g.maxTouchPoints=m),mi(b)||(g.screenWidth=b),mi(y)||(g.screenHeight=y),mi(w)||(g.devicePixelRatio=w);const x=zn(qn({$os:u,$os_version:d,$browser:De(Qt,navigator.vendor,f,p),$webview_app:c,$webview_app_version:v,$device:ze(Qt),$device_type:He(Qt,g),$timezone:Vo(),$timezone_offset:Wo()}),{$current_url:To(n?ts(null==Kt?void 0:Kt.href):null==Kt?void 0:Kt.href,h,Ao),$host:null==Kt?void 0:Kt.host,$pathname:null==Kt?void 0:Kt.pathname,$raw_user_agent:Qt.length>1e3?Qt.substring(0,997)+"...":Qt,$browser_version:Be(Qt,navigator.vendor,f,p),$browser_language:No(),$browser_language_prefix:Lo(),$screen_height:null==qt?void 0:qt.screen.height,$screen_width:null==qt?void 0:qt.screen.width,$viewport_height:null==qt?void 0:qt.innerHeight,$viewport_width:null==qt?void 0:qt.innerWidth,$lib:i.LIB_NAME,$lib_version:i.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return i.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=i.SDK_DIST_CHANNEL),x}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId(r,s.getTime(),!0);l.$session_id=t,l.$window_id=i}this.sessionPropsManager&&zn(l,this.sessionPropsManager.getSessionProps());try{var h;if(this.sessionRecording){const i=this.sessionRecording.sdkDebugProperties,e=!this.Pu&&uh(t);for(const t in i)(e||li(ah,t))&&(l[t]=i[t])}l.$sdk_debug_retry_queue_size=null===(h=this.Bu)||void 0===h?void 0:h.length}catch(t){l.$sdk_debug_error_capturing_properties=String(t)}let u;if(this.requestRouter.region===Na&&(l.$lib_custom_api_host=this.config.api_host),u="$pageview"!==t||r?"$pageleave"!==t||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,n),l=zn(l,u),"$pageview"===t&&Gt&&(l.title=Gt.title),!mi(o)){const t=s.getTime()-o;l.$duration=parseFloat((t/1e3).toFixed(3))}Qt&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),c=this.sessionPersistence.properties(),v=l.$groups,f=d.$groups;gi(v)&&!_i(v)&&(l.$groups=cs(cs({},gi(f)?f:{}),v)),Ln(["$referrer","$referring_domain"],t=>{t in d&&delete c[t]});const p={};if(this.Eu.length>0)for(const t of this.Eu.slice())try{zn(p,t())}catch(t){jn.error("Failed to produce browser extension event properties",t)}l=zn({},a,d,c,cs(cs({},p),l)),l.$is_identified=this._isIdentified(),fi(this.config.property_denylist)?Ln(this.config.property_denylist,function(t){delete l[t]}):jn.error(lh+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const g=this.config.sanitize_properties;g&&(jn.error(oh),l=g(l,t));const _=this.yh();return l.$process_person_profile=_,_&&!r&&this.bh("_calculate_event_properties"),l}ph(t,i=!0,e=!1){var s;if(!this.persistence||!this.yh())return t;if(this.Tu&&!e)return t;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=zn({},n,r||{},t||{});const l=this.config.sanitize_properties;return l&&(jn.error(oh),o=l(o,"$set_once")),i&&(this.Tu=!0),_i(o)?void 0:o}register(t,i){var e;null===(e=this.persistence)||void 0===e||e.register(t,i)}register_once(t,i,e){var s;null===(s=this.persistence)||void 0===s||s.register_once(t,i,e)}register_for_session(t){var i,e;null===(i=this.persistence)||void 0===i||i.syncCookieProperties(),this.gh(),null===(e=this.sessionPersistence)||void 0===e||e.register(t),Object.keys(t).forEach(t=>this.Iu.add(t)),this.mh()}unregister(t){var i;null===(i=this.persistence)||void 0===i||i.unregister(t)}unregister_for_session(t){var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t),this.Iu.delete(t),this.mh()}_h(t,i){this.register({[t]:i})}Hu(){this.Iu.forEach(t=>{var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t)}),this.Iu.clear(),this.mh()}mh(){var t;if(!this.Mu)return;if("memory"===this.config.persistence||(null===(t=this.sessionPersistence)||void 0===t?void 0:t.hi)||!xr.Et())return void xr.Lt(this.Mu);const i=[];this.Iu.forEach(t=>i.push(t)),i.length>0?xr.$t(this.Mu,i):xr.Lt(this.Mu)}getFeatureFlag(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,s;return null!==(e=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null===(t=this.featureFlags)||void 0===t||t.reloadFeatureFlags()}updateFlags(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i=!1,e){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.du.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:rh}),()=>{})}onSessionId(t){var i,e;return null!==(i=null===(e=this.sessionManager)||void 0===e?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:rh})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:rh})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:rh}),()=>{})}renderSurvey(t,i){var e;null===(e=this.surveys)||void 0===e||e.renderSurvey(t,i)}displaySurvey(t,i=Ga){var e;null===(e=this.surveys)||void 0===e||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null===(i=this.surveys)||void 0===i||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null===(e=this.surveys)||void 0===e?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:rh}}canRenderSurveyAsync(t,i=!1){var e,s;return null!==(e=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:rh})}wh(t){return!t||yi(t)?(jn.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(jn.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(jn.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return jn.uninitializedWarning("posthog.identify");if(xi(t)&&(t=t.toString(),jn.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.wh(t))return;if(!this.bh("posthog.identify"))return;this.ku();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.gh(!1),o=this.persistence.Oa();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),t!==s&&t!==this.get_property("__alias")&&(this.unregister(l),this.register({distinct_id:t}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Rt,u=t!==s,d=!u&&o;if(u&&o){var h;const n=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:s};this.persistence.set_property(vt,Dt),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",n,{$set:i||{},$set_once:e||{}})&&(this.Ou=Ba(t,i,e)),null===(h=this.featureFlags)||void 0===h||h.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(d){this.persistence.set_property(vt,Dt);const s=i||{},n=e||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:s,$set_once:n})&&(this.Ou=Ba(t,i,e))}else(i||e)&&this.setPersonProperties(i,e);u||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ht)):d&&(i||e)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.qa(a)}}setPersonProperties(t,i){if(!t&&!i)return;if(!this.bh("posthog.setPersonProperties"))return;const e=Ba(this.get_distinct_id(),t,i);this.Ou!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}})&&(this.Ou=e)):jn.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;const e=(fi(t)?t:[t]).filter(t=>bi(t)&&t.length>0);0!==e.length&&this.bh("posthog.unsetPersonProperties")&&(null===(i=this.featureFlags)||void 0===i||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.Ou=null)}group(t,i,e){var s;if(!t||!i)return void jn.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.gh();const n=this.getGroups(),r=n[t]!==i;if(r&&this.resetGroupPropertiesForFlags(t),this.register({$groups:cs(cs({},n),{},{[t]:i})}),(r||e)&&this.yh()){const s={$group_type:t,$group_key:i};e&&(s.$group_set=e),this.capture(Ut,s)}e&&this.setGroupPropertiesForFlags({[t]:e}),r&&!e&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var e;null===(e=this.featureFlags)||void 0===e||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var e;this.bh("posthog.setGroupPropertiesForFlags")&&(null===(e=this.featureFlags)||void 0===e||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null===(i=this.featureFlags)||void 0===i||i.resetGroupPropertiesForFlags(t)}reset(t){const i=ki(t)?t:null==t?void 0:t.resetDeviceID,e=ki(t)||null==t?void 0:t.bootstrap;this.kh(i,!1,e)}kh(t,i=!1,e){var s,n,l,a,h,u;if(jn.info("reset"),!this.__loaded)return jn.uninitializedWarning("posthog.reset");const d=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null===(s=this.Lu)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(l=n.updateConfig)||void 0===l||l.call(n,this.config,this.il());const c=this.get_property(r),v=this.get_property(o),f=this.get_property(k);null===(a=this.sessionRecording)||void 0===a||a.flushBeforeIdentityReset();const p=this.is_capturing();this.consent.reset(),i||!p||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const g=null===(h=this.persistence)||void 0===h||null===(u=h.Oa)||void 0===u?void 0:u.call(h);let _=!1;try{var m,b,y,w,x,S,E,P,T,C,F,M,I;if(null===(m=this.persistence)||void 0===m||m.clear(),null===(b=this.sessionPersistence)||void 0===b||b.clear(),this.Iu.clear(),this.mh(),mi(f)||null===(C=this.persistence)||void 0===C||C.register({$session_recording_remote_config:f}),null===(y=this.surveys)||void 0===y||y.reset(),null===(w=this.featureFlags)||void 0===w||w.reset(),null===(x=this.conversations)||void 0===x||x.reset(),null===(S=this.logs)||void 0===S||S.reset(),null===(E=this.metrics)||void 0===E||E.reset(),null===(P=this.persistence)||void 0===P||P.set_property("$user_state","anonymous"),null===(T=this.sessionManager)||void 0===T||T.resetSessionId(),this.Ou=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:yt,$device_id:null},"");else{const i=this.config.get_device_id(er());this.register_once({distinct_id:i,$device_id:t?i:c},""),t||mi(v)||this.register({[o]:v})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(e.distinctID&&!this.yu()&&(null===(I=this.persistence)||void 0===I||I.set_property("$user_state",e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:e.distinctID})),null===(F=this.featureFlags)||void 0===F||F.initialize(),!$i(d)&&!(null===(M=this.sessionManager)||void 0===M?void 0:M.setBootstrapSessionId(d,!0))){const t=cs({},e);delete t.sessionID,this.config.bootstrap=t}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var O,A;g&&(null===(O=this.persistence)||void 0===O||null===(A=O.qa)||void 0===A||A.call(O,_))}this.reloadFeatureFlags()}shutdown(t){var i=this;return ji(function*(){var t,e,s,n,r,o,l,a;if(i.__loaded){i.$u=!0,i.Zu().dispose(),null===(t=i.sessionRecording)||void 0===t||t.dispose(),null===(e=i.logs)||void 0===e||e.flushLogs("sendBeacon"),null===(s=i.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=i.metrics)||void 0===n||n.dispose(),null===(r=i.qu)||void 0===r||r.unload(),null===(o=i.Bu)||void 0===o||o.unload();try{var h;null===(h=i.featureFlags)||void 0===h||h.destroy()}catch(t){jn.error("Error while destroying feature flags",t)}null===(l=i.persistence)||void 0===l||l.destroy(),null===(a=i.sessionPersistence)||void 0===a||a.destroy()}else jn.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null===(e=this.conversations)||void 0===e||e.Sh()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(t=this.conversations)||void 0===t||t.xh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:i,sessionStartTimestamp:e}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if((null==t?void 0:t.withTimestamp)&&e){var n;const i=null!==(n=t.timestampLookBack)&&void 0!==n?n:10;if(!e)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-e)/1e3)-i,0)}`}return s}alias(t,i){return t===this.get_property("$people_distinct_id")?(jn.critical("Attempting to create alias for existing People user - aborting."),-2):this.bh("posthog.alias")?(mi(i)&&(i=this.get_distinct_id()),t!==i?(this._h(l,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(jn.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const i=cs({},this.config);if(gi(t)){var s,n,r,o,l,a,h,u,d,c,v,f,p,g;zn(this.config,bh(t));const m=this.Su();null===(s=this.persistence)||void 0===s||s.update_config(this.config,i,m),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new rl(cs(cs({},this.config),{},{persistence:"sessionStorage"}),m,!1);const b=this.Du(this.config.debug);var _;ki(b)&&(this.config.debug=b),ki(this.config.debug)&&(this.config.debug?(e.DEBUG=!0,hr.Et()&&hr.$t("ph_debug",!0),jn.info("set_config",{config:t,oldConfig:i,newConfig:cs({},this.config)})):(e.DEBUG=!1,hr.Et()&&hr.Lt("ph_debug"))),null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.il()),null===(o=this.exceptionObserver)||void 0===o||o.onConfigChange(),null===(l=this.exceptions)||void 0===l||l.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(h=this.sessionRecording)||void 0===h||h.startIfEnabledOrStop(),null===(u=this.tracingHeaders)||void 0===u||u.startIfEnabledOrStop(),null===(d=this.autocapture)||void 0===d||d.startIfEnabled(),null===(c=this.heatmaps)||void 0===c||c.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null===(_=this.historyAutocapture)||void 0===_||_.startIfEnabledOrStop()),null===(v=this.exceptionObserver)||void 0===v||v.startIfEnabledOrStop(),null===(f=this.deadClicksAutocapture)||void 0===f||f.startIfEnabledOrStop(),null===(p=this.surveys)||void 0===p||p.loadIfEnabled(),this.xu(),null===(g=this.externalIntegrations)||void 0===g||g.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&go(this,sh,!1)}}_overrideSDKInfo(t,i){e.LIB_NAME=t,e.LIB_VERSION=i}startSessionRecording(t){const i=!0===t,e={sampling:i||!!(null==t?void 0:t.sampling),linked_flag:i||!!(null==t?void 0:t.linked_flag),url_trigger:i||!!(null==t?void 0:t.url_trigger),event_trigger:i||!!(null==t?void 0:t.event_trigger)};var s,n,r,o,l;Object.values(e).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),e.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),e.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),e.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),e.event_trigger&&(null===(l=this.sessionRecording)||void 0===l||l.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(null===(t=this.sessionRecording)||void 0===t?void 0:t.started)}captureException(t,i){try{if(!this.exceptions)return;const e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(cs(cs({},e),i))}catch(t){return}}addExceptionStep(t,i){var e;null===(e=this.exceptions)||void 0===e||e.addExceptionStep(t,i)}captureLog(t){var i;null===(i=this.logs)||void 0===i||i.captureLog(t)}get logger(){var i,e;return null!==(i=null===(e=this.logs)||void 0===e?void 0:e.logger)&&void 0!==i?i:t.Ch}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null===(e=this.toolbar)||void 0===e?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null===(i=this.persistence)||void 0===i?void 0:i.props[t]}getSessionProperty(t){var i;return null===(i=this.sessionPersistence)||void 0===i?void 0:i.props[t]}toString(){var t;let i=null!==(t=this.config.name)&&void 0!==t?t:ph;return i!==ph&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))||"identified"===(null===(i=this.sessionPersistence)||void 0===i?void 0:i.get_property("$user_state"))}yh(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&_i(this.getGroups())&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.__alias)&&!(null===(i=this.persistence)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.$epp))}ih(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.yh()||this.bh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}bh(t){return"never"===this.config.person_profiles?(jn.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bu(),this._h(bt,!0),!0)}Su(){if("always"===this.config.cookieless_mode)return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}xu(){var t,i;const e=this.Su();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.$h(),(null===(t=this.persistence)||void 0===t?void 0:t.hi)!==e&&(null===(n=this.persistence)||void 0===n||n.set_disabled(e)),(null===(i=this.sessionPersistence)||void 0===i?void 0:i.hi)!==e&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(e)),e&&(this.Iu.clear(),this.mh()),e}opt_in_capturing(i){var e;if("always"!==this.config.cookieless_mode){if(this.yu()){var s,n,r,o,l,a;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.kh(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Ca(this),this.pageViewManager=new yo(this),this.persistence&&(this.sessionPropsManager=new ka(this,this.sessionManager,this.persistence));const i=null!==(o=null===(l=this.config.__extensionClasses)||void 0===l?void 0:l.sessionRecording)&&void 0!==o?o:null===(a=t.__defaultExtensionClasses)||void 0===a?void 0:a.sessionRecording;var h,u;i&&(this.sessionRecording=this.mu(this.sessionRecording,new i(this)),this.cu&&(null===(h=this.sessionRecording)||void 0===h||null===(u=h.onRemoteConfig)||void 0===u||u.call(h,this.cu)))}var d,c;this.consent.optInOut(!0),this.xu(),this.Yu(),null===(e=this.sessionRecording)||void 0===e||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(mi(null==i?void 0:i.captureEventName)||(null==i?void 0:i.captureEventName))&&this.capture(null!==(c=null==i?void 0:i.captureEventName)&&void 0!==c?c:"$opt_in",null==i?void 0:i.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.th()}else jn.warn(nh)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void jn.warn(nh);const t="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var i,e;null==t||t.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.kh(!0,!0),this.consent.optInOut(!1),this.xu(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:yt,$device_id:null}),this.gu(t),this.sessionRecording=void 0,null===(i=this.sessionManager)||void 0===i||i.destroy(),null===(e=this.pageViewManager)||void 0===e||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.th(),this.Yu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.xu()}_is_bot(){return Wt?Fa(Wt,this.config.custom_blocked_useragents):void 0}th(){Gt&&("visible"===Gt.visibilityState?this.Ru||(this.Ru=!0,this.capture(Lt,{title:Gt.title},{send_instantly:!0}),this.Au&&(Gt.removeEventListener(Bt,this.Au),this.Au=null)):this.Au||(this.Au=this.th.bind(this),Kn(Gt,Bt,this.Au)))}debug(t){!1===t?(null==qt||qt.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==qt||qt.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}il(){const t=this.Lu||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(jn.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(t,i,e,s,n){const r=i in t&&!$i(t[i]),o=e in t&&!$i(t[e]);return r?t[i]:!!o&&(n&&n.warn(`Config field '${e}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,jn)}Os(t){var i;if($i(this.config.before_send))return t;const e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(Pi),s=fi(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const i of s)try{if(n=i(n),$i(n)){const i=`Event '${t.event}' was rejected in beforeSend function`;return Ei(t.event)?jn.warn(`${i}. This can cause unexpected behavior.`):jn.info(i),null}n.properties&&!_i(n.properties)||jn.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(i){return jn.error(`Error in beforeSend function for event '${t.event}':`,i),null}for(const i of e)if(n.properties&&$i(n.properties[i]))return jn.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return null===(t=this.pageViewManager.Wo)||void 0===t?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Du(t){const i=ki(t)&&!t,e=hr.Et()&&"true"===hr.Ot("ph_debug");return!i&&(!!e||t)}};wh.__defaultExtensionClasses={},wh.Ch=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(let e=0;i.length>e;e++)t.prototype[i[e]]=Un(t.prototype[i[e]])}(wh,["identify"]);var $h=class{constructor(t){this.disabled=!1===t;const i=gi(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(t-s.x)+Math.abs(i-s.y)<this.thresholdPx&&this.timeoutMs>e-s.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}};const xh="$copy_autocapture",Sh=Bn("[AutoCapture]");function kh(t,i){return i.length>t?i.slice(0,t)+"...":i}function Eh(t){if(t.previousElementSibling)return t.previousElementSibling;let i=t;do{i=i.previousSibling}while(i&&!Pr(i));return i}function Ph(t,{e:i,maskAllElementAttributes:e,maskAllText:s,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var l,a;if(!Pr(t))return{props:{}};const h=[t],u=new Set([t]);let d=t;for(;d.parentNode&&!Tr(d,"body")&&1e3>h.length;){if(Fr(d.parentNode)){const t=d.parentNode.host;if(u.has(t))break;u.add(t),h.push(t),d=t;continue}if(!Pr(d.parentNode))break;if(u.has(d.parentNode))break;u.add(d.parentNode),h.push(d.parentNode),d=d.parentNode}const c="click"===i.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?h.findIndex(t=>Tr(t,"button")||Tr(t,"a")):-1;c>0&&(s=s||h.slice(0,c+1).some(t=>!Yr(t)||Xr(t)));const v=[],f={};let p,g=!1,_=!1;if(Ln(h,t=>{const i=Yr(t);if(Tr(t,"a")&&!e&&!(null==n?void 0:n.includes("href"))){const e=t.getAttribute("href");g=!!(i&&e&&ro(e))&&(o?ts(e):e)}li(Or(t),"ph-no-capture")&&(_=!0),v.push(function(t,i,e,s,n=!1){const r=t.tagName.toLowerCase(),o={tag_name:r};jr.indexOf(r)>-1&&!e&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?kh(1024,oo(t)):kh(1024,Rr(t)));const l=Or(t);i||(null==s?void 0:s.includes("class"))||0>=l.length||(o.classes=l.filter(function(t){return""!==t})),Ln(t.attributes,function(e){var r;if((!Xr(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&!(null==s?void 0:s.includes(e.name))&&!i&&ro(e.value)&&(!bi(r=e.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let t=e.value;"class"===e.name&&(t=Mr(t).join(" ")),o["attr__"+e.name]=kh(1024,"href"===e.name&&n?ts(t):t)}});let a=1,h=1,u=t;for(;u=Eh(u);)a++,u.tagName===t.tagName&&h++;return o.nth_child=a,o.nth_of_type=h,o}(t,e,s,n,o)),Ln(function(t){if(!Yr(t))return{};const i={};return Ln(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){const e=t.name.replace("data-ph-capture-attribute-",""),s=t.value;e&&s&&ro(s)&&(i[e]=s)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(f,i)||(f[i]=t)})}),_)return{props:{},explicitNoCapture:_};if(c>0&&(t=h[c],v.splice(0,c)),s||(v[0].$el_text=Tr(t,"a")||Tr(t,"button")?oo(t):Rr(t)),g){var m,b;v[0].attr__href=g;const t=null===(m=Eo(g))||void 0===m?void 0:m.host,i=null==qt||null===(b=qt.location)||void 0===b?void 0:b.host;t&&i&&t!==i&&(p=g)}return{props:zn((w=i.type,{$event_type:w,$ce_version:1}),r?{}:{$elements:v},{$elements_chain:(y=v,fi(y)?function(t){return t.map(t=>{var i,e;let s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class){t.attr_class.sort();for(const i of t.attr_class)s+=`.${i.replace(/"/g,"")}`}const n=cs(cs(cs(cs({},t.text?{text:t.text}:{}),{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{}),t.attr_id?{attr_id:t.attr_id}:{}),t.attributes),r={};return Hn(n).sort(([t],[i])=>function(t,i){return i>t?-1:t>i?1:0}(t,i)).forEach(([t,i])=>r[ao(t.toString())]=ao(i.toString())),s+=":",s+=Hn(r).map(([t,i])=>`${t}="${i}"`).join(""),s}).join(";")}(function(t){return t.map(t=>{var i,e;const s={text:null===(i=t.$el_text)||void 0===i?void 0:i.slice(0,400),tag_name:t.tag_name,href:null===(e=t.attr__href)||void 0===e?void 0:e.slice(0,2048),attr_class:ho(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Hn(t).filter(([t])=>0===t.indexOf("attr__")).forEach(([t,i])=>s.attributes[t]=i),s})}(y)):"")},(null===(l=v[0])||void 0===l?void 0:l.$el_text)?{$el_text:null===(a=v[0])||void 0===a?void 0:a.$el_text}:{},p&&"click"===i.type?{$external_click_url:p}:{},f),target:t};var y,w}var Th=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(t){var i;if(!Yr(t))return!0;const e=null!==(i=this.mo().css_selector_ignorelist)&&void 0!==i?i:zr,s=new Set;let n=t;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const t=n,i=Or(t);if(li(i,"ph-no-capture")||li(i,"ph-sensitive")||Xr(t)||e.some(i=>Br(t,i)))return!0;const r=n.parentNode;n=Fr(r)?r.host:r&&Pr(r)?r:null}return!1}yo(t){if(!this.isEnabled||"pointercancel"===t.type)return void this.do();if("pointerdown"===t.type){this.do();const e=Dr(t);var i;return void(t.isPrimary&&0===t.button&&!t.ctrlKey&&e&&Pr(e)&&(this.vo={target:e,excluded:this.po(e),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null===(i=this.bo)||void 0===i?void 0:i.distinctId}))}const e=this.vo;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.do():"pointerup"===t.type&&(e.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(t){var i;const e=this.vo;this.do();const s=Dr(t);if((null==e?void 0:e.released)&&e.target.isConnected&&e.distinctId===(null===(i=this.bo)||void 0===i?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&s&&(Tr(s,"html")||Tr(s,"body"))){var n;if(e.excluded)return null;const t=null!==(n=this.mo().css_selector_ignorelist)&&void 0!==n?n:zr;return[s,null==Gt?void 0:Gt.documentElement,null==Gt?void 0:Gt.body].some(i=>{if(!i)return!1;const e=Or(i);return li(e,"ph-no-capture")||li(e,"ph-sensitive")||!Yr(i)||Xr(i)||t.some(t=>Br(i,t))})?null:e.target}}constructor(t){this.wo=t,this.name="autocapture",this.ko=!1,this.So=null,this.xo=!1,this.Co=new Map,this.$o=!1,this.Ir={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Ir),this.rageclicks=new $h(this.Ir.rageclick),this.Io=null}setup(t){this.Mo(),this.bo=t;const i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?i.dispose():(this.Eo=i,this.startIfEnabled())}dispose(){var t;this.To||(this.To=!0,this.bo=void 0,null===(t=this.Eo)||void 0===t||t.dispose(),this.Eo=void 0,this.Co.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Ir),this.Ir}Mo(){var t,i;return this.mo(),this.Ir.url_allowlist=null===(t=this.Ir.url_allowlist)||void 0===t?void 0:t.map(t=>new RegExp(t)),this.Ir.url_ignorelist=null===(i=this.Ir.url_ignorelist)||void 0===i?void 0:i.map(t=>new RegExp(t)),this.Ir}Ro(){if(!this.isBrowserSupported())return void Sh.info("Disabling Automatic Event Collection because this browser is not supported");if(!qt||!Gt)return;const t=this.Ao=t=>{t=t||(null==qt?void 0:qt.event);try{if("blur"===t.type)return void this.do();if(0===t.type.indexOf("pointer"))return void this.yo(t);const i="click"===t.type?this._o(t):void 0;if(wi(i))return;this.Fo(t,"$autocapture",i)}catch(t){Sh.error("Failed to capture event",t)}};if(Kn(qt,"blur",t),Kn(Gt,"submit",t,{capture:!0}),Kn(Gt,"change",t,{capture:!0}),Kn(Gt,"click",t,{capture:!0}),Ln(["pointerdown","pointermove","pointerup","pointercancel"],i=>{Kn(Gt,i,t,{capture:!0})}),this.mo().capture_copied_text){const t=this.Oo=t=>{t=t||(null==qt?void 0:qt.event);try{this.Fo(t,xh)}catch(t){Sh.error("Failed to capture clipboard event",t)}};Kn(Gt,"copy",t,{capture:!0}),Kn(Gt,"cut",t,{capture:!0}),Kn(Gt,"paste",t,{capture:!0})}}Po(){this.do(),this.Ao&&(null==qt||qt.removeEventListener("blur",this.Ao),Ln(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==Gt||Gt.removeEventListener(t,this.Ao,!0)}),null==Gt||Gt.removeEventListener("submit",this.Ao,!0),null==Gt||Gt.removeEventListener("change",this.Ao,!0),null==Gt||Gt.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(null==Gt||Gt.removeEventListener("copy",this.Oo,!0),null==Gt||Gt.removeEventListener("cut",this.Oo,!0),null==Gt||Gt.removeEventListener("paste",this.Oo,!0),this.Oo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(t){if(this.To)return;if(this.xo=!0,!t.ok)return void this.startIfEnabled();const i=t.config;i.elementsChainAsString&&(this.$o=i.elementsChainAsString);const e=i.autocapture_opt_out;var s;ki(e)&&(null===(s=this.bo)||void 0===s||s.kv.set("$autocapture_disabled_server_side",e),this.So=e),this.startIfEnabled()}setElementSelectors(t,i=this){if(this.To)return;t.size?this.Co.set(i,new Set(t)):this.Co.delete(i);const e=new Set;this.Co.forEach(t=>{t.forEach(t=>e.add(t))}),this.Io=e}getElementSelectors(t,i){var e;const s=[];return null===(e=this.Io)||void 0===e||e.forEach(e=>{const n=null==Gt?void 0:Gt.querySelectorAll(e);null==n||n.forEach(n=>{t!==n&&i!==n||li(s,e)||s.push(e)})}),s}get isEnabled(){var t,i;if(this.To)return!1;const e=null===(t=this.bo)||void 0===t?void 0:t.kv.get(f),s=this.So,n=this.mo();if(!n.remoteRequestsDisabled&&!this.xo)return!1;const r=n.remoteRequestsDisabled&&!this.xo;if(wi(s)&&!ki(e)&&!r)return!1;const o=null!==(i=this.So)&&void 0!==i?i:!!e;return!!n.enabled&&!o}Fo(t,i="$autocapture",e){if(!this.isEnabled)return void this.do();let s=e||Dr(t);Cr(s)&&(s=s.parentNode||null);const n=this.Mo();var r;"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&n.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime()))&&Gr(s,n.rageclick)&&this.Fo(t,"$rageclick",e);const o=i===xh,l=o?cs(cs({},n),{},{dom_event_allowlist:void 0}):n;if(s&&function(t,i,e,s,n,r){var o;if(!qt||Kr(t))return!1;if((null==e?void 0:e.url_allowlist)&&!Ir(e.url_allowlist,r))return!1;if((null==e?void 0:e.url_ignorelist)&&Ir(e.url_ignorelist,r))return!1;if(null==e?void 0:e.dom_event_allowlist){const t=e.dom_event_allowlist;if(t&&!t.some(t=>i.type===t))return!1}const{parentIsUsefulElement:l,targetElementList:a}=Jr(t,s);if(!function(t,i){const e=null==i?void 0:i.element_allowlist;if(mi(e))return!0;for(const i of t)if(e.some(t=>i.tagName.toLowerCase()===t))return!0;return!1}(a,e))return!1;if(!Nr(a,null==e?void 0:e.css_selector_allowlist))return!1;if(Nr(a,null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:zr))return!1;try{const e=qt.getComputedStyle(t);if(e&&"pointer"===e.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}const h=t.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return l?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(jr.indexOf(h)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var a;const{props:e,explicitNoCapture:r,target:o}=Ph(s,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.$o,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(r)return!1;const l=this.getElementSelectors(s,o);if(l&&l.length>0&&(e.$element_selectors=l),i===xh){const i=t.type||"clipboard";if("paste"!==i){var h,u;const t=null==qt||null===(h=qt.getSelection())||void 0===h?void 0:h.toString(),i=Ar(t);if(!i)return!1;e.$selected_content=i,e.$clipboard_text_length=null!==(u=null==t?void 0:t.length)&&void 0!==u?u:0}e.$copy_type=i}return null===(a=this.bo)||void 0===a||a.capture(i,e),!0}}isBrowserSupported(){return pi(null==Gt?void 0:Gt.querySelectorAll)}},Ch=class{constructor(t){this._instance=t}refresh(t){const i=this._instance.config,e=gi(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.il(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}};const Fh=Bn("[ExceptionAutocapture]"),Mh=()=>{},Ih=t=>{var i;if(pi(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function Oh(t,i,e){try{if(!(i in t))return Mh;const s={next:t[i]},n=e(function(...t){return s.next.apply(this,t)});return pi(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),t[i]=n,()=>{if(t[i]===n)return void(t[i]=s.next);let e=t[i],r=Ih(e);for(;r;){if(r.next===n)return void(r.next=s.next);e=r.next,r=Ih(e)}}}catch(t){return Mh}}const Ah=Bn("[TracingHeaders]"),Rh=Bn("[Web Vitals]"),Dh=9e5,jh=["CLS","FCP","INP","LCP"],Bh=["INP","LCP"],Nh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Lh="disabled",zh="lazy_loading",Hh=Bn("[SessionRecording]"),Uh=[St,kt,Et,Pt,Tt,Ct,Ft,Mt,It],qh=Bn("[Heatmaps]");function Vh(t){return gi(t)&&"clientX"in t&&"clientY"in t&&xi(t.clientX)&&xi(t.clientY)}const Wh=Bn("[Product Tours]"),Gh=t=>{var i;return!t.config.disable_product_tours&&!!(null===(i=t.persistence)||void 0===i?void 0:i.get_property(w))},Kh=["$set_once","$set"],Jh=Bn("[SiteApps]"),Yh="Error while initializing PostHog app with config id ",Xh=(t,i)=>(null==t?void 0:t.then)?t.then(i):i(t),Zh="SDK is not enabled or survey functionality is not yet loaded",Qh="Disabled. Not loading surveys.";var tu=class{constructor(t,i){this.wo=t,this.Th=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Ih=!1,this.Mh=!1,this.Eh=[],this.Ph=[],this.Rh=null,this.Ah=null,this.To=!1,this.Fh=new Set,this.onRemoteConfig=t=>{if(this.To)return;if(this.Ir.disableSurveys)return;if(!t.ok)return this.Mh=!0,this.Oh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),qa.warn("Remote config unavailable. Not loading surveys.");const i=t.config.surveys;if($i(i))return qa.warn("Flags not loaded yet. Not loading surveys.");this.Dh=ki(i)?i:i.length>0,qa.info(`flags response received, isSurveysEnabled: ${this.Dh}`),this.loadIfEnabled()},this.Oh=t=>{this.Ph.slice().forEach(i=>this.Lh(i,t))}}setup(t){if(!this.To)return this.Nh=t,Xh(t.kv.initialize(),()=>{if(this.Nh!==t||this.To)return;this.Nh=void 0,this.bo=t;const i=t.onRemoteConfig(this.onRemoteConfig);this.To?i.dispose():(this.Eo=i,this.loadIfEnabled())})}dispose(){var t,i,e,s,n;this.To||(this.To=!0,this.Nh=void 0,this.bo=void 0,null===(t=this.Eo)||void 0===t||t.dispose(),this.Eo=void 0,null===(i=this._surveyEventReceiver)||void 0===i||i.dispose(),this._surveyEventReceiver=null,null===(e=this._surveyManager)||void 0===e||null===(s=e.dispose)||void 0===s||s.call(e),this._surveyManager=null,this.Eh=[],this.Ph.forEach(t=>{t.active=!1}),this.Ph=[],null===(n=this.qh)||void 0===n||n.call(this),this.qh=void 0,this.Rh=null,this.Fh.forEach(t=>clearTimeout(t)),this.Fh.clear())}get Ir(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.clearInMemoryInProgressSurveyState)||void 0===i||i.call(t);try{var e;null===(e=this._surveyEventReceiver)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let i=0;i<localStorage.length;i++){const e=localStorage.key(i);((null==e?void 0:e.startsWith("seenSurvey_"))||(null==e?void 0:e.startsWith("inProgressSurvey_")))&&t.push(e)}t.forEach(t=>localStorage.removeItem(t))}catch(t){}this.Oh()}loadIfEnabled(){if(this.To||!this.bo)return;const t=this.Ir;if(this._surveyManager)return;if(this.Ih)return void qa.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void qa.info(Qh);if(t.cookielessMode&&this.wo.isOptedOut())return void qa.info("Not loading surveys in cookieless mode without consent.");const i=this.wo.getExtensions();if(!i)return void this.jh("PostHog Extensions not found.");if(mi(this.Dh)&&!t.advancedEnableSurveys)return;const e=this.Dh||t.advancedEnableSurveys;this.Ih=!0,this.Mh=!1;try{const t=i.generateSurveys;if(t)return this.Bh(t,e),void(this.Ih=!1);const s=i.loadExternalDependency;if(!s)return this.jh(At),void(this.Ih=!1);s(t=>{try{if(this.To)return;const i=this.wo.getExtensions();t||!(null==i?void 0:i.generateSurveys)?this.jh("Could not load surveys script",t):this.Bh(i.generateSurveys,e)}finally{this.Ih=!1}})}catch(t){throw this.Ih=!1,this.jh("Error initializing surveys",t),t}}Bh(t,i){var e,s;if(this.To)return;this._surveyManager=t(i),this._surveyEventReceiver=this.wo.createEventReceiver(this.Oh);const n=null===(e=null!==(s=this.bo)&&void 0!==s?s:this.Th)||void 0===e?void 0:e.kv.get(X);n&&this.Hh(n),qa.info("Surveys loaded successfully"),this.zh(),this.Oh(),this.Uh({isLoaded:!0})}jh(t,i){this.Mh=!0,qa.error(t,i),this.Oh({isLoaded:!1,error:t}),this.Uh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Eh.push(t),this._surveyManager&&this.Uh({isLoaded:!0}),()=>{this.Eh=this.Eh.filter(i=>i!==t)}}getSurveys(t,i=!1){var e;const s=null!==(e=this.bo)&&void 0!==e?e:this.Th;if(!s||this.To)return;if(this.Ir.disableSurveys)return qa.info(Qh),t([]);const n=s.kv.get(X);if(n&&!i)return t(n,{isLoaded:!0}),void(this.Wh()&&this.getSurveys(()=>{},!0));if(this.Rh)return void this.Rh.then(({surveys:i,context:e})=>{this.To||t(i,e)}).catch(t=>qa.error("Error in survey callback",t));const r=this.Vh("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Ir.requestTimeoutMs}).then(t=>{try{return this.Gh(s,t)}catch(t){return qa.error("Error processing surveys response",t),this.Gh(s,{statusCode:0,error:t})}},t=>this.Gh(s,{statusCode:0,error:t}));this.Rh=r;const o=()=>{this.Rh===r&&(this.Rh=null)};r.then(i=>{o(),this.To||(this.Oh(i.context),t(i.surveys,i.context))},o).catch(t=>qa.error("Error in survey callback",t))}Vh(t,i){const e=this.bo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(Zh)}))}Gh(t,i){if(this.To)return{surveys:[],context:{isLoaded:!1,error:Zh}};const e=i.statusCode;if(200!==e||!i.json){const t=`Surveys API could not be loaded, status: ${e}`;return 0!==e?qa.error(t):i.error||qa.warn(t),this.Ah=Date.now(),{surveys:[],context:{isLoaded:!1,error:t}}}this.Ah=null;const s=i.json.surveys||[];return t.kv.set({[X]:s,[Z]:Date.now()}),this.Hh(s),{surveys:s,context:{isLoaded:!0}}}Hh(t){var i;const e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Oa(t)||function(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}(t)));null===(i=this._surveyEventReceiver)||void 0===i||i.replace(e)}Wh(){return this.Zh()&&!this.Rh&&!this.Qh()}Zh(){var t,i;const e=null===(t=null!==(i=this.bo)&&void 0!==i?i:this.Th)||void 0===t?void 0:t.kv.get(Z);return xi(e)&&Date.now()-e>3e5}Qh(){return xi(this.Ah)&&3e5>Date.now()-this.Ah}markSurveyAsSeen(t,i){var e;const s={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};Va(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Oh()}Uh(t){for(const i of this.Eh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){qa.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i=!1){if(!$i(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);qa.warn("init was not called")}onActiveMatchingSurveysChanged(t){var i,e;if(this.To)return()=>{};const s={callback:t,active:!0,revision:0};this.Ph.push(s),this.zh();const n=null===(i=null!==(e=this.bo)&&void 0!==e?e:this.Th)||void 0===i?void 0:i.kv.get(X);return this.Ir.disableSurveys||!this._surveyManager&&this.Mh&&!this.Ih||!n&&!$i(this.Ah)&&!this.Rh?this.Lh(s,{isLoaded:!1}):this._surveyManager&&this.Lh(s),()=>{var t;s.active=!1,this.Ph=this.Ph.filter(t=>t!==s),0===this.Ph.length&&(null===(t=this.qh)||void 0===t||t.call(this),this.qh=void 0)}}zh(){var t,i,e;this._surveyManager&&this.Ph.length>0&&(null!==(t=this.qh)&&void 0!==t||(this.qh=null===(i=(e=this.wo).onMatchingConditionsChanged)||void 0===i?void 0:i.call(e,this.Oh)))}Lh(t,i){if(this.To||!t.active)return;const e=++t.revision,s=s=>{if(!this.To&&t.active&&e===t.revision)try{const e=null!=i?i:{isLoaded:!0},n=JSON.stringify([s,e]);if(n===t.lastResult)return;t.lastResult=n,t.callback(s,e)}catch(t){qa.error("Error in active matching surveys callback",t)}};try{i&&!i.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(t){qa.error("Error in active matching surveys callback",t)}}Jh(t){let i=null;return this.getSurveys(e=>{var s;i=null!==(s=e.find(i=>i.id===t))&&void 0!==s?s:null}),i}Kh(t){if($i(this._surveyManager))return{eligible:!1,reason:Zh};const i="string"==typeof t?this.Jh(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Xh(t){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if($i(this._surveyManager))return{eligible:!1,reason:Zh};const i="string"==typeof t?this.Jh(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if($i(this._surveyManager))return qa.warn("init was not called"),{visible:!1,disabledReason:Zh};const i=this.Xh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return $i(this._surveyManager)?(qa.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Zh})):new Promise(e=>{this.getSurveys(i=>{var s;const n=null!==(s=i.find(i=>i.id===t))&&void 0!==s?s:null;if(n){const t=this.Xh(n);e({visible:t.eligible,disabledReason:t.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var s;if(!this.wo.isCapturing())return;if($i(this._surveyManager))return void qa.warn("init was not called");const n="string"==typeof t?this.Jh(t):t;if(!(null==n?void 0:n.id))return void qa.warn("Survey not found");if(!Wa.includes(n.type))return void qa.warn(`Surveys of type ${n.type} cannot be rendered in the app`);const r=null==Gt?void 0:Gt.querySelector(i);if(r){if(null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds){qa.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);const t=setTimeout(()=>{var i,s;this.Fh.delete(t),!this.To&&this.wo.isCapturing()&&(qa.info(`Rendering survey ${n.id} with delay of ${null===(i=n.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(n,r,e),qa.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.Fh.add(t)}this._surveyManager.renderSurvey(n,r,e)}else qa.warn("Survey element not found")}displaySurvey(t,i){var e;if(!this.wo.isCapturing())return;if($i(this._surveyManager))return void qa.warn("init was not called");const s=this.Jh(t);if(!s)return void qa.warn("Survey not found");let n=s;if((null===(e=s.appearance)||void 0===e?void 0:e.surveyPopupDelaySeconds)&&i.ignoreDelay&&(n=cs(cs({},s),{},{appearance:cs(cs({},s.appearance),{},{surveyPopupDelaySeconds:0})})),i.displayType!==fl&&i.initialResponses&&qa.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){const t=this.Kh(s);if(!t.eligible)return void qa.warn("Survey is not eligible to be displayed: ",t.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}cancelPendingSurvey(t){$i(this._surveyManager)?qa.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t)}};function iu(t,i,e){if($i(t))return!1;switch(e){case"exact":return t===i;case"contains":{const e=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(e,"i").test(t)}case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var eu=class{constructor(t){this._instance=t,this.Yh=new Set,this.tc=new Set,this.ec=new Ea,this.nc=(t,i)=>this.sc(t,i)&&this.rc(t,i)&&this.oc(t,i)&&this.ac(t,i),this.sc=(t,i)=>!(null==i?void 0:i.event)||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;mi(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)||(this.lc=null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t,i;null===(t=this.lc)||void 0===t||t.call(this),this.lc=void 0,null===(i=this._instance)||void 0===i||null===(i=i.autocapture)||void 0===i||i.setElementSelectors(new Set,this),this.ec=new Ea}register(t){var i,e;if(!mi(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Yh.add(t),null===(i=t.steps)||void 0===i||i.forEach(t=>{this.tc.add((null==t?void 0:t.event)||"")})}),null===(e=this._instance)||void 0===e?void 0:e.autocapture)){const t=new Set;this.Yh.forEach(i=>{var e;null===(e=i.steps)||void 0===e||e.forEach(i=>{(null==i?void 0:i.selector)&&t.add(i.selector)})}),this._instance.autocapture.setElementSelectors(t,this)}}replace(t){this.Yh.clear(),this.tc.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.tc.has(t)||this.tc.has(i.event))&&this.Yh.forEach(t=>{this.uc(i,t)&&this.ec.emit("actionCaptured",t.name)})}hc(t){this.onAction("actionCaptured",i=>t(i))}uc(t,i){if(null==(null==i?void 0:i.steps))return!1;for(const e of i.steps)if(this.nc(t,e))return!0;return!1}onAction(t,i){return this.ec.on(t,i)}rc(t,i){if(null==i?void 0:i.url){var e;const s=null==t||null===(e=t.properties)||void 0===e?void 0:e.$current_url;if(!s||"string"!=typeof s)return!1;if(!iu(s,i.url,i.url_matching||"contains"))return!1}return!0}oc(t,i){return!!this.cc(t,i)&&!!this.dc(t,i)&&!!this.vc(t,i)}cc(t,i){var e;if(!(null==i?void 0:i.href))return!0;const s=this.fc(t);if(s.length>0)return s.some(t=>iu(t.href,i.href,i.href_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&iu(function(t){const i=t.match(/(?::|")href="(.*?)"/);return i?i[1]:""}(n),i.href,i.href_matching||"exact")}dc(t,i){var e;if(!(null==i?void 0:i.text))return!0;const s=this.fc(t);if(s.length>0)return s.some(t=>iu(t.text,i.text,i.text_matching||"exact")||iu(t.$el_text,i.text,i.text_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&(r=function(t){const i=[],e=/(?::|")text="(.*?)"/g;let s;for(;!$i(s=e.exec(t));)i.includes(s[1])||i.push(s[1]);return i}(n),o=i.text,l=i.text_matching||"exact",r.some(t=>iu(t,o,l)));var r,o,l}vc(t,i){var e,s;if(!(null==i?void 0:i.selector))return!0;const n=null==t||null===(e=t.properties)||void 0===e?void 0:e.$element_selectors;if(null==n?void 0:n.includes(i.selector))return!0;const r=(null==t||null===(s=t.properties)||void 0===s?void 0:s.$elements_chain)||"";if(i.selector_regex&&r)try{return new RegExp(i.selector_regex).test(r)}catch(t){return!1}return!1}fc(t){var i;return null==(null==t||null===(i=t.properties)||void 0===i?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}ac(t,i){return!(null==i?void 0:i.properties)||0===i.properties.length||ja(i.properties.reduce((t,i)=>{const e=fi(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},su=class{constructor(t,i){var e,s;this.gc=[],this._instance=t,this.mc=i,this.yc=new Map,this.bc=new Map,this._c=new Map,this.wc=null===(e=this._instance)||void 0===e||null===(s=e.onSessionId)||void 0===s?void 0:s.call(e,t=>this.kc(t))}Sc(t){return!1}xc(){return null}Cc(t){}$c(){}Tc(t,i){return!!t&&ja(t.propertyFilters,null==i?void 0:i.properties)}Ic(t,i){const e=new Map;return t.forEach(t=>{var s;null===(s=t.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(i=>{if(null==i?void 0:i.name){const s=e.get(i.name)||[];s.push(t.id),e.set(i.name,s)}})}),e}Mc(t,i,e){const s=(e===al?this.yc:this.bc).get(t);let n=[];return this.Ec(t=>{n=t.filter(t=>null==s?void 0:s.includes(t.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[e])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(i=>i.name===t);return this.Tc(r,i)})}register(t){this.Pc(t,!1)}replace(t){this.Pc(t,!0)}Pc(t,i){var e;mi(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this.Rc(t,i),this.Ac(t,i))}Ac(t,i){const e=t.filter(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length});var s;if(i&&this._c.clear(),0===e.length)return void(i&&(null===(s=this.Fc)||void 0===s||s.replace([])));this.Fc||(this.Fc=new eu(this._instance),this.Fc.init(),this.Fc.hc(t=>this.onAction(t)));const n=[];e.forEach(t=>{var i;null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||i.values.forEach(i=>{if(n.push(i),i.name){var e;const s=null!==(e=this._c.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this._c.set(i.name,s)}})}),i?this.Fc.replace(n):this.Fc.register(n)}Oc(t,i){i.forEach((i,e)=>{var s;const n=null!==(s=t.get(e))&&void 0!==s?s:[];i.forEach(t=>{n.includes(t)||n.push(t)}),t.set(e,n)})}Rc(t,i){var e,s;const n=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.events)&&(null===(e=t.conditions)||void 0===e||null===(e=e.events)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),r=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.cancelEvents)&&(null===(e=t.conditions)||void 0===e||null===(e=e.cancelEvents)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),o=this.Ic(t,al),l=this.Ic(t,hl);i?(this.yc=o,this.bc=l):(this.Oc(this.yc,o),this.Oc(this.bc,l)),(0!==n.length||0!==r.length||t.some(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length}))&&(null!==(e=this.lc)&&void 0!==e||(this.lc=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,s;const n=this.Dc(),r=(null==i||null===(e=i.properties)||void 0===e?void 0:e.$survey_id)||(null==i||null===(s=i.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const e=this.Lc(t,r,i);if("consume"===e)return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.Nc([r]);if("persist"===e)return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.qc(r),void this.jc([r])}if(this.bc.has(t)){const e=this.Mc(t,i,hl);e.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:e.map(t=>t.id)}),this.Nc(e.map(t=>t.id)),e.forEach(t=>this.Bc(t.id)))}if(!this.yc.has(t))return;n.info("event name matched",{event:t,eventPayload:i,items:this.yc.get(t)});const o=this.Mc(t,i,al);this.Hc(o.map(t=>t.id))}onAction(t){this._c.has(t)&&this.Hc(this._c.get(t)||[])}Hc(t){var i,e;if(0===t.length)return;const s=!!(null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i)),n=[];for(const i of t)s&&this.Sc(i)?this.qc(i)&&this.zc(i):n.push(i);n.length>0&&(this.gc=[...new Set([...this.gc,...n])]),this.Dc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Uc()}qc(t){this.gc=this.gc.filter(i=>i!==t);const i=this.Wc();return!i.includes(t)&&(this.Vc([...i,t]),this.Gc(),!0)}Nc(t){const i=new Set(t);this.gc=this.gc.filter(t=>!i.has(t));const e=this.Zc(),s=e.filter(t=>!i.has(t));s.length!==e.length&&(this.Vc(s),0===s.length&&this.Qc()),this.jc(t),this.Uc()}Uc(){try{var t;null===(t=this.mc)||void 0===t||t.call(this)}catch(t){this.Dc().error("Error while handling activated items change",t)}}Jc(){var t;const i=this.xc();if(!i)return{};const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i];return e&&"object"==typeof e?e:{}}zc(t){if(!this.xc())return;const i=this.Jc();this.Cc(cs(cs({},i),{},{[t]:Date.now()}))}jc(t){if(!this.xc())return;const i=this.Jc(),e={};let s=!1;for(const[n,r]of Object.entries(i))t.includes(n)?s=!0:e[n]=r;s&&(_i(e)?this.$c():this.Cc(e))}Kc(){this.xc()&&this.$c()}getActivationTimestamp(t){if(!this.Wc().includes(t))return;const i=this.Jc()[t];return xi(i)?i:void 0}Zc(){var t;const i=this.Xc();return(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i])||[]}Wc(){var t,i,e;const s=this.Zc();if(0===s.length)return[];const n=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this.Yc()],r=null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i);return r&&n===r?s:[]}Gc(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);e&&this.td(e)}Qc(){this.ed()}kc(t){var i;const e=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.props[this.Yc()];if(e&&e!==t){const t=this.Zc(),i=this.Jc();t.length>0&&(this.Vc([]),t.filter(t=>xi(i[t])).forEach(t=>this.Bc(t))),this.Qc(),this.Kc(),t.length>0&&this.Uc()}}getActivatedIds(){return[...new Set([...this.Wc(),...this.gc])].filter(t=>!this.nd(t))}dispose(){var t,i,e;null===(t=this.wc)||void 0===t||t.call(this),this.wc=void 0,null===(i=this.lc)||void 0===i||i.call(this),this.lc=void 0,null===(e=this.Fc)||void 0===e||e.dispose(),this.Fc=void 0}reset(){this.gc=[],this.Zc().length>0&&this.Vc([]),this.Qc(),this.Kc(),this.Uc()}getEventToItemsMap(){return this.yc}sd(){return this.Fc}},nu=class extends su{constructor(t,i){super(t,i)}Xc(){return Q}Yc(){return tt}xc(){return it}Cc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_timestamps:t})}$c(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_timestamps")}Sc(t){var i;let e;this.Ec(i=>{e=i.find(i=>i.id===t)});const s=null==e||null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds;return xi(s)&&s>0}rd(){return ul}Ec(t){var i;null===(i=this._instance)||void 0===i||i.getSurveys(t)}Bc(t){var i;null===(i=this._instance)||void 0===i||i.cancelPendingSurvey(t)}Dc(){return qa}Vc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated:t})}td(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_session:t})}ed(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_session")}nd(){return!1}Lc(t,i,e){var s;if(t===cl&&!1===(null==e||null===(s=e.properties)||void 0===s?void 0:s.$survey_completed))return"ignore";let n;return this.Ec(t=>{n=t.find(t=>t.id===i)}),!n||function(t){var i;return Oa(t)&&!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i?void 0:i.repeatedActivation)||"always"===t.schedule}(n)?t===ul?"consume":"ignore":t===ul?"persist":t===dl||t===cl?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},ru=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);const i={};for(const e of t){const t=this._instance.get_property(e);mi(t)||(i[e]=t)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},ou=class{constructor(t){this._instance=t}get(){const t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const t=null==ei?void 0:ei.__PosthogExtensions__;if(!t)return;const{generateSurveys:i,loadExternalDependency:e}=t;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}createEventReceiver(t){return new nu(this._instance,t)}onMatchingConditionsChanged(t){const i=this._instance._addCaptureHook(i=>{"$pageview"!==i&&i!==ul&&i!==dl&&i!==cl||t()}),e=()=>t();Kn(qt,"PHSurveyShown",e);let s=!1;const n=this._instance.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,i(),n(),null==qt||qt.removeEventListener("PHSurveyShown",e)}}};const lu=(null==qt?void 0:qt.location)?Co(qt.location.hash,"__posthog")||Co(location.hash,"state"):null,au="_postHogToolbarParams",hu=Bn("[Toolbar]"),uu=Bn("[FeatureFlags]");var du=class{constructor(t,i=!1){this.od=!1,this.update(t,i)}update(t,i){this.ad=((t,i)=>{var e,s,n,r,o,l,a,h;return{bootstrap:{featureFlags:null!==(e=null===(s=t.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(n=null===(r=t.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=t.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:mi(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(l=t.feature_flag_request_max_retries)&&void 0!==l?l:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(h=t.evaluation_contexts)&&void 0!==h?h:t.evaluation_environments)&&void 0!==a?a:[],flagKeys:fi(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.od||(uu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.od=!0),mi(t.flag_keys)||fi(t.flag_keys)||uu.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.ad}};const cu=Bn("[FeatureFlags]"),vu=Bn("[FeatureFlags]",{debugEnabled:!0}),fu="\" failed. Feature flags didn't load in time.",pu=[502,504],gu=["click","keydown","wheel","touchstart","pointerdown"],_u="connection_error",mu=t=>{const i={};for(let e=0;t.length>e;e++)i[t[e]]=!0;return i},bu=t=>{const i={};for(const[e,s]of Hn(t||{}))s&&(i[e]=s);return i},yu=t=>Fi(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),wu=Bn("[Error tracking]"),$u="webkit-masked-url:",xu=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Su=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",$u],ku=["__firefox__","__gCrWeb"],Eu="Refusing to render web experiment since the viewer is a likely bot",Pu={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Aa(i,t),not_regex:(t,i)=>!Aa(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},Tu=Bn("[Conversations]"),Cu="Conversations not available yet.";function Fu(t,i){var e,s,n,r,o,l,a;const h=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=(null==i?void 0:i.consoleCapture)?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=mi(d)?Math.max(u,2048):Math.max(u,d),v=cs(cs({},function(){let t="",i="";try{const e=null==Wt?void 0:Wt.userAgent;e&&([t,i]=Le(e))}catch(t){}return function(t,i){const e=function(t){if(t)return{}.hasOwnProperty.call(wn,t)?wn[t]:t}(t);return cs(cs({},e?{"os.name":e}:{}),i?{"os.version":i}:{})}(t,i)}()),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==v?void 0:v["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==r?r:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==v?void 0:v["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(a=null==v?void 0:v["deployment.environment"])&&void 0!==a?a:null==t?void 0:t.environment,resourceAttributes:v,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:u,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Mu=["debug","log","warn","error","info"],Iu=t=>{for(;null==t?void 0:t.__rrweb_original__;)t=t.__rrweb_original__;return t},Ou="console",Au="__posthogHandledLogsRequestError",Ru=(t,i)=>{const e=t instanceof Error?t:new Error(i);return e[Au]=!0,e},Du=t=>!!t&&"object"==typeof t&&!0===t[Au],ju=Bn("[NetworkMetrics]"),Bu=()=>{var t;return(null==qt||null===(t=qt.performance)||void 0===t?void 0:t.now)?qt.performance.now():Date.now()},Nu={"http:":80,"https:":443},Lu=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),zu=(t,i)=>{var e;const s=String(i);return{method:String(t).toUpperCase(),url:(null===(e=Eo(s))||void 0===e?void 0:e.href)||s}},Hu=(t,i,e,s,n,r,o=!1)=>{try{var l,a;const h=n();if(!h)return;const u=e||void 0,d=Bu()-s,c=Eo(i.url);if(c&&"http:"!==c.protocol&&"https:"!==c.protocol)return;const v={url:(null==c?void 0:c.href)||i.url,method:i.method},f=pi(h.name)?h.name(v):bi(h.name)?h.name:"http.client.request.duration";if(!f)return;const p=o&&!u?void 0:((t,i)=>t?400>t?void 0:String(t):(null==i?void 0:i.name)||"_OTHER")(u,r),g=cs(cs(cs(cs(cs({},(t=>{const i=Lu.has(t)?t:"_OTHER";return cs({"http.request.method":i},"_OTHER"===i&&t!==i?{"http.request.method_original":t}:{})})(v.method)),c?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Nu[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(i=t.pathname,i.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var i})(c):{}),u?{"http.response.status_code":u}:{}),p?{"error.type":p}:{}),null===(l=h.attributes)||void 0===l?void 0:l.call(h,v,{status:u,durationMs:d}));null===(a=t.metrics)||void 0===a||a.histogram(f,d,{unit:"ms",attributes:g})}catch(t){ju.error("Failed to record network metric",t)}},Uu=()=>{},qu=(t,i)=>pi(null==qt?void 0:qt.fetch)?Oh(qt,"fetch",e=>function(...s){const n=Bu(),r=e.apply(this,s);if(!i())return r;try{var o,l,a;const[e,h]=s,u=zu(null!==(o=null!==(l=null==h?void 0:h.method)&&void 0!==l?l:null==e?void 0:e.method)&&void 0!==o?o:"GET",null!==(a=null==e?void 0:e.url)&&void 0!==a?a:e);return r.then(e=>(Hu(t,u,null==e?void 0:e.status,n,i,void 0,!0),e),e=>{throw Hu(t,u,void 0,n,i,e),e})}catch(t){return ju.error("Failed to observe fetch",t),r}}):Uu,Vu=(t,i)=>{var e;const s=null==qt||null===(e=qt.XMLHttpRequest)||void 0===e?void 0:e.prototype;if(!s)return Uu;const n=new WeakMap,r=Oh(s,"open",t=>function(...i){try{(()=>ta.has(this))()||n.set(this,zu(i[0],i[1]))}catch(t){ju.error("Failed to observe XHR open",t)}return t.apply(this,i)}),o=Oh(s,"send",e=>function(...s){let r;try{const e=n.get(this);if(e&&i()){const s=Bu();r=()=>{this.removeEventListener("loadend",r),Hu(t,e,this.status,s,i)},Kn(this,"loadend",r)}}catch(t){ju.error("Failed to observe XHR send",t)}try{return e.apply(this,s)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{r(),o()}},Wu={featureFlags:class{constructor(t){this.name="featureFlags",this.ld=!1,this.featureFlagEventHandlers=[],this.A=cu,this.ud={},this.hd={},this.dd=[],this.vd=!1,this.fd=!1,this.pd=0,this.gd=!1,this.md=!1,this.yd=!1,this.bd=!1,this._d=0,this.wd=!1,this.rn=()=>{const t=this.kd();this._d=0,t&&this.reloadFeatureFlags()},this.Sd=()=>{var t,i;const e=this.xd,s=null!==(t=this.Cd)&&void 0!==t?t:e;mi(e)||mi(s)||this.Ir.remoteRequestsDisabled||!Gt||"hidden"===Gt.visibilityState||Date.now()-(null!==(i=this.$d)&&void 0!==i?i:0)<s||(this.Cd=this.wd||!this.Ir.idleRefreshBackoff?e:Math.min(2*s,36e5),this.wd=!1,this.reloadFeatureFlags(),this.Td())},this.Id=()=>{this.wd&&this.Cd===this.xd||this.Md()},this.sn=()=>{"visible"===(null==Gt?void 0:Gt.visibilityState)&&this.Md()},"get"in t?this.wo=t:(this._instance=t,this.Ed=new du(t.config,t.il()),this.wo=this.Ed)}updateConfig(t,i){var e;null===(e=this.Ed)||void 0===e||e.update(t,i),this.bo&&this.Pd()}setup(t){return this.Nh=t,this.A=t.logger.createLogger("[FeatureFlags]"),Xh(t.kv.initialize(),()=>{this.Nh===t&&(this.Nh=void 0,this.bo=t,this.Rd(t))})}Rd(t){var i;if(this.bo===t)return qt&&Kn(qt,"online",this.rn),this.Pd(),this.Ad=t.registerDynamicEventProperties(()=>this.Fd()?this.ud:this.hd),this.Od=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.onCrossTabFeatureFlagChange(()=>{this.Dd(),this.Ld(),this.Nd()}),this.Ld(),this.initialize()}Md(){this.wd=!0,this.Cd=this.xd,this.Sd()}Pd(){const t=this.Ir.refreshIntervalMs,i=!this.Ir.remoteRequestsDisabled&&Gt&&!mi(t)&&t>0?t:void 0;this.Ir.idleRefreshBackoff||(this.Cd=i),i!==this.xd&&(this.qd(),mi(i)||(this.xd=i,this.Cd=i,this.Td(),(null==Gt?void 0:Gt.addEventListener)&&(Kn(Gt,Bt,this.sn),Nn(gu,t=>{Kn(Gt,t,this.Id,{capture:!0})}))))}Td(){mi(this.xd)||(mi(this.jd)||clearInterval(this.jd),this.$d=Date.now(),this.jd=setInterval(this.Sd,this.xd))}qd(){var t;mi(this.jd)||(clearInterval(this.jd),this.jd=void 0,null==Gt||null===(t=Gt.removeEventListener)||void 0===t||t.call(Gt,"visibilitychange",this.sn),Nn(gu,t=>{var i;null==Gt||null===(i=Gt.removeEventListener)||void 0===i||i.call(Gt,t,this.Id,{capture:!0})})),this.xd=void 0,this.Cd=void 0,this.wd=!1,this.$d=void 0}destroy(){this.Bd()}dispose(){this.Bd()}Bd(){var t,i;this.qd(),this.pd++,this.md=!1,this.Nh=void 0,this.bo&&(this.Hd(),null===(t=this.Ad)||void 0===t||t.dispose(),this.Ad=void 0,null===(i=this.Od)||void 0===i||i.call(this),this.Od=void 0,this.dd=[],null==qt||qt.removeEventListener("online",this.rn),this.bo=void 0)}get Ir(){return this.wo.get()}zd(t){var i;return this.Ud&&t in this.Ud?this.Ud[t]:null===(i=this.bo)||void 0===i?void 0:i.kv.get(t)}Dd(){return!!this.Ud&&(this.Ud=void 0,!0)}Wd(){var t;return!mi(null===(t=this.bo)||void 0===t?void 0:t.kv.get("$enabled_feature_flags"))&&this.Dd()}$t(t){this.Vd(()=>{var i;return null===(i=this.bo)||void 0===i?void 0:i.kv.set(t)})}Gd(t,i,e){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!t.$enabled_feature_flags)return;const n=this.zd("$enabled_feature_flags")||{},r=t.$enabled_feature_flags||{},o=i.flags||i.featureFlags,l=i.flags?Object.entries(i.flags).filter(([,t])=>!(null==t?void 0:t.failed)).map(([t])=>t):[],a=!!i.errorsWhileComputingFlags&&!!i.flags,h=a?l:e&&!fi(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),u=this.zd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=a||e?h:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),v=!a&&!e,f=!!v||h,p=!!v||c,g={[L]:f,[N]:f,[U]:p};t.$feature_flag_details&&(g[H]=f);for(const i of[q,ct,V])mi(t[i])||(g[i]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}Lt(t){this.Vd(()=>{var i;return null===(i=this.bo)||void 0===i?void 0:i.kv.remove(t)})}Vd(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Ld(){const t={};for(const i of[L,U,q,W]){const e=this.zd(i);mi(e)||(t[i]=e)}this.ud=t;const i=cs({},t),e=this.zd(N);if(e)for(const[t,s]of Object.entries(e))i[`$feature/${t}`]=s;this.hd=i}Fd(){const t=this.Ir.cacheTtlMs;if(!t||0>=t)return!1;const i=this.zd(ct);return"number"!=typeof i||Date.now()-i>t}Zd(){return!!this.Fd()&&(this.bd||this.fd||(this.bd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Qd(){const t=this.Ir.evaluationContexts;return(null==t?void 0:t.length)?t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}Jd(){const t=this.Ir.flagKeys;if(!mi(t))return t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i;const e=this.Ir,s=null!==(t=null===(i=e.bootstrap)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(s).length){var n,r;const t=null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},i=Object.keys(s).filter(t=>!mi(s[t])).reduce((t,i)=>(t[i]=s[i],t),{}),o=Object.keys(t).filter(t=>i[t]).reduce((i,e)=>(i[e]=t[e],i),{});return this.Kd({featureFlags:i,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n;const r=(null==e?void 0:e.merge)&&null!==(s=this.zd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==e?void 0:e.merge)&&null!==(n=this.zd("$feature_flag_payloads"))&&void 0!==n?n:{},l=cs(cs({},r),t),a=cs(cs({},o),i),h={};for(const[t,i]of Object.entries(l))h[t]={key:t,enabled:Qs(i),variant:tn(i),reason:void 0,metadata:mi(null==a?void 0:a[t])?void 0:{id:0,version:void 0,description:void 0,payload:a[t]}};this.Kd({flags:h})}get hasLoadedFlags(){return this.vd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.zd(H),i=this.zd(W),e=this.zd(G);if(!e&&!i)return t||{};const s=zn({},t||{}),n=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(const t of n){var r;const n=s[t],l=null==i?void 0:i[t],a=mi(l)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!l,h=mi(l)?null==n?void 0:n.variant:"string"==typeof l?l:void 0,u=null==e?void 0:e[t],d=cs(cs({},n),{},{enabled:a,variant:a?null!=h?h:null==n?void 0:n.variant:void 0});var o;a!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),h!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=cs(cs({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[t]=d}return this.ld||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.ld=!0),s}getAllFeatureFlags(){const t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{const s=t[e];return{key:e,enabled:Qs(s),variant:tn(s),payload:Zs(i[e])}})}getFlagVariants(){const t=this.zd(N),i=this.zd(W);if(!i)return t||{};const e=zn({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ld||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.ld=!0),e}getFlagPayloads(){const t=this.zd(U),i=this.zd(G);if(!i)return t||{};const e=zn({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ld||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.ld=!0),e}reloadFeatureFlags(){this.gd||this.Ir.featureFlagsDisabled||this.kd()||(this.fd&&(this.md=!0),this.Xd||(this.dd.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.Xd=setTimeout(()=>{this.Yd()},5)))}Hd(){clearTimeout(this.Xd),this.Xd=void 0}onReloading(t){return this.dd.push(t),()=>{this.dd=this.dd.filter(i=>i!==t)}}ensureFlagsLoaded(){this.vd||this.fd||this.Xd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.gd=t}resetFlagCallReported(){this.Lt(ht)}Yd(t){this.Hd();const i=this.bo;if(!i||this.Ir.remoteRequestsDisabled||this.kd())return;if(this.fd)return void(this.md=!0);const e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:cs(cs(cs({},i.initialPersonProperties),this.zd("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.zd(J),timezone:Vo()};mi(i.deviceId)||(e.$device_id=i.deviceId),((null==t?void 0:t.disableFlags)||this.Ir.featureFlagsDisabled)&&(e.disable_flags=!0);const s=this.Qd();s.length&&(e.evaluation_contexts=s);const n=this.Jd();mi(n)||(e.flag_keys=n);const r=this.Ir.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),l=this.pd;this.fd=!0;const a=()=>{this.md&&(this.md=!1,this.Yd())},h=t=>{var i,s;const n=null!==(i=t.json)&&void 0!==i?i:{},o=200!==t.statusCode;if(this.fd=!1,l!==this.pd)return void a();if(this.tv(t.statusCode),o||this.md||(this.$anon_distinct_id=void 0),e.disable_flags&&!this.md)return;this.yd=!o;const h=[];t.error?h.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?_u:"unknown_error"):200!==t.statusCode&&h.push(`api_error_${t.statusCode}`),n.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");const u=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));u&&h.push("quota_limited"),this.$t({[dt]:h}),u?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):e.disable_flags||this.Kd(n,o,{partialResponse:r}),a()},u=t=>{this.fd=!1,l===this.pd?(this.$t({[dt]:[_u]}),this.A.error("Feature flag request failed",t),this.Wd()&&this.Nd(!0),a()):a()};let d=this.Ir.requestMaxRetries;const c=()=>d>0&&l===this.pd,v=()=>{if(l!==this.pd||!this.bo||this.Ir.remoteRequestsDisabled)return this.fd=!1,void a();try{i.sendRequest(o,{target:"flags",method:"POST",body:e,compression:this.Ir.compression,sentAt:"body",timeoutMs:this.Ir.requestTimeoutMs}).then(t=>{if((t=>pu.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&c())return d--,void setTimeout(v,500);h(t)}).catch(u)}catch(t){u(t)}};v()}kd(){return Fo(this._d,3)}tv(t){this._d=Mo(t,this._d,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i={}){var e;if(i.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+t+fu);if(this.Zd())return;const s=this.getFeatureFlagResult(t,i);return null!==(e=null==s?void 0:s.variant)&&void 0!==e?e:null==s?void 0:s.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i={}){if(i.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+t+fu);if(this.Zd())return;const e=this.getFlagVariants(),s=t in e,n=e[t],r=this.getFlagPayloads()[t],o=String(n),l=this.zd("$feature_flag_request_id")||void 0,a=this.zd("$feature_flag_evaluated_at")||void 0;let h,u=this.zd("$flag_call_reported")||{};if(this.Ir.deduplicateCallsPerSession){var d;const t=null===(d=this.bo)||void 0===d?void 0:d.session.sessionId,i=this.zd(ut);t&&t!==i&&(u={},h=t)}if(i.send_event||!("send_event"in i))if(t in u&&u[t].includes(o))h&&this.$t({[ht]:u,[ut]:h});else{var c,v,f,p,g,_,m,b,y,w,x,S;fi(u[t])?u[t].push(o):u[t]=[o],this.$t(cs({[ht]:u},h?{[ut]:h}:{}));const i=this.getFeatureFlagDetails(t),e=[...null!==(c=this.zd("$feature_flag_errors"))&&void 0!==c?c:[]];mi(n)&&e.push("flag_missing");const s={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:null!==(v=null===(f=this.Ir.bootstrap)||void 0===f||null===(f=f.featureFlags)||void 0===f?void 0:f[t])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(p=null===(g=this.Ir.bootstrap)||void 0===g||null===(g=g.featureFlagPayloads)||void 0===g?void 0:g[t])&&void 0!==p?p:null,$used_bootstrap_value:!this.yd};mi(null==i||null===(_=i.metadata)||void 0===_?void 0:_.has_experiment)||(s.$feature_flag_has_experiment=i.metadata.has_experiment),mi(null==i||null===(m=i.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=i.metadata.version);const d=null!==(b=null==i||null===(y=i.reason)||void 0===y?void 0:y.description)&&void 0!==b?b:null==i||null===(w=i.reason)||void 0===w?void 0:w.code;var k;d&&(s.$feature_flag_reason=d),(null==i||null===(x=i.metadata)||void 0===x?void 0:x.id)&&(s.$feature_flag_id=i.metadata.id),mi(null==i?void 0:i.original_variant)&&mi(null==i?void 0:i.original_enabled)||(s.$feature_flag_original_response=mi(i.original_variant)?i.original_enabled:i.original_variant),(null==i||null===(S=i.metadata)||void 0===S?void 0:S.original_payload)&&(s.$feature_flag_original_payload=null==i||null===(k=i.metadata)||void 0===k?void 0:k.original_payload),e.length&&(s.$feature_flag_error=e.join(",")),this.ev(s)}else h&&this.$t({[ht]:u,[ut]:h});return s?{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:Zs(r)}:void 0}ev(t){try{var i;null===(i=this.bo)||void 0===i||i.capture("$feature_flag_called",t)}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.iv(t,i)}iv(t,i){var e=this;return ji(function*(){const s=e.bo;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=e.Qd();r.length&&(n.evaluation_contexts=r);const o=e.Jd();let l;mi(o)||(n.flag_keys=o);try{var a;const i=null===(a=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:e.Ir.compression,sentAt:"body",timeoutMs:e.Ir.requestTimeoutMs})).json)||void 0===a?void 0:a.featureFlagPayloads;l=(null==i?void 0:i[t])||void 0}catch(t){return void e.A.error("Remote config feature flag request failed",t)}try{i(l)}catch(t){e.A.error("Remote config feature flag callback failed",t)}})()}isFeatureEnabled(t,i={}){if(i.fresh&&!this.yd)return i.defaultValue;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+fu),i.defaultValue;const e=this.getFeatureFlag(t,i);return mi(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.Kd(t,i,e)}Kd(t,i,e){if(!this.bo)return;this.vd=!0;const s=((t,i={},e={},s={},n,r=cu)=>{const o=((t,i)=>{const e=t.flags;if(e){const i=Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),s=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!mi(null===(i=e[t].metadata)||void 0===i?void 0:i.payload)}).map(t=>{var i;return[t,null===(i=e[t].metadata)||void 0===i?void 0:i.payload]}));return cs(cs({},t),{},{featureFlags:i,featureFlagPayloads:s})}return t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t,r),l=o.flags,a=o.featureFlags,h=o.featureFlagPayloads;if(!a)return;const u=t.requestId,d=t.evaluatedAt;if(fi(a)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const t={};if(a)for(let i=0;a.length>i;i++)t[a[i]]=!0;return{[L]:a,[N]:t,[V]:!1}}let c=a,v=h,f=l;if(null==n?void 0:n.partialResponse){const t=Object.keys(c),n=v||{};c=cs(cs({},i),c),v=cs(cs({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=cs(cs({},s),f)}else if(t.errorsWhileComputingFlags)if(l){const t=new Set(Object.keys(l).filter(t=>{var i;return!(null===(i=l[t])||void 0===i?void 0:i.failed)}));c=cs(cs({},i),Object.fromEntries(Object.entries(c).filter(([i])=>t.has(i))));const n=Object.fromEntries(Object.entries(v||{}).filter(([i])=>t.has(i)));v=cs(cs({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=cs(cs({},s),Object.fromEntries(Object.entries(f||{}).filter(([i])=>t.has(i))))}else c=cs(cs({},i),c),v=cs(cs({},e),v),f=cs(cs({},s),f);return cs(cs({[L]:Object.keys(bu(c)),[N]:c||{},[U]:v||{},[H]:f||{},[V]:!0===t.minimalFlagCalledEvents},u?{[q]:u}:{}),d?{[ct]:d}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.A);if(s)if(!1===(null==e?void 0:e.persist)){const t=!mi(this.bo.kv.get(N));this.Ud=s,t||this.$t(s)}else this.Dd(),this.Gd(s,t,!!(null==e?void 0:e.partialResponse)),this.$t(s);else i&&this.Wd();i||(this.bd=!1),this.Nd(i)}override(t,i=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.nv(t)}nv(t){if(this.bo){if(!1===t)return this.Lt([W,G]),this.Nd(),void vu.info("All overrides cleared");if(fi(t))return this.$t({[W]:mu(t)}),this.Nd(),void vu.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i;const e=t;this.ld=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);const s={},n=e.flags,r=e.payloads;return n&&(s[W]=fi(n)?mu(n):n),r&&(s[G]=r),Object.keys(s).length&&this.$t(s),!1===n&&!1===r?this.Lt([W,G]):!1===n?this.Lt(W):!1===r&&this.Lt(G),this.Nd(),!1===n?vu.info("Flag overrides cleared"):n&&vu.info("Flag overrides set",{flags:n}),void(!1===r?vu.info("Payload overrides cleared"):r&&vu.info("Payload overrides set",{payloads:r}))}if(t&&"object"==typeof t)return this.$t({[W]:t}),this.Nd(),void vu.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.vd){const{flags:i,flagVariants:e}=this.sv();try{t(i,e)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;const n=(this.zd("$early_access_features")||[]).find(i=>i.flagKey===t),r={[`$feature_enrollment/${t}`]:i},o={$feature_flag:t,$feature_enrollment:i,$set:r};n&&(o.$early_access_feature_name=n.name),e&&(o.$feature_enrollment_stage=e);const l=cs(cs({},this.getFlagVariants()),{},{[t]:i});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.$t({[L]:Object.keys(bu(l)),[N]:l,[K]:cs(cs({},this.zd("$stored_person_properties")||{}),r)}),this.Nd();try{var a;null===(a=this.bo)||void 0===a||a.capture("$feature_enrollment_update",o)}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i=!1,e){const s=this.zd(z);!s||i?this.rv(t,e):t(s)}rv(t,i){var e=this;return ji(function*(){const s=e.bo;if(!s)return;const n=i?`&${i.map(t=>`stage=${t}`).join("&")}`:"";let r;try{const t=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!t.json)return;r=t.json.earlyAccessFeatures,e.$t({[z]:r})}catch(t){return void e.A.error("Early access feature request failed",t)}try{t(r)}catch(t){e.A.error("Early access feature callback failed",t)}})()}sv(){const t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}Nd(t){this.Ld();const{flags:i,flagVariants:e}=this.sv();this.featureFlagEventHandlers.forEach(s=>{try{s(i,e,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i=!0){this.ov(t,i)}ov(t,i=!0){const e=this.zd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||((null==t?void 0:t.$set_once)?{}:t),n=null==t?void 0:t.$set_once,r={};if(n)for(const t in n)({}).hasOwnProperty.call(n,t)&&(t in e||(r[t]=n[t]));this.$t({[K]:cs(cs(cs({},e),r),s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i=!0){const e=cs({},this.zd("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.$t({[K]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Lt(K),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i=!0){const e=this.zd("$stored_group_properties")||{},s=cs({},e);for(const i of Object.keys(t))s[i]=cs(cs({},e[i]),t[i]);this.$t({[J]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const i=this.zd("$stored_group_properties")||{};this.$t({[J]:cs(cs({},i),{},{[t]:{}})})}else this.Lt(J)}reset(){this.pd++,this.md=!1,this.ud={},this.hd={},this.Ud=void 0,this.vd=!1,this.gd=!1,this.yd=!1,this.$anon_distinct_id=void 0,this.Hd(),this.ld=!1,this._d=0}}},Gu={sessionRecording:class{get Ir(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(null===(t=this.av)||void 0===t?void 0:t.isStarted)}get status(){var t,i;return"awaiting_config"===this.lv||"missing_config"===this.lv?this.lv:null!==(t=null===(i=this.av)||void 0===i?void 0:i.status)&&void 0!==t?t:this.lv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.lv=Lh,this.uv=void 0,this.hv=!1,this.Je=(()=>{var t,i;if(!(null==Gt?void 0:Gt.visibilityState)||"visible"===Gt.visibilityState)return!0;const e=null==qt||null===(t=qt.performance)||void 0===t||null===(i=t.getEntriesByType)||void 0===i?void 0:i.call(t,"visibility-state");return!(null==e?void 0:e.length)||e.some(t=>"visible"===t.name)})(),this.sn=()=>{var t,i;"visible"===(null==Gt?void 0:Gt.visibilityState)&&(this.Je=!0,null===(t=this.av)||void 0===t||null===(i=t.setDocumentWasEverVisible)||void 0===i||i.call(t,!0))},!this._instance.sessionManager)throw Hh.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Ir.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==Gt?void 0:Gt.addEventListener)&&Kn(Gt,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var i;this.hv=!0,null==Gt||null===(i=Gt.removeEventListener)||void 0===i||i.call(Gt,"visibilitychange",this.sn),t?this.dv(!0):this.stopRecording()}get vv(){var t;const i=!!(null===(t=this._instance.get_property("$session_recording_remote_config"))||void 0===t?void 0:t.enabled),e=!this.Ir.disable_session_recording,s=this.Ir.disable_session_recording||this._instance.consent.isOptedOut();return qt&&i&&e&&!s}startIfEnabledOrStop(t){var i;if(this.hv)return;if(this.vv&&(null===(i=this.av)||void 0===i?void 0:i.isStarted))return;const e=!mi(Object.assign)&&!mi(Array.from);this.vv&&e?(this.fv(t),Hh.info("starting")):(this.lv=Lh,this.stopRecording())}fv(t){var i,e;if(this.vv)if("awaiting_config"!==this.lv&&"missing_config"!==this.lv&&(this.lv=zh),(null==ei||null===(i=ei.__PosthogExtensions__)||void 0===i||null===(i=i.rrweb)||void 0===i?void 0:i.record)&&(null===(e=ei.__PosthogExtensions__)||void 0===e?void 0:e.initSessionRecording))this.pv(t);else{var s,n;const i=this._instance.sessionManager;null===(s=ei.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.gv,e=>{if(!this.hv&&this.vv&&this._instance.sessionManager===i)return e?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Hh.error("could not load recorder",e)):void this.pv(t);this.lv="disabled"})}}stopRecording(){var t,i;null===(t=this.uv)||void 0===t||t.call(this),this.uv=void 0,null===(i=this.av)||void 0===i||i.stop()}dv(t=!1){var i,e;null===(i=this.uv)||void 0===i||i.call(this),this.uv=void 0,null===(e=this.av)||void 0===e||e.discard({discardProducerEvents:t})}mv(){var t,i;null===(t=this.Il)||void 0===t||t.unregister("$session_is_sampled"),null===(i=this.Il)||void 0===i||i.unregister("$replay_sample_rate")}yv(t,i){if($i(t))return null;const e=xi(t)?t:parseFloat(t);return"number"!=typeof(s=e)||!Number.isFinite(s)||0>s||s>1?(Hh.warn(`${i} must be between 0 and 1. Ignoring invalid value:`,t),null):e;var s}bv(t){if(this.Il){var i,e;const s=this.Il,n=()=>{var i;const e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.yv(null===(i=this.Ir.session_recording)||void 0===i?void 0:i.sampleRate,"session_recording.sampleRate"),r=this.yv(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=n?n:r;$i(o)&&this.mv();const l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[k]:cs(cs({cache_timestamp:Date.now(),enabled:!!e},e),{},{networkPayloadCapture:cs({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:mi(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null===(i=this.uv)||void 0===i||i.call(this),this.uv=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(n)}}onRemoteConfig(t){const i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.bv(i),void this.dv()):(this.bv(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.lv&&(this.lv="missing_config",this._instance.register_for_session({[kt]:!0}),Hh.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i="log"){var e;(null===(e=this.av)||void 0===e?void 0:e.log)?this.av.log(t,i):Hh.warn("log called before recorder was ready")}get gv(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.get_property(k);return(null==e||null===(i=e.scriptConfig)||void 0===i?void 0:i.script)||"lazy-recorder"}_v(){const t=this._instance.get_property(k);if(!t)return!1;let i;try{i="object"==typeof t?t:JSON.parse(t)}catch(t){return Hh.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!$i(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}pv(t){var i,e,s;if(!this.hv&&this.vv&&this._instance.sessionManager){if(!(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))return Hh.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[St]:!0});var n;if(this.av||(this.av=null===(n=ei.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Je),this.av._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._v()){if("missing_config"===this.lv||"awaiting_config"===this.lv)return;return this.lv="awaiting_config",Hh.info("persisted remote config is stale, requesting fresh config before starting"),void new bl(this._instance).load()}this.lv=zh,null===(e=(s=this.av).setDocumentWasEverVisible)||void 0===e||e.call(s,this.Je),this.av.start(t)}else this.lv=Lh}onRRwebEmit(t){var i,e;null===(i=this.av)||void 0===i||null===(e=i.onRRwebEmit)||void 0===e||e.call(i,t)}overrideLinkedFlag(){var t,i;this.av||null===(i=this.Il)||void 0===i||i.register({$replay_override_linked_flag:!0}),null===(t=this.av)||void 0===t||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.av||null===(i=this.Il)||void 0===i||i.register({$replay_override_sampling:!0}),null===(t=this.av)||void 0===t||t.overrideSampling()}overrideTrigger(t){var i,e;this.av||null===(e=this.Il)||void 0===e||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(i=this.av)||void 0===i||i.overrideTrigger(t)}get sdkDebugProperties(){var t;const i={};for(const t of Uh){var e;const s=null===(e=this._instance.sessionPersistence)||void 0===e?void 0:e.get_property(t);mi(s)||(i[t]=s)}return cs(cs({},i),(null===(t=this.av)||void 0===t?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,i){var e;return!!(null===(e=this.av)||void 0===e?void 0:e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t,i;null===(t=this.av)||void 0===t||null===(i=t.flushBeforeIdentityReset)||void 0===i||i.call(t)}}},Ku={autocapture:class extends Th{constructor(t){super(new Ch(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.wv=!1,this._instance=t,this.Sv=this.xv()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Cv();return!!(t.path||t.search||this.$v(t))}startIfEnabled(){this.isEnabled&&(jn.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Sv=this.xv(),this.startIfEnabled()}stop(){this.Tv&&this.Tv(),this.Tv=void 0,this.Iv&&this.Iv(),this.Iv=void 0,jn.info("History API monitoring stopped")}monitorHistoryChanges(){qt&&qt.history&&(this.Mv("pushState"),this.Mv("replaceState"),this.Ev(),this.$v()&&this.Pv())}Mv(t){var i;if(!qt||(null===(i=qt.history[t])||void 0===i?void 0:i.__posthog_wrapped__))return;const e=this;Oh(qt.history,t,i=>function(s,n,r){var o;e.Rv(r)&&e.Av(),i.call(this,s,n,r),e.Fv(t,!e.wv&&"popstate"!==(null==qt||null===(o=qt.event)||void 0===o?void 0:o.type))})}xv(){const t=null==qt?void 0:qt.location;if(null==t?void 0:t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Cv(){const t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:gi(t)?t:{}}$v(t=this.Cv()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Ov(t){const i=this.Cv(),e=this.Sv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.$v(i)&&t.hash!==e.hash))}Fv(t,i=!1){try{i||this.Av();const e=this.xv();if(!e)return;if(this.Ov(e)){const e=()=>this._instance.capture(Lt,{navigation_type:t});i?(this.Dv=e,Promise.resolve().then(()=>this.Av())):e()}this.Sv=e}catch(i){jn.error(`Error capturing ${t} pageview`,i)}}Rv(t){var i,e;return!($i(t)||!qt)&&(null===(i=Eo(String(t)))||void 0===i?void 0:i.href)!==(null===(e=qt.location)||void 0===e?void 0:e.href)}Av(){const t=this.Dv;if(t){this.Dv=void 0,this.wv=!0;try{t()}catch(t){jn.error("Error capturing deferred pageview",t)}finally{this.wv=!1}this.Sv=this.xv()}}Ev(){if(this.Tv)return;const t=()=>{this.Fv("popstate")};Kn(qt,"popstate",t),this.Tv=()=>{qt&&qt.removeEventListener("popstate",t)}}Pv(){if(this.Iv)return;const t=()=>{this.Fv("hashchange")};Kn(qt,"hashchange",t),this.Iv=()=>{qt&&qt.removeEventListener("hashchange",t)}}},heatmaps:class{get Ir(){return this.instance.config}constructor(t){var i;this.Lv=!1,this.ko=!1,this.Nv=null,this.instance=t,this.Lv=!!(null===(i=this.instance.persistence)||void 0===i?void 0:i.props[p]),this.rageclicks=new $h(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return gi(this.Ir.capture_heatmaps)&&this.Ir.capture_heatmaps.flush_interval_milliseconds&&(t=this.Ir.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return $i(this.Ir.capture_heatmaps)?$i(this.Ir.enable_heatmaps)?this.Lv:this.Ir.enable_heatmaps:!1!==this.Ir.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ko)return;qh.info("starting..."),this.qv(),this.sn()}else{var t;clearInterval(null!==(t=this.Nv)&&void 0!==t?t:void 0),this.jv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("heatmaps"in i))return;const e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[p]:e}),this.Lv=e,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}Bv(t){Vh(t.originalEvent)&&this.Mr(t.originalEvent,"deadclick")}sn(){this.Nv&&clearInterval(this.Nv),this.Nv=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(Gt)?setInterval(this.yl.bind(this),this.flushIntervalMilliseconds):null}qv(){qt&&Gt&&(this.Hv=this.yl.bind(this),Kn(qt,Nt,this.Hv),this.zv=t=>this.Mr(t||(null==qt?void 0:qt.event)),Kn(Gt,"click",this.zv,{capture:!0}),this.Uv=t=>this.Wv(t||(null==qt?void 0:qt.event)),Kn(Gt,"mousemove",this.Uv,{capture:!0}),this.Vv=new fo(this.instance,co,this.Bv.bind(this)),this.Vv.startIfEnabledOrStop(),this.Gv=this.sn.bind(this),Kn(Gt,Bt,this.Gv),this.ko=!0)}jv(){var t;qt&&Gt&&(this.Hv&&qt.removeEventListener(Nt,this.Hv),this.zv&&Gt.removeEventListener("click",this.zv,{capture:!0}),this.Uv&&Gt.removeEventListener("mousemove",this.Uv,{capture:!0}),this.Gv&&Gt.removeEventListener(Bt,this.Gv),clearTimeout(this.Zv),null===(t=this.Vv)||void 0===t||t.stop(),this.ko=!1)}Qv(t,i){const e=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=function(t,i,e){let s=t;for(;s&&Pr(s)&&!Tr(s,"body");){if(s===e)return!1;let t;try{var n,r,o;t=null===(n=null!==(r=null===(o=s.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==r?r:qt)||void 0===n?void 0:n.getComputedStyle(s).position}catch(t){return!1}if(li(i,t))return!0;s=Lr(s)}return!1}(Dr(t),["fixed","sticky"],n);return{x:t.clientX+(r?0:s),y:t.clientY+(r?0:e),target_fixed:r,type:i}}Mr(t,i="click"){var e;if(Er(t.target)||!Vh(t))return;const s=this.Qv(t,i);(null===(e=this.rageclicks)||void 0===e?void 0:e.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&Gr(Dr(t),this.instance.config.rageclick)&&this.Zs(cs(cs({},s),{},{type:"rageclick"})),this.Zs(s)}Wv(t){!Er(t.target)&&Vh(t)&&(clearTimeout(this.Zv),this.Zv=setTimeout(()=>{this.Zs(this.Qv(t,"mousemove"))},500))}Zs(t){if(!qt)return;const i=this.Ir.disable_capture_url_hashes?ts(qt.location.href):qt.location.href,e=this.Ir.custom_personal_data_properties,s=this.Ir.mask_personal_data_properties?[...Io,...e||[]]:[],n=To(i,s,Ao);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(t)}yl(){this.Rt&&!_i(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:fo,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this.Lv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Jv=()=>{clearTimeout(this.Kv),this.Kv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",cs({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>cs(cs({},t),{},{[`$web_vitals_${i.name}_event`]:cs({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Xv=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},$i(null==t?void 0:t.name)||$i(null==t?void 0:t.value))return void Rh.error("Invalid metric received",t);const e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Yv(e);if(mi(s))return;const n=xi(t.navigationId)||"string"==typeof t.navigationId?`navigation:${t.navigationId}`:`url:${s}`;if(this.tf&&t.value>=this.tf)return void Rh.error("Ignoring metric with value >= "+this.tf,t);this.Rt.navigationKey!==n&&(this.Jv(),this.Kv=setTimeout(this.Jv,this.flushToCaptureTimeoutMs)),mi(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=mi(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0),o=cs(cs(cs({},t),e?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,gi(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){const i={};for(const e of Nh){const s="url"===e&&"string"==typeof t.attribution[e]?this.Yv(t.attribution[e]):t.attribution[e];mi(s)||(i[e]=s)}o.attribution=i}else delete o.attribution;mi(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Jv()},this.ef=()=>{if(this.ko)return;let t,i,e,s,n=!1;const r=ei.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.if])||("web-vitals"===this.if&&mi(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!mi(l)){const r=l.withoutAttribution,o=this.attributionMetrics;n=!mi(r),t=o.indexOf("LCP")>-1?l.onLCP:(null==r?void 0:r.onLCP)||l.onLCP,i=o.indexOf("CLS")>-1?l.onCLS:(null==r?void 0:r.onCLS)||l.onCLS,e=o.indexOf("FCP")>-1?l.onFCP:(null==r?void 0:r.onFCP)||l.onFCP,s=o.indexOf("INP")>-1?l.onINP:(null==r?void 0:r.onINP)||l.onINP}if(!(t&&i&&e&&s))return void Rh.error("web vitals callbacks not loaded - not starting");const a={reportSoftNavs:this.useSoftNavs},h=n&&this.attributionMetrics.indexOf("INP")>-1?cs(cs({},a),{},{includeProcessedEventEntries:!1}):a;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Xv.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Xv.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&e(this.Xv.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&s(this.Xv.bind(this),h),this.ko=!0},this.Lv=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[b]),this.startIfEnabled()}get nf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i;const e=gi(this.nf)?null===(t=this.nf)||void 0===t?void 0:t.web_vitals_allowed_metrics:void 0;return $i(e)?(null===(i=this._instance.persistence)||void 0===i?void 0:i.props.$web_vitals_allowed_metrics)||jh:e}get flushToCaptureTimeoutMs(){return(gi(this.nf)?this.nf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=gi(this.nf)?this.nf.web_vitals_attribution:void 0;return ki(t)?t?jh:[]:fi(t)?t:Bh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=gi(this.nf)?this.nf.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get tf(){const t=gi(this.nf)&&xi(this.nf.__web_vitals_max_value)?this.nf.__web_vitals_max_value:Dh;return t>0&&6e4>=t?Dh:t}get isEnabled(){const t=null==Kt?void 0:Kt.protocol;if("http:"!==t&&"https:"!==t)return Rh.info("Web Vitals are disabled on non-http/https protocols"),!1;const i=gi(this.nf)?this.nf.web_vitals:ki(this.nf)?this.nf:void 0;return ki(i)?i:this.Lv}startIfEnabled(){this.isEnabled&&!this.ko&&(Rh.info("enabled, starting..."),this.Ho(this.ef))}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("capturePerformance"in i))return;const e=gi(i.capturePerformance)&&!!i.capturePerformance.web_vitals,s=gi(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[b]:e}),this._instance.persistence.register({[S]:s})),this.Lv=e,this.startIfEnabled()}get if(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ho(t){var i;const e=ei.__PosthogExtensions__,s=this.if,n=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&mi(n)&&(null==e?void 0:e.postHogWebVitalsCallbacks)?t():null==e||null===(i=e.loadExternalDependency)||void 0===i||i.call(e,this._instance,s,i=>{i?Rh.error("failed to load script",i):t()})}Yv(t){const i=t||(null==qt?void 0:qt.location.href);if(!i)return void Rh.error("Could not determine current URL");const e=this._instance.config.disable_capture_url_hashes?ts(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Io,...s||[]]:[];return To(e,n,Ao)}}},Ju={exceptionObserver:class{constructor(t){var i;this.ef=()=>{var t;if(!qt||!this.isEnabled||!(null===(t=ei.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions))return;const i=ei.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=ei.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=ei.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.sf&&this.Ir.capture_unhandled_errors&&(this.sf=i(this.captureException.bind(this))),!this.rf&&this.Ir.capture_unhandled_rejections&&(this.rf=e(this.captureException.bind(this))),!this.af&&this.Ir.capture_console_errors&&(this.af=s(this.captureException.bind(this)))}catch(t){Fh.error("failed to start",t),this.lf()}},this._instance=t,this.uf=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[g]),this.wt=new zi(cs(cs({},function(t={}){var i,e,s,n;return{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:Fh})),this.Ir=this.hf(),this.startIfEnabledOrStop()}hf(){const t=this._instance.config.capture_exceptions;let i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return gi(t)?i=cs(cs({},i),t):(mi(t)?this.uf:t)&&(i=cs(cs({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Ir.capture_console_errors||this.Ir.capture_unhandled_errors||this.Ir.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Fh.info("enabled"),this.lf(),this.Ho(this.ef)):this.lf()}Ho(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"exception-autocapture",i=>{if(i)return Fh.error("failed to load script",i);t()})}lf(){var t,i,e;null===(t=this.sf)||void 0===t||t.call(this),this.sf=void 0,null===(i=this.rf)||void 0===i||i.call(this),this.rf=void 0,null===(e=this.af)||void 0===e||e.call(this),this.af=void 0}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"autocaptureExceptions"in i&&(this.uf=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[g]:this.uf}),this.Ir=this.hf(),this.startIfEnabledOrStop())}onConfigChange(){this.Ir=this.hf()}captureException(t){try{var i,e,s;const n=null!==(i=null==t||null===(e=t.$exception_list)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(n))return void Fh.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.cf=[],this.df=new vs([new As,new qs,new Ds,new Rs,new Hs,new zs,new Bs,new Us],function(t,...i){return(e,s=0)=>{const n=[],r=e.split("\n"),o=Math.min(r.length,s+1e3),l=[];for(let e=s;o>e;e++){const s=r[e];if(s.length>1024)continue;const o=Es.test(s)?s.replace(Es,"$1"):s;if(!o.match(/\S*Error: /)){for(const e of i){const i=e(o,t);if(i){n.push(i);const t=Ts(n);if(t){for(let i=l.length-1;i>=0;i--){const e=l[i];if(t.start>=e.start+e.length)break;l.pop()}l.push(t)}break}}if(Is(n,l)>=50)break}}const a=[...l].sort((t,i)=>i.start-t.start),h=a[a.length-1];if(h){const t=Fs(n,h);n.splice(h.start-t,t);for(const i of a)i.start-=t}for(const t of a)Cs(n,t);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){const i=t.map(t=>`${t.function}|${t.filename}|${t.lineno}|${t.colno}|${t.module}`);let e=0;for(let t=1;i.length>t;t++)Os(i,t,e)&&(e=t);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];const i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return cs(cs({},t),{},{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",$s,ks)),this._instance=t,this.cf=null!==(i=null===(e=this._instance.persistence)||void 0===e?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.vf=Js(this.ff()),this.pf=new Ys(this.vf)}onConfigChange(){this.vf=Js(this.ff()),this.pf.setConfig(this.vf)}onRemoteConfig(t){var i,e,s;if(!t.ok)return;const n=t.config;if(!("errorTracking"in n))return;const r=null!==(i=null===(e=n.errorTracking)||void 0===e?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.cf=r,this._instance.persistence&&this._instance.persistence.register({[_]:this.cf,[m]:o})}get gf(){var t;const i=!!this._instance.get_property(m),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.df.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.vf.enabled)try{if(!bi(t)||0===t.trim().length)return void wu.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:e,droppedKeys:s}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};const i=[];return{sanitizedProperties:Object.keys(t).reduce((e,s)=>Gs.has(s)?(i.push(s),e):(e[s]=t[s],e),{}),droppedKeys:i}}(this.mf(i));s.length>0&&wu.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.pf.add(cs({[Vs]:t,[Ws]:(new Date).toISOString()},e))}catch(t){wu.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{const i=t.$exception_list;if(this.yf(i)){if(this.bf(i))return this._f("Exception dropped: matched a suppression rule"),void wu.info("Skipping exception capture because a suppression rule matched");if(!this.gf&&this.wf(i))return this._f("Exception dropped: thrown by a browser extension"),void wu.info("Skipping exception capture because it was thrown by an extension");if(!this.gf&&this.kf(i))return this._f("Exception dropped: thrown by an injected browser script"),void wu.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Sf(i))return this._f("Exception dropped: thrown by the PostHog SDK"),void wu.info("Skipping exception capture because it was thrown by the PostHog SDK")}const e=this.vf.enabled&&$i(t.$exception_steps)?this.xf(t):t,s=function(){const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();s&&(e.$release_id=s);try{const t=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",fh:!0});return t&&this.pf.clear(),t}catch(t){return yu(t)||wu.error("Failed to capture exception event. Dropping this exception.",t),void this.pf.clear()}}catch(t){return void(yu(t)||wu.error("Failed to process exception event. Ignoring this exception.",t))}}xf(t){try{const i=this.pf.getAttachable();return 0===i.length?t:cs(cs({},t),{},{$exception_steps:i})}catch(i){return wu.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}_f(t){this.vf.enabled&&this.pf.add({[Vs]:t,[Ws]:(new Date).toISOString()})}mf(t){return gi(t)?cs({},t):{}}ff(){var t,i;return null!==(t=null===(i=this._instance.config.error_tracking)||void 0===i?void 0:i.exception_steps)&&void 0!==t?t:{}}bf(t){if(0===t.length)return!1;try{const i=t.reduce((t,{type:i,value:e})=>(bi(i)&&i.length>0&&t.$exception_types.push(i),bi(e)&&e.length>0&&t.$exception_values.push(e),t),{$exception_types:[],$exception_values:[]});return this.cf.some(t=>{const e=t.values.map(t=>{const e=Da[t.operator],s=i[t.key];if(!e||!s)return!1;const n=fi(t.value)?t.value:[t.value];return n.length>0&&e(n,s)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return wu.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}wf(t){const i=t.flatMap(t=>{var i,e;return null!==(i=null===(e=t.stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(({filename:t})=>!!t&&Su.some(i=>t.startsWith(i)));return 0!==e.length&&(!e.every(({filename:t})=>!!t&&t.startsWith($u))||t.some(({type:t,value:i})=>"NoResponse"===t||bi(i)&&xu.some(({value:t,exact:e})=>e?i===t:i.includes(t)))&&!i.some(({in_app:t,filename:i})=>t&&!(null==i?void 0:i.startsWith($u))))}kf(t){return t.some(({value:t})=>bi(t)&&ku.some(i=>t.includes(i)))}Sf(t){if(t.length>0){var i,e,s,n;const r=null!==(i=null===(e=t[0].stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}yf(t){return!$i(t)&&fi(t)}}},Yu=cs({productTours:class{get Il(){return this._instance.persistence}constructor(t){this.Cf=null,this.$f=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if("productTours"in i){var e,s;if(this.Il&&this.Il.register({[w]:!!i.productTours}),!Gh(this._instance))return!this.Cf&&$i(null===(e=this.Il)||void 0===e?void 0:e.props.ph_product_tours)||Wh.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.Cf)||void 0===s||s.stop(),this.Cf=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Cf&&Gh(this._instance)&&this.Ho(()=>this.Tf())}Ho(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.generateProductTours)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"product-tours",i=>{i?Wh.error("Could not load product tours script",i):t()})}Tf(){var t;!this.Cf&&(null===(t=ei.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)&&(this.Cf=ei.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i=!1){if(fi(this.$f)&&!i)return void t(this.$f,{isLoaded:!0});const e=this.Il;if(e){const s=e.props[et];if(fi(s)&&!i)return this.$f=s,void t(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!Gh(this._instance))return void t([],{isLoaded:!0});const s=i.statusCode;if(200!==s||!i.json){const e=`Product Tours API could not be loaded, status: ${s}`;return 0===s?i.error||Wh.warn(e):Wh.error(e),void t([],{isLoaded:!1,error:e})}const n=fi(i.json.product_tours)?i.json.product_tours:[];this.$f=n,e&&e.register({[et]:n}),t(n,{isLoaded:!0})}})}getActiveProductTours(t){$i(this.Cf)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Cf.getActiveProductTours(t)}showProductTour(t){var i;null===(i=this.Cf)||void 0===i||i.showTourById(t)}previewTour(t){this.Cf?this.Cf.previewTour(t):this.Ho(()=>{var i;this.Tf(),null===(i=this.Cf)||void 0===i||i.previewTour(t)})}dismissProductTour(){var t;null===(t=this.Cf)||void 0===t||t.dismissTour("user_clicked_skip")}nextStep(){var t;null===(t=this.Cf)||void 0===t||t.nextStep()}previousStep(){var t;null===(t=this.Cf)||void 0===t||t.previousStep()}clearCache(){var t;this.$f=null,null===(t=this.Il)||void 0===t||t.unregister("ph_product_tours")}resetTour(t){var i;null===(i=this.Cf)||void 0===i||i.resetTour(t)}resetAllTours(){var t;null===(t=this.Cf)||void 0===t||t.resetAllTours()}cancelPendingTour(t){var i;null===(i=this.Cf)||void 0===i||i.cancelPendingTour(t)}}},Wu),Xu={siteApps:class{constructor(t){this._instance=t,this.If=0,this.Mf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Ef(t,i){if(!i)return;const e=this.globalsForEvent(i);this.Mf.push(e),this.Mf.length>1e3&&(this.Mf=this.Mf.slice(10))}get siteAppLoaders(){var t;return null===(t=ei._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.Ef.bind(this));this.Pf=()=>{t(),this.Mf=[],this.Pf=void 0}}}globalsForEvent(t){var i,e,s,n,r,o,l;if(!t)throw new Error("Event payload is required");const a={},h=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[t,i]of Object.entries(u))a[t]={id:h[t],type:t,properties:i};const{$set_once:d,$set:c}=t;return{event:cs(cs({},cn(t,Kh)),{},{properties:cs(cs(cs({},t.properties),c?{$set:cs(cs({},null!==(i=null===(e=t.properties)||void 0===e?void 0:e.$set)&&void 0!==i?i:{}),c)}:{}),d?{$set_once:cs(cs({},null!==(s=null===(n=t.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=t.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(l=t.properties)||void 0===l?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Rf(t){var i;const e=null===(i=t.tagName)||void 0===i?void 0:i.toLowerCase();if("style"===e&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(t)||(Jh.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===e&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(t)||(Jh.error("prepare_external_dependency_script returned null"),null)}return t}Af(){var t,i,e,s,n,r,o,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const a=null==Gt?void 0:Gt.defaultView,h=null==a||null===(t=a.Node)||void 0===t?void 0:t.prototype;if(!a||!h)return()=>{};if(this.If++,this.Ff)return this.Of();const u=[],d=this,c=new WeakSet,v=(t,i,e)=>{if(!(null==t?void 0:t[i]))return;const s=t[i];t[i]=e(s),u.push(()=>{t[i]=s})},f=t=>{if(c.has(t))return t;const i=d.Rf(t);return i&&c.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!wi(t));return v(h,"appendChild",t=>function(i){const e=f(i);return e?t.call(this,e):i}),v(h,"insertBefore",t=>function(i,e){const s=f(i);return s?t.call(this,s,e):i}),v(h,"replaceChild",t=>function(i,e){const s=f(i);return s?t.call(this,s,e):e}),[null===(i=a.Element)||void 0===i?void 0:i.prototype,null===(e=a.Document)||void 0===e?void 0:e.prototype,null===(s=a.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(t=>{v(t,"append",t=>function(...i){return t.apply(this,p(i))}),v(t,"prepend",t=>function(...i){return t.apply(this,p(i))})}),[null===(n=a.Element)||void 0===n?void 0:n.prototype,null===(r=a.CharacterData)||void 0===r?void 0:r.prototype,null===(o=a.DocumentType)||void 0===o?void 0:o.prototype].forEach(t=>{v(t,"before",t=>function(...i){return t.apply(this,p(i))}),v(t,"after",t=>function(...i){return t.apply(this,p(i))}),v(t,"replaceWith",t=>function(...i){const e=p(i);return i.length&&!e.length?void 0:t.apply(this,e)})}),v(null===(l=a.Element)||void 0===l?void 0:l.prototype,"insertAdjacentElement",t=>function(i,e){const s=f(e);return s?t.call(this,i,s):null}),this.Ff=()=>{u.forEach(t=>t()),this.Ff=void 0},this.Of()}Of(){let t=!1;return()=>{var i;t||(t=!0,this.If--,0===this.If&&(null===(i=this.Ff)||void 0===i||i.call(this)))}}Df(t,i=!0){const e=this.Af();try{const s=t(e);return i&&e(),s}catch(t){throw e(),t}}setupSiteApp(t){const i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Mf.length&&(Jh.info(`Processing ${this.Mf.length} events for site app with id ${t.id}`),this.Mf.forEach(t=>this.Df(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null===(e=this.Pf)||void 0===e||e.call(this))};let s=!1;const n=n=>{i.errored=!n,i.loaded=!0,Jh.info(`Site app with id ${t.id} ${n?"loaded":"errored"}`),s&&e()};try{const{processEvent:e}=this.Df(i=>t.init({posthog:this._instance,callback(t){i(),n(t)}}),!1);e&&(i.processEvent=e),s=!0}catch(i){Jh.error(Yh+t.id,i),n(!1)}if(s&&i.loaded)try{e()}catch(e){Jh.error(`Error while processing buffered events PostHog app with config id ${t.id}`,e),i.errored=!0}}Lf(){const t=this.siteAppLoaders||[];for(const i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(const i of t)this.setupSiteApp(i)}Nf(t){if(0===Object.keys(this.apps).length)return;const i=this.globalsForEvent(t);for(const e of Object.values(this.apps))try{this.Df(()=>{var t;return null===(t=e.processEvent)||void 0===t?void 0:t.call(e,i)})}catch(i){Jh.error(`Error while processing event ${t.event} for site app ${e.id}`,i)}}onRemoteConfig(t){var i,e,s;if(null===(i=this.siteAppLoaders)||void 0===i?void 0:i.length)return this.isEnabled?(this.Lf(),void this._instance.on("eventCaptured",t=>this.Nf(t))):void Jh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(e=this.Pf)||void 0===e||e.call(this),!t.ok)return;const n=t.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:t,url:i}of n.siteApps){var r,o;ei[`__$$ph_site_app_${t}`]=this._instance,null===(r=ei.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,i,i=>{if(i)return Jh.error(Yh+t,i)})}else Jh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Zu={tracingHeaders:class{constructor(t){this._instance=t,this.qf=void 0,this.jf=void 0,this.Bf=void 0,this.ef=()=>{const t=this.Hf();var i,e;t?(mi(this.qf)&&(this.qf=null===(i=ei.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),mi(this.jf)&&(this.jf=null===(e=ei.__PosthogExtensions__)||void 0===e||null===(e=e.tracingHeadersPatchFns)||void 0===e?void 0:e._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.lf()}}initialize(){this.startIfEnabledOrStop()}Ho(t){var i,e,s;(null===(i=ei.__PosthogExtensions__)||void 0===i?void 0:i.tracingHeadersPatchFns)?t():null===(e=ei.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"tracing-headers",i=>{if(i)return Ah.error("failed to load script",i);t()})}zf(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Hf(){const t=this.zf();return fi(t)?(fi(this.Bf)?this.Bf.splice(0,this.Bf.length,...t):this.Bf=[...t],t.length>0?this.Bf:void 0):(fi(this.Bf)&&this.Bf.splice(0),this.Bf=t||void 0,this.Bf)}lf(){var t,i;null===(t=this.qf)||void 0===t||t.call(this),null===(i=this.jf)||void 0===i||i.call(this),this.qf=void 0,this.jf=void 0}startIfEnabledOrStop(){this.Hf()?this.Ho(this.ef):this.lf()}}},Qu=cs({surveys:class extends tu{constructor(t){var i;super(new ou(t),(i=t,{get projectToken(){return i.config.token},kv:new ru(i)})),this._instance=t}Vh(t,i){const e=i.query?ra(t,i.query):t;return new Promise(t=>{var s;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})})}}},Wu),td={toolbar:class{constructor(t){this.instance=t}Uf(t){ei.ph_toolbar_state=t}Wf(){var t;return null!==(t=ei.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,i=void 0,e=void 0){var s,n;if(Jn(this.instance.config))return!1;if(!qt||!Gt)return!1;t=null!==(s=t)&&void 0!==s?s:qt.location,e=null!==(n=e)&&void 0!==n?n:qt.history;try{if(!i){try{qt.localStorage.setItem("test","test"),qt.localStorage.removeItem("test")}catch(t){return!1}i=null==qt?void 0:qt.localStorage}const s=lu||Co(t.hash,"__posthog")||Co(t.hash,"state");let n;const r=s?is(()=>JSON.parse(atob(decodeURIComponent(s))))||is(()=>JSON.parse(decodeURIComponent(s))):null;return r&&"ph_authorize"===r.action?(n=r,n.source="url",n&&Object.keys(n).length>0&&(r.desiredHash?t.hash=r.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):(n=JSON.parse(i.getItem(au)||"{}"),n.source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}Vf(t){const i=ei.ph_load_toolbar||ei.ph_load_editor;!$i(i)&&pi(i)?i(t,this.instance):hu.warn("No toolbar load function found")}loadToolbar(t){const i=!!(null==Gt?void 0:Gt.getElementById("__POSTHOG_TOOLBAR__"));if(!qt||i)return!1;const e="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=cs(cs({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},e?{instrument:!1}:{});if(qt.localStorage.setItem(au,JSON.stringify(cs(cs({},s),{},{source:void 0}))),2===this.Wf())this.Vf(s);else if(0===this.Wf()){var n,r;this.Uf(1),null===(n=ei.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",t=>{if(t)return hu.error("[Toolbar] Failed to load",t),void this.Uf(0);this.Uf(2),this.Vf(s)}),Kn(qt,"turbolinks:load",()=>{this.Uf(0),this.loadToolbar(s)})}return!0}Gf(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,i=void 0,e=void 0){return this.maybeLoadToolbar(t,i,e)}}},id=cs({experiments:class t{get Ir(){return this._instance.config}constructor(i){this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=(i=!1)=>{this.getWebExperiments(i=>{t.Zf("retrieved web experiments from the server"),this.Qf=new Map,i.forEach(i=>{if(i.feature_flag_key){var e;this.Qf&&(t.Zf("setting flag key ",i.feature_flag_key," to web experiment ",i),null===(e=this.Qf)||void 0===e||e.set(i.feature_flag_key,i));const s=this._instance.getFeatureFlag(i.feature_flag_key);bi(s)&&i.variants[s]&&this.Jf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(const e in i.variants){const s=i.variants[e];t.Kf(s,this._instance)&&this.Jf(i.name,e,s.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.Zf(Eu);else if(!this.Ir.disable_web_experiments){if($i(this.Qf))return this.Qf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Zf("applying feature flags",i),i.forEach(t=>{var i;if(this.Qf&&(null===(i=this.Qf)||void 0===i?void 0:i.has(t))){var e;const i=this._instance.getFeatureFlag(t),s=null===(e=this.Qf)||void 0===e?void 0:e.get(t);i&&(null==s?void 0:s.variants[i])&&this.Jf(s.name,i,s.variants[i].transforms)}})}}previewWebExperiment(){const i=t.getWindowLocation();if(null==i?void 0:i.search){const e=Po(null==i?void 0:i.search,"__experiment_id"),s=Po(null==i?void 0:i.search,"__experiment_variant");e&&s&&(t.Zf(`previewing web experiments ${e} && ${s}`),this.getWebExperiments(t=>{this.Xf(parseInt(e),s,t)},!1,!0))}}loadIfEnabled(){this.Ir.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Ir.disable_web_experiments&&!e)return t([]);const s=this._instance.get_property("$web_experiments");if(s&&!i)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Ir.token}`),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}Xf(i,e,s){const n=s.filter(t=>t.id===i);n&&n.length>0&&(t.Zf(`Previewing web experiment [${n[0].name}] with variant [${e}]`),this.Jf(n[0].name,e,n[0].variants[e].transforms))}static Kf(i,e){return!$i(i.conditions)&&t.Yf(i,e)&&t.tp(i)}static Yf(i,e){var s;if($i(i.conditions)||$i(null===(s=i.conditions)||void 0===s?void 0:s.url))return!0;const n=t.getWindowLocation();if(n){var r,o,l;const t=kr(e,n.href);return!(null===(r=i.conditions)||void 0===r?void 0:r.url)||Pu[null!==(o=null===(l=i.conditions)||void 0===l?void 0:l.urlMatchType)&&void 0!==o?o:"icontains"](i.conditions.url,t)}return!1}static getWindowLocation(){return null==qt?void 0:qt.location}static tp(t){var i;if($i(t.conditions)||$i(null===(i=t.conditions)||void 0===i?void 0:i.utm))return!0;const e=Do();if(e.utm_source){var s,n,r,o,l,a,h,u;const i=!(null===(s=t.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=t.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==e.utm_campaign,d=!(null===(r=t.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=t.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==e.utm_source,c=!(null===(l=t.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)||(null===(a=t.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)==e.utm_medium,v=!(null===(h=t.conditions)||void 0===h||null===(h=h.utm)||void 0===h?void 0:h.utm_term)||(null===(u=t.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==e.utm_term;return i&&c&&v&&d}return!1}static Zf(t,...i){jn.info(`[WebExperiments] ${t}`,i)}Jf(i,e,s){this._is_bot()?t.Zf(Eu):"control"!==e?s.forEach(s=>{if(s.selector){var n;t.Zf(`applying transform of variant ${e} for experiment ${i} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(t=>{const i=t;s.html&&(i.innerHTML=s.html),s.css&&i.setAttribute("style",s.css)})}}):t.Zf("Control variants leave the page unmodified.")}_is_bot(){return Wt&&this._instance?Fa(Wt,this.Ir.custom_blocked_useragents):void 0}}},Wu),ed={conversations:class{constructor(t){this._instance=t,this.ep=void 0,this._conversationsManager=null,this.np=!1,this.ne=null,this.sp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)return;if(this.rp=t.ok,!t.ok)return;const i=t.config.conversations;$i(i)||(ki(i)?this.ep=i:(this.ep=i.enabled,this.ne=i),this.loadIfEnabled())}reset(){var t;null===(t=this._conversationsManager)||void 0===t||t.reset(),this._conversationsManager=null,this.ep=void 0,this.ne=null,this.rp=void 0,this.sp=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.np)return;if(this._instance.config.disable_conversations)return;if(Jn(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=null==ei?void 0:ei.__PosthogExtensions__;if(t&&!mi(this.ep)&&this.ep)if(this.ne&&this.ne.token){this.np=!0;try{const i=t.initConversations;if(i)return this.op(i),void(this.np=!1);const e=t.loadExternalDependency;if(!e)return void this.ap(At);e(this._instance,"conversations",i=>{i||!t.initConversations?this.ap("Could not load conversations script",i):this.op(t.initConversations),this.np=!1})}catch(t){this.ap("Error initializing conversations",t),this.np=!1}}else Tu.error("Conversations enabled but missing token in remote config.")}op(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.sp=!1,Tu.info("Conversations loaded successfully")}catch(t){this.ap("Error completing conversations initialization",t)}else Tu.error("Cannot complete initialization: remote config is null")}ap(t,i){Tu.error(t,i),this._conversationsManager=null,this.np=!1,this.sp=!0}show(){this._conversationsManager?this._conversationsManager.show():Tu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.ep&&!wi(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Jn(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.rp?"remote_config_failed":mi(this.ep)?this.rp?"disabled_in_project":"remote_config_pending":this.ep?$i(this.ne)||!this.ne.token?"missing_token":(null==ei?void 0:ei.__PosthogExtensions__)?this.np?"initializing":this.sp?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return ji(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(Tu.warn(Cu),null)})()}getMessages(t,i){var e=this;return ji(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Tu.warn(Cu),null)})()}markAsRead(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Tu.warn(Cu),null)})()}getTickets(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Tu.warn(Cu),null)})()}requestRestoreLink(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Tu.warn(Cu),null)})()}restoreFromToken(t){var i=this;return ji(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Tu.warn(Cu),null)})()}restoreFromUrlToken(){var t=this;return ji(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Tu.warn(Cu),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}Sh(){var t;null===(t=this._conversationsManager)||void 0===t||t.setIdentity()}xh(){var t;null===(t=this._conversationsManager)||void 0===t||t.clearIdentity()}}},sd={logs:class{constructor(t){var i;this._instance=t,this.name="logs",this.lp=!1,this.up=!1,this.hp=!1,this.A=Bn("[logs]"),this.cp=cs(cs({},this.A),{},{error:(...t)=>{t.some(Du)||this.A.error(...t)}}),this.ol=[],this.dp=[],this._d=0,this.To=!1,this.vp=[],this.fp=[],this.pp=!1,this.gp=!1,this.mp=()=>{var t,i;this.To||(this._d=0,null===(t=this.yp)||void 0===t||t.onReconnect(),null===(i=this.bp)||void 0===i||i.onReconnect())},this._instance&&(null===(i=this._instance.config.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this.lp=!0),qt&&Kn(qt,"online",this.mp)}_p(t,i,e,s){var n;const r=Fu(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,e);return[new Mn(this.wp(t,i),r,this.cp,()=>this.kp(),t=>t(),void 0,s),r]}Sp(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.yp&&this.xp===i||(null===(e=this.yp)||void 0===e||e.reset(),this.xp=i,[this.yp,this.Cp]=this._p(()=>this.ol,t=>{this.ol=t})),this.yp}$p(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.bp&&this.Tp===i||(null===(e=this.bp)||void 0===e||e.reset(),this.Tp=i,[this.bp,this.Ip]=this._p(()=>this.dp,t=>{this.dp=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Ou)),this.bp}setup(t){var i;if(this.To)return;this.bo=t,(null===(i=this._instance)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this.lp=!0),(this.lp||this.Mp()&&this.Ep())&&this.Pp();let e=!1;const s=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.To?s.dispose():(this.Eo=s,e||this.loadIfEnabled())}dispose(){var t,i,e,s;this.To||(this.To=!0,this.Rp(),null===(t=this.Eo)||void 0===t||t.dispose(),this.Eo=void 0,this.bo=void 0,this.hp=!1,null==qt||qt.removeEventListener("online",this.mp),null===(i=this.Ap)||void 0===i||i.call(this),this.Ap=void 0,null===(e=this.yp)||void 0===e||e.reset(),null===(s=this.bp)||void 0===s||s.reset())}onRemoteConfig(t){var i,e;if(this.To)return;const s=t.ok?null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs:void 0;$i(s)?this.Fp():(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.register({$logs_capture_enabled_server_side:!!s}),s?(this.lp=!0,this.up||this.Pp(),this.loadIfEnabled()):this.Fp())}reset(){var t,i,e,s;this.Rp(),null===(t=this.yp)||void 0===t||t.clearQueue(),this.ol=[],null===(i=this.yp)||void 0===i||i.reset(),null===(e=this.bp)||void 0===e||e.clearQueue(),this.dp=[],null===(s=this.bp)||void 0===s||s.reset(),this._d=0}captureLog(t){this.To||this.Sp().captureLog(t)}captureConsoleLog(t){this.To||this.$p().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.To||this.$p().captureLog(t,{context:i,occurredAtMs:e})}Ep(){var t;return!!(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t[x])}Mp(){var t,i,e;return!(null===(t=this._instance)||void 0===t||null===(i=t.il)||void 0===i?void 0:i.call(t))||!!(null===(e=ei._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config)}$h(){var t;this.Rp(),null===(t=this.bp)||void 0===t||t.clearQueue(),this.dp=[]}Fp(){this.lp||this.Rp()}Pp(){var t;if(this.pp||!(null==ei?void 0:ei.console))return;const i=Fu(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs).maxBufferSize;let e=!0;this.fp.push(()=>{e=!1});for(const t of Mu){let s;try{s=Iu(ei.console[t])}catch(t){continue}s&&this.fp.push(Oh(ei.console,t,n=>{const r=(...s)=>{try{e&&this.Op(t,s,i)}catch(t){}return n.apply(ei.console,s)};return r.__rrweb_original__=s,r}))}this.pp=!0,this.Dp=setTimeout(()=>{this.Rp()},3e4)}Op(t,i,e){var s;if(this.pp&&!this.gp&&0!==i.length)if(null===(s=this._instance)||void 0===s?void 0:s.is_capturing()){if(e>this.vp.length){this.gp=!0;try{this.vp.push({level:t,args:i,occurredAtMs:Date.now(),context:this.kp()})}finally{this.gp=!1}}}else this.Rp()}Rp(){if(this.vp=[],this.pp){this.pp=!1,this.Dp&&(clearTimeout(this.Dp),this.Dp=void 0);for(const t of this.fp)t();this.fp=[]}}Lp(){const t=this.vp;return this.Rp(),t}get logger(){return this.Np||(this.Np={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.Np}flushLogs(t){t?this.qp(t):(this.yp&&this.yp.flush().catch(t=>this.jp(t)),this.bp&&this.bp.flush().catch(t=>this.jp(t)))}jp(t){Du(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.To||!this.lp||this.up||this.hp)return;const t=null==ei?void 0:ei.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Rp();const i=t.loadExternalDependency;if(!i)return this.A.error(At),void this.Rp();this.hp=!0;try{i(this._instance,"logs",i=>{if(this.hp=!1,this.To||!this.lp)return;const e=t.logs;if(i||!(null==e?void 0:e.initializeLogs))this.A.error("Could not load logs script",i),this.Rp();else{var s;const t=this.Lp();var n,r;this.Ap=e.initializeLogs(null!==(s=this.bo)&&void 0!==s?s:this._instance),this.up=!0,t.length>0&&(null===(n=e.replayConsoleBuffer)||void 0===n||n.call(e,null!==(r=this.bo)&&void 0!==r?r:this._instance,t))}})}catch(t){throw this.hp=!1,t}}wp(t,i){const s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===si.LogsQueue?t():void 0,setPersistedProperty(t,e){var s;t===si.LogsQueue&&i(null!==(s=e)&&void 0!==s?s:[])},js:t=>this.js(t),getLibraryId:()=>e.LIB_NAME,getLibraryVersion:()=>e.LIB_VERSION}}js(t){return new Promise(i=>{if(Fo(this._d,3))return void i({kind:"fatal",error:Ru(void 0,"logs endpoint is unreachable, dropping batch")});let e=!1;const s=t=>{e||(e=!0,clearTimeout(n),i(t))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Ru(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Bp(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{const i=t.statusCode;if(this.Hp(i),i>=200&&300>i)s({kind:"ok"});else if(413===i)s({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)s({kind:"fatal",error:new Error(`logs request failed with status ${i}`)});else{var e;0===i?(t.error||this.A.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Ru(t.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`logs request failed with status ${i}`)})}}})})}Hp(t){(0!==t||this._instance.__loaded)&&(this._d=Mo(t,this._d,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}qp(t){this.ol.length>0&&this.zp(t,this.ol,this.Cp,e.LIB_NAME,t=>{this.ol=t}),this.dp.length>0&&this.zp(t,this.dp,this.Ip,Ou,t=>{this.dp=t})}zp(t,i,s,n,r){if(0===i.length)return;const o=i.map(t=>t.record);r([]);const l=Pn(o,En(s,e.LIB_NAME,e.LIB_VERSION),n,e.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Bp(),data:l,compression:"best-available",batchKey:"logs",transport:t})}Bp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}kp(){var t;const i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:t,windowId:e,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=e,$i(s)||(i.sessionStartTimestamp=s),$i(n)||(i.lastActivityTimestamp=n)}if((null==ei||null===(t=ei.location)||void 0===t?void 0:t.href)&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?ts(ei.location.href):ei.location.href),this._instance.featureFlags){const t=this._instance.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}}},nd={metrics:class{constructor(t){this._instance=t,this.A=Bn("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.To)return;const i=!!(null===(t=this._instance.config.metrics)||void 0===t?void 0:t.network);i&&!this.Up?this.Up=(t=>{let i=!0;const e=()=>i?(t=>{var i;const e=null===(i=t.config.metrics)||void 0===i?void 0:i.network;return!0===e?{}:e||void 0})(t):void 0,s=qu(t,e),n=Vu(t,e);return()=>{i=!1,s(),n()}})(this._instance):!i&&this.Up&&(this.Up(),this.Up=void 0)}Sp(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.metrics;var e;return this.yp&&this.xp===i||(null===(e=this.yp)||void 0===e||e.reset(),this.xp=i,this.yp=new Rn(this.wp(),function(t){var i,e,s,n,r;const o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(i),this.A)),this.yp}count(t,i=1,e){this.Sp().count(t,i,e)}gauge(t,i,e){this.Sp().gauge(t,i,e)}histogram(t,i,e){this.Sp().histogram(t,i,e)}flush(t){if(!this.yp)return Promise.resolve();if(t){const i=this.yp.drainWindow();return i&&this.Ys(i,t),Promise.resolve()}return this.yp.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null===(t=this.yp)||void 0===t||t.reset()}dispose(){var t,i;this.To=!0,null===(t=this.Up)||void 0===t||t.call(this),this.Up=void 0,null===(i=this.yp)||void 0===i||i.reset()}wp(){const t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:t=>i.Ys(t),getLibraryId:()=>e.LIB_NAME,getLibraryVersion:()=>e.LIB_VERSION}}Ys(t,i){return new Promise(e=>{let s=!1;const n=t=>{s||(s=!0,clearTimeout(r),e(t))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(cs(cs({method:"POST",url:this.Wp(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i}),{},{fireCallbackOnDrop:!0,callback(t){const i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error(`metrics request failed with status ${i}`)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`metrics request failed with status ${i}`)})}}}))})}Wp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};wh.__defaultExtensionClasses=cs({},cs(cs(cs(cs(cs(cs(cs(cs(cs(cs(cs(cs(cs({},Wu),Gu),Ku),Ju),Yu),Xu),Qu),Zu),td),id),ed),sd),nd))}();
|
|
2
2
|
//# sourceMappingURL=default-extensions.js.map
|