posthog-js 1.428.2 → 1.428.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/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/default-extensions.js.map +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/extension-bundles.js.map +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.no-external.js +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/autocapture.js +6 -1
- package/lib/src/autocapture.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){var e=["retriesPerformedSoFar"],t=["$set_once","$set"];function i(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},s.apply(null,arguments)}function r(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function n(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var o=e.apply(t,i);function a(e){r(o,s,n,a,l,"next",e)}function l(e){r(o,s,n,a,l,"throw",e)}a(void 0)})}}!function(r){var o="0.8.2",a={DEBUG:(!1,!1),LIB_VERSION:(o,"1.428.2"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:o},l=a,u="$people_distinct_id",c="distinct_id",d="$device_id",h="$device_model",_="__alias",p="__cmpns",g="$fbc",v="$fbc_persistence",f="__timers",m="$autocapture_disabled_server_side",y="$heatmaps_enabled_server_side",b="$exception_capture_enabled_server_side",w="$error_tracking_suppression_rules",S="$error_tracking_capture_extension_exceptions",k="$web_vitals_enabled_server_side",C="$dead_clicks_enabled_server_side",x="$product_tours_enabled_server_side",E="$logs_capture_enabled_server_side",P="$web_vitals_allowed_metrics",F="$session_recording_remote_config",I="$session_recording_enabled_server_side",T="$replay_sample_rate",R="$replay_override_sampling",A="$replay_override_linked_flag",M="$replay_override_url_trigger",L="$replay_override_event_trigger",O="$sesid",D="$session_is_sampled",B="$session_past_minimum_duration",q="$session_recording_url_trigger_activated_session",H="$session_recording_event_trigger_activated_session",N="$debug_first_full_snapshot_timestamp",z="$sess_rec_flush_size",j="$enabled_feature_flags",V="$active_feature_flags",W="$early_access_features",U="$feature_flag_details",G="$feature_flag_payloads",K="$feature_flag_request_id",Q="$minimal_flag_called_events",J="$override_feature_flags",Y="$override_feature_flag_payloads",X="$stored_person_properties",Z="$stored_group_properties",ee="$groups",te="$surveys",ie="$surveys_loaded_at",se="$surveys_activated",re="$surveys_activated_session",ne="$surveys_activated_timestamps",oe="ph_product_tours",ae="$product_tours_activated",le="$product_tours_activated_session",ue="$conversations_widget_session_id",ce="$conversations_ticket_id",de="$conversations_widget_state",he="$conversations_user_traits",_e="$flag_call_reported",pe="$flag_call_reported_session_id",ge="$feature_flag_errors",ve="$feature_flag_evaluated_at",fe="$user_state",me="$client_session_props",ye="$capture_rate_limit",be="$initial_campaign_params",we="$initial_referrer_info",Se="$initial_person_info",ke="$epp",Ce="$posthog_cookieless",xe="$cookieless_mode",Ee="$sdk_debug_extensions_init_method",Pe="$sdk_debug_extensions_init_time_ms",Fe="$sdk_debug_recording_script_not_loaded",Ie="$sdk_debug_replay_event_trigger_status",Te="$sdk_debug_replay_linked_flag_trigger_status",Re="$sdk_debug_replay_matched_recording_trigger_groups",Ae="$sdk_debug_replay_pending_trigger_conditions",Me="$sdk_debug_replay_remote_trigger_matching_config",Le="$sdk_debug_replay_trigger_groups_count",$e="$sdk_debug_replay_url_trigger_status",Oe="$session_recording_start_reason",De="PostHog loadExternalDependency extension not found.",Be="anonymous",qe="identified",He="identified_only",Ne="visibilitychange",ze="beforeunload",je="$pageview",Ve="$pageleave",We="$identify",Ue="$groupidentify",Ge="u">typeof window?window:void 0,Ke="u">typeof globalThis?globalThis:Ge,Qe=null==Ke?void 0:Ke.navigator,Je=null==Ke?void 0:Ke.document,Ye=null==Ke?void 0:Ke.location,Xe=null==Ke?void 0:Ke.fetch,Ze=null!=Ke&&Ke.XMLHttpRequest&&"withCredentials"in new Ke.XMLHttpRequest?Ke.XMLHttpRequest:void 0,et=null==Ke?void 0:Ke.AbortController,tt=null==Ke?void 0:Ke.CompressionStream,it=null==Qe?void 0:Qe.userAgent;function st(){return!(!Ge||!1===Ge.navigator.onLine)}var rt="undefined"!=typeof globalThis?globalThis:Ge;rt&&"undefined"==typeof self&&(rt.self=rt),rt&&"undefined"==typeof File&&(rt.File=function(){});var nt=null!=Ge?Ge:{},ot=["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"],at=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return ot.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})};function lt(e,t){return-1!==e.indexOf(t)}var ut=function(e){return e.trim()},ct=function(e){return e.replace(/^\$/,"")};function dt(e){var t,i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}var ht=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),_t=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),pt=["$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"],gt=["token"],vt=Object.prototype,ft=vt.hasOwnProperty,mt=vt.toString,yt=Array.isArray||function(e){return"[object Array]"===mt.call(e)},bt=e=>"function"==typeof e,wt=e=>e===Object(e)&&!yt(e),St=e=>{if(wt(e)){for(var t in e)if(ft.call(e,t))return!1;return!0}return!1},kt=e=>void 0===e,Ct=e=>"[object String]"==mt.call(e),xt=e=>Ct(e)&&0===e.trim().length,Et=e=>null===e,Pt=e=>kt(e)||Et(e),Ft=e=>"[object Number]"==mt.call(e)&&e==e,It=e=>Ft(e)&&e>0,Tt=e=>"[object Boolean]"===mt.call(e),Rt=e=>lt(pt,e),At=e=>lt(gt,e);function Mt(e){return null===e||"object"!=typeof e}function Lt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function $t(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Dt(e,Error)}}function Ot(e){return"u">typeof Event&&Dt(e,Event)}function Dt(e,t){try{return e instanceof t}catch(e){return!1}}var Bt=[!0,"true",1,"1","yes"],qt=e=>lt(Bt,e),Ht=[!1,"false",0,"0","no"];function Nt(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),Ft(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Nt(null!=r?r:i,t,i,s))}var zt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Nt(e.bucketSize,0,100,e._logger),this._refillRate=Nt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Nt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):this._buckets[s]=r={tokens:this._bucketSize,lastAccess:i},0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}},jt="Mobile",Vt="Android",Wt="Tablet",Ut="Android Tablet",Gt="iPad",Kt="Apple Watch",Qt="Safari",Jt="BlackBerry",Yt="Samsung Internet",Xt="Chrome",Zt="Chrome iOS",ei="Internet Explorer",ti="Internet Explorer Mobile",ii="Opera",si="Microsoft Edge",ri="Firefox",ni="Firefox iOS",oi="Nintendo",ai="PlayStation",li="Xbox",ui="Android Mobile",ci="Mobile Safari",di="Windows",hi="Windows Phone",_i="Nokia",pi="Ouya",gi="Generic "+jt.toLowerCase(),vi="Generic "+Wt.toLowerCase(),fi="Konqueror",mi="Oculus Browser",yi="Vivaldi",bi="Yandex",wi="Whale",Si="DuckDuckGo",ki="Pale Moon",Ci="Waterfox",xi="Brave",Ei="Claude",Pi="Codex",Fi="ChatGPT",Ii="Google Search App",Ti=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ri=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ai=new RegExp(li,"i"),Mi=new RegExp("PlayStation \\w+","i"),Li=new RegExp("Nintendo \\w+","i"),$i=new RegExp("BlackBerry|PlayBook|BB10","i"),Oi={"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"},Di=function(e,t,i,s){t=t||"";var r=function(e){return null!=e&&e.brave?xi:null}(i);return r||(null!=s&&s.detectGoogleSearchApp&<(e,"GSA/")?Ii:lt(e," OPR/")&<(e,"Mini")?"Opera Mini":lt(e," OPR/")?ii:$i.test(e)?Jt:lt(e,"IEMobile")||lt(e,"WPDesktop")?ti:lt(e,"OculusBrowser")?mi:lt(e,"SamsungBrowser")?Yt:lt(e,"Edge")||lt(e,"Edg/")?si:lt(e,"Vivaldi/")?yi:lt(e,"YaBrowser/")?bi:lt(e,"Whale/")?wi:lt(e,"DuckDuckGo/")||lt(e,"Ddg/")?Si:lt(e,"Claude/")?Ei:lt(e,"Codex/")?Pi:lt(e,"ChatGPT/")?Fi:lt(e,"FBIOS")?"Facebook Mobile":lt(e,"UCWEB")||lt(e,"UCBrowser")?"UC Browser":lt(e,"CriOS")?Zt:lt(e,"CrMo")||lt(e,Xt)?Xt:lt(e,Vt)&<(e,Qt)?ui:lt(e,"FxiOS")?ni:lt(e.toLowerCase(),fi.toLowerCase())?fi:lt(e,"Brave/")?xi:((e,t)=>t&<(t,"Apple")||function(e){return lt(e,Qt)&&!lt(e,Xt)&&!lt(e,Vt)}(e))(e,t)?lt(e,jt)?ci:Qt:lt(e,"PaleMoon/")?ki:lt(e,"Waterfox/")?Ci:lt(e,ri)?ri:lt(e,"MSIE")||lt(e,"Trident/")?ei:lt(e,"Gecko")?ri:"")},Bi={[ti]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[si]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Xt]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Zt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Qt]:[Ti],[ci]:[Ti],[ii]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[ri]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ni]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[fi]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Jt]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ti],[ui]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Yt]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[mi]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[yi]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[bi]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[wi]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[xi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Ei]:[Ri],[Pi]:[Ri],[Fi]:[Ri],[Si]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[ki]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Ii]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ei]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},qi=function(e,t,i,s){var r=Bi[Di(e,t,i,s)];if(kt(r))return null;for(var n=0;r.length>n;n++){var o=e.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},Hi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[li,e&&e[1]||""]],[new RegExp(oi,"i"),[oi,""]],[new RegExp(ai,"i"),[ai,""]],[$i,[Jt,""]],[new RegExp(di,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[hi,""];if(new RegExp(jt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=Oi[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[di,s]}return[di,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=kt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Vt,[e[2],e[3],e[4]||"0"].join(".")]:[Vt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Ni=function(e){for(var t=0;Hi.length>t;t++){var i=Hi[t],s=i[1],r=i[0].exec(e),n=r&&(bt(s)?s(r,e):s);if(n)return n}return["",""]},zi=function(e){return Li.test(e)?oi:Mi.test(e)?ai:Ai.test(e)?li:new RegExp(pi,"i").test(e)?pi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?hi:/iPad/.test(e)?Gt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Kt:$i.test(e)?Jt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(_i,"i").test(e)?_i:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(jt).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Vt:Ut:new RegExp("(pda|Mobile)","i").test(e)?gi:new RegExp(Wt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?vi:""},ji=/\bFBAV\/(\d+(?:\.\d+)*)/i,Vi=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ji],[/\bFBAN\/EMA\b/i,"Facebook Lite",ji],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ji],[/\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"]],Wi="[Truncated]",Ui="[Unserializable]";function Gi(e){for(var t="",i=0;e.length>i;i++){var s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"�";else{var r=e.charCodeAt(i+1);56320>r||r>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}Date,Date;var Ki,Qi,Ji,Yi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Xi(e,t){return"string"==typeof(i=e)&&Yi.test(i)?e:t();var i}function Zi(e,t){var i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function es(e){return e?e.split("#")[0]:e}function ts(e,t){var i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function is(e,t,i){return ss.apply(this,arguments)}function ss(){return(ss=n(function*(e,t,i){var s;try{return yield Promise.race([e,new Promise((e,r)=>{s=ts(()=>{try{null==i||i(),e()}catch(e){r(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function rs(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Ji&&i.length===Qi?Ji:(Qi=i.length,Ji=i.reduce((i,s)=>{Ki||(Ki={});var r=Ki[s];if(r)i[r[0]]=r[1];else for(var n=e(s),o=n.length-1;o>=0;o--){var a,l=null==(a=n[o])?void 0:a.filename,u=t[s];if(l&&u){i[l]=u,Ki[s]=[l,u];break}}return i},{}))}}var ns=class{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(t),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var t=this;return n(function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&yt(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),s({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return n(function*(){var i=e;for(var s of t.modifiers)i=yield s(i);return i})()}convertToExceptionList(e,t){var i,r,n,o={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,s({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:rs(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i){void 0===i&&(i=0);var r=(i,s)=>{if(4>=s){var r=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,r)}};return s({},t,{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,i),next:e=>r(e,i+1)})}};function os(e,t,i,s,r){var n={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:!!t&&!t.startsWith("webkit-masked-url://")&&"<anonymous>"!==t};return kt(s)||(n.lineno=s),kt(r)||(n.colno=r),n}var as=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ls=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,us=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,cs=/\((\S*)(?::(\d+))(?::(\d+))\)/,ds=(e,t)=>{var i=ls.exec(e);if(i)return os(t,i[1],"?",+i[2],+i[3]);var s=us.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){var r=cs.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var n=as(s[1]||"?",s[2]);return os(t,n[1],n[0],s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},hs=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,_s=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ps=(e,t)=>{var i=hs.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=_s.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||"?",o=as(n,r);return os(t,r=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},gs=/\(error: (.*)\)/;var vs=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=Ct(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Lt(e,"DOMException")}isDOMError(e){return Lt(e,"DOMError")}},fs=class{match(e){return $t(e)}coerce(e,t){var i,s=this.getStack(e),r=void 0===s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:null==(i=t.syntheticException)?void 0:i.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},ms=class{match(e){return!!Lt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);var r=t.apply(e.message);return s({},r,{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:r.stack,synthetic:!0})}_hasUsableMessage(e){return Ct(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i,s=e,r=null!==(t=s.lineno)&&void 0!==t?t:0,n=null!==(i=s.colno)&&void 0!==i?i:0;if(Ct(s.filename)&&0!==s.filename.length&&0!==r)return"Error\n at "+s.filename+":"+r+":"+n}},ys=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,bs=class{match(e){return"string"==typeof e}coerce(e,t){var i,s=this.getInfos(e),r=s[0],n=s[1];return{type:null!=r?r:"Error",value:null!=n?n:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(ys);return s&&(t=s[1],i=s[2]),[t,i]}},ws=["fatal","error","warning","log","info","debug"];function Ss(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(t>=r.length)return s===i.length?r:r.length>t?r.slice(0,t)+"...":r}return""}var ks=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null==(s=t.syntheticException)?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ot(e))return e.constructor.name;var t="name"in e?e.name:void 0;return Ct(t)&&!xt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+Ss(e)}isSeverityLevel(e){return Ct(e)&&!xt(e)&&ws.indexOf(e)>=0}getStack(e){try{return Ct(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Ct(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if($t(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},Cs=class{match(e){return Ot(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+Ss(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}},xs=class{match(e){return Mt(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}},Es=class{match(e){return Lt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ot(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Mt(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}},Ps="$message",Fs="$timestamp",Is=new Set([Ps,Fs]),Ts={enabled:!0,max_bytes:32768};function Rs(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Ts.enabled,max_bytes:Ms(e.max_bytes,Ts.max_bytes)}:s({},Ts)}var As=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=Rs(e)}setConfig(e){this._config=Rs(e),this._trimToMaxBytes()}add(e){var t=function(e){var t;try{t=dt(e)}catch(e){return}try{var i=JSON.parse(t);if(!wt(i))return;var s=i,r=s[Ps],n=s[Fs];if(!Ct(r)||0===r.trim().length)return;if(!Ct(n)&&!Ft(n))return;return{step:s,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,s=0;t.length>s;s++)"%"===t[s]?(i+=1,s+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map(e=>e.step)}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function Ms(e,t){if(!Ft(e)||1/0===e||-1/0===e)return t;var i=Math.floor(e);return 0>i?t:i}var Ls=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function $s(e){return"string"==typeof e||e}function Os(e){return"string"==typeof e?e:void 0}var Ds,Bs=["$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"],qs="NativeGzipValidationError",Hs=e=>e.length>=2&&31===e[0]&&139===e[1],Ns=(e,t)=>e===_t.GZipJS||t===_t.GZipJS||"gzip"===t,zs=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),js=e=>{throw Zi(qs,"Native gzip produced invalid output: "+e)},Vs=function(){var e=n(function*(e,t){18>e.size&&js("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Hs(i)&&8===i[2]||js("invalid-header");var s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Ds)return Ds;Ds=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Ds[e]=t>>>0}return Ds})(),i=4294967295,s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&js("invalid-crc");var r=t.length>>>0;s.getUint32(4,!0)!==r&&js("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function Ws(){return Ws=n(function*(e,t,i){void 0===t&&(t=!0);try{var s=(new TextEncoder).encode(e),r=new globalThis.CompressionStream("gzip"),o=r.writable.getWriter(),a=o.write(s).then(()=>o.close()).catch(function(){var e=n(function*(e){try{yield o.abort(e)}catch(e){}throw e});return function(t){return e.apply(this,arguments)}}()),l=new Response(r.readable).blob(),u=(yield Promise.all([l,a]))[0];return yield Vs(u,s),u}catch(e){if(null!=i&&i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}}),Ws.apply(this,arguments)}var Us={}.propertyIsEnumerable;function Gs(e,t){try{return Js(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Ks(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:Wi};if(i.remainingNodes--,Tt(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){var i=e.toString(),s=BigInt("9223372036854775808");return e>=s||-s>e?(null==t||t.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};var r=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:Gi(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:Wi};if(e instanceof Date){var n=e.getTime(),o=Number.isFinite(n)?e.toISOString():String(e);return{stringValue:"string"==typeof o?Gi(o):String(o)}}i.ancestors.add(e);try{try{var a=e.toJSON;if("function"==typeof a)return Ks(a.call(e),t,i,s+1)}catch(e){}return yt(e)?{arrayValue:{values:Qs(e,t,i,s+1)}}:{kvlistValue:{values:Js(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:Gi(String(e))}}function Qs(e,t,i,s){for(var r=[],n=Math.min(e.length,1e3),o=0;n>o&&i.remainingNodes>0;o++)try{var a=o in e?e[o]:void 0;if(Pt(a))continue;r.push(Ks(a,t,i,s))}catch(e){r.push({stringValue:Ui})}return e.length>o&&r.push({stringValue:Wi}),r}function Js(e,t,i,s){var r=[];for(var n in e)if(Us.call(e,n)){if(!n){null==t||t.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=e[n];if(Et(o)||kt(o))continue;r.push({key:Gi(n),value:Ks(o,t,i,s)})}catch(e){r.push({key:Gi(n),value:{stringValue:Ui}})}}return r}function Ys(e,t,i){return s({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":i})}var Xs={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var Zs={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}},er=Zs.info;function tr(e){try{return Gi(String(e))}catch(e){return Ui}}function ir(e,t,i,r){var n,o=Zs[e.level||"info"]||er,a=o.text,l=o.number,u=(void 0===(n=Ft(r)?r:void 0)&&(n=Date.now()),String(n)+"000000"),c={};t.distinctId&&(c.posthogDistinctId=t.distinctId),t.sessionId&&(c.sessionId=t.sessionId),t.windowId&&(c["window.id"]=t.windowId),Pt(t.sessionStartTimestamp)||(c.sessionStartTimestamp=String(t.sessionStartTimestamp)),Pt(t.lastActivityTimestamp)||(c.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(c["url.full"]=t.currentUrl),t.screenName&&(c["screen.name"]=t.screenName),t.appState&&(c["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(c.feature_flags=t.activeFeatureFlags);var d=s({},c),h=e.attributes;if(h){var _=[];try{_=Object.keys(h)}catch(e){_=[]}for(var p of _){var g=void 0;try{g=h[p]}catch(e){g=Ui}Object.defineProperty(d,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var v={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:a,body:{stringValue:tr(e.body)},attributes:Gs(d,i)};return e.trace_id&&(v.traceId=e.trace_id),e.span_id&&(v.spanId=e.span_id),kt(e.trace_flags)||(v.flags=e.trace_flags),v}function sr(e,t,i){return Ys(e,t,i)}function rr(e,t,i,s){return{resourceLogs:[{resource:{attributes:Gs(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var nr=class{constructor(e,t,i,s,r,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=e,this._config=t,this._logger=i,this._getContext=s,this._onReady=r,this._waitForStoragePersist=n,this._scopeName=o,this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._consecutiveFlushFailures=0,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(ht.LogsQueue,[])}reset(){this._clearFlushTimer(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushInBackground()}captureLog(e,t){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=e&&e.body){var s=this._runBeforeSend(e);if(null!==s)if(s.body){if(this._checkRateLimit()){var r={record:ir(s,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this._getContext(),this._logger,null==t?void 0:t.occurredAtMs)};this._onReady(()=>this._enqueue(r))}}else this._logger.info("Log was rejected in beforeSend function")}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=yt(t)?t:[t],s=e;for(var r of i)try{var n=r(s);if(!n)return this._logger.info("Log was rejected in beforeSend function"),null;s=n}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return s}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;var e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||(this._logger.warn("captureLog dropping logs: exceeded "+this._maxLogsPerInterval+" logs per "+this._rateCapWindowMs+"ms"),this._droppedWarned=!0),!1)}flush(){var e=this;return n(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return n(function*(){var t;e._clearFlushTimer();var i=null!==(t=e._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==t?t:[];if(0!==i.length)for(var s=i.length,r=0;i.length>0&&s>r;){var n,o,a=e._queueGeneration;e._evictedSinceAdvance=0;var l=Math.min(i.length,e._maxBatchRecordsPerPost),u=i.slice(0,l),c=rr(u.map(e=>e.record),e._buildResourceAttributes(),null!==(n=e._scopeName)&&void 0!==n?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),d=yield e._instance._sendLogsBatch(c);if(e._queueGeneration!==a)return;if("too-large"===d.kind&&u.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(u.length/2)),e._logger.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+e._maxBatchRecordsPerPost);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?e._logger.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(u.length),i=null!==(o=e._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==o?o:[],r+=u.length,"fatal"===d.kind)throw d.error}}})()}_persistQueueAdvance(e){var t=this;return n(function*(){var i,s=Math.max(0,e-t._evictedSinceAdvance),r=null!==(i=t._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(ht.LogsQueue,r.slice(s)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return sr(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==t?t:[];this._maxQueueSize>i.length||(i.shift(),this._evictedSinceAdvance++,this._logger.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(ht.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=ts(()=>{this._flushTimer=void 0,this._flushInBackground()},e))}_nextFlushDelay(){var e=Math.min(Math.max(0,this._consecutiveFlushFailures-1),6);return this._flushIntervalMs*Math.pow(2,e)}_hasQueuedRecords(){var e=this._instance.getPersistedProperty(ht.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return n(function*(){t._clearFlushTimer();var i=t.flush().catch(()=>{});void 0!==e?yield is(i,e):yield i})()}flushWithTimeout(e){var t=this;return n(function*(){var i=t.flush();yield is(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0},e=>{this._consecutiveFlushFailures++,this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._armFlushTimer(this._nextFlushDelay())})}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}},or=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ar(e){return String(e)+"000000"}function lr(e,t,i,s){var r="";return s&&(r=Object.keys(s).sort().map(e=>JSON.stringify(e)+":"+JSON.stringify(s[e])).join(",")),e+"\0"+t+"\0"+(null!=i?i:"")+"\0"+r}var ur=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._generation=0}count(e,t,i){void 0===t&&(t=1),this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var e=this,t=this._flushPromise,i=function(){var i=n(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this._flushPromise===i&&(this._flushPromise=null)});return this._flushPromise=i,i}drainWindow(){if(0===this._series.size)return null;var e=this._series;return this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._buildPayload(e)}reset(){this._generation++,this._clearFlushTimer(),this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set}_capture(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this._runBeforeSend(e);if(null!==t)if(t.name&&"string"==typeof t.name)if("number"==typeof t.value&&Number.isFinite(t.value))if("count"===t.type&&0>t.value)this._logger.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=t.attributes?s({},t.attributes):void 0,r=lr(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn("Dropping metric '"+t.name+"': attributes could not be serialized",e)}var n=this._series.get(r);if(!n){if(!this._admitNewSeries())return;n={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this._series.set(r,n)}var o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn("Metric name '"+t.name+"' is already used as a "+o+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this._fold(n,t.value),this._armFlushTimer()}else this._logger.warn("Dropping metric '"+t.name+"': value must be a finite number");else this._logger.warn("Dropping metric with empty name")}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn("Metric series cap reached ("+this._config.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}_fold(e,t){var i;switch(e.type){case"count":e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(or.length+1).fill(0)});var s=e.hist;s.count+=1,s.sum+=t,s.min=Math.min(s.min,t),s.max=Math.max(s.max,t),s.bucketCounts[function(e,t){for(var i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,or)]+=1}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=yt(t)?t:[t],s=e;for(var r of i)try{var n=r(s);if(!n)return this._logger.info("Metric was rejected in beforeSend function"),null;s=n}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return s}_armFlushTimer(){this._flushTimer||(this._flushTimer=ts(()=>{this._flushTimer=void 0,this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})},this._config.flushIntervalMs))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_doFlush(){var e=this;return n(function*(){if(0!==e._series.size){var t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;var i=e._generation,s=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(s.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._armFlushTimer();case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",s.error)}}})()}_buildPayload(e){return t=this._buildMetrics(e),i=function(e,t,i){return Ys(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Gs(i)},scopeMetrics:[{scope:{name:s,version:r},metrics:t}]}]};var t,i,s,r}_buildMetrics(e){var t=ar(Date.now()),i=new Map;for(var r of e.values()){var n,o=lr(r.type,r.name,r.unit,void 0),a=i.get(o);a||(a=s({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(o,a));var l=Gs(null!==(n=r.attributes)&&void 0!==n?n:{},this._logger),u=ar(r.windowStartMs);if("count"===r.type){var c,d={attributes:l,startTimeUnixNano:u,timeUnixNano:t,asDouble:null!==(c=r.total)&&void 0!==c?c:0};a.sum.dataPoints.push(d)}else if("gauge"===r.type){var h,_={attributes:l,timeUnixNano:t,asDouble:null!==(h=r.last)&&void 0!==h?h:0};a.gauge.dataPoints.push(_)}else r.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:or})}return Array.from(i.values())}_mergeWindowBack(e){var t,i;for(var s of e){var r=s[0],n=s[1],o=this._series.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(t=o.total)&&void 0!==t?t:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this._admitNewSeries()&&this._series.set(r,n)}}},cr=function(e,t){var i=(void 0===t?{}:t).debugEnabled,s={_log(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),n=1;s>n;n++)r[n-1]=arguments[n];Ge&&(a.DEBUG||Ge.POSTHOG_DEBUG||i)&&!kt(Ge.console)&&Ge.console&&("__rrweb_original__"in Ge.console[t]?Ge.console[t].__rrweb_original__:Ge.console[t])(e,...r)},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning(e){s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>cr(e+" "+t,i)};return s},dr=cr("[PostHog.js]"),hr=dr.createLogger;function _r(e,t){yt(e)&&e.forEach(t)}function pr(e,t){if(!Pt(e))if(yt(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(var i in e)ft.call(e,i)&&t(e[i],i)}var gr=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)void 0!==r[n]&&(e[n]=r[n]);return e};function vr(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var fr=function(e){try{return e()}catch(e){return}},mr=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){dr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),dr.critical(e)}}},yr=function(e){var t={};return pr(e,function(e,i){(Ct(e)&&e.length>0||Ft(e))&&(t[i]=e)}),t};function br(e){var t=s({},e);for(var i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}var wr=["herokuapp.com","vercel.app","netlify.app"];function Sr(e){var t=null==e?void 0:e.hostname;if(!Ct(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of wr)if(i===s)return!1;return!0}function kr(e,t,i,s){var r=null!=s?s:{},n=r.capture,o=r.passive;null==e||e.addEventListener(t,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function Cr(e){return"ph_toolbar_internal"===e.name}var xr=e=>{if(Je){try{for(var t=e+"=",i=Je.cookie.split(";").filter(e=>e.length),s=0;i.length>s;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ft(e)&&isFinite(e)&&Math.floor(e)===e});var Er=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>t||0>i||0>s||0>r||t>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|i>>>8,n[7]=i,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new e(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},Pr=class{generate(){var e=this.generateOrAbort();if(!kt(e))return e;this._timestamp=0;var t=this.generateOrAbort();if(kt(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e,t=(e=Date.now(),Ft(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0);if(t>this._timestamp)this._timestamp=t,this._resetCounter();else{if(this._timestamp>=t+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Er.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new Tr}},Fr=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ge&&!kt(Ge.crypto)&&crypto.getRandomValues&&(Fr=e=>crypto.getRandomValues(e));var Ir,Tr=class{nextUint32(){return this._buffer.length>this._cursor||(Fr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}},Rr=()=>Ar().toString(),Ar=()=>(Ir||(Ir=new Pr)).generate(),Mr="",Lr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var $r=null,Or={_is_supported(){if(!Et($r))return $r;if($r=!1,Je)try{var e="__ph_cookie_support_"+Rr();Or._set(e,"xyz"),$r='"xyz"'===xr(e),Or._remove(e)}catch(e){$r=!1}return $r},_error(e){dr.error("cookieStore error: "+e)},_get:xr,_parse(e){var t;try{t=JSON.parse(Or._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(!Je)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=Je),Mr)return Mr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+Rr();!Mr&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",Mr=n)}return Mr}(e);if(!i){var s=(e=>{var t=e.match(Lr);return t?t[0]:""})(e);s!==i&&dr.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(Je.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&dr.warn("cookieStore warning: large cookie, len="+u.length),Je.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=Je&&Je.cookie)try{Or._set(e,"",-1,t)}catch(e){return}}},Dr=null,Br={_is_supported(){if(!Et(Dr))return Dr;var e=!0;if(kt(Ge))e=!1;else try{var t="__mplssupport__";Br._set(t,"xyz"),'"xyz"'!==Br._get(t)&&(e=!1),Br._remove(t)}catch(t){e=!1}return e||dr.error("localStorage unsupported; falling back to cookie store"),Dr=e,e},_error(e){dr.error("localStorage error: "+e)},_get(e){try{return null==Ge?void 0:Ge.localStorage.getItem(e)}catch(e){Br._error(e)}return null},_parse(e){try{return JSON.parse(Br._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==Ge||Ge.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Br._error(e)}return!1},_remove(e){try{null==Ge||Ge.localStorage.removeItem(e)}catch(e){Br._error(e)}}},qr=[X,V,j,U,G,K,ve,ge,_e],Hr=[d,c,O,D,ke,Se,v,fe],Nr=e=>e+"_cpm",zr=["__proto__","constructor","prototype"],jr=e=>{if(!wt(e))return{};var t={};return Object.keys(e).forEach(i=>{-1===zr.indexOf(i)&&(t[i]=e[i])}),t},Vr=function(e,t){void 0===t&&(t=[]);var i={};return[...Hr,...t].forEach(t=>{var s=e[t];kt(s)||Et(s)||""===s||(i[t]=s)}),i},Wr=e=>{for(var t=5381,i=2166136261,s=0;e.length>s;s++){var r=e.charCodeAt(s);t=33*t^r,i=Math.imul(i^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Ur=(e,t)=>({p:t,f:Wr(JSON.stringify(e))}),Gr=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var i=Or._parse(Nr(e)),s=(null==i?void 0:i.f)===Wr(t)&&yt(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Kr=(e,t)=>t+"|"+(Or._get(Nr(e))||""),Qr={},Jr={_is_supported:()=>!0,_error(e){dr.error("memoryStorage error: "+e)},_get:e=>e in Qr?Qr[e]:null,_parse:e=>e in Qr?Qr[e]:null,_set:(e,t)=>(Qr[e]=t,!0),_remove(e){delete Qr[e]}},Yr=null,Xr={_is_supported(){if(!Et(Yr))return Yr;if(Yr=!0,kt(Ge))Yr=!1;else try{var e="__support__";Xr._set(e,"xyz"),'"xyz"'!==Xr._get(e)&&(Yr=!1),Xr._remove(e)}catch(e){Yr=!1}return Yr},_error(e){dr.error("sessionStorage error: ",e)},_get(e){try{return null==Ge?void 0:Ge.sessionStorage.getItem(e)}catch(e){Xr._error(e)}return null},_parse(e){try{return JSON.parse(Xr._get(e))||null}catch(e){}return null},_set(e,t){try{return null==Ge||Ge.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Xr._error(e)}return!1},_remove(e){try{null==Ge||Ge.sessionStorage.removeItem(e)}catch(e){Xr._error(e)}}},Zr=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get _storedConsent(){var e=this._storage._get(this._storageKey);return qt(e)?1:lt(Ht,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Br:Or,i=t._is_supported()?t:Jr;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;var s="localStorage"===e?Or:Br;s._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(qt(s._get(this._storageKey))),s._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==Qe?void 0:Qe.doNotTrack,null==Qe?void 0:Qe.msDoNotTrack,nt.doNotTrack,null==Qe?void 0:Qe.globalPrivacyControl].some(e=>qt(e))}};function en(e,t){var i,s=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!bt(s))return t;try{var r=s(t);return Ct(r)&&r?r:t}catch(e){return dr.error("Error in get_current_url, falling back to window.location.href",e),t}}function tn(e){return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function sn(e){return!!e&&1===e.nodeType}function rn(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function nn(e){return!!e&&3===e.nodeType}function on(e){return!!e&&11===e.nodeType&&sn(e.host)}function an(e){return e?ut(e).split(/\s+/):[]}function ln(e,t){var i=function(e){var t,i=null==Ge||null==(t=Ge.location)?void 0:t.href;return kt(i)?void 0:en(e,i)}(t);return!!(i&&e&&e.some(e=>i.match(e)))}function un(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return an(t)}function cn(e){return Pt(e)?null:ut(e).split(/(\s+)/).filter(e=>$n(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function dn(e){var t="";return En(e)&&!Pn(e)&&e.childNodes&&e.childNodes.length&&pr(e.childNodes,function(e){var i;nn(e)&&e.textContent&&(t+=null!==(i=cn(e.textContent))&&void 0!==i?i:"")}),ut(t)}function hn(e){var t;return kt(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var _n=["a","button","form","input","select","textarea","label"];function pn(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function gn(e,t){if(kt(t))return!0;var i,s=function(e){if(t.some(t=>pn(e,t)))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function vn(e){var t=e.parentNode;return!(!t||!sn(t))&&t}var fn=[".ph-no-autocapture","[data-ph-no-autocapture]"],mn=["next","previous","prev",">","<"],yn=[...mn,"+","-","−","–"],bn=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,wn=[".ph-no-rageclick",".ph-no-capture"],Sn=["","text","search","email","password","url","tel","number"];function kn(e,t){if(!Ge||Cn(e))return!1;var i,s,r,n,o;if(Tt(t)?(i=!!t&&wn,s=void 0,r=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:wn,s=null==t?void 0:t.content_ignorelist,r=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(r&&function(e){return!(!e||!sn(e))&&(!!rn(e,"textarea")||(rn(e,"input")?lt(Sn,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var a=xn(e,!1).targetElementList;return!function(e,t){if(!1===e||kt(e))return!1;var i;if(!0===e)i=mn;else{if(!yt(e))return!1;if(e.length>10)return dr.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(e=>{var t=e.safeText,s=e.ariaLabel;return i.some(e=>bn(t,e)||bn(s,e))})}(s,a.map(e=>{var t;return{safeText:dn(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}}))&&!gn(a,i)}var Cn=e=>!e||rn(e,"html")||!sn(e),xn=(e,t)=>{if(!Ge||Cn(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],r=e;r.parentNode&&!rn(r,"body");)if(on(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=vn(r);if(!n)break;if(t||_n.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=Ge.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}catch(e){}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};function En(e){for(var t=new Set,i=0,s=e;s.parentNode&&!rn(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);var r=un(s);if(lt(r,"ph-sensitive")||lt(r,"ph-no-capture"))return!1}if(lt(un(e),"ph-include"))return!0;var n=e.type||"";if(Ct(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!Ct(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function Pn(e){return!!(rn(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||rn(e,"select")||rn(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Fn=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}))$"),In=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Tn=[16,15,14,13],Rn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),An=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Mn=/[0-9A-Za-z_]/;function Ln(e){for(var t=0,i=!1,s=e.length-1;s>=0;s--){var r=e.charCodeAt(s)-48;i&&(r*=2)>9&&(r-=9),t+=r,i=!i}return t%10==0}function $n(e,t){if(void 0===t&&(t=!0),Pt(e))return!1;if(Ct(e)){if(e=ut(e),t?Fn.test((e||"").replace(/[- ]/g,"")):function(e){var t;for(In.lastIndex=0;t=In.exec(e);){var i=t[2];if(i)for(var s=i.replace(/[- ]/g,""),r=0;s.length>r;r++)for(var n of Tn){var o=r+n;if(s.length>=o){var a=s.slice(r,o);if(Fn.test(a)&&Ln(a))return!0}}}return!1}(e))return!1;if(t?Rn.test(e):function(e){var t;for(An.lastIndex=0;t=An.exec(e);){var i=t[1],s=t[3];if(!(i&&s&&Mn.test(i)&&Mn.test(s)))return!0}return!1}(e))return!1}return!0}function On(e){var t=dn(e);return $n(t=(t+" "+Dn(e)).trim())?t:""}function Dn(e){var t="";return e&&e.childNodes&&e.childNodes.length&&pr(e.childNodes,function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=dn(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Dn(e)).trim())}catch(e){dr.error("[AutoCapture]",e)}}),t}function Bn(e){return e.replace(/"|\\"/g,'\\"')}function qn(e){var t=e.attr__class;if(t)return yt(t)?t:an(t)}var Hn=hr("[Dead Clicks]"),Nn=()=>!0,zn=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(C)),s=e.instance.config.capture_dead_clicks;return Tt(s)?s:!!wt(s)||i},jn=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[C]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Hn.error("failed to load script",t):e()})}_start(){var e;if(Je){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=nt.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=wt(this.instance.config.capture_dead_clicks)?s({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=nt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(Je),Hn.info("starting...")}}else Hn.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Hn.info("stopping..."))}},Vn=hr("[SegmentIntegration]");function Wn(e,t,i){void 0===i&&(i=!0);var s=e.config.segment;if(!s)return t();!function(e,t,i){var s=e.config.segment;if(!s)return t();var r=s=>{var r=()=>s.anonymousId()||Rr();e.config.get_device_id=r,i&&s.id()&&(e.register({distinct_id:s.id(),$device_id:r()}),e.persistence.set_property(fe,qe)),t(i?void 0:s.anonymousId()||void 0)},n=s.user();"then"in n&&bt(n.then)?n.then(r):r(n)}(e,i=>{s.register(((e,t)=>{"undefined"!=typeof Promise&&Promise.resolve||Vn.warn("This browser does not have Promise support, and can not use the segment integration");var i=(i,s)=>{if(!s)return i;var r=!!t&&i.event.anonymousId===t&&!i.event.userId;r||i.event.userId||i.event.anonymousId===e.get_distinct_id()||(Vn.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),i.event.userId&&i.event.userId!==e.get_distinct_id()&&(Vn.info("UserId set, identifying with PostHog"),e.identify(i.event.userId));var n=e.calculateEventProperties(s,i.event.properties);return i.event.properties=Object.assign({},n,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return i(e,e.event.event)},page(e){return i(e,je)},identify(e){return i(e,We)},screen(e){return i(e,"$screen")}}})(e,i)).then(()=>{t()},e=>{Vn.error("Failed to register the Segment integration",e),t()})},i)}var Un="posthog-js";function Gn(e,t){var i=void 0===t?{}:t,r=i.organization,n=i.projectId,o=i.prefix,a=i.severityAllowList,l=void 0===a?["error"]:a,u=i.sendExceptionsToPostHog,c=void 0===u||u;return t=>{var i,a,u,d,h,_;if("*"!==l&&!l.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var p=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=p,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var g=(null==(i=t.exception)?void 0:i.values)||[],v=g.map(e=>s({},e,{stacktrace:e.stacktrace?s({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>s({},e,{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null==(a=g[0])?void 0:a.value)||t.message,$exception_type:null==(u=g[0])?void 0:u.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(h=g[0])?void 0:h.type,$sentry_tags:t.tags};return r&&n&&(f.$sentry_url=(o||"https://sentry.io/organizations/")+r+"/issues/?project="+n+"&query="+t.event_id),c&&(null==(_=e.exceptions)||_.sendExceptionEvent(f)),t}}var Kn=class{constructor(e,t,i,s,r,n){this.name=Un,this.setupOnce=function(o){o(Gn(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}},Qn=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(dr.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==Ge?void 0:Ge.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,u=r.lastContentY,c=r.maxContentY;if(!(kt(n)||kt(o)||kt(a)||kt(l)||kt(u)||kt(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?Nt(o/n,0,1,dr):1,h=n>1?Nt(a/n,0,1,dr):1,_=l>1?Nt(u/l,0,1,dr):1,p=l>1?Nt(c/l,0,1,dr):1;s=gr(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},Jn=["flags","surveys"],Yn={[u]:{exposure:"hidden"},[_]:{exposure:"hidden"},[p]:{exposure:"hidden"},[f]:{exposure:"hidden"},[v]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},[E]:{exposure:"hidden"},[b]:{exposure:"event"},[w]:{exposure:"hidden"},[S]:{exposure:"event"},[k]:{exposure:"event"},[C]:{exposure:"event"},[x]:{exposure:"hidden"},[P]:{exposure:"event"},[F]:{exposure:"hidden"},[I]:{exposure:"hidden"},[O]:{exposure:"hidden"},[D]:{exposure:"event"},[T]:{exposure:"event",shouldSkipFromEventProperties:e=>Et(e)},[B]:{exposure:"event"},[q]:{exposure:"event"},[H]:{exposure:"event"},[N]:{exposure:"event"},[z]:{exposure:"hidden"},[j]:{exposure:"hidden",storageGroup:"flags"},[V]:{exposure:"hidden",storageGroup:"flags"},[W]:{exposure:"hidden"},[U]:{exposure:"hidden",storageGroup:"flags"},[G]:{exposure:"hidden",storageGroup:"flags"},[K]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Q]:{exposure:"hidden",storageGroup:"flags"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[te]:{exposure:"hidden",storageGroup:"surveys"},[ie]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[se]:{exposure:"event"},[re]:{exposure:"hidden"},[ne]:{exposure:"hidden"},[oe]:{exposure:"hidden"},[ae]:{exposure:"hidden"},[le]:{exposure:"hidden"},[ue]:{exposure:"event"},[ce]:{exposure:"event"},[de]:{exposure:"event"},[he]:{exposure:"event"},[_e]:{exposure:"hidden"},[pe]:{exposure:"hidden"},[ee]:{exposure:"event"},[ge]:{exposure:"hidden"},[ve]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[fe]:{exposure:"hidden"},[me]:{exposure:"hidden"},[ye]:{exposure:"hidden"},[be]:{exposure:"hidden"},[we]:{exposure:"hidden"},[Se]:{exposure:"hidden"},[ke]:{exposure:"hidden"},[R]:{exposure:"event"},[A]:{exposure:"event"},[M]:{exposure:"event"},[L]:{exposure:"event"},[Ee]:{exposure:"event"},[Pe]:{exposure:"event"},[Fe]:{exposure:"event"},[Ie]:{exposure:"event"},[Te]:{exposure:"event"},[Re]:{exposure:"event"},[Ae]:{exposure:"event"},[Me]:{exposure:"event"},[Le]:{exposure:"event"},[$e]:{exposure:"event"},[Oe]:{exposure:"event"}},Xn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Zn=e=>{var t=Yn[e];if(t)return t;for(var i of Xn){var s=i[1];if(0===e.indexOf(i[0]))return s}},eo=(e,t)=>{try{var i;return JSON.stringify(e,(e,t)=>$t(t)?(null!=i||(i=new WeakMap),i.has(t)||i.set(t,br(t)),i.get(t)):"bigint"==typeof t?t.toString():t,t)}catch(t){return dt(e)}},to=e=>{var t=null==Je?void 0:Je.createElement("a");return kt(t)?null:(t.href=e,t)},io=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!yt(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){dr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},so=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");yt(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var h=a;return null!=o&&(h+="?"+u.join("&")),null!=r&&(h+="#"+r),h},ro=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},no=(e,t)=>e>=t&&st(),oo=(e,t,i,s)=>{if(0===e){if(st()){var r=t+1;return r===i&&s(),r}return t}return 0},ao=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],lo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...ao],uo="<masked>",co=["li_fat_id"];function ho(e,t,i){if(!Je)return{};var s,r=t?[...ao,...i||[]]:[],n=_o(so(Je.URL,r,uo),e);return gr((s={},pr(co,function(e){var t=xr(e);s[e]=t||null}),s),n)}function _o(e,t){var i=lo.concat(t||[]),s={};return pr(i,function(t){var i=io(e,t);s[t]=i||null}),s}function po(e){var t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!Et(t)){s.$search_engine=t;var r=Je?io(Je.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function go(){return navigator.language||navigator.userLanguage}var vo="$direct";function fo(){return(null==Je?void 0:Je.referrer)||vo}function mo(e,t,i){var s;void 0===i&&(i=!1);var r=e?[...ao,...t||[]]:[],n=null==(s=i?es(null==Ye?void 0:Ye.href):null==Ye?void 0:Ye.href)?void 0:s.substring(0,1e3);return{r:fo().substring(0,1e3),u:n?so(n,r,uo):void 0}}function yo(e,t){var i;void 0===t&&(t=!1);var s=e.r,r=e.u,n=t?es(r):r,o={$referrer:s,$referring_domain:null==s?void 0:s==vo?vo:null==(i=to(s))?void 0:i.host};if(n){o.$current_url=n;var a=to(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname,gr(o,_o(n))}return s&&gr(o,po(s)),o}function bo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function wo(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var So={flags:ve,surveys:ie},ko=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Co=e=>e+"_cookie_identity_change_pending",xo=e=>{var t="",i=0;for(var s of e){var r=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+r>1e3)break;t+=s,i+=r}return t},Eo="main",Po=[j,V,U,G,K,ve,Q,X],Fo=e=>-1!==Po.indexOf(e),Io=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},To=e=>{if(!e)return{};var t=JSON.parse(e);return wt(t)?t:{}},Ro=(e,t)=>{pr(e,(i,s)=>{var r=Zn(s);r&&"event"!==r.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})},Ao=class{constructor(e,t,i){if(void 0===i&&(i=!0),this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._facebookClickIdChangePending=!1,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=i,this.props={},this._campaign_params_url=void 0,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&dr.info("Persistence loaded",e.persistence,s({},this.props)),this.update_config(e,e,t),this.save(),Ge){var r=()=>this.flush();kr(Ge,"beforeunload",r,{capture:!1}),kr(Ge,"pagehide",r,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===(null==Ge?void 0:Ge.localStorage))&&e.key)if(e.key!==this._name){if(this._splitStorage){var t=Jn.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,Eo)},kr(Ge,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(e=>{var t=e[0],i=e[1],s=this._pendingCrossTabFeatureFlagChanges.get(t);if(Fo(t)&&!0!==s)if(!0!==i){var r=new Set(s||[]);i.forEach(e=>r.add(e)),r.size&&this._setCrossTabFeatureFlagChangesPending(t,r)}else this._setCrossTabFeatureFlagChangesPending(t,!0)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&Ge&&(Ge.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i){if(void 0===i&&(i=!0),this._disabled)return!1;var s,r;try{if(r=Br._get(e),Et(r)){var n=this._slotWriteState(t);return n.storageValue=null,t!==Eo&&(n.persisted=!1),!1}s=To(r)}catch(e){return!1}var o=t===Eo?s:Br._parse(this._name);if(o&&this._hasCrossTabFeatureFlagIdentityMismatch(o))return!1;var a=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===Eo&&this._splitStorage&&!Io(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,r),a}_hasCrossTabFeatureFlagIdentityMismatch(e){var t=this.props[c],i=e[c];return!kt(t)&&!kt(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){var r=this._slotWriteState(t);r.storageValue=s,t!==Eo&&(r.persisted=i);try{r.fingerprint=this._entryFingerprint(e,t)}catch(e){r.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){var s=!1;return Po.forEach(i=>{var r,n=null==(r=Zn(i))?void 0:r.storageGroup;if(!(t===Eo&&this._splitStorage&&n||t!==Eo&&n!==t)){var o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&Io(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),s=!0)}}),s&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),s}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;var e,t=Br._get(this._name),i=this._slotWriteState(Eo),s=!1,r=!1;if(t!==i.storageValue)if(Et(t))i.storageValue=null;else{if(e=To(t),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(e),this._crossTabFeatureFlagIdentityMismatch)return!1;r=this._mergeCrossTabFeatureFlagProperties(e,Eo,!1),!this._splitStorage||Io(this._partitionProps().main,e)?this._rememberCrossTabStorageFingerprint(e,Eo,!0,t):i.storageValue=t,s=!0}return this._splitStorage&&Jn.forEach(t=>{var i=Br._get(this._groupEntryName(t)),n=this._slotWriteState(t),o=e||{},a=s&&Po.some(e=>{var i;return(null==(i=Zn(e))?void 0:i.storageGroup)===t&&e in o});if(i!==n.storageValue||a){if(Et(i))return n.storageValue=null,n.persisted=!1,void(a&&(r=this._mergeCrossTabFeatureFlagProperties(o,t,!1)||r));var l=To(i);r=this._mergeCrossTabFeatureFlagProperties(l,t,!1)||r,this._rememberCrossTabStorageFingerprint(l,t,!0,i)}}),r}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);var i=Zn(e);null!=i&&i.volatile||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||Eo).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){Po.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{var e=Br._get(this._name),t=To(e);this._slotWriteState(Eo).storageValue=e,Po.forEach(e=>{var i,s=this._splitStorage?null==(i=Zn(e))?void 0:i.storageGroup:void 0,r=s?Br._get(this._groupEntryName(s)):null;if(s){var n=this._slotWriteState(s);n.storageValue=r,n.persisted=!Et(r)}var o=s&&!Et(r)?To(r):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,o[e],this.props[e]):e in o&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){var i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){var r=new Set(yt(t)?t:[]),n=new Set(yt(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?r.add(e):r.delete(e)),Array.from(r)}var o=wt(t)?s({},t):{},a=wt(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in a?o[e]=a[e]:delete o[e]}),o}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(Fo(e)){var s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0!==s){var r=t;if(this._splitStorageEligible)try{var n,o=this._splitStorage?null==(n=Zn(e))?void 0:n.storageGroup:void 0,a=o?this._groupEntryName(o):this._name;r=To(Br._get(a))[e]}catch(e){}var l=new Set(s||[]);if("$active_feature_flags"===e){if(!kt(t)&&!yt(t)||!kt(r)&&!yt(r)||!yt(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var u=new Set(t||[]),c=new Set(r||[]),d=new Set(i);new Set([...u,...d]).forEach(e=>{u.has(e)!==d.has(e)&&l.add(e)}),l.forEach(e=>{c.has(e)===d.has(e)&&l.delete(e)})}else{if(!wt(i))return void(Io(r,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));if(!kt(t)&&!wt(t)||kt(t)&&St(i)&&kt(r))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var h=wt(t)?t:{},_=wt(r)?r:{};new Set([...Object.keys(h),...Object.keys(i)]).forEach(e=>{e in h==e in i&&Io(h[e],i[e])||l.add(e)}),l.forEach(e=>{e in _==e in i&&Io(_[e],i[e])&&l.delete(e)})}l.size?this._setCrossTabFeatureFlagChangesPending(e,l):this._pendingCrossTabFeatureFlagChanges.delete(e)}}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return Ft(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{var t=Vr(e,this._config.cookie_persisted_properties||[]),i=Ur(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),r=Or._get(this._name)||void 0;r&&Kr(this._name,r)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=r)}catch(e){}else try{var n=Or._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=n?Kr(this._name,n):void 0,this._lastSeenMainCookieValue=n}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t){if(void 0===t&&(t=!1),this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;var i;try{i=Or._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;var s,r=Kr(this._name,i);try{s=jr(JSON.parse(i))}catch(e){return!1}if((Or._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=r,this._lastSeenMainCookieValue=i;var n=Gr(this._name,i),o=[...Hr,...n.properties],a={};if(Object.keys(s).forEach(e=>{var t=s[e];(kt(t)||Et(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete s[e])}),St(s))return!1;var l="distinct_id"in s||"anonymous"===s.$user_state||"identified"===s.$user_state,u=this.props,d=u[c],h=u[fe],p=gr({},u);[...Hr,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in s)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){var t=p[e];(n.isValid||-1===Hr.indexOf(e)||!1!==t&&0!==t)&&delete p[e]}}),this.props=gr(p,s),Po.forEach(e=>{var t=e in this.props;e in u===t&&Io(u[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,u[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this._setProp(fe,Be);var g=this.props[c],v=this.props[fe];return!l||g===d&&v===h||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Xr._set(Co(this._name),!0),this._deleteProp(X),this._deleteProp(V),this._deleteProp(j),this._deleteProp(U),this._deleteProp(G),this._deleteProp(K),this._deleteProp(ve),this._deleteProp(ge),this._deleteProp(_e),"anonymous"!==v||"identified"!==h&&"anonymous"!==s.$user_state&&(kt(d)||g===d)||(Ro(this.props,s),this._deleteProp(Z)),"identified"===v?this.props.$user_id=g:delete this.props.$user_id,this._deleteProp(_)),!0}consumeCookieIdentityChange(){var e=Co(this._name),t=this._cookieIdentityChangePending||!!Xr._get(e);return this._cookieIdentityChangePending=!1,t&&Xr._remove(e),t}_beginCookieSyncSuppression(e){return void 0===e&&(e=!1),!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Eo],this._writeNow(!0))}_endCookieSyncSuppression(e){if(void 0===e&&(e=!0),this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){-1===ko.indexOf(e.persistence.toLowerCase())&&(dr.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,i=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var i=[...Hr,...e];return s({},Br,{_parse(e){try{var s,r={};try{s=Or._get(e)||void 0,r=s?jr(JSON.parse(s)):{}}catch(e){}var n,o=JSON.parse(Br._get(e)||"{}");if(t){var a=Gr(e,s),l=[...Hr,...a.properties],u={};Object.keys(r).forEach(e=>{var t=r[e];Et(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(u[e]=t)});var d="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var h,_=o[c],p=null!==(h=o.$user_state)&&void 0!==h?h:"anonymous";i.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(d||"distinct_id"!==e&&"$user_state"!==e)){var t=o[e];(a.isValid||-1===Hr.indexOf(e)||!1!==t&&0!==t)&&delete o[e]}}),!d||"$user_state"in r||"$user_state"in o||(o[fe]=Be),!d||("distinct_id"in u?u[c]:o[c])===_&&("$user_state"in u?u[fe]:o[fe])===p||(qr.forEach(e=>delete o[e]),"identified"===u.$user_state&&"distinct_id"in u?o.$user_id=u[c]:delete o.$user_id,"identified"!==u.$user_state&&(delete o[ee],delete o[Z]),delete o.__alias)}n=gr(o,u)}else n=gr(r,o);return Br._set(e,n),n}catch(e){}return null},_set(i,s,r,n,o,a){var l=Br._set(i,s,void 0,void 0,a);try{var u=Vr(s,e);if(Object.keys(u).length){if(t){var c=Nr(i),d=Ur(u,e);if(Or._set(c,d,r,n,o,a),Or._get(c)!==JSON.stringify(d)){Or._remove(c,n);var h=Vr(s);return Or._set(i,h,r,n,o,a),l}}Or._set(i,u,r,n,o,a)}}catch(e){Br._error(e)}return l},_remove(e,t){try{null==Ge||Ge.localStorage.removeItem(e),Or._remove(e,t),Or._remove(Nr(e),t)}catch(e){Br._error(e)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),r=!1,n=!1,o=e.persistence.toLowerCase();return"localstorage"===o&&Br._is_supported()?(t=Br,n=!0):"localstorage+cookie"===o&&i._is_supported()?(t=i,n=!0,r=!0):"sessionstorage"===o&&Xr._is_supported()?t=Xr:"memory"===o?t=Jr:"cookie"===o&&Or._is_supported()?(t=Or,r=!0):i._is_supported()?(t=i,n=!0,r=!0):Or._is_supported()?(t=Or,r=!0):t=Jr,this._splitStorageEligible=n,this._storesIdentityInCookie=r,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){var e={};return pr(this.props,(t,i)=>{var s=Zn(i);if(!s||"event"===s.exposure){if(null!=s&&null!=s.shouldSkipFromEventProperties&&s.shouldSkipFromEventProperties(t))return;e[i]=t}}),e}load(e){if(void 0===e&&(e=!1),!this._disabled||e){var t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?Br._parse(this._name):null,s={};if(t)try{pr(s=jr(Or._parse(this._name)),(e,t)=>{(kt(e)||Et(e)||""===e)&&delete s[t]})}catch(e){}var r=this._storage._parse(this._name);if(r&&(this.props=gr({},r)),this._splitStorage&&this._loadGroupEntries(),t&&r){var n,o,a=null==i?void 0:i[c],l=null!==(n=null==i?void 0:i.$user_state)&&void 0!==n?n:"anonymous",u=r[c],d=null!==(o=r.$user_state)&&void 0!==o?o:"anonymous";if(u!==a||d!==l){this._cookieIdentityChangePending=!0,Xr._set(Co(this._name),!0);var h=gr({},this.props);qr.forEach(e=>delete h[e]),"anonymous"!==d||"identified"!==l&&"anonymous"!==s.$user_state&&(kt(a)||u===a)||(Ro(h,s),delete h[Z]),this.props=h;var _=new Set;qr.forEach(e=>{var t,i=null==(t=Zn(e))?void 0:t.storageGroup;i&&_.add(i)}),_.forEach(e=>{var t={};pr(this.props,(i,s)=>{var r;(null==(r=Zn(s))?void 0:r.storageGroup)===e&&(t[s]=i)}),St(t)?(Br._remove(this._groupEntryName(e)),this._slotState[e]={}):Br._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Xr._get(Co(this._name))&&(this._cookieIdentityChangePending=!0)}}_loadGroupEntries(){for(var e of Jn){var t=Br._parse(this._groupEntryName(e));if(t&&!St(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||gr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null==(i=Zn(t))?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){var i=So[e];if(!i)return!1;var s=t[i],r=this.props[i];return Ft(s)&&Ft(r)&&r>s}refreshKey(e){var t;if(!(this._disabled||"$fbc_persistence"===e&&this._facebookClickIdChangePending)){var i=this._splitStorage?null==(t=Zn(e))?void 0:t.storageGroup:void 0,s=i?Br._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){var r=this._storage._parse(this._name);if(r&&e in r)return void this._setProp(e,r[e],!1)}this._deleteProp(e,!1)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?kt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}}flush(){kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e){if(void 0===e&&(e=!1),!(this._disabled||this._cookieSyncSuppressed&&!e)){e||(this.syncCookieProperties(),this._facebookClickIdChangePending||this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||this.refreshKey(v));var t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);var i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)this._config.debug&&dr.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));var s=this._writeEntry(this._storage,this._name,this.props,Eo);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._facebookClickIdChangePending=!1),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}}}_writeNowSplit(){var e=this,t=this._partitionProps(),i=t.main,s=t.groups,r=this._writeEntry(this._storage,this._name,i,Eo);"written"===r&&this._rememberCurrentCookieProperties(i),"failed"!==r&&(this._localIdentityChangePending=!1,this._facebookClickIdChangePending=!1,Po.forEach(e=>{var t;null!=(t=Zn(e))&&t.storageGroup||this._pendingCrossTabFeatureFlagChanges.delete(e)}));var n=function(t){var i,r=s[t];if(St(r)&&(null==(i=e._slotState[t])||!i.persisted))return Po.forEach(i=>{var s;(null==(s=Zn(i))?void 0:s.storageGroup)===t&&e._pendingCrossTabFeatureFlagChanges.delete(i)}),1;var n=e._writeEntry(Br,e._groupEntryName(t),r,t);"failed"!==n&&Po.forEach(i=>{var s=Zn(i);(null==s?void 0:s.storageGroup)!==t||"written"!==n&&s.volatile||e._pendingCrossTabFeatureFlagChanges.delete(i)})};for(var o of Jn)if(n(o))continue}_partitionProps(){var e={},t={flags:{},surveys:{}};return pr(this.props,(i,s)=>{var r,n=null==(r=Zn(s))?void 0:r.storageGroup;n?t[n][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===Eo)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return pr(e,(e,t)=>{var s;i[t]=null!=(s=Zn(t))&&s.volatile?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){var r,n=this._slotWriteState(s);if(s!==Eo&&!n.dirty&&!kt(n.fingerprint))return"skipped";try{if((r=this._entryFingerprint(i,s))===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(n.dirty=!1,s!==Eo&&(n.persisted=!0),kt(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=Br._get(t)),"written"):(this._config.debug&&dr.warn('failed to persist storage entry "'+t+'"; will retry on next save'),"failed")}remove(e){var t=(void 0===e?{}:e).keepGroupEntries,i=void 0!==t&&t;if(this._markAllCrossTabFeatureFlagChangesPending(),kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!i&&this._ownsSplitStorage)for(var s of Jn)Br._remove(this._groupEntryName(s));i?delete this._slotState[Eo]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(wt(e)){this.syncCookieProperties(),kt(t)&&(t="None"),this._expire_days=kt(i)?this._default_expiry:i;var s=!1;if(pr(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(wt(e)){this.syncCookieProperties(),this._expire_days=kt(t)?this._default_expiry:t;var i=!1;if(pr(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||wt(t)||yt(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t="string"==typeof e?[e]:e,i=!1;for(var s of t)s in this.props&&(this._deleteProp(s),i=!0);i&&this.save()}update_campaign_params(){var e=null==Je?void 0:Je.URL;if(e!==this._campaign_params_url){var t=ho(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!St(yr(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}}update_search_keyword(){var e;this.register((e=null==Je?void 0:Je.referrer)?po(e):{})}update_referrer_info(){var e;this.register_once({$referrer:fo(),$referring_domain:null!=Je&&Je.referrer&&(null==(e=to(Je.referrer))?void 0:e.host)||vo},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var e=mo(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Se]:this._storesIdentityInCookie?{r:xo(e.r),u:e.u?xo(e.u):void 0}:e},void 0)}}get_initial_props(){var e={};pr([we,be],t=>{var i=this.props[t];i&&pr(i,function(t,i){e["$initial_"+ct(i)]=t})});var t=this.props[Se];return t&&gr(e,function(e,t){void 0===t&&(t=!1);var i=yo(e,t),s={};return pr(i,function(e,t){s["$initial_"+ct(t)]=e}),s}(t,this._config.disable_capture_url_hashes)),e}safe_merge(e){return pr(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){var r=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),o=r||n,a=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,l=e.disable_persistence||!!i,u=!!this._disabled&&!l;l||this._syncCookieProperties(t,u),this._config=e,!l&&(r||n||a)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(s({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),u));var c=o||a?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();var d=this._resolveSplitStorage(e),h=o||d!==this._splitStorage,_=!l&&(h||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(u);this._storageMigrationInProgress=h;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),h){var p=this.props;this.clear(),this._storage=c,this._splitStorage=d,this.props=p,this.save()}else a&&(this._storage=c,l||(delete this._slotState[Eo],this._writeNow()))}finally{this._storageMigrationInProgress=!1,_&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){var e=this.props[Se];if(this._storesIdentityInCookie&&wt(e)&&"string"==typeof e.r){var t=xo(e.r),i="string"==typeof e.u?xo(e.u):e.u;t===e.r&&i===e.u||this._setProp(Se,s({},e,{r:t,u:i}))}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props.__timers||{};i[e]=t,this._setProp(f,i),this.save()}remove_event_timer(e){var t=this.props.__timers||{},i=t[e];return kt(i)||(delete t[e],this._setProp(f,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i){var s;void 0===i&&(i=!0);var r=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||r===t||(this._localIdentityChangePending=!0),"$fbc_persistence"!==e||Io(r,t)||(this._facebookClickIdChangePending=!0),this._markPendingCrossTabFeatureFlagChanges(e,r,t),null!=(s=Zn(e))&&s.volatile||this._markGroupDirty(e))}_deleteProp(e,t){void 0===t&&(t=!0),delete this.props[e],t&&(Fo(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),"$fbc_persistence"===e&&(this._facebookClickIdChangePending=!0),this._markGroupDirty(e))}_markGroupDirty(e){var t,i=null==(t=Zn(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}},Mo="gzip-js",Lo="base64",$o="events",Oo="cancelEvents",Do="survey shown",Bo="survey dismissed",qo="survey sent",Ho="$survey_last_seen_date",No="popover";function zo(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&bt(i.then)&&i.then(void 0,()=>{})}}}}var jo=hr("[RateLimiter]"),Vo=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{jo.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void jo.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var u=(Ft(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this._captureWarning(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(s=this.instance.persistence)||s.set_property(ye,a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){var t=this.instance.config.property_denylist;return!yt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&null!=Ye&&Ye.pathname)return""+(null!==(e=Ye.origin)&&void 0!==e?e:"")+Ye.pathname}_captureWarning(e){var t,i,s=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null==(t=(i=this.instance).get_session_id)?void 0:t.call(i):void 0,a=[e+" event(s) dropped since the last warning",n?"triggered on "+n: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: "+a+". Config is set to "+r+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}},Wo=hr("[RemoteConfig]"),Uo=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=nt._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:e})}load(){try{if(this.remoteConfig)return Wo.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Wo.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return Wo.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){Wo.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||Wo.warn("Failed to fetch remote config from PostHog."):Wo.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){Wo.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(e){Wo.error("Error loading feature flags",e)}}},Go=Uint8Array,Ko=Uint16Array,Qo=Uint32Array,Jo=new Go([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]),Yo=new Go([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]),Xo=new Go([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zo=function(e,t){for(var i=new Ko(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new Qo(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},ea=Zo(Jo,2),ta=ea[1];ea[0][28]=258,ta[258]=28;for(var ia=Zo(Yo,0)[1],sa=new Ko(32768),ra=0;32768>ra;++ra){var na=(43690&ra)>>>1|(21845&ra)<<1;sa[ra]=((65280&(na=(61680&(na=(52428&na)>>>2|(13107&na)<<2))>>>4|(3855&na)<<4))>>>8|(255&na)<<8)>>>1}var oa=function(e,t,i){for(var s=e.length,r=0,n=new Ko(t);s>r;++r)++n[e[r]-1];var o,a=new Ko(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Ko(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,h=d|(1<<c)-1;h>=d;++d)o[sa[d]>>>l]=u}else for(o=new Ko(s),r=0;s>r;++r)o[r]=sa[a[e[r]-1]++]>>>15-e[r];return o},aa=new Go(288);for(ra=0;144>ra;++ra)aa[ra]=8;for(ra=144;256>ra;++ra)aa[ra]=9;for(ra=256;280>ra;++ra)aa[ra]=7;for(ra=280;288>ra;++ra)aa[ra]=8;var la=new Go(32);for(ra=0;32>ra;++ra)la[ra]=5;var ua=oa(aa,9,0),ca=oa(la,5,0),da=function(e){return(e/8|0)+(7&e&&1)},ha=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Ko?Ko:e instanceof Qo?Qo:Go)(i-t);return s.set(e.subarray(t,i)),s},_a=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},pa=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},ga=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Go(0),0];if(1==r){var o=new Go(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(s=1;r>s;++s)n[s].s>h&&(h=n[s].s);var _=new Ko(h+1),p=va(i[c-1],_,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});r>s;++s){var m=n[s].s;if(t>=_[m])break;g+=f-(1<<p-_[m]),_[m]=t}for(g>>>=v;g>0;){var y=n[s].s;t>_[y]?g-=1<<t-_[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;_[b]==t&&(--_[b],++g)}p=t}return[new Go(_),p]},va=function(e,t,i){return-1==e.s?Math.max(va(e.l,t,i+1),va(e.r,t,i+1)):t[e.s]=i},fa=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ko(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},ma=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},ya=function(e,t,i){var s=i.length,r=da(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},ba=function(e,t,i,s,r,n,o,a,l,u,c){_a(t,c++,i),++r[256];for(var d=ga(r,15),h=d[0],_=d[1],p=ga(n,15),g=p[0],v=p[1],f=fa(h),m=f[0],y=f[1],b=fa(g),w=b[0],S=b[1],k=new Ko(19),C=0;m.length>C;++C)k[31&m[C]]++;for(C=0;w.length>C;++C)k[31&w[C]]++;for(var x=ga(k,7),E=x[0],P=x[1],F=19;F>4&&!E[Xo[F-1]];--F);var I,T,R,A,M=u+5<<3,L=ma(r,aa)+ma(n,la)+o,O=ma(r,h)+ma(n,g)+o+14+3*F+ma(k,E)+(2*k[16]+3*k[17]+7*k[18]);if(L>=M&&O>=M)return ya(t,c,e.subarray(l,l+u));if(_a(t,c,1+(L>O)),c+=2,L>O){I=oa(h,_,0),T=h,R=oa(g,v,0),A=g;var D=oa(E,P,0);for(_a(t,c,y-257),_a(t,c+5,S-1),_a(t,c+10,F-4),c+=14,C=0;F>C;++C)_a(t,c+3*C,E[Xo[C]]);c+=3*F;for(var B=[m,w],q=0;2>q;++q){var H=B[q];for(C=0;H.length>C;++C)_a(t,c,D[N=31&H[C]]),c+=E[N],N>15&&(_a(t,c,H[C]>>>5&127),c+=H[C]>>>12)}}else I=ua,T=aa,R=ca,A=la;for(C=0;a>C;++C)if(s[C]>255){var N;pa(t,c,I[257+(N=s[C]>>>18&31)]),c+=T[N+257],N>7&&(_a(t,c,s[C]>>>23&31),c+=Jo[N]);var z=31&s[C];pa(t,c,R[z]),c+=A[z],z>3&&(pa(t,c,s[C]>>>5&8191),c+=Yo[z])}else pa(t,c,I[s[C]]),c+=T[s[C]];return pa(t,c,I[256]),c+T[256]},wa=new Qo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Sa=new Go(0),ka=function(){for(var e=new Qo(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Ca=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function xa(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=ka[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n,o,a,l,u,c=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,function(e,t,i,s,r,n){var o=e.length,a=new Go(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=ya(l,u,e.subarray(c,d)):(l[c]=n,u=ya(l,u,e.subarray(c,o)))}else{for(var h=wa[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Ko(32768),f=new Ko(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new Qo(25e3),S=new Ko(288),k=new Ko(32),C=0,x=0,E=(c=0,0),P=0,F=0;o>c;++c){var I=b(c),T=32767&c,R=f[I];if(v[T]=R,f[I]=T,c>=P){var A=o-c;if((C>7e3||E>24576)&&A>423){u=ba(e,l,0,w,S,k,x,E,F,c-F,u),E=C=x=0,F=c;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)k[M]=0}var L=2,O=0,D=p,B=T-R&32767;if(A>2&&I==b(c-B))for(var q=Math.min(_,A)-1,H=Math.min(32767,c),N=Math.min(258,A);H>=B&&--D&&T!=R;){if(e[c+L]==e[c+L-B]){for(var z=0;N>z&&e[c+z]==e[c+z-B];++z);if(z>L){if(L=z,O=B,z>q)break;var j=Math.min(B,z-2),V=0;for(M=0;j>M;++M){var W=c-B+M+32768&32767,U=W-v[W]+32768&32767;U>V&&(V=U,R=W)}}}B+=(T=R)-(R=v[T])+32768&32767}if(O){w[E++]=268435456|ta[L]<<18|ia[O];var G=31&ta[L],K=31&ia[O];x+=Jo[G]+Yo[K],++S[257+G],++k[K],P=c+L,++C}else w[E++]=e[c],++S[e[c]]}}u=ba(e,l,n,w,S,k,x,E,F,c-F,u),n||(u=ya(l,u,Sa))}return ha(a,0,s+da(u)+r)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!u)),d=c.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ca(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(c,t),Ca(c,d-8,i.d()),Ca(c,d-4,s),c}var Ea=!!Ze||!!Xe,Pa="text/plain",Fa=!1,Ia=(e,t)=>{var i=e.split("#"),s=i[1],r=i[0].split("?"),n=r[0],o=r[1];if(!o)return e;var a=o.split("&").filter(e=>e.split("=")[0]!==t).join("&");return n+(a?"?"+a:"")+(s?"#"+s:"")},Ta=function(e,t,i){var r;void 0===i&&(i=!0);var n=e.split("?"),o=n[0],a=n[1],l=s({},t),u=null!==(r=null==a?void 0:a.split("&").map(e=>{var t,s=e.split("="),r=s[0],n=i&&null!==(t=l[r])&&void 0!==t?t:s[1];return delete l[r],r+"="+n}))&&void 0!==r?r:[],c=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return pr(e,function(e,t){kt(e)||kt(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)}),r.join(t)}(l);return c&&u.push(c),u.length>0?o+"?"+u.join("&"):o},Ra=e=>{if(e._encodedBody)return e._encodedBody;var t=e.data,i=e.compression;if(t){if(i===Mo){var s=xa(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new Go(e.length+(e.length>>>1)),s=0,r=function(e){i[s++]=e},n=0;t>n;++n){if(s+5>i.length){var o=new Go(s+8+(t-n<<1));o.set(i),i=o}var a=e.charCodeAt(n);128>a?r(a):2048>a?(r(192|a>>>6),r(128|63&a)):a>55295&&57344>a?(r(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++n))>>>18),r(128|a>>>12&63),r(128|a>>>6&63),r(128|63&a)):(r(224|a>>>12),r(128|a>>>6&63),r(128|63&a))}return ha(i,0,s)}(eo(t)),{mtime:0});return{contentType:Pa,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===Lo){var r=(e=>"data="+encodeURIComponent("string"==typeof e?e:eo(e)))(function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(eo(t)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=eo(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},Aa=e=>{var t,i,r=()=>"sendBeacon"===e.transport?{url:Ta(e.url,{compression:Lo}),encodedBody:Ra(s({},e,{compression:Lo,_encodedBody:void 0}))}:{url:Ia(e.url,"compression"),encodedBody:Ra(s({},e,{compression:void 0,_encodedBody:void 0}))};try{t=Ra(e)}catch(t){if(Ns(e.compression,io(e.url,"compression")))return dr.error("Failed to gzip request body, sending uncompressed payload",t),r();throw t}return t&&Ns(e.compression,io(e.url,"compression"))&&!((i=t.body)instanceof ArrayBuffer?Hs(new Uint8Array(i)):ArrayBuffer.isView(i)&&Hs(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Fa=!0,r()):{url:e.url,encodedBody:t}},Ma=e=>{try{return Aa(e)}catch(t){return dr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},La=function(){var e=n(function*(e){var t=yield function(e,t,i){return Ws.apply(this,arguments)}(eo(e.data),l.DEBUG,{rethrow:!0});if(!t)return e;var i=yield t.arrayBuffer();return s({},e,{_encodedBody:{contentType:Pa,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),$a=/Failed to fetch|NetworkError|Load failed/i,Oa=e=>"TypeError"===(null==e?void 0:e.name)&&$a.test((null==e?void 0:e.message)||""),Da=e=>{var t=Ma(e);if(t){var i=t.url,r=t.encodedBody,n=null!=r?r:{},o=n.contentType,a=n.body,l=n.estimatedSize,u=new Headers;pr(e.headers,function(e,t){u.append(t,e)}),o&&u.append("Content-Type",o);var c=null,d=!1;if(et){var h=new et;c={signal:h.signal,timeout:setTimeout(()=>{var t;d=!0,h.abort(Zi("AbortError","PostHog request timed out"+((t=e.timeout)?" after "+t+"ms":"")))},e.timeout)}}var _=t=>{d&&"AbortError"===(null==t?void 0:t.name)||Oa(t)?dr.warn(t):dr.error(t),null==e.callback||e.callback({statusCode:0,error:t})};try{var p;Xe(i,s({method:(null==e?void 0:e.method)||"GET",headers:u,keepalive:"POST"===e.method&&!e._keepaliveDisabled&&52428.8>(l||0),body:a,signal:null==(p=c)?void 0:p.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){dr.error(e)}null==e.callback||e.callback(s)})).catch(_).finally(()=>c?clearTimeout(c.timeout):null)}catch(e){c&&clearTimeout(c.timeout),_(e)}}},Ba=e=>{try{var t,i=Aa(e),r=i.url,n=i.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(Qe.sendBeacon(r,u))return;var c=yt(e.data)?e.data:null==(t=e.data)?void 0:t.batch;if(yt(c)&&c.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(c.length/2),h=t=>yt(e.data)?t:s({},e.data,{batch:t});return Ba(s({},e,{data:h(c.slice(0,d))})),void Ba(s({},e,{data:h(c.slice(d))}))}dr.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Da(s({},e,{_keepaliveDisabled:!0}))}catch(e){dr.warn("Beacon send failed",e)}},qa=(e,t,i,r)=>{var n="query"===r?"POST"===t?"sent_at":"_":void 0;return Ta(i===Mo?Ia(e,"compression"):e,s({},n?{[n]:Date.now().toString()}:{},i===Mo?{}:{compression:i}))},Ha=[];Xe&&Ha.push({transport:"fetch",method:Da}),Ze&&Ha.push({transport:"XHR",method(e){var t=Ma(e);if(t){var i=new Ze,s=t.encodedBody;i.open(e.method||"GET",t.url,!0);var r=null!=s?s:{},n=r.contentType,o=r.body;pr(e.headers,function(e,t){i.setRequestHeader(t,e)}),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(o)}}}),null!=Qe&&Qe.sendBeacon&&Ha.push({transport:"sendBeacon",method:Ba});var Na=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Nt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,dr.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(s({},e,{transport:"sendBeacon"}))})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[s],r=(new Date).getTime();i.data&&yt(i.data)&&pr(i.data,e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp}),e._sendRequestSafely(i)};for(var s in t)i()}},this._flushTimeoutMs))}_sendRequestSafely(e){try{this._sendRequest(e)}catch(e){dr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return pr(this._queue,t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;kt(e[n])&&(e[n]=s({},r,{data:[]})),null==(i=e[n].data)||i.push(r.data)}),this._queue=[],e}},za=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,!kt(Ge)&&"onLine"in Ge.navigator&&(this._areWeOnline=Ge.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},kr(Ge,"online",this._onlineListener),kr(Ge,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(t){var r=t.retriesPerformedSoFar,n=i(t,e);It(r)&&(n.url=Ta(n.url,{retry_count:r})),this._instance._send_request(s({},n,{callback:e=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=r?r:0))return void this._enqueue(s({retriesPerformedSoFar:r},n));0===e.statusCode&&dr.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!=r?r:0)+" retries.")}null==n.callback||n.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this._queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),dr.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(var s of i)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,kt(Ge)||(this._onlineListener&&(Ge.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(Ge.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue)){var t=e.requestOptions;try{this._instance._send_request(s({},t,{transport:"sendBeacon"}))}catch(e){dr.error(e)}}this._queue=[]}},ja=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){kr(Ge,"scroll",this._updateScrollData,{capture:!0}),kr(Ge,"scrollend",this._updateScrollData,{capture:!0}),kr(Ge,"resize",this._updateScrollData)}scrollElement(){var e;if(!this._scrollRoot)return null==Ge||null==(e=Ge.document)?void 0:e.documentElement;for(var t of yt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot]){var i,s=null==Ge||null==(i=Ge.document)?void 0:i.querySelector(t);if(s)return s}}_scrollPosition(e){var t,i,s="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var r=this.scrollElement();return r&&r[s]||0}return Ge?"y"===e?Ge.scrollY||Ge.pageYOffset||(null==(t=Ge.document)||null==(t=t.documentElement)?void 0:t.scrollTop)||0:Ge.scrollX||Ge.pageXOffset||(null==(i=Ge.document)||null==(i=i.documentElement)?void 0:i.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}},Va=e=>mo(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes),Wa=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[me]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Va,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[me]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?yo(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return pr(yr(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+ct(i)]=t}),e}},Ua=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}constructor(){this._events={}}},Ga=hr("[SessionId]"),Ka=864e5,Qa=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Ua,this._sessionHasBeenIdleTooLong=(e,t)=>!(!It(e)||!It(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Rr,this._windowIdGenerator=i||Rr;var r=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Nt(this._config.session_idle_timeout_seconds||1800,60,36e3,Ga.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var n=Xr._parse(this._window_id_storage_key),o=Xr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Xr._remove(this._window_id_storage_key),Xr._set(this._primary_window_exists_storage_key,!0)}null!=(s=this._config.bootstrap)&&s.sessionID&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return kt(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Xr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Xr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Xr._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!Et(t)&&!Et(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var s=t!==this._sessionActivityTimestamp,r=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,r&&!s||r&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[O]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return It(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(O):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!Et(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var t=this._getSessionId();t[1]===this._sessionId&&t[2]===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[O]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var e=this._getSessionId()[0],t=It(e)?e:0,i=It(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[O];return yt(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t){void 0===t&&(t=!1);var i=function(e,t){void 0===t&&(t=(new Date).getTime());try{var i=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Ga.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Ga.error("Invalid sessionID in bootstrap",e)}}(e);return!kt(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&Ge&&(Ge.removeEventListener(ze,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Xr._remove(this._primary_window_exists_storage_key)},kr(Ge,ze,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=null),void 0===i&&(i=!1),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||(new Date).getTime(),r=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(Et(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var n,o;null==(n=(o=this._persistence).syncCookieProperties)||n.call(o),this._lastCookieSyncTimestamp=s}var a=this._getSessionId(),l=a[1],u=a[2],c=!kt(r)&&l!==r,d=this._freshestActivityTimestamp(),h=this._getWindowId(),_=this._pendingBootstrapSession,p=!!_&&(_.sessionStartTimestamp>s+6e4||s-_.sessionStartTimestamp>Ka),g=_?p:It(u)&&Math.abs(s-u)>Ka,v=!1,f=c,m=!l||!!_,y=l,b=!m&&!e&&this._sessionHasBeenIdleTooLong(s,d);if(b){(b=this._isSessionIdleAfterCrossTabRefresh(s))||Ga.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this._getSessionId();l=w[1],u=w[2]}if(m||b||g){f=!1;var S=_&&!p;l=S?_.sessionId:this._sessionIdGenerator(),h=this._windowIdGenerator(),Ga.info("new session ID assigned",{sessionId:l,windowId:h,bootstrapped:!!S,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g}}),u=S?_.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,v=!0}else h||(h=this._windowIdGenerator(),v=!0),(f=f||l!==y)&&(Ga.info("adopted cross-tab session id",{sessionId:l,windowId:h}),v=!0);var k=It(d)&&e&&!g?d:s,C=It(u)?u:(new Date).getTime();this._setWindowId(h),this._setSessionId(l,k,C),e||this._resetIdleTimer();var x={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g,crossTabAdoption:f};return v&&this._sessionIdChangedHandlers.forEach(e=>e(l,h,x)),{sessionId:l,windowId:h,sessionStartTimestamp:C,changeReason:v?x:void 0,lastActivityTimestamp:d}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}},Ja=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&at(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some(e=>at(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function Ya(){return(Ya=n(function*(){var e=null==Qe?void 0:Qe.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t,i=null==(t=yield e.getHighEntropyValues(["model"]))?void 0:t.model;return Ct(i)&&i.length>0?i:void 0}catch(e){return void dr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Xa(e,t){var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i}function Za(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}var el=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch(e){return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}},tl=e=>e.toLowerCase(),il={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>el(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!el(t,e))),icontains:(e,t)=>t.map(tl).some(t=>e.map(tl).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(tl).every(t=>e.map(tl).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function sl(e,t){return!e||Object.entries(e).every(e=>{var i=e[1],s=null==t?void 0:t[e[0]];if(null==s)return!1;var r=il[i.operator];return!!r&&r(i.values,[String(s)])})}function rl(e,t,i){return eo({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var nl="custom",ol="i.posthog.com",al=/^\/static\//,ll=["/s/","/e/","/i/"],ul=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ol,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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":nl),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(al.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}_urlKey(e){var t=to(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;var s=i,r=this.instance.config.rewriteRequestPath;if(r){var n,o=(null==(n=to(i))?void 0:n.href)||i;s=r(new URL(o)).toString()}if(r&&"api"===e&&ll.some(e=>0===t.indexOf(e))){var a=this._urlKey(s);if(a){var l,u=this.apiHost,c=this._ingestionEndpoints;(null==(l=c)?void 0:l.apiHost)===u&&c.rewriteRequestPath===r||(this._ingestionEndpoints=c={apiHost:u,rewriteRequestPath:r,urls:new Set}),c.urls.add(a)}}return s}isIngestionEndpoint(e){var t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,""+i+t)}if(this.region===nl)return this._prepareEndpoint(e,t,this.apiHost+t);var s=ol+t;switch(e){case"assets":return this._prepareEndpoint(e,t,"https://"+this.region+"-assets."+s);case"api":return this._prepareEndpoint(e,t,"https://"+this.region+"."+s)}}},cl=hr("[Surveys]"),dl=e=>{try{var t=(e=>((e,t)=>"seenSurvey_"+function(e){return e.current_iteration&&e.current_iteration>0?e.id+"_"+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){cl.error("Failed to persist survey seen state",e)}},hl=["popover","widget","api"],_l={ignoreConditions:!1,ignoreDelay:!1,displayType:No},pl=hr("[PostHog ExternalIntegrations]"),gl={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},vl=class{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return pl.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(){var t,s,r,n=i[0],o=i[1];!o||null!=(t=nt.__PosthogExtensions__)&&null!=(t=t.integrations)&&t[n]||e._loadScript(gl[n],()=>{var t;null==(t=nt.__PosthogExtensions__)||null==(t=t.integrations)||null==(t=t[n])||t.start(e._instance)}),!o&&null!=(s=nt.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[n]&&(null==(r=nt.__PosthogExtensions__)||null==(r=r.integrations)||null==(r=r[n])||r.stop())};for(var i of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t()}}},fl=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return n(function*(){if(t._disposed)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t._extensions.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t._extensions.set(e.name,e);try{var i=e.setup(t._client);i&&(yield i)}catch(i){var s=t._extensions.get(e.name)===e;s&&t._extensions.delete(e.name),t._logger.error('Failed to set up browser extension "'+e.name+'"',i),s&&t._disposeExtension(e)}})()}getExtension(e){return this._extensions.get(e)}dispose(){if(!this._disposed){this._disposed=!0;var e=Array.from(this._extensions.values()).reverse();for(var t of(this._extensions.clear(),e))this._disposeExtension(t)}}_disposeExtension(e){try{var t=null==e.dispose?void 0:e.dispose();t&&bt(t.then)&&t.then(void 0,t=>{this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)})}catch(t){this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}}},ml=class{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);var i={};for(var s of e){var r=null==t?void 0:t.get_property(s);kt(r)||(i[s]=r)}return i}set(e,t){var i;null==(i=this._instance.persistence)||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null==(t=this._instance.persistence)||t.unregister(e)}},yl="extensionsRemoteConfig",bl=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=dr,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new ml(e),this.onEvent=e=>zo(this.instance.on("eventCaptured",t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{if(this._disposed)return zo(()=>{});var t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(yl,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),zo(i)},this._runtime=new fl(dr.createLogger("[BrowserExtensions]"),this)}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){var e=this.instance.get_property(d);return"string"==typeof e?e:void 0}get library(){return{name:l.LIB_NAME,version:l.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null==(t=this.instance.persistence)?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,r=null==(e=this.instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this._runtime.add(e)}getExtension(e){return this._runtime.getExtension(e)}capture(e,t,i){var s=this;return n(function*(){i?s.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):s.instance.capture(e,t)})()}registerDynamicEventProperties(e){return zo(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(yl,e))}sendRequest(e,t){var i=this;return n(function*(){var s;void 0===t&&(t={});var r=i.instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",e),n={method:t.method,url:t.query?Ta(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,compressionFallback:"flags"===t.target&&"best-available"===t.compression?_t.Base64:void 0,timestampMode:t.sentAt};return"sendBeacon"===t.transport?(i.instance._send_request(n),{statusCode:202}):new Promise(e=>{n.callback=e,i.instance._send_request(n)})})()}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}},wl={},Sl=0,kl=()=>{},Cl='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',xl="Surveys module not available",El="sanitize_properties is deprecated. Use before_send instead",Pl="Invalid value for property_denylist config: ",Fl=/^[A-Za-z0-9_-]{1,400}$/,Il=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Tl=["token","distinct_id",xe],Rl="posthog",Al=!Ea&&-1===(null==it?void 0:it.indexOf("MSIE"))&&-1===(null==it?void 0:it.indexOf("Mozilla")),Ml=e=>{var t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},Ll=e=>{var t;return s({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Sr(null==Je?void 0:Je.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:kl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ye&&Ct(null==Ye?void 0:Ye.search)&&-1!==Ye.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==Ge||null==(t=Ge.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,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,surveys_request_timeout_ms:1e4,on_request_error(e){dr.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:He,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:kl},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:yn,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:Ml(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},$l=[["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"]],Ol=e=>{var t={};for(var i of $l){var s=i[0],r=i[1];kt(e[s])||(t[r]=e[s])}var n=gr({},t,e),o=e.__preview_external_dependency_versioned_paths;return kt(o)||(kt(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),Ct(o)&&kt(e.asset_host)&&(n.asset_host=o)),yt(e.property_blacklist)&&(kt(e.property_denylist)?n.property_denylist=e.property_blacklist:yt(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:dr.error(Pl+e.property_denylist)),n},Dl=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){dr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Bl=(r=class e{_removeExtension(e){if(e){var t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}}_replaceExtension(e,t){return this._removeExtension(e),this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(!(this._hasWarnedAboutVolatileIdentity||this.config.reuseAnonymousId||this.config.segment||this._inCookielessMode())){var e,t,i,s="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;(s||this.config.disable_persistence)&&(this._hasStableInitialDistinctId||(s?(e="persistence is set to '"+this.config.persistence+"'",t="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(e="persistence is disabled (disable_persistence is true)",t="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",e+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+t+", 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. "+i)))}}_healCookielessSentinelDistinctId(){if(!this._inCookielessMode()&&"$posthog_cookieless"===this.get_distinct_id()){var e=this.persistence;if(e){this._is_persistence_disabled()||e.load(!0);var t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){var i=this.config.get_device_id(Rr());this.register({distinct_id:i,$device_id:i}),e.set_property(fe,Be)}this._sync_opt_out_with_persistence()}}}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this.webPerformance=new Dl,this._personProcessingSetOncePropertiesSent=!1,this.version=l.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Ua,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ll(),this.SentryIntegration=Kn,this.sentryIntegration=e=>function(e,t){var i=Gn(e,t);return{name:Un,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new ja(this),this.pageViewManager=new Qn(this),this.rateLimiter=new Vo(this),this.requestRouter=new ul(this),this.consent=new Zr(this),this.externalIntegrations=new vl(this);var i=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{var s=Ct(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=Ct(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>dr.info('send "'+(null==e?void 0:e.event)+'"',e))}init(t,i,s){if(s&&s!==Rl){var r,n=null!==(r=wl[s])&&void 0!==r?r:new e;return n._init(t,i,s),wl[s]=n,wl[Rl][s]=n,n}return this._init(t,i,s)}_init(e,t,i){var r,n,o;void 0===t&&(t={});var a,u=Ct(e)?e.trim():"";if(!u)return dr.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return u!==(null==(a=this.config)?void 0:a.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('"+u+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ll(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var c=Ll(t.defaults),d=Ol(t),_=gr({},c,d,{name:i,token:u});wt(c.rageclick)&&wt(d.rageclick)&&(_.rageclick=gr({},c.rageclick,d.rageclick)),wt(c.session_recording)&&wt(d.session_recording)&&(_.session_recording=gr({},c.session_recording,d.session_recording)),this.set_config(_),this.config.on_xhr_error&&dr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Mo;var p=this._is_persistence_disabled();if(this.persistence=new Ao(this.config,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ao(s({},this.config,{persistence:"sessionStorage"}),p,!1),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!p&&Xr._is_supported()){var g=Xr._parse(this._sessionRegisteredPropertiesStorageKey);yt(g)&&g.forEach(e=>{Ct(e)&&this._sessionRegisteredPropKeys.add(e)})}else Xr._remove(this._sessionRegisteredPropertiesStorageKey);var v=s({},this.persistence.props),f=s({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Na(e=>this._send_retriable_request(e),this.config.request_queue_config),this._retryQueue=new za(this),this.__request_queue=[];var m=this._inCookielessMode();m||(this.sessionManager=new Qa(this),this.sessionPropsManager=new Wa(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(dr.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._initExtensions(m)},0)):(dr.info("Initializing extensions synchronously"),this._initExtensions(m)),l.DEBUG=l.DEBUG||this.config.debug,l.DEBUG&&dr.info("Starting in debug mode",{this:this,config:t,thisC:s({},this.config),p:v,s:f}),!this.config.identity_distinct_id||null!=(r=t.bootstrap)&&r.distinctID||(t.bootstrap=s({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var y=null==(n=t.bootstrap)?void 0:n.distinctID;if(this._hasStableInitialDistinctId=!!y&&!xt(y),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var b=t.bootstrap.distinctID,w=this.get_distinct_id(),S=this.persistence.get_property(fe);if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"anonymous"===S)this.identify(b);else if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"identified"===S)dr.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{var k=this.config.get_device_id(Rr()),C=t.bootstrap.isIdentifiedID?k:b;this.persistence.set_property(fe,t.bootstrap.isIdentifiedID?qe:Be),this.register({distinct_id:b,$device_id:C})}}if(m)this.register_once({distinct_id:Ce,$device_id:null},"");else if(!this.get_distinct_id()){var x=this.config.get_device_id(Rr());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(fe,Be)}return kr(Ge,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?Wn(this,()=>this._loaded()):this._loaded(),bt(this.config._onCapture)&&this.config._onCapture!==kl&&(dr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&dr.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 Ya.apply(this,arguments)}().then(e=>{e&&this.register({[h]:e})}).catch(kl),this}_isSharedExtension(e){var t=e;return Ct(t.name)&&bt(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>null==e.dispose?void 0:e.dispose()).catch(t=>{dr.error('Failed to dispose browser extension "'+e.name+'"',t)})}):this._extensions.push(e)}_enrollFeatureFlags(){var t,i,s,r,n,o,a=null!==(t=null==(i=this.config.__extensionClasses)?void 0:i.featureFlags)&&void 0!==t?t:null==(s=e.__defaultExtensionClasses)?void 0:s.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||(null==(o=this._featureFlagsReloadingUnsubscribe)||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new a(this)),bt(this.featureFlags.onReloading)&&bt(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):null==(r=(n=this.featureFlags).initialize)||r.call(n))}_initExtensions(t){var i,r,n,o,a,l,u,c=performance.now(),d=s({},e.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.exceptions&&this._extensions.push(this.exceptions=null!==(i=this.exceptions)&&void 0!==i?i:new d.exceptions(this)),d.historyAutocapture&&this._extensions.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this._extensions.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this._extensions.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!t&&this._extensions.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),d.autocapture&&this._enrollExtension(this.autocapture=new d.autocapture(this),h),d.surveys&&this._enrollExtension(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new d.surveys(this),h),d.logs&&this._enrollExtension(this.logs=null!==(n=this.logs)&&void 0!==n?n:new d.logs(this),h),d.metrics&&this._extensions.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new d.metrics(this)),d.conversations&&this._extensions.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new d.conversations(this)),d.productTours&&this._extensions.push(this.productTours=new d.productTours(this)),d.heatmaps&&this._extensions.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this._extensions.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,zn)),d.toolbar&&this._extensions.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new d.toolbar(this)),d.experiments&&this._extensions.push(this.experiments=null!==(u=this.experiments)&&void 0!==u?u:new d.experiments(this)),this._extensions.forEach(e=>{e.initialize&&h.push(()=>{null==e.initialize||e.initialize()})}),h.push(()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}}),this._processInitTaskQueue(h,c)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this._processInitTaskQueue(e,t)},0);var i=e.shift();if(i)try{i()}catch(e){dr.error("Error initializing extension:",e)}}var s=Math.round(performance.now()-t);this.register_for_session({[Ee]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Pe]:s}),this.config.__preview_deferred_init_extensions&&dr.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t;if(!Je||!Je.body)return dr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var i,s=e.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=lt(s.supportedCompression,Mo)?Mo:lt(s.supportedCompression,Lo)?Lo:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:He}),null==(t=this._browserClientAdapter)||t.handleRemoteConfig(e),this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}_loaded(){try{this.config.loaded(this)}catch(e){dr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=Ye&&Ye.hostname){var e=Ye.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new Uo(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&_r(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s,r;null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),null==(t=this.metrics)||t.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(Ve),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(s=this._requestQueue)||s.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(Ve,null,{transport:"sendBeacon"})}_send_request(e){var t;this.__loaded?Al?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=s({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?null!==(t=this.compression)&&void 0!==t?t:e.compressionFallback:e.compression,(kt(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,r,n=s({},e);n.timeout=n.timeout||6e4;var o,a,l,u,c,d=null!==(t=n.transport)&&void 0!==t?t:"fetch";"sendBeacon"===d&&kt(n.compression)&&n.data&&(n.compression=Lo),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data={api_key:null!==(a=null==(c=(u=(yt(o=n.data)?o:[o]).map(e=>s({},e,e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})))[0])||null==(l=c.properties)?void 0:l.token)&&void 0!==a?a:null==c?void 0:c.token,batch:u,sent_at:(new Date).toISOString()}:"body"===n.timestampMode&&(n.data=function(e,t){return void 0===t&&(t=(new Date).toISOString()),yt(e)?e.map(e=>s({},e,{sent_at:t})):s({},e,{sent_at:t})}(n.data))),n.url=qa(n.url,n.method,n.compression,n.timestampMode);var h=Ha.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),_=null!==(i=null==(r=function(e,t){for(var i=0;e.length>i;i++)if(t(e[i]))return e[i]}(h,e=>e.transport===d))?void 0:r.method)&&void 0!==i?i:h[0].method;if(!_)throw new Error("No available transport method");var p=e=>{try{_(e)}catch(e){Oa(e)?dr.warn(e):dr.error(e),null==n.callback||n.callback({statusCode:0,error:e})}};"sendBeacon"!==d&&n.data&&n.compression===Mo&&tt&&"undefined"!=typeof Promise&&!Fa?La(n).then(e=>{p(e)}).catch(t=>{if(zs(t))return Fa=!0,void p(s({},n,{compression:void 0,url:qa(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return zs(e)||t===qs})(t)&&(Fa=!0),p(n)}):_(n)})(s({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(s=this.config).on_request_error)||i.call(s,t),null==e.callback||e.callback(t)}}))):e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:0}))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){Sl++;try{var t,i=[],s=[],r=[];_r(e,e=>{if(e)if(yt(t=e[0]))r.push(e);else if(bt(e))try{e.call(this)}catch(t){dr.error("Error executing queued PostHog call",e,t)}else yt(e)&&"alias"===t?i.push(e):yt(e)&&-1!==t.indexOf("capture")&&bt(this[t])?r.push(e):s.push(e)});var n=function(e,t){_r(e,function(e){try{if(yt(e[0])){var i=t;pr(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){dr.error("Error executing queued PostHog call",e,t)}})};n(i,this),n(s,this),n(r,this)}finally{Sl--}}push(t){if(Sl>0&&yt(t)&&Ct(t[0])){var i=e.prototype[t[0]];bt(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}_getPersistedFacebookClickId(){var e,t=null==(e=this.persistence)?void 0:e.get_property(v);return Ct(t)&&Il.test(t)?{value:t,delivered:!1}:wt(t)&&Ct(t.value)&&Il.test(t.value)?{value:t.value,delivered:!0===t.delivered}:void 0}_updateFacebookClickId(e,t,i,s){if(this.persistence){this.persistence.refreshKey(v);var r=this._getPersistedFacebookClickId();if(!s){if(i)return Ct(t)&&Il.test(t)?(t!==(null==r?void 0:r.value)&&this.persistence.register({[v]:{value:t,delivered:!1}}),{value:t,pending:t!==(null==r?void 0:r.value)||!r.delivered}):void this.persistence.unregister(v);if(Ct(e)&&Fl.test(e)){if((null==r?void 0:r.value.split(".")[3])===e)return{value:r.value,pending:!r.delivered};var n="fb.1."+Date.now()+"."+e;return this.persistence.register({[v]:{value:n,delivered:!1}}),{value:n,pending:!0}}return r?{value:r.value,pending:!r.delivered}:void 0}this.persistence.unregister(v)}}_markFacebookClickIdDelivered(e){if(this.persistence){this.persistence.refreshKey(v);var t=this._getPersistedFacebookClickId();(null==t?void 0:t.value)!==e||t.delivered||this.persistence.register({[v]:{value:e,delivered:!0}})}}capture(e,t,i){var r,n,o,a,l,u,c,d,h,_;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!kt(e)&&Ct(e)){this._healCookielessSentinelDistinctId();var p=!this.config.opt_out_useragent_filter&&this._is_bot();if(!p||this.config.__preview_capture_bot_pageviews){var v=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==v||!v.isRateLimited){var f;null!=t&&t.$current_url&&!Ct(null==t?void 0:t.$current_url)&&(dr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=i&&i._originatedFromCaptureException||dr.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&&(f=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var m=new Date,y=(null==i?void 0:i.timestamp)||m,b=Xi(null==i?void 0:i.uuid,Rr),w={uuid:b,event:e,properties:this.calculateEventProperties(e,t||{},y,b)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&p&&(w.event="$bot_pageview",w.properties.$browser_type="bot"),v&&(w.properties.$lib_rate_limit_remaining_tokens=v.remainingTokens);var S="$feature_flag_called"===e&&!1===w.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");null!=i&&i.$set&&!S&&(w.$set=null==i?void 0:i.$set);var k=wt(null==t?void 0:t.$set)?t.$set:void 0,C=!(null==i||!i.$set)&&"$fbc"in i.$set,x=C||!!k&&"$fbc"in k,E=C?null==i||null==(r=i.$set)?void 0:r[g]:null==k?void 0:k[g],P=yt(null==t?void 0:t.$unset)?t.$unset:[],F=(null==i?void 0:i.$unset)||[],I=-1!==P.indexOf("$fbc")||-1!==F.indexOf("$fbc"),T=this._updateFacebookClickId(null==(n=f)?void 0:n.fbclid,E,x,I);T&&!0===w.properties.$process_person_profile&&T.pending&&!x&&!S&&(w.$set=s({[g]:T.value},w.$set));var R=null==i?void 0:i.$unset;R&&(w.$unset=R);var A=S?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==Ue,e===We);if(A&&(w.$set_once=A),null!=i&&i._noTruncate||(c=this.config.properties_string_max_length,d=w,h=e=>Ct(e)?e.slice(0,c):e,_=new Set,w=function e(t,i){if(t!==Object(t))return h?h(t):t;if(!_.has(t)){var s;if(_.add(t),yt(t))s=[],_r(t,t=>{s.push(e(t))});else{var r={};pr($t(t)?br(t):t,(t,i)=>{_.has(t)||(r[i]=e(t,i))}),s=r}return s}}(d)),w.timestamp=y,kt(null==i?void 0:i.timestamp)||(w.properties.$event_time_override_provided=!0,w.properties.$event_time_override_system_time=m),S&&(w.properties=function(e,t){void 0===t&&(t=[]);var i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return Bs.forEach(s),t.forEach(s),i}(w.properties,Tl)),e===Bo||e===qo){var M=null==t?void 0:t.$survey_id,L=null==t?void 0:t.$survey_iteration;dl({id:M,current_iteration:L}),w.$set=s({},w.$set,{[Xa({id:M,current_iteration:L},e===qo?"responded":"dismissed")]:!0})}else e===Do&&(w.$set=s({},w.$set,{[Ho]:(new Date).toISOString()}));if("product tour shown"===e){var O=null==t?void 0:t.$product_tour_type;O&&(w.$set=s({},w.$set,{["$product_tour_last_seen_date/"+O]:(new Date).toISOString()}))}var D=s({},w.properties.$set,w.$set);if(St(D)||this.setPersonPropertiesForFlags(D),!Pt(this.config.before_send)){var B=this._runBeforeSend(w);if(!B)return;(w=B).uuid=Xi(w.uuid,Rr)}var q=null!==(o=null==(a=w.$set)?void 0:a.$fbc)&&void 0!==o?o:wt(null==(l=w.properties)?void 0:l.$set)?w.properties.$set.$fbc:void 0,H=null!=T&&T.pending&&q===T.value?T.value:void 0;this._internalEventEmitter.emit("eventCaptured",w);var N=null!==(u=null==i?void 0:i._url)&&void 0!==u?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),z=s({method:"POST",url:N,data:w,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(N)?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},null!=i&&i.transport?{transport:i.transport}:{},H?{fireCallbackOnDrop:!0,callback:e=>{e.statusCode>=200&&300>e.statusCode&&this._markFacebookClickIdDelivered(H)}}:{});return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly||H?this._send_retriable_request(z):this._requestQueue.enqueue(z),w}dr.critical("This capture call is ignored due to client rate limiting.")}}else dr.error("No event name provided to posthog.capture")}else dr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null==(t=this._browserClientAdapter)?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new bl(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);var t=!0;return()=>{if(t){t=!1;var i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}}_processCookieIdentityChange(e){var t,i,s;return void 0===e&&(e=!0),!(null==(t=this.persistence)||!t.consumeCookieIdentityChange())&&(this._cachedPersonProperties=null,"anonymous"===this.persistence.get_property("$user_state")&&(null==(s=this.sessionPersistence)||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null==(i=this.featureFlags)||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;this.persistence.syncCookieProperties(),this._processCookieIdentityChange();var o=n?void 0:this.persistence.remove_event_timer(e),l=s({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l[xe]=!0),"$snapshot"===e){var u=s({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!Ct(l.distinct_id)&&!Ft(l.distinct_id)||xt(l.distinct_id))&&dr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i,s){var r,n,o,l;if(void 0===s&&(s=!1),!it)return{};var u,c=e?[...ao,...t||[]]:[],d=Ni(it),h=d[0],_=d[1],p=function(e){for(var t=0;Vi.length>t;t++){var i,s=Vi[t],r=s[1],n=s[2],o=e.match(s[0]);if(o)return[r,(null==(i=n&&e.match(n)||o)?void 0:i[1])||""]}return["",""]}(it),g=p[0],v=p[1],f=null!=(u="u">typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},m={};kt(i)||(m.detectGoogleSearchApp=i);var y={},b=null==(r=navigator)||null==(r=r.userAgentData)?void 0:r.platform,w=null==(n=navigator)?void 0:n.maxTouchPoints,S=null==Ge||null==(o=Ge.screen)?void 0:o.width,k=null==Ge||null==(l=Ge.screen)?void 0:l.height,C=null==Ge?void 0:Ge.devicePixelRatio;kt(b)||(y.userAgentDataPlatform=b),kt(w)||(y.maxTouchPoints=w),kt(S)||(y.screenWidth=S),kt(k)||(y.screenHeight=k),kt(C)||(y.devicePixelRatio=C);var x,E,P,F,I,T,R,A,M=gr(yr({$os:h,$os_version:_,$browser:Di(it,navigator.vendor,f,m),$webview_app:g,$webview_app_version:v,$device:zi(it),$device_type:(E=it,P=y,A=zi(E),A===Gt||A===Ut||"Kobo"===A||"Kindle Fire"===A||A===vi?Wt:A===oi||A===li||A===ai||A===pi?"Console":A===Kt?"Wearable":A?jt:"Android"===(null==P?void 0:P.userAgentDataPlatform)&&(null!==(F=null==P?void 0:P.maxTouchPoints)&&void 0!==F?F:0)>0?600>Math.min(null!==(I=null==P?void 0:P.screenWidth)&&void 0!==I?I:0,null!==(T=null==P?void 0:P.screenHeight)&&void 0!==T?T:0)/(null!==(R=null==P?void 0:P.devicePixelRatio)&&void 0!==R?R:1)?jt:Wt:"Desktop"),$timezone:bo(),$timezone_offset:wo()}),{$current_url:so(s?es(null==Ye?void 0:Ye.href):null==Ye?void 0:Ye.href,c,uo),$host:null==Ye?void 0:Ye.host,$pathname:null==Ye?void 0:Ye.pathname,$raw_user_agent:it.length>1e3?it.substring(0,997)+"...":it,$browser_version:qi(it,navigator.vendor,f,m),$browser_language:go(),$browser_language_prefix:(x=go(),"string"==typeof x?x.split("-")[0]:void 0),$screen_height:null==Ge?void 0:Ge.screen.height,$screen_width:null==Ge?void 0:Ge.screen.width,$viewport_height:null==Ge?void 0:Ge.innerHeight,$viewport_width:null==Ge?void 0:Ge.innerWidth,$lib:a.LIB_NAME,$lib_version:a.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return a.SDK_DIST_CHANNEL&&(M.$sdk_dist_channel=a.SDK_DIST_CHANNEL),M}(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){var h=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0),_=h.windowId;l.$session_id=h.sessionId,l.$window_id=_}this.sessionPropsManager&&gr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&gr(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===nl&&(l.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),l=gr(l,c),"$pageview"===e&&Je&&(l.title=Je.title),!kt(o)){var g=i.getTime()-o;l.$duration=parseFloat((g/1e3).toFixed(3))}it&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var v=this.persistence.properties(),f=this.sessionPersistence.properties(),m=l.$groups,y=v.$groups;wt(m)&&!St(m)&&(l.$groups=s({},wt(y)?y:{},m)),pr(["$referrer","$referring_domain"],e=>{e in v&&delete f[e]});var b={};if(this._extensionEventPropertyProducers.length>0)for(var w of this._extensionEventPropertyProducers.slice())try{gr(b,w())}catch(e){dr.error("Failed to produce browser extension event properties",e)}(l=gr({},d,v,f,s({},b,l))).$is_identified=this._isIdentified(),yt(this.config.property_denylist)?pr(this.config.property_denylist,function(e){delete l[e]}):dr.error(Pl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(dr.error(El),l=S(l,e));var k=this._hasPersonProcessing();return l.$process_person_profile=k,k&&!n&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var s;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var r=gr({},this.persistence.get_initial_props(),(null==(s=this.sessionPropsManager)?void 0:s.getSetOnceProps())||{},e||{}),n=this.config.sanitize_properties;return n&&(dr.error(El),r=n(r,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),St(r)?void 0:r}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t,i;null==(t=this.persistence)||t.syncCookieProperties(),this._processCookieIdentityChange(),null==(i=this.sessionPersistence)||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null==(t=this.sessionPersistence)||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(this._sessionRegisteredPropertiesStorageKey)if("memory"===this.config.persistence||null!=(e=this.sessionPersistence)&&e._disabled||!Xr._is_supported())Xr._remove(this._sessionRegisteredPropertiesStorageKey);else{var t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Xr._set(this._sessionRegisteredPropertiesStorageKey,t):Xr._remove(this._sessionRegisteredPropertiesStorageKey)}}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null==(s=this.featureFlags)?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null==(s=this.featureFlags)||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null==(s=this.featureFlags)||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var s;return void 0===t&&(t=!1),null==(s=this.featureFlags)?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:xl}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:xl})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:xl})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=_l),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:xl}}canRenderSurveyAsync(e,t){var i,s;return void 0===t&&(t=!1),null!==(i=null==(s=this.surveys)?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:xl})}_validateIdentifyId(e){return!e||xt(e)?(dr.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(dr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(dr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return dr.uninitializedWarning("posthog.identify");if(Ft(e)&&(e=e.toString(),dr.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){this._healCookielessSentinelDistinctId();var s=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,n=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),e!==l&&e!==this.get_property("__alias")&&(this.unregister(_),this.register({distinct_id:e}));var u=(this.persistence.get_property("$user_state")||"anonymous")===Be,c=e!==l,d=!c&&u;if(c&&u){var h,p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(fe,qe),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture(We,p,{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=rl(e,t,i),null==(h=this.featureFlags)||h.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(d){this.persistence.set_property(fe,qe);var g=t||{},v=i||{};this.setPersonPropertiesForFlags({$set:g,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:g,$set_once:v}),this._cachedPersonProperties=rl(e,t,i)}else(t||i)&&this.setPersonProperties(t,i);c||r||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(_e)):d&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=rl(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):dr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(yt(e)?e:[e]).filter(e=>Ct(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var r;if(e&&t){null==(r=this.persistence)||r.syncCookieProperties(),this._processCookieIdentityChange();var n=this.getGroups(),o=n[e]!==t;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:s({},n,{[e]:t})}),(o||i)&&this._hasPersonProcessing()){var a={$group_type:e,$group_key:t};i&&(a.$group_set=i),this.capture(Ue,a)}i&&this.setGroupPropertiesForFlags({[e]:i}),o&&!i&&this.reloadFeatureFlags()}else dr.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t=Tt(e)?e:null==e?void 0:e.resetDeviceID,i=Tt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t,i){var r,n,o,a;if(void 0===t&&(t=!1),dr.info("reset"),!this.__loaded)return dr.uninitializedWarning("posthog.reset");var l=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null==(r=this._originalUserConfig)?void 0:r.bootstrap)||{},null==(n=this.featureFlags)||null==n.updateConfig||n.updateConfig(this.config,this._shouldDisableFlags());var u=this.get_property(d),c=this.get_property(h),_=this.get_property(F);null==(o=this.sessionRecording)||o.flushBeforeIdentityReset();var p=this.is_capturing();this.consent.reset(),t||!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.");var g=null==(a=this.persistence)||null==a._beginCookieSyncSuppression?void 0:a._beginCookieSyncSuppression(),v=!1;try{var f,m,y,b,w,S,k,C,x,E,P,I,T;if(null==(f=this.persistence)||f.clear(),null==(m=this.sessionPersistence)||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),kt(_)||null==(y=this.persistence)||y.register({[F]:_}),null==(b=this.surveys)||b.reset(),null==(w=this.featureFlags)||w.reset(),null==(S=this.conversations)||S.reset(),null==(k=this.logs)||k.reset(),null==(C=this.metrics)||C.reset(),null==(x=this.persistence)||x.set_property(fe,Be),null==(E=this.sessionManager)||E.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Ce,$device_id:null},"");else{var R=this.config.get_device_id(Rr());this.register_once({distinct_id:R,$device_id:e?R:u},""),e||kt(c)||this.register({[h]:c})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(void 0===i.distinctID||this._inCookielessMode()||(null==(T=this.persistence)||T.set_property(fe,i.isIdentifiedID?qe:Be),this.register({distinct_id:i.distinctID})),null==(P=this.featureFlags)||P.initialize(),!(kt(l)||null!=(I=this.sessionManager)&&I.setBootstrapSessionId(l,!0))){var A=s({},i);delete A.sessionID,this.config.bootstrap=A}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,v=!0}finally{var M;g&&(null==(M=this.persistence)||null==M._endCookieSyncSuppression||M._endCookieSyncSuppression(v))}this.reloadFeatureFlags()}shutdown(e){var t=this;return n(function*(){var e,i,s,r,n,o,a;if(t.__loaded){t._getBrowserClientAdapter().dispose(),null==(e=t.sessionRecording)||e.dispose(),null==(i=t.logs)||i.flushLogs("sendBeacon"),null==(s=t.metrics)||s.flush("sendBeacon"),null==(r=t._requestQueue)||r.unload(),null==(n=t._retryQueue)||n.unload();try{var l;null==(l=t.featureFlags)||l.destroy()}catch(e){dr.error("Error while destroying feature flags",e)}null==(o=t.persistence)||o.destroy(),null==(a=t.sessionPersistence)||a.destroy()}else dr.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(dr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(kt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(_,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(dr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=s({},this.config);if(wt(e)){var i,r,n,o,a,u,c,d,h,_,p,g,v;gr(this.config,Ol(e));var f=this._is_persistence_disabled();null==(i=this.persistence)||i.update_config(this.config,t,f),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ao(s({},this.config,{persistence:"sessionStorage"}),f,!1);var m=this._checkLocalStorageForDebug(this.config.debug);Tt(m)&&(this.config.debug=m),Tt(this.config.debug)&&(this.config.debug?(l.DEBUG=!0,Br._is_supported()&&Br._set("ph_debug",!0),dr.info("set_config",{config:e,oldConfig:t,newConfig:s({},this.config)})):(l.DEBUG=!1,Br._is_supported()&&Br._remove("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this._shouldDisableFlags()),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(u=this.tracingHeaders)||u.startIfEnabledOrStop(),null==(c=this.autocapture)||c.startIfEnabled(),null==(d=this.heatmaps)||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null==(h=this.historyAutocapture)||h.startIfEnabledOrStop()),null==(_=this.exceptionObserver)||_.startIfEnabledOrStop(),null==(p=this.deadClicksAutocapture)||p.startIfEnabledOrStop(),null==(g=this.surveys)||g.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(v=this.externalIntegrations)||v.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&Wn(this,kl,!1)}}_overrideSDKInfo(e,t){l.LIB_NAME=e,l.LIB_VERSION=t}startSessionRecording(e){var t,i,s,r,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),a.url_trigger&&(null==(r=this.sessionRecording)||r.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){try{if(!this.exceptions)return;var i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(s({},i,t))}catch(e){return}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var t,i;return null!==(t=null==(i=this.logs)?void 0:i.logger)&&void 0!==t?t:e._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Rl;return t!==Rl&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property("$user_state"))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&St(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e.__alias)&&(null==(t=this.persistence)||null==(t=t.props)||!t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(dr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(ke,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t,i,s,r,n=this._is_persistence_disabled();return this.is_capturing()||null==(e=this.logs)||e._onOptOut(),(null==(t=this.persistence)?void 0:t._disabled)!==n&&(null==(i=this.persistence)||i.set_disabled(n)),(null==(s=this.sessionPersistence)?void 0:s._disabled)!==n&&(null==(r=this.sessionPersistence)||r.set_disabled(n)),n&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),n}opt_in_capturing(t){var i,s,r;if("always"!==this.config.cookieless_mode){if(this._inCookielessMode()){var n,o,a,l,u,c;null==(n=this.sessionRecording)||n.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null==(o=this.sessionManager)||o.destroy(),null==(a=this.pageViewManager)||a.destroy(),this.sessionManager=new Qa(this),this.pageViewManager=new Qn(this),this.persistence&&(this.sessionPropsManager=new Wa(this,this.sessionManager,this.persistence));var d,h=null!==(l=null==(u=this.config.__extensionClasses)?void 0:u.sessionRecording)&&void 0!==l?l:null==(c=e.__defaultExtensionClasses)?void 0:c.sessionRecording;h&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new h(this)),this._lastRemoteConfig&&(null==(d=this.sessionRecording)||null==d.onRemoteConfig||d.onRemoteConfig(this._lastRemoteConfig)))}this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(i=this.sessionRecording)||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null==(s=this.surveys)||s.loadIfEnabled()),(kt(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(r=null==t?void 0:t.captureEventName)&&void 0!==r?r:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else dr.warn(Cl)}opt_out_capturing(){if("always"!==this.config.cookieless_mode){var e,t,i="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;null==i||i.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:Ce,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())}else dr.warn(Cl)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return 1===e?"granted":0===e?"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._sync_opt_out_with_persistence()}_is_bot(){return Qe?Ja(Qe,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Je&&("visible"===Je.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(je,{title:Je.title},{send_instantly:!0}),this._visibilityStateListener&&(Je.removeEventListener(Ne,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),kr(Je,Ne,this._visibilityStateListener)))}debug(e){!1===e?(null==Ge||Ge.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==Ge||Ge.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){var e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(dr.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(e,t,i,s,r){var n=t in e&&!Pt(e[t]),o=i in e&&!Pt(e[i]);return n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,dr)}_runBeforeSend(e){var t;if(Pt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(At),s=yt(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var n of s)try{if(r=n(r),Pt(r)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Rt(e.event)?dr.warn(o+". This can cause unexpected behavior."):dr.info(o),null}r.properties&&!St(r.properties)||dr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(t){return dr.error("Error in beforeSend function for event '"+e.event+"':",t),null}for(var a of i)if(r.properties&&Pt(r.properties[a]))return dr.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return r}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=Tt(e)&&!e,i=Br._is_supported()&&"true"===Br._get("ph_debug");return!t&&(!!i||e)}},r.__defaultExtensionClasses={},r._noopLogger=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),r);!function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=mr(e.prototype[t[i]])}(Bl,["identify"]);var ql=class{constructor(e){this.disabled=!1===e;var t=wt(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Hl="$copy_autocapture",Nl=hr("[AutoCapture]");function zl(e,t){return t.length>e?t.slice(0,e)+"...":t}function jl(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!sn(t));return t}function Vl(e,t){var i,r,n=t.e,o=t.maskAllElementAttributes,a=t.maskAllText,l=t.elementAttributeIgnoreList,u=t.elementsChainAsString,c=t.disableCaptureUrlHashes;if(!sn(e))return{props:{}};for(var d=[e],h=new Set([e]),_=e;_.parentNode&&!rn(_,"body")&&1e3>d.length;)if(on(_.parentNode)){var p=_.parentNode.host;if(h.has(p))break;h.add(p),d.push(p),_=p}else{if(!sn(_.parentNode))break;if(h.has(_.parentNode))break;h.add(_.parentNode),d.push(_.parentNode),_=_.parentNode}var g="click"===n.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?d.findIndex(e=>rn(e,"button")||rn(e,"a")):-1;g>0&&(a=a||d.slice(0,g+1).some(e=>!En(e)||Pn(e)));var v,f,m,y=[],b={},w=!1,S=!1;if(pr(d,e=>{var t=En(e);if(rn(e,"a")){var i=e.getAttribute("href");w=!!(t&&i&&$n(i))&&(c?es(i):i)}lt(un(e),"ph-no-capture")&&(S=!0),y.push(function(e,t,i,s,r){void 0===r&&(r=!1);var n=e.tagName.toLowerCase(),o={tag_name:n};_n.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?zl(1024,On(e)):zl(1024,dn(e)));var a=un(e);a.length>0&&(o.classes=a.filter(function(e){return""!==e})),pr(e.attributes,function(i){var n;if((!Pn(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==s||!s.includes(i.name))&&!t&&$n(i.value)&&(!Ct(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=an(a).join(" ")),o["attr__"+i.name]=zl(1024,"href"===i.name&&r?es(a):a)}});for(var l=1,u=1,c=e;c=jl(c);)l++,c.tagName===e.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(e,o,a,l,c)),pr(function(e){if(!En(e))return{};var t={};return pr(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&$n(s)&&(t[i]=s)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(b,t)||(b[t]=e)})}),S)return{props:{},explicitNoCapture:S};if(g>0&&(e=d[g],y.splice(0,g)),a||(y[0].$el_text=rn(e,"a")||rn(e,"button")?On(e):dn(e)),w){var k,C;y[0].attr__href=w;var x=null==(k=to(w))?void 0:k.host,E=null==Ge||null==(C=Ge.location)?void 0:C.host;x&&E&&x!==E&&(v=w)}return{props:gr((f=n.type,{$event_type:f,$ce_version:1}),u?{}:{$elements:y},{$elements_chain:(m=y,yt(m)?function(e){return e.map(e=>{var t,i,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var o=s({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return vr(o).sort((e,t)=>{return(s=t[0])>(i=e[0])?-1:i>s?1:0;var i,s}).forEach(e=>{var t=e[1];return a[Bn(e[0].toString())]=Bn(t.toString())}),(r+=":")+vr(a).map(e=>e[0]+'="'+e[1]+'"').join("")}).join(";")}(function(e){return e.map(e=>{var t,i,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:qn(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return vr(e).filter(e=>0===e[0].indexOf("attr__")).forEach(e=>s.attributes[e[0]]=e[1]),s})}(m)):"")},null!=(i=y[0])&&i.$el_text?{$el_text:null==(r=y[0])?void 0:r.$el_text}:{},v&&"click"===n.type?{$external_click_url:v}:{},b),target:e}}var Wl=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!En(e))return!0;for(var i,s=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:fn,r=new Set,n=e,o=function(){if(r.size>=1e3||r.has(n))return{v:!0};r.add(n);var e=n,t=un(e);if(lt(t,"ph-no-capture")||lt(t,"ph-sensitive")||Pn(e)||s.some(t=>pn(e,t)))return{v:!0};var i=n.parentNode;n=on(i)?i.host:i&&sn(i)?i:null};n;)if(i=o())return i.v;return!1}_trackPointer(e){if(this.isEnabled&&"pointercancel"!==e.type)if("pointerdown"!==e.type){var t=this._pointerDown;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this._clearPointer():"pointerup"===e.type&&(t.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}else{var i;this._clearPointer();var s=hn(e);e.isPrimary&&0===e.button&&!e.ctrlKey&&s&&sn(s)&&(this._pointerDown={target:s,excluded:this._isExcludedPointerTarget(s),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null==(i=this._client)?void 0:i.distinctId})}else this._clearPointer()}_recoverClickTarget(e){var t,i=this._pointerDown;this._clearPointer();var s=hn(e);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(t=this._client)?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(rn(s,"html")||rn(s,"body"))){var r;if(i.excluded)return null;var n=null!==(r=this._refreshConfig().css_selector_ignorelist)&&void 0!==r?r:fn;return[s,null==Je?void 0:Je.documentElement,null==Je?void 0:Je.body].some(e=>{if(!e)return!1;var t=un(e);return lt(t,"ph-no-capture")||lt(t,"ph-sensitive")||!En(e)||Pn(e)||n.some(t=>pn(e,t))})?null:i.target}}constructor(e){this._configSource=e,this.name="autocapture",this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementsChainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new ql(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;var t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,null==(e=this._remoteConfigSubscription)||e.dispose(),this._remoteConfigSubscription=void 0,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){var e,t;return this._refreshConfig(),this._config.url_allowlist=null==(e=this._config.url_allowlist)?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null==(t=this._config.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ge&&Je){var e=this._domEventHandler=e=>{e=e||(null==Ge?void 0:Ge.event);try{if("blur"===e.type)return void this._clearPointer();if(0===e.type.indexOf("pointer"))return void this._trackPointer(e);var t="click"===e.type?this._recoverClickTarget(e):void 0;if(Et(t))return;this._captureEvent(e,"$autocapture",t)}catch(e){Nl.error("Failed to capture event",e)}};if(kr(Ge,"blur",e),kr(Je,"submit",e,{capture:!0}),kr(Je,"change",e,{capture:!0}),kr(Je,"click",e,{capture:!0}),pr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{kr(Je,t,e,{capture:!0})}),this._refreshConfig().capture_copied_text){var t=this._copiedTextHandler=e=>{e=e||(null==Ge?void 0:Ge.event);try{this._captureEvent(e,Hl)}catch(e){Nl.error("Failed to capture clipboard event",e)}};kr(Je,"copy",t,{capture:!0}),kr(Je,"cut",t,{capture:!0}),kr(Je,"paste",t,{capture:!0})}}}else Nl.info("Disabling Automatic Event Collection because this browser is not supported")}_removeDomEventHandlers(){this._clearPointer(),this._domEventHandler&&(null==Ge||Ge.removeEventListener("blur",this._domEventHandler),pr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==Je||Je.removeEventListener(e,this._domEventHandler,!0)}),null==Je||Je.removeEventListener("submit",this._domEventHandler,!0),null==Je||Je.removeEventListener("change",this._domEventHandler,!0),null==Je||Je.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==Je||Je.removeEventListener("copy",this._copiedTextHandler,!0),null==Je||Je.removeEventListener("cut",this._copiedTextHandler,!0),null==Je||Je.removeEventListener("paste",this._copiedTextHandler,!0),this._copiedTextHandler=void 0),this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(!this._disposed)if(this._hasReceivedConfigResponse=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);var i,s=t.autocapture_opt_out;Tt(s)&&(null==(i=this._client)||i.kv.set(m,s),this._isDisabledServerSide=s),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e,t){var i,s=[];return null==(i=this._elementSelectors)||i.forEach(i=>{var r;null==Je||null==(r=Je.querySelectorAll(i))||r.forEach(r=>{e!==r&&t!==r||lt(s,i)||s.push(i)})}),s}get isEnabled(){var e,t;if(this._disposed)return!1;var i=null==(e=this._client)?void 0:e.kv.get(m),s=this._isDisabledServerSide,r=this._refreshConfig(),n=r.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(Et(s)&&!Tt(i)&&!n)return!1;var o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!r.enabled&&!o}_captureEvent(e,t,i){if(void 0===t&&(t="$autocapture"),this.isEnabled){var r=i||hn(e);nn(r)&&(r=r.parentNode||null);var n,o=this._compileUrlPatterns();"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&o.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&kn(r,o.rageclick)&&this._captureEvent(e,"$rageclick",i);var a=t===Hl,l=a?s({},o,{dom_event_allowlist:void 0}):o;if(r&&function(e,t,i,s,r,n){var o;if(!Ge||Cn(e))return!1;if(null!=i&&i.url_allowlist&&!ln(i.url_allowlist,n))return!1;if(null!=i&&i.url_ignorelist&&ln(i.url_ignorelist,n))return!1;if(null!=i&&i.dom_event_allowlist){var a=i.dom_event_allowlist;if(a&&!a.some(e=>t.type===e))return!1}var l=xn(e,s),u=l.parentIsUsefulElement,c=l.targetElementList;if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(kt(i))return!0;var s,r=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var n of e)if(s=r(n))return s.v;return!1}(c,i))return!1;if(!gn(c,null==i?void 0:i.css_selector_allowlist))return!1;if(gn(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:fn))return!1;try{var d=Ge.getComputedStyle(e);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return u?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(_n.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,l,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var u,c=Vl(r,{e:e,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),d=c.props;if(c.explicitNoCapture)return!1;var h=this.getElementSelectors(r,c.target);if(h&&h.length>0&&(d.$element_selectors=h),t===Hl){var _=e.type||"clipboard";if("paste"!==_){var p,g,v=null==Ge||null==(p=Ge.getSelection())?void 0:p.toString(),f=cn(v);if(!f)return!1;d.$selected_content=f,d.$clipboard_text_length=null!==(g=null==v?void 0:v.length)&&void 0!==g?g:0}d.$copy_type=_}return null==(u=this._client)||u.capture(t,d).catch(e=>Nl.error("Failed to capture event",e)),!0}}else this._clearPointer()}isBrowserSupported(){return bt(null==Je?void 0:Je.querySelectorAll)}},Ul=class{constructor(e){this._instance=e}refresh(e){var t=this._instance.config,i=wt(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),e.url_allowlist=null==i?void 0:i.url_allowlist,e.url_ignorelist=null==i?void 0:i.url_ignorelist,e.dom_event_allowlist=null==i?void 0:i.dom_event_allowlist,e.element_allowlist=null==i?void 0:i.element_allowlist,e.css_selector_allowlist=null==i?void 0:i.css_selector_allowlist,e.css_selector_ignorelist=null==i?void 0:i.css_selector_ignorelist,e.element_attribute_ignorelist=null==i?void 0:i.element_attribute_ignorelist,e.capture_copied_text=null==i?void 0:i.capture_copied_text}},Gl=hr("[ExceptionAutocapture]"),Kl=()=>{},Ql=e=>{var t;if(bt(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Jl(e,t,i){try{if(!(t in e))return Kl;var s={next:e[t]},r=i(function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.next.apply(this,t)});return bt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=r,()=>{if(e[t]!==r)for(var i=e[t],n=Ql(i);n;){if(n.next===r)return void(n.next=s.next);n=Ql(i=n.next)}else e[t]=s.next}}catch(e){return Kl}}var Yl=hr("[TracingHeaders]"),Xl=hr("[Web Vitals]"),Zl=9e5,eu=["CLS","FCP","INP","LCP"],tu=["INP","LCP"],iu=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],su="disabled",ru="lazy_loading",nu=hr("[SessionRecording]"),ou=hr("[Heatmaps]");function au(e){return wt(e)&&"clientX"in e&&"clientY"in e&&Ft(e.clientX)&&Ft(e.clientY)}var lu=hr("[Product Tours]"),uu=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(x))},cu=hr("[SiteApps]"),du="Error while initializing PostHog app with config id ",hu=(e,t)=>null!=e&&e.then?e.then(t):t(e),_u="SDK is not enabled or survey functionality is not yet loaded",pu="Disabled. Not loading surveys.",gu=class{constructor(e,t){this._configSource=e,this._initialClientState=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(!this._disposed&&!this._config.disableSurveys){if(!e.ok)return cl.warn("Remote config unavailable. Not loading surveys.");var t=e.config.surveys;if(Pt(t))return cl.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=Tt(t)?t:t.length>0,cl.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}}setup(e){if(!this._disposed)return this._initializingClient=e,hu(e.kv.initialize(),()=>{if(this._initializingClient===e&&!this._disposed){this._initializingClient=void 0,this._client=e;var t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())}})}dispose(){var e,t,i;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null==(e=this._remoteConfigSubscription)||e.dispose(),this._remoteConfigSubscription=void 0,null==(t=this._surveyEventReceiver)||t.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._renderTimeouts.forEach(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var s=localStorage.key(i);(null!=s&&s.startsWith("seenSurvey_")||null!=s&&s.startsWith("inProgressSurvey_"))&&t.push(s)}t.forEach(e=>localStorage.removeItem(e))}catch(e){}}loadIfEnabled(){if(!this._disposed&&this._client){var e=this._config;if(!this._surveyManager)if(this._isInitializingSurveys)cl.info("Already initializing surveys, skipping...");else if(e.disableSurveys)cl.info(pu);else if(e.cookielessMode&&this._configSource.isOptedOut())cl.info("Not loading surveys in cookieless mode without consent.");else{var t=this._configSource.getExtensions();if(t){if(!kt(this._isSurveysEnabled)||e.advancedEnableSurveys){var i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0;try{var s=t.generateSurveys;if(s)return this._completeSurveyInitialization(s,i),void(this._isInitializingSurveys=!1);var r=t.loadExternalDependency;if(!r)return this._handleSurveyLoadError(De),void(this._isInitializingSurveys=!1);r(e=>{try{if(this._disposed)return;var t=this._configSource.getExtensions();e||null==t||!t.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",e):this._completeSurveyInitialization(t.generateSurveys,i)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError("Error initializing surveys",e),e}}}else cl.error("PostHog Extensions not found.")}}}_completeSurveyInitialization(e,t){this._disposed||(this._surveyManager=e(t),this._surveyEventReceiver=this._configSource.createEventReceiver(),cl.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0}))}_handleSurveyLoadError(e,t){cl.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(t=>t!==e)}}getSurveys(e,t){var i;void 0===t&&(t=!1);var s=null!==(i=this._client)&&void 0!==i?i:this._initialClientState;if(s&&!this._disposed){if(this._config.disableSurveys)return cl.info(pu),e([]);var r=s.kv.get(te);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)this._getSurveysInFlightPromise.then(t=>{this._disposed||e(t.surveys,t.context)}).catch(e=>cl.error("Error in survey callback",e));else{var n=this._sendSurveysRequest("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(s,e)}catch(e){return cl.error("Error processing surveys response",e),this._handleSurveyResponse(s,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(s,{statusCode:0,error:e}));this._getSurveysInFlightPromise=n;var o=()=>{this._getSurveysInFlightPromise===n&&(this._getSurveysInFlightPromise=null)};n.then(t=>{o(),this._disposed||e(t.surveys,t.context)},o).catch(e=>cl.error("Error in survey callback",e))}}}_sendSurveysRequest(e,t){var i=this._client;return i?i.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:new Error(_u)}))}_handleSurveyResponse(e,t){var i;if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:_u}};var s=t.statusCode;if(200!==s||!t.json){var r="Surveys API could not be loaded, status: "+s;return 0!==s?cl.error(r):t.error||cl.warn(r),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this._lastSurveyRefreshFailedAt=null;var n=t.json.surveys||[],o=n.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(Za(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e)));return o.length>0&&(null==(i=this._surveyEventReceiver)||i.register(o)),e.kv.set({[te]:n,[ie]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e,t,i=null==(e=null!==(t=this._client)&&void 0!==t?t:this._initialClientState)?void 0:e.kv.get(ie);return Ft(i)&&Date.now()-i>3e5}_isSurveyRefreshBackingOff(){return Ft(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;dl({id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){cl.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!Pt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);cl.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys(i=>{var s;t=null!==(s=i.find(t=>t.id===e))&&void 0!==s?s:null}),t}_checkSurveyEligibility(e){if(Pt(this._surveyManager))return{eligible:!1,reason:_u};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){if(Pt(this._surveyManager))return{eligible:!1,reason:_u};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Pt(this._surveyManager))return cl.warn("init was not called"),{visible:!1,disabledReason:_u};var t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Pt(this._surveyManager)?(cl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:_u})):new Promise(i=>{this.getSurveys(t=>{var s,r=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(r){var n=this._checkSurveyRenderability(r);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s;if(Pt(this._surveyManager))cl.warn("init was not called");else{var r="string"==typeof e?this._getSurveyById(e):e;if(null!=r&&r.id)if(hl.includes(r.type)){var n=null==Je?void 0:Je.querySelector(t);if(n)if(null!=(s=r.appearance)&&s.surveyPopupDelaySeconds){cl.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var e,t;this._renderTimeouts.delete(o),this._disposed||(cl.info("Rendering survey "+r.id+" with delay of "+(null==(e=r.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(r,n,i),cl.info("Survey "+r.id+" rendered"))},1e3*r.appearance.surveyPopupDelaySeconds);this._renderTimeouts.add(o)}else this._surveyManager.renderSurvey(r,n,i);else cl.warn("Survey element not found")}else cl.warn("Surveys of type "+r.type+" cannot be rendered in the app");else cl.warn("Survey not found")}}displaySurvey(e,t){var i;if(Pt(this._surveyManager))cl.warn("init was not called");else{var r=this._getSurveyById(e);if(r){var n=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=s({},r,{appearance:s({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==No&&t.initialResponses&&cl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this._checkSurveyEligibility(r);if(!o.eligible)return void cl.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else cl.warn("Survey not found")}}cancelPendingSurvey(e){Pt(this._surveyManager)?cl.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||null==e.handlePageUnload||e.handlePageUnload()}};function vu(e,t,i){if(Pt(e))return!1;switch(i){case"exact":return e===t;case"contains":var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var fu=class{constructor(e){this._instance=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Ua,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;kt(null==(e=this._instance)?void 0:e._addCaptureHook)||(this._captureHookUnsubscribe=null==(t=this._instance)?void 0:t._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;null==(e=this._captureHookUnsubscribe)||e.call(this),this._captureHookUnsubscribe=void 0,this._debugEventEmitter=new Ua}register(e){var t,i;if(!kt(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null==(t=e.steps)||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null!=(i=this._instance)&&i.autocapture)){var s=new Set;this._actionRegistry.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&s.add(e.selector)})}),this._instance.autocapture.setElementSelectors(s)}}replace(e){this._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry.forEach(e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)})}_addActionHook(e){this.onAction("actionCaptured",t=>e(t))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!vu(s,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var i;if(null==t||!t.href)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some(e=>vu(e.href,t.href,t.href_matching||"exact"));var r,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&vu((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some(e=>vu(e.text,t.text,t.text_matching||"exact")||vu(e.$el_text,t.text,t.text_matching||"exact"));var r,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(r=function(e){for(var t,i=[],s=/(?::|")text="(.*?)"/g;!Pt(t=s.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",r.some(e=>vu(e,n,o)))}_checkStepSelector(e,t){var i,s;if(null==t||!t.selector)return!0;if(null!=e&&null!=(i=e.properties)&&null!=(i=i.$element_selectors)&&i.includes(t.selector))return!0;var r=(null==e||null==(s=e.properties)?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||sl(t.properties.reduce((e,t)=>{var i=yt(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}},mu=class{constructor(e){var t;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,this._sessionIdUnsubscribe=null==(t=this._instance)||null==t.onSessionId?void 0:t.onSessionId(e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&sl(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach(e=>{var s;null==(s=e.conditions)||null==(s=s[t])||null==(s=s.values)||s.forEach(t=>{if(null!=t&&t.name){var s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}_getMatchingItems(e,t,i){var s=(i===$o?this._eventToItems:this._cancelEventToItems).get(e),r=[];return this._getItems(e=>{r=e.filter(e=>null==s?void 0:s.includes(e.id))}),r.filter(s=>{var r,n=null==(r=s.conditions)||null==(r=r[i])||null==(r=r.values)?void 0:r.find(t=>t.name===e);return this._doesEventMatchFilter(n,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){var i;kt(null==(i=this._instance)?void 0:i._addCaptureHook)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){var i=e.filter(e=>{var t;return null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)?void 0:t.length});if(t&&this._actionToItems.clear(),0!==i.length){this._actionMatcher||(this._actionMatcher=new fu(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));var s=[];i.forEach(e=>{var t;null==(t=e.conditions)||null==(t=t.actions)||t.values.forEach(t=>{if(s.push(t),t.name){var i,r=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];r.includes(e.id)||r.push(e.id),this._actionToItems.set(t.name,r)}})}),t?this._actionMatcher.replace(s):this._actionMatcher.register(s)}else{var r;t&&(null==(r=this._actionMatcher)||r.replace([]))}}_mergeItemMaps(e,t){t.forEach((t,i)=>{var s,r=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{r.includes(e)||r.push(e)}),e.set(i,r)})}_setupEventBasedItems(e,t){var i,s,r=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),n=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}),o=this._buildEventToItemMap(e,$o),a=this._buildEventToItemMap(e,Oo);t?(this._eventToItems=o,this._cancelEventToItems=a):(this._mergeItemMaps(this._eventToItems,o),this._mergeItemMaps(this._cancelEventToItems,a)),(0!==r.length||0!==n.length)&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null==(s=this._instance)?void 0:s._addCaptureHook((e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s,r=this._getLogger(),n=(null==t||null==(i=t.properties)?void 0:i.$survey_id)||(null==t||null==(s=t.properties)?void 0:s.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this._activationOutcome(e,n);if("consume"===o)return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this._deactivateItems([n]);if("persist"===o)return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this._persistActivation(n),void this._clearActivationTimestamps([n])}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,Oo);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(e=>e.id)}),this._deactivateItems(a.map(e=>e.id)),a.forEach(e=>this._cancelPendingItem(e.id)))}if(this._eventToItems.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var l=this._getMatchingItems(e,t,$o);this._activateItems(l.map(e=>e.id))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){var t;if(0!==e.length){var i=!(null==(t=this._instance)||null==t.get_session_id||!t.get_session_id()),s=[];for(var r of e)i&&this._shouldPersistArmedActivation(r)?this._persistActivation(r)&&this._recordActivationTimestamp(r):s.push(r);s.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...s])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()})}}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);var t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));var i=this._getRawPersistedActivatedIds(),s=i.filter(e=>!t.has(e));s.length!==i.length&&(this._setActivatedItems(s),0===s.length&&this._clearActivationSession()),this._clearActivationTimestamps(e)}_getRawActivationTimestamps(){var e,t=this._getActivationTimestampsKey();if(!t)return{};var i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t];return i&&"object"==typeof i?i:{}}_recordActivationTimestamp(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps();this._writeActivationTimestamps(s({},t,{[e]:Date.now()}))}}_clearActivationTimestamps(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps(),i={},s=!1;for(var r of Object.entries(t)){var n=r[0],o=r[1];e.includes(n)?s=!0:i[n]=o}s&&(St(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(this._getPersistedActivatedIds().includes(e)){var t=this._getRawActivationTimestamps()[e];return Ft(t)?t:void 0}}_getRawPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,i=this._getRawPersistedActivatedIds();if(0===i.length)return[];var s=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this._getActivatedSessionKey()],r=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();return r&&s===r?i:[]}_stampActivationSession(){var e,t=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();t&&this._setActivatedSession(t)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this._getActivatedSessionKey()];if(i&&i!==e){var s=this._getRawPersistedActivatedIds(),r=this._getRawActivationTimestamps();s.length>0&&(this._setActivatedItems([]),s.filter(e=>Ft(r[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,i;null==(e=this._sessionIdUnsubscribe)||e.call(this),this._sessionIdUnsubscribe=void 0,null==(t=this._captureHookUnsubscribe)||t.call(this),this._captureHookUnsubscribe=void 0,null==(i=this._actionMatcher)||i.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},yu=class extends mu{constructor(e){super(e)}_getActivatedKey(){return se}_getActivatedSessionKey(){return re}_getActivationTimestampsKey(){return ne}_writeActivationTimestamps(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[ne]:e})}_clearActivationTimestampsStore(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(ne)}_shouldPersistArmedActivation(e){var t,i;this._getItems(t=>{i=t.find(t=>t.id===e)});var s=null==(t=i)||null==(t=t.appearance)?void 0:t.surveyPopupDelaySeconds;return Ft(s)&&s>0}_getShownEventName(){return Do}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return cl}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[se]:e})}_setActivatedSession(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[re]:e})}_clearActivatedSession(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(re)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){var i;return this._getItems(e=>{i=e.find(e=>e.id===t)}),!i||function(e){var t;return Za(e)&&!(null==(t=e.conditions)||null==(t=t.events)||!t.repeatedActivation)||"always"===e.schedule}(i)?e===Do?"consume":"ignore":e===Do?"persist":e===Bo||e===qo?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},bu=class{constructor(e){this._instance=e}initialize(){}get(e){if("string"==typeof e)return this._instance.get_property(e);var t={};for(var i of e){var s=this._instance.get_property(i);kt(s)||(t[i]=s)}return t}set(e,t){this._instance.register("string"==typeof e?{[e]:t}:e)}remove(e){"string"!=typeof e?e.forEach(e=>this._instance.unregister(e)):this._instance.unregister(e)}},wu=class{constructor(e){this._instance=e}get(){var e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var e=null==nt?void 0:nt.__PosthogExtensions__;if(e){var t=e.generateSurveys,i=e.loadExternalDependency;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:i?e=>i(this._instance,"surveys",e):void 0}}}createEventReceiver(){return new yu(this._instance)}},Su=null!=Ge&&Ge.location?ro(Ge.location.hash,"__posthog")||ro(location.hash,"state"):null,ku="_postHogToolbarParams",Cu=hr("[Toolbar]"),xu=hr("[FeatureFlags]"),Eu=class{constructor(e,t){void 0===t&&(t=!1),this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,s,r,n,o;return{bootstrap:{featureFlags:null==(i=e.bootstrap)?void 0:i.featureFlags,featureFlagPayloads:null==(s=e.bootstrap)?void 0:s.featureFlagPayloads},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(r=e.remote_config_refresh_interval_ms)&&void 0!==r?r:3e5,requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(o=e.evaluation_contexts)&&void 0!==o?o:e.evaluation_environments)&&void 0!==n?n:[],flagKeys:yt(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(xu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),kt(e.flag_keys)||yt(e.flag_keys)||xu.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}},Pu=hr("[FeatureFlags]"),Fu=hr("[FeatureFlags]",{debugEnabled:!0}),Iu="\" failed. Feature flags didn't load in time.",Tu="connection_error",Ru=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Au=e=>{var t={};for(var i of vr(e||{})){var s=i[1];s&&(t[i[0]]=s)}return t},Mu=e=>$t(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),Lu=hr("[Error tracking]"),$u="webkit-masked-url:",Ou=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",$u],Du=["__firefox__","__gCrWeb"],Bu="Refusing to render web experiment since the viewer is a likely bot",qu={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>el(t,e),not_regex:(e,t)=>!el(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Hu=hr("[Conversations]"),Nu="Conversations not available yet.";function zu(e,t){var i,r,n,o,a,l,u,c=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,d=null!==(r=null==e?void 0:e.maxBufferSize)&&void 0!==r?r:100,h=null!=t&&t.consoleCapture?void 0:null!==(n=null==e?void 0:e.maxLogsPerInterval)&&void 0!==n?n:1e3,_=kt(h)?Math.max(d,2048):Math.max(d,h),p=s({},function(){var e="",t="";try{var i=null==Qe?void 0:Qe.userAgent;if(i){var r=Ni(i);e=r[0],t=r[1]}}catch(e){}return function(e,t){var i=function(e){if(e)return{}.hasOwnProperty.call(Xs,e)?Xs[e]:e}(e);return s({},i?{"os.name":i}:{},t?{"os.version":t}:{})}(e,t)}(),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(o=null!==(a=null==p?void 0:p["service.name"])&&void 0!==a?a:null==e?void 0:e.serviceName)&&void 0!==o?o:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(l=null==p?void 0:p["service.version"])&&void 0!==l?l:null==e?void 0:e.serviceVersion,environment:null!==(u=null==p?void 0:p["deployment.environment"])&&void 0!==u?u:null==e?void 0:e.environment,resourceAttributes:p,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:d,maxQueueSize:_,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var ju=["debug","log","warn","error","info"],Vu="console",Wu="__posthogHandledLogsRequestError",Uu=(e,t)=>{var i=e instanceof Error?e:new Error(t);return i[Wu]=!0,i},Gu=e=>!!e&&"object"==typeof e&&!0===e[Wu],Ku={featureFlags:class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=Pu,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._onOnline=()=>{var e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t=this._refreshIntervalMs;kt(t)||this._config.remoteRequestsDisabled||!Je||"hidden"===Je.visibilityState||Date.now()-(null!==(e=this._lastRefreshAt)&&void 0!==e?e:0)<t||(this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onVisibilityChange=()=>{"visible"===(null==Je?void 0:Je.visibilityState)&&this._refreshIfDue()},"get"in e?this._configSource=e:(this._instance=e,this._mutableConfigSource=new Eu(e.config,e._shouldDisableFlags()),this._configSource=this._mutableConfigSource)}updateConfig(e,t){var i;null==(i=this._mutableConfigSource)||i.update(e,t),this._client&&this._syncAutomaticRefresh()}setup(e){return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),hu(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return Ge&&kr(Ge,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_syncAutomaticRefresh(){var e=this._config.refreshIntervalMs,t=!this._config.remoteRequestsDisabled&&Je&&!kt(e)&&e>0?e:void 0;t!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),kt(t)||(this._refreshIntervalMs=t,this._scheduleNextRefresh(),null!=Je&&Je.addEventListener&&kr(Je,Ne,this._onVisibilityChange)))}_scheduleNextRefresh(){kt(this._refreshIntervalMs)||(kt(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){kt(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null==Je||null==Je.removeEventListener||Je.removeEventListener(Ne,this._onVisibilityChange)),this._refreshIntervalMs=void 0,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._client&&(this._clearDebouncer(),null==(e=this._dynamicProperties)||e.dispose(),this._dynamicProperties=void 0,null==(t=this._crossTabPersistenceUnsubscribe)||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null==Ge||Ge.removeEventListener("online",this._onOnline),this._client=void 0)}get _config(){return this._configSource.get()}_prop(e){var t;return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:null==(t=this._client)?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!kt(null==(e=this._client)?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null==(t=this._client)?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){var s;if(null!=(s=this._instance)&&s.persistence&&e.$enabled_feature_flags){var r=this._prop("$enabled_feature_flags")||{},n=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(e=>{var t=e[1];return!(null!=t&&t.failed)}).map(e=>e[0]):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,u=l?a:i&&!yt(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),c=this._prop("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},h=l||i?u:Array.from(new Set([...Object.keys(c),...Object.keys(d)])),_=!l&&!i,p=!!_||u,g=!!_||h,v={[V]:p,[j]:p,[G]:g};for(var f of(e.$feature_flag_details&&(v[U]=p),[K,ve,Q]))kt(e[f])||(v[f]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(v)}}_remove(e){this._persist(()=>{var t;return null==(t=this._client)?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){var e={};for(var t of[V,G,K,J]){var i=this._prop(t);kt(i)||(e[t]=i)}this._baseEventProperties=e;var r=s({},e),n=this._prop(j);if(n)for(var o of Object.entries(n))r["$feature/"+o[0]]=o[1];this._eventPropertiesWithFlagValues=r}_isCacheStale(){var e=this._config.cacheTtlMs;if(!e||0>=e)return!1;var t=this._prop(ve);return"number"!=typeof t||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e=this._config.evaluationContexts;return null!=e&&e.length?e.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}_getValidFlagKeys(){var e=this._config.flagKeys;if(!kt(e))return e.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t,i=this._config,s=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var r,n,o=null!==(r=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==r?r:{},a=Object.keys(s).filter(e=>!kt(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),l=Object.keys(o).filter(e=>a[e]).reduce((e,t)=>(e[t]=o[t],e),{});return this._receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,i){var r,n,o=null!=i&&i.merge&&null!==(r=this._prop("$enabled_feature_flags"))&&void 0!==r?r:{},a=null!=i&&i.merge&&null!==(n=this._prop("$feature_flag_payloads"))&&void 0!==n?n:{},l=s({},o,e),u=s({},a,t),c={};for(var d of Object.entries(l)){var h=d[0],_=d[1];c[h]={key:h,enabled:$s(_),variant:Os(_),reason:void 0,metadata:kt(null==u?void 0:u[h])?void 0:{id:0,version:void 0,description:void 0,payload:u[h]}}}this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(U),t=this._prop(J),i=this._prop(Y);if(!i&&!t)return e||{};var r=gr({},e||{});for(var n of[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])]){var o,a,l=r[n],u=null==t?void 0:t[n],c=kt(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=kt(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,h=null==i?void 0:i[n],_=s({},l,{enabled:c,variant:c?null!=d?d:null==l?void 0:l.variant:void 0});c!==(null==l?void 0:l.enabled)&&(_.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(_.original_variant=null==l?void 0:l.variant),h&&(_.metadata=s({},null==l?void 0:l.metadata,{payload:h,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=_}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this._override_warning=!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{var s=e[i];return{key:i,enabled:$s(s),variant:Os(s),payload:Ls(t[i])}})}getFlagVariants(){var e=this._prop(j),t=this._prop(J);if(!t)return e||{};for(var i=gr({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(G),t=this._prop(Y);if(!t)return e||{};for(var i=gr({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(this._logger.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error("Error while running feature flags reloading callback",e)}}),this._reloadDebouncer=setTimeout(()=>{this._callFlagsEndpoint()},5)))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(_e)}_callFlagsEndpoint(e){this._clearDebouncer();var t=this._client;if(t&&!this._config.remoteRequestsDisabled&&!this._hasStatusZeroCircuitBreakerTripped())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var i={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:s({},t.initialPersonProperties,this._prop("$stored_person_properties")||{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this._prop(Z),timezone:bo()};kt(t.deviceId)||(i.$device_id=t.deviceId),(null!=e&&e.disableFlags||this._config.featureFlagsDisabled)&&(i.disable_flags=!0);var r=this._getValidEvaluationEnvironments();r.length&&(i.evaluation_contexts=r);var n=this._getValidFlagKeys();kt(n)||(i.flag_keys=n);var o=this._config.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this._requestGeneration;this._requestInFlight=!0;var u=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},c=e=>{this._requestInFlight=!1,l===this._requestGeneration?(this._set({[ge]:[Tu]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),u()):u()};try{t.sendRequest(a,{target:"flags",method:"POST",body:i,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(e=>{var t,s,r=null!==(t=e.json)&&void 0!==t?t:{},n=200!==e.statusCode;if(this._requestInFlight=!1,l===this._requestGeneration){if(this._trackStatusZeroReachability(e.statusCode),n||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),!i.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!n;var a=[];e.error?a.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?Tu:"unknown_error"):200!==e.statusCode&&a.push("api_error_"+e.statusCode),r.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var c=!(null==(s=r.quotaLimited)||!s.includes("feature_flags"));c&&a.push("quota_limited"),this._set({[ge]:a}),c?this._logger.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."):i.disable_flags||this._receivedFeatureFlags(r,n,{partialResponse:o}),u()}}else u()}).catch(c)}catch(e){c(e)}}}_hasStatusZeroCircuitBreakerTripped(){return no(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=oo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}}else this._logger.warn('getFeatureFlag for key "'+e+Iu)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t;return null==(t=this.getFeatureFlagResult(e,{send_event:!1}))?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i,r=this.getFlagVariants(),n=e in r,o=r[e],a=this.getFlagPayloads()[e],l=String(o),u=this._prop("$feature_flag_request_id")||void 0,c=this._prop("$feature_flag_evaluated_at")||void 0,d=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var h,_=null==(h=this._client)?void 0:h.session.sessionId,p=this._prop(pe);_&&_!==p&&(d={},i=_)}if(t.send_event||!("send_event"in t))if(e in d&&d[e].includes(l))i&&this._set({[_e]:d,[pe]:i});else{var g,v,f,m,y,b,w,S,k,C,x,E,P;yt(d[e])?d[e].push(l):d[e]=[l],this._set(s({[_e]:d},i?{[pe]:i}:{}));var F=this.getFeatureFlagDetails(e),I=[...null!==(g=this._prop("$feature_flag_errors"))&&void 0!==g?g:[]];kt(o)&&I.push("flag_missing");var T={$feature_flag:e,$feature_flag_response:o,$feature_flag_payload:null!=a?a:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:null!==(v=null==(f=this._config.bootstrap)||null==(f=f.featureFlags)?void 0:f[e])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(m=null==(y=this._config.bootstrap)||null==(y=y.featureFlagPayloads)?void 0:y[e])&&void 0!==m?m:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};kt(null==F||null==(b=F.metadata)?void 0:b.has_experiment)||(T.$feature_flag_has_experiment=F.metadata.has_experiment),kt(null==F||null==(w=F.metadata)?void 0:w.version)||(T.$feature_flag_version=F.metadata.version);var R=null!==(S=null==F||null==(k=F.reason)?void 0:k.description)&&void 0!==S?S:null==F||null==(C=F.reason)?void 0:C.code;R&&(T.$feature_flag_reason=R),null!=F&&null!=(x=F.metadata)&&x.id&&(T.$feature_flag_id=F.metadata.id),kt(null==F?void 0:F.original_variant)&&kt(null==F?void 0:F.original_enabled)||(T.$feature_flag_original_response=kt(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(E=F.metadata)&&E.original_payload&&(T.$feature_flag_original_payload=null==F||null==(P=F.metadata)?void 0:P.original_payload),I.length&&(T.$feature_flag_error=I.join(",")),this._captureFeatureFlagCalled(T)}else i&&this._set({[_e]:d,[pe]:i});if(n)return{key:e,enabled:!!o,variant:"string"==typeof o?o:void 0,payload:Ls(a)}}}else this._logger.warn('getFeatureFlagResult for key "'+e+Iu)}_captureFeatureFlagCalled(e){try{var t;null==(t=this._client)||t.capture("$feature_flag_called",e).catch(e=>{this._logger.error("Failed to capture feature flag call",e)})}catch(e){this._logger.error("Failed to capture feature flag call",e)}}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var i=this;return n(function*(){var s=i._client;if(s){var r={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},n=i._getValidEvaluationEnvironments();n.length&&(r.evaluation_contexts=n);var o,a=i._getValidFlagKeys();kt(a)||(r.flag_keys=a);try{var l;o=(null==(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(o)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}}})()}isFeatureEnabled(e,t){if(void 0===t&&(t={}),t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+Iu),t.defaultValue;var i=this.getFeatureFlag(e,t);return kt(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this._receivedFeatureFlags(e,t,i)}_receivedFeatureFlags(e,t,i){if(this._client){this._hasLoadedFlags=!0;var r=function(e,t,i,r,n,o){void 0===t&&(t={}),void 0===i&&(i={}),void 0===r&&(r={}),void 0===o&&(o=Pu);var a=((e,t)=>{var i=e.flags;return i?s({},e,{featureFlags:Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!kt(null==(t=i[e].metadata)?void 0:t.payload)}).map(e=>{var t;return[e,null==(t=i[e].metadata)?void 0:t.payload]}))}):(e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e)})(e,o),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,h=e.evaluatedAt;if(yt(u)){o.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var _={};if(u)for(var p=0;u.length>p;p++)_[u[p]]=!0;return{[V]:u,[j]:_,[Q]:!1}}var g=u,v=c,f=l;if(null!=n&&n.partialResponse){var m=Object.keys(g),y=v||{};g=s({},t,g),v=s({},i,y),m.forEach(e=>{var t;e in y||null==(t=v)||delete t[e]}),f=s({},r,f)}else if(e.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter(e=>{var t;return!(null!=(t=l[e])&&t.failed)}));g=s({},t,Object.fromEntries(Object.entries(g).filter(e=>b.has(e[0]))));var w=Object.fromEntries(Object.entries(v||{}).filter(e=>b.has(e[0])));v=s({},i,w),b.forEach(e=>{var t;e in w||null==(t=v)||delete t[e]}),f=s({},r,Object.fromEntries(Object.entries(f||{}).filter(e=>b.has(e[0]))))}else g=s({},t,g),v=s({},i,v),f=s({},r,f);return s({[V]:Object.keys(Au(g)),[j]:g||{},[G]:v||{},[U]:f||{},[Q]:!0===e.minimalFlagCalledEvents},d?{[K]:d}:{},h?{[ve]:h}:{})}}(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(r)if(!1===(null==i?void 0:i.persist)){var n=!kt(this._client.kv.get(j));this._bootstrapState=r,n||this._set(r)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(r,e,!(null==i||!i.partialResponse)),this._set(r);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),this._logger.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([J,Y]),this._fireFeatureFlagsCallbacks(),void Fu.info("All overrides cleared");if(yt(e))return this._set({[J]:Ru(e)}),this._fireFeatureFlagsCallbacks(),void Fu.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);var s={},r=i.flags,n=i.payloads;return r&&(s[J]=yt(r)?Ru(r):r),n&&(s[Y]=n),Object.keys(s).length&&this._set(s),!1===r&&!1===n?this._remove([J,Y]):!1===r?this._remove(J):!1===n&&this._remove(Y),this._fireFeatureFlagsCallbacks(),!1===r?Fu.info("Flag overrides cleared"):r&&Fu.info("Flag overrides set",{flags:r}),void(!1===n?Fu.info("Payload overrides cleared"):n&&Fu.info("Payload overrides set",{payloads:n}))}if(e&&"object"==typeof e)return this._set({[J]:e}),this._fireFeatureFlagsCallbacks(),void Fu.info("Flag overrides set",{flags:e});this._logger.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this._logger.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,s=t.flagVariants;try{e(i,s)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var r,n=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),i&&(a.$feature_enrollment_stage=i);var l=s({},this.getFlagVariants(),{[e]:t});null==(r=this._instance)||null==(r=r.persistence)||r.markCrossTabFeatureFlagChanges({[V]:[e],[j]:[e],[X]:Object.keys(o)}),this._set({[V]:Object.keys(Au(l)),[j]:l,[X]:s({},this._prop("$stored_person_properties")||{},o)}),this._fireFeatureFlagsCallbacks();try{var u;null==(u=this._client)||u.capture("$feature_enrollment_update",a).catch(e=>{this._logger.error("Failed to capture early access feature enrollment",e)})}catch(e){this._logger.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._prop(W);!s||t?this._getEarlyAccessFeatures(e,i):e(s)}_getEarlyAccessFeatures(e,t){var i=this;return n(function*(){var s=i._client;if(s){var r,n=t?"&"+t.map(e=>"stage="+e).join("&"):"";try{var o=yield s.sendRequest("/api/early_access_features/?token="+s.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,i._set({[W]:r})}catch(e){return void i._logger.error("Early access feature request failed",e)}try{e(r)}catch(e){i._logger.error("Early access feature callback failed",e)}}})()}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,s=t.flagVariants;this.featureFlagEventHandlers.forEach(t=>{try{t(i,s,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}})}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._prop("$stored_person_properties")||{},r=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in i||(o[a]=n[a]));this._set({[X]:s({},i,o,r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=s({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[X]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){void 0===e&&(e=!0),this._remove(X),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._prop("$stored_group_properties")||{},r=s({},i);for(var n of Object.keys(e))r[n]=s({},i[n],e[n]);this._set({[Z]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop("$stored_group_properties")||{};this._set({[Z]:s({},t,{[e]:{}})})}else this._remove(Z)}reset(){this._requestGeneration++,this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0}}},Qu={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return"awaiting_config"===this._recordingStatus||"missing_config"===this._recordingStatus?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=su,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var e;if(null==Je||!Je.visibilityState||"visible"===Je.visibilityState)return!0;var t=null==Ge||null==(e=Ge.performance)||null==e.getEntriesByType?void 0:e.getEntriesByType("visibility-state");return!(null!=t&&t.length)||t.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e;"visible"===(null==Je?void 0:Je.visibilityState)&&(this._documentWasEverVisible=!0,null==(e=this._lazyLoadedSessionRecording)||null==e.setDocumentWasEverVisible||e.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw nu.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this._config.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=Je&&Je.addEventListener&&kr(Je,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose(e){var t=(void 0===e?{}:e).discardBufferedEvents,i=void 0!==t&&t;this._sessionRecordingDisposed=!0,null==Je||null==Je.removeEventListener||Je.removeEventListener("visibilitychange",this._onVisibilityChange),i?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(F))||!e.enabled),i=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return Ge&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!(this._sessionRecordingDisposed||this._isRecordingEnabled&&null!=(t=this._lazyLoadedSessionRecording)&&t.isStarted)){var i=!kt(Object.assign)&&!kt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),nu.info("starting")):(this._recordingStatus=su,this.stopRecording())}}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=ru),null!=nt&&null!=(t=nt.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=nt.__PosthogExtensions__)&&i.initSessionRecording)this._onScriptLoaded(e);else{var s,r=this._instance.sessionManager;null==(s=nt.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,t=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===r)return t?(this._instance.register_for_session({[Fe]:!0}),nu.error("could not load recorder",t)):void this._onScriptLoaded(e);this._recordingStatus=su})}}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_discardRecording(e){var t,i;void 0===e&&(e=!1),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=void 0,null==(i=this._lazyLoadedSessionRecording)||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null==(e=this._persistence)||e.unregister(D),null==(t=this._persistence)||t.unregister(T)}_validateSampleRate(e,t){if(Pt(e))return null;var i,s=Ft(e)?e:parseFloat(e);return"number"!=typeof(i=s)||!Number.isFinite(i)||0>i||i>1?(nu.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):s}_persistRemoteConfig(e){if(this._persistence){var t,i,r=this._persistence,n=()=>{var t,i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Pt(a)&&this._resetSampling();var l=null==i?void 0:i.minimumDurationMilliseconds;r.register({[F]:s({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:s({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:a,minimumDurationMilliseconds:kt(l)?null:l,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(n)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):("awaiting_config"===this._recordingStatus&&(this._recordingStatus="missing_config",nu.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):nu.warn("log called before recorder was ready")}get _scriptName(){var e;return(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.get_property("$session_recording_remote_config"))||null==(e=e.scriptConfig)?void 0:e.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t=this._instance.get_property(F);if(!t)return!1;try{e="object"==typeof t?t:JSON.parse(t)}catch(e){return nu.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!Pt(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}_onScriptLoaded(e){var t,i,s;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(null==(t=nt.__PosthogExtensions__)||!t.initSessionRecording)return nu.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Fe]:!0});var r;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(r=nt.__PosthogExtensions__)?void 0:r.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if("missing_config"===this._recordingStatus||"awaiting_config"===this._recordingStatus)return;return this._recordingStatus="awaiting_config",nu.info("persisted remote config is stale, requesting fresh config before starting"),void new Uo(this._instance).load()}this._recordingStatus=ru,null==(i=(s=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||i.call(s,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=su}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null==(e=this._persistence)||e.register({[A]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(e=this._persistence)||e.register({[R]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({["url"===e?M:L]:!0}),null==(i=this._lazyLoadedSessionRecording)||i.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e;null==(e=this._lazyLoadedSessionRecording)||null==e.flushBeforeIdentityReset||e.flushBeforeIdentityReset()}}},Ju={autocapture:class extends Wl{constructor(e){super(new Ul(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){var e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(dr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,dr.info("History API monitoring stopped")}monitorHistoryChanges(){Ge&&Ge.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(e){var t;if(Ge&&(null==(t=Ge.history[e])||!t.__posthog_wrapped__)){var i=this;Jl(Ge.history,e,t=>function(s,r,n){t.call(this,s,r,n),i._capturePageview(e)})}}_getCurrentLocation(){var e=null==Ge?void 0:Ge.location;if(null!=e&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}_getCaptureOptions(){var e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:wt(e)?e:{}}_shouldCaptureHashChanges(e){return void 0===e&&(e=this._getCaptureOptions()),!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){var t=this._getCaptureOptions(),i=this._lastLocation;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this._shouldCaptureHashChanges(t)&&e.hash!==i.hash))}_capturePageview(e){try{var t=this._getCurrentLocation();if(!t)return;this._hasLocationChanged(t)&&this._instance.capture(je,{navigation_type:e}),this._lastLocation=t}catch(t){dr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};kr(Ge,"popstate",e),this._popstateListener=()=>{Ge&&Ge.removeEventListener("popstate",e)}}}_setupHashchangeListener(){if(!this._hashchangeListener){var e=()=>{this._capturePageview("hashchange")};kr(Ge,"hashchange",e),this._hashchangeListener=()=>{Ge&&Ge.removeEventListener("hashchange",e)}}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[y]),this.rageclicks=new ql(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return wt(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Pt(this._config.capture_heatmaps)?Pt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;ou.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[y]:i}),this._enabledServerSide=i,this.startIfEnabled()}}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){au(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(Je)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){Ge&&Je&&(this._flushHandler=this._flush.bind(this),kr(Ge,ze,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==Ge?void 0:Ge.event)),kr(Je,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==Ge?void 0:Ge.event)),kr(Je,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new jn(this.instance,Nn,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),kr(Je,Ne,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;Ge&&Je&&(this._flushHandler&&Ge.removeEventListener(ze,this._flushHandler),this._onClickHandler&&Je.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&Je.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&Je.removeEventListener(Ne,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var s=e;s&&sn(s)&&!rn(s,"body");){if(s===i)return!1;var r=void 0;try{var n,o,a;r=null==(n=null!==(o=null==(a=s.ownerDocument)?void 0:a.defaultView)&&void 0!==o?o:Ge)?void 0:n.getComputedStyle(s).position}catch(e){return!1}if(lt(t,r))return!0;s=vn(s)}return!1}(hn(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:s),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var i;if(void 0===t&&(t="click"),!tn(e.target)&&au(e)){var r=this._getProperties(e,t);null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&kn(hn(e),this.instance.config.rageclick)&&this._capture(s({},r,{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!tn(e.target)&&au(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(e){if(Ge){var t=this._config.disable_capture_url_hashes?es(Ge.location.href):Ge.location.href,i=this._config.custom_personal_data_properties,s=so(t,this._config.mask_personal_data_properties?[...ao,...i||[]]:[],uo);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!St(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:jn,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",s({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>s({},e,{["$web_vitals_"+t.name+"_event"]:s({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{}))),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Pt(null==e?void 0:e.name)||Pt(null==e?void 0:e.value))Xl.error("Invalid metric received",e);else{var i="string"==typeof e.navigationURL?e.navigationURL:void 0,r=this._maskedURL(i);if(!kt(r)){var n=Ft(e.navigationId)||"string"==typeof e.navigationId?"navigation:"+e.navigationId:"url:"+r;if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),kt(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=r),this._buffer.firstMetricTimestamp=kt(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;var o=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),a=s({},e,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});if(delete a.entries,wt(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){var l={};for(var u of iu){var c="url"===u&&"string"==typeof e.attribution[u]?this._maskedURL(e.attribution[u]):e.attribution[u];kt(c)||(l[u]=c)}a.attribution=l}else delete a.attribution;kt(o)||(a.$session_id=o.sessionId,a.$window_id=o.windowId),this._buffer.metrics.push(a),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else Xl.error("Ignoring metric with value >= "+this._maxAllowedValue,e)}}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,n=!1,o=nt.__PosthogExtensions__,a=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(null==a?void 0:a[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&kt(a)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!kt(l)){var u=l.withoutAttribution,c=this.attributionMetrics;n=!kt(u),e=c.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,t=c.indexOf("CLS")>-1?l.onCLS:(null==u?void 0:u.onCLS)||l.onCLS,i=c.indexOf("FCP")>-1?l.onFCP:(null==u?void 0:u.onFCP)||l.onFCP,r=c.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(e&&t&&i&&r){var d={reportSoftNavs:this.useSoftNavs},h=n&&this.attributionMetrics.indexOf("INP")>-1?s({},d,{includeProcessedEventEntries:!1}):d;this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),d),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),d),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),d),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this),h),this._initialized=!0}else Xl.error("web vitals callbacks not loaded - not starting")}},this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[k]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=wt(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return Pt(i)?(null==(t=this._instance.persistence)?void 0:t.props.$web_vitals_allowed_metrics)||eu:i}get flushToCaptureTimeoutMs(){return(wt(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var e=wt(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return Tt(e)?e?eu:[]:yt(e)?e:tu}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var e;return null!==(e=wt(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0)&&void 0!==e&&e}get _maxAllowedValue(){var e=wt(this._perfConfig)&&Ft(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Zl;return e>0&&6e4>=e?Zl:e}get isEnabled(){var e=null==Ye?void 0:Ye.protocol;if("http:"!==e&&"https:"!==e)return Xl.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=wt(this._perfConfig)?this._perfConfig.web_vitals:Tt(this._perfConfig)?this._perfConfig:void 0;return Tt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Xl.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var i=wt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=wt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[k]:i}),this._instance.persistence.register({[P]:s})),this._enabledServerSide=i,this.startIfEnabled()}}}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t=nt.__PosthogExtensions__,i=this._callbackFlavor,s=null==t?void 0:t.postHogWebVitalsCallbacksByFlavor;null!=s&&s[i]||"web-vitals"===i&&kt(s)&&null!=t&&t.postHogWebVitalsCallbacks?e():null==t||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,i,t=>{t?Xl.error("failed to load script",t):e()})}_maskedURL(e){var t=e||(null==Ge?void 0:Ge.location.href);if(t){var i=this._instance.config.disable_capture_url_hashes?es(t):t,s=this._instance.config.custom_personal_data_properties;return so(i,this._instance.config.mask_personal_data_properties?[...ao,...s||[]]:[],uo)}Xl.error("Could not determine current URL")}}},Yu={exceptionObserver:class{constructor(e){var t;this._startCapturing=()=>{var e;if(Ge&&this.isEnabled&&null!=(e=nt.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=nt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=nt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=nt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){Gl.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[b]),this._rateLimiter=new zt(s({},function(e){var t,i,s,r;return void 0===e&&(e={}),{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(r=e.exceptionRateLimiterBucketSize)&&void 0!==r?r:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking),{refillInterval:1e4,_logger:Gl})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return wt(e)?t=s({},t,e):(kt(e)?this._remoteEnabled:e)&&(t=s({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Gl.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return Gl.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[b]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,s,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(r))return void Gl.info("Skipping exception capture because of client rate limiting.",{exception:r});null==(s=this._instance.exceptions)||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new ns([new vs,new Es,new ms,new fs,new Cs,new ks,new bs,new xs],function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],o=t.split("\n"),a=r;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=gs.test(l)?l.replace(gs,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of i){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return s({},e,{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(n)}}("web:javascript",ds,ps)),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=Rs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new As(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Rs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if(e.ok){var r=e.config;if("errorTracking"in r){var n=null!==(t=null==(i=r.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null==(s=r.errorTracking)?void 0:s.captureExtensionExceptions;this._suppressionRules=n,this._instance.persistence&&this._instance.persistence.register({[w]:this._suppressionRules,[S]:o})}}}get _captureExtensionExceptions(){var e,t,i=!!this._instance.get_property(S);return null!==(e=null!==(t=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==t?t:i)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!Ct(e)||0===e.trim().length)return void Lu.warn("Ignoring exception step because message must be a non-empty string");var i=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>Is.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t)),r=i.sanitizedProperties,n=i.droppedKeys;n.length>0&&Lu.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(s({[Ps]:e,[Fs]:(new Date).toISOString()},r))}catch(e){Lu.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Lu.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void Lu.info("Skipping exception capture because it was thrown by an extension");if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by an injected browser script"),void Lu.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Lu.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&Pt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,s="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;s&&(i.$release_id=s);try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return Mu(e)||Lu.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void(Mu(e)||Lu.error("Failed to process exception event. Ignoring this exception.",e))}var n}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:s({},e,{$exception_steps:t})}catch(t){return Lu.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Ps]:e,[Fs]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return wt(e)?s({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{var t=e.reduce((e,t)=>{var i=t.type,s=t.value;return Ct(i)&&i.length>0&&e.$exception_types.push(i),Ct(s)&&s.length>0&&e.$exception_values.push(s),e},{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{var i=e.values.map(e=>{var i=il[e.operator],s=t[e.key];if(!i||!s)return!1;var r=yt(e.value)?e.value:[e.value];return r.length>0&&i(r,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return Lu.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){var t=e.flatMap(e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(e=>{var t=e.filename;return!!t&&Ou.some(e=>t.startsWith(e))});return 0!==i.length&&(!i.every(e=>{var t=e.filename;return!!t&&t.startsWith($u)})||e.some(e=>{var t=e.value;return Ct(t)&&t.includes("isolatedAPI.contexts.topHostname")})&&!t.some(e=>{var t=e.filename;return e.in_app&&!(null!=t&&t.startsWith($u))}))}_isInjectedBrowserScriptException(e){return e.some(e=>{var t=e.value;return Ct(t)&&Du.some(e=>t.includes(e))})}_isPostHogException(e){if(e.length>0){var t,i,s,r,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[];return null!==(s=null==(r=n[n.length-1])||null==(r=r.filename)?void 0:r.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!Pt(e)&&yt(e)}}},Xu=s({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var i,s;if(this._persistence&&this._persistence.register({[x]:!!t.productTours}),!uu(this._instance))return!this._productTourManager&&Pt(null==(i=this._persistence)?void 0:i.props.ph_product_tours)||lu.info("product tours disabled; stopping and clearing cached tours"),null==(s=this._productTourManager)||s.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this._productTourManager&&uu(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",t=>{t?lu.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&null!=(e=nt.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=nt.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!yt(this._cachedTours)||t){var i=this._persistence;if(i){var s=i.props[oe];if(yt(s)&&!t)return this._cachedTours=s,void e(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:t=>{if(uu(this._instance)){var s=t.statusCode;if(200!==s||!t.json){var r="Product Tours API could not be loaded, status: "+s;return 0===s?t.error||lu.warn(r):lu.error(r),void e([],{isLoaded:!1,error:r})}var n=yt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[oe]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){Pt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)})}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._persistence)||e.unregister(oe)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},Ku),Zu={siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=nt._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var r,n,o,a,l,u,c;if(!e)throw new Error("Event payload is required");var d={},h=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var p of Object.entries(_)){var g=p[0];d[g]={id:h[g],type:g,properties:p[1]}}var v=e.$set_once,f=e.$set;return{event:s({},i(e,t),{properties:s({},e.properties,f?{$set:s({},null!==(r=null==(n=e.properties)?void 0:n.$set)&&void 0!==r?r:{},f)}:{},v?{$set_once:s({},null!==(o=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==o?o:{},v)}:{}),elements_chain:null!==(l=null==(u=e.properties)?void 0:u.$elements_chain)&&void 0!==l?l:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:d}}_prepareElementForSiteApp(e){var t,i=null==(t=e.tagName)?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(cu.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(cu.error("prepare_external_dependency_script returned null"),null):e}_patchSiteAppElementInsertionMethods(){var e,t,i,s,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==Je?void 0:Je.defaultView,u=null==l||null==(e=l.Node)?void 0:e.prototype;if(!l||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();var c=[],d=this,h=new WeakSet,_=(e,t,i)=>{if(null!=e&&e[t]){var s=e[t];e[t]=i(s),c.push(()=>{e[t]=s})}},p=e=>{if(h.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&h.add(t),t},g=e=>e.map(e=>"string"==typeof e?e:p(e)).filter(e=>!Et(e));return _(u,"appendChild",e=>function(t){var i=p(t);return i?e.call(this,i):t}),_(u,"insertBefore",e=>function(t,i){var s=p(t);return s?e.call(this,s,i):t}),_(u,"replaceChild",e=>function(t,i){var s=p(t);return s?e.call(this,s,i):i}),[null==(t=l.Element)?void 0:t.prototype,null==(i=l.Document)?void 0:i.prototype,null==(s=l.DocumentFragment)?void 0:s.prototype].forEach(e=>{_(e,"append",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))}),_(e,"prepend",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))})}),[null==(r=l.Element)?void 0:r.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach(e=>{_(e,"before",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))}),_(e,"after",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))}),_(e,"replaceWith",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];var r=g(i);return i.length&&!r.length?void 0:e.apply(this,r)})}),_(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",e=>function(t,i){var s=p(i);return s?e.call(this,t,s):null}),this._restoreSiteAppElementPatches=()=>{c.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){var e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null==(t=this._restoreSiteAppElementPatches)||t.call(this)))}}_runWithPreparedSiteAppElements(e,t){void 0===t&&(t=!0);var i=this._patchSiteAppElementInsertionMethods();try{var s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(cu.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(i=this._stopBuffering)||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,cu.info("Site app with id "+e.id+" "+(r?"loaded":"errored")),s&&i()};try{var n=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),r(e)}}),!1).processEvent;n&&(t.processEvent=n),s=!0}catch(t){cu.error(du+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){cu.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){var t=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(e),s=function(s){try{t._runWithPreparedSiteAppElements(()=>null==s.processEvent?void 0:s.processEvent(i))}catch(t){cu.error("Error while processing event "+e.event+" for site app "+s.id,t)}};for(var r of Object.values(this.apps))s(r)}}onRemoteConfig(e){var t,i,s,r=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),e.ok){var n=e.config;if(null!=(s=n.siteApps)&&s.length)if(this.isEnabled){var o=function(){var e,t=a.id,i=a.url;nt["__$$ph_site_app_"+t]=r._instance,null==(e=nt.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(r._instance,i,e=>{if(e)return cu.error(du+t,e)})};for(var a of n.siteApps)o()}else cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ec={tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{var e,t,i=this._syncHostnamesForPatch();i?(kt(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=nt.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),kt(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=nt.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return Yl.error("failed to load script",t);e()})}_getConfiguredHostnames(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){var e=this._getConfiguredHostnames();return yt(e)?(yt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(yt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},tc=s({surveys:class extends gu{constructor(e){var t;super(new wu(e),(t=e,{get projectToken(){return t.config.token},kv:new bu(t)})),this._instance=e}_sendSurveysRequest(e,t){var i=t.query?Ta(e,t.query):e;return new Promise(e=>{var s;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",i),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:e})})}}},Ku),ic={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){nt.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=nt.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),Cr(this.instance.config))return!1;if(!Ge||!Je)return!1;e=null!=e?e:Ge.location,i=null!=i?i:Ge.history;try{if(!t){try{Ge.localStorage.setItem("test","test"),Ge.localStorage.removeItem("test")}catch(e){return!1}t=null==Ge?void 0:Ge.localStorage}var s,r=Su||ro(e.hash,"__posthog")||ro(e.hash,"state"),n=r?fr(()=>JSON.parse(atob(decodeURIComponent(r))))||fr(()=>JSON.parse(decodeURIComponent(r))):null;return n&&"ph_authorize"===n.action?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(ku)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch(e){return!1}}_callLoadToolbar(e){var t=nt.ph_load_toolbar||nt.ph_load_editor;!Pt(t)&&bt(t)?t(e,this.instance):Cu.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==Je||!Je.getElementById("__POSTHOG_TOOLBAR__"));if(!Ge||t)return!1;var i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=s({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(Ge.localStorage.setItem(ku,JSON.stringify(s({},r,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=nt.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return Cu.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),kr(Ge,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},sc=s({experiments:class e{get _config(){return this._instance.config}constructor(t){var i=this;this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments(t=>{e._logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,t.forEach(t=>{if(t.feature_flag_key){var s;i._flagToExperiments&&(e._logInfo("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(s=i._flagToExperiments)||s.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);Ct(r)&&t.variants[r]&&i._applyTransforms(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var n in t.variants){var o=t.variants[n];e._matchesTestVariant(o,i._instance)&&i._applyTransforms(t.name,n,o.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e._logInfo(Bu);else if(!this._config.disable_web_experiments){if(Pt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e._logInfo("applying feature flags",t),t.forEach(e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,s=this._instance.getFeatureFlag(e),r=null==(i=this._flagToExperiments)?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this._applyTransforms(r.name,s,r.variants[s].transforms)}})}}previewWebExperiment(){var t=e.getWindowLocation();if(null!=t&&t.search){var i=io(null==t?void 0:t.search,"__experiment_id"),s=io(null==t?void 0:t.search,"__experiment_variant");i&&s&&(e._logInfo("previewing web experiments "+i+" && "+s),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(i),s,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(t,i,s){var r=s.filter(e=>e.id===t);r&&r.length>0&&(e._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this._applyTransforms(r[0].name,i,r[0].variants[i].transforms))}static _matchesTestVariant(t,i){return!Pt(t.conditions)&&e._matchUrlConditions(t,i)&&e._matchUTMConditions(t)}static _matchUrlConditions(t,i){var s;if(Pt(t.conditions)||Pt(null==(s=t.conditions)?void 0:s.url))return!0;var r=e.getWindowLocation();if(r){var n,o,a,l=en(i,r.href);return null==(n=t.conditions)||!n.url||qu[null!==(o=null==(a=t.conditions)?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return null==Ge?void 0:Ge.location}static _matchUTMConditions(e){var t;if(Pt(e.conditions)||Pt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=ho();if(i.utm_source){var s,r,n,o,a,l,u,c,d=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_campaign)==i.utm_campaign,h=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,_=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return d&&_&&p&&h}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];dr.info("[WebExperiments] "+e,i)}_applyTransforms(t,i,s){this._is_bot()?e._logInfo(Bu):"control"!==i?s.forEach(s=>{var r;s.selector&&(e._logInfo("applying transform of variant "+i+" for experiment "+t+" ",s),null==(r=document)||null==(r=r.querySelectorAll(s.selector))||r.forEach(e=>{var t=e;s.html&&(t.innerHTML=s.html),s.css&&t.setAttribute("style",s.css)}))}):e._logInfo("Control variants leave the page unmodified.")}_is_bot(){return Qe&&this._instance?Ja(Qe,this._config.custom_blocked_useragents):void 0}}},Ku),rc=s({},Ku,Qu,Ju,Yu,Xu,Zu,tc,ec,ic,sc,{conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this._remoteConfigSuccessful=e.ok,e.ok)){var t=e.config.conversations;Pt(t)||(Tt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1}loadIfEnabled(){if(!(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||Cr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==nt?void 0:nt.__PosthogExtensions__;if(e&&!kt(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError(De);i(this._instance,"conversations",t=>{t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1})}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}else Hu.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,Hu.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Hu.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Hu.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():Hu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!Et(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Cr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":kt(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?Pt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":null!=nt&&nt.__PosthogExtensions__?this._isInitializing?"initializing":this._loadFailed?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return n(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(Hu.warn(Nu),null)})()}getMessages(e,t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Hu.warn(Nu),null)})()}markAsRead(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Hu.warn(Nu),null)})()}getTickets(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Hu.warn(Nu),null)})()}requestRestoreLink(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Hu.warn(Nu),null)})()}restoreFromToken(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Hu.warn(Nu),null)})()}restoreFromUrlToken(){var e=this;return n(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Hu.warn(Nu),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},{logs:class{constructor(e){var t,i=this;this._instance=e,this.name="logs",this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=hr("[logs]"),this._coreLogger=s({},this._logger,{error(){for(var e=arguments.length,t=new Array(e),s=0;e>s;s++)t[s]=arguments[s];t.some(Gu)||i._logger.error(...t)}}),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,null==(e=this._core)||e.onReconnect(),null==(t=this._consoleCore)||t.onReconnect())},this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),Ge&&kr(Ge,"online",this._onReconnect)}_buildCore(e,t,i,s){var r,n=zu(null==(r=this._instance)||null==(r=r.config)?void 0:r.logs,i);return[new nr(this._createHost(e,t),n,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,s),n]}_getCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._core||this._resolvedFrom!==t){var i;null==(i=this._core)||i.reset(),this._resolvedFrom=t;var s=this._buildCore(()=>this._queue,e=>{this._queue=e});this._core=s[0],this._resolvedConfig=s[1]}return this._core}_getConsoleCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._consoleCore||this._consoleResolvedFrom!==t){var i;null==(i=this._consoleCore)||i.reset(),this._consoleResolvedFrom=t;var s=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Vu);this._consoleCore=s[0],this._consoleResolvedConfig=s[1]}return this._consoleCore}setup(e){var t;if(!this._disposed){this._client=e,null!=(t=this._instance)&&null!=(t=t.config)&&null!=(t=t.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._remoteConfigWillArrive()&&this._persistedCaptureHint())&&this._startConsoleRecorder();var i=!1,s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null==(t=e.config.logs)?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?s.dispose():(this._remoteConfigSubscription=s,i||this.loadIfEnabled())}}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null==(e=this._remoteConfigSubscription)||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null==Ge||Ge.removeEventListener("online",this._onReconnect),null==(t=this._consoleLogsDispose)||t.call(this),this._consoleLogsDispose=void 0,null==(i=this._core)||i.reset(),null==(s=this._consoleCore)||s.reset())}onRemoteConfig(e){var t,i;if(!this._disposed){var s=e.ok?null==(t=e.config.logs)?void 0:t.captureConsoleLogs:void 0;Pt(s)?this._stopRecorderStartedByPersistedHint():(null==(i=this._instance)||null==(i=i.persistence)||i.register({[E]:!!s}),s?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}}reset(){var e,t,i,s;this._stopConsoleRecorder(),null==(e=this._core)||e.clearQueue(),this._queue=[],null==(t=this._core)||t.reset(),null==(i=this._consoleCore)||i.clearQueue(),this._consoleQueue=[],null==(s=this._consoleCore)||s.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){this._disposed||this._getCore().captureLog(e)}captureConsoleLog(e){this._disposed||this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,i){this._disposed||this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:i})}_persistedCaptureHint(){var e;return!(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.props)||!e[E])}_remoteConfigWillArrive(){var e,t;return null==(e=this._instance)||null==e._shouldDisableFlags||!e._shouldDisableFlags()||!(null==(t=nt._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])||!t.config)}_onOptOut(){var e;this._stopConsoleRecorder(),null==(e=this._consoleCore)||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e,t=this;if(!this._isRecordingConsole&&null!=nt&&nt.console){var i=zu(null==(e=this._instance)||null==(e=e.config)?void 0:e.logs).maxBufferSize,s=function(e){var s;try{s=(e=>{for(;null!=(t=e)&&t.__rrweb_original__;){var t;e=e.__rrweb_original__}return e})(nt.console[e])}catch(e){return 0}if(!s)return 0;t._consoleRecorderUnpatchers.push(Jl(nt.console,e,r=>{var n=function(){for(var s=arguments.length,n=new Array(s),o=0;s>o;o++)n[o]=arguments[o];try{t._recordConsoleEntry(e,n,i)}catch(e){}return r.apply(nt.console,n)};return n.__rrweb_original__=s,n}))};for(var r of ju)s(r);this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}}_recordConsoleEntry(e,t,i){var s;if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&0!==t.length)if(null!=(s=this._instance)&&s.is_capturing()){if(i>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){for(var e of(this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0),this._consoleRecorderUnpatchers))e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){var e=this._consoleBuffer;return this._stopConsoleRecorder(),e}get logger(){return this._capture_logger||(this._capture_logger={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._capture_logger}flushLogs(e){e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e)))}_logFlushError(e){Gu(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(!this._disposed&&this._isLogsEnabled&&!this._isLoaded&&!this._isLoading){var e=null==nt?void 0:nt.__PosthogExtensions__;if(!e)return this._logger.error("PostHog Extensions not found."),void this._stopConsoleRecorder();var t=e.loadExternalDependency;if(!t)return this._logger.error(De),void this._stopConsoleRecorder();this._isLoading=!0;try{t(this._instance,"logs",t=>{if(this._isLoading=!1,!this._disposed&&this._isLogsEnabled){var i=e.logs;if(t||null==i||!i.initializeLogs)this._logger.error("Could not load logs script",t),this._stopConsoleRecorder();else{var s,r,n=this._takeConsoleBuffer();this._consoleLogsDispose=i.initializeLogs(null!==(s=this._client)&&void 0!==s?s:this._instance),this._isLoaded=!0,n.length>0&&(null==i.replayConsoleBuffer||i.replayConsoleBuffer(null!==(r=this._client)&&void 0!==r?r:this._instance,n))}}})}catch(e){throw this._isLoading=!1,e}}}_createHost(e,t){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===ht.LogsQueue?e():void 0,setPersistedProperty(e,i){e===ht.LogsQueue&&t(null!=i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}_sendLogsBatch(e){return new Promise(t=>{if(no(this._consecutiveStatusZeroFailures,3))t({kind:"fatal",error:Uu(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,s=e=>{i||(i=!0,clearTimeout(r),t(e))},r=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Uu(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this._logsUrl(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;if(this._trackEndpointReachability(t),t>=200&&300>t)s({kind:"ok"});else if(413===t)s({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)s({kind:"fatal",error:new Error("logs request failed with status "+t)});else{var i;0===t?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Uu(e.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}})}_trackEndpointReachability(e){(0!==e||this._instance.__loaded)&&(this._consecutiveStatusZeroFailures=oo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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.")))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,l.LIB_NAME,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,Vu,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,s,r){if(0!==t.length){var n=t.map(e=>e.record);r([]);var o=rr(n,sr(i,l.LIB_NAME,l.LIB_VERSION),s,l.LIB_VERSION);this._instance._send_request({method:"POST",url:this._logsUrl(),data:o,compression:"best-available",batchKey:"logs",transport:e})}}_logsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_getSdkContext(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),s=i.windowId,r=i.sessionStartTimestamp,n=i.lastActivityTimestamp;t.sessionId=i.sessionId,t.windowId=s,Pt(r)||(t.sessionStartTimestamp=r),Pt(n)||(t.lastActivityTimestamp=n)}if(null!=nt&&null!=(e=nt.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?es(nt.location.href):nt.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},{metrics:class{constructor(e){this._instance=e,this._logger=hr("[metrics]")}initialize(){}_getCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.metrics;return this._core&&this._resolvedFrom===i||(null==(t=this._core)||t.reset(),this._resolvedFrom=i,this._core=new ur(this._createHost(),function(e){var t,i,s,r,n,o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(r=null==e?void 0:e.flushIntervalMs)&&void 0!==r?r:1e4,maxSeriesPerFlush:null!==(n=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this._logger)),this._core}count(e,t,i){void 0===t&&(t=1),this._getCore().count(e,t,i)}gauge(e,t,i){this._getCore().gauge(e,t,i)}histogram(e,t,i){this._getCore().histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){var t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error("PostHog metrics flush failed:",e))}reset(){var e;null==(e=this._core)||e.reset()}_createHost(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{var r=!1,n=e=>{r||(r=!0,clearTimeout(o),i(e))},o=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(s({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t,i=e.statusCode;n(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(t=e.error)&&void 0!==t?t:new Error("metrics request failed with status "+i)})}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});Bl.__defaultExtensionClasses=s({},rc),function(){l.SDK_DIST_CHANNEL="cdn";var e=nt.posthog;if(!e||yt(e._i)){var t=wl[Rl]=new Bl;if(e){var i=[];pr(e._i,function(s){if(s&&yt(s)){var r=t.init(s[0],s[1],s[2]),n=e[s[2]]||e;r.__loaded&&-1===i.indexOf(n)&&(i.push(n),r._execute_array.call(r.people,n.people),r._execute_array(n))}})}t.__SV=1,nt.posthog=t,function(){function e(){e.done||(e.done=!0,Al=!1,pr(wl,function(e){e._dom_loaded()}))}null!=Je&&Je.addEventListener?"complete"===Je.readyState?e():kr(Je,"DOMContentLoaded",e,{capture:!1}):Ge&&dr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}}()}()}();
|
|
1
|
+
!function(){var e=["retriesPerformedSoFar"],t=["$set_once","$set"];function i(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},s.apply(null,arguments)}function r(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function n(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var o=e.apply(t,i);function a(e){r(o,s,n,a,l,"next",e)}function l(e){r(o,s,n,a,l,"throw",e)}a(void 0)})}}!function(r){var o="0.8.2",a={DEBUG:(!1,!1),LIB_VERSION:(o,"1.428.3"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:o},l=a,u="$people_distinct_id",c="distinct_id",d="$device_id",h="$device_model",_="__alias",p="__cmpns",g="$fbc",v="$fbc_persistence",f="__timers",m="$autocapture_disabled_server_side",y="$heatmaps_enabled_server_side",b="$exception_capture_enabled_server_side",w="$error_tracking_suppression_rules",S="$error_tracking_capture_extension_exceptions",k="$web_vitals_enabled_server_side",C="$dead_clicks_enabled_server_side",x="$product_tours_enabled_server_side",E="$logs_capture_enabled_server_side",P="$web_vitals_allowed_metrics",F="$session_recording_remote_config",I="$session_recording_enabled_server_side",T="$replay_sample_rate",R="$replay_override_sampling",A="$replay_override_linked_flag",M="$replay_override_url_trigger",L="$replay_override_event_trigger",O="$sesid",D="$session_is_sampled",B="$session_past_minimum_duration",q="$session_recording_url_trigger_activated_session",H="$session_recording_event_trigger_activated_session",N="$debug_first_full_snapshot_timestamp",z="$sess_rec_flush_size",j="$enabled_feature_flags",V="$active_feature_flags",W="$early_access_features",U="$feature_flag_details",G="$feature_flag_payloads",K="$feature_flag_request_id",Q="$minimal_flag_called_events",J="$override_feature_flags",Y="$override_feature_flag_payloads",X="$stored_person_properties",Z="$stored_group_properties",ee="$groups",te="$surveys",ie="$surveys_loaded_at",se="$surveys_activated",re="$surveys_activated_session",ne="$surveys_activated_timestamps",oe="ph_product_tours",ae="$product_tours_activated",le="$product_tours_activated_session",ue="$conversations_widget_session_id",ce="$conversations_ticket_id",de="$conversations_widget_state",he="$conversations_user_traits",_e="$flag_call_reported",pe="$flag_call_reported_session_id",ge="$feature_flag_errors",ve="$feature_flag_evaluated_at",fe="$user_state",me="$client_session_props",ye="$capture_rate_limit",be="$initial_campaign_params",we="$initial_referrer_info",Se="$initial_person_info",ke="$epp",Ce="$posthog_cookieless",xe="$cookieless_mode",Ee="$sdk_debug_extensions_init_method",Pe="$sdk_debug_extensions_init_time_ms",Fe="$sdk_debug_recording_script_not_loaded",Ie="$sdk_debug_replay_event_trigger_status",Te="$sdk_debug_replay_linked_flag_trigger_status",Re="$sdk_debug_replay_matched_recording_trigger_groups",Ae="$sdk_debug_replay_pending_trigger_conditions",Me="$sdk_debug_replay_remote_trigger_matching_config",Le="$sdk_debug_replay_trigger_groups_count",$e="$sdk_debug_replay_url_trigger_status",Oe="$session_recording_start_reason",De="PostHog loadExternalDependency extension not found.",Be="anonymous",qe="identified",He="identified_only",Ne="visibilitychange",ze="beforeunload",je="$pageview",Ve="$pageleave",We="$identify",Ue="$groupidentify",Ge="u">typeof window?window:void 0,Ke="u">typeof globalThis?globalThis:Ge,Qe=null==Ke?void 0:Ke.navigator,Je=null==Ke?void 0:Ke.document,Ye=null==Ke?void 0:Ke.location,Xe=null==Ke?void 0:Ke.fetch,Ze=null!=Ke&&Ke.XMLHttpRequest&&"withCredentials"in new Ke.XMLHttpRequest?Ke.XMLHttpRequest:void 0,et=null==Ke?void 0:Ke.AbortController,tt=null==Ke?void 0:Ke.CompressionStream,it=null==Qe?void 0:Qe.userAgent;function st(){return!(!Ge||!1===Ge.navigator.onLine)}var rt="undefined"!=typeof globalThis?globalThis:Ge;rt&&"undefined"==typeof self&&(rt.self=rt),rt&&"undefined"==typeof File&&(rt.File=function(){});var nt=null!=Ge?Ge:{},ot=["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"],at=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return ot.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})};function lt(e,t){return-1!==e.indexOf(t)}var ut=function(e){return e.trim()},ct=function(e){return e.replace(/^\$/,"")};function dt(e){var t,i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}var ht=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),_t=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),pt=["$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"],gt=["token"],vt=Object.prototype,ft=vt.hasOwnProperty,mt=vt.toString,yt=Array.isArray||function(e){return"[object Array]"===mt.call(e)},bt=e=>"function"==typeof e,wt=e=>e===Object(e)&&!yt(e),St=e=>{if(wt(e)){for(var t in e)if(ft.call(e,t))return!1;return!0}return!1},kt=e=>void 0===e,Ct=e=>"[object String]"==mt.call(e),xt=e=>Ct(e)&&0===e.trim().length,Et=e=>null===e,Pt=e=>kt(e)||Et(e),Ft=e=>"[object Number]"==mt.call(e)&&e==e,It=e=>Ft(e)&&e>0,Tt=e=>"[object Boolean]"===mt.call(e),Rt=e=>lt(pt,e),At=e=>lt(gt,e);function Mt(e){return null===e||"object"!=typeof e}function Lt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function $t(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Dt(e,Error)}}function Ot(e){return"u">typeof Event&&Dt(e,Event)}function Dt(e,t){try{return e instanceof t}catch(e){return!1}}var Bt=[!0,"true",1,"1","yes"],qt=e=>lt(Bt,e),Ht=[!1,"false",0,"0","no"];function Nt(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),Ft(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Nt(null!=r?r:i,t,i,s))}var zt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Nt(e.bucketSize,0,100,e._logger),this._refillRate=Nt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Nt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):this._buckets[s]=r={tokens:this._bucketSize,lastAccess:i},0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}},jt="Mobile",Vt="Android",Wt="Tablet",Ut="Android Tablet",Gt="iPad",Kt="Apple Watch",Qt="Safari",Jt="BlackBerry",Yt="Samsung Internet",Xt="Chrome",Zt="Chrome iOS",ei="Internet Explorer",ti="Internet Explorer Mobile",ii="Opera",si="Microsoft Edge",ri="Firefox",ni="Firefox iOS",oi="Nintendo",ai="PlayStation",li="Xbox",ui="Android Mobile",ci="Mobile Safari",di="Windows",hi="Windows Phone",_i="Nokia",pi="Ouya",gi="Generic "+jt.toLowerCase(),vi="Generic "+Wt.toLowerCase(),fi="Konqueror",mi="Oculus Browser",yi="Vivaldi",bi="Yandex",wi="Whale",Si="DuckDuckGo",ki="Pale Moon",Ci="Waterfox",xi="Brave",Ei="Claude",Pi="Codex",Fi="ChatGPT",Ii="Google Search App",Ti=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ri=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ai=new RegExp(li,"i"),Mi=new RegExp("PlayStation \\w+","i"),Li=new RegExp("Nintendo \\w+","i"),$i=new RegExp("BlackBerry|PlayBook|BB10","i"),Oi={"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"},Di=function(e,t,i,s){t=t||"";var r=function(e){return null!=e&&e.brave?xi:null}(i);return r||(null!=s&&s.detectGoogleSearchApp&<(e,"GSA/")?Ii:lt(e," OPR/")&<(e,"Mini")?"Opera Mini":lt(e," OPR/")?ii:$i.test(e)?Jt:lt(e,"IEMobile")||lt(e,"WPDesktop")?ti:lt(e,"OculusBrowser")?mi:lt(e,"SamsungBrowser")?Yt:lt(e,"Edge")||lt(e,"Edg/")?si:lt(e,"Vivaldi/")?yi:lt(e,"YaBrowser/")?bi:lt(e,"Whale/")?wi:lt(e,"DuckDuckGo/")||lt(e,"Ddg/")?Si:lt(e,"Claude/")?Ei:lt(e,"Codex/")?Pi:lt(e,"ChatGPT/")?Fi:lt(e,"FBIOS")?"Facebook Mobile":lt(e,"UCWEB")||lt(e,"UCBrowser")?"UC Browser":lt(e,"CriOS")?Zt:lt(e,"CrMo")||lt(e,Xt)?Xt:lt(e,Vt)&<(e,Qt)?ui:lt(e,"FxiOS")?ni:lt(e.toLowerCase(),fi.toLowerCase())?fi:lt(e,"Brave/")?xi:((e,t)=>t&<(t,"Apple")||function(e){return lt(e,Qt)&&!lt(e,Xt)&&!lt(e,Vt)}(e))(e,t)?lt(e,jt)?ci:Qt:lt(e,"PaleMoon/")?ki:lt(e,"Waterfox/")?Ci:lt(e,ri)?ri:lt(e,"MSIE")||lt(e,"Trident/")?ei:lt(e,"Gecko")?ri:"")},Bi={[ti]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[si]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Xt]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Zt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Qt]:[Ti],[ci]:[Ti],[ii]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[ri]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ni]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[fi]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Jt]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ti],[ui]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Yt]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[mi]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[yi]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[bi]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[wi]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[xi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Ei]:[Ri],[Pi]:[Ri],[Fi]:[Ri],[Si]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[ki]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Ii]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ei]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},qi=function(e,t,i,s){var r=Bi[Di(e,t,i,s)];if(kt(r))return null;for(var n=0;r.length>n;n++){var o=e.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},Hi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[li,e&&e[1]||""]],[new RegExp(oi,"i"),[oi,""]],[new RegExp(ai,"i"),[ai,""]],[$i,[Jt,""]],[new RegExp(di,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[hi,""];if(new RegExp(jt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=Oi[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[di,s]}return[di,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=kt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Vt,[e[2],e[3],e[4]||"0"].join(".")]:[Vt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Ni=function(e){for(var t=0;Hi.length>t;t++){var i=Hi[t],s=i[1],r=i[0].exec(e),n=r&&(bt(s)?s(r,e):s);if(n)return n}return["",""]},zi=function(e){return Li.test(e)?oi:Mi.test(e)?ai:Ai.test(e)?li:new RegExp(pi,"i").test(e)?pi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?hi:/iPad/.test(e)?Gt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Kt:$i.test(e)?Jt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(_i,"i").test(e)?_i:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(jt).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Vt:Ut:new RegExp("(pda|Mobile)","i").test(e)?gi:new RegExp(Wt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?vi:""},ji=/\bFBAV\/(\d+(?:\.\d+)*)/i,Vi=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ji],[/\bFBAN\/EMA\b/i,"Facebook Lite",ji],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ji],[/\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"]],Wi="[Truncated]",Ui="[Unserializable]";function Gi(e){for(var t="",i=0;e.length>i;i++){var s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"�";else{var r=e.charCodeAt(i+1);56320>r||r>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}Date,Date;var Ki,Qi,Ji,Yi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Xi(e,t){return"string"==typeof(i=e)&&Yi.test(i)?e:t();var i}function Zi(e,t){var i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function es(e){return e?e.split("#")[0]:e}function ts(e,t){var i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function is(e,t,i){return ss.apply(this,arguments)}function ss(){return(ss=n(function*(e,t,i){var s;try{return yield Promise.race([e,new Promise((e,r)=>{s=ts(()=>{try{null==i||i(),e()}catch(e){r(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function rs(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Ji&&i.length===Qi?Ji:(Qi=i.length,Ji=i.reduce((i,s)=>{Ki||(Ki={});var r=Ki[s];if(r)i[r[0]]=r[1];else for(var n=e(s),o=n.length-1;o>=0;o--){var a,l=null==(a=n[o])?void 0:a.filename,u=t[s];if(l&&u){i[l]=u,Ki[s]=[l,u];break}}return i},{}))}}var ns=class{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(t),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var t=this;return n(function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&yt(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),s({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return n(function*(){var i=e;for(var s of t.modifiers)i=yield s(i);return i})()}convertToExceptionList(e,t){var i,r,n,o={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,s({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:rs(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i){void 0===i&&(i=0);var r=(i,s)=>{if(4>=s){var r=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,r)}};return s({},t,{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,i),next:e=>r(e,i+1)})}};function os(e,t,i,s,r){var n={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:!!t&&!t.startsWith("webkit-masked-url://")&&"<anonymous>"!==t};return kt(s)||(n.lineno=s),kt(r)||(n.colno=r),n}var as=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ls=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,us=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,cs=/\((\S*)(?::(\d+))(?::(\d+))\)/,ds=(e,t)=>{var i=ls.exec(e);if(i)return os(t,i[1],"?",+i[2],+i[3]);var s=us.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){var r=cs.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var n=as(s[1]||"?",s[2]);return os(t,n[1],n[0],s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},hs=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,_s=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ps=(e,t)=>{var i=hs.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=_s.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||"?",o=as(n,r);return os(t,r=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},gs=/\(error: (.*)\)/;var vs=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=Ct(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Lt(e,"DOMException")}isDOMError(e){return Lt(e,"DOMError")}},fs=class{match(e){return $t(e)}coerce(e,t){var i,s=this.getStack(e),r=void 0===s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:null==(i=t.syntheticException)?void 0:i.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},ms=class{match(e){return!!Lt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);var r=t.apply(e.message);return s({},r,{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:r.stack,synthetic:!0})}_hasUsableMessage(e){return Ct(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i,s=e,r=null!==(t=s.lineno)&&void 0!==t?t:0,n=null!==(i=s.colno)&&void 0!==i?i:0;if(Ct(s.filename)&&0!==s.filename.length&&0!==r)return"Error\n at "+s.filename+":"+r+":"+n}},ys=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,bs=class{match(e){return"string"==typeof e}coerce(e,t){var i,s=this.getInfos(e),r=s[0],n=s[1];return{type:null!=r?r:"Error",value:null!=n?n:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(ys);return s&&(t=s[1],i=s[2]),[t,i]}},ws=["fatal","error","warning","log","info","debug"];function Ss(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(t>=r.length)return s===i.length?r:r.length>t?r.slice(0,t)+"...":r}return""}var ks=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null==(s=t.syntheticException)?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ot(e))return e.constructor.name;var t="name"in e?e.name:void 0;return Ct(t)&&!xt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+Ss(e)}isSeverityLevel(e){return Ct(e)&&!xt(e)&&ws.indexOf(e)>=0}getStack(e){try{return Ct(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Ct(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if($t(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},Cs=class{match(e){return Ot(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+Ss(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}},xs=class{match(e){return Mt(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}},Es=class{match(e){return Lt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ot(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Mt(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}},Ps="$message",Fs="$timestamp",Is=new Set([Ps,Fs]),Ts={enabled:!0,max_bytes:32768};function Rs(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Ts.enabled,max_bytes:Ms(e.max_bytes,Ts.max_bytes)}:s({},Ts)}var As=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=Rs(e)}setConfig(e){this._config=Rs(e),this._trimToMaxBytes()}add(e){var t=function(e){var t;try{t=dt(e)}catch(e){return}try{var i=JSON.parse(t);if(!wt(i))return;var s=i,r=s[Ps],n=s[Fs];if(!Ct(r)||0===r.trim().length)return;if(!Ct(n)&&!Ft(n))return;return{step:s,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,s=0;t.length>s;s++)"%"===t[s]?(i+=1,s+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map(e=>e.step)}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function Ms(e,t){if(!Ft(e)||1/0===e||-1/0===e)return t;var i=Math.floor(e);return 0>i?t:i}var Ls=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function $s(e){return"string"==typeof e||e}function Os(e){return"string"==typeof e?e:void 0}var Ds,Bs=["$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"],qs="NativeGzipValidationError",Hs=e=>e.length>=2&&31===e[0]&&139===e[1],Ns=(e,t)=>e===_t.GZipJS||t===_t.GZipJS||"gzip"===t,zs=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),js=e=>{throw Zi(qs,"Native gzip produced invalid output: "+e)},Vs=function(){var e=n(function*(e,t){18>e.size&&js("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Hs(i)&&8===i[2]||js("invalid-header");var s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Ds)return Ds;Ds=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Ds[e]=t>>>0}return Ds})(),i=4294967295,s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&js("invalid-crc");var r=t.length>>>0;s.getUint32(4,!0)!==r&&js("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function Ws(){return Ws=n(function*(e,t,i){void 0===t&&(t=!0);try{var s=(new TextEncoder).encode(e),r=new globalThis.CompressionStream("gzip"),o=r.writable.getWriter(),a=o.write(s).then(()=>o.close()).catch(function(){var e=n(function*(e){try{yield o.abort(e)}catch(e){}throw e});return function(t){return e.apply(this,arguments)}}()),l=new Response(r.readable).blob(),u=(yield Promise.all([l,a]))[0];return yield Vs(u,s),u}catch(e){if(null!=i&&i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}}),Ws.apply(this,arguments)}var Us={}.propertyIsEnumerable;function Gs(e,t){try{return Js(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Ks(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:Wi};if(i.remainingNodes--,Tt(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){var i=e.toString(),s=BigInt("9223372036854775808");return e>=s||-s>e?(null==t||t.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};var r=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:Gi(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:Wi};if(e instanceof Date){var n=e.getTime(),o=Number.isFinite(n)?e.toISOString():String(e);return{stringValue:"string"==typeof o?Gi(o):String(o)}}i.ancestors.add(e);try{try{var a=e.toJSON;if("function"==typeof a)return Ks(a.call(e),t,i,s+1)}catch(e){}return yt(e)?{arrayValue:{values:Qs(e,t,i,s+1)}}:{kvlistValue:{values:Js(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:Gi(String(e))}}function Qs(e,t,i,s){for(var r=[],n=Math.min(e.length,1e3),o=0;n>o&&i.remainingNodes>0;o++)try{var a=o in e?e[o]:void 0;if(Pt(a))continue;r.push(Ks(a,t,i,s))}catch(e){r.push({stringValue:Ui})}return e.length>o&&r.push({stringValue:Wi}),r}function Js(e,t,i,s){var r=[];for(var n in e)if(Us.call(e,n)){if(!n){null==t||t.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=e[n];if(Et(o)||kt(o))continue;r.push({key:Gi(n),value:Ks(o,t,i,s)})}catch(e){r.push({key:Gi(n),value:{stringValue:Ui}})}}return r}function Ys(e,t,i){return s({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":i})}var Xs={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var Zs={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}},er=Zs.info;function tr(e){try{return Gi(String(e))}catch(e){return Ui}}function ir(e,t,i,r){var n,o=Zs[e.level||"info"]||er,a=o.text,l=o.number,u=(void 0===(n=Ft(r)?r:void 0)&&(n=Date.now()),String(n)+"000000"),c={};t.distinctId&&(c.posthogDistinctId=t.distinctId),t.sessionId&&(c.sessionId=t.sessionId),t.windowId&&(c["window.id"]=t.windowId),Pt(t.sessionStartTimestamp)||(c.sessionStartTimestamp=String(t.sessionStartTimestamp)),Pt(t.lastActivityTimestamp)||(c.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(c["url.full"]=t.currentUrl),t.screenName&&(c["screen.name"]=t.screenName),t.appState&&(c["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(c.feature_flags=t.activeFeatureFlags);var d=s({},c),h=e.attributes;if(h){var _=[];try{_=Object.keys(h)}catch(e){_=[]}for(var p of _){var g=void 0;try{g=h[p]}catch(e){g=Ui}Object.defineProperty(d,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var v={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:a,body:{stringValue:tr(e.body)},attributes:Gs(d,i)};return e.trace_id&&(v.traceId=e.trace_id),e.span_id&&(v.spanId=e.span_id),kt(e.trace_flags)||(v.flags=e.trace_flags),v}function sr(e,t,i){return Ys(e,t,i)}function rr(e,t,i,s){return{resourceLogs:[{resource:{attributes:Gs(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var nr=class{constructor(e,t,i,s,r,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=e,this._config=t,this._logger=i,this._getContext=s,this._onReady=r,this._waitForStoragePersist=n,this._scopeName=o,this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._consecutiveFlushFailures=0,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(ht.LogsQueue,[])}reset(){this._clearFlushTimer(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushInBackground()}captureLog(e,t){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=e&&e.body){var s=this._runBeforeSend(e);if(null!==s)if(s.body){if(this._checkRateLimit()){var r={record:ir(s,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this._getContext(),this._logger,null==t?void 0:t.occurredAtMs)};this._onReady(()=>this._enqueue(r))}}else this._logger.info("Log was rejected in beforeSend function")}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=yt(t)?t:[t],s=e;for(var r of i)try{var n=r(s);if(!n)return this._logger.info("Log was rejected in beforeSend function"),null;s=n}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return s}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;var e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||(this._logger.warn("captureLog dropping logs: exceeded "+this._maxLogsPerInterval+" logs per "+this._rateCapWindowMs+"ms"),this._droppedWarned=!0),!1)}flush(){var e=this;return n(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return n(function*(){var t;e._clearFlushTimer();var i=null!==(t=e._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==t?t:[];if(0!==i.length)for(var s=i.length,r=0;i.length>0&&s>r;){var n,o,a=e._queueGeneration;e._evictedSinceAdvance=0;var l=Math.min(i.length,e._maxBatchRecordsPerPost),u=i.slice(0,l),c=rr(u.map(e=>e.record),e._buildResourceAttributes(),null!==(n=e._scopeName)&&void 0!==n?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),d=yield e._instance._sendLogsBatch(c);if(e._queueGeneration!==a)return;if("too-large"===d.kind&&u.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(u.length/2)),e._logger.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+e._maxBatchRecordsPerPost);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?e._logger.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(u.length),i=null!==(o=e._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==o?o:[],r+=u.length,"fatal"===d.kind)throw d.error}}})()}_persistQueueAdvance(e){var t=this;return n(function*(){var i,s=Math.max(0,e-t._evictedSinceAdvance),r=null!==(i=t._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(ht.LogsQueue,r.slice(s)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return sr(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(ht.LogsQueue))&&void 0!==t?t:[];this._maxQueueSize>i.length||(i.shift(),this._evictedSinceAdvance++,this._logger.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(ht.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=ts(()=>{this._flushTimer=void 0,this._flushInBackground()},e))}_nextFlushDelay(){var e=Math.min(Math.max(0,this._consecutiveFlushFailures-1),6);return this._flushIntervalMs*Math.pow(2,e)}_hasQueuedRecords(){var e=this._instance.getPersistedProperty(ht.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return n(function*(){t._clearFlushTimer();var i=t.flush().catch(()=>{});void 0!==e?yield is(i,e):yield i})()}flushWithTimeout(e){var t=this;return n(function*(){var i=t.flush();yield is(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0},e=>{this._consecutiveFlushFailures++,this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._armFlushTimer(this._nextFlushDelay())})}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}},or=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ar(e){return String(e)+"000000"}function lr(e,t,i,s){var r="";return s&&(r=Object.keys(s).sort().map(e=>JSON.stringify(e)+":"+JSON.stringify(s[e])).join(",")),e+"\0"+t+"\0"+(null!=i?i:"")+"\0"+r}var ur=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._generation=0}count(e,t,i){void 0===t&&(t=1),this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var e=this,t=this._flushPromise,i=function(){var i=n(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this._flushPromise===i&&(this._flushPromise=null)});return this._flushPromise=i,i}drainWindow(){if(0===this._series.size)return null;var e=this._series;return this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._buildPayload(e)}reset(){this._generation++,this._clearFlushTimer(),this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set}_capture(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this._runBeforeSend(e);if(null!==t)if(t.name&&"string"==typeof t.name)if("number"==typeof t.value&&Number.isFinite(t.value))if("count"===t.type&&0>t.value)this._logger.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=t.attributes?s({},t.attributes):void 0,r=lr(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn("Dropping metric '"+t.name+"': attributes could not be serialized",e)}var n=this._series.get(r);if(!n){if(!this._admitNewSeries())return;n={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this._series.set(r,n)}var o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn("Metric name '"+t.name+"' is already used as a "+o+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this._fold(n,t.value),this._armFlushTimer()}else this._logger.warn("Dropping metric '"+t.name+"': value must be a finite number");else this._logger.warn("Dropping metric with empty name")}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn("Metric series cap reached ("+this._config.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}_fold(e,t){var i;switch(e.type){case"count":e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(or.length+1).fill(0)});var s=e.hist;s.count+=1,s.sum+=t,s.min=Math.min(s.min,t),s.max=Math.max(s.max,t),s.bucketCounts[function(e,t){for(var i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,or)]+=1}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=yt(t)?t:[t],s=e;for(var r of i)try{var n=r(s);if(!n)return this._logger.info("Metric was rejected in beforeSend function"),null;s=n}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return s}_armFlushTimer(){this._flushTimer||(this._flushTimer=ts(()=>{this._flushTimer=void 0,this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})},this._config.flushIntervalMs))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_doFlush(){var e=this;return n(function*(){if(0!==e._series.size){var t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;var i=e._generation,s=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(s.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._armFlushTimer();case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",s.error)}}})()}_buildPayload(e){return t=this._buildMetrics(e),i=function(e,t,i){return Ys(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Gs(i)},scopeMetrics:[{scope:{name:s,version:r},metrics:t}]}]};var t,i,s,r}_buildMetrics(e){var t=ar(Date.now()),i=new Map;for(var r of e.values()){var n,o=lr(r.type,r.name,r.unit,void 0),a=i.get(o);a||(a=s({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(o,a));var l=Gs(null!==(n=r.attributes)&&void 0!==n?n:{},this._logger),u=ar(r.windowStartMs);if("count"===r.type){var c,d={attributes:l,startTimeUnixNano:u,timeUnixNano:t,asDouble:null!==(c=r.total)&&void 0!==c?c:0};a.sum.dataPoints.push(d)}else if("gauge"===r.type){var h,_={attributes:l,timeUnixNano:t,asDouble:null!==(h=r.last)&&void 0!==h?h:0};a.gauge.dataPoints.push(_)}else r.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:or})}return Array.from(i.values())}_mergeWindowBack(e){var t,i;for(var s of e){var r=s[0],n=s[1],o=this._series.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(t=o.total)&&void 0!==t?t:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this._admitNewSeries()&&this._series.set(r,n)}}},cr=function(e,t){var i=(void 0===t?{}:t).debugEnabled,s={_log(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),n=1;s>n;n++)r[n-1]=arguments[n];Ge&&(a.DEBUG||Ge.POSTHOG_DEBUG||i)&&!kt(Ge.console)&&Ge.console&&("__rrweb_original__"in Ge.console[t]?Ge.console[t].__rrweb_original__:Ge.console[t])(e,...r)},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning(e){s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>cr(e+" "+t,i)};return s},dr=cr("[PostHog.js]"),hr=dr.createLogger;function _r(e,t){yt(e)&&e.forEach(t)}function pr(e,t){if(!Pt(e))if(yt(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(var i in e)ft.call(e,i)&&t(e[i],i)}var gr=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)void 0!==r[n]&&(e[n]=r[n]);return e};function vr(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var fr=function(e){try{return e()}catch(e){return}},mr=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){dr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),dr.critical(e)}}},yr=function(e){var t={};return pr(e,function(e,i){(Ct(e)&&e.length>0||Ft(e))&&(t[i]=e)}),t};function br(e){var t=s({},e);for(var i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}var wr=["herokuapp.com","vercel.app","netlify.app"];function Sr(e){var t=null==e?void 0:e.hostname;if(!Ct(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of wr)if(i===s)return!1;return!0}function kr(e,t,i,s){var r=null!=s?s:{},n=r.capture,o=r.passive;null==e||e.addEventListener(t,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function Cr(e){return"ph_toolbar_internal"===e.name}var xr=e=>{if(Je){try{for(var t=e+"=",i=Je.cookie.split(";").filter(e=>e.length),s=0;i.length>s;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ft(e)&&isFinite(e)&&Math.floor(e)===e});var Er=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>t||0>i||0>s||0>r||t>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|i>>>8,n[7]=i,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new e(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},Pr=class{generate(){var e=this.generateOrAbort();if(!kt(e))return e;this._timestamp=0;var t=this.generateOrAbort();if(kt(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e,t=(e=Date.now(),Ft(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0);if(t>this._timestamp)this._timestamp=t,this._resetCounter();else{if(this._timestamp>=t+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Er.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new Tr}},Fr=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ge&&!kt(Ge.crypto)&&crypto.getRandomValues&&(Fr=e=>crypto.getRandomValues(e));var Ir,Tr=class{nextUint32(){return this._buffer.length>this._cursor||(Fr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}},Rr=()=>Ar().toString(),Ar=()=>(Ir||(Ir=new Pr)).generate(),Mr="",Lr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var $r=null,Or={_is_supported(){if(!Et($r))return $r;if($r=!1,Je)try{var e="__ph_cookie_support_"+Rr();Or._set(e,"xyz"),$r='"xyz"'===xr(e),Or._remove(e)}catch(e){$r=!1}return $r},_error(e){dr.error("cookieStore error: "+e)},_get:xr,_parse(e){var t;try{t=JSON.parse(Or._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(!Je)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=Je),Mr)return Mr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+Rr();!Mr&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",Mr=n)}return Mr}(e);if(!i){var s=(e=>{var t=e.match(Lr);return t?t[0]:""})(e);s!==i&&dr.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(Je.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&dr.warn("cookieStore warning: large cookie, len="+u.length),Je.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=Je&&Je.cookie)try{Or._set(e,"",-1,t)}catch(e){return}}},Dr=null,Br={_is_supported(){if(!Et(Dr))return Dr;var e=!0;if(kt(Ge))e=!1;else try{var t="__mplssupport__";Br._set(t,"xyz"),'"xyz"'!==Br._get(t)&&(e=!1),Br._remove(t)}catch(t){e=!1}return e||dr.error("localStorage unsupported; falling back to cookie store"),Dr=e,e},_error(e){dr.error("localStorage error: "+e)},_get(e){try{return null==Ge?void 0:Ge.localStorage.getItem(e)}catch(e){Br._error(e)}return null},_parse(e){try{return JSON.parse(Br._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==Ge||Ge.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Br._error(e)}return!1},_remove(e){try{null==Ge||Ge.localStorage.removeItem(e)}catch(e){Br._error(e)}}},qr=[X,V,j,U,G,K,ve,ge,_e],Hr=[d,c,O,D,ke,Se,v,fe],Nr=e=>e+"_cpm",zr=["__proto__","constructor","prototype"],jr=e=>{if(!wt(e))return{};var t={};return Object.keys(e).forEach(i=>{-1===zr.indexOf(i)&&(t[i]=e[i])}),t},Vr=function(e,t){void 0===t&&(t=[]);var i={};return[...Hr,...t].forEach(t=>{var s=e[t];kt(s)||Et(s)||""===s||(i[t]=s)}),i},Wr=e=>{for(var t=5381,i=2166136261,s=0;e.length>s;s++){var r=e.charCodeAt(s);t=33*t^r,i=Math.imul(i^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Ur=(e,t)=>({p:t,f:Wr(JSON.stringify(e))}),Gr=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var i=Or._parse(Nr(e)),s=(null==i?void 0:i.f)===Wr(t)&&yt(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Kr=(e,t)=>t+"|"+(Or._get(Nr(e))||""),Qr={},Jr={_is_supported:()=>!0,_error(e){dr.error("memoryStorage error: "+e)},_get:e=>e in Qr?Qr[e]:null,_parse:e=>e in Qr?Qr[e]:null,_set:(e,t)=>(Qr[e]=t,!0),_remove(e){delete Qr[e]}},Yr=null,Xr={_is_supported(){if(!Et(Yr))return Yr;if(Yr=!0,kt(Ge))Yr=!1;else try{var e="__support__";Xr._set(e,"xyz"),'"xyz"'!==Xr._get(e)&&(Yr=!1),Xr._remove(e)}catch(e){Yr=!1}return Yr},_error(e){dr.error("sessionStorage error: ",e)},_get(e){try{return null==Ge?void 0:Ge.sessionStorage.getItem(e)}catch(e){Xr._error(e)}return null},_parse(e){try{return JSON.parse(Xr._get(e))||null}catch(e){}return null},_set(e,t){try{return null==Ge||Ge.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Xr._error(e)}return!1},_remove(e){try{null==Ge||Ge.sessionStorage.removeItem(e)}catch(e){Xr._error(e)}}},Zr=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get _storedConsent(){var e=this._storage._get(this._storageKey);return qt(e)?1:lt(Ht,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Br:Or,i=t._is_supported()?t:Jr;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;var s="localStorage"===e?Or:Br;s._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(qt(s._get(this._storageKey))),s._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==Qe?void 0:Qe.doNotTrack,null==Qe?void 0:Qe.msDoNotTrack,nt.doNotTrack,null==Qe?void 0:Qe.globalPrivacyControl].some(e=>qt(e))}};function en(e,t){var i,s=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!bt(s))return t;try{var r=s(t);return Ct(r)&&r?r:t}catch(e){return dr.error("Error in get_current_url, falling back to window.location.href",e),t}}function tn(e){return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function sn(e){return!!e&&1===e.nodeType}function rn(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function nn(e){return!!e&&3===e.nodeType}function on(e){return!!e&&11===e.nodeType&&sn(e.host)}function an(e){return e?ut(e).split(/\s+/):[]}function ln(e,t){var i=function(e){var t,i=null==Ge||null==(t=Ge.location)?void 0:t.href;return kt(i)?void 0:en(e,i)}(t);return!!(i&&e&&e.some(e=>i.match(e)))}function un(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return an(t)}function cn(e){return Pt(e)?null:ut(e).split(/(\s+)/).filter(e=>$n(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function dn(e){var t="";return En(e)&&!Pn(e)&&e.childNodes&&e.childNodes.length&&pr(e.childNodes,function(e){var i;nn(e)&&e.textContent&&(t+=null!==(i=cn(e.textContent))&&void 0!==i?i:"")}),ut(t)}function hn(e){var t;return kt(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var _n=["a","button","form","input","select","textarea","label"];function pn(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function gn(e,t){if(kt(t))return!0;var i,s=function(e){if(t.some(t=>pn(e,t)))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function vn(e){var t=e.parentNode;return!(!t||!sn(t))&&t}var fn=[".ph-no-autocapture","[data-ph-no-autocapture]"],mn=["next","previous","prev",">","<"],yn=[...mn,"+","-","−","–"],bn=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,wn=[".ph-no-rageclick",".ph-no-capture"],Sn=["","text","search","email","password","url","tel","number"];function kn(e,t){if(!Ge||Cn(e))return!1;var i,s,r,n,o;if(Tt(t)?(i=!!t&&wn,s=void 0,r=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:wn,s=null==t?void 0:t.content_ignorelist,r=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(r&&function(e){return!(!e||!sn(e))&&(!!rn(e,"textarea")||(rn(e,"input")?lt(Sn,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var a=xn(e,!1).targetElementList;return!function(e,t){if(!1===e||kt(e))return!1;var i;if(!0===e)i=mn;else{if(!yt(e))return!1;if(e.length>10)return dr.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(e=>{var t=e.safeText,s=e.ariaLabel;return i.some(e=>bn(t,e)||bn(s,e))})}(s,a.map(e=>{var t;return{safeText:dn(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}}))&&!gn(a,i)}var Cn=e=>!e||rn(e,"html")||!sn(e),xn=(e,t)=>{if(!Ge||Cn(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],r=e;r.parentNode&&!rn(r,"body");)if(on(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=vn(r);if(!n)break;if(t||_n.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=Ge.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}catch(e){}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};function En(e){for(var t=new Set,i=0,s=e;s.parentNode&&!rn(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);var r=un(s);if(lt(r,"ph-sensitive")||lt(r,"ph-no-capture"))return!1}if(lt(un(e),"ph-include"))return!0;var n=e.type||"";if(Ct(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!Ct(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function Pn(e){return!!(rn(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||rn(e,"select")||rn(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Fn=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}))$"),In=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Tn=[16,15,14,13],Rn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),An=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Mn=/[0-9A-Za-z_]/;function Ln(e){for(var t=0,i=!1,s=e.length-1;s>=0;s--){var r=e.charCodeAt(s)-48;i&&(r*=2)>9&&(r-=9),t+=r,i=!i}return t%10==0}function $n(e,t){if(void 0===t&&(t=!0),Pt(e))return!1;if(Ct(e)){if(e=ut(e),t?Fn.test((e||"").replace(/[- ]/g,"")):function(e){var t;for(In.lastIndex=0;t=In.exec(e);){var i=t[2];if(i)for(var s=i.replace(/[- ]/g,""),r=0;s.length>r;r++)for(var n of Tn){var o=r+n;if(s.length>=o){var a=s.slice(r,o);if(Fn.test(a)&&Ln(a))return!0}}}return!1}(e))return!1;if(t?Rn.test(e):function(e){var t;for(An.lastIndex=0;t=An.exec(e);){var i=t[1],s=t[3];if(!(i&&s&&Mn.test(i)&&Mn.test(s)))return!0}return!1}(e))return!1}return!0}function On(e){var t=dn(e);return $n(t=(t+" "+Dn(e)).trim())?t:""}function Dn(e){var t="";return e&&e.childNodes&&e.childNodes.length&&pr(e.childNodes,function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=dn(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Dn(e)).trim())}catch(e){dr.error("[AutoCapture]",e)}}),t}function Bn(e){return e.replace(/"|\\"/g,'\\"')}function qn(e){var t=e.attr__class;if(t)return yt(t)?t:an(t)}var Hn=hr("[Dead Clicks]"),Nn=()=>!0,zn=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(C)),s=e.instance.config.capture_dead_clicks;return Tt(s)?s:!!wt(s)||i},jn=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[C]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Hn.error("failed to load script",t):e()})}_start(){var e;if(Je){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=nt.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=wt(this.instance.config.capture_dead_clicks)?s({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=nt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(Je),Hn.info("starting...")}}else Hn.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Hn.info("stopping..."))}},Vn=hr("[SegmentIntegration]");function Wn(e,t,i){void 0===i&&(i=!0);var s=e.config.segment;if(!s)return t();!function(e,t,i){var s=e.config.segment;if(!s)return t();var r=s=>{var r=()=>s.anonymousId()||Rr();e.config.get_device_id=r,i&&s.id()&&(e.register({distinct_id:s.id(),$device_id:r()}),e.persistence.set_property(fe,qe)),t(i?void 0:s.anonymousId()||void 0)},n=s.user();"then"in n&&bt(n.then)?n.then(r):r(n)}(e,i=>{s.register(((e,t)=>{"undefined"!=typeof Promise&&Promise.resolve||Vn.warn("This browser does not have Promise support, and can not use the segment integration");var i=(i,s)=>{if(!s)return i;var r=!!t&&i.event.anonymousId===t&&!i.event.userId;r||i.event.userId||i.event.anonymousId===e.get_distinct_id()||(Vn.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),i.event.userId&&i.event.userId!==e.get_distinct_id()&&(Vn.info("UserId set, identifying with PostHog"),e.identify(i.event.userId));var n=e.calculateEventProperties(s,i.event.properties);return i.event.properties=Object.assign({},n,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return i(e,e.event.event)},page(e){return i(e,je)},identify(e){return i(e,We)},screen(e){return i(e,"$screen")}}})(e,i)).then(()=>{t()},e=>{Vn.error("Failed to register the Segment integration",e),t()})},i)}var Un="posthog-js";function Gn(e,t){var i=void 0===t?{}:t,r=i.organization,n=i.projectId,o=i.prefix,a=i.severityAllowList,l=void 0===a?["error"]:a,u=i.sendExceptionsToPostHog,c=void 0===u||u;return t=>{var i,a,u,d,h,_;if("*"!==l&&!l.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var p=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=p,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var g=(null==(i=t.exception)?void 0:i.values)||[],v=g.map(e=>s({},e,{stacktrace:e.stacktrace?s({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>s({},e,{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null==(a=g[0])?void 0:a.value)||t.message,$exception_type:null==(u=g[0])?void 0:u.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(h=g[0])?void 0:h.type,$sentry_tags:t.tags};return r&&n&&(f.$sentry_url=(o||"https://sentry.io/organizations/")+r+"/issues/?project="+n+"&query="+t.event_id),c&&(null==(_=e.exceptions)||_.sendExceptionEvent(f)),t}}var Kn=class{constructor(e,t,i,s,r,n){this.name=Un,this.setupOnce=function(o){o(Gn(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}},Qn=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(dr.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==Ge?void 0:Ge.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,u=r.lastContentY,c=r.maxContentY;if(!(kt(n)||kt(o)||kt(a)||kt(l)||kt(u)||kt(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?Nt(o/n,0,1,dr):1,h=n>1?Nt(a/n,0,1,dr):1,_=l>1?Nt(u/l,0,1,dr):1,p=l>1?Nt(c/l,0,1,dr):1;s=gr(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},Jn=["flags","surveys"],Yn={[u]:{exposure:"hidden"},[_]:{exposure:"hidden"},[p]:{exposure:"hidden"},[f]:{exposure:"hidden"},[v]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},[E]:{exposure:"hidden"},[b]:{exposure:"event"},[w]:{exposure:"hidden"},[S]:{exposure:"event"},[k]:{exposure:"event"},[C]:{exposure:"event"},[x]:{exposure:"hidden"},[P]:{exposure:"event"},[F]:{exposure:"hidden"},[I]:{exposure:"hidden"},[O]:{exposure:"hidden"},[D]:{exposure:"event"},[T]:{exposure:"event",shouldSkipFromEventProperties:e=>Et(e)},[B]:{exposure:"event"},[q]:{exposure:"event"},[H]:{exposure:"event"},[N]:{exposure:"event"},[z]:{exposure:"hidden"},[j]:{exposure:"hidden",storageGroup:"flags"},[V]:{exposure:"hidden",storageGroup:"flags"},[W]:{exposure:"hidden"},[U]:{exposure:"hidden",storageGroup:"flags"},[G]:{exposure:"hidden",storageGroup:"flags"},[K]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Q]:{exposure:"hidden",storageGroup:"flags"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[te]:{exposure:"hidden",storageGroup:"surveys"},[ie]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[se]:{exposure:"event"},[re]:{exposure:"hidden"},[ne]:{exposure:"hidden"},[oe]:{exposure:"hidden"},[ae]:{exposure:"hidden"},[le]:{exposure:"hidden"},[ue]:{exposure:"event"},[ce]:{exposure:"event"},[de]:{exposure:"event"},[he]:{exposure:"event"},[_e]:{exposure:"hidden"},[pe]:{exposure:"hidden"},[ee]:{exposure:"event"},[ge]:{exposure:"hidden"},[ve]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[fe]:{exposure:"hidden"},[me]:{exposure:"hidden"},[ye]:{exposure:"hidden"},[be]:{exposure:"hidden"},[we]:{exposure:"hidden"},[Se]:{exposure:"hidden"},[ke]:{exposure:"hidden"},[R]:{exposure:"event"},[A]:{exposure:"event"},[M]:{exposure:"event"},[L]:{exposure:"event"},[Ee]:{exposure:"event"},[Pe]:{exposure:"event"},[Fe]:{exposure:"event"},[Ie]:{exposure:"event"},[Te]:{exposure:"event"},[Re]:{exposure:"event"},[Ae]:{exposure:"event"},[Me]:{exposure:"event"},[Le]:{exposure:"event"},[$e]:{exposure:"event"},[Oe]:{exposure:"event"}},Xn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Zn=e=>{var t=Yn[e];if(t)return t;for(var i of Xn){var s=i[1];if(0===e.indexOf(i[0]))return s}},eo=(e,t)=>{try{var i;return JSON.stringify(e,(e,t)=>$t(t)?(null!=i||(i=new WeakMap),i.has(t)||i.set(t,br(t)),i.get(t)):"bigint"==typeof t?t.toString():t,t)}catch(t){return dt(e)}},to=e=>{var t=null==Je?void 0:Je.createElement("a");return kt(t)?null:(t.href=e,t)},io=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!yt(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){dr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},so=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");yt(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var h=a;return null!=o&&(h+="?"+u.join("&")),null!=r&&(h+="#"+r),h},ro=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},no=(e,t)=>e>=t&&st(),oo=(e,t,i,s)=>{if(0===e){if(st()){var r=t+1;return r===i&&s(),r}return t}return 0},ao=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],lo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...ao],uo="<masked>",co=["li_fat_id"];function ho(e,t,i){if(!Je)return{};var s,r=t?[...ao,...i||[]]:[],n=_o(so(Je.URL,r,uo),e);return gr((s={},pr(co,function(e){var t=xr(e);s[e]=t||null}),s),n)}function _o(e,t){var i=lo.concat(t||[]),s={};return pr(i,function(t){var i=io(e,t);s[t]=i||null}),s}function po(e){var t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!Et(t)){s.$search_engine=t;var r=Je?io(Je.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function go(){return navigator.language||navigator.userLanguage}var vo="$direct";function fo(){return(null==Je?void 0:Je.referrer)||vo}function mo(e,t,i){var s;void 0===i&&(i=!1);var r=e?[...ao,...t||[]]:[],n=null==(s=i?es(null==Ye?void 0:Ye.href):null==Ye?void 0:Ye.href)?void 0:s.substring(0,1e3);return{r:fo().substring(0,1e3),u:n?so(n,r,uo):void 0}}function yo(e,t){var i;void 0===t&&(t=!1);var s=e.r,r=e.u,n=t?es(r):r,o={$referrer:s,$referring_domain:null==s?void 0:s==vo?vo:null==(i=to(s))?void 0:i.host};if(n){o.$current_url=n;var a=to(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname,gr(o,_o(n))}return s&&gr(o,po(s)),o}function bo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function wo(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var So={flags:ve,surveys:ie},ko=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Co=e=>e+"_cookie_identity_change_pending",xo=e=>{var t="",i=0;for(var s of e){var r=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+r>1e3)break;t+=s,i+=r}return t},Eo="main",Po=[j,V,U,G,K,ve,Q,X],Fo=e=>-1!==Po.indexOf(e),Io=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},To=e=>{if(!e)return{};var t=JSON.parse(e);return wt(t)?t:{}},Ro=(e,t)=>{pr(e,(i,s)=>{var r=Zn(s);r&&"event"!==r.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})},Ao=class{constructor(e,t,i){if(void 0===i&&(i=!0),this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._facebookClickIdChangePending=!1,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=i,this.props={},this._campaign_params_url=void 0,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&dr.info("Persistence loaded",e.persistence,s({},this.props)),this.update_config(e,e,t),this.save(),Ge){var r=()=>this.flush();kr(Ge,"beforeunload",r,{capture:!1}),kr(Ge,"pagehide",r,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===(null==Ge?void 0:Ge.localStorage))&&e.key)if(e.key!==this._name){if(this._splitStorage){var t=Jn.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,Eo)},kr(Ge,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(e=>{var t=e[0],i=e[1],s=this._pendingCrossTabFeatureFlagChanges.get(t);if(Fo(t)&&!0!==s)if(!0!==i){var r=new Set(s||[]);i.forEach(e=>r.add(e)),r.size&&this._setCrossTabFeatureFlagChangesPending(t,r)}else this._setCrossTabFeatureFlagChangesPending(t,!0)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&Ge&&(Ge.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i){if(void 0===i&&(i=!0),this._disabled)return!1;var s,r;try{if(r=Br._get(e),Et(r)){var n=this._slotWriteState(t);return n.storageValue=null,t!==Eo&&(n.persisted=!1),!1}s=To(r)}catch(e){return!1}var o=t===Eo?s:Br._parse(this._name);if(o&&this._hasCrossTabFeatureFlagIdentityMismatch(o))return!1;var a=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===Eo&&this._splitStorage&&!Io(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,r),a}_hasCrossTabFeatureFlagIdentityMismatch(e){var t=this.props[c],i=e[c];return!kt(t)&&!kt(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){var r=this._slotWriteState(t);r.storageValue=s,t!==Eo&&(r.persisted=i);try{r.fingerprint=this._entryFingerprint(e,t)}catch(e){r.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){var s=!1;return Po.forEach(i=>{var r,n=null==(r=Zn(i))?void 0:r.storageGroup;if(!(t===Eo&&this._splitStorage&&n||t!==Eo&&n!==t)){var o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&Io(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),s=!0)}}),s&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),s}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;var e,t=Br._get(this._name),i=this._slotWriteState(Eo),s=!1,r=!1;if(t!==i.storageValue)if(Et(t))i.storageValue=null;else{if(e=To(t),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(e),this._crossTabFeatureFlagIdentityMismatch)return!1;r=this._mergeCrossTabFeatureFlagProperties(e,Eo,!1),!this._splitStorage||Io(this._partitionProps().main,e)?this._rememberCrossTabStorageFingerprint(e,Eo,!0,t):i.storageValue=t,s=!0}return this._splitStorage&&Jn.forEach(t=>{var i=Br._get(this._groupEntryName(t)),n=this._slotWriteState(t),o=e||{},a=s&&Po.some(e=>{var i;return(null==(i=Zn(e))?void 0:i.storageGroup)===t&&e in o});if(i!==n.storageValue||a){if(Et(i))return n.storageValue=null,n.persisted=!1,void(a&&(r=this._mergeCrossTabFeatureFlagProperties(o,t,!1)||r));var l=To(i);r=this._mergeCrossTabFeatureFlagProperties(l,t,!1)||r,this._rememberCrossTabStorageFingerprint(l,t,!0,i)}}),r}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);var i=Zn(e);null!=i&&i.volatile||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||Eo).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){Po.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{var e=Br._get(this._name),t=To(e);this._slotWriteState(Eo).storageValue=e,Po.forEach(e=>{var i,s=this._splitStorage?null==(i=Zn(e))?void 0:i.storageGroup:void 0,r=s?Br._get(this._groupEntryName(s)):null;if(s){var n=this._slotWriteState(s);n.storageValue=r,n.persisted=!Et(r)}var o=s&&!Et(r)?To(r):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,o[e],this.props[e]):e in o&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){var i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){var r=new Set(yt(t)?t:[]),n=new Set(yt(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?r.add(e):r.delete(e)),Array.from(r)}var o=wt(t)?s({},t):{},a=wt(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in a?o[e]=a[e]:delete o[e]}),o}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(Fo(e)){var s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0!==s){var r=t;if(this._splitStorageEligible)try{var n,o=this._splitStorage?null==(n=Zn(e))?void 0:n.storageGroup:void 0,a=o?this._groupEntryName(o):this._name;r=To(Br._get(a))[e]}catch(e){}var l=new Set(s||[]);if("$active_feature_flags"===e){if(!kt(t)&&!yt(t)||!kt(r)&&!yt(r)||!yt(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var u=new Set(t||[]),c=new Set(r||[]),d=new Set(i);new Set([...u,...d]).forEach(e=>{u.has(e)!==d.has(e)&&l.add(e)}),l.forEach(e=>{c.has(e)===d.has(e)&&l.delete(e)})}else{if(!wt(i))return void(Io(r,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));if(!kt(t)&&!wt(t)||kt(t)&&St(i)&&kt(r))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var h=wt(t)?t:{},_=wt(r)?r:{};new Set([...Object.keys(h),...Object.keys(i)]).forEach(e=>{e in h==e in i&&Io(h[e],i[e])||l.add(e)}),l.forEach(e=>{e in _==e in i&&Io(_[e],i[e])&&l.delete(e)})}l.size?this._setCrossTabFeatureFlagChangesPending(e,l):this._pendingCrossTabFeatureFlagChanges.delete(e)}}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return Ft(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{var t=Vr(e,this._config.cookie_persisted_properties||[]),i=Ur(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),r=Or._get(this._name)||void 0;r&&Kr(this._name,r)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=r)}catch(e){}else try{var n=Or._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=n?Kr(this._name,n):void 0,this._lastSeenMainCookieValue=n}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t){if(void 0===t&&(t=!1),this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;var i;try{i=Or._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;var s,r=Kr(this._name,i);try{s=jr(JSON.parse(i))}catch(e){return!1}if((Or._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=r,this._lastSeenMainCookieValue=i;var n=Gr(this._name,i),o=[...Hr,...n.properties],a={};if(Object.keys(s).forEach(e=>{var t=s[e];(kt(t)||Et(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete s[e])}),St(s))return!1;var l="distinct_id"in s||"anonymous"===s.$user_state||"identified"===s.$user_state,u=this.props,d=u[c],h=u[fe],p=gr({},u);[...Hr,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in s)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){var t=p[e];(n.isValid||-1===Hr.indexOf(e)||!1!==t&&0!==t)&&delete p[e]}}),this.props=gr(p,s),Po.forEach(e=>{var t=e in this.props;e in u===t&&Io(u[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,u[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this._setProp(fe,Be);var g=this.props[c],v=this.props[fe];return!l||g===d&&v===h||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Xr._set(Co(this._name),!0),this._deleteProp(X),this._deleteProp(V),this._deleteProp(j),this._deleteProp(U),this._deleteProp(G),this._deleteProp(K),this._deleteProp(ve),this._deleteProp(ge),this._deleteProp(_e),"anonymous"!==v||"identified"!==h&&"anonymous"!==s.$user_state&&(kt(d)||g===d)||(Ro(this.props,s),this._deleteProp(Z)),"identified"===v?this.props.$user_id=g:delete this.props.$user_id,this._deleteProp(_)),!0}consumeCookieIdentityChange(){var e=Co(this._name),t=this._cookieIdentityChangePending||!!Xr._get(e);return this._cookieIdentityChangePending=!1,t&&Xr._remove(e),t}_beginCookieSyncSuppression(e){return void 0===e&&(e=!1),!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Eo],this._writeNow(!0))}_endCookieSyncSuppression(e){if(void 0===e&&(e=!0),this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){-1===ko.indexOf(e.persistence.toLowerCase())&&(dr.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,i=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var i=[...Hr,...e];return s({},Br,{_parse(e){try{var s,r={};try{s=Or._get(e)||void 0,r=s?jr(JSON.parse(s)):{}}catch(e){}var n,o=JSON.parse(Br._get(e)||"{}");if(t){var a=Gr(e,s),l=[...Hr,...a.properties],u={};Object.keys(r).forEach(e=>{var t=r[e];Et(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(u[e]=t)});var d="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var h,_=o[c],p=null!==(h=o.$user_state)&&void 0!==h?h:"anonymous";i.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(d||"distinct_id"!==e&&"$user_state"!==e)){var t=o[e];(a.isValid||-1===Hr.indexOf(e)||!1!==t&&0!==t)&&delete o[e]}}),!d||"$user_state"in r||"$user_state"in o||(o[fe]=Be),!d||("distinct_id"in u?u[c]:o[c])===_&&("$user_state"in u?u[fe]:o[fe])===p||(qr.forEach(e=>delete o[e]),"identified"===u.$user_state&&"distinct_id"in u?o.$user_id=u[c]:delete o.$user_id,"identified"!==u.$user_state&&(delete o[ee],delete o[Z]),delete o.__alias)}n=gr(o,u)}else n=gr(r,o);return Br._set(e,n),n}catch(e){}return null},_set(i,s,r,n,o,a){var l=Br._set(i,s,void 0,void 0,a);try{var u=Vr(s,e);if(Object.keys(u).length){if(t){var c=Nr(i),d=Ur(u,e);if(Or._set(c,d,r,n,o,a),Or._get(c)!==JSON.stringify(d)){Or._remove(c,n);var h=Vr(s);return Or._set(i,h,r,n,o,a),l}}Or._set(i,u,r,n,o,a)}}catch(e){Br._error(e)}return l},_remove(e,t){try{null==Ge||Ge.localStorage.removeItem(e),Or._remove(e,t),Or._remove(Nr(e),t)}catch(e){Br._error(e)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),r=!1,n=!1,o=e.persistence.toLowerCase();return"localstorage"===o&&Br._is_supported()?(t=Br,n=!0):"localstorage+cookie"===o&&i._is_supported()?(t=i,n=!0,r=!0):"sessionstorage"===o&&Xr._is_supported()?t=Xr:"memory"===o?t=Jr:"cookie"===o&&Or._is_supported()?(t=Or,r=!0):i._is_supported()?(t=i,n=!0,r=!0):Or._is_supported()?(t=Or,r=!0):t=Jr,this._splitStorageEligible=n,this._storesIdentityInCookie=r,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){var e={};return pr(this.props,(t,i)=>{var s=Zn(i);if(!s||"event"===s.exposure){if(null!=s&&null!=s.shouldSkipFromEventProperties&&s.shouldSkipFromEventProperties(t))return;e[i]=t}}),e}load(e){if(void 0===e&&(e=!1),!this._disabled||e){var t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?Br._parse(this._name):null,s={};if(t)try{pr(s=jr(Or._parse(this._name)),(e,t)=>{(kt(e)||Et(e)||""===e)&&delete s[t]})}catch(e){}var r=this._storage._parse(this._name);if(r&&(this.props=gr({},r)),this._splitStorage&&this._loadGroupEntries(),t&&r){var n,o,a=null==i?void 0:i[c],l=null!==(n=null==i?void 0:i.$user_state)&&void 0!==n?n:"anonymous",u=r[c],d=null!==(o=r.$user_state)&&void 0!==o?o:"anonymous";if(u!==a||d!==l){this._cookieIdentityChangePending=!0,Xr._set(Co(this._name),!0);var h=gr({},this.props);qr.forEach(e=>delete h[e]),"anonymous"!==d||"identified"!==l&&"anonymous"!==s.$user_state&&(kt(a)||u===a)||(Ro(h,s),delete h[Z]),this.props=h;var _=new Set;qr.forEach(e=>{var t,i=null==(t=Zn(e))?void 0:t.storageGroup;i&&_.add(i)}),_.forEach(e=>{var t={};pr(this.props,(i,s)=>{var r;(null==(r=Zn(s))?void 0:r.storageGroup)===e&&(t[s]=i)}),St(t)?(Br._remove(this._groupEntryName(e)),this._slotState[e]={}):Br._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Xr._get(Co(this._name))&&(this._cookieIdentityChangePending=!0)}}_loadGroupEntries(){for(var e of Jn){var t=Br._parse(this._groupEntryName(e));if(t&&!St(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||gr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null==(i=Zn(t))?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){var i=So[e];if(!i)return!1;var s=t[i],r=this.props[i];return Ft(s)&&Ft(r)&&r>s}refreshKey(e){var t;if(!(this._disabled||"$fbc_persistence"===e&&this._facebookClickIdChangePending)){var i=this._splitStorage?null==(t=Zn(e))?void 0:t.storageGroup:void 0,s=i?Br._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){var r=this._storage._parse(this._name);if(r&&e in r)return void this._setProp(e,r[e],!1)}this._deleteProp(e,!1)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?kt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}}flush(){kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e){if(void 0===e&&(e=!1),!(this._disabled||this._cookieSyncSuppressed&&!e)){e||(this.syncCookieProperties(),this._facebookClickIdChangePending||this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||this.refreshKey(v));var t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);var i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)this._config.debug&&dr.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));var s=this._writeEntry(this._storage,this._name,this.props,Eo);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._facebookClickIdChangePending=!1),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}}}_writeNowSplit(){var e=this,t=this._partitionProps(),i=t.main,s=t.groups,r=this._writeEntry(this._storage,this._name,i,Eo);"written"===r&&this._rememberCurrentCookieProperties(i),"failed"!==r&&(this._localIdentityChangePending=!1,this._facebookClickIdChangePending=!1,Po.forEach(e=>{var t;null!=(t=Zn(e))&&t.storageGroup||this._pendingCrossTabFeatureFlagChanges.delete(e)}));var n=function(t){var i,r=s[t];if(St(r)&&(null==(i=e._slotState[t])||!i.persisted))return Po.forEach(i=>{var s;(null==(s=Zn(i))?void 0:s.storageGroup)===t&&e._pendingCrossTabFeatureFlagChanges.delete(i)}),1;var n=e._writeEntry(Br,e._groupEntryName(t),r,t);"failed"!==n&&Po.forEach(i=>{var s=Zn(i);(null==s?void 0:s.storageGroup)!==t||"written"!==n&&s.volatile||e._pendingCrossTabFeatureFlagChanges.delete(i)})};for(var o of Jn)if(n(o))continue}_partitionProps(){var e={},t={flags:{},surveys:{}};return pr(this.props,(i,s)=>{var r,n=null==(r=Zn(s))?void 0:r.storageGroup;n?t[n][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===Eo)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return pr(e,(e,t)=>{var s;i[t]=null!=(s=Zn(t))&&s.volatile?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){var r,n=this._slotWriteState(s);if(s!==Eo&&!n.dirty&&!kt(n.fingerprint))return"skipped";try{if((r=this._entryFingerprint(i,s))===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(n.dirty=!1,s!==Eo&&(n.persisted=!0),kt(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=Br._get(t)),"written"):(this._config.debug&&dr.warn('failed to persist storage entry "'+t+'"; will retry on next save'),"failed")}remove(e){var t=(void 0===e?{}:e).keepGroupEntries,i=void 0!==t&&t;if(this._markAllCrossTabFeatureFlagChangesPending(),kt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!i&&this._ownsSplitStorage)for(var s of Jn)Br._remove(this._groupEntryName(s));i?delete this._slotState[Eo]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(wt(e)){this.syncCookieProperties(),kt(t)&&(t="None"),this._expire_days=kt(i)?this._default_expiry:i;var s=!1;if(pr(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(wt(e)){this.syncCookieProperties(),this._expire_days=kt(t)?this._default_expiry:t;var i=!1;if(pr(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||wt(t)||yt(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t="string"==typeof e?[e]:e,i=!1;for(var s of t)s in this.props&&(this._deleteProp(s),i=!0);i&&this.save()}update_campaign_params(){var e=null==Je?void 0:Je.URL;if(e!==this._campaign_params_url){var t=ho(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!St(yr(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}}update_search_keyword(){var e;this.register((e=null==Je?void 0:Je.referrer)?po(e):{})}update_referrer_info(){var e;this.register_once({$referrer:fo(),$referring_domain:null!=Je&&Je.referrer&&(null==(e=to(Je.referrer))?void 0:e.host)||vo},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var e=mo(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Se]:this._storesIdentityInCookie?{r:xo(e.r),u:e.u?xo(e.u):void 0}:e},void 0)}}get_initial_props(){var e={};pr([we,be],t=>{var i=this.props[t];i&&pr(i,function(t,i){e["$initial_"+ct(i)]=t})});var t=this.props[Se];return t&&gr(e,function(e,t){void 0===t&&(t=!1);var i=yo(e,t),s={};return pr(i,function(e,t){s["$initial_"+ct(t)]=e}),s}(t,this._config.disable_capture_url_hashes)),e}safe_merge(e){return pr(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){var r=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),o=r||n,a=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,l=e.disable_persistence||!!i,u=!!this._disabled&&!l;l||this._syncCookieProperties(t,u),this._config=e,!l&&(r||n||a)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(s({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),u));var c=o||a?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();var d=this._resolveSplitStorage(e),h=o||d!==this._splitStorage,_=!l&&(h||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(u);this._storageMigrationInProgress=h;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),h){var p=this.props;this.clear(),this._storage=c,this._splitStorage=d,this.props=p,this.save()}else a&&(this._storage=c,l||(delete this._slotState[Eo],this._writeNow()))}finally{this._storageMigrationInProgress=!1,_&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){var e=this.props[Se];if(this._storesIdentityInCookie&&wt(e)&&"string"==typeof e.r){var t=xo(e.r),i="string"==typeof e.u?xo(e.u):e.u;t===e.r&&i===e.u||this._setProp(Se,s({},e,{r:t,u:i}))}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props.__timers||{};i[e]=t,this._setProp(f,i),this.save()}remove_event_timer(e){var t=this.props.__timers||{},i=t[e];return kt(i)||(delete t[e],this._setProp(f,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i){var s;void 0===i&&(i=!0);var r=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||r===t||(this._localIdentityChangePending=!0),"$fbc_persistence"!==e||Io(r,t)||(this._facebookClickIdChangePending=!0),this._markPendingCrossTabFeatureFlagChanges(e,r,t),null!=(s=Zn(e))&&s.volatile||this._markGroupDirty(e))}_deleteProp(e,t){void 0===t&&(t=!0),delete this.props[e],t&&(Fo(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),"$fbc_persistence"===e&&(this._facebookClickIdChangePending=!0),this._markGroupDirty(e))}_markGroupDirty(e){var t,i=null==(t=Zn(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}},Mo="gzip-js",Lo="base64",$o="events",Oo="cancelEvents",Do="survey shown",Bo="survey dismissed",qo="survey sent",Ho="$survey_last_seen_date",No="popover";function zo(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&bt(i.then)&&i.then(void 0,()=>{})}}}}var jo=hr("[RateLimiter]"),Vo=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{jo.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void jo.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var u=(Ft(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this._captureWarning(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(s=this.instance.persistence)||s.set_property(ye,a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){var t=this.instance.config.property_denylist;return!yt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&null!=Ye&&Ye.pathname)return""+(null!==(e=Ye.origin)&&void 0!==e?e:"")+Ye.pathname}_captureWarning(e){var t,i,s=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null==(t=(i=this.instance).get_session_id)?void 0:t.call(i):void 0,a=[e+" event(s) dropped since the last warning",n?"triggered on "+n: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: "+a+". Config is set to "+r+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}},Wo=hr("[RemoteConfig]"),Uo=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=nt._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:e})}load(){try{if(this.remoteConfig)return Wo.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Wo.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return Wo.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){Wo.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||Wo.warn("Failed to fetch remote config from PostHog."):Wo.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){Wo.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(e){Wo.error("Error loading feature flags",e)}}},Go=Uint8Array,Ko=Uint16Array,Qo=Uint32Array,Jo=new Go([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]),Yo=new Go([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]),Xo=new Go([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zo=function(e,t){for(var i=new Ko(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new Qo(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},ea=Zo(Jo,2),ta=ea[1];ea[0][28]=258,ta[258]=28;for(var ia=Zo(Yo,0)[1],sa=new Ko(32768),ra=0;32768>ra;++ra){var na=(43690&ra)>>>1|(21845&ra)<<1;sa[ra]=((65280&(na=(61680&(na=(52428&na)>>>2|(13107&na)<<2))>>>4|(3855&na)<<4))>>>8|(255&na)<<8)>>>1}var oa=function(e,t,i){for(var s=e.length,r=0,n=new Ko(t);s>r;++r)++n[e[r]-1];var o,a=new Ko(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Ko(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,h=d|(1<<c)-1;h>=d;++d)o[sa[d]>>>l]=u}else for(o=new Ko(s),r=0;s>r;++r)o[r]=sa[a[e[r]-1]++]>>>15-e[r];return o},aa=new Go(288);for(ra=0;144>ra;++ra)aa[ra]=8;for(ra=144;256>ra;++ra)aa[ra]=9;for(ra=256;280>ra;++ra)aa[ra]=7;for(ra=280;288>ra;++ra)aa[ra]=8;var la=new Go(32);for(ra=0;32>ra;++ra)la[ra]=5;var ua=oa(aa,9,0),ca=oa(la,5,0),da=function(e){return(e/8|0)+(7&e&&1)},ha=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Ko?Ko:e instanceof Qo?Qo:Go)(i-t);return s.set(e.subarray(t,i)),s},_a=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},pa=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},ga=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Go(0),0];if(1==r){var o=new Go(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(s=1;r>s;++s)n[s].s>h&&(h=n[s].s);var _=new Ko(h+1),p=va(i[c-1],_,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});r>s;++s){var m=n[s].s;if(t>=_[m])break;g+=f-(1<<p-_[m]),_[m]=t}for(g>>>=v;g>0;){var y=n[s].s;t>_[y]?g-=1<<t-_[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;_[b]==t&&(--_[b],++g)}p=t}return[new Go(_),p]},va=function(e,t,i){return-1==e.s?Math.max(va(e.l,t,i+1),va(e.r,t,i+1)):t[e.s]=i},fa=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ko(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},ma=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},ya=function(e,t,i){var s=i.length,r=da(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},ba=function(e,t,i,s,r,n,o,a,l,u,c){_a(t,c++,i),++r[256];for(var d=ga(r,15),h=d[0],_=d[1],p=ga(n,15),g=p[0],v=p[1],f=fa(h),m=f[0],y=f[1],b=fa(g),w=b[0],S=b[1],k=new Ko(19),C=0;m.length>C;++C)k[31&m[C]]++;for(C=0;w.length>C;++C)k[31&w[C]]++;for(var x=ga(k,7),E=x[0],P=x[1],F=19;F>4&&!E[Xo[F-1]];--F);var I,T,R,A,M=u+5<<3,L=ma(r,aa)+ma(n,la)+o,O=ma(r,h)+ma(n,g)+o+14+3*F+ma(k,E)+(2*k[16]+3*k[17]+7*k[18]);if(L>=M&&O>=M)return ya(t,c,e.subarray(l,l+u));if(_a(t,c,1+(L>O)),c+=2,L>O){I=oa(h,_,0),T=h,R=oa(g,v,0),A=g;var D=oa(E,P,0);for(_a(t,c,y-257),_a(t,c+5,S-1),_a(t,c+10,F-4),c+=14,C=0;F>C;++C)_a(t,c+3*C,E[Xo[C]]);c+=3*F;for(var B=[m,w],q=0;2>q;++q){var H=B[q];for(C=0;H.length>C;++C)_a(t,c,D[N=31&H[C]]),c+=E[N],N>15&&(_a(t,c,H[C]>>>5&127),c+=H[C]>>>12)}}else I=ua,T=aa,R=ca,A=la;for(C=0;a>C;++C)if(s[C]>255){var N;pa(t,c,I[257+(N=s[C]>>>18&31)]),c+=T[N+257],N>7&&(_a(t,c,s[C]>>>23&31),c+=Jo[N]);var z=31&s[C];pa(t,c,R[z]),c+=A[z],z>3&&(pa(t,c,s[C]>>>5&8191),c+=Yo[z])}else pa(t,c,I[s[C]]),c+=T[s[C]];return pa(t,c,I[256]),c+T[256]},wa=new Qo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Sa=new Go(0),ka=function(){for(var e=new Qo(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Ca=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function xa(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=ka[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n,o,a,l,u,c=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,function(e,t,i,s,r,n){var o=e.length,a=new Go(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=ya(l,u,e.subarray(c,d)):(l[c]=n,u=ya(l,u,e.subarray(c,o)))}else{for(var h=wa[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Ko(32768),f=new Ko(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new Qo(25e3),S=new Ko(288),k=new Ko(32),C=0,x=0,E=(c=0,0),P=0,F=0;o>c;++c){var I=b(c),T=32767&c,R=f[I];if(v[T]=R,f[I]=T,c>=P){var A=o-c;if((C>7e3||E>24576)&&A>423){u=ba(e,l,0,w,S,k,x,E,F,c-F,u),E=C=x=0,F=c;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)k[M]=0}var L=2,O=0,D=p,B=T-R&32767;if(A>2&&I==b(c-B))for(var q=Math.min(_,A)-1,H=Math.min(32767,c),N=Math.min(258,A);H>=B&&--D&&T!=R;){if(e[c+L]==e[c+L-B]){for(var z=0;N>z&&e[c+z]==e[c+z-B];++z);if(z>L){if(L=z,O=B,z>q)break;var j=Math.min(B,z-2),V=0;for(M=0;j>M;++M){var W=c-B+M+32768&32767,U=W-v[W]+32768&32767;U>V&&(V=U,R=W)}}}B+=(T=R)-(R=v[T])+32768&32767}if(O){w[E++]=268435456|ta[L]<<18|ia[O];var G=31&ta[L],K=31&ia[O];x+=Jo[G]+Yo[K],++S[257+G],++k[K],P=c+L,++C}else w[E++]=e[c],++S[e[c]]}}u=ba(e,l,n,w,S,k,x,E,F,c-F,u),n||(u=ya(l,u,Sa))}return ha(a,0,s+da(u)+r)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!u)),d=c.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ca(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(c,t),Ca(c,d-8,i.d()),Ca(c,d-4,s),c}var Ea=!!Ze||!!Xe,Pa="text/plain",Fa=!1,Ia=(e,t)=>{var i=e.split("#"),s=i[1],r=i[0].split("?"),n=r[0],o=r[1];if(!o)return e;var a=o.split("&").filter(e=>e.split("=")[0]!==t).join("&");return n+(a?"?"+a:"")+(s?"#"+s:"")},Ta=function(e,t,i){var r;void 0===i&&(i=!0);var n=e.split("?"),o=n[0],a=n[1],l=s({},t),u=null!==(r=null==a?void 0:a.split("&").map(e=>{var t,s=e.split("="),r=s[0],n=i&&null!==(t=l[r])&&void 0!==t?t:s[1];return delete l[r],r+"="+n}))&&void 0!==r?r:[],c=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return pr(e,function(e,t){kt(e)||kt(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)}),r.join(t)}(l);return c&&u.push(c),u.length>0?o+"?"+u.join("&"):o},Ra=e=>{if(e._encodedBody)return e._encodedBody;var t=e.data,i=e.compression;if(t){if(i===Mo){var s=xa(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new Go(e.length+(e.length>>>1)),s=0,r=function(e){i[s++]=e},n=0;t>n;++n){if(s+5>i.length){var o=new Go(s+8+(t-n<<1));o.set(i),i=o}var a=e.charCodeAt(n);128>a?r(a):2048>a?(r(192|a>>>6),r(128|63&a)):a>55295&&57344>a?(r(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++n))>>>18),r(128|a>>>12&63),r(128|a>>>6&63),r(128|63&a)):(r(224|a>>>12),r(128|a>>>6&63),r(128|63&a))}return ha(i,0,s)}(eo(t)),{mtime:0});return{contentType:Pa,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===Lo){var r=(e=>"data="+encodeURIComponent("string"==typeof e?e:eo(e)))(function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(eo(t)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=eo(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},Aa=e=>{var t,i,r=()=>"sendBeacon"===e.transport?{url:Ta(e.url,{compression:Lo}),encodedBody:Ra(s({},e,{compression:Lo,_encodedBody:void 0}))}:{url:Ia(e.url,"compression"),encodedBody:Ra(s({},e,{compression:void 0,_encodedBody:void 0}))};try{t=Ra(e)}catch(t){if(Ns(e.compression,io(e.url,"compression")))return dr.error("Failed to gzip request body, sending uncompressed payload",t),r();throw t}return t&&Ns(e.compression,io(e.url,"compression"))&&!((i=t.body)instanceof ArrayBuffer?Hs(new Uint8Array(i)):ArrayBuffer.isView(i)&&Hs(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Fa=!0,r()):{url:e.url,encodedBody:t}},Ma=e=>{try{return Aa(e)}catch(t){return dr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},La=function(){var e=n(function*(e){var t=yield function(e,t,i){return Ws.apply(this,arguments)}(eo(e.data),l.DEBUG,{rethrow:!0});if(!t)return e;var i=yield t.arrayBuffer();return s({},e,{_encodedBody:{contentType:Pa,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),$a=/Failed to fetch|NetworkError|Load failed/i,Oa=e=>"TypeError"===(null==e?void 0:e.name)&&$a.test((null==e?void 0:e.message)||""),Da=e=>{var t=Ma(e);if(t){var i=t.url,r=t.encodedBody,n=null!=r?r:{},o=n.contentType,a=n.body,l=n.estimatedSize,u=new Headers;pr(e.headers,function(e,t){u.append(t,e)}),o&&u.append("Content-Type",o);var c=null,d=!1;if(et){var h=new et;c={signal:h.signal,timeout:setTimeout(()=>{var t;d=!0,h.abort(Zi("AbortError","PostHog request timed out"+((t=e.timeout)?" after "+t+"ms":"")))},e.timeout)}}var _=t=>{d&&"AbortError"===(null==t?void 0:t.name)||Oa(t)?dr.warn(t):dr.error(t),null==e.callback||e.callback({statusCode:0,error:t})};try{var p;Xe(i,s({method:(null==e?void 0:e.method)||"GET",headers:u,keepalive:"POST"===e.method&&!e._keepaliveDisabled&&52428.8>(l||0),body:a,signal:null==(p=c)?void 0:p.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){dr.error(e)}null==e.callback||e.callback(s)})).catch(_).finally(()=>c?clearTimeout(c.timeout):null)}catch(e){c&&clearTimeout(c.timeout),_(e)}}},Ba=e=>{try{var t,i=Aa(e),r=i.url,n=i.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(Qe.sendBeacon(r,u))return;var c=yt(e.data)?e.data:null==(t=e.data)?void 0:t.batch;if(yt(c)&&c.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(c.length/2),h=t=>yt(e.data)?t:s({},e.data,{batch:t});return Ba(s({},e,{data:h(c.slice(0,d))})),void Ba(s({},e,{data:h(c.slice(d))}))}dr.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Da(s({},e,{_keepaliveDisabled:!0}))}catch(e){dr.warn("Beacon send failed",e)}},qa=(e,t,i,r)=>{var n="query"===r?"POST"===t?"sent_at":"_":void 0;return Ta(i===Mo?Ia(e,"compression"):e,s({},n?{[n]:Date.now().toString()}:{},i===Mo?{}:{compression:i}))},Ha=[];Xe&&Ha.push({transport:"fetch",method:Da}),Ze&&Ha.push({transport:"XHR",method(e){var t=Ma(e);if(t){var i=new Ze,s=t.encodedBody;i.open(e.method||"GET",t.url,!0);var r=null!=s?s:{},n=r.contentType,o=r.body;pr(e.headers,function(e,t){i.setRequestHeader(t,e)}),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(o)}}}),null!=Qe&&Qe.sendBeacon&&Ha.push({transport:"sendBeacon",method:Ba});var Na=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Nt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,dr.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(s({},e,{transport:"sendBeacon"}))})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[s],r=(new Date).getTime();i.data&&yt(i.data)&&pr(i.data,e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp}),e._sendRequestSafely(i)};for(var s in t)i()}},this._flushTimeoutMs))}_sendRequestSafely(e){try{this._sendRequest(e)}catch(e){dr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return pr(this._queue,t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;kt(e[n])&&(e[n]=s({},r,{data:[]})),null==(i=e[n].data)||i.push(r.data)}),this._queue=[],e}},za=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,!kt(Ge)&&"onLine"in Ge.navigator&&(this._areWeOnline=Ge.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},kr(Ge,"online",this._onlineListener),kr(Ge,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(t){var r=t.retriesPerformedSoFar,n=i(t,e);It(r)&&(n.url=Ta(n.url,{retry_count:r})),this._instance._send_request(s({},n,{callback:e=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=r?r:0))return void this._enqueue(s({retriesPerformedSoFar:r},n));0===e.statusCode&&dr.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!=r?r:0)+" retries.")}null==n.callback||n.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this._queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),dr.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(var s of i)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,kt(Ge)||(this._onlineListener&&(Ge.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(Ge.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue)){var t=e.requestOptions;try{this._instance._send_request(s({},t,{transport:"sendBeacon"}))}catch(e){dr.error(e)}}this._queue=[]}},ja=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){kr(Ge,"scroll",this._updateScrollData,{capture:!0}),kr(Ge,"scrollend",this._updateScrollData,{capture:!0}),kr(Ge,"resize",this._updateScrollData)}scrollElement(){var e;if(!this._scrollRoot)return null==Ge||null==(e=Ge.document)?void 0:e.documentElement;for(var t of yt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot]){var i,s=null==Ge||null==(i=Ge.document)?void 0:i.querySelector(t);if(s)return s}}_scrollPosition(e){var t,i,s="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var r=this.scrollElement();return r&&r[s]||0}return Ge?"y"===e?Ge.scrollY||Ge.pageYOffset||(null==(t=Ge.document)||null==(t=t.documentElement)?void 0:t.scrollTop)||0:Ge.scrollX||Ge.pageXOffset||(null==(i=Ge.document)||null==(i=i.documentElement)?void 0:i.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}},Va=e=>mo(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes),Wa=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[me]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Va,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[me]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?yo(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return pr(yr(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+ct(i)]=t}),e}},Ua=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}constructor(){this._events={}}},Ga=hr("[SessionId]"),Ka=864e5,Qa=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Ua,this._sessionHasBeenIdleTooLong=(e,t)=>!(!It(e)||!It(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Rr,this._windowIdGenerator=i||Rr;var r=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Nt(this._config.session_idle_timeout_seconds||1800,60,36e3,Ga.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var n=Xr._parse(this._window_id_storage_key),o=Xr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Xr._remove(this._window_id_storage_key),Xr._set(this._primary_window_exists_storage_key,!0)}null!=(s=this._config.bootstrap)&&s.sessionID&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return kt(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Xr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Xr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Xr._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!Et(t)&&!Et(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var s=t!==this._sessionActivityTimestamp,r=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,r&&!s||r&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[O]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return It(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(O):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!Et(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var t=this._getSessionId();t[1]===this._sessionId&&t[2]===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[O]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var e=this._getSessionId()[0],t=It(e)?e:0,i=It(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[O];return yt(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t){void 0===t&&(t=!1);var i=function(e,t){void 0===t&&(t=(new Date).getTime());try{var i=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Ga.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Ga.error("Invalid sessionID in bootstrap",e)}}(e);return!kt(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&Ge&&(Ge.removeEventListener(ze,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Xr._remove(this._primary_window_exists_storage_key)},kr(Ge,ze,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=null),void 0===i&&(i=!1),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||(new Date).getTime(),r=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(Et(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var n,o;null==(n=(o=this._persistence).syncCookieProperties)||n.call(o),this._lastCookieSyncTimestamp=s}var a=this._getSessionId(),l=a[1],u=a[2],c=!kt(r)&&l!==r,d=this._freshestActivityTimestamp(),h=this._getWindowId(),_=this._pendingBootstrapSession,p=!!_&&(_.sessionStartTimestamp>s+6e4||s-_.sessionStartTimestamp>Ka),g=_?p:It(u)&&Math.abs(s-u)>Ka,v=!1,f=c,m=!l||!!_,y=l,b=!m&&!e&&this._sessionHasBeenIdleTooLong(s,d);if(b){(b=this._isSessionIdleAfterCrossTabRefresh(s))||Ga.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this._getSessionId();l=w[1],u=w[2]}if(m||b||g){f=!1;var S=_&&!p;l=S?_.sessionId:this._sessionIdGenerator(),h=this._windowIdGenerator(),Ga.info("new session ID assigned",{sessionId:l,windowId:h,bootstrapped:!!S,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g}}),u=S?_.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,v=!0}else h||(h=this._windowIdGenerator(),v=!0),(f=f||l!==y)&&(Ga.info("adopted cross-tab session id",{sessionId:l,windowId:h}),v=!0);var k=It(d)&&e&&!g?d:s,C=It(u)?u:(new Date).getTime();this._setWindowId(h),this._setSessionId(l,k,C),e||this._resetIdleTimer();var x={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g,crossTabAdoption:f};return v&&this._sessionIdChangedHandlers.forEach(e=>e(l,h,x)),{sessionId:l,windowId:h,sessionStartTimestamp:C,changeReason:v?x:void 0,lastActivityTimestamp:d}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}},Ja=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&at(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some(e=>at(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function Ya(){return(Ya=n(function*(){var e=null==Qe?void 0:Qe.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t,i=null==(t=yield e.getHighEntropyValues(["model"]))?void 0:t.model;return Ct(i)&&i.length>0?i:void 0}catch(e){return void dr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Xa(e,t){var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i}function Za(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}var el=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch(e){return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}},tl=e=>e.toLowerCase(),il={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>el(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!el(t,e))),icontains:(e,t)=>t.map(tl).some(t=>e.map(tl).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(tl).every(t=>e.map(tl).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function sl(e,t){return!e||Object.entries(e).every(e=>{var i=e[1],s=null==t?void 0:t[e[0]];if(null==s)return!1;var r=il[i.operator];return!!r&&r(i.values,[String(s)])})}function rl(e,t,i){return eo({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var nl="custom",ol="i.posthog.com",al=/^\/static\//,ll=["/s/","/e/","/i/"],ul=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ol,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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":nl),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(al.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}_urlKey(e){var t=to(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;var s=i,r=this.instance.config.rewriteRequestPath;if(r){var n,o=(null==(n=to(i))?void 0:n.href)||i;s=r(new URL(o)).toString()}if(r&&"api"===e&&ll.some(e=>0===t.indexOf(e))){var a=this._urlKey(s);if(a){var l,u=this.apiHost,c=this._ingestionEndpoints;(null==(l=c)?void 0:l.apiHost)===u&&c.rewriteRequestPath===r||(this._ingestionEndpoints=c={apiHost:u,rewriteRequestPath:r,urls:new Set}),c.urls.add(a)}}return s}isIngestionEndpoint(e){var t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,""+i+t)}if(this.region===nl)return this._prepareEndpoint(e,t,this.apiHost+t);var s=ol+t;switch(e){case"assets":return this._prepareEndpoint(e,t,"https://"+this.region+"-assets."+s);case"api":return this._prepareEndpoint(e,t,"https://"+this.region+"."+s)}}},cl=hr("[Surveys]"),dl=e=>{try{var t=(e=>((e,t)=>"seenSurvey_"+function(e){return e.current_iteration&&e.current_iteration>0?e.id+"_"+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){cl.error("Failed to persist survey seen state",e)}},hl=["popover","widget","api"],_l={ignoreConditions:!1,ignoreDelay:!1,displayType:No},pl=hr("[PostHog ExternalIntegrations]"),gl={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},vl=class{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return pl.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(){var t,s,r,n=i[0],o=i[1];!o||null!=(t=nt.__PosthogExtensions__)&&null!=(t=t.integrations)&&t[n]||e._loadScript(gl[n],()=>{var t;null==(t=nt.__PosthogExtensions__)||null==(t=t.integrations)||null==(t=t[n])||t.start(e._instance)}),!o&&null!=(s=nt.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[n]&&(null==(r=nt.__PosthogExtensions__)||null==(r=r.integrations)||null==(r=r[n])||r.stop())};for(var i of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t()}}},fl=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return n(function*(){if(t._disposed)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t._extensions.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t._extensions.set(e.name,e);try{var i=e.setup(t._client);i&&(yield i)}catch(i){var s=t._extensions.get(e.name)===e;s&&t._extensions.delete(e.name),t._logger.error('Failed to set up browser extension "'+e.name+'"',i),s&&t._disposeExtension(e)}})()}getExtension(e){return this._extensions.get(e)}dispose(){if(!this._disposed){this._disposed=!0;var e=Array.from(this._extensions.values()).reverse();for(var t of(this._extensions.clear(),e))this._disposeExtension(t)}}_disposeExtension(e){try{var t=null==e.dispose?void 0:e.dispose();t&&bt(t.then)&&t.then(void 0,t=>{this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)})}catch(t){this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}}},ml=class{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);var i={};for(var s of e){var r=null==t?void 0:t.get_property(s);kt(r)||(i[s]=r)}return i}set(e,t){var i;null==(i=this._instance.persistence)||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null==(t=this._instance.persistence)||t.unregister(e)}},yl="extensionsRemoteConfig",bl=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=dr,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new ml(e),this.onEvent=e=>zo(this.instance.on("eventCaptured",t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{if(this._disposed)return zo(()=>{});var t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(yl,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),zo(i)},this._runtime=new fl(dr.createLogger("[BrowserExtensions]"),this)}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){var e=this.instance.get_property(d);return"string"==typeof e?e:void 0}get library(){return{name:l.LIB_NAME,version:l.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null==(t=this.instance.persistence)?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,r=null==(e=this.instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this._runtime.add(e)}getExtension(e){return this._runtime.getExtension(e)}capture(e,t,i){var s=this;return n(function*(){i?s.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):s.instance.capture(e,t)})()}registerDynamicEventProperties(e){return zo(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(yl,e))}sendRequest(e,t){var i=this;return n(function*(){var s;void 0===t&&(t={});var r=i.instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",e),n={method:t.method,url:t.query?Ta(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,compressionFallback:"flags"===t.target&&"best-available"===t.compression?_t.Base64:void 0,timestampMode:t.sentAt};return"sendBeacon"===t.transport?(i.instance._send_request(n),{statusCode:202}):new Promise(e=>{n.callback=e,i.instance._send_request(n)})})()}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}},wl={},Sl=0,kl=()=>{},Cl='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',xl="Surveys module not available",El="sanitize_properties is deprecated. Use before_send instead",Pl="Invalid value for property_denylist config: ",Fl=/^[A-Za-z0-9_-]{1,400}$/,Il=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Tl=["token","distinct_id",xe],Rl="posthog",Al=!Ea&&-1===(null==it?void 0:it.indexOf("MSIE"))&&-1===(null==it?void 0:it.indexOf("Mozilla")),Ml=e=>{var t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},Ll=e=>{var t;return s({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Sr(null==Je?void 0:Je.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:kl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ye&&Ct(null==Ye?void 0:Ye.search)&&-1!==Ye.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==Ge||null==(t=Ge.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,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,surveys_request_timeout_ms:1e4,on_request_error(e){dr.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:He,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:kl},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:yn,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:Ml(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},$l=[["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"]],Ol=e=>{var t={};for(var i of $l){var s=i[0],r=i[1];kt(e[s])||(t[r]=e[s])}var n=gr({},t,e),o=e.__preview_external_dependency_versioned_paths;return kt(o)||(kt(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),Ct(o)&&kt(e.asset_host)&&(n.asset_host=o)),yt(e.property_blacklist)&&(kt(e.property_denylist)?n.property_denylist=e.property_blacklist:yt(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:dr.error(Pl+e.property_denylist)),n},Dl=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){dr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Bl=(r=class e{_removeExtension(e){if(e){var t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}}_replaceExtension(e,t){return this._removeExtension(e),this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(!(this._hasWarnedAboutVolatileIdentity||this.config.reuseAnonymousId||this.config.segment||this._inCookielessMode())){var e,t,i,s="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;(s||this.config.disable_persistence)&&(this._hasStableInitialDistinctId||(s?(e="persistence is set to '"+this.config.persistence+"'",t="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(e="persistence is disabled (disable_persistence is true)",t="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",e+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+t+", 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. "+i)))}}_healCookielessSentinelDistinctId(){if(!this._inCookielessMode()&&"$posthog_cookieless"===this.get_distinct_id()){var e=this.persistence;if(e){this._is_persistence_disabled()||e.load(!0);var t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){var i=this.config.get_device_id(Rr());this.register({distinct_id:i,$device_id:i}),e.set_property(fe,Be)}this._sync_opt_out_with_persistence()}}}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this.webPerformance=new Dl,this._personProcessingSetOncePropertiesSent=!1,this.version=l.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Ua,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ll(),this.SentryIntegration=Kn,this.sentryIntegration=e=>function(e,t){var i=Gn(e,t);return{name:Un,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new ja(this),this.pageViewManager=new Qn(this),this.rateLimiter=new Vo(this),this.requestRouter=new ul(this),this.consent=new Zr(this),this.externalIntegrations=new vl(this);var i=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{var s=Ct(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=Ct(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>dr.info('send "'+(null==e?void 0:e.event)+'"',e))}init(t,i,s){if(s&&s!==Rl){var r,n=null!==(r=wl[s])&&void 0!==r?r:new e;return n._init(t,i,s),wl[s]=n,wl[Rl][s]=n,n}return this._init(t,i,s)}_init(e,t,i){var r,n,o;void 0===t&&(t={});var a,u=Ct(e)?e.trim():"";if(!u)return dr.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return u!==(null==(a=this.config)?void 0:a.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('"+u+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ll(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var c=Ll(t.defaults),d=Ol(t),_=gr({},c,d,{name:i,token:u});wt(c.rageclick)&&wt(d.rageclick)&&(_.rageclick=gr({},c.rageclick,d.rageclick)),wt(c.session_recording)&&wt(d.session_recording)&&(_.session_recording=gr({},c.session_recording,d.session_recording)),this.set_config(_),this.config.on_xhr_error&&dr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Mo;var p=this._is_persistence_disabled();if(this.persistence=new Ao(this.config,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ao(s({},this.config,{persistence:"sessionStorage"}),p,!1),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!p&&Xr._is_supported()){var g=Xr._parse(this._sessionRegisteredPropertiesStorageKey);yt(g)&&g.forEach(e=>{Ct(e)&&this._sessionRegisteredPropKeys.add(e)})}else Xr._remove(this._sessionRegisteredPropertiesStorageKey);var v=s({},this.persistence.props),f=s({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Na(e=>this._send_retriable_request(e),this.config.request_queue_config),this._retryQueue=new za(this),this.__request_queue=[];var m=this._inCookielessMode();m||(this.sessionManager=new Qa(this),this.sessionPropsManager=new Wa(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(dr.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._initExtensions(m)},0)):(dr.info("Initializing extensions synchronously"),this._initExtensions(m)),l.DEBUG=l.DEBUG||this.config.debug,l.DEBUG&&dr.info("Starting in debug mode",{this:this,config:t,thisC:s({},this.config),p:v,s:f}),!this.config.identity_distinct_id||null!=(r=t.bootstrap)&&r.distinctID||(t.bootstrap=s({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var y=null==(n=t.bootstrap)?void 0:n.distinctID;if(this._hasStableInitialDistinctId=!!y&&!xt(y),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var b=t.bootstrap.distinctID,w=this.get_distinct_id(),S=this.persistence.get_property(fe);if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"anonymous"===S)this.identify(b);else if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"identified"===S)dr.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{var k=this.config.get_device_id(Rr()),C=t.bootstrap.isIdentifiedID?k:b;this.persistence.set_property(fe,t.bootstrap.isIdentifiedID?qe:Be),this.register({distinct_id:b,$device_id:C})}}if(m)this.register_once({distinct_id:Ce,$device_id:null},"");else if(!this.get_distinct_id()){var x=this.config.get_device_id(Rr());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(fe,Be)}return kr(Ge,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?Wn(this,()=>this._loaded()):this._loaded(),bt(this.config._onCapture)&&this.config._onCapture!==kl&&(dr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&dr.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 Ya.apply(this,arguments)}().then(e=>{e&&this.register({[h]:e})}).catch(kl),this}_isSharedExtension(e){var t=e;return Ct(t.name)&&bt(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>null==e.dispose?void 0:e.dispose()).catch(t=>{dr.error('Failed to dispose browser extension "'+e.name+'"',t)})}):this._extensions.push(e)}_enrollFeatureFlags(){var t,i,s,r,n,o,a=null!==(t=null==(i=this.config.__extensionClasses)?void 0:i.featureFlags)&&void 0!==t?t:null==(s=e.__defaultExtensionClasses)?void 0:s.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||(null==(o=this._featureFlagsReloadingUnsubscribe)||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new a(this)),bt(this.featureFlags.onReloading)&&bt(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):null==(r=(n=this.featureFlags).initialize)||r.call(n))}_initExtensions(t){var i,r,n,o,a,l,u,c=performance.now(),d=s({},e.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.exceptions&&this._extensions.push(this.exceptions=null!==(i=this.exceptions)&&void 0!==i?i:new d.exceptions(this)),d.historyAutocapture&&this._extensions.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this._extensions.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this._extensions.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!t&&this._extensions.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),d.autocapture&&this._enrollExtension(this.autocapture=new d.autocapture(this),h),d.surveys&&this._enrollExtension(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new d.surveys(this),h),d.logs&&this._enrollExtension(this.logs=null!==(n=this.logs)&&void 0!==n?n:new d.logs(this),h),d.metrics&&this._extensions.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new d.metrics(this)),d.conversations&&this._extensions.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new d.conversations(this)),d.productTours&&this._extensions.push(this.productTours=new d.productTours(this)),d.heatmaps&&this._extensions.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this._extensions.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,zn)),d.toolbar&&this._extensions.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new d.toolbar(this)),d.experiments&&this._extensions.push(this.experiments=null!==(u=this.experiments)&&void 0!==u?u:new d.experiments(this)),this._extensions.forEach(e=>{e.initialize&&h.push(()=>{null==e.initialize||e.initialize()})}),h.push(()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}}),this._processInitTaskQueue(h,c)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this._processInitTaskQueue(e,t)},0);var i=e.shift();if(i)try{i()}catch(e){dr.error("Error initializing extension:",e)}}var s=Math.round(performance.now()-t);this.register_for_session({[Ee]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Pe]:s}),this.config.__preview_deferred_init_extensions&&dr.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t;if(!Je||!Je.body)return dr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var i,s=e.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=lt(s.supportedCompression,Mo)?Mo:lt(s.supportedCompression,Lo)?Lo:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:He}),null==(t=this._browserClientAdapter)||t.handleRemoteConfig(e),this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}_loaded(){try{this.config.loaded(this)}catch(e){dr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=Ye&&Ye.hostname){var e=Ye.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new Uo(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&_r(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s,r;null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),null==(t=this.metrics)||t.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(Ve),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(s=this._requestQueue)||s.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(Ve,null,{transport:"sendBeacon"})}_send_request(e){var t;this.__loaded?Al?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=s({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?null!==(t=this.compression)&&void 0!==t?t:e.compressionFallback:e.compression,(kt(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,r,n=s({},e);n.timeout=n.timeout||6e4;var o,a,l,u,c,d=null!==(t=n.transport)&&void 0!==t?t:"fetch";"sendBeacon"===d&&kt(n.compression)&&n.data&&(n.compression=Lo),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data={api_key:null!==(a=null==(c=(u=(yt(o=n.data)?o:[o]).map(e=>s({},e,e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})))[0])||null==(l=c.properties)?void 0:l.token)&&void 0!==a?a:null==c?void 0:c.token,batch:u,sent_at:(new Date).toISOString()}:"body"===n.timestampMode&&(n.data=function(e,t){return void 0===t&&(t=(new Date).toISOString()),yt(e)?e.map(e=>s({},e,{sent_at:t})):s({},e,{sent_at:t})}(n.data))),n.url=qa(n.url,n.method,n.compression,n.timestampMode);var h=Ha.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),_=null!==(i=null==(r=function(e,t){for(var i=0;e.length>i;i++)if(t(e[i]))return e[i]}(h,e=>e.transport===d))?void 0:r.method)&&void 0!==i?i:h[0].method;if(!_)throw new Error("No available transport method");var p=e=>{try{_(e)}catch(e){Oa(e)?dr.warn(e):dr.error(e),null==n.callback||n.callback({statusCode:0,error:e})}};"sendBeacon"!==d&&n.data&&n.compression===Mo&&tt&&"undefined"!=typeof Promise&&!Fa?La(n).then(e=>{p(e)}).catch(t=>{if(zs(t))return Fa=!0,void p(s({},n,{compression:void 0,url:qa(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return zs(e)||t===qs})(t)&&(Fa=!0),p(n)}):_(n)})(s({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(s=this.config).on_request_error)||i.call(s,t),null==e.callback||e.callback(t)}}))):e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:0}))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){Sl++;try{var t,i=[],s=[],r=[];_r(e,e=>{if(e)if(yt(t=e[0]))r.push(e);else if(bt(e))try{e.call(this)}catch(t){dr.error("Error executing queued PostHog call",e,t)}else yt(e)&&"alias"===t?i.push(e):yt(e)&&-1!==t.indexOf("capture")&&bt(this[t])?r.push(e):s.push(e)});var n=function(e,t){_r(e,function(e){try{if(yt(e[0])){var i=t;pr(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){dr.error("Error executing queued PostHog call",e,t)}})};n(i,this),n(s,this),n(r,this)}finally{Sl--}}push(t){if(Sl>0&&yt(t)&&Ct(t[0])){var i=e.prototype[t[0]];bt(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}_getPersistedFacebookClickId(){var e,t=null==(e=this.persistence)?void 0:e.get_property(v);return Ct(t)&&Il.test(t)?{value:t,delivered:!1}:wt(t)&&Ct(t.value)&&Il.test(t.value)?{value:t.value,delivered:!0===t.delivered}:void 0}_updateFacebookClickId(e,t,i,s){if(this.persistence){this.persistence.refreshKey(v);var r=this._getPersistedFacebookClickId();if(!s){if(i)return Ct(t)&&Il.test(t)?(t!==(null==r?void 0:r.value)&&this.persistence.register({[v]:{value:t,delivered:!1}}),{value:t,pending:t!==(null==r?void 0:r.value)||!r.delivered}):void this.persistence.unregister(v);if(Ct(e)&&Fl.test(e)){if((null==r?void 0:r.value.split(".")[3])===e)return{value:r.value,pending:!r.delivered};var n="fb.1."+Date.now()+"."+e;return this.persistence.register({[v]:{value:n,delivered:!1}}),{value:n,pending:!0}}return r?{value:r.value,pending:!r.delivered}:void 0}this.persistence.unregister(v)}}_markFacebookClickIdDelivered(e){if(this.persistence){this.persistence.refreshKey(v);var t=this._getPersistedFacebookClickId();(null==t?void 0:t.value)!==e||t.delivered||this.persistence.register({[v]:{value:e,delivered:!0}})}}capture(e,t,i){var r,n,o,a,l,u,c,d,h,_;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!kt(e)&&Ct(e)){this._healCookielessSentinelDistinctId();var p=!this.config.opt_out_useragent_filter&&this._is_bot();if(!p||this.config.__preview_capture_bot_pageviews){var v=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==v||!v.isRateLimited){var f;null!=t&&t.$current_url&&!Ct(null==t?void 0:t.$current_url)&&(dr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=i&&i._originatedFromCaptureException||dr.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&&(f=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var m=new Date,y=(null==i?void 0:i.timestamp)||m,b=Xi(null==i?void 0:i.uuid,Rr),w={uuid:b,event:e,properties:this.calculateEventProperties(e,t||{},y,b)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&p&&(w.event="$bot_pageview",w.properties.$browser_type="bot"),v&&(w.properties.$lib_rate_limit_remaining_tokens=v.remainingTokens);var S="$feature_flag_called"===e&&!1===w.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");null!=i&&i.$set&&!S&&(w.$set=null==i?void 0:i.$set);var k=wt(null==t?void 0:t.$set)?t.$set:void 0,C=!(null==i||!i.$set)&&"$fbc"in i.$set,x=C||!!k&&"$fbc"in k,E=C?null==i||null==(r=i.$set)?void 0:r[g]:null==k?void 0:k[g],P=yt(null==t?void 0:t.$unset)?t.$unset:[],F=(null==i?void 0:i.$unset)||[],I=-1!==P.indexOf("$fbc")||-1!==F.indexOf("$fbc"),T=this._updateFacebookClickId(null==(n=f)?void 0:n.fbclid,E,x,I);T&&!0===w.properties.$process_person_profile&&T.pending&&!x&&!S&&(w.$set=s({[g]:T.value},w.$set));var R=null==i?void 0:i.$unset;R&&(w.$unset=R);var A=S?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==Ue,e===We);if(A&&(w.$set_once=A),null!=i&&i._noTruncate||(c=this.config.properties_string_max_length,d=w,h=e=>Ct(e)?e.slice(0,c):e,_=new Set,w=function e(t,i){if(t!==Object(t))return h?h(t):t;if(!_.has(t)){var s;if(_.add(t),yt(t))s=[],_r(t,t=>{s.push(e(t))});else{var r={};pr($t(t)?br(t):t,(t,i)=>{_.has(t)||(r[i]=e(t,i))}),s=r}return s}}(d)),w.timestamp=y,kt(null==i?void 0:i.timestamp)||(w.properties.$event_time_override_provided=!0,w.properties.$event_time_override_system_time=m),S&&(w.properties=function(e,t){void 0===t&&(t=[]);var i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return Bs.forEach(s),t.forEach(s),i}(w.properties,Tl)),e===Bo||e===qo){var M=null==t?void 0:t.$survey_id,L=null==t?void 0:t.$survey_iteration;dl({id:M,current_iteration:L}),w.$set=s({},w.$set,{[Xa({id:M,current_iteration:L},e===qo?"responded":"dismissed")]:!0})}else e===Do&&(w.$set=s({},w.$set,{[Ho]:(new Date).toISOString()}));if("product tour shown"===e){var O=null==t?void 0:t.$product_tour_type;O&&(w.$set=s({},w.$set,{["$product_tour_last_seen_date/"+O]:(new Date).toISOString()}))}var D=s({},w.properties.$set,w.$set);if(St(D)||this.setPersonPropertiesForFlags(D),!Pt(this.config.before_send)){var B=this._runBeforeSend(w);if(!B)return;(w=B).uuid=Xi(w.uuid,Rr)}var q=null!==(o=null==(a=w.$set)?void 0:a.$fbc)&&void 0!==o?o:wt(null==(l=w.properties)?void 0:l.$set)?w.properties.$set.$fbc:void 0,H=null!=T&&T.pending&&q===T.value?T.value:void 0;this._internalEventEmitter.emit("eventCaptured",w);var N=null!==(u=null==i?void 0:i._url)&&void 0!==u?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),z=s({method:"POST",url:N,data:w,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(N)?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},null!=i&&i.transport?{transport:i.transport}:{},H?{fireCallbackOnDrop:!0,callback:e=>{e.statusCode>=200&&300>e.statusCode&&this._markFacebookClickIdDelivered(H)}}:{});return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly||H?this._send_retriable_request(z):this._requestQueue.enqueue(z),w}dr.critical("This capture call is ignored due to client rate limiting.")}}else dr.error("No event name provided to posthog.capture")}else dr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null==(t=this._browserClientAdapter)?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new bl(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);var t=!0;return()=>{if(t){t=!1;var i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}}_processCookieIdentityChange(e){var t,i,s;return void 0===e&&(e=!0),!(null==(t=this.persistence)||!t.consumeCookieIdentityChange())&&(this._cachedPersonProperties=null,"anonymous"===this.persistence.get_property("$user_state")&&(null==(s=this.sessionPersistence)||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null==(i=this.featureFlags)||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;this.persistence.syncCookieProperties(),this._processCookieIdentityChange();var o=n?void 0:this.persistence.remove_event_timer(e),l=s({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l[xe]=!0),"$snapshot"===e){var u=s({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!Ct(l.distinct_id)&&!Ft(l.distinct_id)||xt(l.distinct_id))&&dr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i,s){var r,n,o,l;if(void 0===s&&(s=!1),!it)return{};var u,c=e?[...ao,...t||[]]:[],d=Ni(it),h=d[0],_=d[1],p=function(e){for(var t=0;Vi.length>t;t++){var i,s=Vi[t],r=s[1],n=s[2],o=e.match(s[0]);if(o)return[r,(null==(i=n&&e.match(n)||o)?void 0:i[1])||""]}return["",""]}(it),g=p[0],v=p[1],f=null!=(u="u">typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},m={};kt(i)||(m.detectGoogleSearchApp=i);var y={},b=null==(r=navigator)||null==(r=r.userAgentData)?void 0:r.platform,w=null==(n=navigator)?void 0:n.maxTouchPoints,S=null==Ge||null==(o=Ge.screen)?void 0:o.width,k=null==Ge||null==(l=Ge.screen)?void 0:l.height,C=null==Ge?void 0:Ge.devicePixelRatio;kt(b)||(y.userAgentDataPlatform=b),kt(w)||(y.maxTouchPoints=w),kt(S)||(y.screenWidth=S),kt(k)||(y.screenHeight=k),kt(C)||(y.devicePixelRatio=C);var x,E,P,F,I,T,R,A,M=gr(yr({$os:h,$os_version:_,$browser:Di(it,navigator.vendor,f,m),$webview_app:g,$webview_app_version:v,$device:zi(it),$device_type:(E=it,P=y,A=zi(E),A===Gt||A===Ut||"Kobo"===A||"Kindle Fire"===A||A===vi?Wt:A===oi||A===li||A===ai||A===pi?"Console":A===Kt?"Wearable":A?jt:"Android"===(null==P?void 0:P.userAgentDataPlatform)&&(null!==(F=null==P?void 0:P.maxTouchPoints)&&void 0!==F?F:0)>0?600>Math.min(null!==(I=null==P?void 0:P.screenWidth)&&void 0!==I?I:0,null!==(T=null==P?void 0:P.screenHeight)&&void 0!==T?T:0)/(null!==(R=null==P?void 0:P.devicePixelRatio)&&void 0!==R?R:1)?jt:Wt:"Desktop"),$timezone:bo(),$timezone_offset:wo()}),{$current_url:so(s?es(null==Ye?void 0:Ye.href):null==Ye?void 0:Ye.href,c,uo),$host:null==Ye?void 0:Ye.host,$pathname:null==Ye?void 0:Ye.pathname,$raw_user_agent:it.length>1e3?it.substring(0,997)+"...":it,$browser_version:qi(it,navigator.vendor,f,m),$browser_language:go(),$browser_language_prefix:(x=go(),"string"==typeof x?x.split("-")[0]:void 0),$screen_height:null==Ge?void 0:Ge.screen.height,$screen_width:null==Ge?void 0:Ge.screen.width,$viewport_height:null==Ge?void 0:Ge.innerHeight,$viewport_width:null==Ge?void 0:Ge.innerWidth,$lib:a.LIB_NAME,$lib_version:a.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return a.SDK_DIST_CHANNEL&&(M.$sdk_dist_channel=a.SDK_DIST_CHANNEL),M}(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){var h=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0),_=h.windowId;l.$session_id=h.sessionId,l.$window_id=_}this.sessionPropsManager&&gr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&gr(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===nl&&(l.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),l=gr(l,c),"$pageview"===e&&Je&&(l.title=Je.title),!kt(o)){var g=i.getTime()-o;l.$duration=parseFloat((g/1e3).toFixed(3))}it&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var v=this.persistence.properties(),f=this.sessionPersistence.properties(),m=l.$groups,y=v.$groups;wt(m)&&!St(m)&&(l.$groups=s({},wt(y)?y:{},m)),pr(["$referrer","$referring_domain"],e=>{e in v&&delete f[e]});var b={};if(this._extensionEventPropertyProducers.length>0)for(var w of this._extensionEventPropertyProducers.slice())try{gr(b,w())}catch(e){dr.error("Failed to produce browser extension event properties",e)}(l=gr({},d,v,f,s({},b,l))).$is_identified=this._isIdentified(),yt(this.config.property_denylist)?pr(this.config.property_denylist,function(e){delete l[e]}):dr.error(Pl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(dr.error(El),l=S(l,e));var k=this._hasPersonProcessing();return l.$process_person_profile=k,k&&!n&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var s;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var r=gr({},this.persistence.get_initial_props(),(null==(s=this.sessionPropsManager)?void 0:s.getSetOnceProps())||{},e||{}),n=this.config.sanitize_properties;return n&&(dr.error(El),r=n(r,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),St(r)?void 0:r}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t,i;null==(t=this.persistence)||t.syncCookieProperties(),this._processCookieIdentityChange(),null==(i=this.sessionPersistence)||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null==(t=this.sessionPersistence)||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(this._sessionRegisteredPropertiesStorageKey)if("memory"===this.config.persistence||null!=(e=this.sessionPersistence)&&e._disabled||!Xr._is_supported())Xr._remove(this._sessionRegisteredPropertiesStorageKey);else{var t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Xr._set(this._sessionRegisteredPropertiesStorageKey,t):Xr._remove(this._sessionRegisteredPropertiesStorageKey)}}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null==(s=this.featureFlags)?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null==(s=this.featureFlags)||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null==(s=this.featureFlags)||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var s;return void 0===t&&(t=!1),null==(s=this.featureFlags)?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:xl}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:xl})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:xl})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=_l),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:xl}}canRenderSurveyAsync(e,t){var i,s;return void 0===t&&(t=!1),null!==(i=null==(s=this.surveys)?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:xl})}_validateIdentifyId(e){return!e||xt(e)?(dr.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(dr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(dr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return dr.uninitializedWarning("posthog.identify");if(Ft(e)&&(e=e.toString(),dr.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){this._healCookielessSentinelDistinctId();var s=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,n=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),e!==l&&e!==this.get_property("__alias")&&(this.unregister(_),this.register({distinct_id:e}));var u=(this.persistence.get_property("$user_state")||"anonymous")===Be,c=e!==l,d=!c&&u;if(c&&u){var h,p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(fe,qe),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture(We,p,{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=rl(e,t,i),null==(h=this.featureFlags)||h.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(d){this.persistence.set_property(fe,qe);var g=t||{},v=i||{};this.setPersonPropertiesForFlags({$set:g,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:g,$set_once:v}),this._cachedPersonProperties=rl(e,t,i)}else(t||i)&&this.setPersonProperties(t,i);c||r||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(_e)):d&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=rl(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):dr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(yt(e)?e:[e]).filter(e=>Ct(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var r;if(e&&t){null==(r=this.persistence)||r.syncCookieProperties(),this._processCookieIdentityChange();var n=this.getGroups(),o=n[e]!==t;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:s({},n,{[e]:t})}),(o||i)&&this._hasPersonProcessing()){var a={$group_type:e,$group_key:t};i&&(a.$group_set=i),this.capture(Ue,a)}i&&this.setGroupPropertiesForFlags({[e]:i}),o&&!i&&this.reloadFeatureFlags()}else dr.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t=Tt(e)?e:null==e?void 0:e.resetDeviceID,i=Tt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t,i){var r,n,o,a;if(void 0===t&&(t=!1),dr.info("reset"),!this.__loaded)return dr.uninitializedWarning("posthog.reset");var l=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null==(r=this._originalUserConfig)?void 0:r.bootstrap)||{},null==(n=this.featureFlags)||null==n.updateConfig||n.updateConfig(this.config,this._shouldDisableFlags());var u=this.get_property(d),c=this.get_property(h),_=this.get_property(F);null==(o=this.sessionRecording)||o.flushBeforeIdentityReset();var p=this.is_capturing();this.consent.reset(),t||!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.");var g=null==(a=this.persistence)||null==a._beginCookieSyncSuppression?void 0:a._beginCookieSyncSuppression(),v=!1;try{var f,m,y,b,w,S,k,C,x,E,P,I,T;if(null==(f=this.persistence)||f.clear(),null==(m=this.sessionPersistence)||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),kt(_)||null==(y=this.persistence)||y.register({[F]:_}),null==(b=this.surveys)||b.reset(),null==(w=this.featureFlags)||w.reset(),null==(S=this.conversations)||S.reset(),null==(k=this.logs)||k.reset(),null==(C=this.metrics)||C.reset(),null==(x=this.persistence)||x.set_property(fe,Be),null==(E=this.sessionManager)||E.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Ce,$device_id:null},"");else{var R=this.config.get_device_id(Rr());this.register_once({distinct_id:R,$device_id:e?R:u},""),e||kt(c)||this.register({[h]:c})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(void 0===i.distinctID||this._inCookielessMode()||(null==(T=this.persistence)||T.set_property(fe,i.isIdentifiedID?qe:Be),this.register({distinct_id:i.distinctID})),null==(P=this.featureFlags)||P.initialize(),!(kt(l)||null!=(I=this.sessionManager)&&I.setBootstrapSessionId(l,!0))){var A=s({},i);delete A.sessionID,this.config.bootstrap=A}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,v=!0}finally{var M;g&&(null==(M=this.persistence)||null==M._endCookieSyncSuppression||M._endCookieSyncSuppression(v))}this.reloadFeatureFlags()}shutdown(e){var t=this;return n(function*(){var e,i,s,r,n,o,a;if(t.__loaded){t._getBrowserClientAdapter().dispose(),null==(e=t.sessionRecording)||e.dispose(),null==(i=t.logs)||i.flushLogs("sendBeacon"),null==(s=t.metrics)||s.flush("sendBeacon"),null==(r=t._requestQueue)||r.unload(),null==(n=t._retryQueue)||n.unload();try{var l;null==(l=t.featureFlags)||l.destroy()}catch(e){dr.error("Error while destroying feature flags",e)}null==(o=t.persistence)||o.destroy(),null==(a=t.sessionPersistence)||a.destroy()}else dr.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(dr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(kt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(_,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(dr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=s({},this.config);if(wt(e)){var i,r,n,o,a,u,c,d,h,_,p,g,v;gr(this.config,Ol(e));var f=this._is_persistence_disabled();null==(i=this.persistence)||i.update_config(this.config,t,f),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ao(s({},this.config,{persistence:"sessionStorage"}),f,!1);var m=this._checkLocalStorageForDebug(this.config.debug);Tt(m)&&(this.config.debug=m),Tt(this.config.debug)&&(this.config.debug?(l.DEBUG=!0,Br._is_supported()&&Br._set("ph_debug",!0),dr.info("set_config",{config:e,oldConfig:t,newConfig:s({},this.config)})):(l.DEBUG=!1,Br._is_supported()&&Br._remove("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this._shouldDisableFlags()),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(u=this.tracingHeaders)||u.startIfEnabledOrStop(),null==(c=this.autocapture)||c.startIfEnabled(),null==(d=this.heatmaps)||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null==(h=this.historyAutocapture)||h.startIfEnabledOrStop()),null==(_=this.exceptionObserver)||_.startIfEnabledOrStop(),null==(p=this.deadClicksAutocapture)||p.startIfEnabledOrStop(),null==(g=this.surveys)||g.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(v=this.externalIntegrations)||v.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&Wn(this,kl,!1)}}_overrideSDKInfo(e,t){l.LIB_NAME=e,l.LIB_VERSION=t}startSessionRecording(e){var t,i,s,r,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),a.url_trigger&&(null==(r=this.sessionRecording)||r.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){try{if(!this.exceptions)return;var i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(s({},i,t))}catch(e){return}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var t,i;return null!==(t=null==(i=this.logs)?void 0:i.logger)&&void 0!==t?t:e._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Rl;return t!==Rl&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property("$user_state"))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&St(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e.__alias)&&(null==(t=this.persistence)||null==(t=t.props)||!t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(dr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(ke,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t,i,s,r,n=this._is_persistence_disabled();return this.is_capturing()||null==(e=this.logs)||e._onOptOut(),(null==(t=this.persistence)?void 0:t._disabled)!==n&&(null==(i=this.persistence)||i.set_disabled(n)),(null==(s=this.sessionPersistence)?void 0:s._disabled)!==n&&(null==(r=this.sessionPersistence)||r.set_disabled(n)),n&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),n}opt_in_capturing(t){var i,s,r;if("always"!==this.config.cookieless_mode){if(this._inCookielessMode()){var n,o,a,l,u,c;null==(n=this.sessionRecording)||n.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null==(o=this.sessionManager)||o.destroy(),null==(a=this.pageViewManager)||a.destroy(),this.sessionManager=new Qa(this),this.pageViewManager=new Qn(this),this.persistence&&(this.sessionPropsManager=new Wa(this,this.sessionManager,this.persistence));var d,h=null!==(l=null==(u=this.config.__extensionClasses)?void 0:u.sessionRecording)&&void 0!==l?l:null==(c=e.__defaultExtensionClasses)?void 0:c.sessionRecording;h&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new h(this)),this._lastRemoteConfig&&(null==(d=this.sessionRecording)||null==d.onRemoteConfig||d.onRemoteConfig(this._lastRemoteConfig)))}this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(i=this.sessionRecording)||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null==(s=this.surveys)||s.loadIfEnabled()),(kt(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(r=null==t?void 0:t.captureEventName)&&void 0!==r?r:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else dr.warn(Cl)}opt_out_capturing(){if("always"!==this.config.cookieless_mode){var e,t,i="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;null==i||i.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:Ce,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())}else dr.warn(Cl)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return 1===e?"granted":0===e?"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._sync_opt_out_with_persistence()}_is_bot(){return Qe?Ja(Qe,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Je&&("visible"===Je.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(je,{title:Je.title},{send_instantly:!0}),this._visibilityStateListener&&(Je.removeEventListener(Ne,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),kr(Je,Ne,this._visibilityStateListener)))}debug(e){!1===e?(null==Ge||Ge.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==Ge||Ge.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){var e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(dr.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(e,t,i,s,r){var n=t in e&&!Pt(e[t]),o=i in e&&!Pt(e[i]);return n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,dr)}_runBeforeSend(e){var t;if(Pt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(At),s=yt(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var n of s)try{if(r=n(r),Pt(r)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Rt(e.event)?dr.warn(o+". This can cause unexpected behavior."):dr.info(o),null}r.properties&&!St(r.properties)||dr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(t){return dr.error("Error in beforeSend function for event '"+e.event+"':",t),null}for(var a of i)if(r.properties&&Pt(r.properties[a]))return dr.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return r}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=Tt(e)&&!e,i=Br._is_supported()&&"true"===Br._get("ph_debug");return!t&&(!!i||e)}},r.__defaultExtensionClasses={},r._noopLogger=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),r);!function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=mr(e.prototype[t[i]])}(Bl,["identify"]);var ql=class{constructor(e){this.disabled=!1===e;var t=wt(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Hl="$copy_autocapture",Nl=hr("[AutoCapture]");function zl(e,t){return t.length>e?t.slice(0,e)+"...":t}function jl(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!sn(t));return t}function Vl(e,t){var i,r,n=t.e,o=t.maskAllElementAttributes,a=t.maskAllText,l=t.elementAttributeIgnoreList,u=t.elementsChainAsString,c=t.disableCaptureUrlHashes;if(!sn(e))return{props:{}};for(var d=[e],h=new Set([e]),_=e;_.parentNode&&!rn(_,"body")&&1e3>d.length;)if(on(_.parentNode)){var p=_.parentNode.host;if(h.has(p))break;h.add(p),d.push(p),_=p}else{if(!sn(_.parentNode))break;if(h.has(_.parentNode))break;h.add(_.parentNode),d.push(_.parentNode),_=_.parentNode}var g="click"===n.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?d.findIndex(e=>rn(e,"button")||rn(e,"a")):-1;g>0&&(a=a||d.slice(0,g+1).some(e=>!En(e)||Pn(e)));var v,f,m,y=[],b={},w=!1,S=!1;if(pr(d,e=>{var t=En(e);if(rn(e,"a")){var i=e.getAttribute("href");w=!!(t&&i&&$n(i))&&(c?es(i):i)}lt(un(e),"ph-no-capture")&&(S=!0),y.push(function(e,t,i,s,r){void 0===r&&(r=!1);var n=e.tagName.toLowerCase(),o={tag_name:n};_n.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?zl(1024,On(e)):zl(1024,dn(e)));var a=un(e);a.length>0&&(o.classes=a.filter(function(e){return""!==e})),pr(e.attributes,function(i){var n;if((!Pn(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==s||!s.includes(i.name))&&!t&&$n(i.value)&&(!Ct(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=an(a).join(" ")),o["attr__"+i.name]=zl(1024,"href"===i.name&&r?es(a):a)}});for(var l=1,u=1,c=e;c=jl(c);)l++,c.tagName===e.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(e,o,a,l,c)),pr(function(e){if(!En(e))return{};var t={};return pr(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&$n(s)&&(t[i]=s)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(b,t)||(b[t]=e)})}),S)return{props:{},explicitNoCapture:S};if(g>0&&(e=d[g],y.splice(0,g)),a||(y[0].$el_text=rn(e,"a")||rn(e,"button")?On(e):dn(e)),w){var k,C;y[0].attr__href=w;var x=null==(k=to(w))?void 0:k.host,E=null==Ge||null==(C=Ge.location)?void 0:C.host;x&&E&&x!==E&&(v=w)}return{props:gr((f=n.type,{$event_type:f,$ce_version:1}),u?{}:{$elements:y},{$elements_chain:(m=y,yt(m)?function(e){return e.map(e=>{var t,i,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var o=s({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return vr(o).sort((e,t)=>{return(s=t[0])>(i=e[0])?-1:i>s?1:0;var i,s}).forEach(e=>{var t=e[1];return a[Bn(e[0].toString())]=Bn(t.toString())}),(r+=":")+vr(a).map(e=>e[0]+'="'+e[1]+'"').join("")}).join(";")}(function(e){return e.map(e=>{var t,i,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:qn(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return vr(e).filter(e=>0===e[0].indexOf("attr__")).forEach(e=>s.attributes[e[0]]=e[1]),s})}(m)):"")},null!=(i=y[0])&&i.$el_text?{$el_text:null==(r=y[0])?void 0:r.$el_text}:{},v&&"click"===n.type?{$external_click_url:v}:{},b),target:e}}var Wl=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!En(e))return!0;for(var i,s=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:fn,r=new Set,n=e,o=function(){if(r.size>=1e3||r.has(n))return{v:!0};r.add(n);var e=n,t=un(e);if(lt(t,"ph-no-capture")||lt(t,"ph-sensitive")||Pn(e)||s.some(t=>pn(e,t)))return{v:!0};var i=n.parentNode;n=on(i)?i.host:i&&sn(i)?i:null};n;)if(i=o())return i.v;return!1}_trackPointer(e){if(this.isEnabled&&"pointercancel"!==e.type)if("pointerdown"!==e.type){var t=this._pointerDown;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this._clearPointer():"pointerup"===e.type&&(t.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}else{var i;this._clearPointer();var s=hn(e);e.isPrimary&&0===e.button&&!e.ctrlKey&&s&&sn(s)&&(this._pointerDown={target:s,excluded:this._isExcludedPointerTarget(s),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null==(i=this._client)?void 0:i.distinctId})}else this._clearPointer()}_recoverClickTarget(e){var t,i=this._pointerDown;this._clearPointer();var s=hn(e);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(t=this._client)?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(rn(s,"html")||rn(s,"body"))){var r;if(i.excluded)return null;var n=null!==(r=this._refreshConfig().css_selector_ignorelist)&&void 0!==r?r:fn;return[s,null==Je?void 0:Je.documentElement,null==Je?void 0:Je.body].some(e=>{if(!e)return!1;var t=un(e);return lt(t,"ph-no-capture")||lt(t,"ph-sensitive")||!En(e)||Pn(e)||n.some(t=>pn(e,t))})?null:i.target}}constructor(e){this._configSource=e,this.name="autocapture",this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementsChainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new ql(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;var t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,null==(e=this._remoteConfigSubscription)||e.dispose(),this._remoteConfigSubscription=void 0,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){var e,t;return this._refreshConfig(),this._config.url_allowlist=null==(e=this._config.url_allowlist)?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null==(t=this._config.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ge&&Je){var e=this._domEventHandler=e=>{e=e||(null==Ge?void 0:Ge.event);try{if("blur"===e.type)return void this._clearPointer();if(0===e.type.indexOf("pointer"))return void this._trackPointer(e);var t="click"===e.type?this._recoverClickTarget(e):void 0;if(Et(t))return;this._captureEvent(e,"$autocapture",t)}catch(e){Nl.error("Failed to capture event",e)}};if(kr(Ge,"blur",e),kr(Je,"submit",e,{capture:!0}),kr(Je,"change",e,{capture:!0}),kr(Je,"click",e,{capture:!0}),pr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{kr(Je,t,e,{capture:!0})}),this._refreshConfig().capture_copied_text){var t=this._copiedTextHandler=e=>{e=e||(null==Ge?void 0:Ge.event);try{this._captureEvent(e,Hl)}catch(e){Nl.error("Failed to capture clipboard event",e)}};kr(Je,"copy",t,{capture:!0}),kr(Je,"cut",t,{capture:!0}),kr(Je,"paste",t,{capture:!0})}}}else Nl.info("Disabling Automatic Event Collection because this browser is not supported")}_removeDomEventHandlers(){this._clearPointer(),this._domEventHandler&&(null==Ge||Ge.removeEventListener("blur",this._domEventHandler),pr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==Je||Je.removeEventListener(e,this._domEventHandler,!0)}),null==Je||Je.removeEventListener("submit",this._domEventHandler,!0),null==Je||Je.removeEventListener("change",this._domEventHandler,!0),null==Je||Je.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==Je||Je.removeEventListener("copy",this._copiedTextHandler,!0),null==Je||Je.removeEventListener("cut",this._copiedTextHandler,!0),null==Je||Je.removeEventListener("paste",this._copiedTextHandler,!0),this._copiedTextHandler=void 0),this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(!this._disposed)if(this._hasReceivedConfigResponse=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);var i,s=t.autocapture_opt_out;Tt(s)&&(null==(i=this._client)||i.kv.set(m,s),this._isDisabledServerSide=s),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e,t){var i,s=[];return null==(i=this._elementSelectors)||i.forEach(i=>{var r;null==Je||null==(r=Je.querySelectorAll(i))||r.forEach(r=>{e!==r&&t!==r||lt(s,i)||s.push(i)})}),s}get isEnabled(){var e,t;if(this._disposed)return!1;var i=null==(e=this._client)?void 0:e.kv.get(m),s=this._isDisabledServerSide,r=this._refreshConfig();if(!r.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;var n=r.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(Et(s)&&!Tt(i)&&!n)return!1;var o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!r.enabled&&!o}_captureEvent(e,t,i){if(void 0===t&&(t="$autocapture"),this.isEnabled){var r=i||hn(e);nn(r)&&(r=r.parentNode||null);var n,o=this._compileUrlPatterns();"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&o.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&kn(r,o.rageclick)&&this._captureEvent(e,"$rageclick",i);var a=t===Hl,l=a?s({},o,{dom_event_allowlist:void 0}):o;if(r&&function(e,t,i,s,r,n){var o;if(!Ge||Cn(e))return!1;if(null!=i&&i.url_allowlist&&!ln(i.url_allowlist,n))return!1;if(null!=i&&i.url_ignorelist&&ln(i.url_ignorelist,n))return!1;if(null!=i&&i.dom_event_allowlist){var a=i.dom_event_allowlist;if(a&&!a.some(e=>t.type===e))return!1}var l=xn(e,s),u=l.parentIsUsefulElement,c=l.targetElementList;if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(kt(i))return!0;var s,r=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var n of e)if(s=r(n))return s.v;return!1}(c,i))return!1;if(!gn(c,null==i?void 0:i.css_selector_allowlist))return!1;if(gn(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:fn))return!1;try{var d=Ge.getComputedStyle(e);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return u?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(_n.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,l,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var u,c=Vl(r,{e:e,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),d=c.props;if(c.explicitNoCapture)return!1;var h=this.getElementSelectors(r,c.target);if(h&&h.length>0&&(d.$element_selectors=h),t===Hl){var _=e.type||"clipboard";if("paste"!==_){var p,g,v=null==Ge||null==(p=Ge.getSelection())?void 0:p.toString(),f=cn(v);if(!f)return!1;d.$selected_content=f,d.$clipboard_text_length=null!==(g=null==v?void 0:v.length)&&void 0!==g?g:0}d.$copy_type=_}return null==(u=this._client)||u.capture(t,d).catch(e=>Nl.error("Failed to capture event",e)),!0}}else this._clearPointer()}isBrowserSupported(){return bt(null==Je?void 0:Je.querySelectorAll)}},Ul=class{constructor(e){this._instance=e}refresh(e){var t=this._instance.config,i=wt(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),e.url_allowlist=null==i?void 0:i.url_allowlist,e.url_ignorelist=null==i?void 0:i.url_ignorelist,e.dom_event_allowlist=null==i?void 0:i.dom_event_allowlist,e.element_allowlist=null==i?void 0:i.element_allowlist,e.css_selector_allowlist=null==i?void 0:i.css_selector_allowlist,e.css_selector_ignorelist=null==i?void 0:i.css_selector_ignorelist,e.element_attribute_ignorelist=null==i?void 0:i.element_attribute_ignorelist,e.capture_copied_text=null==i?void 0:i.capture_copied_text}},Gl=hr("[ExceptionAutocapture]"),Kl=()=>{},Ql=e=>{var t;if(bt(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Jl(e,t,i){try{if(!(t in e))return Kl;var s={next:e[t]},r=i(function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.next.apply(this,t)});return bt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=r,()=>{if(e[t]!==r)for(var i=e[t],n=Ql(i);n;){if(n.next===r)return void(n.next=s.next);n=Ql(i=n.next)}else e[t]=s.next}}catch(e){return Kl}}var Yl=hr("[TracingHeaders]"),Xl=hr("[Web Vitals]"),Zl=9e5,eu=["CLS","FCP","INP","LCP"],tu=["INP","LCP"],iu=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],su="disabled",ru="lazy_loading",nu=hr("[SessionRecording]"),ou=hr("[Heatmaps]");function au(e){return wt(e)&&"clientX"in e&&"clientY"in e&&Ft(e.clientX)&&Ft(e.clientY)}var lu=hr("[Product Tours]"),uu=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(x))},cu=hr("[SiteApps]"),du="Error while initializing PostHog app with config id ",hu=(e,t)=>null!=e&&e.then?e.then(t):t(e),_u="SDK is not enabled or survey functionality is not yet loaded",pu="Disabled. Not loading surveys.",gu=class{constructor(e,t){this._configSource=e,this._initialClientState=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(!this._disposed&&!this._config.disableSurveys){if(!e.ok)return cl.warn("Remote config unavailable. Not loading surveys.");var t=e.config.surveys;if(Pt(t))return cl.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=Tt(t)?t:t.length>0,cl.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}}setup(e){if(!this._disposed)return this._initializingClient=e,hu(e.kv.initialize(),()=>{if(this._initializingClient===e&&!this._disposed){this._initializingClient=void 0,this._client=e;var t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())}})}dispose(){var e,t,i;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null==(e=this._remoteConfigSubscription)||e.dispose(),this._remoteConfigSubscription=void 0,null==(t=this._surveyEventReceiver)||t.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._renderTimeouts.forEach(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var s=localStorage.key(i);(null!=s&&s.startsWith("seenSurvey_")||null!=s&&s.startsWith("inProgressSurvey_"))&&t.push(s)}t.forEach(e=>localStorage.removeItem(e))}catch(e){}}loadIfEnabled(){if(!this._disposed&&this._client){var e=this._config;if(!this._surveyManager)if(this._isInitializingSurveys)cl.info("Already initializing surveys, skipping...");else if(e.disableSurveys)cl.info(pu);else if(e.cookielessMode&&this._configSource.isOptedOut())cl.info("Not loading surveys in cookieless mode without consent.");else{var t=this._configSource.getExtensions();if(t){if(!kt(this._isSurveysEnabled)||e.advancedEnableSurveys){var i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0;try{var s=t.generateSurveys;if(s)return this._completeSurveyInitialization(s,i),void(this._isInitializingSurveys=!1);var r=t.loadExternalDependency;if(!r)return this._handleSurveyLoadError(De),void(this._isInitializingSurveys=!1);r(e=>{try{if(this._disposed)return;var t=this._configSource.getExtensions();e||null==t||!t.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",e):this._completeSurveyInitialization(t.generateSurveys,i)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError("Error initializing surveys",e),e}}}else cl.error("PostHog Extensions not found.")}}}_completeSurveyInitialization(e,t){this._disposed||(this._surveyManager=e(t),this._surveyEventReceiver=this._configSource.createEventReceiver(),cl.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0}))}_handleSurveyLoadError(e,t){cl.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(t=>t!==e)}}getSurveys(e,t){var i;void 0===t&&(t=!1);var s=null!==(i=this._client)&&void 0!==i?i:this._initialClientState;if(s&&!this._disposed){if(this._config.disableSurveys)return cl.info(pu),e([]);var r=s.kv.get(te);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)this._getSurveysInFlightPromise.then(t=>{this._disposed||e(t.surveys,t.context)}).catch(e=>cl.error("Error in survey callback",e));else{var n=this._sendSurveysRequest("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(s,e)}catch(e){return cl.error("Error processing surveys response",e),this._handleSurveyResponse(s,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(s,{statusCode:0,error:e}));this._getSurveysInFlightPromise=n;var o=()=>{this._getSurveysInFlightPromise===n&&(this._getSurveysInFlightPromise=null)};n.then(t=>{o(),this._disposed||e(t.surveys,t.context)},o).catch(e=>cl.error("Error in survey callback",e))}}}_sendSurveysRequest(e,t){var i=this._client;return i?i.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:new Error(_u)}))}_handleSurveyResponse(e,t){var i;if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:_u}};var s=t.statusCode;if(200!==s||!t.json){var r="Surveys API could not be loaded, status: "+s;return 0!==s?cl.error(r):t.error||cl.warn(r),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this._lastSurveyRefreshFailedAt=null;var n=t.json.surveys||[],o=n.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(Za(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e)));return o.length>0&&(null==(i=this._surveyEventReceiver)||i.register(o)),e.kv.set({[te]:n,[ie]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e,t,i=null==(e=null!==(t=this._client)&&void 0!==t?t:this._initialClientState)?void 0:e.kv.get(ie);return Ft(i)&&Date.now()-i>3e5}_isSurveyRefreshBackingOff(){return Ft(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;dl({id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){cl.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!Pt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);cl.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys(i=>{var s;t=null!==(s=i.find(t=>t.id===e))&&void 0!==s?s:null}),t}_checkSurveyEligibility(e){if(Pt(this._surveyManager))return{eligible:!1,reason:_u};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){if(Pt(this._surveyManager))return{eligible:!1,reason:_u};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Pt(this._surveyManager))return cl.warn("init was not called"),{visible:!1,disabledReason:_u};var t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Pt(this._surveyManager)?(cl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:_u})):new Promise(i=>{this.getSurveys(t=>{var s,r=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(r){var n=this._checkSurveyRenderability(r);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s;if(Pt(this._surveyManager))cl.warn("init was not called");else{var r="string"==typeof e?this._getSurveyById(e):e;if(null!=r&&r.id)if(hl.includes(r.type)){var n=null==Je?void 0:Je.querySelector(t);if(n)if(null!=(s=r.appearance)&&s.surveyPopupDelaySeconds){cl.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var e,t;this._renderTimeouts.delete(o),this._disposed||(cl.info("Rendering survey "+r.id+" with delay of "+(null==(e=r.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(r,n,i),cl.info("Survey "+r.id+" rendered"))},1e3*r.appearance.surveyPopupDelaySeconds);this._renderTimeouts.add(o)}else this._surveyManager.renderSurvey(r,n,i);else cl.warn("Survey element not found")}else cl.warn("Surveys of type "+r.type+" cannot be rendered in the app");else cl.warn("Survey not found")}}displaySurvey(e,t){var i;if(Pt(this._surveyManager))cl.warn("init was not called");else{var r=this._getSurveyById(e);if(r){var n=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=s({},r,{appearance:s({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==No&&t.initialResponses&&cl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this._checkSurveyEligibility(r);if(!o.eligible)return void cl.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else cl.warn("Survey not found")}}cancelPendingSurvey(e){Pt(this._surveyManager)?cl.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||null==e.handlePageUnload||e.handlePageUnload()}};function vu(e,t,i){if(Pt(e))return!1;switch(i){case"exact":return e===t;case"contains":var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var fu=class{constructor(e){this._instance=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Ua,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;kt(null==(e=this._instance)?void 0:e._addCaptureHook)||(this._captureHookUnsubscribe=null==(t=this._instance)?void 0:t._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;null==(e=this._captureHookUnsubscribe)||e.call(this),this._captureHookUnsubscribe=void 0,this._debugEventEmitter=new Ua}register(e){var t,i;if(!kt(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null==(t=e.steps)||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null!=(i=this._instance)&&i.autocapture)){var s=new Set;this._actionRegistry.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&s.add(e.selector)})}),this._instance.autocapture.setElementSelectors(s)}}replace(e){this._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry.forEach(e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)})}_addActionHook(e){this.onAction("actionCaptured",t=>e(t))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!vu(s,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var i;if(null==t||!t.href)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some(e=>vu(e.href,t.href,t.href_matching||"exact"));var r,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&vu((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some(e=>vu(e.text,t.text,t.text_matching||"exact")||vu(e.$el_text,t.text,t.text_matching||"exact"));var r,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(r=function(e){for(var t,i=[],s=/(?::|")text="(.*?)"/g;!Pt(t=s.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",r.some(e=>vu(e,n,o)))}_checkStepSelector(e,t){var i,s;if(null==t||!t.selector)return!0;if(null!=e&&null!=(i=e.properties)&&null!=(i=i.$element_selectors)&&i.includes(t.selector))return!0;var r=(null==e||null==(s=e.properties)?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||sl(t.properties.reduce((e,t)=>{var i=yt(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}},mu=class{constructor(e){var t;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,this._sessionIdUnsubscribe=null==(t=this._instance)||null==t.onSessionId?void 0:t.onSessionId(e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&sl(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach(e=>{var s;null==(s=e.conditions)||null==(s=s[t])||null==(s=s.values)||s.forEach(t=>{if(null!=t&&t.name){var s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}_getMatchingItems(e,t,i){var s=(i===$o?this._eventToItems:this._cancelEventToItems).get(e),r=[];return this._getItems(e=>{r=e.filter(e=>null==s?void 0:s.includes(e.id))}),r.filter(s=>{var r,n=null==(r=s.conditions)||null==(r=r[i])||null==(r=r.values)?void 0:r.find(t=>t.name===e);return this._doesEventMatchFilter(n,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){var i;kt(null==(i=this._instance)?void 0:i._addCaptureHook)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){var i=e.filter(e=>{var t;return null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)?void 0:t.length});if(t&&this._actionToItems.clear(),0!==i.length){this._actionMatcher||(this._actionMatcher=new fu(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));var s=[];i.forEach(e=>{var t;null==(t=e.conditions)||null==(t=t.actions)||t.values.forEach(t=>{if(s.push(t),t.name){var i,r=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];r.includes(e.id)||r.push(e.id),this._actionToItems.set(t.name,r)}})}),t?this._actionMatcher.replace(s):this._actionMatcher.register(s)}else{var r;t&&(null==(r=this._actionMatcher)||r.replace([]))}}_mergeItemMaps(e,t){t.forEach((t,i)=>{var s,r=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{r.includes(e)||r.push(e)}),e.set(i,r)})}_setupEventBasedItems(e,t){var i,s,r=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),n=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}),o=this._buildEventToItemMap(e,$o),a=this._buildEventToItemMap(e,Oo);t?(this._eventToItems=o,this._cancelEventToItems=a):(this._mergeItemMaps(this._eventToItems,o),this._mergeItemMaps(this._cancelEventToItems,a)),(0!==r.length||0!==n.length)&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null==(s=this._instance)?void 0:s._addCaptureHook((e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s,r=this._getLogger(),n=(null==t||null==(i=t.properties)?void 0:i.$survey_id)||(null==t||null==(s=t.properties)?void 0:s.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this._activationOutcome(e,n);if("consume"===o)return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this._deactivateItems([n]);if("persist"===o)return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this._persistActivation(n),void this._clearActivationTimestamps([n])}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,Oo);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(e=>e.id)}),this._deactivateItems(a.map(e=>e.id)),a.forEach(e=>this._cancelPendingItem(e.id)))}if(this._eventToItems.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var l=this._getMatchingItems(e,t,$o);this._activateItems(l.map(e=>e.id))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){var t;if(0!==e.length){var i=!(null==(t=this._instance)||null==t.get_session_id||!t.get_session_id()),s=[];for(var r of e)i&&this._shouldPersistArmedActivation(r)?this._persistActivation(r)&&this._recordActivationTimestamp(r):s.push(r);s.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...s])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()})}}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);var t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));var i=this._getRawPersistedActivatedIds(),s=i.filter(e=>!t.has(e));s.length!==i.length&&(this._setActivatedItems(s),0===s.length&&this._clearActivationSession()),this._clearActivationTimestamps(e)}_getRawActivationTimestamps(){var e,t=this._getActivationTimestampsKey();if(!t)return{};var i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t];return i&&"object"==typeof i?i:{}}_recordActivationTimestamp(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps();this._writeActivationTimestamps(s({},t,{[e]:Date.now()}))}}_clearActivationTimestamps(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps(),i={},s=!1;for(var r of Object.entries(t)){var n=r[0],o=r[1];e.includes(n)?s=!0:i[n]=o}s&&(St(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(this._getPersistedActivatedIds().includes(e)){var t=this._getRawActivationTimestamps()[e];return Ft(t)?t:void 0}}_getRawPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,i=this._getRawPersistedActivatedIds();if(0===i.length)return[];var s=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this._getActivatedSessionKey()],r=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();return r&&s===r?i:[]}_stampActivationSession(){var e,t=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();t&&this._setActivatedSession(t)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this._getActivatedSessionKey()];if(i&&i!==e){var s=this._getRawPersistedActivatedIds(),r=this._getRawActivationTimestamps();s.length>0&&(this._setActivatedItems([]),s.filter(e=>Ft(r[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,i;null==(e=this._sessionIdUnsubscribe)||e.call(this),this._sessionIdUnsubscribe=void 0,null==(t=this._captureHookUnsubscribe)||t.call(this),this._captureHookUnsubscribe=void 0,null==(i=this._actionMatcher)||i.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},yu=class extends mu{constructor(e){super(e)}_getActivatedKey(){return se}_getActivatedSessionKey(){return re}_getActivationTimestampsKey(){return ne}_writeActivationTimestamps(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[ne]:e})}_clearActivationTimestampsStore(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(ne)}_shouldPersistArmedActivation(e){var t,i;this._getItems(t=>{i=t.find(t=>t.id===e)});var s=null==(t=i)||null==(t=t.appearance)?void 0:t.surveyPopupDelaySeconds;return Ft(s)&&s>0}_getShownEventName(){return Do}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return cl}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[se]:e})}_setActivatedSession(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[re]:e})}_clearActivatedSession(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(re)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){var i;return this._getItems(e=>{i=e.find(e=>e.id===t)}),!i||function(e){var t;return Za(e)&&!(null==(t=e.conditions)||null==(t=t.events)||!t.repeatedActivation)||"always"===e.schedule}(i)?e===Do?"consume":"ignore":e===Do?"persist":e===Bo||e===qo?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},bu=class{constructor(e){this._instance=e}initialize(){}get(e){if("string"==typeof e)return this._instance.get_property(e);var t={};for(var i of e){var s=this._instance.get_property(i);kt(s)||(t[i]=s)}return t}set(e,t){this._instance.register("string"==typeof e?{[e]:t}:e)}remove(e){"string"!=typeof e?e.forEach(e=>this._instance.unregister(e)):this._instance.unregister(e)}},wu=class{constructor(e){this._instance=e}get(){var e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var e=null==nt?void 0:nt.__PosthogExtensions__;if(e){var t=e.generateSurveys,i=e.loadExternalDependency;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:i?e=>i(this._instance,"surveys",e):void 0}}}createEventReceiver(){return new yu(this._instance)}},Su=null!=Ge&&Ge.location?ro(Ge.location.hash,"__posthog")||ro(location.hash,"state"):null,ku="_postHogToolbarParams",Cu=hr("[Toolbar]"),xu=hr("[FeatureFlags]"),Eu=class{constructor(e,t){void 0===t&&(t=!1),this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,s,r,n,o;return{bootstrap:{featureFlags:null==(i=e.bootstrap)?void 0:i.featureFlags,featureFlagPayloads:null==(s=e.bootstrap)?void 0:s.featureFlagPayloads},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(r=e.remote_config_refresh_interval_ms)&&void 0!==r?r:3e5,requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(o=e.evaluation_contexts)&&void 0!==o?o:e.evaluation_environments)&&void 0!==n?n:[],flagKeys:yt(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(xu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),kt(e.flag_keys)||yt(e.flag_keys)||xu.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}},Pu=hr("[FeatureFlags]"),Fu=hr("[FeatureFlags]",{debugEnabled:!0}),Iu="\" failed. Feature flags didn't load in time.",Tu="connection_error",Ru=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Au=e=>{var t={};for(var i of vr(e||{})){var s=i[1];s&&(t[i[0]]=s)}return t},Mu=e=>$t(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),Lu=hr("[Error tracking]"),$u="webkit-masked-url:",Ou=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",$u],Du=["__firefox__","__gCrWeb"],Bu="Refusing to render web experiment since the viewer is a likely bot",qu={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>el(t,e),not_regex:(e,t)=>!el(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Hu=hr("[Conversations]"),Nu="Conversations not available yet.";function zu(e,t){var i,r,n,o,a,l,u,c=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,d=null!==(r=null==e?void 0:e.maxBufferSize)&&void 0!==r?r:100,h=null!=t&&t.consoleCapture?void 0:null!==(n=null==e?void 0:e.maxLogsPerInterval)&&void 0!==n?n:1e3,_=kt(h)?Math.max(d,2048):Math.max(d,h),p=s({},function(){var e="",t="";try{var i=null==Qe?void 0:Qe.userAgent;if(i){var r=Ni(i);e=r[0],t=r[1]}}catch(e){}return function(e,t){var i=function(e){if(e)return{}.hasOwnProperty.call(Xs,e)?Xs[e]:e}(e);return s({},i?{"os.name":i}:{},t?{"os.version":t}:{})}(e,t)}(),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(o=null!==(a=null==p?void 0:p["service.name"])&&void 0!==a?a:null==e?void 0:e.serviceName)&&void 0!==o?o:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(l=null==p?void 0:p["service.version"])&&void 0!==l?l:null==e?void 0:e.serviceVersion,environment:null!==(u=null==p?void 0:p["deployment.environment"])&&void 0!==u?u:null==e?void 0:e.environment,resourceAttributes:p,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:d,maxQueueSize:_,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var ju=["debug","log","warn","error","info"],Vu="console",Wu="__posthogHandledLogsRequestError",Uu=(e,t)=>{var i=e instanceof Error?e:new Error(t);return i[Wu]=!0,i},Gu=e=>!!e&&"object"==typeof e&&!0===e[Wu],Ku={featureFlags:class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=Pu,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._onOnline=()=>{var e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t=this._refreshIntervalMs;kt(t)||this._config.remoteRequestsDisabled||!Je||"hidden"===Je.visibilityState||Date.now()-(null!==(e=this._lastRefreshAt)&&void 0!==e?e:0)<t||(this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onVisibilityChange=()=>{"visible"===(null==Je?void 0:Je.visibilityState)&&this._refreshIfDue()},"get"in e?this._configSource=e:(this._instance=e,this._mutableConfigSource=new Eu(e.config,e._shouldDisableFlags()),this._configSource=this._mutableConfigSource)}updateConfig(e,t){var i;null==(i=this._mutableConfigSource)||i.update(e,t),this._client&&this._syncAutomaticRefresh()}setup(e){return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),hu(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return Ge&&kr(Ge,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_syncAutomaticRefresh(){var e=this._config.refreshIntervalMs,t=!this._config.remoteRequestsDisabled&&Je&&!kt(e)&&e>0?e:void 0;t!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),kt(t)||(this._refreshIntervalMs=t,this._scheduleNextRefresh(),null!=Je&&Je.addEventListener&&kr(Je,Ne,this._onVisibilityChange)))}_scheduleNextRefresh(){kt(this._refreshIntervalMs)||(kt(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){kt(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null==Je||null==Je.removeEventListener||Je.removeEventListener(Ne,this._onVisibilityChange)),this._refreshIntervalMs=void 0,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._client&&(this._clearDebouncer(),null==(e=this._dynamicProperties)||e.dispose(),this._dynamicProperties=void 0,null==(t=this._crossTabPersistenceUnsubscribe)||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null==Ge||Ge.removeEventListener("online",this._onOnline),this._client=void 0)}get _config(){return this._configSource.get()}_prop(e){var t;return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:null==(t=this._client)?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!kt(null==(e=this._client)?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null==(t=this._client)?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){var s;if(null!=(s=this._instance)&&s.persistence&&e.$enabled_feature_flags){var r=this._prop("$enabled_feature_flags")||{},n=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(e=>{var t=e[1];return!(null!=t&&t.failed)}).map(e=>e[0]):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,u=l?a:i&&!yt(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),c=this._prop("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},h=l||i?u:Array.from(new Set([...Object.keys(c),...Object.keys(d)])),_=!l&&!i,p=!!_||u,g=!!_||h,v={[V]:p,[j]:p,[G]:g};for(var f of(e.$feature_flag_details&&(v[U]=p),[K,ve,Q]))kt(e[f])||(v[f]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(v)}}_remove(e){this._persist(()=>{var t;return null==(t=this._client)?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){var e={};for(var t of[V,G,K,J]){var i=this._prop(t);kt(i)||(e[t]=i)}this._baseEventProperties=e;var r=s({},e),n=this._prop(j);if(n)for(var o of Object.entries(n))r["$feature/"+o[0]]=o[1];this._eventPropertiesWithFlagValues=r}_isCacheStale(){var e=this._config.cacheTtlMs;if(!e||0>=e)return!1;var t=this._prop(ve);return"number"!=typeof t||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e=this._config.evaluationContexts;return null!=e&&e.length?e.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}_getValidFlagKeys(){var e=this._config.flagKeys;if(!kt(e))return e.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t,i=this._config,s=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var r,n,o=null!==(r=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==r?r:{},a=Object.keys(s).filter(e=>!kt(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),l=Object.keys(o).filter(e=>a[e]).reduce((e,t)=>(e[t]=o[t],e),{});return this._receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,i){var r,n,o=null!=i&&i.merge&&null!==(r=this._prop("$enabled_feature_flags"))&&void 0!==r?r:{},a=null!=i&&i.merge&&null!==(n=this._prop("$feature_flag_payloads"))&&void 0!==n?n:{},l=s({},o,e),u=s({},a,t),c={};for(var d of Object.entries(l)){var h=d[0],_=d[1];c[h]={key:h,enabled:$s(_),variant:Os(_),reason:void 0,metadata:kt(null==u?void 0:u[h])?void 0:{id:0,version:void 0,description:void 0,payload:u[h]}}}this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(U),t=this._prop(J),i=this._prop(Y);if(!i&&!t)return e||{};var r=gr({},e||{});for(var n of[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])]){var o,a,l=r[n],u=null==t?void 0:t[n],c=kt(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=kt(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,h=null==i?void 0:i[n],_=s({},l,{enabled:c,variant:c?null!=d?d:null==l?void 0:l.variant:void 0});c!==(null==l?void 0:l.enabled)&&(_.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(_.original_variant=null==l?void 0:l.variant),h&&(_.metadata=s({},null==l?void 0:l.metadata,{payload:h,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=_}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this._override_warning=!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{var s=e[i];return{key:i,enabled:$s(s),variant:Os(s),payload:Ls(t[i])}})}getFlagVariants(){var e=this._prop(j),t=this._prop(J);if(!t)return e||{};for(var i=gr({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(G),t=this._prop(Y);if(!t)return e||{};for(var i=gr({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(this._logger.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error("Error while running feature flags reloading callback",e)}}),this._reloadDebouncer=setTimeout(()=>{this._callFlagsEndpoint()},5)))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(_e)}_callFlagsEndpoint(e){this._clearDebouncer();var t=this._client;if(t&&!this._config.remoteRequestsDisabled&&!this._hasStatusZeroCircuitBreakerTripped())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var i={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:s({},t.initialPersonProperties,this._prop("$stored_person_properties")||{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this._prop(Z),timezone:bo()};kt(t.deviceId)||(i.$device_id=t.deviceId),(null!=e&&e.disableFlags||this._config.featureFlagsDisabled)&&(i.disable_flags=!0);var r=this._getValidEvaluationEnvironments();r.length&&(i.evaluation_contexts=r);var n=this._getValidFlagKeys();kt(n)||(i.flag_keys=n);var o=this._config.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this._requestGeneration;this._requestInFlight=!0;var u=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},c=e=>{this._requestInFlight=!1,l===this._requestGeneration?(this._set({[ge]:[Tu]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),u()):u()};try{t.sendRequest(a,{target:"flags",method:"POST",body:i,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(e=>{var t,s,r=null!==(t=e.json)&&void 0!==t?t:{},n=200!==e.statusCode;if(this._requestInFlight=!1,l===this._requestGeneration){if(this._trackStatusZeroReachability(e.statusCode),n||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),!i.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!n;var a=[];e.error?a.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?Tu:"unknown_error"):200!==e.statusCode&&a.push("api_error_"+e.statusCode),r.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var c=!(null==(s=r.quotaLimited)||!s.includes("feature_flags"));c&&a.push("quota_limited"),this._set({[ge]:a}),c?this._logger.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."):i.disable_flags||this._receivedFeatureFlags(r,n,{partialResponse:o}),u()}}else u()}).catch(c)}catch(e){c(e)}}}_hasStatusZeroCircuitBreakerTripped(){return no(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=oo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}}else this._logger.warn('getFeatureFlag for key "'+e+Iu)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t;return null==(t=this.getFeatureFlagResult(e,{send_event:!1}))?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i,r=this.getFlagVariants(),n=e in r,o=r[e],a=this.getFlagPayloads()[e],l=String(o),u=this._prop("$feature_flag_request_id")||void 0,c=this._prop("$feature_flag_evaluated_at")||void 0,d=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var h,_=null==(h=this._client)?void 0:h.session.sessionId,p=this._prop(pe);_&&_!==p&&(d={},i=_)}if(t.send_event||!("send_event"in t))if(e in d&&d[e].includes(l))i&&this._set({[_e]:d,[pe]:i});else{var g,v,f,m,y,b,w,S,k,C,x,E,P;yt(d[e])?d[e].push(l):d[e]=[l],this._set(s({[_e]:d},i?{[pe]:i}:{}));var F=this.getFeatureFlagDetails(e),I=[...null!==(g=this._prop("$feature_flag_errors"))&&void 0!==g?g:[]];kt(o)&&I.push("flag_missing");var T={$feature_flag:e,$feature_flag_response:o,$feature_flag_payload:null!=a?a:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:null!==(v=null==(f=this._config.bootstrap)||null==(f=f.featureFlags)?void 0:f[e])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(m=null==(y=this._config.bootstrap)||null==(y=y.featureFlagPayloads)?void 0:y[e])&&void 0!==m?m:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};kt(null==F||null==(b=F.metadata)?void 0:b.has_experiment)||(T.$feature_flag_has_experiment=F.metadata.has_experiment),kt(null==F||null==(w=F.metadata)?void 0:w.version)||(T.$feature_flag_version=F.metadata.version);var R=null!==(S=null==F||null==(k=F.reason)?void 0:k.description)&&void 0!==S?S:null==F||null==(C=F.reason)?void 0:C.code;R&&(T.$feature_flag_reason=R),null!=F&&null!=(x=F.metadata)&&x.id&&(T.$feature_flag_id=F.metadata.id),kt(null==F?void 0:F.original_variant)&&kt(null==F?void 0:F.original_enabled)||(T.$feature_flag_original_response=kt(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(E=F.metadata)&&E.original_payload&&(T.$feature_flag_original_payload=null==F||null==(P=F.metadata)?void 0:P.original_payload),I.length&&(T.$feature_flag_error=I.join(",")),this._captureFeatureFlagCalled(T)}else i&&this._set({[_e]:d,[pe]:i});if(n)return{key:e,enabled:!!o,variant:"string"==typeof o?o:void 0,payload:Ls(a)}}}else this._logger.warn('getFeatureFlagResult for key "'+e+Iu)}_captureFeatureFlagCalled(e){try{var t;null==(t=this._client)||t.capture("$feature_flag_called",e).catch(e=>{this._logger.error("Failed to capture feature flag call",e)})}catch(e){this._logger.error("Failed to capture feature flag call",e)}}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var i=this;return n(function*(){var s=i._client;if(s){var r={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},n=i._getValidEvaluationEnvironments();n.length&&(r.evaluation_contexts=n);var o,a=i._getValidFlagKeys();kt(a)||(r.flag_keys=a);try{var l;o=(null==(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(o)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}}})()}isFeatureEnabled(e,t){if(void 0===t&&(t={}),t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+Iu),t.defaultValue;var i=this.getFeatureFlag(e,t);return kt(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this._receivedFeatureFlags(e,t,i)}_receivedFeatureFlags(e,t,i){if(this._client){this._hasLoadedFlags=!0;var r=function(e,t,i,r,n,o){void 0===t&&(t={}),void 0===i&&(i={}),void 0===r&&(r={}),void 0===o&&(o=Pu);var a=((e,t)=>{var i=e.flags;return i?s({},e,{featureFlags:Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!kt(null==(t=i[e].metadata)?void 0:t.payload)}).map(e=>{var t;return[e,null==(t=i[e].metadata)?void 0:t.payload]}))}):(e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e)})(e,o),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,h=e.evaluatedAt;if(yt(u)){o.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var _={};if(u)for(var p=0;u.length>p;p++)_[u[p]]=!0;return{[V]:u,[j]:_,[Q]:!1}}var g=u,v=c,f=l;if(null!=n&&n.partialResponse){var m=Object.keys(g),y=v||{};g=s({},t,g),v=s({},i,y),m.forEach(e=>{var t;e in y||null==(t=v)||delete t[e]}),f=s({},r,f)}else if(e.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter(e=>{var t;return!(null!=(t=l[e])&&t.failed)}));g=s({},t,Object.fromEntries(Object.entries(g).filter(e=>b.has(e[0]))));var w=Object.fromEntries(Object.entries(v||{}).filter(e=>b.has(e[0])));v=s({},i,w),b.forEach(e=>{var t;e in w||null==(t=v)||delete t[e]}),f=s({},r,Object.fromEntries(Object.entries(f||{}).filter(e=>b.has(e[0]))))}else g=s({},t,g),v=s({},i,v),f=s({},r,f);return s({[V]:Object.keys(Au(g)),[j]:g||{},[G]:v||{},[U]:f||{},[Q]:!0===e.minimalFlagCalledEvents},d?{[K]:d}:{},h?{[ve]:h}:{})}}(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(r)if(!1===(null==i?void 0:i.persist)){var n=!kt(this._client.kv.get(j));this._bootstrapState=r,n||this._set(r)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(r,e,!(null==i||!i.partialResponse)),this._set(r);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),this._logger.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([J,Y]),this._fireFeatureFlagsCallbacks(),void Fu.info("All overrides cleared");if(yt(e))return this._set({[J]:Ru(e)}),this._fireFeatureFlagsCallbacks(),void Fu.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);var s={},r=i.flags,n=i.payloads;return r&&(s[J]=yt(r)?Ru(r):r),n&&(s[Y]=n),Object.keys(s).length&&this._set(s),!1===r&&!1===n?this._remove([J,Y]):!1===r?this._remove(J):!1===n&&this._remove(Y),this._fireFeatureFlagsCallbacks(),!1===r?Fu.info("Flag overrides cleared"):r&&Fu.info("Flag overrides set",{flags:r}),void(!1===n?Fu.info("Payload overrides cleared"):n&&Fu.info("Payload overrides set",{payloads:n}))}if(e&&"object"==typeof e)return this._set({[J]:e}),this._fireFeatureFlagsCallbacks(),void Fu.info("Flag overrides set",{flags:e});this._logger.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this._logger.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,s=t.flagVariants;try{e(i,s)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var r,n=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),i&&(a.$feature_enrollment_stage=i);var l=s({},this.getFlagVariants(),{[e]:t});null==(r=this._instance)||null==(r=r.persistence)||r.markCrossTabFeatureFlagChanges({[V]:[e],[j]:[e],[X]:Object.keys(o)}),this._set({[V]:Object.keys(Au(l)),[j]:l,[X]:s({},this._prop("$stored_person_properties")||{},o)}),this._fireFeatureFlagsCallbacks();try{var u;null==(u=this._client)||u.capture("$feature_enrollment_update",a).catch(e=>{this._logger.error("Failed to capture early access feature enrollment",e)})}catch(e){this._logger.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._prop(W);!s||t?this._getEarlyAccessFeatures(e,i):e(s)}_getEarlyAccessFeatures(e,t){var i=this;return n(function*(){var s=i._client;if(s){var r,n=t?"&"+t.map(e=>"stage="+e).join("&"):"";try{var o=yield s.sendRequest("/api/early_access_features/?token="+s.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,i._set({[W]:r})}catch(e){return void i._logger.error("Early access feature request failed",e)}try{e(r)}catch(e){i._logger.error("Early access feature callback failed",e)}}})()}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,s=t.flagVariants;this.featureFlagEventHandlers.forEach(t=>{try{t(i,s,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}})}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._prop("$stored_person_properties")||{},r=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in i||(o[a]=n[a]));this._set({[X]:s({},i,o,r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=s({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[X]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){void 0===e&&(e=!0),this._remove(X),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._prop("$stored_group_properties")||{},r=s({},i);for(var n of Object.keys(e))r[n]=s({},i[n],e[n]);this._set({[Z]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop("$stored_group_properties")||{};this._set({[Z]:s({},t,{[e]:{}})})}else this._remove(Z)}reset(){this._requestGeneration++,this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0}}},Qu={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return"awaiting_config"===this._recordingStatus||"missing_config"===this._recordingStatus?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=su,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var e;if(null==Je||!Je.visibilityState||"visible"===Je.visibilityState)return!0;var t=null==Ge||null==(e=Ge.performance)||null==e.getEntriesByType?void 0:e.getEntriesByType("visibility-state");return!(null!=t&&t.length)||t.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e;"visible"===(null==Je?void 0:Je.visibilityState)&&(this._documentWasEverVisible=!0,null==(e=this._lazyLoadedSessionRecording)||null==e.setDocumentWasEverVisible||e.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw nu.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this._config.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=Je&&Je.addEventListener&&kr(Je,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose(e){var t=(void 0===e?{}:e).discardBufferedEvents,i=void 0!==t&&t;this._sessionRecordingDisposed=!0,null==Je||null==Je.removeEventListener||Je.removeEventListener("visibilitychange",this._onVisibilityChange),i?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(F))||!e.enabled),i=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return Ge&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!(this._sessionRecordingDisposed||this._isRecordingEnabled&&null!=(t=this._lazyLoadedSessionRecording)&&t.isStarted)){var i=!kt(Object.assign)&&!kt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),nu.info("starting")):(this._recordingStatus=su,this.stopRecording())}}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=ru),null!=nt&&null!=(t=nt.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=nt.__PosthogExtensions__)&&i.initSessionRecording)this._onScriptLoaded(e);else{var s,r=this._instance.sessionManager;null==(s=nt.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,t=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===r)return t?(this._instance.register_for_session({[Fe]:!0}),nu.error("could not load recorder",t)):void this._onScriptLoaded(e);this._recordingStatus=su})}}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_discardRecording(e){var t,i;void 0===e&&(e=!1),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=void 0,null==(i=this._lazyLoadedSessionRecording)||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null==(e=this._persistence)||e.unregister(D),null==(t=this._persistence)||t.unregister(T)}_validateSampleRate(e,t){if(Pt(e))return null;var i,s=Ft(e)?e:parseFloat(e);return"number"!=typeof(i=s)||!Number.isFinite(i)||0>i||i>1?(nu.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):s}_persistRemoteConfig(e){if(this._persistence){var t,i,r=this._persistence,n=()=>{var t,i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Pt(a)&&this._resetSampling();var l=null==i?void 0:i.minimumDurationMilliseconds;r.register({[F]:s({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:s({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:a,minimumDurationMilliseconds:kt(l)?null:l,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(n)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):("awaiting_config"===this._recordingStatus&&(this._recordingStatus="missing_config",nu.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):nu.warn("log called before recorder was ready")}get _scriptName(){var e;return(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.get_property("$session_recording_remote_config"))||null==(e=e.scriptConfig)?void 0:e.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t=this._instance.get_property(F);if(!t)return!1;try{e="object"==typeof t?t:JSON.parse(t)}catch(e){return nu.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!Pt(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}_onScriptLoaded(e){var t,i,s;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(null==(t=nt.__PosthogExtensions__)||!t.initSessionRecording)return nu.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Fe]:!0});var r;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(r=nt.__PosthogExtensions__)?void 0:r.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if("missing_config"===this._recordingStatus||"awaiting_config"===this._recordingStatus)return;return this._recordingStatus="awaiting_config",nu.info("persisted remote config is stale, requesting fresh config before starting"),void new Uo(this._instance).load()}this._recordingStatus=ru,null==(i=(s=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||i.call(s,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=su}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null==(e=this._persistence)||e.register({[A]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(e=this._persistence)||e.register({[R]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({["url"===e?M:L]:!0}),null==(i=this._lazyLoadedSessionRecording)||i.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e;null==(e=this._lazyLoadedSessionRecording)||null==e.flushBeforeIdentityReset||e.flushBeforeIdentityReset()}}},Ju={autocapture:class extends Wl{constructor(e){super(new Ul(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){var e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(dr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,dr.info("History API monitoring stopped")}monitorHistoryChanges(){Ge&&Ge.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(e){var t;if(Ge&&(null==(t=Ge.history[e])||!t.__posthog_wrapped__)){var i=this;Jl(Ge.history,e,t=>function(s,r,n){t.call(this,s,r,n),i._capturePageview(e)})}}_getCurrentLocation(){var e=null==Ge?void 0:Ge.location;if(null!=e&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}_getCaptureOptions(){var e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:wt(e)?e:{}}_shouldCaptureHashChanges(e){return void 0===e&&(e=this._getCaptureOptions()),!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){var t=this._getCaptureOptions(),i=this._lastLocation;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this._shouldCaptureHashChanges(t)&&e.hash!==i.hash))}_capturePageview(e){try{var t=this._getCurrentLocation();if(!t)return;this._hasLocationChanged(t)&&this._instance.capture(je,{navigation_type:e}),this._lastLocation=t}catch(t){dr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};kr(Ge,"popstate",e),this._popstateListener=()=>{Ge&&Ge.removeEventListener("popstate",e)}}}_setupHashchangeListener(){if(!this._hashchangeListener){var e=()=>{this._capturePageview("hashchange")};kr(Ge,"hashchange",e),this._hashchangeListener=()=>{Ge&&Ge.removeEventListener("hashchange",e)}}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[y]),this.rageclicks=new ql(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return wt(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Pt(this._config.capture_heatmaps)?Pt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;ou.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[y]:i}),this._enabledServerSide=i,this.startIfEnabled()}}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){au(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(Je)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){Ge&&Je&&(this._flushHandler=this._flush.bind(this),kr(Ge,ze,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==Ge?void 0:Ge.event)),kr(Je,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==Ge?void 0:Ge.event)),kr(Je,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new jn(this.instance,Nn,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),kr(Je,Ne,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;Ge&&Je&&(this._flushHandler&&Ge.removeEventListener(ze,this._flushHandler),this._onClickHandler&&Je.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&Je.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&Je.removeEventListener(Ne,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var s=e;s&&sn(s)&&!rn(s,"body");){if(s===i)return!1;var r=void 0;try{var n,o,a;r=null==(n=null!==(o=null==(a=s.ownerDocument)?void 0:a.defaultView)&&void 0!==o?o:Ge)?void 0:n.getComputedStyle(s).position}catch(e){return!1}if(lt(t,r))return!0;s=vn(s)}return!1}(hn(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:s),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var i;if(void 0===t&&(t="click"),!tn(e.target)&&au(e)){var r=this._getProperties(e,t);null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&kn(hn(e),this.instance.config.rageclick)&&this._capture(s({},r,{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!tn(e.target)&&au(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(e){if(Ge){var t=this._config.disable_capture_url_hashes?es(Ge.location.href):Ge.location.href,i=this._config.custom_personal_data_properties,s=so(t,this._config.mask_personal_data_properties?[...ao,...i||[]]:[],uo);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!St(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:jn,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",s({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>s({},e,{["$web_vitals_"+t.name+"_event"]:s({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{}))),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Pt(null==e?void 0:e.name)||Pt(null==e?void 0:e.value))Xl.error("Invalid metric received",e);else{var i="string"==typeof e.navigationURL?e.navigationURL:void 0,r=this._maskedURL(i);if(!kt(r)){var n=Ft(e.navigationId)||"string"==typeof e.navigationId?"navigation:"+e.navigationId:"url:"+r;if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),kt(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=r),this._buffer.firstMetricTimestamp=kt(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;var o=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),a=s({},e,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});if(delete a.entries,wt(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){var l={};for(var u of iu){var c="url"===u&&"string"==typeof e.attribution[u]?this._maskedURL(e.attribution[u]):e.attribution[u];kt(c)||(l[u]=c)}a.attribution=l}else delete a.attribution;kt(o)||(a.$session_id=o.sessionId,a.$window_id=o.windowId),this._buffer.metrics.push(a),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else Xl.error("Ignoring metric with value >= "+this._maxAllowedValue,e)}}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,n=!1,o=nt.__PosthogExtensions__,a=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(null==a?void 0:a[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&kt(a)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!kt(l)){var u=l.withoutAttribution,c=this.attributionMetrics;n=!kt(u),e=c.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,t=c.indexOf("CLS")>-1?l.onCLS:(null==u?void 0:u.onCLS)||l.onCLS,i=c.indexOf("FCP")>-1?l.onFCP:(null==u?void 0:u.onFCP)||l.onFCP,r=c.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(e&&t&&i&&r){var d={reportSoftNavs:this.useSoftNavs},h=n&&this.attributionMetrics.indexOf("INP")>-1?s({},d,{includeProcessedEventEntries:!1}):d;this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),d),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),d),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),d),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this),h),this._initialized=!0}else Xl.error("web vitals callbacks not loaded - not starting")}},this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[k]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=wt(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return Pt(i)?(null==(t=this._instance.persistence)?void 0:t.props.$web_vitals_allowed_metrics)||eu:i}get flushToCaptureTimeoutMs(){return(wt(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var e=wt(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return Tt(e)?e?eu:[]:yt(e)?e:tu}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var e;return null!==(e=wt(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0)&&void 0!==e&&e}get _maxAllowedValue(){var e=wt(this._perfConfig)&&Ft(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Zl;return e>0&&6e4>=e?Zl:e}get isEnabled(){var e=null==Ye?void 0:Ye.protocol;if("http:"!==e&&"https:"!==e)return Xl.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=wt(this._perfConfig)?this._perfConfig.web_vitals:Tt(this._perfConfig)?this._perfConfig:void 0;return Tt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Xl.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var i=wt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=wt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[k]:i}),this._instance.persistence.register({[P]:s})),this._enabledServerSide=i,this.startIfEnabled()}}}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t=nt.__PosthogExtensions__,i=this._callbackFlavor,s=null==t?void 0:t.postHogWebVitalsCallbacksByFlavor;null!=s&&s[i]||"web-vitals"===i&&kt(s)&&null!=t&&t.postHogWebVitalsCallbacks?e():null==t||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,i,t=>{t?Xl.error("failed to load script",t):e()})}_maskedURL(e){var t=e||(null==Ge?void 0:Ge.location.href);if(t){var i=this._instance.config.disable_capture_url_hashes?es(t):t,s=this._instance.config.custom_personal_data_properties;return so(i,this._instance.config.mask_personal_data_properties?[...ao,...s||[]]:[],uo)}Xl.error("Could not determine current URL")}}},Yu={exceptionObserver:class{constructor(e){var t;this._startCapturing=()=>{var e;if(Ge&&this.isEnabled&&null!=(e=nt.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=nt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=nt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=nt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){Gl.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[b]),this._rateLimiter=new zt(s({},function(e){var t,i,s,r;return void 0===e&&(e={}),{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(r=e.exceptionRateLimiterBucketSize)&&void 0!==r?r:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking),{refillInterval:1e4,_logger:Gl})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return wt(e)?t=s({},t,e):(kt(e)?this._remoteEnabled:e)&&(t=s({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Gl.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return Gl.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[b]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,s,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(r))return void Gl.info("Skipping exception capture because of client rate limiting.",{exception:r});null==(s=this._instance.exceptions)||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new ns([new vs,new Es,new ms,new fs,new Cs,new ks,new bs,new xs],function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],o=t.split("\n"),a=r;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=gs.test(l)?l.replace(gs,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of i){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return s({},e,{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(n)}}("web:javascript",ds,ps)),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=Rs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new As(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Rs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if(e.ok){var r=e.config;if("errorTracking"in r){var n=null!==(t=null==(i=r.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null==(s=r.errorTracking)?void 0:s.captureExtensionExceptions;this._suppressionRules=n,this._instance.persistence&&this._instance.persistence.register({[w]:this._suppressionRules,[S]:o})}}}get _captureExtensionExceptions(){var e,t,i=!!this._instance.get_property(S);return null!==(e=null!==(t=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==t?t:i)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!Ct(e)||0===e.trim().length)return void Lu.warn("Ignoring exception step because message must be a non-empty string");var i=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>Is.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t)),r=i.sanitizedProperties,n=i.droppedKeys;n.length>0&&Lu.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(s({[Ps]:e,[Fs]:(new Date).toISOString()},r))}catch(e){Lu.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Lu.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void Lu.info("Skipping exception capture because it was thrown by an extension");if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by an injected browser script"),void Lu.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Lu.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&Pt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,s="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;s&&(i.$release_id=s);try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return Mu(e)||Lu.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void(Mu(e)||Lu.error("Failed to process exception event. Ignoring this exception.",e))}var n}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:s({},e,{$exception_steps:t})}catch(t){return Lu.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Ps]:e,[Fs]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return wt(e)?s({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{var t=e.reduce((e,t)=>{var i=t.type,s=t.value;return Ct(i)&&i.length>0&&e.$exception_types.push(i),Ct(s)&&s.length>0&&e.$exception_values.push(s),e},{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{var i=e.values.map(e=>{var i=il[e.operator],s=t[e.key];if(!i||!s)return!1;var r=yt(e.value)?e.value:[e.value];return r.length>0&&i(r,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return Lu.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){var t=e.flatMap(e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(e=>{var t=e.filename;return!!t&&Ou.some(e=>t.startsWith(e))});return 0!==i.length&&(!i.every(e=>{var t=e.filename;return!!t&&t.startsWith($u)})||e.some(e=>{var t=e.value;return Ct(t)&&t.includes("isolatedAPI.contexts.topHostname")})&&!t.some(e=>{var t=e.filename;return e.in_app&&!(null!=t&&t.startsWith($u))}))}_isInjectedBrowserScriptException(e){return e.some(e=>{var t=e.value;return Ct(t)&&Du.some(e=>t.includes(e))})}_isPostHogException(e){if(e.length>0){var t,i,s,r,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[];return null!==(s=null==(r=n[n.length-1])||null==(r=r.filename)?void 0:r.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!Pt(e)&&yt(e)}}},Xu=s({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var i,s;if(this._persistence&&this._persistence.register({[x]:!!t.productTours}),!uu(this._instance))return!this._productTourManager&&Pt(null==(i=this._persistence)?void 0:i.props.ph_product_tours)||lu.info("product tours disabled; stopping and clearing cached tours"),null==(s=this._productTourManager)||s.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this._productTourManager&&uu(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",t=>{t?lu.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&null!=(e=nt.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=nt.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!yt(this._cachedTours)||t){var i=this._persistence;if(i){var s=i.props[oe];if(yt(s)&&!t)return this._cachedTours=s,void e(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:t=>{if(uu(this._instance)){var s=t.statusCode;if(200!==s||!t.json){var r="Product Tours API could not be loaded, status: "+s;return 0===s?t.error||lu.warn(r):lu.error(r),void e([],{isLoaded:!1,error:r})}var n=yt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[oe]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){Pt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)})}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._persistence)||e.unregister(oe)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},Ku),Zu={siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=nt._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var r,n,o,a,l,u,c;if(!e)throw new Error("Event payload is required");var d={},h=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var p of Object.entries(_)){var g=p[0];d[g]={id:h[g],type:g,properties:p[1]}}var v=e.$set_once,f=e.$set;return{event:s({},i(e,t),{properties:s({},e.properties,f?{$set:s({},null!==(r=null==(n=e.properties)?void 0:n.$set)&&void 0!==r?r:{},f)}:{},v?{$set_once:s({},null!==(o=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==o?o:{},v)}:{}),elements_chain:null!==(l=null==(u=e.properties)?void 0:u.$elements_chain)&&void 0!==l?l:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:d}}_prepareElementForSiteApp(e){var t,i=null==(t=e.tagName)?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(cu.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(cu.error("prepare_external_dependency_script returned null"),null):e}_patchSiteAppElementInsertionMethods(){var e,t,i,s,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==Je?void 0:Je.defaultView,u=null==l||null==(e=l.Node)?void 0:e.prototype;if(!l||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();var c=[],d=this,h=new WeakSet,_=(e,t,i)=>{if(null!=e&&e[t]){var s=e[t];e[t]=i(s),c.push(()=>{e[t]=s})}},p=e=>{if(h.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&h.add(t),t},g=e=>e.map(e=>"string"==typeof e?e:p(e)).filter(e=>!Et(e));return _(u,"appendChild",e=>function(t){var i=p(t);return i?e.call(this,i):t}),_(u,"insertBefore",e=>function(t,i){var s=p(t);return s?e.call(this,s,i):t}),_(u,"replaceChild",e=>function(t,i){var s=p(t);return s?e.call(this,s,i):i}),[null==(t=l.Element)?void 0:t.prototype,null==(i=l.Document)?void 0:i.prototype,null==(s=l.DocumentFragment)?void 0:s.prototype].forEach(e=>{_(e,"append",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))}),_(e,"prepend",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))})}),[null==(r=l.Element)?void 0:r.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach(e=>{_(e,"before",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))}),_(e,"after",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,g(i))}),_(e,"replaceWith",e=>function(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];var r=g(i);return i.length&&!r.length?void 0:e.apply(this,r)})}),_(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",e=>function(t,i){var s=p(i);return s?e.call(this,t,s):null}),this._restoreSiteAppElementPatches=()=>{c.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){var e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null==(t=this._restoreSiteAppElementPatches)||t.call(this)))}}_runWithPreparedSiteAppElements(e,t){void 0===t&&(t=!0);var i=this._patchSiteAppElementInsertionMethods();try{var s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(cu.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(i=this._stopBuffering)||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,cu.info("Site app with id "+e.id+" "+(r?"loaded":"errored")),s&&i()};try{var n=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),r(e)}}),!1).processEvent;n&&(t.processEvent=n),s=!0}catch(t){cu.error(du+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){cu.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){var t=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(e),s=function(s){try{t._runWithPreparedSiteAppElements(()=>null==s.processEvent?void 0:s.processEvent(i))}catch(t){cu.error("Error while processing event "+e.event+" for site app "+s.id,t)}};for(var r of Object.values(this.apps))s(r)}}onRemoteConfig(e){var t,i,s,r=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),e.ok){var n=e.config;if(null!=(s=n.siteApps)&&s.length)if(this.isEnabled){var o=function(){var e,t=a.id,i=a.url;nt["__$$ph_site_app_"+t]=r._instance,null==(e=nt.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(r._instance,i,e=>{if(e)return cu.error(du+t,e)})};for(var a of n.siteApps)o()}else cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ec={tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{var e,t,i=this._syncHostnamesForPatch();i?(kt(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=nt.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),kt(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=nt.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=nt.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=nt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return Yl.error("failed to load script",t);e()})}_getConfiguredHostnames(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){var e=this._getConfiguredHostnames();return yt(e)?(yt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(yt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},tc=s({surveys:class extends gu{constructor(e){var t;super(new wu(e),(t=e,{get projectToken(){return t.config.token},kv:new bu(t)})),this._instance=e}_sendSurveysRequest(e,t){var i=t.query?Ta(e,t.query):e;return new Promise(e=>{var s;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",i),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:e})})}}},Ku),ic={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){nt.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=nt.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),Cr(this.instance.config))return!1;if(!Ge||!Je)return!1;e=null!=e?e:Ge.location,i=null!=i?i:Ge.history;try{if(!t){try{Ge.localStorage.setItem("test","test"),Ge.localStorage.removeItem("test")}catch(e){return!1}t=null==Ge?void 0:Ge.localStorage}var s,r=Su||ro(e.hash,"__posthog")||ro(e.hash,"state"),n=r?fr(()=>JSON.parse(atob(decodeURIComponent(r))))||fr(()=>JSON.parse(decodeURIComponent(r))):null;return n&&"ph_authorize"===n.action?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(ku)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch(e){return!1}}_callLoadToolbar(e){var t=nt.ph_load_toolbar||nt.ph_load_editor;!Pt(t)&&bt(t)?t(e,this.instance):Cu.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==Je||!Je.getElementById("__POSTHOG_TOOLBAR__"));if(!Ge||t)return!1;var i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=s({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(Ge.localStorage.setItem(ku,JSON.stringify(s({},r,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=nt.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return Cu.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),kr(Ge,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},sc=s({experiments:class e{get _config(){return this._instance.config}constructor(t){var i=this;this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments(t=>{e._logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,t.forEach(t=>{if(t.feature_flag_key){var s;i._flagToExperiments&&(e._logInfo("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(s=i._flagToExperiments)||s.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);Ct(r)&&t.variants[r]&&i._applyTransforms(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var n in t.variants){var o=t.variants[n];e._matchesTestVariant(o,i._instance)&&i._applyTransforms(t.name,n,o.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e._logInfo(Bu);else if(!this._config.disable_web_experiments){if(Pt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e._logInfo("applying feature flags",t),t.forEach(e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,s=this._instance.getFeatureFlag(e),r=null==(i=this._flagToExperiments)?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this._applyTransforms(r.name,s,r.variants[s].transforms)}})}}previewWebExperiment(){var t=e.getWindowLocation();if(null!=t&&t.search){var i=io(null==t?void 0:t.search,"__experiment_id"),s=io(null==t?void 0:t.search,"__experiment_variant");i&&s&&(e._logInfo("previewing web experiments "+i+" && "+s),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(i),s,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(t,i,s){var r=s.filter(e=>e.id===t);r&&r.length>0&&(e._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this._applyTransforms(r[0].name,i,r[0].variants[i].transforms))}static _matchesTestVariant(t,i){return!Pt(t.conditions)&&e._matchUrlConditions(t,i)&&e._matchUTMConditions(t)}static _matchUrlConditions(t,i){var s;if(Pt(t.conditions)||Pt(null==(s=t.conditions)?void 0:s.url))return!0;var r=e.getWindowLocation();if(r){var n,o,a,l=en(i,r.href);return null==(n=t.conditions)||!n.url||qu[null!==(o=null==(a=t.conditions)?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return null==Ge?void 0:Ge.location}static _matchUTMConditions(e){var t;if(Pt(e.conditions)||Pt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=ho();if(i.utm_source){var s,r,n,o,a,l,u,c,d=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_campaign)==i.utm_campaign,h=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,_=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return d&&_&&p&&h}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];dr.info("[WebExperiments] "+e,i)}_applyTransforms(t,i,s){this._is_bot()?e._logInfo(Bu):"control"!==i?s.forEach(s=>{var r;s.selector&&(e._logInfo("applying transform of variant "+i+" for experiment "+t+" ",s),null==(r=document)||null==(r=r.querySelectorAll(s.selector))||r.forEach(e=>{var t=e;s.html&&(t.innerHTML=s.html),s.css&&t.setAttribute("style",s.css)}))}):e._logInfo("Control variants leave the page unmodified.")}_is_bot(){return Qe&&this._instance?Ja(Qe,this._config.custom_blocked_useragents):void 0}}},Ku),rc=s({},Ku,Qu,Ju,Yu,Xu,Zu,tc,ec,ic,sc,{conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this._remoteConfigSuccessful=e.ok,e.ok)){var t=e.config.conversations;Pt(t)||(Tt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1}loadIfEnabled(){if(!(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||Cr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==nt?void 0:nt.__PosthogExtensions__;if(e&&!kt(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError(De);i(this._instance,"conversations",t=>{t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1})}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}else Hu.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,Hu.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Hu.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Hu.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():Hu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!Et(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Cr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":kt(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?Pt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":null!=nt&&nt.__PosthogExtensions__?this._isInitializing?"initializing":this._loadFailed?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return n(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(Hu.warn(Nu),null)})()}getMessages(e,t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Hu.warn(Nu),null)})()}markAsRead(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Hu.warn(Nu),null)})()}getTickets(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Hu.warn(Nu),null)})()}requestRestoreLink(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Hu.warn(Nu),null)})()}restoreFromToken(e){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Hu.warn(Nu),null)})()}restoreFromUrlToken(){var e=this;return n(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Hu.warn(Nu),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},{logs:class{constructor(e){var t,i=this;this._instance=e,this.name="logs",this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=hr("[logs]"),this._coreLogger=s({},this._logger,{error(){for(var e=arguments.length,t=new Array(e),s=0;e>s;s++)t[s]=arguments[s];t.some(Gu)||i._logger.error(...t)}}),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,null==(e=this._core)||e.onReconnect(),null==(t=this._consoleCore)||t.onReconnect())},this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),Ge&&kr(Ge,"online",this._onReconnect)}_buildCore(e,t,i,s){var r,n=zu(null==(r=this._instance)||null==(r=r.config)?void 0:r.logs,i);return[new nr(this._createHost(e,t),n,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,s),n]}_getCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._core||this._resolvedFrom!==t){var i;null==(i=this._core)||i.reset(),this._resolvedFrom=t;var s=this._buildCore(()=>this._queue,e=>{this._queue=e});this._core=s[0],this._resolvedConfig=s[1]}return this._core}_getConsoleCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._consoleCore||this._consoleResolvedFrom!==t){var i;null==(i=this._consoleCore)||i.reset(),this._consoleResolvedFrom=t;var s=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Vu);this._consoleCore=s[0],this._consoleResolvedConfig=s[1]}return this._consoleCore}setup(e){var t;if(!this._disposed){this._client=e,null!=(t=this._instance)&&null!=(t=t.config)&&null!=(t=t.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._remoteConfigWillArrive()&&this._persistedCaptureHint())&&this._startConsoleRecorder();var i=!1,s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null==(t=e.config.logs)?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?s.dispose():(this._remoteConfigSubscription=s,i||this.loadIfEnabled())}}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null==(e=this._remoteConfigSubscription)||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null==Ge||Ge.removeEventListener("online",this._onReconnect),null==(t=this._consoleLogsDispose)||t.call(this),this._consoleLogsDispose=void 0,null==(i=this._core)||i.reset(),null==(s=this._consoleCore)||s.reset())}onRemoteConfig(e){var t,i;if(!this._disposed){var s=e.ok?null==(t=e.config.logs)?void 0:t.captureConsoleLogs:void 0;Pt(s)?this._stopRecorderStartedByPersistedHint():(null==(i=this._instance)||null==(i=i.persistence)||i.register({[E]:!!s}),s?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}}reset(){var e,t,i,s;this._stopConsoleRecorder(),null==(e=this._core)||e.clearQueue(),this._queue=[],null==(t=this._core)||t.reset(),null==(i=this._consoleCore)||i.clearQueue(),this._consoleQueue=[],null==(s=this._consoleCore)||s.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){this._disposed||this._getCore().captureLog(e)}captureConsoleLog(e){this._disposed||this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,i){this._disposed||this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:i})}_persistedCaptureHint(){var e;return!(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.props)||!e[E])}_remoteConfigWillArrive(){var e,t;return null==(e=this._instance)||null==e._shouldDisableFlags||!e._shouldDisableFlags()||!(null==(t=nt._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])||!t.config)}_onOptOut(){var e;this._stopConsoleRecorder(),null==(e=this._consoleCore)||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e,t=this;if(!this._isRecordingConsole&&null!=nt&&nt.console){var i=zu(null==(e=this._instance)||null==(e=e.config)?void 0:e.logs).maxBufferSize,s=function(e){var s;try{s=(e=>{for(;null!=(t=e)&&t.__rrweb_original__;){var t;e=e.__rrweb_original__}return e})(nt.console[e])}catch(e){return 0}if(!s)return 0;t._consoleRecorderUnpatchers.push(Jl(nt.console,e,r=>{var n=function(){for(var s=arguments.length,n=new Array(s),o=0;s>o;o++)n[o]=arguments[o];try{t._recordConsoleEntry(e,n,i)}catch(e){}return r.apply(nt.console,n)};return n.__rrweb_original__=s,n}))};for(var r of ju)s(r);this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}}_recordConsoleEntry(e,t,i){var s;if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&0!==t.length)if(null!=(s=this._instance)&&s.is_capturing()){if(i>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){for(var e of(this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0),this._consoleRecorderUnpatchers))e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){var e=this._consoleBuffer;return this._stopConsoleRecorder(),e}get logger(){return this._capture_logger||(this._capture_logger={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._capture_logger}flushLogs(e){e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e)))}_logFlushError(e){Gu(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(!this._disposed&&this._isLogsEnabled&&!this._isLoaded&&!this._isLoading){var e=null==nt?void 0:nt.__PosthogExtensions__;if(!e)return this._logger.error("PostHog Extensions not found."),void this._stopConsoleRecorder();var t=e.loadExternalDependency;if(!t)return this._logger.error(De),void this._stopConsoleRecorder();this._isLoading=!0;try{t(this._instance,"logs",t=>{if(this._isLoading=!1,!this._disposed&&this._isLogsEnabled){var i=e.logs;if(t||null==i||!i.initializeLogs)this._logger.error("Could not load logs script",t),this._stopConsoleRecorder();else{var s,r,n=this._takeConsoleBuffer();this._consoleLogsDispose=i.initializeLogs(null!==(s=this._client)&&void 0!==s?s:this._instance),this._isLoaded=!0,n.length>0&&(null==i.replayConsoleBuffer||i.replayConsoleBuffer(null!==(r=this._client)&&void 0!==r?r:this._instance,n))}}})}catch(e){throw this._isLoading=!1,e}}}_createHost(e,t){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===ht.LogsQueue?e():void 0,setPersistedProperty(e,i){e===ht.LogsQueue&&t(null!=i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}_sendLogsBatch(e){return new Promise(t=>{if(no(this._consecutiveStatusZeroFailures,3))t({kind:"fatal",error:Uu(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,s=e=>{i||(i=!0,clearTimeout(r),t(e))},r=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Uu(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this._logsUrl(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;if(this._trackEndpointReachability(t),t>=200&&300>t)s({kind:"ok"});else if(413===t)s({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)s({kind:"fatal",error:new Error("logs request failed with status "+t)});else{var i;0===t?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Uu(e.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}})}_trackEndpointReachability(e){(0!==e||this._instance.__loaded)&&(this._consecutiveStatusZeroFailures=oo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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.")))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,l.LIB_NAME,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,Vu,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,s,r){if(0!==t.length){var n=t.map(e=>e.record);r([]);var o=rr(n,sr(i,l.LIB_NAME,l.LIB_VERSION),s,l.LIB_VERSION);this._instance._send_request({method:"POST",url:this._logsUrl(),data:o,compression:"best-available",batchKey:"logs",transport:e})}}_logsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_getSdkContext(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),s=i.windowId,r=i.sessionStartTimestamp,n=i.lastActivityTimestamp;t.sessionId=i.sessionId,t.windowId=s,Pt(r)||(t.sessionStartTimestamp=r),Pt(n)||(t.lastActivityTimestamp=n)}if(null!=nt&&null!=(e=nt.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?es(nt.location.href):nt.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},{metrics:class{constructor(e){this._instance=e,this._logger=hr("[metrics]")}initialize(){}_getCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.metrics;return this._core&&this._resolvedFrom===i||(null==(t=this._core)||t.reset(),this._resolvedFrom=i,this._core=new ur(this._createHost(),function(e){var t,i,s,r,n,o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(r=null==e?void 0:e.flushIntervalMs)&&void 0!==r?r:1e4,maxSeriesPerFlush:null!==(n=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this._logger)),this._core}count(e,t,i){void 0===t&&(t=1),this._getCore().count(e,t,i)}gauge(e,t,i){this._getCore().gauge(e,t,i)}histogram(e,t,i){this._getCore().histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){var t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error("PostHog metrics flush failed:",e))}reset(){var e;null==(e=this._core)||e.reset()}_createHost(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{var r=!1,n=e=>{r||(r=!0,clearTimeout(o),i(e))},o=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(s({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t,i=e.statusCode;n(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(t=e.error)&&void 0!==t?t:new Error("metrics request failed with status "+i)})}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});Bl.__defaultExtensionClasses=s({},rc),function(){l.SDK_DIST_CHANNEL="cdn";var e=nt.posthog;if(!e||yt(e._i)){var t=wl[Rl]=new Bl;if(e){var i=[];pr(e._i,function(s){if(s&&yt(s)){var r=t.init(s[0],s[1],s[2]),n=e[s[2]]||e;r.__loaded&&-1===i.indexOf(n)&&(i.push(n),r._execute_array.call(r.people,n.people),r._execute_array(n))}})}t.__SV=1,nt.posthog=t,function(){function e(){e.done||(e.done=!0,Al=!1,pr(wl,function(e){e._dom_loaded()}))}null!=Je&&Je.addEventListener?"complete"===Je.readyState?e():kr(Je,"DOMContentLoaded",e,{capture:!1}):Ge&&dr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}}()}()}();
|
|
2
2
|
//# sourceMappingURL=array.no-external.js.map
|