posthog-js 1.433.2 → 1.433.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.
Files changed (41) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/array.full.es5.js +1 -1
  3. package/dist/array.full.es5.js.map +1 -1
  4. package/dist/array.full.js +1 -1
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -1
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -1
  9. package/dist/array.js.map +1 -1
  10. package/dist/array.no-external.js +1 -1
  11. package/dist/array.no-external.js.map +1 -1
  12. package/dist/customizations.full.js +1 -1
  13. package/dist/customizations.js +1 -1
  14. package/dist/default-extensions.js +1 -1
  15. package/dist/default-extensions.js.map +1 -1
  16. package/dist/extension-bundles.js +1 -1
  17. package/dist/lazy-recorder.js +1 -1
  18. package/dist/main.js +1 -1
  19. package/dist/main.js.map +1 -1
  20. package/dist/module.full.cjs +1 -1
  21. package/dist/module.full.js +1 -1
  22. package/dist/module.full.js.map +1 -1
  23. package/dist/module.full.no-external.cjs +1 -1
  24. package/dist/module.full.no-external.js +1 -1
  25. package/dist/module.full.no-external.js.map +1 -1
  26. package/dist/module.js +1 -1
  27. package/dist/module.js.map +1 -1
  28. package/dist/module.mjs +1 -1
  29. package/dist/module.mjs.map +1 -1
  30. package/dist/module.no-external.cjs +1 -1
  31. package/dist/module.no-external.js +1 -1
  32. package/dist/module.no-external.js.map +1 -1
  33. package/dist/module.slim.js +1 -1
  34. package/dist/module.slim.js.map +1 -1
  35. package/dist/module.slim.no-external.js +1 -1
  36. package/dist/module.slim.no-external.js.map +1 -1
  37. package/dist/posthog-recorder.js +1 -1
  38. package/lib/package.json +1 -1
  39. package/lib/src/request.js +3 -1
  40. package/lib/src/request.js.map +1 -1
  41. package/package.json +6 -6
@@ -1,2 +1,2 @@
1
- const e="u">typeof window?window:void 0,t="u">typeof globalThis?globalThis:e,i=null==t?void 0:t.navigator,s=null==t?void 0:t.document,n=null==t?void 0:t.location,r=null==t?void 0:t.fetch,o=(null==t?void 0:t.XMLHttpRequest)&&"withCredentials"in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,a=null==t?void 0:t.AbortController,l=null==t?void 0:t.CompressionStream,c=null==i?void 0:i.userAgent;function u(){return!(!e||!1===e.navigator.onLine)}const d="undefined"!=typeof globalThis?globalThis:e;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});const h=null!=e?e:{},p="$people_distinct_id",_="distinct_id",g="$device_id",f="$device_model",v="__alias",m="__cmpns",y="$fbc",b="$fbc_persistence",S="$fbp",w="$fbp_persistence",k="__timers",C="$autocapture_disabled_server_side",E="$heatmaps_enabled_server_side",x="$exception_capture_enabled_server_side",I="$error_tracking_suppression_rules",T="$error_tracking_capture_extension_exceptions",M="$web_vitals_enabled_server_side",R="$dead_clicks_enabled_server_side",P="$product_tours_enabled_server_side",F="$logs_capture_enabled_server_side",L="$web_vitals_allowed_metrics",A="$session_recording_remote_config",O="$session_recording_enabled_server_side",D="$replay_sample_rate",N="$replay_override_sampling",B="$replay_override_linked_flag",q="$replay_override_url_trigger",H="$replay_override_event_trigger",U="$sesid",W="$session_is_sampled",z="$session_past_minimum_duration",j="$session_recording_url_trigger_activated_session",V="$session_recording_event_trigger_activated_session",G="$posthog_sr_group_event_trigger_",Q="$posthog_sr_group_url_trigger_",K="$posthog_sr_group_sampling_",Z="$debug_first_full_snapshot_timestamp",J="$sess_rec_flush_size",Y="$enabled_feature_flags",X="$active_feature_flags",ee="$early_access_features",te="$feature_flag_details",ie="$feature_flag_payloads",se="$feature_flag_request_id",ne="$minimal_flag_called_events",re="$override_feature_flags",oe="$override_feature_flag_payloads",ae="$stored_person_properties",le="$stored_group_properties",ce="$groups",ue="$surveys",de="$surveys_loaded_at",he="$surveys_activated",pe="$surveys_activated_session",_e="$surveys_activated_timestamps",ge="ph_product_tours",fe="$product_tours_activated",ve="$product_tours_activated_session",me="$conversations_widget_session_id",ye="$conversations_ticket_id",be="$conversations_widget_state",Se="$conversations_user_traits",we="$flag_call_reported",ke="$flag_call_reported_session_id",Ce="$feature_flag_errors",Ee="$feature_flag_evaluated_at",xe="$user_state",Ie="$client_session_props",Te="$capture_rate_limit",Me="$initial_campaign_params",Re="$initial_referrer_info",Pe="$initial_person_info",Fe="$epp",Le="$posthog_cookieless",Ae="$cookieless_mode",Oe="$sdk_debug_extensions_init_method",De="$sdk_debug_extensions_init_time_ms",$e="$sdk_debug_recording_script_not_loaded",Ne="$sdk_debug_replay_event_trigger_status",Be="$sdk_debug_replay_linked_flag_trigger_status",qe="$sdk_debug_replay_matched_recording_trigger_groups",He="$sdk_debug_replay_pending_trigger_conditions",Ue="$sdk_debug_replay_remote_trigger_matching_config",We="$sdk_debug_replay_trigger_groups_count",ze="$sdk_debug_replay_url_trigger_status",je="$sdk_debug_rrweb_attached",Ve="$sdk_debug_rrweb_start_attempted",Ge="$session_recording_start_reason",Qe="PostHog loadExternalDependency extension not found.",Ke="anonymous",Ze="identified",Je="identified_only",Ye="visibilitychange",Xe="beforeunload",et="$pageview",tt="$pageleave",it="$identify",st="$groupidentify";function nt(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,n)}function rt(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(e){nt(r,s,n,o,a,"next",e)}function a(e){nt(r,s,n,o,a,"throw",e)}o(void 0)})}}function ot(e){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ot(e)}function at(e,t,i){return(t=function(e){var t=function(e){if("object"!=ot(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=ot(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ot(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function lt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function ct(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(i),!0).forEach(function(t){at(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):lt(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var ut=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}({}),dt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});const ht="min_length",pt="max_length",_t=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],gt=["token"];function ft(e,t){return-1!==e.indexOf(t)}const vt=function(e){return e.trim()},mt=function(e){return e.replace(/^\$/,"")};function yt(e){var t;const 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"}const bt=Object.prototype,St=bt.hasOwnProperty,wt=bt.toString,kt=Array.isArray||function(e){return"[object Array]"===wt.call(e)},Ct=e=>"function"==typeof e,Et=e=>e===Object(e)&&!kt(e),xt=e=>{if(Et(e)){for(const t in e)if(St.call(e,t))return!1;return!0}return!1},It=e=>void 0===e,Tt=e=>"[object String]"==wt.call(e),Mt=e=>Tt(e)&&0===e.trim().length,Rt=e=>null===e,Pt=e=>It(e)||Rt(e),Ft=e=>"[object Number]"==wt.call(e)&&e==e,Lt=e=>Ft(e)&&e>0,At=e=>"[object Boolean]"===wt.call(e),Ot=e=>e instanceof FormData,Dt=e=>ft(_t,e),$t=e=>ft(gt,e);function Nt(e){return null===e||"object"!=typeof e}function Bt(e,t){return{}.toString.call(e)===`[object ${t}]`}function qt(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 Ut(e,Error)}}function Ht(e){return"u">typeof Event&&Ut(e,Event)}function Ut(e,t){try{return e instanceof t}catch(e){return!1}}const Wt=[!0,"true",1,"1","yes"],zt=e=>ft(Wt,e),jt=[!1,"false",0,"0","no"],Vt=["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"],Gt=function(e,t=[]){if(!e)return!1;const i=e.toLowerCase();return Vt.concat(t).some(e=>{const t=e.toLowerCase();return-1!==i.indexOf(t)})};function Qt(e,t,i,s,n){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: "+n),Qt(null!=n?n:i,t,i,s))}var Kt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Qt(e.bucketSize,0,100,e._logger),this._refillRate=Qt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Qt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){const 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;const i=Date.now(),s=String(e);let n=this._buckets[s];return n?this._applyRefill(n,i):(n={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(t=this._onBucketRateLimited)||void 0===t||t.call(this,e)),0===n.tokens)}stop(){this._buckets={}}};const Zt="Mobile",Jt="Android",Yt="Tablet",Xt="Android Tablet",ei="iPad",ti="Apple Watch",ii="Safari",si="BlackBerry",ni="Samsung Internet",ri="Chrome",oi="Chrome iOS",ai="Internet Explorer",li="Internet Explorer Mobile",ci="Opera",ui="Microsoft Edge",di="Firefox",hi="Firefox iOS",pi="Nintendo",_i="PlayStation",gi="Xbox",fi="Android Mobile",vi="Mobile Safari",mi="Windows",yi="Windows Phone",bi="Nokia",Si="Ouya",wi="Generic "+Zt.toLowerCase(),ki="Generic "+Yt.toLowerCase(),Ci="Konqueror",Ei="Oculus Browser",xi="Vivaldi",Ii="Yandex",Ti="Whale",Mi="DuckDuckGo",Ri="Pale Moon",Pi="Waterfox",Fi="Brave",Li="Claude",Ai="Codex",Oi="ChatGPT",Di="Google Search App",$i=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ni=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Bi=new RegExp(gi,"i"),qi=new RegExp("PlayStation \\w+","i"),Hi=new RegExp("Nintendo \\w+","i"),Ui=new RegExp("BlackBerry|PlayBook|BB10","i"),Wi={"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"},zi=function(e,t,i,s){t=t||"";const n=function(e){return(null==e?void 0:e.brave)?Fi:null}(i);return n||((null==s?void 0:s.detectGoogleSearchApp)&&ft(e,"GSA/")?Di:ft(e," OPR/")&&ft(e,"Mini")?"Opera Mini":ft(e," OPR/")?ci:Ui.test(e)?si:ft(e,"IEMobile")||ft(e,"WPDesktop")?li:ft(e,"OculusBrowser")?Ei:ft(e,"SamsungBrowser")?ni:ft(e,"Edge")||ft(e,"Edg/")?ui:ft(e,"Vivaldi/")?xi:ft(e,"YaBrowser/")?Ii:ft(e,"Whale/")?Ti:ft(e,"DuckDuckGo/")||ft(e,"Ddg/")?Mi:ft(e,"Claude/")?Li:ft(e,"Codex/")?Ai:ft(e,"ChatGPT/")?Oi:ft(e,"FBIOS")?"Facebook Mobile":ft(e,"UCWEB")||ft(e,"UCBrowser")?"UC Browser":ft(e,"CriOS")?oi:ft(e,"CrMo")||ft(e,ri)?ri:ft(e,Jt)&&ft(e,ii)?fi:ft(e,"FxiOS")?hi:ft(e.toLowerCase(),Ci.toLowerCase())?Ci:ft(e,"Brave/")?Fi:((e,t)=>t&&ft(t,"Apple")||function(e){return ft(e,ii)&&!ft(e,ri)&&!ft(e,Jt)}(e))(e,t)?ft(e,Zt)?vi:ii:ft(e,"PaleMoon/")?Ri:ft(e,"Waterfox/")?Pi:ft(e,di)?di:ft(e,"MSIE")||ft(e,"Trident/")?ai:ft(e,"Gecko")?di:"")},ji={[li]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ui]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ri]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[oi]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ii]:[$i],[vi]:[$i],[ci]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[di]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[hi]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[si]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),$i],[fi]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ni]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Ei]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[xi]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Ii]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Ti]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Fi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Li]:[Ni],[Ai]:[Ni],[Oi]:[Ni],[Mi]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Ri]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Pi]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Di]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ai]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Vi=function(e,t,i,s){const n=zi(e,t,i,s),r=ji[n];if(It(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},Gi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[gi,e&&e[1]||""]],[new RegExp(pi,"i"),[pi,""]],[new RegExp(_i,"i"),[_i,""]],[Ui,[si,""]],[new RegExp(mi,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[yi,""];if(new RegExp(Zt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=Wi[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[mi,e]}return[mi,""]}],[/((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=>{let t="";return e&&e.length>=3&&(t=It(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Jt,[e[2],e[3],e[4]||"0"].join(".")]:[Jt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const 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",""]]],Qi=function(e){for(let t=0;Gi.length>t;t++){const[i,s]=Gi[t],n=i.exec(e),r=n&&(Ct(s)?s(n,e):s);if(r)return r}return["",""]},Ki=function(e){return Hi.test(e)?pi:qi.test(e)?_i:Bi.test(e)?gi:new RegExp(Si,"i").test(e)?Si:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?yi:/iPad/.test(e)?ei:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ti:Ui.test(e)?si:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(bi,"i").test(e)?bi:/(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(Zt).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)?Jt:Xt:new RegExp("(pda|Mobile)","i").test(e)?wi:new RegExp(Yt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?ki:""},Zi=function(e,t){var i;const s=Ki(e);return s===ei||s===Xt||"Kobo"===s||"Kindle Fire"===s||s===ki?Yt:s===pi||s===gi||s===_i||s===Si?"Console":s===ti?"Wearable":s?Zt:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(n=null==t?void 0:t.screenWidth)&&void 0!==n?n:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?Zt:Yt:"Desktop";var n,r,o},Ji=/\bFBAV\/(\d+(?:\.\d+)*)/i,Yi=[[/\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"]],Xi="[Truncated]",es="[Unserializable]";function ts(e){let t="";for(let i=0;e.length>i;i++){const s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"�";else{const s=e.charCodeAt(i+1);56320>s||s>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}function is(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const s of i){let i;try{i=t[s]}catch(e){i=es}Object.defineProperty(e,s,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const ss=3e5;var ns=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),s=Math.min(e.retryAfterMs,ss);if(!t)return this._installedAt=i,void(this._until=i+s);this._until=Math.max(this._until,Math.min(i+s,this._installedAt+ss))}remainingMs(){const e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;const t=Math.min(ss,Math.max(0,this._until-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}};const rs=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function os(e,t){return"string"==typeof(i=e)&&rs.test(i)?e:t();var i}function as(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function ls(e){return e?e.split("#")[0]:e}function cs(e){try{return e()}catch(e){return}}function us(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function ds(e,t,i){return hs.apply(this,arguments)}function hs(){return(hs=rt(function*(e,t,i){let s;try{return yield Promise.race([e,new Promise((e,n)=>{s=us(()=>{try{null==i||i(),e()}catch(e){n(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let ps,_s,gs;function fs(e){const t=globalThis._posthogChunkIds;if(!t)return;const i=Object.keys(t);return gs&&i.length===_s||(_s=i.length,gs=i.reduce((i,s)=>{ps||(ps={});const n=ps[s];if(n)i[n[0]]=n[1];else{const n=e(s);for(let e=n.length-1;e>=0;e--){const r=n[e],o=null==r?void 0:r.filename,a=t[s];if(o&&a){i[o]=a,ps[s]=[o,a];break}}}return i},{})),gs}var vs=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return rt(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&kt(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?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){let i,s;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),ct(ct({},e),{},{cause:i,stack:s})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return rt(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){var i,s,n;const r={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(r.stacktrace={type:"raw",frames:e.stack});const o=[r];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,ct(ct({},t),{},{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:fs(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i=0){const s=(i,s)=>{if(4>=s){const n=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,n)}};return ct(ct({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,i),next:e=>s(e,i+1)})}};const ms=/^([a-z][a-z0-9.+-]+):/i,ys=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function bs(e){if(!e||"<anonymous>"===e)return!1;const t=ms.exec(e);return!t||ys.includes(t[1].toLowerCase())}function Ss(e,t,i,s,n){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:bs(t)};return It(s)||(r.lineno=s),It(n)||(r.colno=n),r}const ws=(e,t)=>{const 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]},ks=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Cs=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Es=/\((\S*)(?::(\d+))(?::(\d+))\)/,xs=(e,t)=>{const i=ks.exec(e);if(i){const[,e,s,n]=i;return Ss(t,e,"?",+s,+n)}const s=Cs.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){const e=Es.exec(s[2]);e&&(s[2]=e[1],s[3]=e[2],s[4]=e[3])}const[e,i]=ws(s[1]||"?",s[2]);return Ss(t,i,e,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},Is=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ts=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ms=(e,t)=>{const i=Is.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Ts.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],s=i[1]||"?";return[s,e]=ws(s,e),Ss(t,e,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Rs=/\(error: (.*)\)/;function Ps(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Fs(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let s=!0;for(let n=0;t>n;n++)if(!Ps(e[i+n],e[i+t+n])){s=!1;break}if(s){for(let s=0;t>s;s++)e[i+s]=e[i+t+s];return e.length=i+t,{start:i,length:t}}}}function Ls(e,t){const i=t.start+t.length,s=Os(e,t);s&&e.splice(i+s===e.length?i:t.start,s)}function As(e,t){let i=t.start;for(;i>0&&Ps(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function Os(e,t){const i=t.start+t.length;let s=i;for(;e.length>s&&Ps(e[s],e[s-t.length]);)s++;return s-i}function Ds(e,t){const i=t[0];let s=e.length-(i?As(e,i):0);for(const i of t)s-=Os(e,i);return s}function $s(e,t,i){for(let s=0;e.length>s;s++){const n=e[(t+s)%e.length],r=e[(i+s)%e.length];if(n!==r)return r>n}return!1}var Ns=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const i=Tt(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){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Bt(e,"DOMException")}isDOMError(e){return Bt(e,"DOMError")}},Bs=class{match(e){return qt(e)}coerce(e,t){var i;const s=this.getStack(e),n=void 0===s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const 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}},qs=class{match(e){return!!Bt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const s=t.apply(e.message);return ct(ct({},s),{},{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:s.stack,synthetic:!0})}_hasUsableMessage(e){return Tt(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i;const s=e,n=null!==(t=s.lineno)&&void 0!==t?t:0,r=null!==(i=s.colno)&&void 0!==i?i:0;if(Tt(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Hs=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Us=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[s,n]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const s=e.match(Hs);return s&&(t=s[1],i=s[2]),[t,i]}};const Ws=["fatal","error","warning","log","info","debug"];function zs(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const s=i.slice(0,e).join(", ");if(t>=s.length)return e===i.length?s:s.length>t?`${s.slice(0,t)}...`:s}return""}var js=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s;const n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{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?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ht(e))return e.constructor.name;const t="name"in e?e.name:void 0;return Tt(t)&&!Mt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let 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;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${zs(e)}`}isSeverityLevel(e){return Tt(e)&&!Mt(e)&&Ws.indexOf(e)>=0}getStack(e){try{return Tt(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Tt(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(qt(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},Vs=class{match(e){return Ht(e)}coerce(e,t){var i;const s=e.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${zs(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},Gs=class{match(e){return Nt(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?void 0:i.stack,synthetic:!0}}},Qs=class{match(e){return Bt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ht(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const s=this.getUnhandledRejectionReason(e);return Nt(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(i=t.syntheticException)||void 0===i?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}};const Ks="$message",Zs="$timestamp",Js=new Set([Ks,Zs]),Ys={enabled:!0,max_bytes:32768};function Xs(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Ys.enabled,max_bytes:tn(e.max_bytes,Ys.max_bytes)}:ct({},Ys)}var en=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=Xs(e)}setConfig(e){this._config=Xs(e),this._trimToMaxBytes()}add(e){const t=function(e){let t;try{t=yt(e)}catch(e){return}try{const e=JSON.parse(t);if(!Et(e))return;const i=e,s=i[Ks],n=i[Zs];if(!Tt(s)||0===s.trim().length)return;if(!Tt(n)&&!Ft(n))return;return{step:i,json:t}}catch(e){return}}(e);if(!t)return;const i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=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;){const e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function tn(e,t){if(!Ft(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const sn=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function nn(e){return"string"==typeof e||e}function rn(e){return"string"==typeof e?e:void 0}const on=["$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"],an="NativeGzipValidationError",ln=e=>e.length>=2&&31===e[0]&&139===e[1],cn=(e,t)=>e===dt.GZipJS||t===dt.GZipJS||"gzip"===t,un=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),dn=e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return un(e)||t===an};let hn;const pn=e=>{throw as(an,`Native gzip produced invalid output: ${e}`)},_n=(gn=rt(function*(e,t){18>e.size&&pn("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());ln(i)&&8===i[2]||pn("invalid-header");const s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{const t=(()=>{if(hn)return hn;hn=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;hn[e]=t>>>0}return hn})();let i=4294967295;for(let s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&pn("invalid-crc");const n=t.length>>>0;s.getUint32(4,!0)!==n&&pn("invalid-size")}),function(e,t){return gn.apply(this,arguments)});var gn;function fn(e){return vn.apply(this,arguments)}function vn(){return vn=rt(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),n=i.writable.getWriter(),r=n.write(t).then(()=>n.close()).catch((s=rt(function*(e){try{yield n.abort(e)}catch(e){}throw e}),function(e){return s.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield _n(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var s}),vn.apply(this,arguments)}function mn(e,t){if(null==e)return{};var i,s,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;i[s]=e[s]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;r.length>s;s++)t.includes(i=r[s])||{}.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}const yn={}.propertyIsEnumerable;function bn(e,t){try{return kn(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Sn(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:Xi};if(i.remainingNodes--,At(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){const 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)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:ts(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:Xi};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?ts(i):String(i)}}i.ancestors.add(e);try{try{const n=e.toJSON;if("function"==typeof n)return Sn(n.call(e),t,i,s+1)}catch(e){}return kt(e)?{arrayValue:{values:wn(e,t,i,s+1)}}:{kvlistValue:{values:kn(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:ts(String(e))}}function wn(e,t,i,s){const n=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(Pt(r))continue;n.push(Sn(r,t,i,s))}catch(e){n.push({stringValue:es})}return e.length>o&&n.push({stringValue:Xi}),n}function kn(e,t,i,s){const n=[];for(const r in e)if(yn.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(Rt(o)||It(o))continue;n.push({key:ts(r),value:Sn(o,t,i,s)})}catch(e){n.push({key:ts(r),value:{stringValue:es}})}}return n}function Cn(e,t,i){return ct(ct(ct(ct({},is({},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})}const En=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function xn(e,t){const i=is({},e),s={};for(const e of En)({}).hasOwnProperty.call(i,e)&&(s[e]=i[e],delete i[e]);return[...bn(i,t),...bn(s,t)]}const In={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const Tn={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}},Mn=Tn.info;function Rn(e){try{return ts(String(e))}catch(e){return es}}function Pn(e,t,i,s){const n=e.level||"info",{text:r,number:o}=Tn[n]||Mn,a=function(e=Date.now()){return String(e)+"000000"}(Ft(s)?s:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),Pt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),Pt(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=ct({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const t of e){let e;try{e=u[t]}catch(t){e=es}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:Rn(e.body)},attributes:bn(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),It(e.trace_flags)||(d.flags=e.trace_flags),d}function Fn(e,t,i){return Cn(e,t,i)}function Ln(e,t,i,s){return{resourceLogs:[{resource:{attributes:xn(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var An=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=us(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&(clearTimeout(this._timer),this._timer=void 0)}};function On(){return.75+.5*Math.random()}function Dn(e,t,i,s){const n=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,e)))*i)}var $n=class{constructor(e,t,i,s,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this._config=t,this._logger=i,this._getContext=s,this._onReady=n,this._waitForStoragePersist=r,this._scopeName=o,this._flushTimer=new An(()=>this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new ns,this._consecutiveFlushFailures=0,this._flushJitter=1,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(ut.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const s=this._runBeforeSend(e);if(null===s)return;if(!s.body)return void this._logger.info("Log was rejected in beforeSend function");if(!this._checkRateLimit())return;const n={record:Pn(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(n))}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Log was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return s}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;const 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 rt(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return rt(function*(){var t;e._flushTimer.clear();let i=null!==(t=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const s=i.length;let n=0;for(;i.length>0&&s>n;){var r,o;const t=e._queueGeneration;e._evictedSinceAdvance=0;const s=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,s),l=Ln(a.map(e=>e.record),e._buildResourceAttributes(),null!==(r=e._scopeName)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(l);if(e._queueGeneration!==t)return;if("too-large"===c.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else{if(e._retryAfter.record(c),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===c.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),i=null!==(o=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==o?o:[],n+=a.length,"fatal"===c.kind)throw c.error}}})()}_persistQueueAdvance(e){var t=this;return rt(function*(){var i;const s=Math.max(0,e-t._evictedSinceAdvance),n=null!==(i=t._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(ut.LogsQueue,n.slice(s)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return Fn(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(ut.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(ut.LogsQueue,i),this._maxBufferSize>i.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackground()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(Dn(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){const e=this._instance.getPersistedProperty(ut.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return rt(function*(){t._flushTimer.clear();const i=t.flush().catch(()=>{});void 0!==e?yield ds(i,e):yield i})()}flushWithTimeout(e){var t=this;return rt(function*(){const i=t.flush();yield ds(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=On(),this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}};const Nn=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Bn(e){return String(e)+"000000"}function qn(e,t,i,s){let n="";return s&&(n=Object.keys(s).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(s[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${n}`}var Hn=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushTimer=new An(()=>this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._retryAfter=new ns,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,i){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;const t=this._flushPromise,i=function(){var i=rt(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;const 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._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),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)return;const t=this._runBeforeSend(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this._logger.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"===t.type&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,s;try{i=t.attributes?ct({},t.attributes):void 0,s=qn(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let n=this._series.get(s);if(!n){if(!this._admitNewSeries())return;n={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this._series.set(s,n)}const r=this._typeByName.get(t.name);void 0===r?this._typeByName.set(t.name,t.type):r===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn(`Metric name '${t.name}' is already used as a ${r}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this._fold(n,t.value),this._armFlushTimer()}_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){switch(e.type){case"count":var i;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(Nn.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,Nn)]+=1;break}}}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Metric was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return s}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(Dn(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return rt(function*(){if(e._flushTimer.clear(),0===e._series.size)return;const t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;const i=e._generation,s=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(e._retryAfter.record(s),"retry-later"===s.kind?(e._consecutiveFlushFailures++,e._flushJitter=On()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),s.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._flushTimer.armNoEarlierThan(e._nextFlushDelay());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 Cn(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:xn(i)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,i,s,n}_buildMetrics(e){const t=Bn(Date.now()),i=new Map;for(const o of e.values()){var s;const e=qn(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=ct({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=bn(null!==(s=o.attributes)&&void 0!==s?s:{},this._logger),c=Bn(o.windowStartMs);if("count"===o.type){var n;const e={attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(n=o.total)&&void 0!==n?n:0};a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e={attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0};a.gauge.dataPoints.push(e)}else o.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Nn})}return Array.from(i.values())}_mergeWindowBack(e){for(const[s,n]of e){const e=this._series.get(s);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,n.windowStartMs),e.type){case"count":var t,i;e.total=(null!==(t=e.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(e.hist){e.hist.count+=n.hist.count,e.hist.sum+=n.hist.sum,e.hist.min=Math.min(e.hist.min,n.hist.min),e.hist.max=Math.max(e.hist.max,n.hist.max);for(let t=0;e.hist.bucketCounts.length>t;t++)e.hist.bucketCounts[t]+=n.hist.bucketCounts[t]}else e.hist=n.hist}else this._admitNewSeries()&&this._series.set(s,n)}}};function Un(e,t){if(!e)return;const i=e.find(e=>e.type===t);return null==i?void 0:i.value}const Wn="0.8.3",zn={DEBUG:!1,LIB_VERSION:Wn,LIB_NAME:"browser-common",JS_SDK_VERSION:Wn},jn=(t,{debugEnabled:i}={})=>{const s={_log(s,...n){e&&(zn.DEBUG||e.POSTHOG_DEBUG||i)&&!It(e.console)&&e.console&&("__rrweb_original__"in e.console[s]?e.console[s].__rrweb_original__:e.console[s])(t,...n)},debug(...e){s._log("debug",...e)},info(...e){s._log("log",...e)},warn(...e){s._log("warn",...e)},error(...e){s._log("error",...e)},critical(...e){console.error(t,...e)},uninitializedWarning(e){s.error(`You must initialize PostHog before calling ${e}`)},createLogger:(e,i)=>jn(`${t} ${e}`,i)};return s},Vn=jn("[PostHog.js]"),Gn=Vn.createLogger;function Qn(e,t){kt(e)&&e.forEach(t)}function Kn(e,t){if(!Pt(e))if(kt(e))e.forEach(t);else if(Ot(e))e.forEach((e,i)=>t(e,i));else for(const i in e)St.call(e,i)&&t(e[i],i)}const Zn=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function Jn(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const Yn=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Vn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Vn.critical(e)}}},Xn=function(e){const t={};return Kn(e,function(e,i){(Tt(e)&&e.length>0||Ft(e))&&(t[i]=e)}),t};function er(e){const t=ct({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const tr=["herokuapp.com","vercel.app","netlify.app"];function ir(e){const t=null==e?void 0:e.hostname;if(!Tt(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of tr)if(i===e)return!1;return!0}function sr(e,t,i,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:n,passive:r})}function nr(e){return"ph_toolbar_internal"===e.name}const rr=["localhost","127.0.0.1"],or=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var s;return qt(t)?(null!==(s=i)&&void 0!==s||(i=new WeakMap),i.has(t)||i.set(t,er(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return yt(e)}},ar=e=>{const t=null==s?void 0:s.createElement("a");return It(t)?null:(t.href=e,t)},lr=function(e,t="&"){let i,s;const n=[];return Kn(e,function(e,t){It(e)||It(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),n[n.length]=s+"="+i)}),n.join(t)},cr=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let e=0;i.length>e;e++){const n=i[e].split("=");if(n[0]===t){s=n;break}}if(!kt(s)||2>s.length)return"";{let e=s[1];try{e=decodeURIComponent(e)}catch(t){Vn.error("Skipping decoding for malformed query param: "+e)}return e.replace(/\+/g," ")}},ur=function(e,t,i){if(!e||!t||!t.length)return e;const s=e.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const s=l[e].split("=");kt(s)&&(t.includes(s[0])?c.push(s[0]+"="+i):c.push(l[e]))}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=n&&(u+="#"+n),u},dr=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},hr=(e,t)=>e>=t&&u(),pr=(e,t,i,s)=>{if(0===e){if(u()){const e=t+1;return e===i&&s(),e}return t}return 0};function _r(e,t){var i;const s=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!Ct(s))return t;try{const e=s(t);return Tt(e)&&e?e:t}catch(e){return Vn.error("Error in get_current_url, falling back to window.location.href",e),t}}function gr(t){var i;const s=null==e||null===(i=e.location)||void 0===i?void 0:i.href;return It(s)?void 0:_r(t,s)}function fr(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function vr(e){return!!e&&1===e.nodeType}function mr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function yr(e){return!!e&&3===e.nodeType}function br(e){return!!e&&11===e.nodeType&&vr(e.host)}function Sr(e){return e?vt(e).split(/\s+/):[]}function wr(e,t){const i=gr(t);return!!(i&&e&&e.some(e=>i.match(e)))}function kr(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Sr(t)}function Cr(e){return Pt(e)?null:vt(e).split(/(\s+)/).filter(e=>Jr(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Er(e){let t="";return Ur(e)&&!Wr(e)&&e.childNodes&&e.childNodes.length&&Kn(e.childNodes,function(e){var i;yr(e)&&e.textContent&&(t+=null!==(i=Cr(e.textContent))&&void 0!==i?i:"")}),vt(t)}function xr(e){var t;return It(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const Ir=["a","button","form","input","select","textarea","label"];function Tr(e,t){const 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 Mr(e,t){if(It(t))return!0;for(const i of e)if(t.some(e=>Tr(i,e)))return!0;return!1}function Rr(e){const t=e.parentNode;return!(!t||!vr(t))&&t}const Pr=[".ph-no-autocapture","[data-ph-no-autocapture]"],Fr=["next","previous","prev",">","<"],Lr=[...Fr,"+","-","−","–"],Ar=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Or=[".ph-no-deadclick",".ph-no-capture"],Dr=[".ph-no-rageclick",".ph-no-capture"],$r=["","text","search","email","password","url","tel","number"];function Nr(e){return!(!e||!vr(e))&&(!!mr(e,"textarea")||(mr(e,"input")?ft($r,(e.getAttribute("type")||"").toLowerCase()):function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i}(e)))}function Br(t,i){if(!e||qr(t))return!1;let s,n,r;var o,a;if(At(i)?(s=!!i&&Dr,n=void 0,r=!1):(s=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Dr,n=null==i?void 0:i.content_ignorelist,r=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===s)return!1;if(r&&Nr(t))return!1;const{targetElementList:l}=Hr(t,!1);return!function(e,t){if(!1===e||It(e))return!1;let i;if(!0===e)i=Fr;else{if(!kt(e))return!1;if(e.length>10)return Vn.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(({safeText:e,ariaLabel:t})=>i.some(i=>Ar(e,i)||Ar(t,i)))}(n,l.map(e=>{var t;return{safeText:Er(e).toLowerCase(),ariaLabel:(null===(t=e.getAttribute("aria-label"))||void 0===t?void 0:t.toLowerCase().trim())||""}}))&&!Mr(l,s)}const qr=e=>!e||mr(e,"html")||!vr(e),Hr=(t,i)=>{if(!e||qr(t))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const n=[t];let r=t;for(;r.parentNode&&!mr(r,"body");){if(br(r.parentNode)){n.push(r.parentNode.host),r=r.parentNode.host;continue}const t=Rr(r);if(!t)break;if(i||Ir.indexOf(t.tagName.toLowerCase())>-1)s=!0;else try{const i=e.getComputedStyle(t);i&&"pointer"===i.getPropertyValue("cursor")&&(s=!0)}catch(e){}n.push(t),r=t}return{parentIsUsefulElement:s,targetElementList:n}};function Ur(e){const t=new Set;let i=0;for(let s=e;s.parentNode&&!mr(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);const e=kr(s);if(ft(e,"ph-sensitive")||ft(e,"ph-no-capture"))return!1}if(ft(kr(e),"ph-include"))return!0;const s=e.type||"";if(Tt(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=e.name||e.id||"";return!Tt(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Wr(e){return!!(mr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||mr(e,"select")||mr(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const zr=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),jr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Vr=[16,15,14,13],Gr=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Qr=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Kr=/[0-9A-Za-z_]/;function Zr(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function Jr(e,t=!0){if(Pt(e))return!1;if(Tt(e)){if(e=vt(e),t?zr.test((e||"").replace(/[- ]/g,"")):function(e){let t;for(jr.lastIndex=0;t=jr.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of Vr){const s=e+t;if(i.length>=s){const t=i.slice(e,s);if(zr.test(t)&&Zr(t))return!0}}}return!1}(e))return!1;if(t?Gr.test(e):function(e){let t;for(Qr.lastIndex=0;t=Qr.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&Kr.test(e)&&Kr.test(i)))return!0}return!1}(e))return!1}return!0}function Yr(e){let t=Er(e);return t=`${t} ${Xr(e)}`.trim(),Jr(t)?t:""}function Xr(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Kn(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=Er(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${Xr(e)}`.trim())}catch(e){Vn.error("[AutoCapture]",e)}}),t}function eo(e){return e.replace(/"|\\"/g,'\\"')}function to(e){const t=e.attr__class;if(t)return kt(t)?t:Sr(t)}const io=1e6;function so(e){var t;return Math.min(io,null!==(t=e.payloadSizeLimitBytes)&&void 0!==t?t:io)}const no={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:io,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","google-analytics.com","analytics.google.com","nr-data.net","datadoghq.com","datadoghq.eu","ddog-gov.com","segment.io","rudderstack.com","amplitude.com","mixpanel.com","hotjar.com","hotjar.io","fullstory.com"],streamNetworkBody:!1},ro=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],oo=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],ao=["auth","token","secret","session","api-key","apikey","api_key","credential","password","passwd","cookie","csrf","xsrf"],lo=e=>{Pt(e)||Kn(Object.keys(e),t=>{(e=>{const t=e.toLowerCase();return ro.includes(t)||ao.some(e=>t.includes(e))})(t)&&(e[t]="redacted")})},co=["/s/","/e/","/i/"];function uo(e,t,i,s){if(Pt(e))return e;let n=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return Tt(n)&&(n=parseInt(n)),n>i?`[SessionRecording] ${s} body too large to record (${n} bytes)`:e}function ho(e,t){if(Pt(e))return e;let i=e;return Jr(i,!1)||(i="[SessionRecording] "+t+" body redacted"),Kn(oo,e=>{(null==i?void 0:i.length)&&-1!==(null==i?void 0:i.indexOf(e))&&(i="[SessionRecording] "+t+" body redacted as might contain: "+e)}),i}const po=new WeakSet,_o="disabled",go="sampled",fo="active",vo="buffering",mo="paused",yo="lazy_loading",bo="rrweb_error",So="trigger_activated",wo="trigger_pending",ko="trigger_disabled";function Co(e,t,i,s,n,r){return 0===t?ko:(null==e?void 0:e.get_property(i?s+i:n))===r?So:wo}function Eo(e,t,i){return t.some(t=>{var s;return"regex"===t.matching&&(null!==(s=null==i?void 0:i.get(t.url))&&void 0!==s?s:new RegExp(t.url)).test(e)})}function xo(e){return e.includes("trigger_activated")?So:e.includes("trigger_pending")?wo:ko}function Io(e){const t=new Set(e);switch(t.delete(ko),t.size){case 0:return ko;case 1:return Array.from(t)[0];default:return wo}}var To=class{constructor(e){this._matchers=e}triggerStatus(e){return xo(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return xo(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},Mo=class{constructor(e){this._matchers=e}triggerStatus(e){return Io(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return Io(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},Ro=class{triggerStatus(){return this.triggerStatusNoSideEffects()}triggerStatusNoSideEffects(){return So}stop(){}};const Po=e=>"sessionRecording"in e;var Fo=class{constructor(e,t){this._instance=e,this._urlTriggers=[],this._urlBlocklist=[],this._compiledTriggerRegexes=new Map,this._compiledBlocklistRegexes=new Map,this._lastCheckedUrl="",this.urlBlocked=!1,this._groupId=t}onConfig(e){var t,i;this._urlTriggers=(Po(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.urlTriggers:[]:null==e?void 0:e.urlTriggers)||[],this._urlBlocklist=(Po(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.urlBlocklist:[]:null==e?void 0:e.urlBlocklist)||[],this._compileRegexCache()}_compileRegexCache(){this._compiledTriggerRegexes.clear(),this._compiledBlocklistRegexes.clear();for(const e of this._urlTriggers)if("regex"===e.matching&&!this._compiledTriggerRegexes.has(e.url))try{this._compiledTriggerRegexes.set(e.url,new RegExp(e.url))}catch(t){Vn.error("Invalid URL trigger regex pattern:",e.url,t)}for(const e of this._urlBlocklist)if("regex"===e.matching&&!this._compiledBlocklistRegexes.has(e.url))try{this._compiledBlocklistRegexes.set(e.url,new RegExp(e.url))}catch(t){Vn.error("Invalid URL blocklist regex pattern:",e.url,t)}}onRemoteConfig(e){this.onConfig(e)}_urlTriggerStatus(e){return Co(this._instance,this._urlTriggers.length,this._groupId,Q,j,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[ze]:t}),t}triggerStatusNoSideEffects(e){return this._urlTriggerStatus(e)}isCurrentUrlBlocked(){const e=gr(this._instance);if(!e)return!1;try{return Eo(e,this._urlBlocklist,this._compiledBlocklistRegexes)}catch(e){return!0}}checkUrlBlocklist(e,t){const i=gr(this._instance);if(!i)return;if(i===this._lastCheckedUrl)return;this._lastCheckedUrl=i;const s=this.urlBlocked,n=Eo(i,this._urlBlocklist,this._compiledBlocklistRegexes);s&&n||(n&&!s?e():!n&&s&&t())}checkUrlTriggerConditions(e,t,i,s){const n=gr(this._instance);if(!n)return;if(n===this._lastCheckedUrl)return;this._lastCheckedUrl=n;const r=this.urlBlocked,o=Eo(n,this._urlBlocklist,this._compiledBlocklistRegexes);o&&!r?e():!o&&r&&t();const a=this._urlTriggerStatus(s)===So,l=Eo(n,this._urlTriggers,this._compiledTriggerRegexes);!a&&l&&i("url",n)}stop(){this._lastCheckedUrl=""}},Lo=class{constructor(e){this._instance=e,this.linkedFlag=null,this.linkedFlagSeen=!1,this._flagListenerCleanup=()=>{}}triggerStatus(){const e=this.triggerStatusNoSideEffects();return this._instance.register_for_session({[Be]:e}),e}triggerStatusNoSideEffects(){let e=wo;return Pt(this.linkedFlag)&&(e=ko),this.linkedFlagSeen&&(e=So),e}onConfig(e,t){var i;if(this.linkedFlag=(Po(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.linkedFlag:null:null==e?void 0:e.linkedFlag)||null,!Pt(this.linkedFlag)&&!this.linkedFlagSeen){const e=Tt(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,i=Tt(this.linkedFlag)?null:this.linkedFlag.variant;this._flagListenerCleanup=this._instance.onFeatureFlags((s,n)=>{let r=!1;if(Et(n)&&e in n){const t=n[e];r=At(t)?!0===t:i?t===i:!!t}const o=r&&!this.linkedFlagSeen;this.linkedFlagSeen=r,o&&t(e,i)})}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this._flagListenerCleanup()}},Ao=class{constructor(e,t){this._instance=e,this._eventTriggers=[],this._groupId=t}onConfig(e){var t;this._eventTriggers=(Po(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.eventTriggers:[]:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}_eventTriggerStatus(e){return Co(this._instance,this._eventTriggers.length,this._groupId,G,V,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[Ne]:t}),t}triggerStatusNoSideEffects(e){return this._eventTriggerStatus(e)}checkEventTriggerConditions(e,t,i){if(0===this._eventTriggers.length)return;const s=this._eventTriggerStatus(i)===So,n=this._eventTriggers.includes(e);!s&&n&&t("event",e)}stop(){}},Oo=class{constructor(e,t,i){if(this._instance=e,this.group=t,this._urlTriggerMatching=new Fo(e,t.id),this._eventTriggerMatching=new Ao(e,t.id),this._linkedFlagMatching=new Lo(e),t.conditions.events&&t.conditions.events.length>0||t.conditions.urls&&t.conditions.urls.length>0||t.conditions.flag){const e=(t.conditions.events||[]).map(e=>e.name),s={urlTriggers:t.conditions.urls||[],eventTriggers:e,linkedFlag:t.conditions.flag||null,urlBlocklist:[]};this._urlTriggerMatching.onConfig(s),this._eventTriggerMatching.onConfig(s),this._linkedFlagMatching.onConfig(s,i);const n=[this._eventTriggerMatching,this._urlTriggerMatching,this._linkedFlagMatching];this._combinedMatching="any"===t.conditions.matchType?new To(n):new Mo(n)}else this._combinedMatching=new Ro}triggerStatus(e){return this._combinedMatching.triggerStatus(e)}triggerStatusNoSideEffects(e){return this._combinedMatching.triggerStatusNoSideEffects(e)}getPendingTriggerConditions(e){return"trigger_pending"!==this.triggerStatusNoSideEffects(e)?[]:[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===wo).map(({label:e})=>e)}checkEventTriggerConditions(e,t,i){this._eventTriggerMatching.checkEventTriggerConditions(e,t,i)}checkUrlTriggerConditions(e,t,i,s){this._urlTriggerMatching.checkUrlTriggerConditions(e,t,i,s)}activateTrigger(e,t){var i;const s="url"===e?Q+this.group.id:G+this.group.id;null===(i=this._instance.persistence)||void 0===i||i.register({[s]:t})}stop(){this._urlTriggerMatching.stop(),this._eventTriggerMatching.stop(),this._linkedFlagMatching.stop()}};function Do(e){if(e.rrwebError)return bo;if(!e.receivedFlags)return vo;if(!e.isRecordingEnabled)return _o;if(e.urlTriggerMatching.urlBlocked)return mo;const t=!0===e.isSampled,i=new To([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?go:"trigger_activated"===i?fo:"trigger_pending"===i?vo:!1===e.isSampled?_o:fo}function $o(e){if(e.rrwebError)return bo;if(!e.receivedFlags)return vo;if(!e.isRecordingEnabled)return _o;if(e.urlTriggerMatching.urlBlocked)return mo;const t=new Mo([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),i=t!==ko,s=At(e.isSampled);return i&&"trigger_pending"===t?vo:i&&"trigger_disabled"===t||s&&!e.isSampled?_o:!0===e.isSampled?go:fo}function No(){const e=[];return function(t,i){if(Et(i)||kt(i)){for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i}}function Bo(e){const t=JSON.stringify(e,No());return t?new Blob([t]).size:0}function qo(e){if(Rt(e))return 4;if(It(e))return 0;switch(typeof e){case"string":return e.length+2;case"number":return String(e).length;case"boolean":return e?4:5;case"object":{if(kt(e)){let t=2;for(let i=0;e.length>i;i++){i>0&&(t+=1);const s=e[i];t+=It(s)||Rt(s)?4:qo(s)}return t}const t=e;let i=2,s=!0;for(const e in t){if(!{}.hasOwnProperty.call(t,e))continue;const n=t[e];It(n)||(s||(i+=1),s=!1,i+=e.length+3+qo(n))}return i}default:return 0}}function Ho(e,t=6606028.8){if(e.size>=t&&e.data.length>1){const t=Math.floor(e.data.length/2),i=e.sizes.slice(0,t),s=e.sizes.slice(t);return[Ho({size:i.reduce((e,t)=>e+t,0),data:e.data.slice(0,t),sizes:i,sessionId:e.sessionId,windowId:e.windowId}),Ho({size:s.reduce((e,t)=>e+t,0),data:e.data.slice(t),sizes:s,sessionId:e.sessionId,windowId:e.windowId})].flatMap(e=>e)}return[e]}var Uo=Uint8Array,Wo=Uint16Array,zo=Uint32Array,jo=new Uo([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]),Vo=new Uo([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]),Go=new Uo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qo=function(e,t){for(var i=new Wo(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var n=new zo(i[30]);for(s=1;30>s;++s)for(var r=i[s];i[s+1]>r;++r)n[r]=r-i[s]<<5|s;return[i,n]},Ko=Qo(jo,2),Zo=Ko[1];Ko[0][28]=258,Zo[258]=28;for(var Jo=Qo(Vo,0)[1],Yo=new Wo(32768),Xo=0;32768>Xo;++Xo){var ea=(43690&Xo)>>>1|(21845&Xo)<<1;Yo[Xo]=((65280&(ea=(61680&(ea=(52428&ea)>>>2|(13107&ea)<<2))>>>4|(3855&ea)<<4))>>>8|(255&ea)<<8)>>>1}var ta=function(e,t,i){for(var s=e.length,n=0,r=new Wo(t);s>n;++n)++r[e[n]-1];var o,a=new Wo(t);for(n=0;t>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new Wo(1<<t);var l=15-t;for(n=0;s>n;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[Yo[d]>>>l]=c}else for(o=new Wo(s),n=0;s>n;++n)o[n]=Yo[a[e[n]-1]++]>>>15-e[n];return o},ia=new Uo(288);for(Xo=0;144>Xo;++Xo)ia[Xo]=8;for(Xo=144;256>Xo;++Xo)ia[Xo]=9;for(Xo=256;280>Xo;++Xo)ia[Xo]=7;for(Xo=280;288>Xo;++Xo)ia[Xo]=8;var sa=new Uo(32);for(Xo=0;32>Xo;++Xo)sa[Xo]=5;var na=ta(ia,9,0),ra=ta(sa,5,0),oa=function(e){return(e/8|0)+(7&e&&1)},aa=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Wo?Wo:e instanceof zo?zo:Uo)(i-t);return s.set(e.subarray(t,i)),s},la=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},ca=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},ua=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new Uo(0),0];if(1==n){var o=new Uo(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;n>s;++s)r[s].s>h&&(h=r[s].s);var p=new Wo(h+1),_=da(i[u-1],p,0);if(_>t){s=0;var g=0,f=_-t,v=1<<f;for(r.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});n>s;++s){var m=r[s].s;if(t>=p[m])break;g+=v-(1<<_-p[m]),p[m]=t}for(g>>>=f;g>0;){var y=r[s].s;t>p[y]?g-=1<<t-p[y]++-1:++s}for(;s>=0&&g;--s){var b=r[s].s;p[b]==t&&(--p[b],++g)}_=t}return[new Uo(p),_]},da=function(e,t,i){return-1==e.s?Math.max(da(e.l,t,i+1),da(e.r,t,i+1)):t[e.s]=i},ha=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Wo(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},pa=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},_a=function(e,t,i){var s=i.length,n=oa(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;s>r;++r)e[n+r+4]=i[r];return 8*(n+4+s)},ga=function(e,t,i,s,n,r,o,a,l,c,u){la(t,u++,i),++n[256];for(var d=ua(n,15),h=d[0],p=d[1],_=ua(r,15),g=_[0],f=_[1],v=ha(h),m=v[0],y=v[1],b=ha(g),S=b[0],w=b[1],k=new Wo(19),C=0;m.length>C;++C)k[31&m[C]]++;for(C=0;S.length>C;++C)k[31&S[C]]++;for(var E=ua(k,7),x=E[0],I=E[1],T=19;T>4&&!x[Go[T-1]];--T);var M,R,P,F,L=c+5<<3,A=pa(n,ia)+pa(r,sa)+o,O=pa(n,h)+pa(r,g)+o+14+3*T+pa(k,x)+(2*k[16]+3*k[17]+7*k[18]);if(A>=L&&O>=L)return _a(t,u,e.subarray(l,l+c));if(la(t,u,1+(A>O)),u+=2,A>O){M=ta(h,p,0),R=h,P=ta(g,f,0),F=g;var D=ta(x,I,0);for(la(t,u,y-257),la(t,u+5,w-1),la(t,u+10,T-4),u+=14,C=0;T>C;++C)la(t,u+3*C,x[Go[C]]);u+=3*T;for(var N=[m,S],B=0;2>B;++B){var q=N[B];for(C=0;q.length>C;++C)la(t,u,D[H=31&q[C]]),u+=x[H],H>15&&(la(t,u,q[C]>>>5&127),u+=q[C]>>>12)}}else M=na,R=ia,P=ra,F=sa;for(C=0;a>C;++C)if(s[C]>255){var H;ca(t,u,M[257+(H=s[C]>>>18&31)]),u+=R[H+257],H>7&&(la(t,u,s[C]>>>23&31),u+=jo[H]);var U=31&s[C];ca(t,u,P[U]),u+=F[U],U>3&&(ca(t,u,s[C]>>>5&8191),u+=Vo[U])}else ca(t,u,M[s[C]]),u+=R[s[C]];return ca(t,u,M[256]),u+R[256]},fa=new zo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),va=new Uo(0),ma=function(){for(var e=new zo(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),ya=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ba(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=ma[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var n,r,o,a,l,c=(n=e,r=t,o=function(e){return 10+(e.filename&&e.filename.length+1||0)}(t),a=8,function(e,t,i,s,n,r){var o=e.length,a=new Uo(s+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(s,a.length-n),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=_a(l,c,e.subarray(u,d)):(l[u]=r,c=_a(l,c,e.subarray(u,o)))}else{for(var h=fa[t-1],p=h>>>13,_=8191&h,g=(1<<i)-1,f=new Wo(32768),v=new Wo(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},S=new zo(25e3),w=new Wo(288),k=new Wo(32),C=0,E=0,x=(u=0,0),I=0,T=0;o>u;++u){var M=b(u),R=32767&u,P=v[M];if(f[R]=P,v[M]=R,u>=I){var F=o-u;if((C>7e3||x>24576)&&F>423){c=ga(e,l,0,S,w,k,E,x,T,u-T,c),x=C=E=0,T=u;for(var L=0;286>L;++L)w[L]=0;for(L=0;30>L;++L)k[L]=0}var A=2,O=0,D=_,N=R-P&32767;if(F>2&&M==b(u-N))for(var B=Math.min(p,F)-1,q=Math.min(32767,u),H=Math.min(258,F);q>=N&&--D&&R!=P;){if(e[u+A]==e[u+A-N]){for(var U=0;H>U&&e[u+U]==e[u+U-N];++U);if(U>A){if(A=U,O=N,U>B)break;var W=Math.min(N,U-2),z=0;for(L=0;W>L;++L){var j=u-N+L+32768&32767,V=j-f[j]+32768&32767;V>z&&(z=V,P=j)}}}N+=(R=P)-(P=f[R])+32768&32767}if(O){S[x++]=268435456|Zo[A]<<18|Jo[O];var G=31&Zo[A],Q=31&Jo[O];E+=jo[G]+Vo[Q],++w[257+G],++k[Q],I=u+A,++C}else S[x++]=e[u],++w[e[u]]}}c=ga(e,l,r,S,w,k,E,x,T,u-T,c),r||(c=_a(l,c,va))}return aa(a,0,s+oa(c)+n)}(n,null==r.level?6:r.level,null==r.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+r.mem,o,a,!l)),u=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&&ya(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),ya(c,u-8,i.d()),ya(c,u-4,s),c}function Sa(e,t){var i=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new Uo(e.length+(e.length>>>1)),n=0,r=function(e){s[n++]=e},o=0;i>o;++o){if(n+5>s.length){var a=new Uo(n+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);128>l||t?r(l):2048>l?(r(192|l>>>6),r(128|63&l)):l>55295&&57344>l?(r(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),r(128|l>>>12&63),r(128|l>>>6&63),r(128|63&l)):(r(224|l>>>12),r(128|l>>>6&63),r(128|63&l))}return aa(s,0,n)}function wa(e,t){var i="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var s=0;e.length>s;){var n=e[s++];128>n||t?i+=String.fromCharCode(n):224>n?i+=String.fromCharCode((31&n)<<6|63&e[s++]):240>n?i+=String.fromCharCode((15&n)<<12|(63&e[s++])<<6|63&e[s++]):(n=((15&n)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,i+=String.fromCharCode(55296|n>>10,56320|1023&n))}return i}var ka=class{constructor(e,t={}){var i,s,n,r;this._rrweb=e,this._options=t,this._loggedTracker={},this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0,this._refillByteBudget=()=>{const e=Date.now(),t=e-this._lastByteRefill;t>0?(this._byteTokens=Math.min(this._bytesBucketSize,this._byteTokens+t/1e3*this._bytesRefillRate),this._lastByteRefill=e):this._lastByteRefill=e},this._onNodeRateLimited=e=>{if(!this._loggedTracker[e]){var t,i;this._loggedTracker[e]=!0;const s=this._getNode(e);null===(t=(i=this._options).onBlockedNode)||void 0===t||t.call(i,e,s)}},this._getNodeOrRelevantParent=e=>{const t=this._getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){const e=t.closest("svg");if(e)return[this._rrweb.mirror.getId(e),e]}return[e,t]},this._getNode=e=>this._rrweb.mirror.getNode(e),this._numberOfChanges=e=>{var t,i,s,n,r,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null===(n=e.attributes)||void 0===n?void 0:n.length)&&void 0!==s?s:0)+(null!==(r=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==r?r:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;const t=e.data,i=this._numberOfChanges(t);if(t.attributes){const e=t.attributes.length;t.attributes=t.attributes.filter(e=>{const[t]=this._getNodeOrRelevantParent(e.id);return!this._rateLimiter.consumeRateLimit(t)&&e});const i=e-t.attributes.length;var s,n;i>0&&(null===(s=(n=this._options).onDroppedAttributeMutations)||void 0===s||s.call(n,i))}const r=this._numberOfChanges(t);if(0===r&&i!==r)return;if(this._byteBudgetDisabled)return e;this._refillByteBudget();const o=qo(e);var a,l;return o>this._byteTokens?(null===(a=(l=this._options).onDroppedOversizedMutation)||void 0===a||a.call(l,o),void this._scheduleResync()):(this._byteTokens-=o,e)},this._scheduleResync=()=>{if(this._resyncTimer)return;const e=Math.max(0,this._resyncIntervalMs-(Date.now()-this._lastResyncAt));this._resyncTimer=setTimeout(()=>{var e,t;this._resyncTimer=void 0,this._lastResyncAt=Date.now(),null===(e=(t=this._options).requestFullSnapshot)||void 0===e||e.call(t)},e)},this._rateLimiter=new Kt({bucketSize:null!==(i=this._options.bucketSize)&&void 0!==i?i:100,refillRate:null!==(s=this._options.refillRate)&&void 0!==s?s:10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited,_logger:Vn}),this._bytesBucketSize=null!==(n=this._options.bytesBucketSize)&&void 0!==n?n:0,this._bytesRefillRate=null!==(r=this._options.bytesRefillRate)&&void 0!==r?r:25600,this._byteBudgetDisabled=!Number.isFinite(this._bytesBucketSize)||0>=this._bytesBucketSize,this._byteTokens=this._bytesBucketSize;const o=this._options.resyncIntervalMs;this._resyncIntervalMs=Ft(o)&&Number.isFinite(o)&&o>0?o:3e5}reset(){this._loggedTracker={},this._resyncTimer&&(clearTimeout(this._resyncTimer),this._resyncTimer=void 0),this._lastResyncAt=Date.now()}stop(){this._rateLimiter.stop(),this.reset(),this._byteTokens=this._bytesBucketSize,this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0}};const Ca=e=>{if(s){try{const t=e+"=",i=s.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(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 Ea=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,n){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(n)||0>t||0>i||0>s||0>n||t>0xffffffffffff||i>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new e(r)}toString(){let e="";for(let 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(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},xa=class{generate(){const e=this.generateOrAbort();if(!It(e))return e;{this._timestamp=0;const e=this.generateOrAbort();if(It(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return Ft(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Ea.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 Ta}};let Ia=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!It(e.crypto)&&crypto.getRandomValues&&(Ia=e=>crypto.getRandomValues(e));var Ta=class{nextUint32(){return this._buffer.length>this._cursor||(Ia(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}};let Ma;const Ra=()=>Pa().toString(),Pa=()=>(Ma||(Ma=new xa)).generate();let Fa="";const La=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Aa=null;const Oa={_is_supported(){if(!Rt(Aa))return Aa;if(Aa=!1,s)try{const e=`__ph_cookie_support_${Ra()}`;Oa._set(e,"xyz"),Aa='"xyz"'===Ca(e),Oa._remove(e)}catch(e){Aa=!1}return Aa},_error(e){Vn.error("cookieStore error: "+e)},_get:Ca,_parse(e){let t;try{t=JSON.parse(Oa._get(e))||{}}catch(e){}return t},_set(e,t,i,n,r){if(!s)return!1;try{let o="",a="";const l=function(e,t){if(t){let t=function(e,t=s){if(Fa)return Fa;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let n=Math.min(i.length,8);const r="dmn_chk_"+Ra();for(;!Fa&&n--;){const e=i.slice(n).join("."),s=r+"=1;domain=."+e+";path=/";t.cookie=s+";max-age=3",t.cookie.includes(r)&&(t.cookie=s+";max-age=0",Fa=e)}return Fa}(e);if(!t){const i=(e=>{const t=e.match(La);return t?t[0]:""})(e);i!==t&&Vn.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}(s.location.hostname,n);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),o="; expires="+e.toUTCString()}r&&(a="; secure");const c=e+"="+encodeURIComponent(JSON.stringify(t))+o+"; SameSite=Lax; path=/"+l+a;return c.length>3686.4&&Vn.warn("cookieStore warning: large cookie, len="+c.length),s.cookie=c,!0}catch(e){return!1}},_remove(e,t){if(null==s?void 0:s.cookie)try{Oa._set(e,"",-1,t)}catch(e){return}}};let Da=null;const $a={_is_supported(){if(!Rt(Da))return Da;let t=!0;if(It(e))t=!1;else try{const e="__mplssupport__";$a._set(e,"xyz"),'"xyz"'!==$a._get(e)&&(t=!1),$a._remove(e)}catch(e){t=!1}return t||Vn.error("localStorage unsupported; falling back to cookie store"),Da=t,t},_error(e){Vn.error("localStorage error: "+e)},_get(t){try{return null==e?void 0:e.localStorage.getItem(t)}catch(e){$a._error(e)}return null},_parse(e){try{return JSON.parse($a._get(e))||{}}catch(e){}return null},_set(t,i){try{return null==e||e.localStorage.setItem(t,JSON.stringify(i)),!0}catch(e){$a._error(e)}return!1},_remove(t){try{null==e||e.localStorage.removeItem(t)}catch(e){$a._error(e)}}},Na=[ae,X,Y,te,ie,se,Ee,Ce,we],Ba=[g,_,U,W,Fe,Pe,b,xe],qa=e=>e+"_cpm",Ha=["__proto__","constructor","prototype"],Ua=e=>{if(!Et(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===Ha.indexOf(i)&&(t[i]=e[i])}),t},Wa=(e,t=[])=>{const i={};return[...Ba,...t].forEach(t=>{const s=e[t];It(s)||Rt(s)||""===s||(i[t]=s)}),i},za=e=>{let t=5381,i=2166136261;for(let s=0;e.length>s;s++){const n=e.charCodeAt(s);t=33*t^n,i=Math.imul(i^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},ja=(e,t)=>({p:t,f:za(JSON.stringify(e))}),Va=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=Oa._parse(qa(e)),s=(null==i?void 0:i.f)===za(t)&&kt(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Ga=(e,t)=>t+"|"+(Oa._get(qa(e))||""),Qa={},Ka={_is_supported:()=>!0,_error(e){Vn.error("memoryStorage error: "+e)},_get:e=>e in Qa?Qa[e]:null,_parse:e=>e in Qa?Qa[e]:null,_set:(e,t)=>(Qa[e]=t,!0),_remove(e){delete Qa[e]}};let Za=null;const Ja={_is_supported(){if(!Rt(Za))return Za;if(Za=!0,It(e))Za=!1;else try{const e="__support__";Ja._set(e,"xyz"),'"xyz"'!==Ja._get(e)&&(Za=!1),Ja._remove(e)}catch(e){Za=!1}return Za},_error(e){Vn.error("sessionStorage error: ",e)},_get(t){try{return null==e?void 0:e.sessionStorage.getItem(t)}catch(e){Ja._error(e)}return null},_parse(e){try{return JSON.parse(Ja._get(e))||null}catch(e){}return null},_set(t,i){try{return null==e||e.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(e){Ja._error(e)}return!1},_remove(t){try{null==e||e.sessionStorage.removeItem(t)}catch(e){Ja._error(e)}}};zn.DEBUG=!1,zn.LIB_VERSION="1.433.2",zn.LIB_NAME="web";var Ya=zn,Xa=class{constructor(e){if(!e.persistence)throw new Error("it is not valid to not have persistence and be this far into setting up the application");this._getProperty=e.get_property.bind(e),this._setProperty=e.persistence.set_property.bind(e.persistence)}trackSize(e,t){this._setProperty(J,{sessionId:e,size:this.currentTrackedSize(e)+t})}currentTrackedSize(e){const t=this._getProperty(J);return Et(i=t)&&Tt(i.sessionId)&&Ft(i.size)&&t.sessionId===e?t.size:0;var i}};function el(e,t){return function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<Qt(100*t,0,100,Vn)}function tl(e){return`$survey_response_${e}`}function il(e,t){if(!t)return null;const i=e[tl(t)];return kt(i)?[...i]:i}function sl(e={},t,i){const s={};return t.questions.forEach(t=>{if(It(t.originalQuestionIndex))return;const i=0===(n=t.originalQuestionIndex)?"$survey_response":`$survey_response_${n}`;var n;const r=il(e,t.id);It(r)||(s[i]=r)}),ct(ct({$survey_questions:t.questions.map(t=>{var s,n;return{id:t.id,question:null!==(s=null==i?void 0:i[null!==(n=t.id)&&void 0!==n?n:""])&&void 0!==s?s:t.question,response:il(e,t.id)}})},e),s)}function nl(e={}){return Object.values(e).some(e=>!Pt(e))}function rl(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function ol(e){return"string"==typeof e&&e.trim()?e.trim():null}function al(e){return e.toLowerCase()}function ll(e,t,i){if(!e||!t)return null;const s=al(t),n=Object.keys(e).find(e=>al(e)===s);if(n)return null==i||i.debug(`Found exact translation match: ${n}`),n;if(s.includes("-")){const n=s.split("-")[0],r=Object.keys(e).find(e=>al(e)===n);if(r)return null==i||i.debug(`Found base language translation match: ${r} (from ${t})`),r}return null}const cl=["thankYouMessageHeader","thankYouMessageDescription","thankYouMessageCloseButtonText","introScreenHeader","introScreenDescription","introScreenButtonText","submitButtonText","backButtonText"];function ul(e,t,i){var s;const n=ll(e.translations,t,i),r=ct({},e);let o=!1;if(n){var a;const t=null===(a=e.translations)||void 0===a?void 0:a[n];if(t)if(null==i||i.info(`Applying survey-level translation for language: ${n}`),It(t.name)||(r.name=t.name,o=!0),r.appearance){const e=ct({},r.appearance);for(const i of cl){const s=t[i];It(s)||(e[i]=s,o=!0)}r.appearance=e}else(function(e){return cl.some(t=>!It(e[t]))})(t)&&(o=!0)}const l=e.questions.map(e=>function(e,t,i){var s;const n=ll(e.translations,t,i);if(!n)return{question:e,matchedKey:null,hasChanges:!1};const r=null===(s=e.translations)||void 0===s?void 0:s[n];if(!r)return{question:e,matchedKey:null,hasChanges:!1};const o=ct({},e);let a=!1;return It(r.question)||(o.question=r.question,a=!0),It(r.description)||(o.description=r.description,a=!0),It(r.buttonText)||(o.buttonText=r.buttonText,a=!0),"link"in o&&!It(r.link)&&(o.link=r.link,a=!0),"lowerBoundLabel"in o&&!It(r.lowerBoundLabel)&&(o.lowerBoundLabel=r.lowerBoundLabel,a=!0),"upperBoundLabel"in o&&!It(r.upperBoundLabel)&&(o.upperBoundLabel=r.upperBoundLabel,a=!0),"choices"in o&&function(e){return kt(e.choices)}(r)&&(o.choices=r.choices,a=!0),{question:a?o:e,matchedKey:a?n:null,hasChanges:a}}(e,t,i)),c=l.map(e=>e.question),u=l.some(e=>e.hasChanges);let d=null;return n||(d=(null===(s=l.find(e=>e.matchedKey))||void 0===s?void 0:s.matchedKey)||null),u&&(r.questions=c,o=!0,null==i||i.info(`Applied question-level translations for language: ${t}`)),{survey:r,matchedKey:o?n||d:null}}function dl(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}function hl(e){var t;return dl(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule}const pl=(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}},_l=e=>e.toLowerCase(),gl={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=>pl(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!pl(t,e))),icontains:(e,t)=>t.map(_l).some(t=>e.map(_l).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(_l).every(t=>e.map(_l).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function fl(e,t){return!e||Object.entries(e).every(([e,i])=>{const s=null==t?void 0:t[e];if(null==s)return!1;const n=gl[i.operator];return!!n&&n(i.values,[String(s)])})}function vl(e,t,i){return or({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const ml=new Set(["is_not","not_icontains","not_regex"]);function yl(e,t,i){return!e||0===e.length||e.every(e=>{const s="person"===e.type?i:t,n=null==s?void 0:s[e.key],r=e.operator||"exact";if(It(n)||Rt(n))return ml.has(r);const o=gl[r];return!!o&&!It(e.value)&&!Rt(e.value)&&o(kt(e.value)?e.value.map(String):[String(e.value)],kt(n)?n.map(String):[String(n)])})}const bl=Gn("[SessionRecording]");function Sl(e,t){return t?e:"!"+e}function wl(e,t){return e===t||e!=="!"+t&&null}var kl=class{constructor(e,t,i,s,n,r,o){this._instance=e,this._urlTriggerMatching=t,this._eventTriggerMatching=i,this._linkedFlagMatching=s,this._reportStarted=n,this._tryTakeFullSnapshot=r,this._onTriggerActivated=o,this._sampleRate=null,this._recordingStatusFunction=$o}onRemoteConfig(e){this._sampleRate=Ft(e.sampleRate)?e.sampleRate:null,"any"===e.triggerMatchType?(this._triggerStatusMatcher=new To([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=Do):(this._triggerStatusMatcher=new Mo([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=$o),this._instance.register_for_session({[Ue]:e.triggerMatchType}),this._urlTriggerMatching.onConfig(e),this._eventTriggerMatching.onConfig(e),this._linkedFlagMatching.onConfig(e,(e,t)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:t}),this._onTriggerActivated()})}getStatus(e){return this._recordingStatusFunction({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId})}getMinimumDuration(e){const t=this._instance.get_property("$session_recording_remote_config"),i=null==t?void 0:t.minimumDurationMilliseconds;return Ft(i)?i:null}checkUrlTriggers(e,t,i,s){this._urlTriggerMatching.checkUrlTriggerConditions(t,i,s,e)}setupEventTriggerListeners(e,t,i){if(0!==this._eventTriggerMatching._eventTriggers.length&&Pt(this._removeEventTriggerCaptureHook))return this._removeEventTriggerCaptureHook=e(e=>{try{this._eventTriggerMatching.checkEventTriggerConditions(e.event,i,t)}catch(e){bl.error("Could not activate event trigger",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){var t;const i=this._sampleRate;var s,n;if(!Ft(i))return null===(s=this._instance.persistence)||void 0===s||s.unregister("$session_is_sampled"),void(null===(n=this._instance.persistence)||void 0===n||n.unregister("$replay_sample_rate"));const r=this._instance.get_property(W),o=this._instance.get_property(D),a=wl(r,e),l=Ft(o)&&o!==i,c=It(o)&&r===e,u=l||c||!At(a),d=u?el(e,i):a;u&&(d?this._reportStarted("sampled"):bl.warn(`Sample rate (${i}) has determined that this sessionId (${e}) will not be sent to the server.`)),null===(t=this._instance.persistence)||void 0===t||t.register({$session_is_sampled:Sl(e,d),$replay_sample_rate:Rt(o)&&r===e?null:i})}ensureSamplingDecision(e){if(!Ft(this._sampleRate))return;const t=this._instance.get_property(W);At(wl(t,e))||this.makeSamplingDecisions(e)}onFlushComplete(){}clearConditionalRecordingPersistence(){var e,t,i,s,n;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_recording_event_trigger_activated_session"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$session_recording_url_trigger_activated_session"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_is_sampled"),null===(s=this._instance.persistence)||void 0===s||s.unregister("$replay_sample_rate"),null===(n=this._instance.persistence)||void 0===n||n.unregister("$session_past_minimum_duration")}updateActiveTriggers(e){}hasPendingTriggers(e){var t;return(null===(t=this._triggerStatusMatcher)||void 0===t?void 0:t.triggerStatus(e))===wo}getPendingTriggerConditions(e){return[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===wo).map(({label:e})=>e)}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._eventTriggerMatching.stop(),this._urlTriggerMatching.stop(),this._linkedFlagMatching.stop()}},Cl=class{constructor(e,t,i,s,n){this._instance=e,this._urlTriggerMatching=t,this._reportStarted=i,this._tryAddCustomEvent=s,this._onTriggerActivated=n,this._triggerGroupMatchers=[],this._triggerGroupSamplingResults=new Map,this._hasCompletedInitialFlush=!1}onRemoteConfig(e){e.triggerGroups&&0!==e.triggerGroups.length?(this._setupTriggerGroups(e.triggerGroups),this._instance.register_for_session({[Ue]:"v2_trigger_groups",[We]:e.triggerGroups.length}),this._urlTriggerMatching.onConfig(e)):bl.warn("[V2Strategy] No trigger groups configured")}getStatus(e){return function(e){if(e.rrwebError)return bo;if(!e.receivedFlags)return vo;if(!e.isRecordingEnabled)return _o;if(e.urlTriggerMatching.urlBlocked)return mo;const t=e.triggerGroupMatchers,i=e.triggerGroupSamplingResults;if(0===t.length)return _o;let s=!1,n=!1;for(const r of t){const t=r.triggerStatus(e.sessionId);if("trigger_activated"===t){const e=r.group.id,t=i.get(e);It(t)?Vn.warn("[V2 Triggers] Group activated but no sampling decision found",{groupId:e}):!0===t&&(n=!0)}else"trigger_pending"===t&&(s=!0)}return n?go:s?vo:_o}({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId,triggerGroupMatchers:this._triggerGroupMatchers,triggerGroupSamplingResults:this._triggerGroupSamplingResults,minimumDuration:this.getMinimumDuration(e.sessionId)})}getMinimumDuration(e){let t=null;for(const i of this._triggerGroupMatchers)if("trigger_activated"===i.triggerStatus(e)){const e=i.group.minDurationMs;Ft(e)&&(Rt(t)||t>e)&&(t=e)}return t}checkUrlTriggers(e,t,i,s){this._urlTriggerMatching.checkUrlBlocklist(t,i);for(const s of this._triggerGroupMatchers)s.checkUrlTriggerConditions(t,i,t=>{this._checkGroupLevelProperties(s,void 0)&&(s.activateTrigger(t,e),this.updateActiveTriggers(e),this._onTriggerActivated(t))},e)}setupEventTriggerListeners(e,t,i){return this._removeEventTriggerCaptureHook=e(e=>{var i;if(this._hasCompletedInitialFlush)return bl.info("[SessionRecorder] Stopping trigger checks - initial buffer flushed"),null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),void(this._removeEventTriggerCaptureHook=void 0);try{for(const i of this._triggerGroupMatchers)i.checkEventTriggerConditions(e.event,s=>{if(!this._checkGroupLevelProperties(i,e.properties))return;const n=(i.group.conditions.events||[]).filter(t=>t.name===e.event),r=this._instance.get_property(ae);n.some(t=>!t.properties||0===t.properties.length||yl(t.properties,e.properties,r))&&(i.activateTrigger(s,t),this.updateActiveTriggers(t),this._onTriggerActivated(s))},t)}catch(e){bl.error("Could not activate event trigger for trigger groups",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){for(const i of this._triggerGroupMatchers){var t;const s=i.group,n=s.id,r=s.sampleRate,o=K+n,a=this._instance.get_property(o);let l=null,c=!1,u=!1,d=!1;if(Et(a)){const t=a.sessionId,i=a.sampleRate,s=a.sampled;c="string"==typeof t&&t!==e,u=Ft(i)&&i!==r,l=t===e&&Ft(i)&&i===r&&At(s)?s:null}else l=a===e||null,c="string"==typeof a&&a!==e,d=a===e;const h=c||u||d||!At(l),p=h?el(e+n,r):l;h&&this._tryAddCustomEvent("triggerGroupSamplingDecisionMade",{group_id:n,group_name:s.name,sampleRate:r,isSampled:p}),this._triggerGroupSamplingResults.set(n,p),null===(t=this._instance.persistence)||void 0===t||t.register({[o]:{sessionId:e,sampleRate:r,sampled:p}})}this.updateActiveTriggers(e)}ensureSamplingDecision(e){}onFlushComplete(){this._hasCompletedInitialFlush=!0}clearConditionalRecordingPersistence(){var e,t,i;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$replay_sample_rate"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_past_minimum_duration");for(const e of this._triggerGroupMatchers){var s,n,r;const t=e.group.id;null===(s=this._instance.persistence)||void 0===s||s.unregister("$posthog_sr_group_event_trigger_"+t),null===(n=this._instance.persistence)||void 0===n||n.unregister("$posthog_sr_group_url_trigger_"+t),null===(r=this._instance.persistence)||void 0===r||r.unregister("$posthog_sr_group_sampling_"+t)}}updateActiveTriggers(e){const t=[];for(const i of this._triggerGroupMatchers){const s=i.group,n=s.id,r="trigger_activated"===i.triggerStatus(e),o=!0===this._triggerGroupSamplingResults.get(n);r&&t.push({id:n,name:s.name,matched:!0,sampled:o})}this._instance.register_for_session({[qe]:t})}hasPendingTriggers(e){for(const t of this._triggerGroupMatchers)if("trigger_pending"===t.triggerStatus(e))return!0;return!1}getPendingTriggerConditions(e){return this._triggerGroupMatchers.flatMap(t=>"trigger_pending"!==t.triggerStatusNoSideEffects(e)?[]:t.getPendingTriggerConditions(e).map(e=>`trigger group "${t.group.name}": ${e}`))}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear(),this._urlTriggerMatching.stop()}_checkGroupLevelProperties(e,t){const i=e.group.conditions.properties;return!i||0===i.length||yl(i,t,this._instance.get_property(ae))}_setupTriggerGroups(e){this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear();for(const t of e){const e=new Oo(this._instance,t,(e,i)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:i,group_id:t.id,group_name:t.name}),this._onTriggerActivated()});this._triggerGroupMatchers.push(e)}}};const El=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],xl=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...El],Il="<masked>",Tl=["li_fat_id"];function Ml(e,t,i){if(!s)return{};const n=t?[...El,...i||[]]:[],r=Rl(ur(s.URL,n,Il),e),o=function(){const e={};return Kn(Tl,function(t){const i=Ca(t);e[t]=i||null}),e}();return Zn(o,r)}function Rl(e,t){const i=xl.concat(t||[]),s={};return Kn(i,function(t){const i=cr(e,t);s[t]=i||null}),s}function Pl(e){const 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",n={};if(!Rt(t)){n.$search_engine=t;const e=s?cr(s.referrer,i):"";e.length&&(n.ph_keyword=e)}return n}function Fl(){return navigator.language||navigator.userLanguage}function Ll(){const e=Fl();return"string"==typeof e?e.split("-")[0]:void 0}const Al="$direct";function Ol(){return(null==s?void 0:s.referrer)||Al}function Dl(e,t,i=!1){const s=e?[...El,...t||[]]:[],r=i?ls(null==n?void 0:n.href):null==n?void 0:n.href,o=null==r?void 0:r.substring(0,1e3);return{r:Ol().substring(0,1e3),u:o?ur(o,s,Il):void 0}}function $l(e,t=!1){var i;const{r:s,u:n}=e,r=t?ls(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Al?Al:null===(i=ar(s))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=ar(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Rl(r);Zn(o,t)}if(s){const e=Pl(s);Zn(o,e)}return o}function Nl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Bl(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const ql=1e5,Hl=/^[A-Za-z0-9]*[A-Za-z][A-Za-z0-9]*$/,Ul=[],Wl=()=>!1,zl="@type @id actionStatus availability bestRating contentRating encodingFormat eventAttendanceMode eventStatus highPrice inLanguage isAccessibleForFree isFamilyFriendly itemCondition itemListOrder lowPrice maximumAttendeeCapacity nonprofitStatus numberOfItems offerCount position price priceCurrency priceValidUntil publicAccess ratingCount ratingValue reviewCount smokingAllowed worstRating".split(" "),jl="Action BorrowAction ReadAction SearchAction SeekToAction SolveMathAction WatchAction".split(" "),Vl="AutoDealer Bakery BarOrPub CafeOrCoffeeShop CollegeOrUniversity Corporation DaySpa Dentist EducationalOrganization Electrician FoodEstablishment GovernmentOrganization HealthClub Hotel LegalService Library LibrarySystem LocalBusiness Locksmith LodgingBusiness MedicalBusiness NGO OnlineStore Organization PerformingGroup Pharmacy Physician Plumber RealEstateAgent Restaurant School SportsOrganization Store".split(" "),Gl="Accommodation AdministrativeArea Country Place State".split(" "),Ql={AggregateOffer:{offers:["Offer"]},Brand:{name:!0},BreadcrumbList:{itemListElement:["ListItem"]},CreativeWork:{genre:!0,dateCreated:!0,dateModified:!0,datePublished:!0,expires:!0,learningResourceType:!0,educationalLevel:!0,educationalUse:!0,interactivityType:!0,aggregateRating:["AggregateRating"],potentialAction:jl,publisher:Vl},Event:{startDate:!0,endDate:!0,previousStartDate:!0,aggregateRating:["AggregateRating"],offers:["AggregateOffer","Offer"]},ItemList:{itemListElement:["ListItem"]},ListItem:{item:Ul},Offer:{seller:Vl},Organization:{name:!0,legalName:!0,foundingDate:!0,dissolutionDate:!0,aggregateRating:["AggregateRating"],brand:["Brand"]},Place:{aggregateRating:["AggregateRating"]},Product:{name:!0,sku:!0,mpn:!0,gtin:!0,gtin8:!0,gtin12:!0,gtin13:!0,gtin14:!0,productID:!0,productGroupID:!0,asin:!0,model:!0,category:!0,color:!0,material:!0,pattern:!0,size:!0,productionDate:!0,releaseDate:!0,brand:["Brand","Organization"],manufacturer:Vl,offers:["Offer","AggregateOffer"],aggregateRating:["AggregateRating"]},Service:{name:!0,serviceType:!0,category:!0,provider:Vl,areaServed:Gl,offers:["AggregateOffer","Offer"],aggregateRating:["AggregateRating"]},OfferCatalog:{name:!0,itemListElement:Ul}},Kl=[["3DModel AboutPage Answer Article AudioObject Blog BlogPosting Book Clip CollectionPage Comment ContactPage Course CreativeWorkSeason CreativeWorkSeries DataCatalog DataDownload DataFeed Dataset DiscussionForumPosting Episode FAQPage Game HowTo HowToDirection HowToSection HowToStep HowToTip ImageObject LearningResource MediaObject Message MobileApplication Movie MusicPlaylist MusicRecording NewsArticle Photograph PodcastEpisode PodcastSeries ProfilePage QAPage Question Quiz Recipe Review ScholarlyArticle SearchResultsPage SiteNavigationElement SocialMediaPosting SoftwareApplication TVEpisode TVSeries TechArticle VacationRental VideoGame VideoObject WebApplication WebPage WebPageElement WebSite".split(" "),Ql.CreativeWork],["BroadcastEvent BusinessEvent EducationEvent Festival MusicEvent SportsEvent TheaterEvent".split(" "),Ql.Event],[Vl,Ql.Organization],[Gl,Ql.Place],["Car IndividualProduct ProductGroup ProductModel".split(" "),Ql.Product]];function Zl(e,t){return St.call(e,t)?e[t]:void 0}function Jl(e){const t=typeof e;return Rt(e)||"string"===t||"number"===t||"boolean"===t}function Yl(e,t){return t&&function(e){return Tt(e)&&/^(https?:\/\/|\/|\.\.?\/)/i.test(e.trim())}(e)?t(e.trim())||void 0:e}function Xl(e,t){return kt(e)&&e.every(Jl)?e.map(e=>Yl(e,t)).filter(e=>!It(e)):Jl(e)?Yl(e,t):void 0}function ec(e,t){if("string"!=typeof e)return;const i=e.trim(),s=i.indexOf("#"),n=0>s?i:i.slice(s+1);if(!(!n||0>s&&(/^[a-z][a-z\d+.-]*:/i.test(i)||i.includes("/")||i.includes("?"))))try{return t(n)?n:void 0}catch(e){return}}function tc(e){if(St.call(Ql,e))return Ql[e];for(const[t,i]of Kl)if(t.includes(e))return i}function ic(e,t,i){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0})}function sc(e,t,i,s){if(kt(e)){const n=e.map(e=>sc(e,t,i,s)).filter(e=>!It(e));return n.length?n:void 0}return nc(e,t,i,s)||void 0}function nc(e,t,i,s){if(!Et(e)||!function(e){return e.remainingNodes?(e.remainingNodes--,!0):(e.exceeded=!0,!1)}(i))return null;const n=Zl(e,"@type"),r=function(e){const t=new Set,i="string"==typeof e?[e]:kt(e)?e:[],s=[];for(const e of i){if("string"!=typeof e)continue;const i=e.replace(/^https?:\/\/schema\.org\//,"");if(100>=i.length&&Hl.test(i)&&!t.has(i)&&(t.add(i),s.push(i),20===s.length))break}return s}(n),o=r.filter(e=>!!tc(e)&&(!s||!s.length||s.includes(e))),a={};for(const s of zl){const o="@type"===s?r.length?"string"==typeof n?r[0]:r:void 0:"@id"===s?ec(Zl(e,s),t):Xl(Zl(e,s),i.maskUrl);It(o)||ic(a,s,o)}for(const s of o){const n=tc(s);for(const s of Object.keys(n)){const r=Zl(e,s),o=n[s];if(!0===o){const e=Xl(r,i.maskUrl);It(e)||ic(a,s,e)}else{const e=sc(r,t,i,o);It(e)||ic(a,s,e)}}}const l=sc(Zl(e,"@graph"),t,i);return It(l)||ic(a,"@graph",l),Object.keys(a).length?a:null}function rc(e,t,i){if(!Et(e))return null;const s=Zl(e,"@context");if("string"!=typeof s||!/^https?:\/\/schema\.org\/?$/.test(s))return null;const n=nc(e,t,i);return n?ct({"@context":"https://schema.org"},n):null}function oc(e){var t;return"SCRIPT"===e.nodeName&&"application/ld+json"===(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.trim().toLowerCase())}function ac(e,t,i){if("string"==typeof t?e.classList.contains(t):t&&Array.from(e.classList).some(e=>(t.lastIndex=0,t.test(e))))return!0;try{return!!i&&e.matches(i)}catch(e){return!1}}function lc(e,t,i){for(let s=e;s;){if(ac(s,t,i))return!0;const e=s.parentNode;s=s.parentElement||(e&&e.nodeType===e.DOCUMENT_FRAGMENT_NODE?e.host:null)}return!1}function cc(e){return oc(e)?[e]:e.nodeType!==e.ELEMENT_NODE?[]:Array.from(e.querySelectorAll("script")).filter(oc)}function uc(e){return It(e)?void 0:Math.round(e)}function dc(e){return Et(e)?e.network_timing:e}const hc=Gn("[SessionRecording]"),pc=[1,2,3,4,5,6,7,12],_c=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function gc(){var e;return null==h||null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.rrweb}function fc(){var e;return null===(e=gc())||void 0===e?void 0:e.record}function vc(e){try{return JSON.stringify(e)}catch(t){return JSON.stringify(e,No())}}function mc(e){return wa(ba(Sa(vc(e))),!0)}function yc(e){return bc.apply(this,arguments)}function bc(){return(bc=rt(function*(e){const t=yield fn(vc(e),Ya.DEBUG,{rethrow:!0});return wa(new Uint8Array(yield t.arrayBuffer()),!0)})).apply(this,arguments)}let Sc,wc;const kc="undefined"!=typeof globalThis&&"CompressionStream"in globalThis&&"TextEncoder"in globalThis&&"Response"in globalThis&&"function"==typeof Response.prototype.blob;let Cc=!1;function Ec(e){var t;return kt(e)&&0===e.length?(Sc=null!==(t=Sc)&&void 0!==t?t:mc([]),Sc):mc(e)}function xc(e){return Ic.apply(this,arguments)}function Ic(){return(Ic=rt(function*(e){var t;return kt(e)&&0===e.length?Sc||(wc=null!==(t=wc)&&void 0!==t?t:yc([]).then(e=>(Sc=e,e)).catch(e=>{throw Sc=void 0,wc=void 0,e}),wc):yc(e)})).apply(this,arguments)}function Tc(e){return kc&&!Cc&&function(e){return 2===e.type||3===e.type&&(0===e.data.source||8===e.data.source)}(e)}function Mc(e){return{event:e,size:qo(e)}}function Rc(e,t){return ct(ct({},e),{},{data:t,cv:"2024-10"})}function Pc(e,t){return ct(ct({},e),{},{cv:"2024-10",data:ct(ct({},e.data),t)})}function Fc(e){try{if(2===e.type)return Mc(Rc(e,mc(e.data)));if(3===e.type&&0===e.data.source)return Mc(Pc(e,{texts:Ec(e.data.texts),attributes:Ec(e.data.attributes),removes:Ec(e.data.removes),adds:Ec(e.data.adds)}));if(3===e.type&&8===e.data.source)return Mc(Pc(e,{adds:e.data.adds?mc(e.data.adds):void 0,removes:e.data.removes?mc(e.data.removes):void 0}))}catch(e){hc.error("could not compress event - will use uncompressed event",e)}return{event:e,size:Bo(e)}}function Lc(){return Lc=rt(function*(e){try{if(2===e.type)return Mc(Rc(e,yield yc(e.data)));if(3===e.type&&0===e.data.source){const[t,i,s,n]=yield Promise.all([xc(e.data.texts),xc(e.data.attributes),xc(e.data.removes),xc(e.data.adds)]);return Mc(Pc(e,{texts:t,attributes:i,removes:s,adds:n}))}if(3===e.type&&8===e.data.source){const[t,i]=yield Promise.all([e.data.adds?yc(e.data.adds):void 0,e.data.removes?yc(e.data.removes):void 0]);return Mc(Pc(e,{adds:t,removes:i}))}}catch(t){return dn(t)&&(Cc=!0),hc.error("could not compress event asynchronously - trying synchronous compression",t),Fc(e)}return{event:e,size:Bo(e)}}),Lc.apply(this,arguments)}function Ac(e,t){return 5===e.type&&e.data.tag===t}function Oc(e){return Ac(e,"sessionIdle")}function Dc(e){return Ac(e,"$session_ending")}function $c(e){return Ac(e,"$session_starting")}var Nc=class{get sessionId(){return this._sessionId}get _sessionManager(){if(!this._instance.sessionManager)throw new Error("[SessionRecording] must be started with a valid sessionManager.");return this._instance.sessionManager}get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get _isSampled(){return wl(this._instance.get_property(W),this.sessionId)}get _sampleRate(){var e;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.sampleRate;return Ft(t)?t:null}get _minimumDuration(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getMinimumDuration(this.sessionId))&&void 0!==e?e:null}constructor(e,t){this._instance=e,this._endpoint="/s/",this._forceAllowLocalhostNetworkCapture=!1,this._stopRrweb=void 0,this._jsonLdCaptureReady=!1,this._lastActivityTimestamp=Date.now(),this._isActivatingTrigger=!1,this._queuedRRWebEvents=[],this._isIdle="unknown",this._eventsDroppedWhileIdle=0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,this._holdFlushUntilInteraction=!1,this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed=!1,this._suppressNextFreshStartHold=!1,this._rrwebError=!1,this._rrwebStartAttempted=!1,this._maxDepthExceeded=!1,this._snapshotCostErrorLogged=!1,this._hasWarnedClientMaskingOverride=!1,this._hasWarnedExclusiveAttributeMasking=!1,this._maskRegionsFnFailed=!1,this._hasLoggedRecorderCallbackError=!1,this._fullSnapshotTimestamps=[],this._lastFullSnapshotSessionId=void 0,this._fullSnapshotHealAttemptedFor=void 0,this._pendingBufferRestored=!1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueueGeneration=0,this._isStoppingAfterCompression=!1,this._removePageViewCaptureHook=void 0,this._removeEventTriggerCaptureHook=void 0,this._onSessionIdListener=void 0,this._onSessionIdleResetForcedListener=void 0,this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback=(e,t,i)=>{var s,n,r,o;if(!i)return;if(e===this._sessionId&&t===this._windowId)return;const a=!i.noSessionId&&(i.activityTimeout||i.sessionPastMaximumLength),l=this._sessionId,c=this._windowId;var u;if(a&&this._tryAddCustomEvent("$session_ending",{currentSessionId:l,currentWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp,flushed_size:null===(u=this._flushedSizeTracker)||void 0===u?void 0:u.currentTrackedSize(l)}),null===(s=this._instance.persistence)||void 0===s||s.unregister("$debug_first_full_snapshot_timestamp"),this._maxDepthExceeded=!1,null===(n=gc())||void 0===n||null===(r=n.resetMaxDepthState)||void 0===r||r.call(n),this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),this._clearConditionalRecordingPersistence(),!(!1===this._isIdle&&this.isStarted||this._sessionId===e&&this._windowId===t)){const t=this._sessionId!==e&&!1!==this._isIdle;this._isIdle="unknown",this._restartForSessionIdChange(t)}a&&this._tryAddCustomEvent("$session_starting",{previousSessionId:l,previousWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp}),null===(o=this._strategy)||void 0===o||o.makeSamplingDecisions(e)},this._isRestartingForSessionIdChange=!1,this._hasPassedMinimumDuration=()=>{var e;return(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[z])===this._sessionId},this._getBufferDuration=()=>{var e,t;if(0===this._buffer.data.length)return null;const i=null===(e=this._buffer.data[0])||void 0===e?void 0:e.timestamp,s=null===(t=this._buffer.data[this._buffer.data.length-1])||void 0===t?void 0:t.timestamp;return Ft(i)&&Ft(s)?s-i:null},this._isBelowMinimumDuration=()=>{var e,t;const i=this._minimumDuration;if(!Ft(i))return!1;if(null===(e=null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.strictMinimumDuration)||void 0===e||!e){const e=this._sessionDuration;return Ft(e)&&e>=0&&i>e}if(this._hasPassedMinimumDuration())return!1;const s=this._getBufferDuration();return!!Rt(s)||i>s||(null===(n=this._instance.persistence)||void 0===n||n.register({$session_past_minimum_duration:this._sessionId}),!1);var n},this._onBeforeUnload=()=>{"buffering"!==this.status?(this._holdFlushUntilInteraction&&this._heldEpochShipsOnUnload&&this._documentWasEverVisible&&!this._heldBufferOverflowed&&this._setFlushHold(void 0),this._drainCompressionQueueSync(),this._flushBuffer(!0)):this._clearBuffer()},this._onPageHide=()=>{this._onBeforeUnload()},this._onOffline=()=>{this._tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this._tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{(null==s?void 0:s.visibilityState)&&("visible"===s.visibilityState&&(this._documentWasEverVisible=!0),this._tryAddCustomEvent("window "+s.visibilityState,{}))},this._documentWasEverVisible=null==t||t;const{sessionId:i,windowId:n,sessionStartTimestamp:r}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=i,this._windowId=n,this._sessionStartTimestamp=r,this._linkedFlagMatching=new Lo(this._instance),this._urlTriggerMatching=new Fo(this._instance),this._eventTriggerMatching=new Ao(this._instance),this._buffer=this._clearBuffer(),this._pendingBufferStorageKey="ph_replay_pending_buffer_"+JSON.stringify([this._instance.config.persistence_name||this._instance.config.token,this._instance.config.token]),this._sessionManager.sessionTimeoutMs>this._sessionIdleThresholdMilliseconds||hc.warn(`session_idle_threshold_ms (${this._sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this._sessionManager.sessionTimeoutMs}). Session will never be detected as idle`),this._flushedSizeTracker=new Xa(this._instance)}setDocumentWasEverVisible(e){e&&(this._documentWasEverVisible=!0)}get _masking(){var e,t,i,s,n,r,o,a,l;const c=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking,u={maskAllInputs:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.maskAllInputs,maskTextSelector:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.maskTextSelector,blockSelector:null===(s=this._instance.config.session_recording)||void 0===s?void 0:s.blockSelector,maskAllElementAttributes:null===(n=this._instance.config.session_recording)||void 0===n?void 0:n.maskAllElementAttributes},d=null!==(r=null==u?void 0:u.maskAllInputs)&&void 0!==r?r:null==c?void 0:c.maskAllInputs,h=null!==(o=null==u?void 0:u.maskTextSelector)&&void 0!==o?o:null==c?void 0:c.maskTextSelector,p=null!==(a=null==u?void 0:u.blockSelector)&&void 0!==a?a:null==c?void 0:c.blockSelector,_=null!==(l=null==u?void 0:u.maskAllElementAttributes)&&void 0!==l?l:null==c?void 0:c.maskAllElementAttributes;return It(d)&&It(h)&&It(p)&&It(_)?void 0:{maskAllInputs:null==d||d,maskTextSelector:h,blockSelector:p,maskAllElementAttributes:_}}_warnIfClientMaskingShadowsServer(){var e;if(this._hasWarnedClientMaskingOverride)return;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking;if(Pt(t))return;const i=this._instance.config.session_recording,s=["maskAllInputs","maskTextSelector","blockSelector","maskAllElementAttributes"].filter(e=>{const s=null==i?void 0:i[e],n=t[e];return!It(s)&&s!==n});0!==s.length&&(this._hasWarnedClientMaskingOverride=!0,hc.warn('Session recording masking is configured both in `posthog.init` and in your project settings, and they differ. The `session_recording` options in `posthog.init` take precedence, so the project ("Privacy and masking") setting is ignored for: '+s.join(", ")+". Remove these masking options from `posthog.init` to use the project setting instead. See https://posthog.com/docs/session-replay/privacy",{client:{maskAllInputs:null==i?void 0:i.maskAllInputs,maskTextSelector:null==i?void 0:i.maskTextSelector,blockSelector:null==i?void 0:i.blockSelector,maskAllElementAttributes:null==i?void 0:i.maskAllElementAttributes},project:t}))}get _canvasResolutionScale(){var e;return Qt(null===(e=this._instance.config.session_recording.canvasCapture)||void 0===e?void 0:e.resolutionScale,.1,1,Gn("canvas recording resolution scale"),1)}get _canvasRecording(){var e,t,i,s,n,r,o;const a=this._instance.config.session_recording.captureCanvas,l=null===(e=this._remoteConfig)||void 0===e?void 0:e.canvasRecording,c=null!==(t=null!==(i=null==a?void 0:a.recordCanvas)&&void 0!==i?i:null==l?void 0:l.enabled)&&void 0!==t&&t,u=null!==(s=null!==(n=null==a?void 0:a.canvasFps)&&void 0!==n?n:null==l?void 0:l.fps)&&void 0!==s?s:4;let d=null!==(r=null!==(o=null==a?void 0:a.canvasQuality)&&void 0!==o?o:null==l?void 0:l.quality)&&void 0!==r?r:.4;if("string"==typeof d){const e=parseFloat(d);d=isNaN(e)?.4:e}return{enabled:c,fps:Qt(u,0,12,Gn("canvas recording fps"),4),quality:Qt(d,0,1,Gn("canvas recording quality"),.4)}}get _isConsoleLogCaptureEnabled(){var e;const t=!!(null===(e=this._remoteConfig)||void 0===e?void 0:e.consoleLogRecordingEnabled),i=this._instance.config.enable_recording_console_log;return null!=i?i:t}get _networkPayloadCapture(){var e,t,i;const s=null===(e=this._remoteConfig)||void 0===e?void 0:e.networkPayloadCapture,n={recordHeaders:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.recordHeaders,recordBody:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.recordBody},r=(null==n?void 0:n.recordHeaders)||(null==s?void 0:s.recordHeaders),o=(null==n?void 0:n.recordBody)||(null==s?void 0:s.recordBody),a=dc(this._instance.config.capture_performance),l=dc(null==s?void 0:s.capturePerformance),c=!!(At(a)?a:l);return r||o||c?{recordHeaders:r,recordBody:o,recordPerformance:c}:void 0}_gatherRRWebPlugins(){var e,t;const i=[],s=null===(e=h.__PosthogExtensions__)||void 0===e||null===(e=e.rrwebPlugins)||void 0===e?void 0:e.getRecordConsolePlugin;s&&this._isConsoleLogCaptureEnabled&&i.push(s());const r=null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.rrwebPlugins)||void 0===t?void 0:t.getRecordNetworkPlugin;if(this._networkPayloadCapture&&Ct(r))if(!rr.includes(n.hostname)||this._forceAllowLocalhostNetworkCapture){const e=Ct(this._instance.requestRouter.isIngestionEndpoint)?this._instance.requestRouter.isIngestionEndpoint.bind(this._instance.requestRouter):void 0;i.push(r(((e,t,i)=>{const s={payloadSizeLimitBytes:no.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...no.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...no.payloadHostDenyList]},n=!1!==e.session_recording.recordHeaders&&t.recordHeaders,r=!1!==e.session_recording.recordBody&&t.recordBody,o=!1!==e.capture_performance&&t.recordPerformance,a=(e=>{const t=so(e);return e=>((null==e?void 0:e.requestBody)&&(e.requestBody=uo(e.requestBody,e.requestHeaders,t,"Request")),(null==e?void 0:e.responseBody)&&(e.responseBody=uo(e.responseBody,e.responseHeaders,t,"Response")),e)})(s),l=t=>{return a(((e,t,i)=>{var s;if(null==i?void 0:i(e.name))return;const n=ar(e.name);let r=0===t.indexOf("http")?null===(s=ar(t))||void 0===s?void 0:s.pathname:t;"/"===r&&(r="");const o=null==n?void 0:n.pathname.replace(r||"","");return n&&o&&co.some(e=>0===o.indexOf(e))?void 0:e})((lo((s=t).requestHeaders),lo(s.responseHeaders),s),e.api_host,i));var s},c=Ct(e.session_recording.maskNetworkRequestFn);return c&&Ct(e.session_recording.maskCapturedNetworkRequestFn)&&Vn.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),c&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{const i=e.session_recording.maskNetworkRequestFn({url:t.name});return!i&&t.isInitial?i:ct(ct({},t),{},{name:null==i?void 0:i.url})}),s.maskRequestFn=Ct(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s;const n=l(t);if(!n)return;const r=n.isInitial?{name:"",entryType:n.entryType,startTime:n.startTime,duration:n.duration,endTime:n.endTime,timeOrigin:n.timeOrigin,timestamp:n.timestamp,isInitial:!0}:void 0,o=null===(i=(s=e.session_recording).maskCapturedNetworkRequestFn)||void 0===i?void 0:i.call(s,n);return Pt(o)&&r?(po.add(r),r):null!=o?o:void 0}:e=>function(e){if(!It(e))return e.requestBody=ho(e.requestBody,"Request"),e.responseBody=ho(e.responseBody,"Response"),e}(l(e)),ct(ct(ct({},no),s),{},{recordHeaders:n,recordBody:r,recordPerformance:o,recordInitialRequests:o,streamNetworkBody:!0===e.session_recording.streamNetworkBody})})(this._instance.config,this._networkPayloadCapture,e)))}else hc.info("NetworkCapture not started because we are on localhost.");return i}_stripUrlHash(e){return this._instance.config.disable_capture_url_hashes?ls(e):e}_maskReplayUrl(e,t=!1){const i=t?ls(e):this._stripUrlHash(e),s=this._instance.config.mask_personal_data_properties?[...El,...this._instance.config.custom_personal_data_properties||[]]:[];return this._maskUrl(ur(i,s,Il))}_maskUrl(e){const t=this._instance.config.session_recording;if(t.maskCapturedNetworkRequestFn){var i;const s=t.maskCapturedNetworkRequestFn({name:e});return null!==(i=null==s?void 0:s.name)&&void 0!==i?i:null==s?void 0:s.url}if(t.maskNetworkRequestFn){const i=t.maskNetworkRequestFn({url:e});return null==i?void 0:i.url}return e}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return 10>this._queuedRRWebEvents.length?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt+1,rrwebMethod:e.rrwebMethod}):hc.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(_c(()=>fc().addCustomEvent(e,t)))}_canCaptureJsonLd(){var e;return this._jsonLdCaptureReady&&!0===(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)&&!this._urlTriggerMatching.urlBlocked&&!0!==this._isIdle}_tryAddJsonLdEvent(e){if(!this._canCaptureJsonLd())return!1;try{const t=fc();return!!t&&(t.addCustomEvent("$json_ld",e),this._canCaptureJsonLd())}catch(e){return!1}}_scheduleJsonLdScan(e=!1){Promise.resolve().then(()=>{var t;return null===(t=this._jsonLdCapture)||void 0===t?void 0:t.scan(e)})}_pageViewFallBack(){try{if(this._instance.config.capture_pageview||!e)return;const t=new URL(e.location.href),i=this._maskReplayUrl(t.origin+t.pathname+t.search);this._lastHref!==i&&(this._lastHref=i,this._tryAddCustomEvent("$url_changed",{href:i}))}catch(e){}}_processQueuedEvents(){if(this._queuedRRWebEvents.length){const e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach(e=>{Date.now()-e.enqueuedAt>2e3||this._tryRRWebMethod(e)})}}_tryTakeFullSnapshot(){return this._tryRRWebMethod(_c(()=>fc().takeFullSnapshot()))}get _fullSnapshotIntervalMillis(){var e,t,i;if((null===(e=this._strategy)||void 0===e?void 0:e.hasPendingTriggers(this.sessionId))&&!["sampled","active"].includes(this.status)){var s;const e=null===(s=this._instance.config.session_recording)||void 0===s?void 0:s.trigger_pending_buffer_interval_millis;return Ft(e)&&Number.isFinite(e)&&e>=1e3&&36e5>=e?e:6e4}return null!==(t=null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.full_snapshot_interval_millis)&&void 0!==t?t:3e5}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0===this._isIdle)return;const e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},e))}_onTriggerActivated(e){"event"===e&&this._releaseHoldAndFlush(),!this._urlTriggerMatching.urlBlocked&&["sampled","active"].includes(this.status)&&this._scheduleFullSnapshot()}_pauseRecording(){var e;this._urlTriggerMatching.urlBlocked||(this._urlTriggerMatching.urlBlocked=!0,null===(e=this._jsonLdCapture)||void 0===e||e.scan(),clearInterval(this._fullSnapshotTimer),hc.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){var e;this._urlTriggerMatching.urlBlocked&&(null===(e=this._jsonLdCapture)||void 0===e||e.scan(),this._urlTriggerMatching.urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),hc.info("recording resumed"))}_activateTrigger(e,t){var i;if("event"===e&&this._releaseHoldAndFlush(),!this._isActivatingTrigger&&(null===(i=this._strategy)||void 0===i?void 0:i.hasPendingTriggers(this.sessionId))){this._isActivatingTrigger=!0;try{var s,n;const i="url"===e?j:V;null===(s=this._instance.persistence)||void 0===s||s.register({[i]:this.sessionId}),null===(n=this._strategy)||void 0===n||n.updateActiveTriggers(this.sessionId),this._onTriggerActivated(),this._flushBuffer(),this._reportStarted(e+"_trigger_matched",{["url"===e?"matchedUrl":"matchedEvent"]:t})}finally{this._isActivatingTrigger=!1}}}get isStarted(){return!!this._stopRrweb}get _remoteConfig(){const e=this._instance.get_property(A);if(!e)return;let t;try{t=Et(e)?e:JSON.parse(e)}catch(e){return void hc.warn("persisted remote config for session recording is invalid and will be ignored",e)}if(!this.isStarted&&!this._isRestartingForSessionIdChange){var i;const s=null!==(i=t.cache_timestamp)&&void 0!==i?i:Date.now();if(Date.now()-s>36e5)return void hc.info("persisted remote config for session recording is stale and will be ignored",{cacheTimestamp:s,persistedConfig:e})}return t}_checkOverride(e,t,i){this._instance.get_property(e)&&(t(),i())}start(t){var i,n;const r=this._remoteConfig;if(!r)return void hc.info("remote config must be stored in persistence before recording can start");if(!this.isStarted){const e=!1!==this._isIdle&&!this._suppressNextFreshStartHold;this._setFlushHold(e?"no_interaction_since_recording_started":void 0),this._suppressNextFreshStartHold=!1,this._heldEpochShipsOnUnload=e,this._heldBufferOverflowed=!1}this._isStoppingAfterCompression&&(this._invalidateCompressionQueue(),this._clearBuffer());const{sessionId:o,windowId:a,sessionStartTimestamp:l}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=o,this._windowId=a,this._sessionStartTimestamp=l,this._restorePendingBuffer(),null===(i=this._instance.persistence)||void 0===i||i.unregister("$debug_first_full_snapshot_timestamp"),(null==r?void 0:r.endpoint)&&(this._endpoint=null==r?void 0:r.endpoint),this._strategy=2===(null==r?void 0:r.version)&&(null==r?void 0:r.triggerGroups)&&r.triggerGroups.length>0?new Cl(this._instance,this._urlTriggerMatching,this._reportStarted.bind(this),this._tryAddCustomEvent.bind(this),this._onTriggerActivated.bind(this)):new kl(this._instance,this._urlTriggerMatching,this._eventTriggerMatching,this._linkedFlagMatching,this._reportStarted.bind(this),this._tryTakeFullSnapshot.bind(this),this._onTriggerActivated.bind(this)),this._strategy.onRemoteConfig(r),null===(n=this._removeEventTriggerCaptureHook)||void 0===n||n.call(this),this._removeEventTriggerCaptureHook=this._strategy.setupEventTriggerListeners(this._instance.on.bind(this._instance,"eventCaptured"),this.sessionId,(e,t)=>this._activateTrigger(e,t)),this._checkOverride(N,()=>{this.overrideSampling()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(N)}),this._checkOverride(B,()=>{this.overrideLinkedFlag()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(B)}),this._checkOverride(H,()=>{this.overrideTrigger("event")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(H)}),this._checkOverride(q,()=>{this.overrideTrigger("url")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(q)}),this._strategy.makeSamplingDecisions(this.sessionId),this._startRecorder(),this._rrwebError||(sr(e,"beforeunload",this._onBeforeUnload),sr(e,"pagehide",this._onPageHide),sr(e,"offline",this._onOffline),sr(e,"online",this._onOnline),sr(s,"visibilitychange",this._onVisibilityChange),!this._onSessionIdListener&&Ct(this._sessionManager.onSessionId)&&(this._onSessionIdListener=this._sessionManager.onSessionId(this._onSessionIdCallback)),!this._onSessionIdleResetForcedListener&&Ct(this._sessionManager.on)?this._onSessionIdleResetForcedListener=this._sessionManager.on("forcedIdleReset",()=>{this._clearConditionalRecordingPersistence(),this._isIdle="unknown",this.stop(),this._forceIdleSessionIdListener=this._sessionManager.onSessionId((e,t,i)=>{var s;null===(s=this._forceIdleSessionIdListener)||void 0===s||s.call(this),this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback(e,t,i)})}):Ct(this._sessionManager.on)||hc.warn("bundled core has no SessionIdManager.on (requires posthog-js >= 1.268.6); recording will start but skip forced-idle-reset handling"),Pt(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this._instance.on("eventCaptured",e=>{try{if("$pageview"===e.event){const t=(null==e?void 0:e.properties.$current_url)?this._maskReplayUrl(e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){hc.error("Could not add $pageview to rrweb session",e)}})),"active"===this.status&&this._reportStarted(t||"recording_initialized"))}_teardown(){var t,i,n,r,o,a;null==e||e.removeEventListener("beforeunload",this._onBeforeUnload),null==e||e.removeEventListener("pagehide",this._onPageHide),null==e||e.removeEventListener("offline",this._onOffline),null==e||e.removeEventListener("online",this._onOnline),null==s||s.removeEventListener("visibilitychange",this._onVisibilityChange),clearInterval(this._fullSnapshotTimer),this._clearFlushBufferTimer(),null===(t=this._removePageViewCaptureHook)||void 0===t||t.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(n=this._onSessionIdListener)||void 0===n||n.call(this),this._onSessionIdListener=void 0,null===(r=this._onSessionIdleResetForcedListener)||void 0===r||r.call(this),this._onSessionIdleResetForcedListener=void 0,null===(o=this._forceIdleSessionIdListener)||void 0===o||o.call(this),this._forceIdleSessionIdListener=void 0,null===(a=this._strategy)||void 0===a||a.stop(),this._stopRecordingProducers(),this._invalidateCompressionQueue()}_invalidateCompressionQueue(){this._compressionQueueGeneration+=1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueue=void 0,this._isStoppingAfterCompression=!1}_stopRecordingProducers(){var e,t;null===(e=this._mutationThrottler)||void 0===e||e.stop(),this._queuedRRWebEvents=[],null===(t=this._jsonLdCapture)||void 0===t||t.stop(),this._jsonLdCapture=void 0,this._jsonLdCaptureReady=!1;try{var i;null===(i=this._stopRrweb)||void 0===i||i.call(this)}catch(e){hc.warn("could not stop rrweb",e)}this._stopRrweb=void 0}_stopAfterCompressionQueueDrains(){if(!this._compressionQueue||0===this._queuedCompressionEvents)return!1;if(this._isStoppingAfterCompression)return!0;this._isStoppingAfterCompression=!0,this._flushHoldReason=void 0;const e=this._compressionQueueGeneration;return this._clearFlushBufferTimer(),this._stopRecordingProducers(),this._compressionQueue.catch(()=>{}).then(()=>{e===this._compressionQueueGeneration&&(this._isStoppingAfterCompression=!1,this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),hc.info("stopped"))}).catch(()=>{this._isStoppingAfterCompression=!1,this._releaseHoldAfterStop(),this._teardown(),hc.info("stopped")}),!0}stop(){if(this._stopRecordingProducers(),this._isRestartingForSessionIdChange)this._drainCompressionQueueSync();else if(this._stopAfterCompressionQueueDrains())return;this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),hc.info("stopped")}_releaseHoldAfterStop(){this._setFlushHold(void 0,{preserveLogDedup:this._isRestartingForSessionIdChange}),this._heldEpochShipsOnUnload=!1}flushBeforeIdentityReset(){(this.isStarted||this._isStoppingAfterCompression)&&(this._drainCompressionQueueSync(),this._flushBuffer())}_restartForSessionIdChange(e){this._isRestartingForSessionIdChange=!0,this._lastActivityTimestamp=Date.now();try{var t,i;this.stop(),this._slowestFullSnapshot=void 0,this._lastSeenSnapshotCost=void 0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,null===(t=gc())||void 0===t||null===(i=t.resetSnapshotCostState)||void 0===i||i.call(t),this.start("session_id_changed")}finally{this._isRestartingForSessionIdChange=!1}this._setFlushHold(e?"no_interaction_since_session_rotated":void 0),this._heldEpochShipsOnUnload=!1}_setFlushHold(e,{preserveLogDedup:t=!1}={}){if(this._holdFlushUntilInteraction=!It(e),this._flushHoldReason=e,It(e))return void(t||(this._lastLoggedFlushHold=void 0));if(this._isRestartingForSessionIdChange)return;const i=`${this.sessionId}:${e}`;i!==this._lastLoggedFlushHold&&(this._lastLoggedFlushHold=i,hc.info(`holding buffer: ${e}. nothing is uploaded until the user interacts with the page`))}_releaseHoldAndFlush(){this.isStarted||(this._suppressNextFreshStartHold=!0),this._holdFlushUntilInteraction&&(this._setFlushHold(void 0),this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed&&(this._heldBufferOverflowed=!1,this._tryTakeFullSnapshot()),this._scheduleFlushBuffer())}discard({discardProducerEvents:e=!1}={}){this._holdFlushUntilInteraction=!0,e&&(this._clearBuffer(),this._stopRecordingProducers()),this._clearBuffer(),this._teardown(),this._clearBuffer(),this._releaseHoldAfterStop(),hc.info("discarded")}_captureProcessedEvent(e,t,i,s,n){const r={$snapshot_bytes:i,$snapshot_data:t,$session_id:s,$window_id:n};"disabled"!==this.status?(this._ensureFullSnapshotForSession(e,s),this._captureSnapshotBuffered(r)):this._clearBuffer()}_safeTrackFullSnapshotCost(){try{this._trackFullSnapshotCost()}catch(e){this._snapshotCostErrorLogged||(this._snapshotCostErrorLogged=!0,hc.error("could not track full snapshot cost",e))}}_trackFullSnapshotCost(){var e,t;const i=null===(e=gc())||void 0===e||null===(t=e.getLastSnapshotCost)||void 0===t?void 0:t.call(e);i&&i!==this._lastSeenSnapshotCost&&(this._lastSeenSnapshotCost=i,this._slowestFullSnapshot&&this._slowestFullSnapshot.durationMs>=i.durationMs||(this._slowestFullSnapshot=i),500>i.durationMs||hc.warn("full snapshot was slow, the page may have been unresponsive while it ran",{durationMs:Math.round(i.durationMs),stylesheetMs:Math.round(i.stylesheetMs),nodeCount:i.nodeCount,cssRuleCount:i.cssRuleCount,nonDeferrableCssRuleCount:i.nonDeferrableCssRuleCount,deferredStylesheetCount:i.deferredStylesheetCount}))}_ensureFullSnapshotForSession(e,t){2!==e.type?3===e.type&&(It(this._lastFullSnapshotSessionId)||this._lastFullSnapshotSessionId===t||this._fullSnapshotHealAttemptedFor===t||(this._fullSnapshotHealAttemptedFor=t,hc.info("incremental snapshot for a session with no full snapshot - requesting one",{sessionId:t}),this._tryTakeFullSnapshot())):this._lastFullSnapshotSessionId=t}_finishQueuedCompressionEvent(e){e.counted&&e.generation===this._compressionQueueGeneration&&(this._queuedCompressionEvents=Math.max(0,this._queuedCompressionEvents-1)),e.counted=!1,this._pendingCompressionEvents=this._pendingCompressionEvents.filter(t=>t!==e)}_captureQueuedCompressionEvent(e,t,i){e.processed||e.generation!==this._compressionQueueGeneration||(e.processed=!0,this._captureProcessedEvent(e.event,t,i,e.targetSessionId,e.targetWindowId))}_processQueuedCompressionEventSync(e){try{let t=e.event,i=Bo(e.event);if(e.compressionEnabled)try{({event:t,size:i}=Fc(e.event))}catch(e){hc.error("could not process queued compression event - will use uncompressed event",e)}try{this._captureQueuedCompressionEvent(e,t,i)}catch(e){hc.error("could not capture queued compression event",e)}}finally{this._finishQueuedCompressionEvent(e)}}_drainCompressionQueueSync(){[...this._pendingCompressionEvents].forEach(e=>{this._processQueuedCompressionEventSync(e)})}_enqueueCompression(e,t,i,s){var n=this;const r={event:e,compressionEnabled:t,targetSessionId:i,targetWindowId:s,generation:this._compressionQueueGeneration,processed:!1,counted:!0};this._pendingCompressionEvents.push(r),this._queuedCompressionEvents+=1;const o=(a=rt(function*(){try{if(r.processed)return;let i,s;try{const n=t?Tc(e)?yield function(e){return Lc.apply(this,arguments)}(e):Fc(e):{event:e,size:Bo(e)};i=n.event,s=n.size}catch(t){hc.error("could not process queued compression event - will use uncompressed event",t),i=e,s=Bo(e)}n._captureQueuedCompressionEvent(r,i,s)}finally{n._finishQueuedCompressionEvent(r)}}),function(){return a.apply(this,arguments)});var a;this._compressionQueue=this._compressionQueue?this._compressionQueue.catch(()=>{}).then(o):o()}onRRwebEmit(t){var i,s,n,r,o,a,l,c,u,d,h,p,_;if(!this._instance.sessionManager)return;if(this._processQueuedEvents(),!t||!Et(t))return;if(4===t.type){const e=this._maskReplayUrl(t.data.href);if(this._lastHref=e,!e)return;t.data.href=e}else this._pageViewFallBack();if(null===(i=this._strategy)||void 0===i||i.checkUrlTriggers(this.sessionId,()=>this._pauseRecording(),()=>this._resumeRecording(),(e,t)=>this._activateTrigger(e,t)),this._urlTriggerMatching.urlBlocked&&!function(e){return 5===e.type&&"recording paused"===e.data.tag}(t))return;2===t.type&&((null===(d=gc())||void 0===d||null===(h=d.wasMaxDepthReached)||void 0===h?void 0:h.call(d))&&(this._maxDepthExceeded=!0),this._safeTrackFullSnapshotCost(),Promise.resolve().then(()=>this._safeTrackFullSnapshotCost()),this._scheduleFullSnapshot(),null===(p=this._mutationThrottler)||void 0===p||p.reset(),null===(_=this._instance.persistence)||void 0===_||_.register_once({$debug_first_full_snapshot_timestamp:t.timestamp},void 0));const g=2===t.type&&(null===(s=this._strategy)||void 0===s?void 0:s.hasPendingTriggers(this.sessionId));g&&this._clearBufferBeforeMostRecentMeta();const f=this._mutationThrottler?this._mutationThrottler.throttleMutations(t):t;if(!f)return void(!0===this._isIdle&&this._eventsDroppedWhileIdle++);const v=function(e){const t=e;if(t&&Et(t)&&6===t.type&&Et(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));const i=[];for(let e=0;t.data.payload.payload.length>e;e++)i.push(t.data.payload.payload[e]&&t.data.payload.payload[e].length>2e3?t.data.payload.payload[e].slice(0,2e3)+"...[truncated]":t.data.payload.payload[e]);return t.data.payload.payload=i,e}return e}(f),m=function(e){return Dc(e)?e.data.payload:null}(v),y=function(e){return $c(e)?e.data.payload:null}(v),b=function(e){return Oc(e)?e.data.payload:null}(v);m||y?(null==m?void 0:m.lastActivityTimestamp)&&(v.timestamp=m.lastActivityTimestamp):(null==b?void 0:b.sessionId)||this._updateWindowAndSessionIds(v),2===t.type&&(this._fullSnapshotTimestamps.push([this._sessionId,t.timestamp]),this._fullSnapshotTimestamps.length>6&&(this._fullSnapshotTimestamps=this._fullSnapshotTimestamps.slice(-6)));const S=null!==(n=null!==(r=null!==(o=null==m?void 0:m.currentSessionId)&&void 0!==o?o:null==y?void 0:y.nextSessionId)&&void 0!==r?r:null==b?void 0:b.sessionId)&&void 0!==n?n:this._sessionId,w=null!==(a=null!==(l=null!==(c=null==m?void 0:m.currentWindowId)&&void 0!==c?c:null==y?void 0:y.nextWindowId)&&void 0!==l?l:null==b?void 0:b.windowId)&&void 0!==a?a:this._windowId;if(!0===this._isIdle&&!function(e){return Oc(e)||Dc(e)||$c(e)}(v))return void(function(e){return 2===e.type||4===e.type||3===e.type&&9!==e.data.source}(v)&&this._eventsDroppedWhileIdle++);2===v.type&&(this._eventsDroppedWhileIdle=0),b&&(v.timestamp=b.lastActivityTimestamp+b.threshold);const k=this._jsonLdCaptureReady;this._jsonLdCaptureReady=!0,g?this._scheduleJsonLdScan(!0):k||this._scheduleJsonLdScan();const C=null===(u=this._instance.config.session_recording.compress_events)||void 0===u||u;if(5===v.type&&"$json_ld"===v.data.tag){let t;try{t=e?this._maskReplayUrl(e.location.href):void 0}catch(e){}v.data.href=t}if(this._queuedCompressionEvents>0||C&&Tc(v))return void this._enqueueCompression(v,C,S,w);const{event:E,size:x}=C?Fc(v):{event:v,size:Bo(v)};this._captureProcessedEvent(v,E,x,S,w)}get status(){return this._strategy?this._strategy.getStatus({instance:this._instance,sessionId:this.sessionId,isSampled:this._isSampled,rrwebError:this._rrwebError,urlTriggerMatching:this._urlTriggerMatching,eventTriggerMatching:this._eventTriggerMatching,linkedFlagMatching:this._linkedFlagMatching,remoteConfig:this._remoteConfig}):_o}log(e,t="log"){var i;null===(i=this._instance.sessionRecording)||void 0===i||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}overrideLinkedFlag(){this._linkedFlagMatching.linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this._instance.persistence)||void 0===e||e.register({$session_is_sampled:this.sessionId,$replay_sample_rate:null}),this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e),this._releaseHoldAndFlush()}_currentMaskedHostname(){try{var t;const i=null==e||null===(t=e.location)||void 0===t?void 0:t.href;if(!i)return;const s=this._maskReplayUrl(i);if(!s)return;return new URL(s).hostname||void 0}catch(e){return}}_clearFlushBufferTimer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0)}_scheduleFlushBuffer(){this._flushBufferTimer||(this._flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_wouldOpenRecordingWithMarkersOnly(){return this._lastFullSnapshotSessionId!==this._buffer.sessionId&&0!==this._buffer.data.length&&this._buffer.data.every(e=>5===(null==e?void 0:e.type)&&!Dc(e)&&!$c(e))}_describePendingTriggerConditions(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getPendingTriggerConditions(this.sessionId))&&void 0!==e?e:[]}_maybeLogBufferingReason(e){if("buffering"!==e)return It(this._lastLoggedBufferingReason)||this._instance.register_for_session({[He]:[]}),void(this._lastLoggedBufferingReason=void 0);const t=this._describePendingTriggerConditions();if(0===t.length)return It(this._lastLoggedBufferingReason)||this._instance.register_for_session({[He]:[]}),void(this._lastLoggedBufferingReason=void 0);const i=t.join(", "),s=`${this.sessionId}:${i}`;s!==this._lastLoggedBufferingReason&&(this._lastLoggedBufferingReason=s,this._instance.register_for_session({[He]:t}),hc.info(`buffering: ${i}`))}_canParkPendingBuffer(){var e;return"memory"!==this._instance.config.persistence&&!0!==(null===(e=this._instance.persistence)||void 0===e?void 0:e._disabled)&&Ja._is_supported()}_parkBufferForNextPage(){0!==this._buffer.data.length&&this._buffer.size!==this._lastParkedBufferSize&&943718.4>=this._buffer.size&&this._canParkPendingBuffer()&&(this._lastParkedBufferSize=this._buffer.size,Ja._set(this._pendingBufferStorageKey,this._buffer))}_restorePendingBuffer(){if(this._pendingBufferRestored||!this._canParkPendingBuffer())return;this._pendingBufferRestored=!0;const e=Ja._parse(this._pendingBufferStorageKey);Ja._remove(this._pendingBufferStorageKey),Et(e)&&kt(e.data)&&0!==e.data.length&&kt(e.sizes)&&e.sizes.length===e.data.length&&Ft(e.size)&&e.sessionId===this._sessionId&&e.windowId===this._windowId&&(this._buffer.data.length>0||(this._buffer=e))}_flushBuffer(e=!1){var t;if(this._clearFlushBufferTimer(),this._holdFlushUntilInteraction)return this._buffer;if(this._wouldOpenRecordingWithMarkersOnly())return this._buffer.size>943718.4?this._clearBuffer():(e&&this._parkBufferForNextPage(),this._buffer);const i=this._buffer;null===(t=this._strategy)||void 0===t||t.ensureSamplingDecision(this.sessionId);const s=this._isBelowMinimumDuration(),n=this.status;if(this._maybeLogBufferingReason(n),"buffering"===n||"paused"===n||"disabled"===n||s)return!e||"active"!==n&&"sampled"!==n||this._parkBufferForNextPage(),this._scheduleFlushBuffer(),this._buffer;if(this._buffer!==i)return this._buffer;if(i.data.length>0){var r;const e=this._currentMaskedHostname();Ho(i).forEach(t=>{try{var i;null===(i=this._flushedSizeTracker)||void 0===i||i.trackSize(t.sessionId,t.size),this._captureSnapshot({$snapshot_bytes:t.size,$snapshot_data:t.data,$session_id:t.sessionId,$window_id:t.windowId,$lib:Ya.LIB_NAME,$lib_version:Ya.LIB_VERSION,$snapshot_host:e})}catch(e){hc.warn("could not capture snapshot chunk - skipping it",e)}}),It(this._lastParkedBufferSize)||(Ja._remove(this._pendingBufferStorageKey),this._lastParkedBufferSize=void 0),null===(r=this._strategy)||void 0===r||r.onFlushComplete()}return this._clearBuffer()}_captureSnapshotBuffered(e){var t;const i=2+((null===(t=this._buffer)||void 0===t?void 0:t.data.length)||0),s=e.$session_id,n=this._buffer.sessionId!==s;if(n||!0!==this._isIdle&&!this._holdFlushUntilInteraction&&this._buffer.size+e.$snapshot_bytes+i>943718.4){const t=this._sessionId;if(this._buffer=this._flushBuffer(),this._sessionId!==t)return;n&&this._buffer.data.length>0&&(this._buffer=this._clearBuffer()),this._buffer.sessionId=s,this._buffer.windowId=e.$window_id}this._holdFlushUntilInteraction&&(this._heldBufferOverflowed||this._buffer.size+e.$snapshot_bytes+i>943718.4)?this._heldBufferOverflowed||(this._heldBufferOverflowed=!0,this._buffer=this._clearBuffer()):(this._buffer.size+=e.$snapshot_bytes,this._buffer.data.push(e.$snapshot_data),this._buffer.sizes.push(e.$snapshot_bytes),!0===this._isIdle||this._holdFlushUntilInteraction||this._scheduleFlushBuffer())}_captureSnapshot(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}get _sessionDuration(){var e,t;const i=null===(e=this._buffer)||void 0===e?void 0:e.data[(null===(t=this._buffer)||void 0===t?void 0:t.data.length)-1];return i?i.timestamp-this._sessionStartTimestamp:null}_clearBufferBeforeMostRecentMeta(){if(!this._buffer||0===this._buffer.data.length)return this._clearBuffer();let e=-1;for(let t=this._buffer.data.length-1;t>=0;t--)if(4===this._buffer.data[t].type){e=t;break}return 0>e?this._clearBuffer():(this._buffer.data=this._buffer.data.slice(e),this._buffer.sizes=this._buffer.sizes.slice(e),this._buffer.size=this._buffer.sizes.reduce((e,t)=>e+t,0),this._buffer)}_clearBuffer(){return this._buffer={size:0,data:[],sizes:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_reportStarted(e,t){this._instance.register_for_session({[Ge]:e}),hc.info(e.replace("_"," "),t),"session_id_changed"!==e&&this._tryAddCustomEvent("$recording_started",ct({reason:e},t))}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==pc.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){const t=this._isInteractiveEvent(e);t||!0===this._isIdle||e.timestamp-this._lastActivityTimestamp>this._sessionIdleThresholdMilliseconds&&(this._isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this._sessionIdleThresholdMilliseconds,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size,sessionId:this._sessionId,windowId:this._windowId}),this._flushBuffer());const{windowId:i,sessionId:s}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp);let n=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){const t="unknown"===this._isIdle;this._isIdle=!1,t||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),n=!0)}const r=this._sessionId!==s,o=this._windowId!==i;if(this._windowId=i,this._sessionId=s,r||o){const e=r&&!1!==this._isIdle;e&&(this._isIdle="unknown"),this._restartForSessionIdChange(e)}else if(t&&this._releaseHoldAndFlush(),n){var a;const e=["sampled","active"].includes(this.status)||(null===(a=this._strategy)||void 0===a?void 0:a.hasPendingTriggers(this.sessionId));this._eventsDroppedWhileIdle>0&&e&&this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot()}}_clearConditionalRecordingPersistence(){var e;null===(e=this._strategy)||void 0===e||e.clearConditionalRecordingPersistence()}get sdkDebugProperties(){var e,t,i,s,n,r,o,a,l,c,u,d;const h=null===(e=gc())||void 0===e||null===(t=e.getDeferredStylesheetStats)||void 0===t?void 0:t.call(e);return{$recording_status:this.status,$sdk_debug_replay_flush_hold_reason:this._flushHoldReason,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_current_session_duration:this._sessionDuration,$sdk_debug_session_start:this._sessionStartTimestamp,$sdk_debug_replay_flushed_size:null===(i=this._flushedSizeTracker)||void 0===i?void 0:i.currentTrackedSize(this.sessionId),$sdk_debug_replay_full_snapshots:this._fullSnapshotTimestamps,$snapshot_max_depth_exceeded:this._maxDepthExceeded,$sdk_debug_replay_slowest_full_snapshot_ms:uc(null===(s=this._slowestFullSnapshot)||void 0===s?void 0:s.durationMs),$sdk_debug_replay_slowest_full_snapshot_stylesheet_ms:uc(null===(n=this._slowestFullSnapshot)||void 0===n?void 0:n.stylesheetMs),$sdk_debug_replay_slowest_full_snapshot_nodes:null===(r=this._slowestFullSnapshot)||void 0===r?void 0:r.nodeCount,$sdk_debug_replay_slowest_full_snapshot_css_rules:null===(o=this._slowestFullSnapshot)||void 0===o?void 0:o.cssRuleCount,$sdk_debug_replay_slowest_full_snapshot_css_rules_non_deferrable:null===(a=this._slowestFullSnapshot)||void 0===a?void 0:a.nonDeferrableCssRuleCount,$sdk_debug_replay_deferred_stylesheets:null==h?void 0:h.deferredCount,$sdk_debug_replay_deferred_stylesheets_failed:null==h?void 0:h.failedCount,$sdk_debug_replay_deferred_stylesheets_abandoned:null==h?void 0:h.abandonedCount,$sdk_debug_replay_deferred_stylesheet_ms:uc(null==h?void 0:h.totalMs),$sdk_debug_replay_deferred_stylesheet_slowest_slice_ms:uc(null==h?void 0:h.slowestSliceMs),$sdk_debug_replay_slowest_mutation_batch_ms:uc(null===(l=gc())||void 0===l||null===(c=l.getMutationCost)||void 0===c||null===(c=c.call(l))||void 0===c?void 0:c.slowestBatchMs),$sdk_debug_replay_discarded_duration_samples:null===(u=gc())||void 0===u||null===(d=u.getDiscardedDurationSamples)||void 0===d?void 0:d.call(u),$sdk_debug_replay_throttled_mutations_dropped:this._throttledMutationsDropped,$sdk_debug_replay_oversized_mutations_dropped:this._oversizedMutationsDropped,$sdk_debug_replay_oversized_mutation_bytes_dropped:this._oversizedMutationBytesDropped,$sdk_debug_replay_rrweb_error:this._rrwebError,[je]:!!this._stopRrweb,[Ve]:this._rrwebStartAttempted}}_startRecorder(){var t;if(this._stopRrweb)return;this._rrwebStartAttempted=!0;const i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,maskAllElementAttributes:!1,maskAttributeFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,inlineStylesheetBudgetRules:1e4,recordCrossOriginIframes:!1,sampling:void 0,attributeFilter:void 0},n=this._instance.config.session_recording;for(const[e,t]of Object.entries(n||{}))if(e in i)if("maskInputOptions"===e)i.maskInputOptions=ct({password:!0},t);else if("sampling"===e){const e=null!=t?t:{},s={};It(e.mousemove)||(s.mousemove=e.mousemove),It(e.mouseInteraction)||(s.mouseInteraction=e.mouseInteraction),i.sampling=s}else i[e]=t;var r,o,a,l;!0===(null==n?void 0:n.captureJsonLd)&&!0!==i.slimDOMOptions&&"all"!==i.slimDOMOptions&&(i.slimDOMOptions=ct(ct({},i.slimDOMOptions),{},{script:!0})),this._canvasRecording&&this._canvasRecording.enabled&&(i.recordCanvas=!0,i.sampling=ct(ct({},i.sampling),{},{canvas:this._canvasRecording.fps}),i.dataURLOptions={type:"image/webp",quality:this._canvasRecording.quality},i.canvasResolutionScale=this._canvasResolutionScale,i.canvasMasking={configured:()=>{var e;return Ct(null===(e=this._instance.config.session_recording)||void 0===e||null===(e=e.canvasCapture)||void 0===e?void 0:e.maskRegionsFn)},regionsFn:e=>{var t;const i=null===(t=this._instance.config.session_recording)||void 0===t||null===(t=t.canvasCapture)||void 0===t?void 0:t.maskRegionsFn;if(Ct(i))try{var s;return null!==(s=i(e))&&void 0!==s?s:null}catch(e){return this._maskRegionsFnFailed||(this._maskRegionsFnFailed=!0,hc.warn("canvasCapture.maskRegionsFn threw, canvas frames will be skipped",e)),null}}}),this._masking&&(i.maskAllInputs=null===(r=this._masking.maskAllInputs)||void 0===r||r,i.maskTextSelector=null!==(o=this._masking.maskTextSelector)&&void 0!==o?o:void 0,i.blockSelector=null!==(a=this._masking.blockSelector)&&void 0!==a?a:void 0,i.maskAllElementAttributes=null!==(l=this._masking.maskAllElementAttributes)&&void 0!==l&&l),i.maskAllElementAttributes&&i.maskAttributeFn&&(i.maskAttributeFn=void 0,this._hasWarnedExclusiveAttributeMasking||(this._hasWarnedExclusiveAttributeMasking=!0,hc.warn('`maskAllElementAttributes` and `maskAttributeFn` are mutually exclusive, and `maskAttributeFn` is being ignored. Remove one of the two. Note that `maskAllElementAttributes` can also come from your project\'s "Privacy and masking" settings. See https://posthog.com/docs/session-replay/privacy'))),this._warnIfClientMaskingShadowsServer();const c=fc();if(!c)return void hc.error("_startRecorder was called but rrwebRecord is not available. This indicates something has gone wrong.");this._mutationThrottler=null!==(t=this._mutationThrottler)&&void 0!==t?t:new ka(c,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{const i=`Too many mutations on node '${e}'. Rate limiting. This could be due to SVG animations or something similar`;hc.info(i,{node:t}),this.log("[SessionRecording] "+i,"warn")},onDroppedAttributeMutations:e=>this._throttledMutationsDropped+=e,bytesRefillRate:this._instance.config.session_recording.__mutationBytesRefillRate,bytesBucketSize:this._instance.config.session_recording.__mutationBytesBucketSize,resyncIntervalMs:this._fullSnapshotIntervalMillis,onDroppedOversizedMutation:e=>{0===this._oversizedMutationsDropped&&this.log("[SessionRecording] Dropped an oversized DOM mutation to keep the recording playable. The recording will resync with a full snapshot.","warn"),this._oversizedMutationsDropped+=1,this._oversizedMutationBytesDropped+=e},requestFullSnapshot:()=>this._tryTakeFullSnapshot()});const u=this._gatherRRWebPlugins();if(this._stopRrweb=c(ct({emit:e=>{this.onRRwebEmit(e)},plugins:u,errorHandler:(e,t)=>"rrweb"===t&&(this._hasLoggedRecorderCallbackError||(this._hasLoggedRecorderCallbackError=!0,hc.error("rrweb internal error - recording will continue but may be incomplete",e)),!0)},i)),!this._stopRrweb)return this._rrwebError=!0,void hc.error("rrweb failed to start - Loss of recording data is possible. Check the browser console for rrweb errors.");this._rrwebError=!1,!0===(null==n?void 0:n.captureJsonLd)&&s&&(null==e?void 0:e.MutationObserver)&&!this._jsonLdCapture&&(this._jsonLdCapture=function(e,t,i){const s=new WeakMap,n=i.getCaptureState||(()=>!0);let r=ql;const o=function(e,t){const i=t.attributeFilter;return t.maskAllElementAttributes||t.maskAttributeFn||(null==i?void 0:i.length)&&!i.includes("id")?Wl:i=>{const s=e.getElementById(i);return!!s&&"SCRIPT"!==s.nodeName&&(!t.isRecordedElement||t.isRecordedElement(s))&&!lc(s,t.blockClass,t.blockSelector)}}(e,i),a=t=>{try{const a=n();if(!r||!1===a||!t.isConnected||t.ownerDocument!==e||function(e,t){return lc(e,t.blockClass,t.blockSelector)||lc(e,t.maskTextClass,t.maskTextSelector)}(t,i))return;const l=function(e,t=Wl,i){if(!e||e.length>ql)return null;try{const s=JSON.parse(e),n={maskUrl:i,remainingNodes:2048,exceeded:!1},r=kt(s)?s.map(e=>rc(e,t,n)):rc(s,t,n);if(n.exceeded||Rt(r)||kt(r)&&(!r.length||r.some(Rt)))return null;const o=JSON.stringify(r);return o.length>2e4?null:[r,o]}catch(e){return null}}(t.text,o,i.maskUrl);if(!l)return void s.delete(t);const[c,u]=l;if(Rt(a))return void s.set(t,u);if(s.get(t)!==u){if(u.length>r)return void(r=0);i.emit(c)&&(s.set(t,u),r-=u.length)}}catch(e){return}};try{const i=new t(e=>{try{if(!r||!1===n())return;const t=e=>{for(const t of cc(e))a(t)};for(const i of e)if("childList"===i.type)oc(i.target)&&a(i.target),i.addedNodes.forEach(t);else if("characterData"===i.type){const e=i.target.parentNode;e&&oc(e)&&a(e)}else"attributes"===i.type&&oc(i.target)&&a(i.target)}catch(e){return}});return i.observe(e,{attributes:!0,attributeFilter:["type"],characterData:!0,childList:!0,subtree:!0}),{scan(t=!1){r&&!1!==n()&&cc(e.documentElement).forEach(e=>{t&&s.delete(e),a(e)})},stop(){return i.disconnect()}}}catch(e){return{scan(){},stop(){}}}}(s,e.MutationObserver,{maskUrl:e=>this._maskReplayUrl(e),attributeFilter:i.attributeFilter,blockClass:i.blockClass,blockSelector:i.blockSelector,isRecordedElement:e=>c.mirror.getId(e)>0,maskAllElementAttributes:i.maskAllElementAttributes,maskAttributeFn:i.maskAttributeFn,maskTextClass:i.maskTextClass,maskTextSelector:i.maskTextSelector,getCaptureState:()=>{var e;return!0!==(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)||this._urlTriggerMatching.urlBlocked||this._urlTriggerMatching.isCurrentUrlBlocked()?null:this._canCaptureJsonLd()},emit:e=>this._tryAddJsonLdEvent(e)}),this._urlTriggerMatching.isCurrentUrlBlocked()&&this._jsonLdCapture.scan()),this._lastActivityTimestamp=Date.now(),this._isIdle=At(this._isIdle)?this._isIdle:"unknown",this.tryAddCustomEvent("$remote_config_received",this._remoteConfig),this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:u.map(e=>null==e?void 0:e.name)}),this._tryAddCustomEvent("$posthog_config",{config:this._instance.config})}tryAddCustomEvent(e,t){return this._tryAddCustomEvent(e,t)}};const Bc=["type"];var qc=function(e){return e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e}({}),Hc=function(e){return e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e}({}),Uc=function(e){return e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e}({}),Wc=function(e){return e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e}({}),zc=function(e){return e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e}({}),jc=function(e){return e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e}({}),Vc=function(e){return e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e}({});function Gc(e,t){return-1!==e.indexOf(t)}"Mobile".toLowerCase(),"Tablet".toLowerCase(),new RegExp("Xbox","i"),new RegExp("Nintendo","i"),new RegExp("PlayStation","i"),new RegExp("Windows","i"),Date,Date,"0".repeat(32),"0".repeat(16);var Qc={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot"],MutationObserver:[]},Kc={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:["querySelector","querySelectorAll"],MutationObserver:["constructor"]},Zc={};function Jc(e){if(Zc[e])return Zc[e];const t=function(e){var t,i;const s=null===(t=globalThis)||void 0===t||null===(t=t.Zone)||void 0===t||null===(i=t.__symbol__)||void 0===i?void 0:i.call(t,e);return s&&globalThis[s]?globalThis[s]:void 0}(e)||globalThis[e],i=t.prototype,s=e in Qc?Qc[e]:void 0,n=Boolean(s&&s.every(e=>{var t;return Boolean(null===(t=Object.getOwnPropertyDescriptor(i,e))||void 0===t||null===(t=t.get)||void 0===t?void 0:t.toString().includes("[native code]"))})),r=e in Kc?Kc[e]:void 0,o=Boolean(r&&r.every(e=>{var t;return"function"==typeof i[e]&&(null===(t=i[e])||void 0===t?void 0:t.toString().includes("[native code]"))}));if(n&&o)return Zc[e]=t.prototype,t.prototype;const a=document.createElement("iframe");a.style.display="none";let l=!1;try{document.body.appendChild(a);const s=a.contentWindow;if(!s)return t.prototype;const n=s[e].prototype;return n?(function(e){return Gc(e,"AppleWebKit")&&!Gc(e,"Chrome")}(navigator.userAgent)&&(a.classList.add("rr-block","ph-no-capture"),a.setAttribute("__rrwebUntaintedPrototype",e),l=!0),Zc[e]=n):i}catch(e){return i}finally{!l&&a.parentNode&&document.body.removeChild(a)}}var Yc=Object.create(null);function Xc(e,t,i){var s;const n=Yc[e],r=n[i];if(r)return r.call(t);const o=Jc(e),a=null===(s=Object.getOwnPropertyDescriptor(o,i))||void 0===s?void 0:s.get;return a?(n[i]=a,a.call(t)):t[i]}Yc.Node=Object.create(null),Yc.ShadowRoot=Object.create(null),Yc.MutationObserver=Object.create(null),Yc.Element=Object.create(null);var eu,tu={};function iu(e,t,i){const s=`${e}.${String(i)}`;if(tu[s])return tu[s].bind(t);const n=Jc(e)[i];return"function"!=typeof n?t[i]:(tu[s]=n,n.bind(t))}function su(){return Jc("MutationObserver").constructor}function nu(e,t,i){try{if(!(t in e))return()=>{};const s=e[t],n={next:s},r=i(function(...e){return n.next.apply(this,e)});return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:s},__rrweb_layer__:{enumerable:!1,value:n}})),e[t]=r,()=>{if(e[t]===r)return void(e[t]=n.next);const i=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let s=e[t],o=i(s);for(;o;){if(o.next===r)return void(o.next=n.next);s=o.next,o=i(s)}}}catch(e){return()=>{}}}var ru={childNodes:e=>Xc("Node",e,"childNodes"),parentNode:e=>Xc("Node",e,"parentNode"),parentElement:e=>Xc("Node",e,"parentElement"),textContent:e=>Xc("Node",e,"textContent"),isConnected(e){if(void 0===eu){var t;const e=null===(t=Object.getOwnPropertyDescriptor(Jc("Node"),"isConnected"))||void 0===t?void 0:t.get;eu=(null==e?void 0:e.toString().includes("[native code]"))?e:null}return null==eu?void 0:eu.call(e)},contains:(e,t)=>iu("Node",e,"contains")(t),getRootNode:e=>iu("Node",e,"getRootNode")(),host:e=>e&&"host"in e?Xc("ShadowRoot",e,"host"):null,styleSheets:e=>e.styleSheets,shadowRoot:e=>e&&"shadowRoot"in e?Xc("Element",e,"shadowRoot"):null,querySelector:(e,t)=>iu("Element",e,"querySelector")(t),querySelectorAll:(e,t)=>iu("Element",e,"querySelectorAll")(t),mutationObserver:su,patch:nu};function ou(){try{if("undefined"!=typeof performance&&performance.now)return performance.now()}catch(e){}return Date.now()}var au=0;function lu(){au+=1}function cu(){return au}function uu(e,t){return(t!==au||e>6e4)&&!0}var du=0,hu=0,pu=0,_u={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gu=null,fu=null,vu=[],mu=0,yu=0,bu={slowestBatchMs:0},Su={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0};function wu(e){(du+=1)>1||(_u={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},vu=[],mu=0,fu=(e=>e&&e>0?e:null)(e),hu=ou(),pu=au)}function ku(){return 0===du?gu||{durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0}:(du-=1)>0?_u:(_u.durationMs=ou()-hu,_u.deferredStylesheetCount=mu,Su.deferredCount+=mu,fu=null,uu(_u.durationMs,pu)?_u:gu=_u)}function Cu(e,t,i){let s=e.length;if(i>=32)return s;for(let n=0;e.length>n;n++){const r=e[n];try{const e=r.cssRules;if(e&&e.length)s+=Cu(e,t,i+1);else if(t&&r.styleSheet){const e=r.styleSheet;if(!t.has(e)){t.add(e);const n=e.rules||e.cssRules;n&&(s+=Cu(n,t,i+1))}}}catch(e){}}return s}function Eu(e){if(0===du)return;const t=Cu(e,null,0);_u.cssRuleCount+=t,yu>0&&(_u.nonDeferrableCssRuleCount+=t)}function xu(e){yu+=1;try{return e()}finally{yu-=1}}function Iu(e){du>0&&(_u.stylesheetMs+=e)}function Tu(e){if(0===du||null===fu)return!1;const t=_u.cssRuleCount-_u.nonDeferrableCssRuleCount;return t>=fu||t+function(e){try{const t=e&&(e.rules||e.cssRules);if(!t)return 0;const i=new WeakSet;return i.add(e),Cu(t,i,0)}catch(e){return 0}}(e)>fu}function Mu(){const e=vu;return vu=[],e}function Ru(){Su.failedCount+=1}function Pu(e){e>0&&(Su.abandonedCount+=e)}function Fu(e){return Fu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fu(e)}function Lu(e,t,i){return(t=function(e){var t=function(e){if("object"!=Fu(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=Fu(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Fu(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Au(e){return e.nodeType===e.ELEMENT_NODE}function Ou(e){const t=e&&"host"in e&&"mode"in e&&ru.host(e)||null;return Boolean(t&&"shadowRoot"in t&&ru.shadowRoot(t)===e)}function Du(e){return"[object ShadowRoot]"==={}.toString.call(e)}function $u(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function Nu(e){const{cssText:t}=e;if(3>t.split('"').length)return t;const i=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?i.push("layer"):e.layerName&&i.push(`layer(${e.layerName})`),e.supportsText&&i.push(`supports(${e.supportsText})`),e.media.length&&i.push(e.media.mediaText),i.join(" ")+";"}var Bu=0;function qu(e){const t=0===Bu,i=t?ou():0;Bu+=1;try{const t=e.rules||e.cssRules;if(!t)return null;Eu(t);let i=e.href;return!i&&e.ownerNode&&(i=e.ownerNode.baseURI),$u(Array.from(t,e=>Hu(e,i)).join(""))}catch(e){return null}finally{Bu-=1,t&&Iu(ou()-i)}}function Hu(e,t){if(Wu(e)){let t;try{t=qu(e.styleSheet)||Nu(e)}catch(i){t=e.cssText}try{var i;if(t&&(null===(i=e.styleSheet)||void 0===i?void 0:i.href))return rd(t,e.styleSheet.href)}catch(e){}return t}{let i=e.cssText;return zu(e)&&e.selectorText.includes(":")&&(i=Uu(i)),t?rd(i,t):i}}function Uu(e){return e.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")}function Wu(e){return"styleSheet"in e}function zu(e){return"selectorText"in e}var ju=/^-?[A-Za-z_][\w-]*$/,Vu=/^-?[A-Za-z_][\w-]*(\.-?[A-Za-z_][\w-]*)*$/;function Gu(e){const t=[];let i=!1,s=null;const n=new Map;function r(e){const n=t.pop();if("group"===n.kind){if(null===e){for(;t.length>0&&"group"===t[t.length-1].kind;)t.pop();return void r(null)}const i=t[t.length-1];return i.parts.push(e),void(i.index+=1)}if(!n.importRule)return i=!0,void(s=e);o(t[t.length-1],n.importRule,e)}function o(e,t,i){try{let n;try{n=i||Nu(t)}catch(e){n=t.cssText}try{var s;n&&(null===(s=t.styleSheet)||void 0===s?void 0:s.href)&&(n=rd(n,t.styleSheet.href))}catch(e){}n&&e.parts.push(n),e.index+=1}catch(e){r(null)}}function a(e){const i=e.rules[e.index];if("sheet"===e.kind&&Wu(i)){const s=n.get(i);return null===s?(e.parts.push(i.cssText),void(e.index+=1)):s?void t.push({kind:"sheet",sheet:s.sheet,rules:s.rules,sheetHref:s.sheetHref,index:0,parts:[],importRule:i}):void o(e,i,null)}if(function(e,i){try{const s=function(e){const t=e;if(!t.cssRules||0===t.cssRules.length)return null;if(t.media&&"string"==typeof t.media.mediaText)return`@media ${t.media.mediaText} {`;if(zu(e)){if("number"==typeof t.type&&1!==t.type)return null;const i=t.style?t.style.cssText:"";return`${e.selectorText} {${i?" "+i:""}`}if("containerName"in t)return"string"!=typeof t.containerQuery||t.containerName&&!ju.test(t.containerName)?null:`@container ${t.containerName?`${t.containerName} `:""}${t.containerQuery} {`;if("string"==typeof t.conditionText){let s="";try{var i;s=(null===(i=e.constructor)||void 0===i?void 0:i.name)||""}catch(e){return null}return""===s||"Object"===s||"CSSSupportsRule"===s?`@supports ${t.conditionText} {`:null}return"string"==typeof t.name?"keyText"in t.cssRules[0]?ju.test(t.name)?`@keyframes ${t.name} {`:null:""===t.name?"@layer {":Vu.test(t.name)?`@layer ${t.name} {`:null:null}(e);if(null===s)return!1;const n=i.sheetHref;return t.push({kind:"group",rules:Array.from(e.cssRules),sheetHref:n,index:0,parts:[],prelude:n?rd(s,n):s,fixColons:"sheet"===i.kind&&zu(e)&&e.selectorText.includes(":")}),!0}catch(e){return!1}}(i,e))return;let s=i.cssText;"sheet"===e.kind&&zu(i)&&i.selectorText.includes(":")&&(s=Uu(s)),e.parts.push(e.sheetHref?rd(s,e.sheetHref):s),e.index+=1}return function(e){try{const i=e.rules||e.cssRules;if(!i)return!1;Eu(i);let s=e.href;!s&&e.ownerNode&&(s=e.ownerNode.baseURI);const r=Array.from(i);return t.push({kind:"sheet",sheet:e,rules:r,sheetHref:s,index:0,parts:[],importRule:null}),function(e,t){const i=[{sheet:t,rules:e,index:0}];for(;i.length>0;){const e=i[i.length-1];if(e.index>=e.rules.length){i.pop();continue}const t=e.rules[e.index];if(e.index+=1,!Wu(t)||n.has(t))continue;let s=null;try{s=t.styleSheet}catch(e){n.set(t,null);continue}if(s&&!i.some(e=>e.sheet===s))try{const e=s.rules||s.cssRules;if(!e)continue;Eu(e);let r=s.href;!r&&s.ownerNode&&(r=s.ownerNode.baseURI);const o=Array.from(e);n.set(t,{sheet:s,rules:o,sheetHref:r}),i.push({sheet:s,rules:o,index:0})}catch(e){}}}(r,e),!0}catch(e){return!1}}(e)||(i=!0),{advance(e){if(i)return!0;const n=ou();let o=e>0?e:1;try{for(;!i&&o>0;){const e=t[t.length-1];if(e.index>=e.rules.length){let t=null;try{if("group"===e.kind){const i=e.prelude+e.parts.join("")+"}";t=e.fixColons?Uu(i):i}else t=$u(e.parts.join(""))}catch(e){}r(t);continue}o-=1;try{a(e)}catch(e){r(null)}}}catch(e){i=!0,s=null}finally{Iu(ou()-n)}return i},text:()=>i?s:null,remainingRules(){if(i)return 0;let e=0;for(const i of t)e+=i.rules.length-i.index;return e}}}var Qu=class{constructor(){Lu(this,"idNodeMap",new Map),Lu(this,"nodeMetaMap",new WeakMap)}getId(e){var t,i;return e&&null!==(t=null===(i=this.getMeta(e))||void 0===i?void 0:i.id)&&void 0!==t?t:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);if(this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e)),Au(e)){const t=ru.shadowRoot(e);t&&this.removeNodeFromMap(t),"IFRAME"===e.nodeName&&e.contentDocument&&this.removeNodeFromMap(e.contentDocument)}}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){this.idNodeMap.set(t.id,e),this.nodeMetaMap.set(e,t)}replace(e,t){const i=this.getNode(e);if(i){const e=this.nodeMetaMap.get(i);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function Ku({element:e,maskInputOptions:t,tagName:i,type:s,value:n,maskInputFn:r}){let o=n||"";const a=s&&Zu(s);return(t[i.toLowerCase()]||a&&t[a])&&(o=r?r(o,e):"*".repeat(o.length)),o}function Zu(e){return e.toLowerCase()}var Ju=new Set(["rr_width","rr_height","rr_left","rr_top","rr_position","rr_transform","rr_display","rr_scrollleft","rr_scrolltop","rr_mediastate","rr_open_mode"]);function Yu({element:e,name:t,value:i,maskAllElementAttributes:s,maskAttributeFn:n,isGenerated:r=!1}){return i?s?r&&Ju.has(Zu(t))?i:"*".repeat(i.length):n?n(t,i,e):i:i}var Xu="__rrweb_original__";function ed(e){try{const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Zu(t):null}catch(e){return null}}var td=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,id=/^(?:[a-z+]+:)?\/\//i,sd=/^www\..*/i,nd=/^(data:)([^,]*),(.*)/i;function rd(e,t){return(e||"").replace(td,(e,i,s,n,r,o)=>{const a=s||r||o,l=i||n||"";if(!a)return e;if(id.test(a)||sd.test(a))return`url(${l}${a}${l})`;if(nd.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),u=a.split("/");c.pop();for(const e of u)"."!==e&&(".."===e?c.pop():c.push(e));return`url(${l}${c.join("/")}${l})`})}var od,ad,ld=new Map,cd=1,ud=new RegExp("[^a-z0-9-_:]");function dd(){return cd++}var hd=/^[^ \t\n\r\u000c]+/,pd=/^[, \t\n\r\u000c]+/,_d=new WeakMap;function gd(e,t){return t&&""!==t.trim()?fd(e,t):t}function fd(e,t){let i=_d.get(e);if(i||(i=e.createElement("a"),_d.set(e,i)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return i.setAttribute("href",t),i.href}function vd(e,t){return(null==t?void 0:t.maxBase64ImageLength)?function(e,t){return t&&e.length>t?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==":e}(e,t.maxBase64ImageLength):e}function md(e,t,i,s,n,r){if(!s)return s;if("src"===i||"href"===i&&("use"!==t||"#"!==s[0])){if("link"===t&&n){var o;const e=null===(o=n.sheet)||void 0===o?void 0:o.href;if(e)return e}const i=gd(e,s);if(i.startsWith("data:")){if("img"===t&&n){let e=i;return((null==r?void 0:r.type)||void 0!==(null==r?void 0:r.quality))&&(e=function(e,t,i,s){if(1e5>t.length)return t;if(!e.complete||0===e.naturalWidth)return t;if(e.naturalWidth>4096||e.naturalHeight>4096)return t;const n=ld.get(t);if(n&&n.type===i&&n.quality===s)return n.result;try{const n=document.createElement("canvas");n.width=e.naturalWidth,n.height=e.naturalHeight;const r=n.getContext("2d");if(!r)return t;r.drawImage(e,0,0);const o=n.toDataURL(i||"image/webp",null!=s?s:.4),a=t.length>o.length?o:t;if(ld.size>=10){const e=ld.keys().next().value;void 0!==e&&ld.delete(e)}return ld.set(t,{type:i,quality:s,result:a}),a}catch(e){return t}}(n,i,r.type,r.quality)),vd(e,r)}if("image"===t)return vd(i,r)}return i}if("xlink:href"===i&&"#"!==s[0]){const i=gd(e,s);return"image"===t&&i.startsWith("data:")?vd(i,r):i}return"background"!==i||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===i?function(e,t){if(""===t.trim())return t;let i=0;function s(e){let s;const n=e.exec(t.substring(i));return n?(s=n[0],i+=s.length,s):""}const n=[];for(;s(pd),t.length>i;){let r=s(hd);if(","===r.slice(-1))r=gd(e,r.substring(0,r.length-1)),n.push(r);else{let s="";r=gd(e,r);let o=!1;for(;;){const e=t.charAt(i);if(""===e){n.push((r+s).trim());break}if(o)")"===e&&(o=!1);else{if(","===e){i+=1,n.push((r+s).trim());break}"("===e&&(o=!0)}s+=e,i+=1}}}return n.join(", ")}(e,s):"style"===i?rd(s,fd(e)):"object"===t&&"data"===i?gd(e,s):s:gd(e,s)}function yd(e,t,i){return("video"===e||"audio"===e)&&"autoplay"===Zu(t)}function bd(e,t,i){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!i&&bd(ru.parentNode(e),t,i);for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;return!!i&&bd(ru.parentNode(e),t,i)}function Sd(e,t,i,s){let n;if(Au(e)){if(n=e,!ru.childNodes(n).length)return!1}else{if(null===ru.parentElement(e))return!1;n=ru.parentElement(e)}try{if("string"==typeof t){if(s){if(n.closest(`.${t}`))return!0}else if(n.classList.contains(t))return!0}else if(bd(n,t,s))return!0;if(i)if(s){if(n.closest(i))return!0}else if(n.matches(i))return!0}catch(e){}return!1}function wd(e,t,i){const s=e.removeEventListener;"function"==typeof s&&s.call(e,t,i)}var kd=new Map;function Cd(e,t){return Array.from(e.styleSheets).find(e=>e.href===t)}function Ed(e){return null==e?"":e.toLowerCase()}var xd=!1,Id=!1;function Td(e,t){const{doc:i,mirror:s,blockClass:n,blockSelector:r,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p=!1,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f={},inlineImages:v=!1,recordCanvas:m=!1,canvasMaskingConfigured:y,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w=5e3,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E=5e3,keepIframeSrcFn:x=()=>!1,newlyAddedElement:I=!1,depth:T=0,maxDepth:M=50}=t;let{needsMask:R}=t,{preserveWhiteSpace:P=!0}=t;if(T>=M)return Id=!0,xd||(xd=!0,console.warn(`[rrweb-snapshot] DOM tree depth exceeded max depth of ${M}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`)),null;R||(R=Sd(e,o,a,void 0===R)),du>0&&(_u.nodeCount+=1);const F=function(e,t){const{doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:u,maskAllElementAttributes:d=!1,maskAttributeFn:h,dataURLOptions:p={},inlineImages:_,recordCanvas:g,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const i=t.getId(e);return 1===i?void 0:i}(i,s);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:Vc.Document,childNodes:[],compatMode:e.compatMode}:{type:Vc.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:Vc.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:i,blockClass:s,blockSelector:n,inlineStylesheet:r,maskInputOptions:o={},maskInputFn:a,maskAllElementAttributes:l=!1,maskAttributeFn:c,dataURLOptions:u={},inlineImages:d,recordCanvas:h,canvasMaskingConfigured:p,keepIframeSrcFn:_,newlyAddedElement:g=!1,rootId:f}=t,v=function(e,t,i){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;if(i)return e.matches(i)}catch(e){}return!1}(e,s,n),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=Zu(e.tagName);return ud.test(t)?"div":t}(e),y=new Set;let b={};const S=e.attributes.length;for(let t=0;S>t;t++){const s=e.attributes[t];yd(m,s.name)||(b[s.name]=md(i,m,Zu(s.name),s.value,e,u))}if("link"===m&&r&&!v){let t=e.sheet;if(!t){const s=function(e){return e.href}(e);s&&(t=Cd(i,s),!t&&s.includes(".css"))&&(t=Cd(i,window.location.origin+"/"+s.replace(window.location.href,"")))}let s=null;t&&(Tu(t)?du>0&&(vu.push(e),mu+=1):s=qu(t)),s&&(delete b.rel,delete b.href,b._cssText=s)}if("style"===m&&e.sheet&&!(e.innerText||ru.textContent(e)||"").trim().length){const t=xu(()=>qu(e.sheet));t&&(b._cssText=t)}if("input"===m||"textarea"===m||"select"===m){const t=e.value,i=e.checked;"radio"!==b.type&&"checkbox"!==b.type&&"submit"!==b.type&&"button"!==b.type&&t?b.value=Ku({element:e,type:ed(e),tagName:m,value:t,maskInputOptions:o,maskInputFn:a}):i&&(b.checked=i)}if("option"===m&&(e.selected&&!o.select?b.selected=!0:delete b.selected),"dialog"===m&&e.open){try{b.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"}catch(e){b.rr_open_mode="modal",b.ph_rr_could_not_detect_modal=!0}y.add("rr_open_mode")}if("canvas"===m&&h&&!(null==p?void 0:p()))if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let i=0;e.width>i;i+=50)for(let s=0;e.height>s;s+=50){const n=t.getImageData;if(new Uint32Array((Xu in n?n[Xu]:n).call(t,i,s,Math.min(50,e.width-i),Math.min(50,e.height-s)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(b.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){const t=e.toDataURL(u.type,u.quality),s=i.createElement("canvas");s.width=e.width,s.height=e.height,t!==s.toDataURL(u.type,u.quality)&&(b.rr_dataURL=t)}let w,k=!1;if("img"===m&&d){od||(od=i.createElement("canvas"),ad=od.getContext("2d"));const t=e,s=t.currentSrc||t.getAttribute("src")||"<unknown-src>",n=t.crossOrigin,r=(t,i)=>k?Yu({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c}):i,o=()=>{wd(t,"load",o);try{od.width=t.naturalWidth,od.height=t.naturalHeight,ad.drawImage(t,0,0);const e=od.toDataURL(u.type,u.quality);b.rr_dataURL=r("rr_dataURL",e)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o));console.warn(`Cannot inline img src=${s}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(n?b.crossOrigin=r("crossOrigin",n):t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if("audio"===m||"video"===m){const t=b;t.rr_mediaState=e.paused?"paused":"played",y.add("rr_mediaState"),t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}if(g||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),v){var C,E,x;const{width:t,height:s,left:n,top:r}=e.getBoundingClientRect(),o=null===(C=i.defaultView)||void 0===C?void 0:C.getComputedStyle(e);b={class:b.class,rr_width:`${t}px`,rr_height:`${s}px`,rr_left:`${Math.floor(n+((null===(E=i.defaultView)||void 0===E?void 0:E.scrollX)||0))}px`,rr_top:`${Math.floor(r+((null===(x=i.defaultView)||void 0===x?void 0:x.scrollY)||0))}px`},y.add("rr_width"),y.add("rr_height"),y.add("rr_left"),y.add("rr_top"),o&&(b.rr_position=o.position||"static",y.add("rr_position"),o.transform&&"none"!==o.transform&&(b.rr_transform=o.transform,y.add("rr_transform")),o.display&&o.display.startsWith("inline")&&(b.rr_display=o.display,y.add("rr_display")))}if("iframe"!==m||_(b.src)||(e.contentDocument||(b.rr_src=b.src),delete b.src),l||c)for(const[t,i]of Object.entries(b))"string"!=typeof i&&null!==i||(b[t]=Yu({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c,isGenerated:y.has(t)}));k=!0;try{customElements.get(m)&&(w=!0)}catch(e){}return{type:Vc.Element,tagName:m,attributes:b,childNodes:[],isSVG:(I=e,Boolean("svg"===I.tagName||I.ownerSVGElement)||void 0),needBlock:v,rootId:f,isCustom:w};var I}(e,{doc:i,blockClass:n,blockSelector:r,inlineStylesheet:a,maskInputOptions:l,maskInputFn:u,maskAllElementAttributes:d,maskAttributeFn:h,dataURLOptions:p,inlineImages:_,recordCanvas:g,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:i,maskTextFn:s,rootId:n}=t,r=ru.parentNode(e),o=r&&r.tagName;let a=ru.textContent(e);const l="STYLE"===o||void 0,c="SCRIPT"===o||void 0;if(l&&a){try{var u;if(e.nextSibling||e.previousSibling);else if(Tu(r.sheet));else if(null===(u=r.sheet)||void 0===u?void 0:u.cssRules){const e=qu(r.sheet);e&&!/(?:^|[\s;{}])-?[a-zA-Z][\w-]*\s*:\s*;/.test(e)&&(a=e)}}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}a=rd(a,fd(t.doc))}return c&&(a="SCRIPT_PLACEHOLDER"),!l&&!c&&a&&i&&(a=s?s(a,ru.parentElement(e)):a.replace(/[\S]/g,"*")),{type:Vc.Text,textContent:a||"",isStyle:l,rootId:n}}(e,{doc:i,needsMask:o,maskTextFn:c,rootId:y});case e.CDATA_SECTION_NODE:return{type:Vc.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:Vc.Comment,textContent:ru.textContent(e)||"",rootId:y};default:return!1}}(e,{doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:R,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,keepIframeSrcFn:x,newlyAddedElement:I});if(!F)return console.warn(e,"not serialized"),null;let L;L=s.hasNode(e)?s.getId(e):function(e,t){if(t.comment&&e.type===Vc.Comment)return!0;if(e.type===Vc.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===function(e){var t;let i;try{i=new URL(e,window.location.href)}catch(e){return null}const s=i.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:null}(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Ed(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Ed(e.attributes.name)||["icon","apple-touch-icon","shortcut icon"].includes(Ed(e.attributes.rel)))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Ed(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Ed(e.attributes.property).match(/^(og|twitter|fb):/)||Ed(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Ed(e.attributes.name)))return!0;if(t.headMetaRobots&&["robots","googlebot","bingbot"].includes(Ed(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&(["author","generator","framework","publisher","progid"].includes(Ed(e.attributes.name))||Ed(e.attributes.property).match(/^article:/)||Ed(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&["google-site-verification","yandex-verification","csrf-token","p:domain_verify","verify-v1","verification","shopify-checkout-api-token"].includes(Ed(e.attributes.name)))return!0}}return!1}(F,g)||!P&&F.type===Vc.Text&&!F.isStyle&&!F.textContent.replace(/^\s+|\s+$/gm,"").length?-2:dd();const A=Object.assign(F,{id:L});if(s.add(e,A),-2===L)return null;b&&b(e);let O=!l;if(A.type===Vc.Element){O=O&&!A.needBlock,delete A.needBlock;const t=ru.shadowRoot(e);t&&Du(t)&&(A.isShadowHost=!0)}if((A.type===Vc.Document||A.type===Vc.Element)&&O){g.headWhitespace&&A.type===Vc.Element&&"head"===A.tagName&&(P=!1);const t={doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:R,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:P,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:x,depth:T+1,maxDepth:M};if(A.type===Vc.Element&&"textarea"===A.tagName&&void 0!==A.attributes.value);else for(const i of Array.from(ru.childNodes(e))){const e=Td(i,t);e&&A.childNodes.push(e)}let I=null;if(Au(e)&&(I=ru.shadowRoot(e)))for(const e of Array.from(ru.childNodes(I))){const i=Td(e,t);i&&(Du(I)&&(i.isShadow=!0),A.childNodes.push(i))}}const D=ru.parentNode(e);if(D&&Ou(D)&&Du(D)&&(A.isShadow=!0),A.type===Vc.Element&&"iframe"===A.tagName){const t=function(e,t,i){const s=()=>{},n=e.contentWindow;if(!n)return s;let r;try{r=n.document.readyState}catch(e){return s}const o=()=>t();if("complete"!==r){let s=!1,n=null;const r=()=>{s||(s=!0,null!==n&&(clearTimeout(n),n=null),wd(e,"load",a),e.addEventListener("load",o),t())},a=()=>r();return n=setTimeout(r,i),e.addEventListener("load",a),()=>{null!==n&&(clearTimeout(n),n=null),s?wd(e,"load",o):(s=!0,wd(e,"load",a))}}const a="about:blank";let l;try{l=n.location.href}catch(e){return s}if(l!==a||e.src===a||""===e.src){const i=setTimeout(t,0);return e.addEventListener("load",o),()=>{clearTimeout(i),wd(e,"load",o)}}return e.addEventListener("load",o),()=>{wd(e,"load",o)}}(e,()=>{const t=e.contentDocument;if(t&&S){const i=Td(t,{doc:t,mirror:s,blockClass:n,blockSelector:r,needsMask:R,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:P,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:x,depth:T+1,maxDepth:M});i&&S(e,i)}},w);null==k||k(e,t)}return A.type===Vc.Element&&"link"===A.tagName&&"stylesheet"===A.attributes.rel&&function(t,l,k){if(kd.has(t))return;let I;try{I=t.sheet}catch(e){return}if(I)return;const F=new AbortController;let L=!1;const A=()=>{if(!L){L=!0;try{(()=>{if(C){const t=Td(e,{doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:R,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:P,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:x,depth:T,maxDepth:M});t&&C(e,t)}})()}finally{kd.delete(t),F.abort()}}},O=setTimeout(A,k);F.signal.addEventListener("abort",()=>clearTimeout(O),{once:!0}),t.addEventListener("load",A,{signal:F.signal,once:!0}),kd.set(t,F)}(e,0,E),A}function Md(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:!1===e?{}:e}var Rd=class e{constructor(...e){Lu(this,"parentElement",null),Lu(this,"parentNode",null),Lu(this,"ownerDocument",void 0),Lu(this,"firstChild",null),Lu(this,"lastChild",null),Lu(this,"previousSibling",null),Lu(this,"nextSibling",null),Lu(this,"ELEMENT_NODE",1),Lu(this,"TEXT_NODE",3),Lu(this,"nodeType",void 0),Lu(this,"nodeName",void 0),Lu(this,"RRNodeType",void 0)}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};function Pd(e,t,i=document){const s={capture:!0,passive:!0};return i.addEventListener(e,t,s),()=>Fd(i,e,t,s)}function Fd(e,t,i,s){Ld(()=>{const n=e.removeEventListener;"function"==typeof n&&(void 0!==s?n.call(e,t,i,s):n.call(e,t,i))})}function Ld(e){try{e()}catch(e){if(!(e instanceof DOMException&&"SecurityError"===e.name))throw e}}function Ad(e){e.forEach(e=>{if("function"==typeof e)try{e()}catch(e){}})}var Od="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",Dd={map:{},getId(){return console.warn(Od),-1},getNode(){return console.warn(Od),null},removeNodeFromMap(){console.warn(Od)},has(){return console.warn(Od),!1},reset(){console.warn(Od)}};function $d(e,t,i={}){let s=null,n=0;return function(...r){const o=Date.now();n||!1!==i.leading||(n=o);const a=t-(o-n),l=this;0>=a||a>t?(s&&(clearTimeout(s),s=null),n=o,e.apply(l,r)):s||!1===i.trailing||(s=setTimeout(()=>{n=!1===i.leading?0:Date.now(),s=null,e.apply(l,r)},a))}}function Nd(e,t,i,s,n=window){const r=n.Object.getOwnPropertyDescriptor(e,t);return n.Object.defineProperty(e,t,s?i:{set(e){if(setTimeout(()=>{try{i.set.call(this,e)}catch(e){}},0),r&&r.set){if(r.get)try{r.get.call(this)}catch(e){return}r.set.call(this,e)}}}),()=>Nd(e,t,r||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Dd=new Proxy(Dd,{get(e,t,i){return"map"===t&&console.warn(Od),Reflect.get(e,t,i)}}));var Bd=Date.now;function qd(e){var t,i,s,n;const r=e.document;return{left:r.scrollingElement?r.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:r.documentElement.scrollLeft||(null==r?void 0:r.body)&&(null===(t=ru.parentElement(r.body))||void 0===t?void 0:t.scrollLeft)||(null==r||null===(i=r.body)||void 0===i?void 0:i.scrollLeft)||0,top:r.scrollingElement?r.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==r?void 0:r.documentElement.scrollTop)||(null==r?void 0:r.body)&&(null===(s=ru.parentElement(r.body))||void 0===s?void 0:s.scrollTop)||(null==r||null===(n=r.body)||void 0===n?void 0:n.scrollTop)||0}}function Hd(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ud(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Wd(e){return e?e.nodeType===e.ELEMENT_NODE?e:ru.parentElement(e):null}function zd(e,t,i,s){if(!e)return!1;const n=Wd(e);if(!n)return!1;try{if("string"==typeof t){if(n.classList.contains(t))return!0;if(s&&null!==n.closest("."+t))return!0}else if(bd(n,t,s))return!0}catch(e){}if(i){if(n.matches(i))return!0;if(s&&null!==n.closest(i))return!0}return!1}function jd(e,t,i){return!("TITLE"!==e.tagName||!i.headTitleMutations)||-2===t.getId(e)}function Vd(e,t){if(Ou(e))return!1;const i=t.getId(e);if(!t.has(i))return!0;const s=ru.parentNode(e);return(!s||s.nodeType!==e.DOCUMENT_NODE)&&(!s||Vd(s,t))}function Gd(e){return Boolean(e.changedTouches)}function Qd(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Kd(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Zd(e){return!!e&&(e instanceof Rd&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(ru.shadowRoot(e)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(Bd=()=>(new Date).getTime());var Jd=class{constructor(){Lu(this,"id",1),Lu(this,"styleIDMap",new WeakMap),Lu(this,"idStyleMap",new Map)}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let i;return i=void 0===t?this.id++:t,this.styleIDMap.set(e,i),this.idStyleMap.set(i,e),i}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function Yd(e){var t;let i=null;return"getRootNode"in e&&(null===(t=ru.getRootNode(e))||void 0===t?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&ru.host(ru.getRootNode(e))&&(i=ru.host(ru.getRootNode(e))),i}function Xd(e){const t=e.ownerDocument;if(!t)return!1;if(ru.contains(t,e))return!0;const i=ru.isConnected(e);return"boolean"==typeof i?i:function(e){const t=e.ownerDocument;if(!t)return!1;const i=function(e){let t,i=e;for(;t=Yd(i);)i=t;return i}(e);return ru.contains(t,i)}(e)}function eh(e){return"__ln"in e}var th,ih=class{constructor(){Lu(this,"length",0),Lu(this,"head",null),Lu(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let i=0;e>i;i++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&eh(e.previousSibling)){const i=e.previousSibling.__ln.next;t.next=i,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,i&&(i.previous=t)}else if(e.nextSibling&&eh(e.nextSibling)&&e.nextSibling.__ln.previous){const i=e.nextSibling.__ln.previous;t.previous=i,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,i&&(i.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},sh=(e,t)=>`${e}@${t}`,nh=class{constructor(){Lu(this,"frozen",!1),Lu(this,"locked",!1),Lu(this,"texts",[]),Lu(this,"attributes",[]),Lu(this,"attributeMap",new WeakMap),Lu(this,"generatedAttributes",new WeakMap),Lu(this,"removes",[]),Lu(this,"mapRemoves",new Set),Lu(this,"movedMap",{}),Lu(this,"addedSet",new Set),Lu(this,"movedSet",new Set),Lu(this,"droppedSet",new Set),Lu(this,"removesSubTreeCache",new Set),Lu(this,"mutationCb",void 0),Lu(this,"blockClass",void 0),Lu(this,"blockSelector",void 0),Lu(this,"maskTextClass",void 0),Lu(this,"maskTextSelector",void 0),Lu(this,"inlineStylesheet",void 0),Lu(this,"maskInputOptions",void 0),Lu(this,"maskTextFn",void 0),Lu(this,"maskInputFn",void 0),Lu(this,"maskAllElementAttributes",void 0),Lu(this,"maskAttributeFn",void 0),Lu(this,"keepIframeSrcFn",void 0),Lu(this,"recordCanvas",void 0),Lu(this,"canvasMaskingConfigured",void 0),Lu(this,"inlineImages",void 0),Lu(this,"slimDOMOptions",void 0),Lu(this,"dataURLOptions",void 0),Lu(this,"doc",void 0),Lu(this,"mirror",void 0),Lu(this,"iframeManager",void 0),Lu(this,"stylesheetManager",void 0),Lu(this,"shadowDomManager",void 0),Lu(this,"canvasManager",void 0),Lu(this,"processedNodeManager",void 0),Lu(this,"unattachedDoc",void 0),Lu(this,"canvasManagerReleased",!1),Lu(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),Lu(this,"emit",()=>{if(this.frozen||this.locked)return;const e=ou(),t=cu();try{this.processBufferedMutations()}finally{i=ou()-e,s=t,du>0||uu(i,null!=s?s:au)||i>bu.slowestBatchMs&&(bu.slowestBatchMs=i)}var i,s}),Lu(this,"processBufferedMutations",()=>{const e=[],t=new Set,i=new ih,s=e=>{let t=e,i=-2;for(;-2===i;)t=t&&t.nextSibling,i=t&&this.mirror.getId(t);return i};let n;const r=r=>{var o;const a=ru.parentNode(r);if(!a||!Xd(r)||"TEXTAREA"===a.tagName)return;if(this.isBlockedAtEmission(a))return;const l=Ou(a)?this.mirror.getId(Yd(r)):this.mirror.getId(a),c=s(r);if(-1===l||-1===c)return i.addNode(r);null!==(o=n)&&void 0!==o||(n={doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,canvasMaskingConfigured:this.canvasMaskingConfigured,inlineImages:this.inlineImages,onSerialize:e=>{Qd(e,this.mirror)&&this.iframeManager.addIframe(e),Kd(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Zd(e)&&!zd(e,this.blockClass,this.blockSelector,!0)&&this.shadowDomManager.addShadowRoot(ru.shadowRoot(e),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onIframeListenerRegistered:(e,t)=>{this.iframeManager.registerLoadListenerDisposer(e,t)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});const u=Td(r,n);u&&(e.push({parentId:l,nextId:c,node:u}),t.add(u.id))};for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e);for(const e of this.movedSet)oh(this.removesSubTreeCache,e)&&!this.movedSet.has(ru.parentNode(e))||r(e);for(const e of this.addedSet)ah(this.droppedSet,e)||oh(this.removesSubTreeCache,e)?ah(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let o=null;for(;i.length;){let e=null;if(o){const t=this.mirror.getId(ru.parentNode(o.value)),i=s(o.value);-1!==t&&-1!==i&&(e=o)}if(!e){let t=i.tail;for(;t;){const i=t;if(t=t.previous,i){const t=this.mirror.getId(ru.parentNode(i.value));if(-1===s(i.value))continue;if(-1!==t){e=i;break}{const t=ru.parentNode(i.value);if(t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const s=ru.host(t);if(-1!==this.mirror.getId(s)){e=i;break}}}}}}if(!e){for(;i.head;)i.removeNode(i.head.value);break}o=e.previous,i.removeNode(e.value),r(e.value)}const a={texts:this.texts.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const t=e.node,i=ru.parentNode(t);return i&&"TEXTAREA"===i.tagName&&this.genTextAreaValueMutation(i),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const{attributes:t}=e;if(!this.maskAllElementAttributes&&!this.maskAttributeFn&&"string"==typeof t.style){const i=JSON.stringify(e.styleDiff),s=JSON.stringify(e._unchangedStyles);t.style.length>i.length&&(i+s).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}if(this.maskAllElementAttributes||this.maskAttributeFn)for(const[s,n]of Object.entries(t))if("string"==typeof n||null===n){var i;t[s]=Yu({element:e.node,name:s,value:n,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,isGenerated:null===(i=this.generatedAttributes.get(e.node))||void 0===i?void 0:i.has(s)})}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.generatedAttributes=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},(a.texts.length||a.attributes.length||a.removes.length||a.adds.length)&&this.mutationCb(a)}),Lu(this,"bufferBelongsToIframe",e=>this.doc===e.contentDocument),Lu(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const i=Array.from(ru.childNodes(e),e=>ru.textContent(e)||"").join("");t.attributes.value=Ku({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:ed(e),value:i,maskInputFn:this.maskInputFn})}),Lu(this,"processMutation",e=>{if(!jd(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=ru.textContent(e.target);zd(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Sd(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Wd(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{var t;const s=e.target,n=Zu(s.tagName),r=e.attributeName,o=null!==(t=e.attributeNamespace)&&void 0!==t?t:null;let a=function(e,t,i){if(!i)return t;const s=e.getAttributeNodeNS(i,t);if(s)return s.name;if("http://www.w3.org/1999/xlink"===i)return`xlink:${t}`;if("http://www.w3.org/XML/1998/namespace"===i)return`xml:${t}`;if("http://www.w3.org/2000/xmlns/"===i)return"xmlns"===t?t:`xmlns:${t}`;const n=e.lookupPrefix(i);return n?`${n}:${t}`:t}(s,r,o),l=o?s.getAttributeNS(o,r):e.target.getAttribute(r);if("value"===a){const e=s,t=ed(e);l=Ku({element:e,maskInputOptions:this.maskInputOptions,tagName:s.tagName,type:t,value:l,maskInputFn:this.maskInputFn})}if(zd(e.target,this.blockClass,this.blockSelector,!1)||l===e.oldValue)return;let c=this.attributeMap.get(e.target);const u="iframe"===n&&"src"===a;if(u&&!this.keepIframeSrcFn(l)&&s.contentDocument)return;if("type"===a&&"input"===n&&"password"===(e.oldValue||"").toLowerCase()&&s.setAttribute("data-rr-is-password","true"),!yd(n,a)){var i;c||(c={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(c),this.attributeMap.set(e.target,c));const t=md(this.doc,n,Zu(a),l,s,this.dataURLOptions);if(u&&!this.keepIframeSrcFn(l)&&(a="rr_src"),c.attributes[a]=t,null===(i=this.generatedAttributes.get(e.target))||void 0===i||i.delete(a),"style"===a){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const t=this.unattachedDoc.createElement("span"),i=s.style;e.oldValue&&(t.style.cssText=e.oldValue);for(const e of Array.from(i)){const s=i.getPropertyValue(e),n=i.getPropertyPriority(e);s!==t.style.getPropertyValue(e)||n!==t.style.getPropertyPriority(e)?c.styleDiff[e]=""===n?s:[s,n]:c._unchangedStyles[e]=[s,n]}for(const e of Array.from(t.style))""===i.getPropertyValue(e)&&(c.styleDiff[e]=!1)}else if("open"===a&&"dialog"===n){c.attributes.rr_open_mode=s.matches("dialog:modal")?"modal":"non-modal";let t=this.generatedAttributes.get(e.target);t||(t=new Set,this.generatedAttributes.set(e.target,t)),t.add("rr_open_mode")}}break}case"childList":if(zd(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const i=this.mirror.getId(t),s=Ou(e.target)?this.mirror.getId(ru.host(e.target)):this.mirror.getId(e.target);zd(e.target,this.blockClass,this.blockSelector,!1)||jd(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(rh(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===i||Vd(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[sh(i,s)]?rh(this.movedSet,t):(this.removes.push({parentId:s,id:i,isShadow:!(!Ou(e.target)||!Du(e.target))||void 0}),function(e,t){const i=[e];for(;i.length;){const e=i.pop();t.has(e)||(t.add(e),ru.childNodes(e).forEach(e=>i.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.add(t))})}}),Lu(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)){if(this.addedSet.has(e))return this.addedSet.delete(e),void this.addedSet.add(e);if(!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(jd(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let i=null;t&&this.mirror.hasNode(t)&&(i=this.mirror.getId(t)),i&&-1!==i&&(this.movedMap[sh(this.mirror.getId(e),i)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);if(!zd(e,this.blockClass,this.blockSelector,!1)){if(e.nodeType===e.TEXT_NODE)return;const t=ru.childNodes(e);for(let e=0,i=t.length;i>e;e++){const i=t[e];i&&this.genAdds(i)}if(Zd(e)){const t=ru.childNodes(ru.shadowRoot(e));for(let i=0,s=t.length;s>i;i++){const s=t[i];s&&(this.processedNodeManager.add(s,this),this.genAdds(s,e))}}}}}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","maskAllElementAttributes","maskAttributeFn","keepIframeSrcFn","recordCanvas","canvasMaskingConfigured","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]}),this.canvasManager.acquire()}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.releaseCanvasManager()}releaseCanvasManager(){this.canvasManagerReleased||(this.canvasManagerReleased=!0,this.canvasManager.reset())}bufferDoc(){return this.doc}destroy(){for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e)}isBlockedAtEmission(e){const t=this.blockClass,i=t&&"string"!=typeof t&&(t.global||t.sticky)?new RegExp(t):null;for(;e;){if(i&&(i.lastIndex=0),zd(e,i||t,this.blockSelector,!0))return!0;const s="getRootNode"in e?ru.getRootNode(e):null;e=(null==s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE?ru.host(s):null}return!1}};function rh(e,t){const i=[t];for(;i.length;){const t=i.pop();if(e.delete(t),t.nodeType===t.TEXT_NODE)continue;const s=ru.childNodes(t);for(let e=0,t=s.length;t>e;e++){const t=s[e];t&&i.push(t)}}}function oh(e,t,i){return 0!==e.size&&function(e,t){const i=ru.parentNode(t);return!!i&&e.has(i)}(e,t)}function ah(e,t){if(0===e.size)return!1;let i=ru.parentNode(t);for(;i;){if(e.has(i))return!0;i=ru.parentNode(i)}return!1}function lh(e){th=e}function ch(){th=void 0}var uh=(e,t="rrweb")=>th?(...i)=>{try{return e(...i)}catch(e){if(th&&!0===th(e,t))return;throw e}}:e,dh=[];function hh(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function ph(e,t){const i=new nh;let s;i.init(e);try{s=new(su())(uh(i.processMutations.bind(i)));const n={attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};return e.attributeFilter&&e.attributeFilter.length>0&&(n.attributeFilter=e.attributeFilter),s.observe(t,n),dh.push(i),{observer:s,buffer:i}}catch(e){try{null==s||s.disconnect(),i.destroy(),i.reset()}catch(e){}throw e}}function _h({scrollCb:e,doc:t,mirror:i,blockClass:s,blockSelector:n,sampling:r}){const o=new Map,a=r=>{const a=hh(r);if(!a||zd(a,s,n,!0))return;const l=i.getId(a);let c,u;if(a===t&&t.defaultView){const e=qd(t.defaultView);c=e.left,u=e.top}else c=a.scrollLeft,u=a.scrollTop;const d=`${c},${u}`;o.get(l)!==d&&(o.set(l,d),e({id:l,x:c,y:u}))},l=[Pd("scroll",uh($d(uh(e=>a(e)),r.scroll||100)),t)];return"onscrollend"in t&&l.push(Pd("scrollend",uh(a),t)),()=>l.forEach(e=>e())}function gh(e,t){for(let i=dh.length-1;i>=0;i--){const s=dh[i];if(!s)continue;let n=s.bufferBelongsToIframe(e);!n&&t&&t.has(s.bufferDoc())&&(n=!0),n&&(s.reset(),dh.splice(i,1))}}var fh=["INPUT","TEXTAREA","SELECT"],vh=new WeakMap;function mh(e){return function e(t,i){if(wh("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||wh("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||wh("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||wh("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const s=Array.from(t.parentRule.cssRules).indexOf(t);return i.unshift(s),e(t.parentRule,i)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);i.unshift(e)}return i}(e,[])}function yh(e,t,i){let s,n;return e?(e.ownerNode?s=t.getId(e.ownerNode):n=i.getId(e),{styleId:n,id:s}):{}}function bh({mirror:e,stylesheetManager:t},i){var s,n;let r=null;r=e.getId("#document"===i.nodeName?i:ru.host(i));const o="#document"===i.nodeName?null===(s=i.defaultView)||void 0===s?void 0:s.Document:null===(n=i.ownerDocument)||void 0===n||null===(n=n.defaultView)||void 0===n?void 0:n.ShadowRoot,a=(null==o?void 0:o.prototype)?Object.getOwnPropertyDescriptor(null==o?void 0:o.prototype,"adoptedStyleSheets"):void 0;return null!==r&&-1!==r&&o&&a?(Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var e;return null===(e=a.get)||void 0===e?void 0:e.call(this)},set(e){let i;try{var s;i=null===(s=a.set)||void 0===s?void 0:s.call(this,e)}catch(e){if(e&&"object"==typeof e&&"NotAllowedError"===e.name)return;throw e}if(null!==r&&-1!==r)try{t.adoptStyleSheets(e,r)}catch(e){}return i}}),uh(()=>{Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})):()=>{}}function Sh(e,t={}){const i=e.doc.defaultView;if(!i)return()=>{};let s,n;!function(e,t){const{mutationCb:i,mousemoveCb:s,mouseInteractionCb:n,scrollCb:r,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p,customElementCb:_}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),i(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),s(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),n(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),r(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),_(...e)}}(e,t);const r=[],o=uh(()=>{try{if(n)try{n.destroy(),n.reset()}finally{const e=dh.indexOf(n);-1!==e&&dh.splice(e,1)}e.shadowDomManager.resetForDoc(e.doc),null==s||s.disconnect()}finally{Ad(r)}});try{if(e.recordDOM){const t=ph(e,e.doc);s=t.observer,n=t.buffer}if(r.push(function({mousemoveCb:e,sampling:t,doc:i,mirror:s}){if(!1===t.mousemove)return()=>{};const n="number"==typeof t.mousemove?t.mousemove:50,r="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let o,a=[];const l=$d(uh(t=>{const i=Date.now()-o;e(a.map(e=>(e.timeOffset-=i,e)),t),a=[],o=null}),r),c=uh($d(uh(e=>{const t=hh(e),{clientX:i,clientY:n}=Gd(e)?e.changedTouches[0]:e;o||(o=Bd()),a.push({x:i,y:n,id:s.getId(t),timeOffset:Bd()-o}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?Hc.Drag:e instanceof MouseEvent?Hc.MouseMove:Hc.TouchMove)}),n,{trailing:!1})),u=[Pd("mousemove",c,i),Pd("touchmove",c,i),Pd("drag",c,i)];return uh(()=>{u.forEach(e=>e())})}(e)),r.push(function({mouseInteractionCb:e,doc:t,mirror:i,blockClass:s,blockSelector:n,sampling:r}){if(!1===r.mouseInteraction)return()=>{};const o=!0===r.mouseInteraction||void 0===r.mouseInteraction?{}:r.mouseInteraction,a=[];let l=null;return Object.keys(Uc).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==o[e]).forEach(r=>{let o=Zu(r);const c=(t=>r=>{const o=hh(r);if(zd(o,s,n,!0))return;let a=null,c=t;if("pointerType"in r){switch(r.pointerType){case"mouse":a=Wc.Mouse;break;case"touch":a=Wc.Touch;break;case"pen":a=Wc.Pen}a===Wc.Touch&&(Uc[t]===Uc.MouseDown?c="TouchStart":Uc[t]===Uc.MouseUp&&(c="TouchEnd"))}else Gd(r)&&(a=Wc.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Wc.Touch||c.startsWith("Mouse")&&a===Wc.Mouse)&&(a=null)):Uc[t]===Uc.Click&&(a=l,l=null);const u=Gd(r)?r.changedTouches[0]:r;if(!u)return;const d=i.getId(o),{clientX:h,clientY:p}=u;uh(e)(ct({type:Uc[c],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(r);if(window.PointerEvent)switch(Uc[r]){case Uc.MouseDown:case Uc.MouseUp:o=o.replace("mouse","pointer");break;case Uc.TouchStart:case Uc.TouchEnd:return}a.push(Pd(o,c,t))}),uh(()=>{a.forEach(e=>e())})}(e)),r.push(_h(e)),r.push(function({viewportResizeCb:e},{win:t}){let i=-1,s=-1;return Pd("resize",uh($d(uh(()=>{const t=Hd(),n=Ud();i===t&&s===n||(e({width:Number(n),height:Number(t)}),i=t,s=n)}),200)),t)}(e,{win:i})),r.push(function({inputCb:e,doc:t,mirror:i,blockClass:s,blockSelector:n,ignoreClass:r,ignoreSelector:o,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:u}){function d(e){let i=hh(e);const c=e.isTrusted,d=t.defaultView;if(i&&d&&!(i instanceof d.HTMLElement))return;const p=i&&i.tagName;if(i&&"OPTION"===p&&(i=ru.parentElement(i)),!i||!p||0>fh.indexOf(p)||zd(i,s,n,!0))return;if(i.classList.contains(r)||o&&i.matches(o))return;let _=i.value,g=!1;const f=ed(i)||"";"radio"===f||"checkbox"===f?g=i.checked:(a[p.toLowerCase()]||a[f])&&(_=Ku({element:i,maskInputOptions:a,tagName:p,type:f,value:_,maskInputFn:l})),h(i,u?{text:_,isChecked:g,userTriggered:c}:{text:_,isChecked:g});const v=i.name;"radio"===f&&v&&g&&t.querySelectorAll(`input[type="radio"][name="${v}"]`).forEach(e=>{if(e!==i){const t=e.value;h(e,u?{text:t,isChecked:!g,userTriggered:!1}:{text:t,isChecked:!g})}})}function h(t,s){const n=vh.get(t);if(!n||n.text!==s.text||n.isChecked!==s.isChecked){vh.set(t,s);const n=i.getId(t);uh(e)(ct(ct({},s),{},{id:n}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>Pd(e,uh(d),t)),_=t.defaultView;if(!_)return()=>{p.forEach(e=>e())};const g=_.Object.getOwnPropertyDescriptor(_.HTMLInputElement.prototype,"value");return g&&g.set&&p.push(...[[_.HTMLInputElement.prototype,"value"],[_.HTMLInputElement.prototype,"checked"],[_.HTMLSelectElement.prototype,"value"],[_.HTMLTextAreaElement.prototype,"value"],[_.HTMLSelectElement.prototype,"selectedIndex"],[_.HTMLOptionElement.prototype,"selected"]].map(e=>Nd(e[0],e[1],{set(){uh(d)({target:this,isTrusted:!1})}},!1,_))),uh(()=>{Ad(p)})}(e)),r.push(function({mediaInteractionCb:e,blockClass:t,blockSelector:i,mirror:s,sampling:n,doc:r}){const o=uh(r=>$d(uh(n=>{const o=hh(n);if(!o||zd(o,t,i,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:u,loop:d}=o;e({type:r,id:s.getId(o),currentTime:a,volume:l,muted:c,playbackRate:u,loop:d})}),n.media||500)),a=[Pd("play",o(jc.Play),r),Pd("pause",o(jc.Pause),r),Pd("seeked",o(jc.Seeked),r),Pd("volumechange",o(jc.VolumeChange),r),Pd("ratechange",o(jc.RateChange),r)];return uh(()=>{a.forEach(e=>e())})}(e)),e.recordDOM){const t=function(e){const t=new Map,i=new Set;let s=!0;const n=e=>{if(s)try{e()}catch(e){}},r=e=>{var i;const s=t.get(e);if(s){for(;null===(i=s[0])||void 0===i?void 0:i.ready;){const e=s.shift();(null==e?void 0:e.emit)&&n(e.emit)}0===s.length&&t.delete(e)}};return{queueMutation(e,i){if(!e)return void n(i);const s=t.get(e);s?(s.push({emit:i,ready:!0}),r(e)):n(i)},queuePendingMutation(o,a,l){if(!s)return()=>{};let c=t.get(o);c||(c=[],t.set(o,c));const u={emit:a,ready:!1};c.push(u);let d,h=!1,p=!1;const _=()=>{h||p||(h=!0,void 0!==d&&i.delete(d),u.ready=!0,u.emit=void 0,r(o))};try{d=e.setTimeout(_,5e3),h||p?e.clearTimeout(d):i.add(d)}catch(e){_()}return t=>{!p&&s&&(p=!0,void 0!==d&&(e.clearTimeout(d),i.delete(d)),h?t&&n(l):(u.ready=!0,t||(u.emit=void 0),r(o)))}},reset(){s=!1,i.forEach(t=>e.clearTimeout(t)),i.clear(),t.clear()}}}(i);r.push(t.reset),r.push(function({styleSheetRuleCb:e,mirror:t,stylesheetManager:i},{win:s,mutationQueue:n}){if(!s.CSSStyleSheet||!s.CSSStyleSheet.prototype)return()=>{};const r=s.CSSStyleSheet.prototype.insertRule;s.CSSStyleSheet.prototype.insertRule=new Proxy(r,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=yh(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&n.queueMutation(r,()=>e({id:c,styleId:u,adds:[{rule:a,index:l}]})),l},"host")}),s.CSSStyleSheet.prototype.addRule=function(e,t,i=this.cssRules.length){return s.CSSStyleSheet.prototype.insertRule.apply(this,[`${e} { ${t} }`,i])};const o=s.CSSStyleSheet.prototype.deleteRule;let a,l;s.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=yh(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&n.queueMutation(r,()=>e({id:c,styleId:u,removes:[{index:a}]})),l},"host")}),s.CSSStyleSheet.prototype.removeRule=function(e){return s.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},s.CSSStyleSheet.prototype.replace&&(a=s.CSSStyleSheet.prototype.replace,s.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);try{const s=null==l?void 0:l.then;if(r.ownerNode||!l||"function"!=typeof s)return l;i.onCssomSheetMutation(r);const{id:o,styleId:c}=yh(r,t,i.styleMirror);if(!(o&&-1!==o||c&&-1!==c))return l;const u=n.queuePendingMutation(r,()=>e({id:o,styleId:c,replace:a}),()=>{const t=qu(r);null!==t&&e({id:o,styleId:c,replace:t})});try{s.call(l,()=>u(!0),()=>u(!1))}catch(e){u(!1)}}catch(e){}return l},"host")})),s.CSSStyleSheet.prototype.replaceSync&&(l=s.CSSStyleSheet.prototype.replaceSync,s.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=yh(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&n.queueMutation(r,()=>e({id:c,styleId:u,replaceSync:a})),l},"host")}));const c={};kh("CSSGroupingRule")?c.CSSGroupingRule=s.CSSGroupingRule:(kh("CSSMediaRule")&&(c.CSSMediaRule=s.CSSMediaRule),kh("CSSConditionRule")&&(c.CSSConditionRule=s.CSSConditionRule),kh("CSSSupportsRule")&&(c.CSSSupportsRule=s.CSSSupportsRule));const u={};return Object.entries(c).forEach(([s,r])=>{u[s]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=new Proxy(u[s].insertRule,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=yh(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...mh(r),l];n.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,adds:[{rule:a,index:t}]}))}return l},"host")}),r.prototype.deleteRule=new Proxy(u[s].deleteRule,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=yh(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...mh(r),a];n.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,removes:[{index:t}]}))}return l},"host")})}),uh(()=>{s.CSSStyleSheet.prototype.insertRule=r,s.CSSStyleSheet.prototype.deleteRule=o,a&&(s.CSSStyleSheet.prototype.replace=a),l&&(s.CSSStyleSheet.prototype.replaceSync=l),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule})})}(e,{win:i,mutationQueue:t})),r.push(bh(e,e.doc)),r.push(function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:i,stylesheetManager:s},{win:n,mutationQueue:r}){const o=n.CSSStyleDeclaration.prototype.setProperty;n.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:uh((n,o,a)=>{var l;const[c,u,d]=a,h=n.apply(o,a);if(i.has(c))return h;const p=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;s.onCssomSheetMutation(p);const{id:_,styleId:g}=yh(p,t,s.styleMirror);if(_&&-1!==_||g&&-1!==g){const t=mh(o.parentRule);r.queueMutation(p,()=>e({id:_,styleId:g,set:{property:c,value:u,priority:d},index:t}))}return h},"host")});const a=n.CSSStyleDeclaration.prototype.removeProperty;return n.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:uh((n,o,a)=>{var l;const[c]=a,u=n.apply(o,a);if(i.has(c))return u;const d=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;s.onCssomSheetMutation(d);const{id:h,styleId:p}=yh(d,t,s.styleMirror);if(h&&-1!==h||p&&-1!==p){const t=mh(o.parentRule);r.queueMutation(d,()=>e({id:h,styleId:p,remove:{property:c},index:t}))}return u},"host")}),uh(()=>{n.CSSStyleDeclaration.prototype.setProperty=o,n.CSSStyleDeclaration.prototype.removeProperty=a})}(e,{win:i,mutationQueue:t})),e.collectFonts&&r.push(function({fontCb:e,doc:t}){const i=t.defaultView;if(!i)return()=>{};const s=[],n=new WeakMap,r=i.FontFace;i.FontFace=function(e,t,i){const s=new r(e,t,i);return n.set(s,{family:e,buffer:"string"!=typeof t,descriptors:i,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),s};const o=nu(t.fonts,"add",function(t){return function(i){return setTimeout(uh(()=>{const t=n.get(i);t&&(e(t),n.delete(i))}),0),t.apply(this,[i])}});return s.push(()=>{i.FontFace=r}),s.push(o),uh(()=>{s.forEach(e=>e())})}(e))}r.push(function(e){const{doc:t,mirror:i,blockClass:s,blockSelector:n,selectionCb:r}=e;let o=!0;const a=uh(()=>{const e=t.getSelection();if(!e||o&&(null==e?void 0:e.isCollapsed))return;o=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;l>t;t++){const{startContainer:r,startOffset:o,endContainer:l,endOffset:c}=e.getRangeAt(t);zd(r,s,n,!0)||zd(l,s,n,!0)||a.push({start:i.getId(r),startOffset:o,end:i.getId(l),endOffset:c})}r({ranges:a})});return a(),Pd("selectionchange",a)}(e)),r.push(function({doc:e,customElementCb:t}){const i=e.defaultView;return i&&i.customElements?nu(i.customElements,"define",function(e){return function(i,s,n){try{t({define:{name:i}})}catch(e){console.warn(`Custom element callback failed for ${i}`)}return e.apply(this,[i,s,n])}}):()=>{}}(e));for(const t of e.plugins)r.push(t.observer(t.callback,i,t.options))}catch(e){try{o()}catch(e){}throw e}return o}function wh(e){return void 0!==window[e]}function kh(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}var Ch=class{constructor(e){Lu(this,"generateIdFn",void 0),Lu(this,"iframeRemoteIdToLocalIdMap",new WeakMap),Lu(this,"iframeLocalIdToRemoteIdMap",new WeakMap),this.generateIdFn=e}getId(e,t,i,s){if(0>t)return t;const n=i||this.getRemoteIdToLocalIdMap(e),r=s||this.getLocalIdToRemoteIdMap(e);let o=n.get(t);return void 0===o&&(o=this.generateIdFn(),n.set(t,o),r.set(o,t)),o}getIds(e,t){const i=this.getRemoteIdToLocalIdMap(e),s=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getId(e,t,i,s))}getRemoteId(e,t,i){var s;return"number"!=typeof t||0>t?t:null!==(s=(i||this.getLocalIdToRemoteIdMap(e)).get(t))&&void 0!==s?s:-1}getRemoteIds(e,t){const i=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getRemoteId(e,t,i))}reset(e){if(!e)return this.iframeRemoteIdToLocalIdMap=new WeakMap,void(this.iframeLocalIdToRemoteIdMap=new WeakMap);this.iframeRemoteIdToLocalIdMap.delete(e),this.iframeLocalIdToRemoteIdMap.delete(e)}getRemoteIdToLocalIdMap(e){let t=this.iframeRemoteIdToLocalIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToLocalIdMap.set(e,t)),t}getLocalIdToRemoteIdMap(e){let t=this.iframeLocalIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeLocalIdToRemoteIdMap.set(e,t)),t}},Eh=class{constructor(e){Lu(this,"iframes",new WeakMap),Lu(this,"crossOriginIframeMap",new WeakMap),Lu(this,"crossOriginIframeMirror",new Ch(dd)),Lu(this,"crossOriginIframeStyleMirror",void 0),Lu(this,"crossOriginIframeRootIdMap",new WeakMap),Lu(this,"mirror",void 0),Lu(this,"mutationCb",void 0),Lu(this,"wrappedEmit",void 0),Lu(this,"loadListener",void 0),Lu(this,"pageHideListener",void 0),Lu(this,"stylesheetManager",void 0),Lu(this,"recordCrossOriginIframes",void 0),Lu(this,"messageHandler",void 0),Lu(this,"nestedIframeListeners",new Map),Lu(this,"attachedWindows",new WeakMap),Lu(this,"attachedDocuments",new WeakMap),Lu(this,"attachedIframes",new Map),Lu(this,"loadListenerDisposers",new WeakMap),Lu(this,"iframeElementsById",new Map),Lu(this,"pageHideHandlers",new WeakMap),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ch(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.messageHandler=this.handleMessage.bind(this),this.recordCrossOriginIframes&&window.addEventListener("message",this.messageHandler)}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}registerLoadListenerDisposer(e,t){let i=this.loadListenerDisposers.get(e);i||(i=new Set,this.loadListenerDisposers.set(e,i)),i.add(t);const s=this.mirror.getId(e);-1!==s&&this.iframeElementsById.set(s,e)}getIframeElementById(e){var t,i,s;return null!==(t=null!==(i=null===(s=this.attachedIframes.get(e))||void 0===s?void 0:s.element)&&void 0!==i?i:this.iframeElementsById.get(e))&&void 0!==t?t:null}forgetIframeId(e){this.attachedIframes.delete(e),this.iframeElementsById.delete(e)}disposeLoadListeners(e){const t=this.loadListenerDisposers.get(e);t&&(t.forEach(e=>Ld(e)),this.loadListenerDisposers.delete(e))}removePageHideListener(e){const t=this.pageHideHandlers.get(e);t&&(t.forEach(({win:e,handler:t})=>{Fd(e,"pagehide",t)}),this.pageHideHandlers.delete(e))}addLoadListener(e){this.loadListener=e}addPageHideListener(e){this.pageHideListener=e}removeLoadListener(){this.loadListener=void 0}trackIframeContent(e,t){const i=this.mirror.getId(e);return this.attachedIframes.set(i,{element:e,content:t}),i}attachIframe(e,t){var i;const s=this.trackIframeContent(e,t);if(e.contentDocument){let t=this.attachedDocuments.get(e);t||(t=new Set,this.attachedDocuments.set(e,t)),t.add(e.contentDocument)}this.mutationCb({adds:[{parentId:s,nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0});const n=e.contentWindow;if(this.recordCrossOriginIframes&&n&&!this.nestedIframeListeners.has(n)){const t=this.handleMessage.bind(this);Ld(()=>{n.addEventListener("message",t),this.nestedIframeListeners.set(n,t);let i=this.attachedWindows.get(e);i||(i=new Set,this.attachedWindows.set(e,i)),i.add(n)})}Ld(()=>{const t=e.contentWindow;if(!t)return;let i=this.pageHideHandlers.get(e);if(i)for(const e of i)if(e.win===t)return;const s=()=>{var t;null===(t=this.pageHideListener)||void 0===t||t.call(this,e),e.contentDocument&&this.mirror.removeNodeFromMap(e.contentDocument)};t.addEventListener("pagehide",s),i||(i=new Set,this.pageHideHandlers.set(e,i)),i.add({win:t,handler:s})}),null===(i=this.loadListener)||void 0===i||i.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const i=this.crossOriginIframeMap.get(e.source);if(!i)return;const s=this.transformCrossOriginEvent(i,t.data.event);s&&this.wrappedEmit(s,t.data.isCheckout)}transformCrossOriginEvent(e,t){switch(t.type){case qc.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const i=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,i),this.patchRootIdOnNode(t.data.node,i),this.trackIframeContent(e,t.data.node),{timestamp:t.timestamp,type:qc.IncrementalSnapshot,data:{source:Hc.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case qc.Meta:case qc.Load:case qc.DomContentLoaded:return!1;case qc.Plugin:return t;case qc.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case qc.IncrementalSnapshot:switch(t.data.source){case Hc.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const i=this.crossOriginIframeRootIdMap.get(e);i&&this.patchRootIdOnNode(t.node,i)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Hc.Drag:case Hc.TouchMove:case Hc.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Hc.ViewportResize:return!1;case Hc.MediaInteraction:case Hc.MouseInteraction:case Hc.Scroll:case Hc.CanvasMutation:case Hc.Input:return this.replaceIds(t.data,e,["id"]),t;case Hc.StyleSheetRule:case Hc.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Hc.Font:return t;case Hc.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case Hc.AdoptedStyleSheet:var i;return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(i=t.data.styles)||void 0===i||i.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,i,s){for(const n of s)(Array.isArray(t[n])||"number"==typeof t[n])&&(t[n]=Array.isArray(t[n])?e.getIds(i,t[n]):e.getId(i,t[n]));return t}replaceIds(e,t,i){return this.replace(this.crossOriginIframeMirror,e,t,i)}replaceStyleIds(e,t,i){return this.replace(this.crossOriginIframeStyleMirror,e,t,i)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===Vc.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}removeIframeById(e){const t=this.attachedIframes.get(e),i=(null==t?void 0:t.element)||this.iframeElementsById.get(e)||this.mirror.getNode(e);if(this.iframeElementsById.delete(e),i){const e=i.contentWindow,t=this.attachedWindows.get(i);t&&(t.forEach(e=>{const t=this.nestedIframeListeners.get(e);t&&(Fd(e,"message",t),this.nestedIframeListeners.delete(e)),this.crossOriginIframeMap.delete(e)}),this.attachedWindows.delete(i)),e&&this.nestedIframeListeners.has(e)&&(Fd(e,"message",this.nestedIframeListeners.get(e)),this.nestedIframeListeners.delete(e)),e&&this.crossOriginIframeMap.delete(e),this.iframes.delete(i),this.disposeLoadListeners(i),this.removePageHideListener(i);const s=this.attachedDocuments.get(i);s&&(s.forEach(e=>{Ld(()=>this.mirror.removeNodeFromMap(e))}),Ld(()=>gh(i,s)),this.attachedDocuments.delete(i))}t&&this.attachedIframes.delete(e)}cleanupDetachedIframes(){if(0===this.attachedIframes.size)return;const e=[];this.attachedIframes.forEach((t,i)=>{this.mirror.has(i)||e.push(i)}),e.forEach(e=>this.removeIframeById(e))}reattachIframes(){this.attachedIframes.forEach(({content:e},t)=>{this.mirror.has(t)?this.mutationCb({adds:[{parentId:t,nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}):this.attachedIframes.delete(t)})}destroy(){this.recordCrossOriginIframes&&Fd(window,"message",this.messageHandler),this.nestedIframeListeners.forEach((e,t)=>{Fd(t,"message",e)}),this.nestedIframeListeners.clear();const e=new Set;this.iframeElementsById.forEach(t=>e.add(t)),this.attachedIframes.forEach(({element:t})=>e.add(t)),e.forEach(e=>{this.disposeLoadListeners(e),this.removePageHideListener(e)}),this.crossOriginIframeMirror.reset(),this.crossOriginIframeStyleMirror.reset(),this.attachedIframes.clear(),this.crossOriginIframeMap=new WeakMap,this.iframes=new WeakMap,this.crossOriginIframeRootIdMap=new WeakMap,this.loadListenerDisposers=new WeakMap,this.pageHideHandlers=new WeakMap,this.attachedDocuments=new WeakMap,this.attachedWindows=new WeakMap,this.iframeElementsById=new Map}},xh=class{constructor(e){Lu(this,"shadowDoms",new WeakSet),Lu(this,"mutationCb",void 0),Lu(this,"scrollCb",void 0),Lu(this,"bypassOptions",void 0),Lu(this,"mirror",void 0),Lu(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){var i,s;if(!Du(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=null!==(i=null===(s=ru.host(e))||void 0===s?void 0:s.ownerDocument)&&void 0!==i?i:t,{observer:r,buffer:o}=ph(ct(ct({},this.bypassOptions),{},{doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push({doc:n,handler(){r.disconnect(),o.destroy(),o.releaseCanvasManager();const e=dh.indexOf(o);-1!==e&&dh.splice(e,1)}}),this.restoreHandlers.push({doc:n,handler:_h(ct(ct({},this.bypassOptions),{},{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))}),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(ru.host(e))),this.restoreHandlers.push({doc:n,handler:bh({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)})},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const i=this;this.restoreHandlers.push({doc:t,handler:nu(e.prototype,"attachShadow",function(e){return function(s){const n=e.call(this,s),r=ru.shadowRoot(this);return r&&Xd(this)&&i.addShadowRoot(r,t),n}})})}reset(){this.restoreHandlers.forEach(({handler:e})=>{try{e()}catch(e){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}resetForDoc(e){const t=[];for(const i of this.restoreHandlers)if(i.doc===e)try{i.handler()}catch(e){}else t.push(i);this.restoreHandlers=t}},Ih="skip-frame";function Th(e){if("object"!=typeof e||null===e)return!1;const{x:t,y:i,width:s,height:n}=e;return Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(s)&&Number.isFinite(n)&&s>=0&&n>=0}for(var Mh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rh="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ph=0;64>Ph;Ph++)Rh[Mh.charCodeAt(Ph)]=Ph;var Fh=function(e){var t,i=new Uint8Array(e),s=i.length,n="";for(t=0;s>t;t+=3)n+=Mh[i[t]>>2],n+=Mh[(3&i[t])<<4|i[t+1]>>4],n+=Mh[(15&i[t+1])<<2|i[t+2]>>6],n+=Mh[63&i[t+2]];return s%3==2?n=n.substring(0,n.length-1)+"=":s%3==1&&(n=n.substring(0,n.length-2)+"=="),n},Lh=new Map,Ah=(e,t,i)=>{if(!e||!$h(e,t)&&"object"!=typeof e)return;const s=function(e,t){let i=Lh.get(e);return i||(i=new Map,Lh.set(e,i)),i.has(t)||i.set(t,[]),i.get(t)}(i,e.constructor.name);let n=s.indexOf(e);return-1===n&&(n=s.length,s.push(e)),n};function Oh(e,t,i,s){if(e instanceof Array)return e.map(e=>Oh(e,t,i,s));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:Fh(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Oh(e.buffer,t,i,s),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:i}=e;return{rr_type:t,src:i}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL(s.type,s.quality)}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Oh(e.data,t,i,s),e.width,e.height]}:$h(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ah(e,t,i)}:e}var Dh=(e,t,i,s)=>e.map(e=>Oh(e,t,i,s)),$h=(e,t)=>{const i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(i.find(i=>e instanceof t[i]))},Nh=["webgl","webgl2"];function Bh(e){return"nodeType"in e}function qh(e,t,i,s){const n=[];try{if(s){const s=function(e,t,i){const s=e.GPUCanvasContext;if((null==s?void 0:s.prototype)&&"function"==typeof s.prototype.configure)return nu(s.prototype,"configure",function(s){return function(n){const r=function(e){const{canvas:t}=e;return t&&"object"==typeof t?t:null}(this);if(!r||Bh(r)&&zd(r,t,i,!0))return s.call(this,n);Bh(r)&&!("__context"in r)&&(r.__context="webgpu");const o=function(e){const t=e.GPUTextureUsage;return t?t.COPY_SRC|t.RENDER_ATTACHMENT:null}(e);return s.call(this,null!==o&&n?ct(ct({},n),{},{usage:"number"==typeof n.usage?n.usage|o:o}):n)}})}(e,t,i);s&&n.push(s)}const r=nu(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(n,...r){const o=function(e){return"experimental-webgl"===e?"webgl":e}(n);if(!zd(this,t,i,!0)&&("__context"in this||(this.__context=o),s&&Nh.includes(o)))if(r[0]&&"object"==typeof r[0]){const e=r[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else r.splice(0,1,{preserveDrawingBuffer:!0});return e.apply(this,[n,...r])}});n.push(r)}catch(e){console.warn("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(e=>e())}}function Hh(e,t,i,s,n,r,o){const a=[],l=Object.getOwnPropertyNames(e);for(const c of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const l=nu(e,c,function(e){return function(...a){const l=e.apply(this,a);if(Ah(l,r,this),this.canvas&&"tagName"in this.canvas&&!zd(this.canvas,s,n,!0)){const e=Dh(a,r,this,o);i(this.canvas,{type:t,property:c,args:e})}return l}});a.push(l)}catch(r){const o=Nd(e,c,{set(e){this.canvas&&"tagName"in this.canvas&&!zd(this.canvas,s,n,!0)&&i(this.canvas,{type:t,property:c,args:[e],setter:!0})}});a.push(o)}return a}var Uh='(function() {\n\t//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/base64-arraybuffer/1.0.2/f63fa6b5c318cf1c9f6bdd1d4292ad2f15f76f2ec78475025a2d44070e896fe9/node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js\n\tvar chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n\tvar lookup = typeof Uint8Array === "undefined" ? [] : /* @__PURE__ */ new Uint8Array(256);\n\tfor (var i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i;\n\tvar encode = function(arraybuffer) {\n\t\tvar bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";\n\t\tfor (i = 0; i < len; i += 3) {\n\t\t\tbase64 += chars[bytes[i] >> 2];\n\t\t\tbase64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n\t\t\tbase64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n\t\t\tbase64 += chars[bytes[i + 2] & 63];\n\t\t}\n\t\tif (len % 3 === 2) base64 = base64.substring(0, base64.length - 1) + "=";\n\t\telse if (len % 3 === 1) base64 = base64.substring(0, base64.length - 2) + "==";\n\t\treturn base64;\n\t};\n\t//#endregion\n\t//#region ../rrweb/src/record/workers/image-bitmap-data-url-worker.ts\n\tconst lastFingerprintMap = /* @__PURE__ */ new Map();\n\tconst transparentFingerprintMap = /* @__PURE__ */ new Map();\n\tconst lastSentAtMap = /* @__PURE__ */ new Map();\n\tconst PROVIDER_KEYFRAME_INTERVAL_MS = 3e4;\n\tfunction hashPixels(data) {\n\t\tconst view = new Uint32Array(data.buffer, data.byteOffset, data.byteLength >>> 2);\n\t\tlet primaryHash = 2166136261;\n\t\tlet secondaryHash = 2654435769;\n\t\tfor (let i = 0; i < view.length; i++) {\n\t\t\tprimaryHash ^= view[i];\n\t\t\tprimaryHash = Math.imul(primaryHash, 16777619);\n\t\t\tsecondaryHash ^= view[i];\n\t\t\tsecondaryHash = Math.imul(secondaryHash, 2246822507);\n\t\t}\n\t\treturn `${(primaryHash >>> 0).toString(16)}:${(secondaryHash >>> 0).toString(16)}`;\n\t}\n\tfunction frameFingerprint(width, height, data) {\n\t\treturn `${width}x${height}:${hashPixels(data)}`;\n\t}\n\tfunction transparentFingerprint(width, height) {\n\t\tconst pixelCount = width * height;\n\t\tlet hash = transparentFingerprintMap.get(pixelCount);\n\t\tif (hash === void 0) {\n\t\t\thash = hashPixels(new Uint8ClampedArray(pixelCount * 4));\n\t\t\ttransparentFingerprintMap.set(pixelCount, hash);\n\t\t}\n\t\treturn `${width}x${height}:${hash}`;\n\t}\n\tconst worker = self;\n\tlet reusableCanvas = null;\n\tlet reusableCtx = null;\n\tworker.onmessage = async function(e) {\n\t\tif ("resetFrameDedup" in e.data) {\n\t\t\tlastFingerprintMap.clear();\n\t\t\treturn;\n\t\t}\n\t\tif ("OffscreenCanvas" in globalThis) {\n\t\t\tconst { id, bitmap, width, height, displayWidth, displayHeight, dataURLOptions, maskRegions } = e.data;\n\t\t\ttry {\n\t\t\t\tif (!reusableCanvas || reusableCanvas.width !== width || reusableCanvas.height !== height) {\n\t\t\t\t\treusableCanvas = new OffscreenCanvas(width, height);\n\t\t\t\t\treusableCtx = reusableCanvas.getContext("2d", { willReadFrequently: true });\n\t\t\t\t}\n\t\t\t\tconst ctx = reusableCtx;\n\t\t\t\tctx.clearRect(0, 0, width, height);\n\t\t\t\tctx.drawImage(bitmap, 0, 0);\n\t\t\t\tbitmap.close();\n\t\t\t\tif (maskRegions) {\n\t\t\t\t\tctx.fillStyle = "black";\n\t\t\t\t\tfor (const region of maskRegions) ctx.fillRect(region.x, region.y, region.width, region.height);\n\t\t\t\t}\n\t\t\t\tconst fingerprint = frameFingerprint(width, height, ctx.getImageData(0, 0, width, height).data);\n\t\t\t\tif (fingerprint === (lastFingerprintMap.get(id) ?? transparentFingerprint(width, height))) {\n\t\t\t\t\tconst lastSentAt = lastSentAtMap.get(id);\n\t\t\t\t\tif (!(maskRegions !== void 0 && lastSentAt !== void 0 && Date.now() - lastSentAt >= PROVIDER_KEYFRAME_INTERVAL_MS)) return worker.postMessage({ id });\n\t\t\t\t}\n\t\t\t\tconst blob = await reusableCanvas.convertToBlob(dataURLOptions);\n\t\t\t\tconst arrayBuffer = await blob.arrayBuffer();\n\t\t\t\tworker.postMessage({\n\t\t\t\t\tid,\n\t\t\t\t\ttype: blob.type,\n\t\t\t\t\tbase64: encode(arrayBuffer),\n\t\t\t\t\tdisplayWidth,\n\t\t\t\t\tdisplayHeight\n\t\t\t\t});\n\t\t\t\tlastFingerprintMap.set(id, fingerprint);\n\t\t\t\tlastSentAtMap.set(id, Date.now());\n\t\t\t} catch {\n\t\t\t\tworker.postMessage({ id });\n\t\t\t}\n\t\t} else {\n\t\t\te.data.bitmap.close();\n\t\t\treturn worker.postMessage({ id: e.data.id });\n\t\t}\n\t};\n\t//#endregion\n})();\n',Wh="undefined"!=typeof self&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Uh],{type:"text/javascript;charset=utf-8"});function zh(e){let t;try{if(t=Wh&&(self.URL||self.webkitURL).createObjectURL(Wh),!t)throw"";const i=new Worker(t,{name:null==e?void 0:e.name});return i.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),i}catch(t){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Uh),{name:null==e?void 0:e.name})}}var jh,Vh,Gh,Qh=class{onFullSnapshot(){var e;null===(e=this.resetFrameDedup)||void 0===e||e.call(this)}acquire(){this.refCount+=1}reset(){this.refCount>0&&(this.refCount-=1),this.refCount>0||this.teardown()}teardown(){this.torndown||(this.torndown=!0,this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers(),null!==this.rafIdTimestamp&&(cancelAnimationFrame(this.rafIdTimestamp),this.rafIdTimestamp=null),null!==this.rafIdFlush&&(cancelAnimationFrame(this.rafIdFlush),this.rafIdFlush=null))}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){Lu(this,"pendingCanvasMutations",new Map),Lu(this,"rafStamps",{latestId:0,invokeId:null}),Lu(this,"mirror",void 0),Lu(this,"mutationCb",void 0),Lu(this,"resetObservers",void 0),Lu(this,"frozen",!1),Lu(this,"locked",!1),Lu(this,"rafIdTimestamp",null),Lu(this,"rafIdFlush",null),Lu(this,"refCount",0),Lu(this,"torndown",!1),Lu(this,"resetFrameDedup",null),Lu(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:i,blockClass:s,blockSelector:n,recordCanvas:r,dataURLOptions:o,resolutionScale:a,canvasMasking:l}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&"all"===t&&this.initCanvasMutationObserver(i,s,n,o),r&&"number"==typeof t&&this.initCanvasFPSObserver(t,i,s,n,{dataURLOptions:o,resolutionScale:a,canvasMasking:l})}initCanvasFPSObserver(e,t,i,s,n){var r=this;if(!("OffscreenCanvas"in t))return;const o="number"==typeof n.resolutionScale&&Number.isFinite(n.resolutionScale)?Math.min(1,Math.max(.1,n.resolutionScale)):1,a=qh(t,i,s,!0),l=new Map;let c;try{c=new zh}catch(e){return}let u=!1;c.onerror=()=>{var e;u=!0,cancelAnimationFrame(h),null===(e=c.terminate)||void 0===e||e.call(c),this.resetFrameDedup=null},this.resetFrameDedup=()=>{c.postMessage({resetFrameDedup:!0})},c.onmessage=e=>{const{id:t}=e.data;if(l.set(t,!1),!("base64"in e.data))return;const{base64:i,type:s,displayWidth:n,displayHeight:r}=e.data;this.mutationCb({id:t,type:zc["2D"],commands:[{property:"clearRect",args:[0,0,n,r]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:i}],type:s}]},0,0,n,r]}],displayWidth:n,displayHeight:r})};const d=1e3/e;let h,p=0;const _=e=>{var a;u||(p&&d>e-p||(p=e,(()=>{const e=[],n=t=>{try{t.querySelectorAll("canvas").forEach(t=>{zd(t,i,s,!0)||e.push(t)}),t.querySelectorAll("*").forEach(e=>{e.shadowRoot&&n(e.shadowRoot)})}catch(e){}};return n(t.document),e})().forEach((a=rt(function*(e){const t=r.mirror.getId(e);if(!l.get(t)&&0!==e.width&&0!==e.height){l.set(t,!0);try{if(["webgl","webgl2"].includes(e.__context)){var i,s;const n=e.getContext(e.__context);if(null==n||null===(i=n.isContextLost)||void 0===i?void 0:i.call(n))return void l.set(t,!1);!1===(null==n||null===(s=n.getContextAttributes())||void 0===s?void 0:s.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=e.clientWidth||e.width,a=e.clientHeight||e.height,u=Math.max(1,Math.round(r*o)),d=Math.max(1,Math.round(a*o)),h=function(e,t,i,s,n,r){if(!e||"function"!=typeof e.regionsFn)return;let o;try{o=e.regionsFn(t)}catch(e){return Ih}if(void 0===o)return;if(!Array.isArray(o)||!o.every(Th))return Ih;const a=i/n,l=s/r;return o.filter(e=>e.width>0&&e.height>0).map(e=>{const t=Math.floor(e.x*a),i=Math.floor(e.y*l);return{x:t,y:i,width:Math.ceil((e.x+e.width)*a)-t,height:Math.ceil((e.y+e.height)*l)-i}})}(n.canvasMasking,e,u,d,r,a);if("skip-frame"===h)return void l.set(t,!1);const p=yield createImageBitmap(e,1>o?{resizeWidth:u,resizeHeight:d,resizeQuality:"medium"}:{resizeWidth:u,resizeHeight:d});c.postMessage({id:t,bitmap:p,width:u,height:d,displayWidth:r,displayHeight:a,dataURLOptions:n.dataURLOptions,maskRegions:h},[p])}catch(e){l.set(t,!1)}}}),function(e){return a.apply(this,arguments)}))),h=requestAnimationFrame(_))};h=requestAnimationFrame(_),this.resetObservers=()=>{var e;a(),cancelAnimationFrame(h),null===(e=c.terminate)||void 0===e||e.call(c),this.resetFrameDedup=null}}initCanvasMutationObserver(e,t,i,s){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const n=qh(e,t,i,!1),r=function(e,t,i,s,n){const r=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const a of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[a])continue;const o=nu(t.CanvasRenderingContext2D.prototype,a,function(r){return function(...o){return zd(this.canvas,i,s,!0)||setTimeout(()=>{const i=Dh(o,t,this,n);e(this.canvas,{type:zc["2D"],property:a,args:i})},0),r.apply(this,o)}});r.push(o)}catch(n){const o=Nd(t.CanvasRenderingContext2D.prototype,a,{set(t){zd(this.canvas,i,s,!0)||e(this.canvas,{type:zc["2D"],property:a,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,s),o=function(e,t,i,s,n){const r=[];return void 0!==t.WebGLRenderingContext&&r.push(...Hh(t.WebGLRenderingContext.prototype,zc.WebGL,e,i,s,t,n)),void 0!==t.WebGL2RenderingContext&&r.push(...Hh(t.WebGL2RenderingContext.prototype,zc.WebGL2,e,i,s,t,n)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,s);this.resetObservers=()=>{n(),r(),o()}}startPendingCanvasMutationFlusher(){this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,this.rafIdTimestamp=requestAnimationFrame(e)};this.rafIdTimestamp=requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const i=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,i)}),this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const i=this.pendingCanvasMutations.get(e);if(!i||-1===t)return;const s=i.map(e=>mn(e,Bc)),{type:n}=i[0];this.mutationCb({id:t,type:n,commands:s}),this.pendingCanvasMutations.delete(e)}},Kh=class{constructor(e){var t;Lu(this,"trackedLinkElements",new WeakSet),Lu(this,"pendingDeferredSheets",new Set),Lu(this,"mutationCb",void 0),Lu(this,"adoptedStyleSheetCb",void 0),Lu(this,"maskAllElementAttributes",void 0),Lu(this,"maskAttributeFn",void 0),Lu(this,"styleMirror",new Jd),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb,this.maskAllElementAttributes=null!==(t=e.maskAllElementAttributes)&&void 0!==t&&t,this.maskAttributeFn=e.maskAttributeFn}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}beginDeferredLinkInlining(e,t){if(-1===t||!e.isConnected)return null;let i=null,s=null;try{s=e.sheet,s&&(i=Gu(s))}catch(e){}if(!i||!s)return Ru(),null;const n=i;let r=!1;const o={sheet:s,invalidate(){r=!0}};this.pendingDeferredSheets.add(o);let a=!1;return{advance:i=>{if(a)return!0;const l=ou(),c=cu();let u=!0;try{if(r)return a=!0,Ru(),!0;if(!n.advance(i))return u=!1,!1;a=!0;const o=n.text();if(!e.isConnected)return!0;let l=null;try{l=e.sheet}catch(e){}return l!==s?(Ru(),!0):o?(this.emitCssTextMutation(e,t,o),!0):(Ru(),!0)}finally{u&&this.pendingDeferredSheets.delete(o),uu(d=ou()-l,null!=(h=c)?h:au)||(Su.totalMs+=d,d>Su.slowestSliceMs&&(Su.slowestSliceMs=d))}var d,h},remainingRules:()=>n.remainingRules(),discard:()=>{this.pendingDeferredSheets.delete(o)}}}onCssomSheetMutation(e){if(e&&0!==this.pendingDeferredSheets.size)for(const t of this.pendingDeferredSheets)t.sheet===e&&(this.pendingDeferredSheets.delete(t),t.invalidate())}inlineDeferredLinkElement(e,t){var i;null===(i=this.beginDeferredLinkInlining(e,t))||void 0===i||i.advance(1/0)}emitCssTextMutation(e,t,i){this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t,attributes:{_cssText:Yu({element:e,name:"_cssText",value:i,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn})}}]})}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const i={id:t,styleIds:[]},s=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{const i=this.styleMirror.add(t);e=i;const n=ou();try{xu(()=>{try{const e=t.rules||t.cssRules;e&&Eu(e)}catch(e){}s.push({styleId:i,rules:Array.from(t.rules||CSSRule,(e,i)=>({rule:Hu(e,t.href),index:i}))})})}finally{Iu(ou()-n)}}i.styleIds.push(e)}s.length>0&&(i.styles=s),this.adoptedStyleSheetCb(i)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet,this.pendingDeferredSheets.clear(),kd.forEach(e=>e.abort()),kd.clear()}trackStylesheetInLinkElement(e){}},Zh=class{constructor(){Lu(this,"nodeMap",new WeakMap),Lu(this,"active",!1)}inOtherBuffer(e,t){const i=this.nodeMap.get(e);return i&&Array.from(i).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},Jh=!1;try{if(2!==Array.from([1],e=>2*e)[0]){var Yh;const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null===(Yh=e.contentWindow)||void 0===Yh?void 0:Yh.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}var Xh=new Qu,ep=new Set([Hc.Mutation,Hc.MediaInteraction,Hc.StyleSheetRule,Hc.CanvasMutation,Hc.Font,Hc.Log,Hc.StyleDeclaration,Hc.AdoptedStyleSheet]);function tp(e){const t=window;if("function"==typeof t.requestIdleCallback){const i=t.requestIdleCallback(e,{timeout:2e3});return{cancel(){var e;return null===(e=t.cancelIdleCallback)||void 0===e?void 0:e.call(t,i)}}}const i=setTimeout(e,250);return{cancel:()=>clearTimeout(i)}}function ip(e={}){let t;const{emit:i,checkoutEveryNms:s,checkoutEveryNth:n,blockClass:r="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:l=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:d=!0,inlineStylesheetBudgetRules:h,maskAllInputs:p,maskInputOptions:_,slimDOMOptions:g,maskInputFn:f,maskTextFn:v,maskAllElementAttributes:m=!1,maskAttributeFn:y,hooks:b,packFn:S,sampling:w={},dataURLOptions:k={},canvasResolutionScale:C,canvasMasking:E,mousemoveWait:x,recordDOM:I=!0,recordCanvas:T=!1,recordCrossOriginIframes:M=!1,recordAfter:R=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:P=!1,collectFonts:F=!1,inlineImages:L=!1,plugins:A,keepIframeSrcFn:O=()=>!1,ignoreCSSAttributes:D=new Set([]),attributeFilter:N,errorHandler:B}=e;lh(B);const q=ct({type:"image/webp",quality:.4,maxBase64ImageLength:1048576},k),H=!M||window.parent===window;let U=!1;if(!H)try{window.parent.document&&(U=!1)}catch(e){U=!0}if(H&&!i)throw new Error("emit function is required");if(!H&&!U)return()=>{};void 0!==x&&void 0===w.mousemove&&(w.mousemove=x),Xh.reset();const W=!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==_?_:{password:!0},z=Md(void 0!==g&&g);let j;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=[].forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=[].forEach)}();let V=0;const G=new Map;let Q,K;const Z=e=>{for(const t of A||[])t.eventProcessor&&(e=t.eventProcessor(e));return S&&!U&&(e=S(e)),e};jh=(e,t)=>{var r;const o=e;if(o.timestamp=Bd(),!(null===(r=dh[0])||void 0===r?void 0:r.isFrozen())||o.type===qc.FullSnapshot||o.type===qc.IncrementalSnapshot&&ep.has(o.data.source)||dh.forEach(e=>e.unfreeze()),H)null==i||i(Z(o),t);else if(U){const e={type:"rrweb",event:Z(o),origin:window.location.origin,isCheckout:t};window.parent.postMessage(e,"*")}if(o.type===qc.FullSnapshot)j=o,V=0;else if(o.type===qc.IncrementalSnapshot){if(o.data.source===Hc.Mutation&&o.data.isAttachIframe)return;V++,(n&&V>=n||s&&o.timestamp-j.timestamp>s)&&Vh(!0)}};const J=e=>{if(e.removes&&e.removes.length>0){const t=e.adds.length>0?new Set(e.adds.map(e=>e.node.id)):null,i=new Set;if(e.adds.length>0)for(const t of e.adds){const e=Xh.getNode(t.node.id);e&&"IFRAME"===e.nodeName&&i.add(e)}e.removes.forEach(({id:e})=>{if(t&&t.has(e))return;const s=te.getIframeElementById(e);s&&i.has(s)?te.forgetIframeId(e):(null==Q||Q(e),te.removeIframeById(e))}),null==K||K(),te.cleanupDetachedIframes()}jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Mutation},e)})},Y=e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Scroll},e)}),X=e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.CanvasMutation},e)}),ee=new Kh({mutationCb:J,adoptedStyleSheetCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.AdoptedStyleSheet},e)}),maskAllElementAttributes:m,maskAttributeFn:y}),te=new Eh({mirror:Xh,mutationCb:J,stylesheetManager:ee,recordCrossOriginIframes:M,wrappedEmit:jh});for(const e of A||[])e.getMirror&&e.getMirror({nodeMirror:Xh,crossOriginIframeMirror:te.crossOriginIframeMirror,crossOriginIframeStyleMirror:te.crossOriginIframeStyleMirror});const ie=new Zh,se=null==E?void 0:E.configured;Gh=new Qh({recordCanvas:T,mutationCb:X,win:window,blockClass:r,blockSelector:o,mirror:Xh,sampling:w.canvas,dataURLOptions:q,resolutionScale:C,canvasMasking:E});const ne=new xh({mutationCb:J,scrollCb:Y,bypassOptions:{blockClass:r,blockSelector:o,maskTextClass:c,maskTextSelector:u,inlineStylesheet:d,maskInputOptions:W,dataURLOptions:q,maskTextFn:v,maskInputFn:f,maskAllElementAttributes:m,maskAttributeFn:y,recordCanvas:T,canvasMaskingConfigured:se,inlineImages:L,sampling:w,slimDOMOptions:z,iframeManager:te,stylesheetManager:ee,canvasManager:Gh,keepIframeSrcFn:O,processedNodeManager:ie,attributeFilter:N},mirror:Xh});Vh=(e=!1)=>{if(I){wu(h);try{jh({type:qc.Meta,data:{href:window.location.href,width:Ud(),height:Hd()}},e),null==t||t.cancel(),t=void 0,ee.reset(),ne.init(),dh.forEach(e=>e.lock());let i=null,s=[];try{i=function(e,t){const{mirror:i=new Qu,blockClass:s="rr-block",blockSelector:n=null,maskTextClass:r="rr-mask",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,canvasMaskingConfigured:u,maskAllInputs:d=!1,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:_=!1,maskAttributeFn:g,slimDOM:f=!1,dataURLOptions:v,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E=()=>!1,maxDepth:x,inlineStylesheetBudgetRules:I}=t||{},T=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,M=Md(f);wu(I);try{return Td(e,{doc:e,mirror:i,blockClass:s,blockSelector:n,maskTextClass:r,maskTextSelector:o,skipChild:!1,inlineStylesheet:a,maskInputOptions:T,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:_,maskAttributeFn:g,slimDOMOptions:M,dataURLOptions:v,inlineImages:l,recordCanvas:c,canvasMaskingConfigured:u,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E,newlyAddedElement:!1,maxDepth:x})}finally{ku()}}(document,{mirror:Xh,blockClass:r,blockSelector:o,maskTextClass:c,maskTextSelector:u,inlineStylesheet:d,maskAllInputs:W,inlineStylesheetBudgetRules:h,maskTextFn:v,maskInputFn:f,maskAllElementAttributes:m,maskAttributeFn:y,slimDOM:z,dataURLOptions:q,recordCanvas:T,canvasMaskingConfigured:se,inlineImages:L,onSerialize(e){Qd(e,Xh)&&te.addIframe(e),Kd(e,Xh)&&ee.trackLinkElement(e),Zd(e)&&ne.addShadowRoot(ru.shadowRoot(e),document)},onIframeLoad(e,t){te.attachIframe(e,t),ne.observeAttachShadow(e)},onIframeListenerRegistered(e,t){te.registerLoadListenerDisposer(e,t)},onStylesheetLoad(e,t){ee.attachLinkElement(e,t)},keepIframeSrcFn:O})}finally{s=Mu()}if(!i)return console.warn("Failed to snapshot the document");if(jh({type:qc.FullSnapshot,data:{node:i,initialOffset:qd(window)}},e),dh.forEach(e=>e.unlock()),Gh.onFullSnapshot(),s.length){const e=function(e,t,i){let s=!1,n=null,r=0,o=null;const a=()=>null!==o||e.length>r,l=()=>{const i=e[r];e[r]=null,r+=1,i&&Ld(()=>{o=t.beginDeferredLinkInlining(i,Xh.getId(i))})},c=()=>{if(!o)return;const e=o;let t=!0;Ld(()=>{t=e.advance(200)}),t&&(o=null)},u=()=>{o||l(),c()},d=e=>{if(n=null,s)return;let t=0;do{try{u()}catch(e){null==o||o.discard(),o=null,Pu(1)}t+=1}while(!s&&a()&&(e?!e.didTimeout&&e.timeRemaining()>5:10>t));s||(a()?n=tp(d):i())};return n=tp(d),{cancel(){s=!0,null==o||o.discard(),o=null,null==n||n.cancel(),n=null},flush(){if(s)return;s=!0,null==n||n.cancel(),n=null;let t=0,u=0;for(;a()&&50>t;){o||l();const e=o;if(e)if(Math.floor(e.remainingRules()/200)+1>50-t)e.discard(),o=null,u+=1;else{try{c()}catch(e){null==o||o.discard(),o=null,u+=1}t+=1}}if(a()||u>0){let t=u+(null!==o?1:0);for(let i=r;e.length>i;i++)null!==e[i]&&(t+=1);Pu(t),null==o||o.discard(),o=null}i()}}}(s,ee,()=>{t===e&&(t=void 0)});t=e}M&&te.reattachIframes(),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ee.adoptStyleSheets(document.adoptedStyleSheets,Xh.getId(document))}finally{ku()}}};try{const e=[];e.push(Pd("pagehide",()=>{try{null==t||t.flush()}catch(e){}t=void 0},window));for(const t of["visibilitychange","freeze","resume"])e.push(Pd(t,lu,document));Q=t=>{const i=G.get(t);i&&(i.forEach(t=>{Ld(t);const i=e.indexOf(t);-1!==i&&e.splice(i,1)}),G.delete(t))},K=()=>{for(const[e]of G){const t=Xh.getNode(e);if(t)try{t.contentDocument&&t.contentDocument.defaultView||null==Q||Q(e)}catch(t){null==Q||Q(e)}else null==Q||Q(e)}};const i=e=>{var t;return uh(Sh)({mutationCb:J,mousemoveCb:(e,t)=>jh({type:qc.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.MouseInteraction},e)}),scrollCb:Y,viewportResizeCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.ViewportResize},e)}),inputCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Input},e)}),mediaInteractionCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.MediaInteraction},e)}),styleSheetRuleCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.StyleSheetRule},e)}),styleDeclarationCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.StyleDeclaration},e)}),canvasMutationCb:X,fontCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Font},e)}),selectionCb(e){jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Selection},e)})},customElementCb(e){jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.CustomElement},e)})},blockClass:r,ignoreClass:a,ignoreSelector:l,maskTextClass:c,maskTextSelector:u,maskInputOptions:W,inlineStylesheet:d,sampling:w,recordDOM:I,recordCanvas:T,canvasMaskingConfigured:se,inlineImages:L,userTriggeredOnInput:P,collectFonts:F,doc:e,maskInputFn:f,maskTextFn:v,maskAllElementAttributes:m,maskAttributeFn:y,keepIframeSrcFn:O,blockSelector:o,slimDOMOptions:z,dataURLOptions:q,mirror:Xh,iframeManager:te,stylesheetManager:ee,shadowDomManager:ne,processedNodeManager:ie,canvasManager:Gh,ignoreCSSAttributes:D,attributeFilter:N,plugins:(null==A||null===(t=A.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>jh({type:qc.Plugin,data:{plugin:e.name,payload:t}})})))||[]},b)};te.addLoadListener(t=>{try{const s=Xh.getId(t),n=i(t.contentDocument);if("function"==typeof n&&(e.push(n),-1!==s)){let e=G.get(s);e||(e=new Set,G.set(s,e)),e.add(n)}}catch(e){console.warn(e)}}),te.addPageHideListener(e=>{const t=Xh.getId(e);null==Q||Q(t),gh(e)});let s=-1;const n=e=>jh({type:qc.Custom,data:{tag:"rrweb/fullscreen",payload:e}}),h=()=>{var e,t,i,r;const o=document,a=null!==(e=null!==(t=null!==(i=null!==(r=o.fullscreenElement)&&void 0!==r?r:o.webkitFullscreenElement)&&void 0!==i?i:o.mozFullScreenElement)&&void 0!==t?t:o.msFullscreenElement)&&void 0!==e?e:null,l=a?Xh.getId(a):-1;l!==s&&(-1!==s&&n({id:s,enter:!1}),s=l,-1!==l&&n({id:l,enter:!0}))},p=()=>{Vh();const t=i(document);"function"==typeof t&&e.push(t),e.push(Pd("fullscreenchange",h)),e.push(Pd("webkitfullscreenchange",h)),e.push(Pd("mozfullscreenchange",h)),e.push(Pd("MSFullscreenChange",h)),Jh=!0};return["interactive","complete"].includes(document.readyState)?p():(e.push(Pd("DOMContentLoaded",()=>{jh({type:qc.DomContentLoaded,data:{}}),"DOMContentLoaded"===R&&p()})),e.push(Pd("load",()=>{jh({type:qc.Load,data:{}}),"load"===R&&p()},window))),()=>{try{null==t||t.flush()}catch(e){}t=void 0,Ad(e),ie.destroy(),te.removeLoadListener(),te.destroy(),G.clear(),ne.reset(),Xh.reset(),Jh=!1,ch()}}catch(e){console.warn(e)}}ip.addCustomEvent=(e,t)=>{if(!Jh)throw new Error("please add custom event after start recording");jh({type:qc.Custom,data:{tag:e,payload:t}})},ip.freezePage=()=>{dh.forEach(e=>e.freeze())},ip.takeFullSnapshot=e=>{if(!Jh)throw new Error("please take full snapshot after start recording");Vh(e)},ip.mirror=Xh,"Mobile".toLowerCase(),"Tablet".toLowerCase(),new RegExp("Xbox","i"),new RegExp("Nintendo","i"),new RegExp("PlayStation","i"),new RegExp("Windows","i"),Date,Date,"0".repeat(32),"0".repeat(16);var sp=Object.create(null);function np(e){return np="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},np(e)}function rp(e,t,i){return(t=function(e){var t=function(e){if("object"!=np(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=np(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==np(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}sp.Node=Object.create(null),sp.ShadowRoot=Object.create(null),sp.MutationObserver=Object.create(null),sp.Element=Object.create(null);var op=class{constructor(e){rp(this,"fileName",void 0),rp(this,"functionName",void 0),rp(this,"lineNumber",void 0),rp(this,"columnNumber",void 0),this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}toString(){const e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${e}:${t})`:`${this.fileName}:${e}:${t}`}},ap=/(^|@)\S+:\d+/,lp=/^\s*at .*(\S+:\d+|\(native\))/m,cp=/^(eval@)?(\[native code])?$/,up={parse(e){return e?void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(lp)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):[]:[]},extractLocation(e){if(-1===e.indexOf(":"))return[e];const t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error(`Cannot parse given url: ${e}`);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE(e){return e.stack.split("\n").filter(function(e){return!!e.match(lp)},this).map(function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let t=e.replace(/^\s+/,"").replace(/\(eval code/g,"(");const i=t.match(/ (\((.+):(\d+):(\d+)\)$)/);t=i?t.replace(i[0],""):t;const s=t.split(/\s+/).slice(1),n=this.extractLocation(i?i[1]:s.pop());return new op({functionName:s.join(" ")||void 0,fileName:["eval","<anonymous>"].indexOf(n[0])>-1?void 0:n[0],lineNumber:n[1],columnNumber:n[2]})},this)},parseFFOrSafari(e){return e.stack.split("\n").filter(function(e){return!e.match(cp)},this).map(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new op({functionName:e});{const t=/((.*".+"[^@]*)?[^@]*)(?:@)/,i=e.match(t),s=i&&i[1]?i[1]:void 0,n=this.extractLocation(e.replace(t,""));return new op({functionName:s,fileName:n[0],lineNumber:n[1],columnNumber:n[2]})}},this)},parseOpera(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9(e){const t=/Line (\d+).*script (?:in )?(\S+)/i,i=e.message.split("\n"),s=[];for(let e=2,n=i.length;n>e;e+=2){const n=t.exec(i[e]);n&&s.push(new op({fileName:n[2],lineNumber:parseFloat(n[1])}))}return s},parseOpera10(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=e.stacktrace.split("\n"),s=[];for(let e=0,n=i.length;n>e;e+=2){const n=t.exec(i[e]);n&&s.push(new op({functionName:n[3]||void 0,fileName:n[2],lineNumber:parseFloat(n[1])}))}return s},parseOpera11(e){return e.stack.split("\n").filter(function(e){return!!e.match(ap)&&!e.match(/^Error created at/)},this).map(function(e){const t=e.split("@"),i=this.extractLocation(t.pop());return new op({functionName:(t.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)}};function dp(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let i=e.localName;if(!i)break;i=i.toLowerCase();const s=e.parentElement,n=[];if(s.children&&s.children.length>0)for(let e=0;s.children.length>e;e++){const t=s.children[e];t.localName&&t.localName.toLowerCase&&t.localName.toLowerCase()===i&&n.push(t)}n.length>1&&(i+=`:eq(${n.indexOf(e)})`),t=i+(t?">"+t:""),e=s}return t}function hp(e){return Array.isArray(e)}function pp(e){return"object"==typeof e&&null!==e&&!hp(e)}function _p(e,t){if(0===t)return!0;const i=Object.keys(e);for(const s of i)if(pp(e[s])&&_p(e[s],t-1))return!0;return!1}function gp(e,t){const i={numOfKeysLimit:50,depthOfLimit:4};Object.assign(i,t);const s=[],n=[];return JSON.stringify(e,function(e,t){if(s.length>0){const i=s.indexOf(this);~i?s.splice(i+1):s.push(this),~i?n.splice(i,1/0,e):n.push(e),~s.indexOf(t)&&(t=s[0]===t?"[Circular ~]":"[Circular ~."+n.slice(0,s.indexOf(t)).join(".")+"]")}else s.push(t);if(null===t)return t;if(void 0===t)return"undefined";if(pp(r=t)&&Object.keys(r).length>i.numOfKeysLimit||"function"==typeof r||pp(r)&&_p(r,i.depthOfLimit))return function(e){let t=e.toString();return i.stringLengthLimit&&t.length>i.stringLengthLimit&&(t=`${t.slice(0,i.stringLengthLimit)}...`),t}(t);var r;if("bigint"==typeof t)return t.toString()+"n";if(t instanceof Event){const e={};for(const i in t){const s=t[i];e[i]=hp(s)?dp(s.length?s[0]:null):s}return e}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t})}var fp={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function vp(e,t,i){const s=i?Object.assign({},fp,i):fp,n=s.logger;if(!n)return()=>{};let r;r="string"==typeof n?t[n]:n;let o=0,a=!1,l=!0;const c=[];if(s.level.includes("error")){const i=t=>{const i=t.message;e({level:"error",trace:up.parse(t.error).map(e=>e.toString()),payload:[gp(i,s.stringifyOptions)]})};t.addEventListener("error",i),c.push(()=>{t.removeEventListener("error",i)});const n=t=>{let i,n;t.reason instanceof Error?(i=t.reason,n=[gp(`Uncaught (in promise) ${i.name}: ${i.message}`,s.stringifyOptions)]):(i=new Error,n=[gp("Uncaught (in promise)",s.stringifyOptions),gp(t.reason,s.stringifyOptions)]),e({level:"error",trace:up.parse(i).map(e=>e.toString()),payload:n})};t.addEventListener("unhandledrejection",n),c.push(()=>{t.removeEventListener("unhandledrejection",n)})}for(const e of s.level)c.push(u(r,e));return()=>{l=!1,c.forEach(e=>e())};function u(t,i){return t[i]?function(n,r){try{if(!(r in n))return()=>{};const c=n[r],u={next:c},d=(n=>(...r)=>{if(n.apply(t,r),l&&!("assert"===i&&r[0]||a)){a=!0;try{const t=up.parse(new Error).map(e=>e.toString()).splice(1),n=("assert"===i?r.slice(1):r).map(e=>gp(e,s.stringifyOptions));o++,s.lengthThreshold>o?e({level:i,trace:t,payload:n}):o===s.lengthThreshold&&e({level:"warn",trace:[],payload:[gp("The number of log records reached the threshold.")]})}catch(e){n.apply(t,["rrweb logger error:",e,...r])}finally{a=!1}}})(function(...e){return u.next.apply(this,e)});return"function"==typeof d&&(d.prototype=d.prototype||{},Object.defineProperties(d,{__rrweb_original__:{enumerable:!1,value:c},__rrweb_layer__:{enumerable:!1,value:u}})),n[r]=d,()=>{if(n[r]===d)return void(n[r]=u.next);const e=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let t=n[r],i=e(t);for(;i;){if(i.next===d)return void(i.next=u.next);t=i.next,i=e(t)}}}catch(e){return()=>{}}}(t,i):()=>{}}}var mp=e=>({name:"rrweb/console@1",observer:vp,options:e});const yp=()=>{},bp=e=>{var t;if(Ct(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Sp(e,t,i){try{if(!(t in e))return yp;const s={next:e[t]},n=i(function(...e){return s.next.apply(this,e)});return Ct(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=s.next);let i=e[t],r=bp(i);for(;r;){if(r.next===n)return void(r.next=s.next);i=r.next,r=bp(i)}}}catch(e){return yp}}function wp(e,t){var i;const s=function(e){try{return"string"==typeof e?new URL(e).hostname:"url"in e?new URL(e.url).hostname:e.hostname}catch(e){return null}}(e),n={hostname:s,isHostDenied:!1};if(!(null===(i=t.payloadHostDenyList)||void 0===i?void 0:i.length)||!(null==s?void 0:s.trim().length))return n;for(const e of t.payloadHostDenyList)if(s.endsWith(e))return{hostname:s,isHostDenied:!0};return n}const kp=Gn("[Recorder]"),Cp=e=>"navigation"===e.entryType,Ep=e=>"resource"===e.entryType;function xp(e,t){return!!t&&(At(t)||t[e])}function Ip(e){if("undefined"==typeof Request)return!1;if(e instanceof Request)return!0;try{return"[object Request]"==={}.toString.call(e)}catch(e){return!1}}const Tp=["image/","video/","audio/","font/","application/octet-stream","application/pdf","application/zip","application/wasm"];function Mp({type:e,recordBody:t,headers:i,url:s}){function n(e){const t=Object.keys(i).find(e=>"content-type"===e.toLowerCase()),s=t&&i[t];return e.some(e=>null==s?void 0:s.toLowerCase().includes(e))}if(!t)return!1;if(function e(t){try{return"string"==typeof t?t.startsWith("blob:"):t instanceof URL?"blob:"===t.protocol:!!Ip(t)&&e(t.url)}catch(e){return!1}}(s))return!1;if(n(Tp))return!1;if(At(t))return!0;if(kt(t))return n(t);const r=t[e];return At(r)?r:n(r)}function Rp(e,t,i,s,n){return Pp.apply(this,arguments)}function Pp(){return Pp=rt(function*(e,t,i,s,n,r=0){if(r>10)return kp.warn("Failed to get performance entry for request",{url:i,initiatorType:t}),null;const o=function(e,t){for(let i=e.length-1;i>=0;i-=1)if(t(e[i]))return e[i]}(e.performance.getEntriesByName(i),e=>Ep(e)&&e.initiatorType===t&&(It(s)||e.startTime>=s)&&(It(n)||n>=e.startTime));return o||(yield new Promise(e=>setTimeout(e,50*r)),Rp(e,t,i,s,n,r+1))}),Pp.apply(this,arguments)}function Fp({body:e,options:t,url:i}){if(Pt(e))return null;const{hostname:s,isHostDenied:n}=wp(i,t);if(n)return s+" is in deny list";if(Tt(e))return e;if((e=>"u">typeof Document&&e instanceof Document)(e))return e.textContent;if(Ot(e))return lr(e);if(Et(e))try{return JSON.stringify(e)}catch(e){return"[SessionReplay] Failed to stringify response object"}return"[SessionReplay] Cannot read body of type "+toString.call(e)}const Lp=e=>!Rt(e)&&("navigation"===e.entryType||"resource"===e.entryType);function Ap({entry:e,method:t,status:i,networkRequest:s,isInitial:n,start:r,end:o,url:a,initiatorType:l}){r=e?e.startTime:r,o=e?e.responseEnd:o;const c=Math.floor(Date.now()-performance.now()),u=Math.floor(c+(r||0)),d=[ct(ct({},e?e.toJSON():{name:a}),{},{startTime:It(r)?void 0:Math.round(r),endTime:It(o)?void 0:Math.round(o),timeOrigin:c,timestamp:u,method:t,initiatorType:l||(e?e.initiatorType:void 0),status:i,requestHeaders:s.requestHeaders,requestBody:s.requestBody,responseHeaders:s.responseHeaders,responseBody:s.responseBody,isInitial:n})];if(Lp(e))for(const t of e.serverTiming||[])d.push({timeOrigin:c,timestamp:u,startTime:Math.round(e.startTime),name:t.name,duration:t.duration,entryType:"serverTiming"});return d}const Op=["video/","audio/"];function Dp(e){return Et(e)&&Ct(e.getReader)&&Ct(e.tee)}const $p="[SessionReplay] Timeout while trying to read body",Np="[SessionReplay] Failed to read body";function Bp(e){return`${Np}: ${e}`}function qp(e){return`[SessionReplay] Body too large to record (> ${e} bytes)`}function Hp(e,t){if(!t.streamNetworkBody)return function(e){return new Promise(t=>{const i=setTimeout(()=>t($p),500);try{e.clone().text().then(e=>t(e),e=>t(Bp(e))).finally(()=>clearTimeout(i))}catch(e){clearTimeout(i),t(Np)}})}(e);const i=so(t);return function(e,t){try{var i,s;const n=null===(i=e.headers)||void 0===i||null===(s=i.get)||void 0===s?void 0:s.call(i,"content-length");if(!n)return!1;const r=parseInt(n,10);return Number.isFinite(r)&&r>t}catch(e){return!1}}(e,i)?Promise.resolve(qp(i)):function(e,t){return new Promise(i=>{let s,n=!1;function r(){try{null==s||s.cancel().catch(()=>{})}catch(e){}}function o(e){n||(n=!0,clearTimeout(a),r(),i(e))}const a=setTimeout(()=>o($p),500);let l;try{l=e.clone()}catch(e){return void o(Np)}const c=l.body;if(!Dp(c)||"undefined"==typeof TextDecoder){try{l.text().then(e=>o(e),e=>o(Bp(e)))}catch(e){o(Np)}return}try{s=c.getReader()}catch(e){return void o(Np)}const u=[];let d=0;!function e(){s.read().then(({done:i,value:s})=>{if(n)r();else if(i)o((new TextDecoder).decode(function(e,t){const i=new Uint8Array(t);let s=0;for(const t of e)i.set(t,s),s+=t.byteLength;return i}(u,d)));else{if(s){if(d+s.byteLength>t)return void o(qp(t));d+=s.byteLength,u.push(s)}e()}},e=>o(Bp(e)))}()})}(e,i)}function Up(){return Up=rt(function*({r:e,options:t,url:i}){const{hostname:s,isHostDenied:n}=wp(i,t);return n?Promise.resolve(s+" is in deny list"):Hp(e,t)}),Up.apply(this,arguments)}function Wp(){return Wp=rt(function*({r:e,options:t,url:i}){const s=function({r:e,options:t,url:i}){var s;if("chunked"===e.headers.get("Transfer-Encoding"))return"Chunked Transfer-Encoding is not supported";const n=null===(s=e.headers.get("Content-Type"))||void 0===s?void 0:s.toLowerCase(),r=Op.some(e=>null==n?void 0:n.startsWith(e));if(n&&r)return`Content-Type ${n} is not supported`;const{hostname:o,isHostDenied:a}=wp(i,t);return a?o+" is in deny list":null}({r:e,options:t,url:i});return Rt(s)?Hp(e,t):Promise.resolve(s)}),Wp.apply(this,arguments)}let zp=null;function jp(e,t,i){if(!("performance"in t))return()=>{};if(zp)return kp.warn("Network observer already initialised, doing nothing"),()=>{};const s=i?Object.assign({},no,i):no;let n=!0;const r=t=>{if(!n)return;const i=[];let r=!1;t.requests.forEach(e=>{const t="serverTiming"===e.entryType;if(t&&r)return;const n=s.maskRequestFn(e);t||(r=!n||(e=>!!e&&po.has(e))(n)),n&&i.push(n)}),i.length>0&&e(ct(ct({},t),{},{requests:i}))},o=function(e,t,i){i.recordInitialRequests&&e({requests:t.performance.getEntries().filter(e=>Cp(e)||Ep(e)&&i.initiatorTypes.includes(e.initiatorType)).flatMap(e=>Ap({entry:e,method:void 0,status:void 0,networkRequest:{},isInitial:!0})),isInitial:!0});const s=new t.PerformanceObserver(t=>{e({requests:t.getEntries().filter(e=>Cp(e)||Ep(e)&&i.initiatorTypes.includes(e.initiatorType)&&(e=>!i.recordBody&&!i.recordHeaders||"xmlhttprequest"!==e.initiatorType&&"fetch"!==e.initiatorType)(e)).flatMap(e=>Ap({entry:e,method:void 0,status:void 0,networkRequest:{}}))})}),n=PerformanceObserver.supportedEntryTypes.filter(e=>i.performanceEntryTypeToObserve.includes(e));return s.observe({entryTypes:n}),()=>{s.disconnect()}}(r,t,s);let a=()=>{},l=()=>{};return(s.recordHeaders||s.recordBody)&&(a=function(e,t,i){if(!i.initiatorTypes.includes("xmlhttprequest"))return()=>{};const s=xp("request",i.recordHeaders),n=xp("response",i.recordHeaders),r=Sp(t.XMLHttpRequest.prototype,"open",r=>function(o,a,l=!0,c,u){const d=this;try{const r=new Request(a),l={};let c,u;const h={},p=d.setRequestHeader.bind(d);d.setRequestHeader=(e,t)=>(h[e]=t,p(e,t)),s&&(l.requestHeaders=h);const _=d.send.bind(d);d.send=e=>(Mp({type:"request",headers:h,url:a,recordBody:i.recordBody})&&(l.requestBody=Fp({body:e,options:i,url:a})),c=t.performance.now(),_(e));const g=()=>{d.removeEventListener("readystatechange",f),d.removeEventListener("error",g),d.removeEventListener("abort",g),d.removeEventListener("timeout",g)},f=()=>{if(d.readyState!==d.DONE)return;g(),u=t.performance.now();const s={};d.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),i=t.shift(),n=t.join(": ");i&&(s[i]=n)}),n&&(l.responseHeaders=s),Mp({type:"response",headers:s,url:a,recordBody:i.recordBody})&&(l.responseBody=Fp({body:d.response,options:i,url:a})),Rp(t,"xmlhttprequest",r.url,c,u).then(t=>{e({requests:Ap({entry:t,method:o,status:null==d?void 0:d.status,networkRequest:l,start:c,end:u,url:a.toString(),initiatorType:"xmlhttprequest"})})}).catch(()=>{})};d.addEventListener("readystatechange",f),d.addEventListener("error",g),d.addEventListener("abort",g),d.addEventListener("timeout",g)}catch(e){kp.error("Failed to instrument XHR for network capture",e)}r.call(d,o,a.toString(),l,c,u)});return()=>{r()}}(r,t,s),l=function(e,t,i){if(!i.initiatorTypes.includes("fetch"))return()=>{};const s=xp("request",i.recordHeaders),n=xp("response",i.recordHeaders),r=Sp(t,"fetch",r=>function(){var o=rt(function*(o,a){let l,c;try{l=new Request(o,a)}catch(e){return kp.error("Failed to instrument fetch for network capture",e),r(o,a)}const u={};let d,h;try{try{const e={};l.headers.forEach((t,i)=>{e[i]=t}),s&&(u.requestHeaders=e),!Dp(null==a?void 0:a.body)&&Mp({type:"request",headers:e,url:o,recordBody:i.recordBody})&&(u.requestBody=yield function(e){return Up.apply(this,arguments)}({r:l,options:i,url:o}))}catch(e){kp.error("Failed to record fetch request for network capture",e)}d=t.performance.now(),c=Ip(o)?yield r(l):yield r(o,a),h=t.performance.now();try{const e={};c.headers.forEach((t,i)=>{e[i]=t}),n&&(u.responseHeaders=e),Mp({type:"response",headers:e,url:o,recordBody:i.recordBody})&&(u.responseBody=yield function(e){return Wp.apply(this,arguments)}({r:c,options:i,url:o}))}catch(e){kp.error("Failed to record fetch response for network capture",e)}return c}finally{Rp(t,"fetch",l.url,d,h).then(t=>{e({requests:Ap({entry:t,method:l.method,status:null==c?void 0:c.status,networkRequest:u,start:d,end:h,url:l.url,initiatorType:"fetch"})})}).catch(()=>{})}});return function(e,t){return o.apply(this,arguments)}}());return()=>{r()}}(r,t,s)),zp=()=>{n=!1,o(),a(),l(),zp=null},zp}const Vp=e=>({name:"rrweb/network@1",observer:jp,options:e});var Gp,Qp,Kp,Zp,Jp,Yp,Xp,e_,t_,i_,s_,n_,r_,o_,a_;h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.rrwebPlugins={getRecordConsolePlugin:mp,getRecordNetworkPlugin:Vp},h.__PosthogExtensions__.rrweb={record:ip,version:"v2",wasMaxDepthReached:()=>Id,resetMaxDepthState(){Id=!1,xd=!1},getLastSnapshotCost:()=>gu,getMutationCost:()=>ct({},bu),resetSnapshotCostState(){du=0,hu=0,pu=0,au=0,_u={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gu=null,fu=null,vu=[],mu=0,yu=0,bu={slowestBatchMs:0},Su={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0}}},h.rrweb={record:ip,version:"v2"},h.rrwebConsoleRecord={getRecordConsolePlugin:mp},h.getRecordNetworkPlugin=Vp,h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.initSessionRecording=(e,t)=>new Nc(e,t);var l_,c_,u_,d_,h_={},p_=[],__=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,g_=Array.isArray;function f_(e,t){for(var i in t)e[i]=t[i];return e}function v_(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function m_(e,t,i){var s,n,r,o={};for(r in t)"key"==r?s=t[r]:"ref"==r?n=t[r]:o[r]=t[r];if(arguments.length>2&&(o.children=arguments.length>3?Gp.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===o[r]&&(o[r]=e.defaultProps[r]);return y_(e,o,s,n,null)}function y_(e,t,i,s,n){var r={type:e,props:t,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==n?++Kp:n,__i:-1,__u:0};return null==n&&null!=Qp.vnode&&Qp.vnode(r),r}function b_(e){return e.children}function S_(e,t){this.props=e,this.context=t}function w_(e,t){if(null==t)return e.__?w_(e.__,e.__i+1):null;for(var i;e.__k.length>t;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?w_(e):null}function k_(e){if(e.__P&&e.__d){var t=e.__v,i=t.__e,s=[],n=[],r=f_({},t);r.__v=t.__v+1,Qp.vnode&&Qp.vnode(r),L_(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[i]:null,s,null==i?w_(t):i,!!(32&t.__u),n),r.__v=t.__v,r.__.__k[r.__i]=r,O_(s,r,n),t.__e=t.__=null,r.__e!=i&&C_(r)}}function C_(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),C_(e)}function E_(e){(!e.__d&&(e.__d=!0)&&Zp.push(e)&&!x_.__r++||Jp!=Qp.debounceRendering)&&((Jp=Qp.debounceRendering)||Yp)(x_)}function x_(){try{for(var e,t=1;Zp.length;)Zp.length>t&&Zp.sort(Xp),e=Zp.shift(),t=Zp.length,k_(e)}finally{Zp.length=x_.__r=0}}function I_(e,t,i,s,n,r,o,a,l,c,u){var d,h,p,_,g,f,v,m=s&&s.__k||p_,y=t.length;for(l=function(e,t,i,s,n){var r,o,a,l,c,u=i.length,d=u,h=0;for(e.__k=new Array(n),r=0;n>r;r++)null!=(o=t[r])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=e.__k[r]=y_(null,o,null,null,null):g_(o)?o=e.__k[r]=y_(b_,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=e.__k[r]=y_(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[r]=o,l=r+h,o.__=e,o.__b=e.__b+1,a=null,-1!=(c=o.__i=M_(o,i,l,d))&&(d--,(a=i[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(n>u?h--:u>n&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[r]=null;if(d)for(r=0;u>r;r++)null!=(a=i[r])&&!(2&a.__u)&&(a.__e==s&&(s=w_(a)),N_(a,a));return s}(i,t,m,l,y),d=0;y>d;d++)null!=(p=i.__k[d])&&(h=-1!=p.__i&&m[p.__i]||h_,p.__i=d,f=L_(e,p,h,n,r,o,a,l,c,u),_=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&$_(h.ref,null,p),u.push(p.ref,p.__c||_,p)),null==g&&null!=_&&(g=_),(v=!!(4&p.__u))||h.__k===p.__k?(l=T_(p,l,e,v),v&&h.__e&&(h.__e=null)):"function"==typeof p.type&&void 0!==f?l=f:_&&(l=_.nextSibling),p.__u&=-7);return i.__e=g,l}function T_(e,t,i,s){var n,r;if("function"==typeof e.type){for(n=e.__k,r=0;n&&n.length>r;r++)n[r]&&(n[r].__=e,t=T_(n[r],t,i,s));return t}e.__e!=t&&(s&&(t&&e.type&&!t.parentNode&&(t=w_(e)),i.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function M_(e,t,i,s){var n,r,o,a=e.key,l=e.type,c=t[i],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&l==c.type)return i;if(s>(u?1:0))for(n=i-1,r=i+1;n>=0||t.length>r;)if(null!=(c=t[o=0>n?r++:n--])&&!(2&c.__u)&&a==c.key&&l==c.type)return o;return-1}function R_(e,t,i){"-"==t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||__.test(t)?i:i+"px"}function P_(e,t,i,s,n){var r,o;e:if("style"==t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof s&&(e.style.cssText=s=""),s)for(t in s)i&&t in i||R_(e.style,t,"");if(i)for(t in i)s&&i[t]==s[t]||R_(e.style,t,i[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(s_,"$1")),o=t.toLowerCase(),t=o in e||"onFocusOut"==t||"onFocusIn"==t?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=i,i?s?i[i_]=s[i_]:(i[i_]=n_,e.addEventListener(t,r?o_:r_,r)):e.removeEventListener(t,r?o_:r_,r);else{if("http://www.w3.org/2000/svg"==n)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==i?"":i))}}function F_(e){return function(t){if(this.l){var i=this.l[t.type+e];if(null==t[t_])t[t_]=n_++;else if(i[i_]>t[t_])return;return i(Qp.event?Qp.event(t):t)}}}function L_(e,t,i,s,n,r,o,a,l,c){var u,d,h,p,_,g,f,v,m,y,$,b,S,w,k,C,E=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),r=[a=t.__e=i.__e]),(u=Qp.__b)&&u(t);e:if("function"==typeof E){d=o.length;try{if(m=t.props,y=E.prototype&&E.prototype.render,$=(u=E.contextType)&&s[u.__c],b=u?$?$.props.value:u.__:s,i.__c?v=(h=t.__c=i.__c).__=h.__E:(y?t.__c=h=new E(m,b):(t.__c=h=new S_(m,b),h.constructor=E,h.render=B_),$&&$.sub(h),h.state||(h.state={}),h.__n=s,p=h.__d=!0,h.__h=[],h._sb=[]),y&&null==h.__s&&(h.__s=h.state),y&&null!=E.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=f_({},h.__s)),f_(h.__s,E.getDerivedStateFromProps(m,h.__s))),_=h.props,g=h.state,h.__v=t,p)y&&null==E.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),y&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(y&&null==E.getDerivedStateFromProps&&m!==_&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,b),t.__v==i.__v||!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,b)){t.__v!=i.__v&&(h.props=m,h.state=h.__s,h.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(e){e&&(e.__=t)}),p_.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,b),y&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(_,g,f)})}if(h.context=b,h.props=m,h.__P=e,h.__e=!1,S=Qp.__r,w=0,y)h.state=h.__s,h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),p_.push.apply(h.__h,h._sb),h._sb=[];else do{h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&25>++w);h.state=h.__s,null!=h.getChildContext&&(s=f_(f_({},s),h.getChildContext())),y&&!p&&null!=h.getSnapshotBeforeUpdate&&(f=h.getSnapshotBeforeUpdate(_,g)),k=null!=u&&u.type===b_&&null==u.key?D_(u.props.children):u,a=I_(e,g_(k)?k:[k],t,i,s,n,r,o,a,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),v&&(h.__E=h.__=null)}catch(e){if(o.length=d,t.__v=null,l||null!=r)if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;null!=r&&(r[r.indexOf(a)]=null),t.__e=a}else{if(null!=r)for(C=r.length;C--;)v_(r[C]);A_(t)}else t.__e=i.__e,!t.__k&&i.__k&&(t.__k=i.__k),e.then||A_(t);Qp.__e(e,t,i)}}else null==r&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):a=t.__e=function(e,t,i,s,n,r,o,a,l){var c,u,d,h,p,_,g,f=i.props||h_,v=t.props,m=t.type;if("svg"==m?n="http://www.w3.org/2000/svg":"math"==m?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;r.length>c;c++)if((p=r[c])&&"setAttribute"in p==!!m&&(m?p.localName==m:3==p.nodeType)){e=p,r[c]=null;break}if(null==e){if(null==m)return document.createTextNode(v);e=document.createElementNS(n,m,v.is&&v),a&&(Qp.__m&&Qp.__m(t,r),a=!1),r=null}if(null==m)f===v||a&&e.data==v||(e.data=v);else{if(r="textarea"==m&&null!=v.defaultValue?null:r&&Gp.call(e.childNodes),!a&&null!=r)for(f={},c=0;e.attributes.length>c;c++)f[(p=e.attributes[c]).name]=p.value;for(c in f)p=f[c],"dangerouslySetInnerHTML"==c?d=p:"children"==c||c in v||"value"==c&&"defaultValue"in v||"checked"==c&&"defaultChecked"in v||P_(e,c,null,p,n);for(c in v)p=v[c],"children"==c?h=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?_=p:"checked"==c?g=p:a&&"function"!=typeof p||f[c]===p||P_(e,c,p,f[c],n);if(u)a||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),I_("template"==t.type?e.content:e,g_(h)?h:[h],t,i,s,"foreignObject"==m?"http://www.w3.org/1999/xhtml":n,r,o,r?r[0]:i.__k&&w_(i,0),a,l),null!=r)for(c=r.length;c--;)v_(r[c]);a&&"textarea"!=m||(c="value","progress"==m&&null==_?e.removeAttribute("value"):null!=_&&(_!==e[c]||"progress"==m&&!_||"option"==m&&_!=f[c])&&P_(e,c,_,f[c],n),c="checked",null!=g&&g!=e[c]&&P_(e,c,g,f[c],n))}return e}(i.__e,t,i,s,n,r,o,l,c);return(u=Qp.diffed)&&u(t),128&t.__u?void 0:a}function A_(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(A_))}function O_(e,t,i){for(var s=0;i.length>s;s++)$_(i[s],i[++s],i[++s]);Qp.__c&&Qp.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Qp.__e(e,t.__v)}})}function D_(e){return"object"!=typeof e||null==e||e.__b>0?e:g_(e)?e.map(D_):void 0!==e.constructor?null:f_({},e)}function $_(e,t,i){try{if("function"==typeof e){var s="function"==typeof e.__u;s&&e.__u(),s&&null==t||(e.__u=e(t))}else e.current=t}catch(e){Qp.__e(e,i)}}function N_(e,t,i){var s,n;if(Qp.unmount&&Qp.unmount(e),(s=e.ref)&&(s.current&&s.current!=e.__e||$_(s,null,t)),null!=(s=e.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(e){Qp.__e(e,t)}s.base=s.__P=s.__n=null}if(s=e.__k)for(n=0;s.length>n;n++)s[n]&&N_(s[n],t,i||"function"!=typeof e.type);i||v_(e.__e),e.__c=e.__=e.__e=void 0}function B_(e,t,i){return this.constructor(e,i)}function q_(e,t,i){var s,n,r,o;t==document&&(t=document.documentElement),Qp.__&&Qp.__(e,t),n=(s="function"==typeof i)?null:i&&i.__k||t.__k,r=[],o=[],L_(t,e=(!s&&i||t).__k=m_(b_,null,[e]),n||h_,h_,t.namespaceURI,!s&&i?[i]:n?null:t.firstChild?Gp.call(t.childNodes):null,r,!s&&i?i:n?n.__e:t.firstChild,s,o),O_(r,e,o),e.props.children=null}Gp=p_.slice,Qp={__e(e,t,i,s){for(var n,r,o;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e,s||{}),o=n.__d),o)return n.__E=n}catch(t){e=t}throw e}},Kp=0,S_.prototype.setState=function(e,t){var i=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=f_({},this.state);"function"==typeof e&&(e=e(f_({},i),this.props)),e&&f_(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),E_(this))},S_.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),E_(this))},S_.prototype.render=b_,Zp=[],Yp="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Xp=function(e,t){return e.__v.__b-t.__v.__b},x_.__r=0,e_=Math.random().toString(8),t_="__d"+e_,i_="__a"+e_,s_=/(PointerCapture)$|Capture$/i,n_=0,r_=F_(!1),o_=F_(!0),a_=0;var H_=0,U_=[],W_=Qp,z_=W_.__b,j_=W_.__r,V_=W_.diffed,G_=W_.__c,Q_=W_.unmount,K_=W_.__;function Z_(e,t){W_.__h&&W_.__h(c_,e,H_||t),H_=0;var i=c_.__H||(c_.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function J_(e){return H_=1,function(e,t){var i=Z_(l_++,2);if(i.t=e,!i.__c&&(i.__=[lg(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],s=i.t(t,e);t!==s&&(i.__N=[s,i.__[1]],i.__c.setState({}))}],i.__c=c_,!c_.__f)){var s=function(e,t,s){if(!i.__c.__H)return!0;var r=!1,o=i.__c.props!==e;if(i.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),n){var a=n.call(this,e,t,s);return r?a||o:a}return!r||o};c_.__f=!0;var n=c_.shouldComponentUpdate,r=c_.componentWillUpdate;c_.componentWillUpdate=function(e,t,i){if(this.__e){var o=n;n=void 0,s(e,t,i),n=o}r&&r.call(this,e,t,i)},c_.shouldComponentUpdate=s}return i.__N||i.__}(lg,e)}function Y_(e,t){var i=Z_(l_++,3);!W_.__s&&ag(i.__H,t)&&(i.__=e,i.u=t,c_.__H.__h.push(i))}function X_(e){return H_=5,eg(function(){return{current:e}},[])}function eg(e,t){var i=Z_(l_++,7);return ag(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function tg(e){var t=c_.context[e.__c],i=Z_(l_++,9);return i.c=e,t?(null==i.__&&(i.__=!0,t.sub(c_)),t.props.value):e.__}function ig(){for(var e;e=U_.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rg),t.__h.some(og),t.__h=[]}catch(i){t.__h=[],W_.__e(i,e.__v)}}}W_.__b=function(e){c_=null,z_&&z_(e)},W_.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),K_&&K_(e,t)},W_.__r=function(e){j_&&j_(e),l_=0;var t=(c_=e.__c).__H;t&&(u_===c_?(t.__h=[],c_.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.length&&ig(),l_=0)),u_=c_},W_.diffed=function(e){V_&&V_(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==U_.push(t)&&d_===W_.requestAnimationFrame||((d_=W_.requestAnimationFrame)||ng)(ig)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),u_=c_=null},W_.__c=function(e,t){t.some(function(e){try{e.__h.some(rg),e.__h=e.__h.filter(function(e){return!e.__||og(e)})}catch(i){t.some(function(e){e.__h&&(e.__h=[])}),t=[],W_.__e(i,e.__v)}}),G_&&G_(e,t)},W_.unmount=function(e){Q_&&Q_(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.some(function(e){try{rg(e)}catch(e){t=e}}),i.__H=void 0,t&&W_.__e(t,i.__v))};var sg="function"==typeof requestAnimationFrame;function ng(e){var t,i=function(){clearTimeout(s),sg&&cancelAnimationFrame(t),setTimeout(e)},s=setTimeout(i,35);sg&&(t=requestAnimationFrame(i))}function rg(e){var t=c_,i=e.__c;"function"==typeof i&&(e.__c=void 0,i()),c_=t}function og(e){var t=c_;e.__c=e.__(),c_=t}function ag(e,t){return!e||e.length!==t.length||t.some(function(t,i){return t!==e[i]})}function lg(e,t){return"function"==typeof t?t(e):t}const cg={GZipJS:"gzip-js",Base64:"base64"},ug={Activation:"events",Cancellation:"cancelEvents"},dg={Button:"button",Tab:"tab",Selector:"selector"},hg={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},pg={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},_g={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},gg={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},fg={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},vg={Once:"once",Recurring:"recurring",Always:"always"},mg={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},yg={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},bg={Popover:"popover",Inline:"inline"};function Sg(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&Ct(i.then)&&i.then(void 0,()=>{})}}}}const wg=Gn("[Surveys]"),kg="PostHog is not capturing, so a survey response cannot be recorded";function Cg(e){return Ct(e.is_capturing)?e.is_capturing():!e.has_opted_out_capturing()}function Eg(e){return!(!e.start_date||e.end_date)}function xg(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Ig=(e,t)=>`${e}${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`,Tg=e=>Ig("seenSurvey_",e),Mg=e=>{try{const t=Tg(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){wg.error("Failed to persist survey seen state",e)}},Rg=[_g.Popover,_g.Widget,_g.API],Pg={ignoreConditions:!1,ignoreDelay:!1,displayType:bg.Popover},Fg="logs",Lg=Gn("[Stylesheet Loader]"),Ag=e,Og=s,Dg="#020617",$g={fontFamily:"inherit",backgroundColor:"#eeeded",submitButtonColor:"black",submitButtonTextColor:"white",ratingButtonColor:"white",ratingButtonActiveColor:"black",borderColor:"#c9c6c6",whiteLabel:!1,displayThankYouMessage:!0,thankYouMessageHeader:"Thank you for your feedback!",position:hg.Right,widgetType:dg.Tab,widgetLabel:"Feedback",widgetColor:"black",zIndex:String(2147483645),disabledButtonOpacity:"0.6",maxWidth:"300px",textSubtleColor:"#939393",boxPadding:"20px 24px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",borderRadius:"10px",shuffleQuestions:!1,surveyPopupDelaySeconds:void 0,outlineColor:"rgba(59, 130, 246, 0.8)",inputBackground:"white",inputTextColor:Dg,scrollbarThumbColor:"var(--ph-survey-border-color)",scrollbarTrackColor:"var(--ph-survey-background-color)"},Ng=[hg.Center,hg.Left,hg.Right];function Bg(e){if(e.startsWith("#")){let t=e.replace(/^#/,"");return/^[0-9A-Fa-f]{3}$/.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),/^[0-9A-Fa-f]{6}$/.test(t)?`rgb(${parseInt(t.slice(0,2),16)},${parseInt(t.slice(2,4),16)},${parseInt(t.slice(4,6),16)})`:"rgb(255, 255, 255)"}return"rgb(255, 255, 255)"}function qg(e=$g.backgroundColor){let t;"#"===e[0]&&(t=Bg(e)),e.startsWith("rgb")&&(t=e);const i={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}[e.toLowerCase()];if(i&&(t=Bg(i)),!t)return Dg;const s=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(s){const e=parseInt(s[1]),t=parseInt(s[2]),i=parseInt(s[3]);return Math.sqrt(e*e*.299+t*t*.587+i*i*.114)>127.5?Dg:"white"}return Dg}const Hg=(e,t,i)=>{const s=af(e),n=Og.querySelector(`.${s}`);if(n&&n.shadowRoot)return{shadow:n.shadowRoot,isNewlyCreated:!1};const r=Og.createElement("div");((e,t,i)=>{const s=ct(ct({},$g),i),n=e.style,r=!Ng.includes(s.position)||t===_g.Widget&&(null==i?void 0:i.widgetType)===dg.Tab;n.setProperty("--ph-survey-font-family",function(e){if("inherit"===e)return"inherit";const t='BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';return e?`${e}, ${t}`:`-apple-system, ${t}`}(s.fontFamily)),n.setProperty("--ph-survey-box-padding",s.boxPadding),n.setProperty("--ph-survey-max-width",s.maxWidth),n.setProperty("--ph-survey-z-index",s.zIndex),n.setProperty("--ph-survey-border-color",s.borderColor),r?(n.setProperty("--ph-survey-border-radius",s.borderRadius),n.setProperty("--ph-survey-border-bottom","1.5px solid var(--ph-survey-border-color)")):(n.setProperty("--ph-survey-border-bottom","none"),n.setProperty("--ph-survey-border-radius",`${s.borderRadius} ${s.borderRadius} 0 0`)),n.setProperty("--ph-survey-background-color",s.backgroundColor),n.setProperty("--ph-survey-box-shadow",s.boxShadow),n.setProperty("--ph-survey-disabled-button-opacity",s.disabledButtonOpacity),n.setProperty("--ph-survey-submit-button-color",s.submitButtonColor),n.setProperty("--ph-survey-submit-button-text-color",(null==i?void 0:i.submitButtonTextColor)||qg(s.submitButtonColor)),n.setProperty("--ph-survey-rating-bg-color",s.ratingButtonColor),n.setProperty("--ph-survey-rating-active-bg-color",s.ratingButtonActiveColor),n.setProperty("--ph-survey-rating-active-text-color",qg(s.ratingButtonActiveColor)),n.setProperty("--ph-survey-text-primary-color",(null==i?void 0:i.textColor)||qg(s.backgroundColor)),n.setProperty("--ph-survey-text-subtle-color",s.textSubtleColor),n.setProperty("--ph-widget-color",s.widgetColor),n.setProperty("--ph-widget-text-color",qg(s.widgetColor)),n.setProperty("--ph-widget-z-index",s.zIndex);const o=(null==i?void 0:i.inputBackground)||(null==i?void 0:i.inputBackgroundColor);let a=o||s.inputBackground;o||"white"!==s.backgroundColor||(a="#f8f8f8"),n.setProperty("--ph-survey-input-background",a);const l=(null==i?void 0:i.inputTextColor)||qg(a);n.setProperty("--ph-survey-input-text-color",l),n.setProperty("--ph-survey-rating-text-color",l),n.setProperty("--ph-survey-scrollbar-thumb-color",s.scrollbarThumbColor),n.setProperty("--ph-survey-scrollbar-track-color",s.scrollbarTrackColor),n.setProperty("--ph-survey-outline-color",s.outlineColor)})(r,e.type,e.appearance),r.className=s;const o=r.attachShadow({mode:"open"}),a=function(e){const t=((e,t,i)=>{let s=e.createElement("style");s.innerText=t;const n=(e=>{var t;return Ct(e)?e:null==e||null===(t=e.config)||void 0===t?void 0:t.prepare_external_dependency_stylesheet})(i);return n&&(s=n(s)),s||(Lg.error("prepare_external_dependency_stylesheet returned null"),null)})(Og,':host{--ph-survey-font-family:-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--ph-survey-box-padding:20px 24px;--ph-survey-max-width:300px;--ph-survey-z-index:calc(2147480000 + 3645);--ph-survey-border-color:#dcdcdc;--ph-survey-border-bottom:1.5px solid var(--ph-survey-border-color);--ph-survey-border-radius:10px;--ph-survey-background-color:#eeeded;--ph-survey-box-shadow:0 4px 12px #00000026;--ph-survey-submit-button-color:black;--ph-survey-submit-button-text-color:white;--ph-survey-rating-bg-color:white;--ph-survey-rating-text-color:#020617;--ph-survey-rating-active-bg-color:black;--ph-survey-rating-active-text-color:white;--ph-survey-text-primary-color:#020617;--ph-survey-text-subtle-color:#939393;--ph-widget-color:#e0a045;--ph-widget-text-color:white;--ph-survey-scrollbar-thumb-color:var(--ph-survey-border-color);--ph-survey-scrollbar-track-color:var(--ph-survey-background-color);--ph-survey-outline-color:#3b82f6cc;--ph-survey-input-background:white;--ph-survey-input-text-color:#020617;--ph-survey-disabled-button-opacity:.6}.ph-survey{min-width:300px;width:var(--ph-survey-max-width);max-width:85%;z-index:var(--ph-survey-z-index);height:fit-content;margin:0;position:fixed;bottom:0}.ph-survey h3,.ph-survey p{margin:0}.ph-survey *{box-sizing:border-box;font-family:var(--ph-survey-font-family);color:var(--ph-survey-text-primary-color)}.ph-survey textarea,.ph-survey input[type=text],.ph-survey .multiple-choice-options label{color:var(--ph-survey-input-text-color);background:var(--ph-survey-input-background);border:1.5px solid var(--ph-survey-border-color);border-radius:4px;padding:10px;transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey textarea,.ph-survey input[type=text]{transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey input{margin:0}.ph-survey textarea:focus,.ph-survey textarea:focus-visible,.ph-survey input[type=text]:focus,.ph-survey input[type=text]:focus-visible,.ph-survey .form-submit:focus,.ph-survey .form-submit:focus-visible,.ph-survey input[type=checkbox]:focus,.ph-survey input[type=radio]:focus,.ph-survey input[type=checkbox]:focus-visible,.ph-survey input[type=radio]:focus-visible{outline:1.5px solid var(--ph-survey-outline-color);border-color:var(--ph-survey-rating-active-bg-color);outline-offset:2px}.ph-survey textarea:focus:not(:focus-visible),.ph-survey input[type=text]:focus:not(:focus-visible),.ph-survey button:focus:not(:focus-visible),.ph-survey input[type=checkbox]:focus:not(:focus-visible),.ph-survey input[type=radio]:focus:not(:focus-visible){outline:none}.ph-survey textarea:hover:not(:focus),.ph-survey input[type=text]:hover:not(:focus){border-color:var(--ph-survey-rating-active-bg-color)}@media (max-width:768px){.ph-survey textarea,.ph-survey input[type=text]{font-size:1rem}}.ph-survey .multiple-choice-options label,.ph-survey .rating-options-number,.ph-survey .form-cancel,.ph-survey input[type=checkbox],.ph-survey input[type=radio]{border:1.5px solid var(--ph-survey-border-color)}.ph-survey label,.ph-survey input[type=checkbox],.ph-survey input[type=radio],.ph-survey .ratings-emoji,.ph-survey .ratings-number,.ph-survey .footer-branding,.ph-survey .form-cancel,.ph-survey .form-submit{transition:all .2s ease-out}@media (prefers-reduced-motion:no-preference){.ph-survey button:active,.ph-survey input[type=checkbox]:active,.ph-survey input[type=radio]:active,.ph-survey label:active{transition-duration:.1s}}.ph-survey-widget-tab{background:var(--ph-widget-color);color:var(--ph-widget-text-color);text-align:center;cursor:pointer;z-index:var(--ph-survey-z-index);border:none;border-radius:3px 3px 0 0;padding:10px 12px;transition:padding .2s ease-out;position:fixed}.ph-survey-widget-tab:hover:not(.widget-tab-top){padding-bottom:16px}.ph-survey-widget-tab.widget-tab-top{border-radius:0 0 3px 3px}.ph-survey-widget-tab.widget-tab-top:hover{padding-top:16px}@keyframes ph-survey-fade-in{0%{opacity:0}to{opacity:1}}.survey-box{flex-direction:column;gap:16px;display:flex}.bottom-section{flex-direction:column;gap:8px;display:flex}.thank-you-message-header~.bottom-section,.intro-screen-header~.bottom-section{padding-top:16px}.question-container,.thank-you-message,.intro-screen{flex-direction:column;gap:8px;display:flex}.survey-question{font-size:14px;font-weight:500}.survey-question-description{opacity:.8;padding-top:4px;font-size:13px}.survey-question-description,.thank-you-message-body,.intro-screen-body{word-wrap:break-word;overflow-wrap:break-word}:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) img,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) video,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) iframe,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) embed,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) object,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) svg{max-width:100%;height:auto}.question-textarea-wrapper{flex-direction:column;display:flex}.survey-form{animation:.3s ease-out forwards ph-survey-fade-in}.survey-form,.thank-you-message,.intro-screen{text-align:left;width:100%;z-index:var(--ph-survey-z-index);border:1.5px solid var(--ph-survey-border-color);border-bottom:var(--ph-survey-border-bottom);background:var(--ph-survey-background-color);border-radius:var(--ph-survey-border-radius);box-shadow:var(--ph-survey-box-shadow);padding:var(--ph-survey-box-padding);margin:0;position:relative}.survey-form textarea,.survey-form input[type=text]{min-width:100%}.survey-form textarea:focus,.survey-form textarea:focus-visible{box-shadow:0 4px 12px #00000014}.survey-form textarea:focus:not(:focus-visible){box-shadow:none}.survey-box .question-header--empty~.multiple-choice-options,.survey-box .question-header--empty~textarea{margin-top:0}.multiple-choice-options{border:none;flex-direction:column;gap:8px;margin:0;padding:1px 0;font-size:14px;display:flex}.multiple-choice-options label,.multiple-choice-options .response-choice{color:inherit;align-items:center;gap:8px;display:flex}.multiple-choice-options label{cursor:pointer;font-size:13px}.multiple-choice-options label:hover:not(:has(input:checked)){border-color:var(--ph-survey-text-subtle-color);box-shadow:0 2px 8px #00000014}.multiple-choice-options label:has(input:checked){border-color:var(--ph-survey-rating-active-bg-color);box-shadow:0 1px 4px #0000000d}.multiple-choice-options label.choice-option-open{flex-wrap:wrap}.multiple-choice-options label span{color:inherit}.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--ph-survey-input-background);cursor:pointer;z-index:1;border-radius:3px;flex-shrink:0;width:1rem;height:1rem;transition:all .2s cubic-bezier(.4,0,.2,1),transform .15s ease-out;position:relative}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):focus{transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):hover{border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):active{transform:scale(.95)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked{background:var(--ph-survey-rating-active-bg-color);border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked:hover{transform:scale(1.05)}.multiple-choice-options input[type=checkbox]:checked:after{border:solid var(--ph-survey-rating-active-text-color);border-width:0 2px 2px 0;width:4px;height:8px;animation:.2s ease-out .1s forwards ph-survey-checkmark-reveal;left:4px;transform:rotate(45deg)scale(0)}.multiple-choice-options input[type=radio]:checked:after{background:var(--ph-survey-rating-active-text-color);border-radius:50%;width:6px;height:6px;animation:.15s ease-out 50ms forwards ph-survey-radio-reveal;top:5px;left:5px;transform:scale(0)}.multiple-choice-options input[type=checkbox]:checked:after,.multiple-choice-options input[type=radio]:checked:after{content:"";box-sizing:content-box;position:absolute}.multiple-choice-options input[type=radio]{border-radius:50%}.multiple-choice-options input[type=radio]:checked{border:none}:is(.multiple-choice-options input[type=checkbox]:checked,.multiple-choice-options input[type=radio]:checked)~*{font-weight:700}.multiple-choice-options .choice-option-open input[type=text]::placeholder{color:var(--ph-survey-text-subtle-color);font-weight:400}.rating-options-emoji{justify-content:space-between;display:flex}.rating-options-emoji-2{justify-content:space-around}.ratings-emoji{opacity:.5;background-color:#0000;border:none;padding:0;font-size:16px}.ratings-emoji:hover{cursor:pointer;opacity:1;transform:scale(1.15)}.ratings-emoji.rating-active{opacity:1}.ratings-emoji svg{fill:var(--ph-survey-text-primary-color);transition:fill .2s ease-out}.rating-options-number{border-radius:6px;grid-auto-columns:1fr;grid-auto-flow:column;display:grid;overflow:hidden}.rating-options-number .ratings-number{border-right:1px solid var(--ph-survey-border-color);text-align:center;cursor:pointer;color:var(--ph-survey-rating-text-color);border-top:none;border-bottom:none;border-left:none;font-weight:700}.rating-options-number .ratings-number:last-of-type{border-right:0}.rating-options-number .ratings-number.rating-active{background:var(--ph-survey-rating-active-bg-color);color:var(--ph-survey-rating-active-text-color)}.ratings-number{background-color:var(--ph-survey-rating-bg-color);border:none;padding:8px 0}.ratings-number .rating-active{background-color:var(--ph-survey-rating-active-bg-color)}.ratings-number{cursor:pointer}@media (hover:hover) and (pointer:fine){.ratings-number:hover:not(.rating-active){background-color:color-mix(in srgb, var(--ph-survey-rating-active-bg-color) 14%, var(--ph-survey-rating-bg-color))}}.rating-text{opacity:.7;flex-direction:row;justify-content:space-between;font-size:11px;display:flex}.form-buttons{flex-direction:row;gap:8px;width:100%;display:flex}.form-buttons-with-back>.form-submit{flex:auto;min-width:0}.form-submit{text-align:center;cursor:pointer;user-select:none;background:var(--ph-survey-submit-button-color);color:var(--ph-survey-submit-button-text-color);border:none;border-radius:6px;min-width:100%;padding:12px;font-weight:700;box-shadow:0 2px #0000000b}.form-submit:not([disabled]):hover{transform:scale(1.02);box-shadow:0 4px 8px #0000001a}.form-submit:not([disabled]):active{transform:scale(.98);box-shadow:0 1px 2px #0000000d}.form-submit[disabled]{opacity:var(--ph-survey-disabled-button-opacity);cursor:not-allowed}.form-back{text-align:center;cursor:pointer;user-select:none;color:var(--ph-survey-text-primary-color);border:1.5px solid var(--ph-survey-border-color);background:0 0;border-radius:6px;flex:none;padding:12px 16px;font-weight:600}.form-back:hover{transform:scale(1.02)}.form-back:active{transform:scale(.98)}.validation-hint{opacity:.7;margin-top:4px;font-size:12px}.form-cancel{cursor:pointer;background:#fff;border-radius:100%;padding:12px;line-height:0;position:absolute;top:0;right:0;transform:translate(50%,-50%)}.form-cancel:hover{opacity:.7;transform:translate(50%,-50%)scale(1.1)}.footer-branding{opacity:.6;justify-content:center;align-items:center;gap:4px;font-size:11px;font-weight:500;text-decoration:none;display:flex}.footer-branding:hover{opacity:1}.footer-branding a{text-decoration:none}.thank-you-message{text-align:center}.thank-you-message-header{margin:10px 0 0}.thank-you-message-body{opacity:.8;font-size:14px}.intro-screen{text-align:center;animation:.3s ease-out forwards ph-survey-fade-in}.intro-screen-header{margin:10px 0 0}.intro-screen-body{opacity:.8;font-size:14px}.limit-height{scrollbar-width:thin;scrollbar-color:var(--ph-survey-scrollbar-thumb-color) var(--ph-survey-scrollbar-track-color);max-height:256px;overflow:hidden auto}.limit-height::-webkit-scrollbar{width:8px}.limit-height::-webkit-scrollbar-track{background:var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb{background-color:var(--ph-survey-scrollbar-thumb-color);border:2px solid var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb:hover{background-color:var(--ph-survey-text-subtle-color)}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.ph-survey *{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes ph-survey-checkmark-reveal{0%{opacity:0;transform:rotate(45deg)scale(0)}50%{opacity:1;transform:rotate(45deg)scale(1.2)}to{opacity:1;transform:rotate(45deg)scale(1)}}@keyframes ph-survey-radio-reveal{0%{opacity:0;transform:scale(0)}50%{opacity:1;transform:scale(1.3)}to{opacity:1;transform:scale(1)}}',e);return null==t||t.setAttribute("data-ph-survey-style","true"),t}(t);if(a){const e=o.querySelector("style");e&&o.removeChild(e),o.appendChild(a)}return(i||Og.body).appendChild(r),{shadow:o,isNewlyCreated:!0}},Ug=({responses:e,survey:t,surveySubmissionId:i,posthog:s,isSurveyCompleted:n,properties:r,surveyLanguage:o,questionSnapshots:a})=>{var l;s?Cg(s)&&(Mg(t),s.capture(mg.SENT,ct(ct(ct(ct({[yg.SURVEY_NAME]:t.name,[yg.SURVEY_ID]:t.id,[yg.SURVEY_ITERATION]:t.current_iteration,[yg.SURVEY_ITERATION_START_DATE]:t.current_iteration_start_date,[yg.SURVEY_SUBMISSION_ID]:i,[yg.SURVEY_COMPLETED]:n},o&&{[yg.SURVEY_LANGUAGE]:o}),{},{sessionRecordingUrl:null===(l=s.get_session_replay_url)||void 0===l?void 0:l.call(s)},sl(e,t,a)),r),{},{$set:{[rl(t,"responded")]:!0}})),n&&(Ag.dispatchEvent(new CustomEvent("PHSurveySent",{detail:{surveyId:t.id}})),of(t),s.reloadFeatureFlags())):wg.error("[survey sent] event not captured, PostHog instance not found.")},Wg=(e,t,i)=>{var s;return ct(ct({[yg.SURVEY_NAME]:e.name,[yg.SURVEY_ID]:e.id,[yg.SURVEY_ITERATION]:e.current_iteration,[yg.SURVEY_ITERATION_START_DATE]:e.current_iteration_start_date,[yg.SURVEY_PARTIALLY_COMPLETED]:nl(null==t?void 0:t.responses)},(null==t?void 0:t.surveyLanguage)&&{[yg.SURVEY_LANGUAGE]:t.surveyLanguage}),{},{sessionRecordingUrl:null===(s=i.get_session_replay_url)||void 0===s?void 0:s.call(i),[yg.SURVEY_SUBMISSION_ID]:null==t?void 0:t.surveySubmissionId},sl(null==t?void 0:t.responses,e,null==t?void 0:t.questionSnapshots))},zg=(e,t,i,s)=>{if(!t)return void wg.error("[survey dismissed] event not captured, PostHog instance not found.");if(i)return;const n=nf(e),r=n?n.surveyLanguage:s;t.capture(mg.DISMISSED,ct(ct(ct({},Wg(e,n,t)),r&&{[yg.SURVEY_LANGUAGE]:r}),{},{$set:{[rl(e,"dismissed")]:!0}})),of(e),Mg(e),Ag.dispatchEvent(new CustomEvent("PHSurveyClosed",{detail:{surveyId:e.id}}))},jg=(e,t)=>{if(!t)return void wg.error("[survey abandoned] event not captured, PostHog instance not found.");const i=(e=>Ig("abandonedSurvey_",e))(e);try{if("true"===localStorage.getItem(i))return}catch(e){return}const s=nf(e);if(s){try{localStorage.setItem(i,"true")}catch(e){}t.capture(mg.ABANDONED,Wg(e,s,t),{transport:"sendBeacon"})}},Vg=e=>e.map(e=>({sort:Math.floor(10*Math.random()),value:e})).sort((e,t)=>e.sort-t.sort).map(e=>e.value),Gg=(e,t)=>e.length===t.length&&e.every((e,i)=>e===t[i])?t.reverse():t,Qg=e=>{const t=e.map(e=>e.id);return t.every(e=>!!e)?t:void 0},Kg=(e,t)=>{return(e=>e.questions.some(e=>{var t;return!!(null===(t=e.branching)||void 0===t?void 0:t.type)}))(e)?e.questions:t?null!==(i=((e,t)=>{if(!t||t.length!==e.questions.length)return null;const i=new Map(e.questions.map(e=>[e.id,e])),s=[];for(const e of t){const t=i.get(e);if(!t)return null;s.push(t)}return s})(e,t.questionOrder))&&void 0!==i?i:e.questions:e.appearance&&e.appearance.shuffleQuestions&&!e.enable_partial_responses?Gg(e.questions,Vg(e.questions)):e.questions;var i},Zg=e=>hl(e)||rf(e),Jg=function(e){function t(e){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&i.forEach(function(e){e.__e=!0,E_(e)})},this.sub=function(e){i.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i&&i.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+a_++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed(){},isPopup:!0,onPreviewSubmit(){},onPreviewBack(){},surveySubmissionId:"",properties:void 0,surveyLanguage:null}),Yg=()=>tg(Jg),Xg=({component:e,children:t,renderAsHtml:i,style:s})=>function(e,t,i){var s,n,r,o,a=f_({},e.props);for(r in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)"key"==r?s=t[r]:"ref"==r?n=t[r]:a[r]=void 0===t[r]&&null!=o?o[r]:t[r];return arguments.length>2&&(a.children=arguments.length>3?Gp.call(arguments,2):i),y_(e.type,a,s||e.key,n||e.ref,null)}(e,i?{dangerouslySetInnerHTML:{__html:t},style:s}:{children:t,style:s});function ef(e,t){var i,s;if(!(null===(i=e.conditions)||void 0===i?void 0:i.url))return!0;const n=gr(t);if(!n)return!1;const r=[e.conditions.url],o=function(e){return null!=e?e:"icontains"}(null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType);return gl[o](r,[n])}const tf=e=>Ig("inProgressSurvey_",e),sf=(e,t)=>{try{localStorage.setItem(tf(e),JSON.stringify(t))}catch(e){wg.error("Error setting in-progress survey state in localStorage",e)}},nf=e=>{try{const t=localStorage.getItem(tf(e));if(t)return JSON.parse(t)}catch(e){wg.error("Error getting in-progress survey state from localStorage",e)}return null},rf=e=>{const t=nf(e);return!Pt(null==t?void 0:t.surveySubmissionId)},of=e=>{try{localStorage.removeItem(tf(e))}catch(e){wg.error("Error clearing in-progress survey state from localStorage",e)}};function af(e,t=!1){const i=`PostHogSurvey-${e.id}`;return t?`.${i}`:i}function lf(e,t=hg.Right,i){if(e===_g.ExternalSurvey)return{};switch(t){case hg.TopLeft:return{top:"0",left:"0",transform:"translate(30px, 30px)"};case hg.TopRight:return{top:"0",right:"0",transform:"translate(-30px, 30px)"};case hg.TopCenter:return{top:"0",left:"50%",transform:"translate(-50%, 30px)"};case hg.MiddleLeft:return{top:"50%",left:"0",transform:"translate(30px, -50%)"};case hg.MiddleRight:return{top:"50%",right:"0",transform:"translate(-30px, -50%)"};case hg.MiddleCenter:return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case hg.Left:return{left:"30px"};case hg.Center:return{left:"50%",transform:"translateX(-50%)"};default:return{right:e===_g.Widget&&i===dg.Tab?"60px":"30px"}}}var cf=0;function uf(e,t,i,s,n,r){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?o=t[a]:l[a]=t[a];var c={type:e,props:l,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--cf,__i:-1,__u:0,__source:n,__self:r};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return Qp.vnode&&Qp.vnode(c),c}const df=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),hf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),pf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),_f=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z"})}),gf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),ff=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:uf("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})}),vf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:uf("path",{d:"M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z"})}),mf=({fill:e="currentColor"}={})=>uf("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:e,xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"close-survey-title-adam",children:[uf("title",{id:"close-survey-title",className:"adam-testing",children:"Close survey"}),uf("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z",fill:e})]}),yf=uf("svg",{width:"77",height:"14",viewBox:"0 0 77 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[uf("g",{"clip-path":"url(#clip0_2415_6911)",children:[uf("mask",{id:"mask0_2415_6911",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"77",height:"14",children:uf("path",{d:"M0.5 0H76.5V14H0.5V0Z",fill:"white"})}),uf("g",{mask:"url(#mask0_2415_6911)",children:[uf("path",{d:"M5.77226 8.02931C5.59388 8.37329 5.08474 8.37329 4.90634 8.02931L4.4797 7.20672C4.41155 7.07535 4.41155 6.9207 4.4797 6.78933L4.90634 5.96669C5.08474 5.62276 5.59388 5.62276 5.77226 5.96669L6.19893 6.78933C6.26709 6.9207 6.26709 7.07535 6.19893 7.20672L5.77226 8.02931ZM5.77226 12.6946C5.59388 13.0386 5.08474 13.0386 4.90634 12.6946L4.4797 11.872C4.41155 11.7406 4.41155 11.586 4.4797 11.4546L4.90634 10.632C5.08474 10.288 5.59388 10.288 5.77226 10.632L6.19893 11.4546C6.26709 11.586 6.26709 11.7406 6.19893 11.872L5.77226 12.6946Z",fill:"#1D4AFF"}),uf("path",{d:"M0.5 10.9238C0.5 10.508 1.02142 10.2998 1.32637 10.5938L3.54508 12.7327C3.85003 13.0267 3.63405 13.5294 3.20279 13.5294H0.984076C0.716728 13.5294 0.5 13.3205 0.5 13.0627V10.9238ZM0.5 8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.19753 13.3927C5.28831 13.4802 5.41144 13.5294 5.53982 13.5294H8.0421C8.47337 13.5294 8.68936 13.0267 8.3844 12.7327L1.32637 5.92856C1.02142 5.63456 0.5 5.84278 0.5 6.25854V8.67083ZM0.5 4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L10.0368 13.3927C10.1276 13.4802 10.2508 13.5294 10.3791 13.5294H12.8814C13.3127 13.5294 13.5287 13.0267 13.2237 12.7327L1.32637 1.26329C1.02142 0.969312 0.5 1.17752 0.5 1.59327V4.00556ZM5.33931 4.00556C5.33931 4.12932 5.39033 4.24802 5.4811 4.33554L14.1916 12.7327C14.4965 13.0267 15.0179 12.8185 15.0179 12.4028V9.99047C15.0179 9.86671 14.9669 9.74799 14.8762 9.66049L6.16568 1.26329C5.86071 0.969307 5.33931 1.17752 5.33931 1.59327V4.00556ZM11.005 1.26329C10.7 0.969307 10.1786 1.17752 10.1786 1.59327V4.00556C10.1786 4.12932 10.2296 4.24802 10.3204 4.33554L14.1916 8.06748C14.4965 8.36148 15.0179 8.15325 15.0179 7.7375V5.3252C15.0179 5.20144 14.9669 5.08272 14.8762 4.99522L11.005 1.26329Z",fill:"#F9BD2B"}),uf("path",{d:"M21.0852 10.981L16.5288 6.58843C16.2238 6.29443 15.7024 6.50266 15.7024 6.91841V13.0627C15.7024 13.3205 15.9191 13.5294 16.1865 13.5294H23.2446C23.5119 13.5294 23.7287 13.3205 23.7287 13.0627V12.5032C23.7287 12.2455 23.511 12.0396 23.2459 12.0063C22.4323 11.9042 21.6713 11.546 21.0852 10.981ZM18.0252 12.0365C17.5978 12.0365 17.251 11.7021 17.251 11.2901C17.251 10.878 17.5978 10.5436 18.0252 10.5436C18.4527 10.5436 18.7996 10.878 18.7996 11.2901C18.7996 11.7021 18.4527 12.0365 18.0252 12.0365Z",fill:"currentColor"}),uf("path",{d:"M0.5 13.0627C0.5 13.3205 0.716728 13.5294 0.984076 13.5294H3.20279C3.63405 13.5294 3.85003 13.0267 3.54508 12.7327L1.32637 10.5938C1.02142 10.2998 0.5 10.508 0.5 10.9238V13.0627ZM5.33931 5.13191L1.32637 1.26329C1.02142 0.969306 0.5 1.17752 0.5 1.59327V4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L5.33931 8.86412V5.13191ZM1.32637 5.92855C1.02142 5.63455 0.5 5.84278 0.5 6.25853V8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.33931 13.5294V9.79717L1.32637 5.92855Z",fill:"#1D4AFF"}),uf("path",{d:"M10.1787 5.3252C10.1787 5.20144 10.1277 5.08272 10.0369 4.99522L6.16572 1.26329C5.8608 0.969306 5.33936 1.17752 5.33936 1.59327V4.00556C5.33936 4.12932 5.39037 4.24802 5.48114 4.33554L10.1787 8.86412V5.3252ZM5.33936 13.5294H8.04214C8.47341 13.5294 8.6894 13.0267 8.38443 12.7327L5.33936 9.79717V13.5294ZM5.33936 5.13191V8.67083C5.33936 8.79459 5.39037 8.91331 5.48114 9.00081L10.1787 13.5294V9.99047C10.1787 9.86671 10.1277 9.74803 10.0369 9.66049L5.33936 5.13191Z",fill:"#F54E00"}),uf("path",{d:"M29.375 11.6667H31.3636V8.48772H33.0249C34.8499 8.48772 36.0204 7.4443 36.0204 5.83052C36.0204 4.21681 34.8499 3.17334 33.0249 3.17334H29.375V11.6667ZM31.3636 6.84972V4.81136H32.8236C33.5787 4.81136 34.0318 5.19958 34.0318 5.83052C34.0318 6.4615 33.5787 6.84972 32.8236 6.84972H31.3636ZM39.618 11.7637C41.5563 11.7637 42.9659 10.429 42.9659 8.60905C42.9659 6.78905 41.5563 5.45438 39.618 5.45438C37.6546 5.45438 36.2701 6.78905 36.2701 8.60905C36.2701 10.429 37.6546 11.7637 39.618 11.7637ZM38.1077 8.60905C38.1077 7.63838 38.7118 6.97105 39.618 6.97105C40.5116 6.97105 41.1157 7.63838 41.1157 8.60905C41.1157 9.57972 40.5116 10.2471 39.618 10.2471C38.7118 10.2471 38.1077 9.57972 38.1077 8.60905ZM46.1482 11.7637C47.6333 11.7637 48.6402 10.8658 48.6402 9.81025C48.6402 7.33505 45.2294 8.13585 45.2294 7.16518C45.2294 6.8983 45.5189 6.72843 45.9342 6.72843C46.3622 6.72843 46.8782 6.98318 47.0418 7.54132L48.527 6.94678C48.2375 6.06105 47.1677 5.45438 45.8713 5.45438C44.4743 5.45438 43.6058 6.25518 43.6058 7.21372C43.6058 9.53118 46.9663 8.88812 46.9663 9.84665C46.9663 10.1864 46.6391 10.417 46.1482 10.417C45.4434 10.417 44.9525 9.94376 44.8015 9.3735L43.3164 9.93158C43.6436 10.8537 44.6001 11.7637 46.1482 11.7637ZM53.4241 11.606L53.2982 10.0651C53.0843 10.1743 52.8074 10.2106 52.5808 10.2106C52.1278 10.2106 51.8257 9.89523 51.8257 9.34918V7.03172H53.3612V5.55145H51.8257V3.78001H49.9755V5.55145H48.9687V7.03172H49.9755V9.57972C49.9755 11.06 51.0202 11.7637 52.3921 11.7637C52.7696 11.7637 53.122 11.7031 53.4241 11.606ZM59.8749 3.17334V6.47358H56.376V3.17334H54.3874V11.6667H56.376V8.11158H59.8749V11.6667H61.8761V3.17334H59.8749ZM66.2899 11.7637C68.2281 11.7637 69.6378 10.429 69.6378 8.60905C69.6378 6.78905 68.2281 5.45438 66.2899 5.45438C64.3265 5.45438 62.942 6.78905 62.942 8.60905C62.942 10.429 64.3265 11.7637 66.2899 11.7637ZM64.7796 8.60905C64.7796 7.63838 65.3837 6.97105 66.2899 6.97105C67.1835 6.97105 67.7876 7.63838 67.7876 8.60905C67.7876 9.57972 67.1835 10.2471 66.2899 10.2471C65.3837 10.2471 64.7796 9.57972 64.7796 8.60905ZM73.2088 11.4725C73.901 11.4725 74.5177 11.242 74.845 10.8416V11.424C74.845 12.1034 74.2786 12.5767 73.4102 12.5767C72.7935 12.5767 72.2523 12.2854 72.1642 11.788L70.4776 12.0428C70.7042 13.1955 71.925 13.972 73.4102 13.972C75.361 13.972 76.6574 12.8679 76.6574 11.2298V5.55145H74.8324V6.07318C74.4926 5.69705 73.9136 5.45438 73.171 5.45438C71.409 5.45438 70.3014 6.61918 70.3014 8.46345C70.3014 10.3077 71.409 11.4725 73.2088 11.4725ZM72.1012 8.46345C72.1012 7.55345 72.655 6.97105 73.5109 6.97105C74.3793 6.97105 74.9331 7.55345 74.9331 8.46345C74.9331 9.37345 74.3793 9.95585 73.5109 9.95585C72.655 9.95585 72.1012 9.37345 72.1012 8.46345Z",fill:"currentColor"})]})]}),uf("defs",{children:uf("clipPath",{id:"clip0_2415_6911",children:uf("rect",{width:"76",height:"14",fill:"white",transform:"translate(0.5)"})})})]});function bf({urlParams:e}){const t=e?Object.entries(e).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&"):"";return uf("a",{href:"https://posthog.com/surveys"+(t?`?${t}`:""),target:"_blank",rel:"noopener",className:"footer-branding",children:["Survey by ",yf]})}function Sf({text:t,submitDisabled:i,appearance:s,onSubmit:n,link:r,onPreviewSubmit:o,skipSubmitButton:a,canGoBack:l,onBack:c}){const{isPreviewMode:u}=tg(Jg),d=!!l&&!!c,h=!a&&uf("button",{className:"form-submit",disabled:i,"aria-label":"Submit survey",type:"button",onClick(){r&&(null==e||e.open(r)),u?null==o||o():n()},children:t});return uf("div",{className:"bottom-section",children:[d?uf("div",{className:"form-buttons form-buttons-with-back",children:[uf("button",{className:"form-back",type:"button","aria-label":"Go to previous question",onClick:c,children:s.backButtonText||"Back"}),h]}):h,!s.whiteLabel&&uf(bf,{urlParams:{utm_source:"survey-footer"}})]})}function wf({question:e,forceDisableHtml:t,htmlFor:i}){return uf("div",{class:e.question||e.description?"question-header":"question-header question-header--empty",children:[uf(e.type===gg.Open?"label":"h3",{className:"survey-question",htmlFor:i,children:e.question}),e.description&&Xg({component:m_("p",{className:"survey-question-description"}),children:e.description,renderAsHtml:!t&&"text"!==e.descriptionContentType})]})}function kf({onClick:e}){const{isPreviewMode:t}=tg(Jg);return uf("button",{className:"form-cancel",onClick:e,disabled:t,"aria-label":"Close survey",type:"button",children:mf({fill:"black"})})}const Cf=e;function Ef({header:e,description:t,contentType:i,forceDisableHtml:s,appearance:n,onClose:r}){const{isPopup:o}=tg(Jg);return Y_(()=>{const e=e=>{"Enter"!==e.key&&"Escape"!==e.key||(e.preventDefault(),r())};return sr(Cf,"keydown",e),()=>{Cf.removeEventListener("keydown",e)}},[r]),uf("div",{className:"thank-you-message",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==n.hideCancelButton&&uf(kf,{onClick:()=>r()}),uf("h3",{className:"thank-you-message-header",children:e}),t&&Xg({component:m_("p",{className:"thank-you-message-body"}),children:t,renderAsHtml:!s&&"text"!==i}),o&&uf(Sf,{text:n.thankYouMessageCloseButtonText||"Close",submitDisabled:!1,appearance:n,onSubmit:()=>r()})]})}function xf({header:e,description:t,contentType:i,forceDisableHtml:s,appearance:n,onStart:r}){const{isPopup:o,onPreviewSubmit:a,onPopupSurveyDismissed:l}=tg(Jg);return uf("div",{className:"intro-screen",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==n.hideCancelButton&&uf(kf,{onClick:()=>l()}),e&&uf("h3",{className:"intro-screen-header",children:e}),t&&Xg({component:m_("p",{className:"intro-screen-body"}),children:t,renderAsHtml:!s&&"text"!==i}),uf(Sf,{text:n.introScreenButtonText||"Get started",submitDisabled:!1,appearance:n,onSubmit:r,onPreviewSubmit:()=>a(null)})]})}const If=e=>kt(e)&&e.every(e=>Tt(e));function Tf({question:e,forceDisableHtml:t,appearance:i,onSubmit:s,onPreviewSubmit:n,displayQuestionIndex:r,initialValue:o,canGoBack:a,onBack:l}){const{isPreviewMode:c}=Yg(),u=X_(null),[d,h]=J_(()=>Tt(o)?o:""),p=null==i?void 0:i.disableAutofocus;Y_(()=>{p||setTimeout(()=>{var e;c||null===(e=u.current)||void 0===e||e.focus()},100)},[c,p]);const _=`surveyQuestion${r}`,g=eg(()=>function(e,t,i){const s=e.trim();if(!i&&""===s)return"This field is required";if(""===s)return!1;if(t&&t.length>0)for(const e of t)switch(e.type){case ht:var n;if(void 0!==e.value&&e.value>s.length)return null!==(n=e.errorMessage)&&void 0!==n?n:`Please enter at least ${e.value} characters`;break;case pt:var r;if(void 0!==e.value&&s.length>e.value)return null!==(r=e.errorMessage)&&void 0!==r?r:`Please enter no more than ${e.value} characters`}return!1}(d,e.validation,e.optional),[d,e.validation,e.optional]),f=Un(e.validation,ht),v=Un(e.validation,pt),m=eg(()=>function(e,t){const i=1===e?void 0:e;return i&&t?`Enter ${i}-${t} characters`:i?`Enter at least ${i} ${1===i?"character":"characters"}`:t?`Maximum ${t} ${1===t?"character":"characters"}`:void 0}(f,v),[f,v]),y=()=>{g||s(d.trim())},b=()=>{g||n(d.trim())};return uf(b_,{children:[uf("div",{className:"question-container",children:[uf(wf,{question:e,forceDisableHtml:t,htmlFor:_}),uf("textarea",{ref:u,id:_,rows:4,placeholder:null==i?void 0:i.placeholder,minLength:f,maxLength:v,onInput(e){h(e.currentTarget.value),e.stopPropagation()},onKeyDown(e){e.stopPropagation(),"Enter"!==e.key||!e.metaKey&&!e.ctrlKey||g||(e.preventDefault(),c?b():y())},value:d}),m&&uf("div",{className:"validation-hint",children:m})]}),uf(Sf,{text:e.buttonText||"Submit",submitDisabled:!!g,appearance:i,onSubmit:y,onPreviewSubmit:b,canGoBack:a,onBack:l})]})}function Mf({question:e,forceDisableHtml:t,appearance:i,onSubmit:s,onPreviewSubmit:n,canGoBack:r,onBack:o}){return uf(b_,{children:[uf("div",{className:"question-container",children:uf(wf,{question:e,forceDisableHtml:t})}),uf(Sf,{text:e.buttonText||"Submit",submitDisabled:!1,link:e.link,appearance:i,onSubmit:()=>s("link clicked"),onPreviewSubmit:()=>n("link clicked"),canGoBack:r,onBack:o})]})}function Rf({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:s,onSubmit:n,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){var c;const u=e.scale,d=10===e.scale?0:1,[h,p]=J_(()=>Ft(o)?o:kt(o)&&o.length>0&&Ft(parseInt(o[0]))?parseInt(o[0]):Tt(o)&&Ft(parseInt(o))?parseInt(o):null),_="emoji"===e.display&&2===e.scale,{isPreviewMode:g}=Yg(),f=e=>g?r(e):n(e);return uf(b_,{children:[uf("div",{className:"question-container",children:[uf(wf,{question:e,forceDisableHtml:t}),uf("div",{className:"rating-section",children:[uf("div",{className:"rating-options",children:["emoji"===e.display&&uf("div",{className:"rating-options-emoji"+(_?" rating-options-emoji-2":""),children:null===(c=Df[e.scale])||void 0===c?void 0:c.map((t,s)=>uf("button",{"aria-label":`Rate ${s+1}`,className:`ratings-emoji question-${i}-rating-${s} ${s+1===h?"rating-active":""}`,value:s+1,type:"button",onClick(){const t=s+1;p(t),e.skipSubmitButton&&f(t)},children:t},s))}),"number"===e.display&&uf("div",{className:"rating-options-number",style:{gridTemplateColumns:`repeat(${u-d+1}, minmax(0, 1fr))`},children:$f(e.scale).map((t,n)=>uf(Pf,{displayQuestionIndex:i,active:h===t,appearance:s,num:t,setActiveNumber(t){p(t),e.skipSubmitButton&&f(t)}},n))})]}),!_&&uf("div",{className:"rating-text",children:[uf("div",{children:e.lowerBoundLabel}),uf("div",{children:e.upperBoundLabel})]})]})]}),uf(Sf,{text:e.buttonText||(null==s?void 0:s.submitButtonText)||"Submit",submitDisabled:Rt(h)&&!e.optional,appearance:s,onSubmit:()=>n(h),onPreviewSubmit:()=>r(h),skipSubmitButton:e.skipSubmitButton,canGoBack:a,onBack:l})]})}function Pf({num:e,active:t,displayQuestionIndex:i,setActiveNumber:s}){return uf("button",{"aria-label":`Rate ${e}`,className:`ratings-number question-${i}-rating-${e} ${t?"rating-active":""}`,type:"button",onClick(){s(e)},children:e})}function Ff({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:s,onSubmit:n,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){const c=X_(null),u=eg(()=>(e=>{if(!e.shuffleOptions)return e.choices;const t=e.choices;let i="";e.hasOpenChoice&&(i=t.pop());const s=Gg(t,Vg(t));return e.hasOpenChoice&&(e.choices.push(i),s.push(i)),s})(e),[e]),[d,h]=J_(()=>((e,t)=>Tt(e)||If(e)?e:t===gg.SingleChoice?null:[])(o,e.type)),[p,_]=J_(()=>((e,t)=>{if(Tt(e)&&!t.includes(e))return{isSelected:!0,inputValue:e};if(If(e)){const i=e.find(e=>!t.includes(e));if(i)return{isSelected:!0,inputValue:i}}return{isSelected:!1,inputValue:""}})(o,u)),{isPreviewMode:g}=Yg(),f=e.type===gg.SingleChoice,v=e.type===gg.MultipleChoice,m=e.skipSubmitButton&&f&&!e.hasOpenChoice,y=(e,t)=>{if(t){const e=!p.isSelected;return _(t=>ct(ct({},t),{},{isSelected:e,inputValue:e?t.inputValue:""})),f&&h(""),void(e&&setTimeout(()=>{var e;return null===(e=c.current)||void 0===e?void 0:e.focus()},75))}if(f)return h(e),_(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),void(m&&(n(e),g&&r(e)));v&&kt(d)&&(d.includes(e)?h(d.filter(t=>t!==e)):h([...d,e]))},b=e=>{e.stopPropagation();const t=e.currentTarget.value;_(e=>ct(ct({},e),{},{inputValue:t})),f&&h(t)},S=e=>{e.stopPropagation(),"Enter"!==e.key||w()||(e.preventDefault(),k()),"Escape"===e.key&&(e.preventDefault(),_(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),f&&h(null))},w=()=>!(e.optional||!Rt(d)&&(!kt(d)||p.isSelected||0!==d.length)&&(!p.isSelected||""!==p.inputValue.trim())),k=()=>{p.isSelected&&v?kt(d)&&(g?r([...d,p.inputValue]):n([...d,p.inputValue])):g?r(d):n(d)};return uf(b_,{children:[uf("div",{className:"question-container",children:[uf(wf,{question:e,forceDisableHtml:t}),uf("fieldset",{className:"multiple-choice-options limit-height",children:[uf("legend",{className:"sr-only",children:v?" Select all that apply":" Select one"}),u.map((t,s)=>{const n=!!e.hasOpenChoice&&s===e.choices.length-1,r=`surveyQuestion${i}Choice${s}`,o=`${r}Open`,a=n?p.isSelected:f?d===t:kt(d)&&d.includes(t);return uf("label",{className:n?"choice-option-open":"",children:[uf("div",{className:"response-choice",children:[uf("input",{type:f?"radio":"checkbox",name:r,checked:a,onChange:()=>y(t,n),id:r,"aria-controls":o}),uf("span",{children:n?`${t}:`:t})]}),n&&uf("input",{type:"text",ref:c,id:o,name:`question${i}Open`,value:p.inputValue,onKeyDown:S,onInput:b,onClick(e){p.isSelected||y(t,!0),e.stopPropagation()},"aria-label":`${t} - please specify`})]},s)})]})]}),uf(Sf,{text:e.buttonText||"Submit",submitDisabled:w(),appearance:s,onSubmit:k,onPreviewSubmit:k,skipSubmitButton:m,canGoBack:a,onBack:l})]})}const Lf=[1,2,3,4,5],Af=[1,2,3,4,5,6,7],Of=[0,1,2,3,4,5,6,7,8,9,10],Df={2:[ff,vf],3:[pf,hf,df],5:[_f,pf,hf,df,gf]};function $f(e){switch(e){case 5:default:return Lf;case 7:return Af;case 10:return Of}}const Nf=Gn("[Surveys]");function Bf(e,t,i){var s;const n=e.questions[t],r=t+1;if(!(null===(s=n.branching)||void 0===s?void 0:s.type))return t===e.questions.length-1?fg.End:r;if(n.branching.type===fg.End)return fg.End;if(n.branching.type===fg.SpecificQuestion){if(Number.isInteger(n.branching.index))return n.branching.index}else if(n.branching.type===fg.ResponseBased){if(n.type===gg.SingleChoice){var o;let e=n.choices.indexOf(`${i}`);if(-1===e&&n.hasOpenChoice&&(e=n.choices.length-1),null===(o=n.branching)||void 0===o||null===(o=o.responseValues)||void 0===o?void 0:o.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fg.End?fg.End:r}}else if(n.type===gg.Rating){var a;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");const e=function(e,t){if(2===t){if(1>e||e>2)throw new Error("The response must be in range 1-2");return 1===e?"positive":"negative"}if(3===t){if(1>e||e>3)throw new Error("The response must be in range 1-3");return 1===e?"negative":2===e?"neutral":"positive"}if(5===t){if(1>e||e>5)throw new Error("The response must be in range 1-5");return e>2?3===e?"neutral":"positive":"negative"}if(7===t){if(1>e||e>7)throw new Error("The response must be in range 1-7");return e>3?4===e?"neutral":"positive":"negative"}if(10===t){if(0>e||e>10)throw new Error("The response must be in range 0-10");return e>6?e>8?"promoters":"passives":"detractors"}throw new Error("The scale must be one of: 2, 3, 5, 7, 10")}(i,n.scale);if(null===(a=n.branching)||void 0===a||null===(a=a.responseValues)||void 0===a?void 0:a.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fg.End?fg.End:r}}return r}return Nf.warn("Falling back to next question index due to unexpected branching type"),r}const qf=Gn("[SurveyTranslations]");function Hf(e,t){const i=function(e){return function({overrideLanguage:e,storedPersonProperties:t,locale:i},s){const n=ol(e);if(n)return null==s||s.info(`Using override display language: ${n}`),n;const r=function(e){return e&&"object"==typeof e&&"language"in e?ol(e.language):null}(t);if(r)return null==s||s.info(`Using person property language: ${r}`),r;const o=ol(i);return o?(null==s||s.info(`Using detected locale: ${o}`),o):(null==s||s.info("No user language detected"),null)}({overrideLanguage:e.config.override_display_language,storedPersonProperties:Ct(e.get_property)?e.get_property(ae):void 0,locale:Fl()},qf)}(t);if(!i)return qf.info("No user language detected"),{survey:e,language:null};const s=ul(e,i,qf);return{survey:s.survey,language:s.matchedKey}}const Uf=e,Wf=s,zf="ph:show_survey_widget",jf="PHWidgetSurveyClickListener";function Vf(e,t){try{const i=e.getBoundingClientRect(),s=Uf.innerHeight,n=Uf.innerWidth;let r=i.left+i.width/2-t/2;r+t>n-20&&(r=n-t-20),20>r&&(r=20);const o=s-i.bottom,a=250>o&&i.top>o;return{position:"fixed",top:a?"auto":`${i.bottom+12}px`,left:`${r}px`,right:"auto",bottom:a?s-i.top+12+"px":"auto",zIndex:$g.zIndex}}catch(e){return wg.warn("Failed to calculate trigger position:",e),null}}var Gf=class{constructor(e){this._surveyTimeouts=new Map,this._widgetSelectorListeners=new Map,this._renderedTabWidgets=new Map,this._renderedTargets=new Map,this._prefillHandledSurveys=new Set,this._currentLanguage=null,this._surveyIsRendered=!1,this._languageChangeListener=null,this._unsubscribeFeatureFlags=null,this._surveyPopupProps=null,this._loggedFeatureFlagsDisabledWarning=!1,this.handlePageUnload=()=>{const e=this._posthog.get_property(ue);if(e)for(const t of e)rf(t)&&jg(t,this._posthog)},this.handlePopoverSurvey=(e,t,{resumeDelayFromActivation:i=!1}={})=>{var s,n,r,o,a,l;if(!Cg(this._posthog))return;const{survey:c,language:u}=this._translateSurveyForRendering(e);this._currentLanguage=u,this._surveyPopupProps=null,this._displayOptions=t;const d=this._applyDisplayOverrides(c,t);this._clearSurveyTimeout(d.id);const{properties:h,initialResponses:p}=null!=t?t:{},_=!(!p||0>=Object.keys(p).length)&&this._handleInitialResponses(d,p,h,u);if(_&&!(null===(s=d.appearance)||void 0===s?void 0:s.displayThankYouMessage))return;this._addSurveyToFocus(d);let g={};if((null===(n=d.appearance)||void 0===n?void 0:n.position)===hg.NextToTrigger&&(null===(r=d.appearance)||void 0===r?void 0:r.widgetSelector)){const e=Wf.querySelector(d.appearance.widgetSelector);var f;e&&(g=Vf(e,parseInt((null===(f=d.appearance)||void 0===f?void 0:f.maxWidth)||$g.maxWidth))||{})}const v=(null===(o=d.appearance)||void 0===o?void 0:o.surveyPopupDelaySeconds)||0,{shadow:m}=Hg(d,this._posthog);this._renderedTargets.set(m,m.host);const y={posthog:this._posthog,survey:d,removeSurveyFromFocus:this._removeSurveyFromFocus,properties:h,style:g,isSurveyCompleted:_,skipShownEvent:null==t?void 0:t.skipShownEvent,surveyLanguage:u};if(this._surveyPopupProps=y,0>=v)return this._surveyIsRendered=!0,q_(uf(Yf,ct({},y)),m);const b=()=>{this._surveyIsRendered=!0;const{survey:i,language:s}=this._translateSurveyForRendering(e);this._currentLanguage=s;const n=this._applyDisplayOverrides(i,t),r=ct(ct({},y),{},{survey:n,surveyLanguage:s});this._surveyPopupProps=r,q_(uf(Yf,ct(ct({},r),{},{survey:ct(ct({},n),{},{appearance:ct(ct({},n.appearance),{},{surveyPopupDelaySeconds:0})})})),m)},S=()=>{if(!Cg(this._posthog)||!this._shouldDisplaySurvey(d))return wg.info(`Survey ${d.id} no longer eligible when its display delay elapsed; not displaying`),this._removeSurveyFromFocus(d);b()},w=i?null===(a=this._posthog.surveys)||void 0===a||null===(a=a._surveyEventReceiver)||void 0===a||null===(l=a.getActivationTimestamp)||void 0===l?void 0:l.call(a,d.id):void 0,k=Ft(w)?Math.max(0,Date.now()-w):0,C=Math.max(0,1e3*v-k);if(0>=C)return S();const E=Uf.setTimeout(()=>{this._surveyTimeouts.delete(d.id),S()},C);this._surveyTimeouts.set(d.id,E)},this._handleWidget=e=>{var t;const{survey:i,language:s}=this._translateSurveyForRendering(e),{shadow:n,isNewlyCreated:r}=Hg(i,this._posthog);this._renderedTargets.set(n,n.host),(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===dg.Tab&&this._renderedTabWidgets.set(e.id,e),r&&q_(uf(ev,{posthog:this._posthog,survey:i,surveyLanguage:s},e.id),n)},this._detachWidgetSelectorListener=e=>{const t=this._widgetSelectorListeners.get(e);t&&(t.element.removeEventListener("click",t.listener),t.element.removeAttribute(jf),this._widgetSelectorListeners.delete(e),wg.info(`Removed click listener for survey ${e}`))},this._removeWidgetSelectorListener=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._detachWidgetSelectorListener(e.id))},this._removeTabWidget=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._renderedTabWidgets.delete(e.id))},this._isWidgetSurveyOpen=e=>{try{var t;const i=Wf.querySelector(af(e,!0));return!!(null==i||null===(t=i.shadowRoot)||void 0===t?void 0:t.querySelector(".ph-survey"))}catch(e){return!1}},this._manageWidgetSelectorListener=(e,t)=>{const i=Wf.querySelector(t),s=this._widgetSelectorListeners.get(e.id);if(i){if(this._handleWidget(e),s){if(i===s.element)return;wg.info(`Selector element changed for survey ${e.id}. Re-attaching listener.`),this._detachWidgetSelectorListener(e.id)}if(!i.hasAttribute(jf)){const t=t=>{var i,s;t.stopPropagation();const n=(null===(i=e.appearance)||void 0===i?void 0:i.position)===hg.NextToTrigger?Vf(t.currentTarget,parseInt((null===(s=e.appearance)||void 0===s?void 0:s.maxWidth)||$g.maxWidth)):{};Uf.dispatchEvent(new CustomEvent(zf,{detail:{surveyId:e.id,position:n}}))};sr(i,"click",t),i.setAttribute(jf,"true"),this._widgetSelectorListeners.set(e.id,{element:i,listener:t,survey:e}),wg.info(`Attached click listener for feedback button survey ${e.id}`)}}else s&&this._removeWidgetSelectorListener(e)},this.renderPopover=e=>{if(!Cg(this._posthog))return;const{survey:t,language:i}=this._translateSurveyForRendering(e),{shadow:s}=Hg(t,this._posthog);this._renderedTargets.set(s,s.host),q_(uf(Yf,{posthog:this._posthog,survey:t,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:i}),s)},this.renderSurvey=(e,t,i)=>{var s;if(!Cg(this._posthog))return;const{survey:n,language:r}=this._translateSurveyForRendering(e);let o=!1;(null===(s=this._posthog.config)||void 0===s||null===(s=s.surveys)||void 0===s?void 0:s.prefillFromUrl)&&(o=this._handleUrlPrefill(n,r,i)),q_(uf(Yf,{posthog:this._posthog,survey:n,removeSurveyFromFocus:this._removeSurveyFromFocus,isPopup:!1,properties:i,isSurveyCompleted:o,surveyLanguage:r}),t)},this.getActiveMatchingSurveys=(e,t=!1)=>{var i;null===(i=this._posthog)||void 0===i||null===(i=i.surveys)||void 0===i||i.getSurveys(t=>{e(t.filter(e=>this._shouldDisplaySurvey(e)))},t)},this.callSurveysAndEvaluateDisplayLogic=(e=!1)=>{this.getActiveMatchingSurveys(e=>{const t=Cg(this._posthog),i=e.filter(e=>t&&(e.type===_g.Popover||e.type===_g.Widget)),s=new Set(i.map(e=>e.id));for(const e of Array.from(this._surveyTimeouts.keys()))s.has(e)||this.cancelSurvey(e);const n=this._sortSurveysByAppearanceDelay(i),r=new Set,o=new Set;n.forEach(e=>{if(e.type===_g.Widget){var t,i,s,n;if((null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===dg.Tab)return o.add(e.id),void this._handleWidget(e);(null===(i=e.appearance)||void 0===i?void 0:i.widgetType)===dg.Selector&&(null===(s=e.appearance)||void 0===s?void 0:s.widgetSelector)&&(r.add(e.id),this._manageWidgetSelectorListener(e,null===(n=e.appearance)||void 0===n?void 0:n.widgetSelector))}Rt(this._surveyInFocus)&&e.type===_g.Popover&&this.handlePopoverSurvey(e,void 0,{resumeDelayFromActivation:!0})}),this._widgetSelectorListeners.forEach(({survey:e})=>{r.has(e.id)||this._removeWidgetSelectorListener(e)}),this._renderedTabWidgets.forEach((e,t)=>{o.has(t)||this._removeTabWidget(e)})},e)},this._addSurveyToFocus=e=>{Rt(this._surveyInFocus)||wg.error(`Survey ${this._surveyInFocus} already in focus. Cannot add survey ${e.id}.`),this._surveyInFocus=e.id},this._removeSurveyFromFocus=e=>{this._surveyInFocus!==e.id&&wg.error(`Survey ${e.id} is not in focus. Cannot remove survey ${e.id}.`),this._clearSurveyTimeout(e.id),this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0,this._removeSurveyFromDom(e)},this._posthog=e,this._surveyInFocus=null,this._languageChangeListener=()=>this._onLanguageChange(),sr(Uf,"languagechange",this._languageChangeListener),this._unsubscribeFeatureFlags=e.onFeatureFlags(()=>this._onLanguageChange())}_onLanguageChange(){if(Rt(this._surveyInFocus))return;const e=this._posthog.get_property(ue),t=null==e?void 0:e.find(e=>e.id===this._surveyInFocus);if(!t)return;const{survey:i,language:s}=this._translateSurveyForRendering(t);if(s===this._currentLanguage)return;if(this._currentLanguage=s,!this._surveyIsRendered)return;const n=this._applyDisplayOverrides(i,this._displayOptions),{shadow:r}=Hg(n,this._posthog);q_(uf(Yf,ct(ct({},this._surveyPopupProps),{},{posthog:this._posthog,survey:n,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:s})),r)}get _featureFlags(){var e,t,i;return null!==(e=null===(t=(i=this._posthog).getExtension)||void 0===t?void 0:t.call(i,"featureFlags"))&&void 0!==e?e:this._posthog.featureFlags}_applyDisplayOverrides(e,t){return(null==t?void 0:t.position)||(null==t?void 0:t.selector)?ct(ct({},e),{},{appearance:ct(ct(ct({},e.appearance),t.position&&{position:t.position}),t.selector&&{widgetSelector:t.selector})}):e}_clearSurveyTimeout(e){const t=this._surveyTimeouts.get(e);t&&(clearTimeout(t),this._surveyTimeouts.delete(e))}cancelSurvey(e){this._surveyTimeouts.has(e)&&(wg.info(`Cancelled pending survey ${e}`),this._clearSurveyTimeout(e),this._surveyInFocus===e&&(this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0))}setAutomaticDisplayDispose(e){this._automaticDisplayDispose=e}dispose(){var e;null===(e=this._automaticDisplayDispose)||void 0===e||e.call(this),this._automaticDisplayDispose=void 0,this._languageChangeListener&&(Uf.removeEventListener("languagechange",this._languageChangeListener),this._languageChangeListener=null),this._unsubscribeFeatureFlags&&(this._unsubscribeFeatureFlags(),this._unsubscribeFeatureFlags=null),this._surveyTimeouts.forEach((e,t)=>this._clearSurveyTimeout(t)),this._widgetSelectorListeners.forEach((e,t)=>this._detachWidgetSelectorListener(t)),this._renderedTargets.forEach((e,t)=>{q_(null,t),null==e||e.remove()}),this._renderedTargets.clear(),this._renderedTabWidgets.clear(),this._surveyInFocus=null}_sortSurveysByAppearanceDelay(e){return e.sort((e,t)=>{var i,s;const n=rf(e),r=rf(t);if(n&&!r)return-1;if(!n&&r)return 1;const o=e.schedule===vg.Always,a=t.schedule===vg.Always;return o&&!a?1:!o&&a?-1:((null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)||0)-((null===(s=t.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds)||0)})}_translateSurveyForRendering(e){return Hf(e,this._posthog)}_handleUrlPrefill(e,t,i){if(this._prefillHandledSurveys.has(e.id))return!1;const{params:s}=function(){const e={};let t=!1;const i=Uf.location.search.replace(/^\?/,"");if(!i)return{params:e,autoSubmit:t};const s=i.split("&");for(const i of s){const[s,n]=i.split("=");if(!s||It(n))continue;const r=decodeURIComponent(s),o=decodeURIComponent(n);if("auto_submit"===r&&"true"===o){t=!0;continue}const a=r.match(/^q(\d+)$/);if(a){const t=parseInt(a[1],10);e[t]||(e[t]=[]),e[t].push(o)}}return{params:e,autoSubmit:t}}();if(0===Object.keys(s).length)return!1;wg.info("[Survey Prefill] Detected URL prefill parameters");const n=this._processPrefillData(e,s,t);return!!n&&(this._autoSubmitPrefilledResponses(e,n,i,t),this._prefillHandledSurveys.add(e.id),n.isSurveyCompleted)}_autoSubmitPrefilledResponses(e,t,i,s){const{responses:n,submissionId:r,isSurveyCompleted:o,skippedResponses:a}=t;(Object.keys(a).length>0&&e.enable_partial_responses||o)&&Ug({responses:o?n:a,survey:e,surveySubmissionId:r,posthog:this._posthog,isSurveyCompleted:o,properties:i,surveyLanguage:s})}_handleInitialResponses(e,t,i,s){const n={};for(const[e,i]of Object.entries(t))n[parseInt(e)]=kt(i)?i.map(String):[String(i)];wg.info("[Survey] Processing initial responses");const r=this._processPrefillData(e,n,s);return!!r&&(this._autoSubmitPrefilledResponses(e,r,i,s),r.isSurveyCompleted)}_processPrefillData(e,t,i){try{const s=function(e,t){const i={};return e.questions.forEach((e,s)=>{if(!t[s]||!e.id)return;const n=t[s],r=tl(e.id);try{switch(e.type){case gg.SingleChoice:{if(!e.choices||0===e.choices.length)return void Vn.warn(`[Survey Prefill] Question ${s} has no choices`);const t=parseInt(n[0],10);if(isNaN(t)||0>t||t>=e.choices.length)return void Vn.warn(`[Survey Prefill] Invalid choice index for q${s}: ${n[0]}`);i[r]=e.choices[t];break}case gg.MultipleChoice:{if(!e.choices||0===e.choices.length)return void Vn.warn(`[Survey Prefill] Question ${s} has no choices`);const t=n.map(e=>parseInt(e,10)).filter(t=>!isNaN(t)&&t>=0&&e.choices.length>t);if(0===t.length)return void Vn.warn(`[Survey Prefill] No valid choices for q${s}`);const o=[...new Set(t.map(t=>e.choices[t]))];t.length>o.length&&Vn.warn(`[Survey Prefill] Removed duplicate choices for q${s}`),i[r]=o;break}case gg.Rating:{const t=parseInt(n[0],10),o=e.scale||10;if(isNaN(t)||0>t||t>o)return void Vn.warn(`[Survey Prefill] Invalid rating for q${s}: ${n[0]} (scale: 0-${o})`);i[r]=t;break}default:Vn.info(`[Survey Prefill] Question type ${e.type} does not support prefill`)}}catch(e){Vn.error(`[Survey Prefill] Error converting q${s}:`,e)}}),i}(e,t);if(0===Object.keys(s).length)return wg.warn("[Survey Prefill] No valid responses after conversion"),null;const n=Ra(),{startQuestionIndex:r,skippedResponses:o,skippedIndices:a}=function(e,t,i){let s=0;const n={},r=[],o=e.questions.length+1;let a=0;for(;e.questions.length>s&&o>a&&(a++,t.includes(s));){const t=e.questions[s];if(!t||!("skipSubmitButton"in t)||!t.skipSubmitButton)break;if(t.id){const e=tl(t.id);It(i[e])||(n[e]=i[e])}r.push(s);const o=Bf(e,s,t.id?i[tl(t.id)]:null);if(o===fg.End)return{startQuestionIndex:e.questions.length,skippedResponses:n,skippedIndices:r};s=o}return{startQuestionIndex:s,skippedResponses:n,skippedIndices:r}}(e,Object.keys(t).map(e=>parseInt(e,10)),s),l=r>=e.questions.length;return sf(e,{surveySubmissionId:n,responses:s,lastQuestionIndex:r,questionOrder:Qg(e.questions),visitedIndices:a,surveyLanguage:i}),wg.info("[Survey Prefill] Stored prefilled responses in localStorage"),{responses:s,submissionId:n,startQuestionIndex:r,isSurveyCompleted:l,skippedResponses:o}}catch(e){return wg.error("[Survey Prefill] Error handling prefill:",e),null}}_isSurveyFeatureFlagEnabled(e,t=void 0){if(!e)return!0;const i=this._featureFlags,s=!!(null==i?void 0:i.isFeatureEnabled(e,{send_event:!e.startsWith("survey-targeting-")}));let n=!0;t&&(n=(null==i?void 0:i.getFeatureFlag(e,{send_event:!1}))===t||"any"===t);const r=s&&n;return r||this._warnIfFeatureFlagsDisabled(e),r}_warnIfFeatureFlagsDisabled(e){var t;!this._loggedFeatureFlagsDisabledWarning&&(null===(t=this._posthog.config)||void 0===t?void 0:t.advanced_disable_feature_flags)&&(this._loggedFeatureFlagsDisabledWarning=!0,wg.warn(`Survey feature flag "${e}" evaluated to false because advanced_disable_feature_flags is set. PostHog creates an internal targeting flag for almost every survey, so no survey can display while flags are disabled. To keep surveys working, replace advanced_disable_feature_flags with advanced_only_evaluate_survey_feature_flags, which evaluates survey flags only.`))}_isSurveyConditionMatched(t){return!t.conditions||ef(t,this._posthog)&&function(t){var s,n;return function(t,s){var n,r,o;if(!t||0===t.length)return!0;if(!c)return!1;const a=Zi(c,{userAgentDataPlatform:null==i||null===(n=i.userAgentData)||void 0===n?void 0:n.platform,maxTouchPoints:null==i?void 0:i.maxTouchPoints,screenWidth:null==e||null===(r=e.screen)||void 0===r?void 0:r.width,screenHeight:null==e||null===(o=e.screen)||void 0===o?void 0:o.height,devicePixelRatio:null==e?void 0:e.devicePixelRatio});return gl[null!=s?s:"icontains"](t,[a])}(null===(s=t.conditions)||void 0===s?void 0:s.deviceTypes,null===(n=t.conditions)||void 0===n?void 0:n.deviceTypesMatchType)}(t)&&function(e){var t;return!(null===(t=e.conditions)||void 0===t?void 0:t.selector)||!!(null==Og?void 0:Og.querySelector(e.conditions.selector))}(t)}_internalFlagCheckSatisfied(e){var t;return Zg(e)?{satisfied:!0}:e.internal_targeting_flag_key&&function(e){var t;return"recurring"===e.schedule||(null!==(t=e.current_iteration)&&void 0!==t?t:0)>0}(e)&&!(null===(t=this._featureFlags)||void 0===t?void 0:t.hasLoadedFlags)?(this._warnIfFeatureFlagsDisabled(e.internal_targeting_flag_key),{satisfied:!1,reason:"Feature flags have not loaded yet; deferring internal targeting flag check"}):{satisfied:this._isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key)}}checkSurveyEligibility(e){var t,i;const s={eligible:!0,reason:void 0};if(!Eg(e))return s.eligible=!1,s.reason=`Survey is not running. It was completed on ${e.end_date}`,s;if(!Rg.includes(e.type))return s.eligible=!1,s.reason=`Surveys of type ${e.type} are never eligible to be shown in the app`,s;const n=null===(t=e.conditions)||void 0===t?void 0:t.linkedFlagVariant;if(!this._isSurveyFeatureFlagEnabled(e.linked_flag_key,n))return s.eligible=!1,s.reason=n?`Survey linked feature flag is not enabled for variant ${n}`:"Survey linked feature flag is not enabled",s;if(!this._isSurveyFeatureFlagEnabled(e.targeting_flag_key))return s.eligible=!1,s.reason="Survey targeting feature flag is not enabled",s;const r=this._internalFlagCheckSatisfied(e);var o;return r.satisfied?function(e,t){if(!e||!t)return!0;const i="string"==typeof t?new Date(t):t,s=Math.abs((new Date).getTime()-i.getTime());return Math.ceil(s/864e5)>e}(null===(i=e.conditions)||void 0===i?void 0:i.seenSurveyWaitPeriodInDays,$a._get("lastSeenSurveyDate"))?(e=>!!$a._get(Tg(e))&&!Zg(e))(e)?(s.eligible=!1,s.reason="Survey has already been seen and it can't be activated again",s):s:(s.eligible=!1,s.reason="Survey wait period has not passed",s):(s.eligible=!1,s.reason=null!==(o=r.reason)&&void 0!==o?o:"Survey internal targeting flag is not enabled and survey cannot activate repeatedly and survey is not in progress",s)}checkSurveyCaptureEligibility(){return Cg(this._posthog)?{eligible:!0}:{eligible:!1,reason:kg}}checkSurveyDisplayEligibility(e){const t=this.checkSurveyCaptureEligibility();return t.eligible?this.checkSurveyEligibility(e):t}checkSurveyRenderability(e){const t=this.checkSurveyDisplayEligibility(e);return t.eligible&&!this._hasActionOrEventTriggeredSurvey(e)?{eligible:!1,reason:"Survey event/action trigger has not been fired yet"}:t}_hasActionOrEventTriggeredSurvey(e){var t;if(!dl(e)&&!xg(e))return!0;const i=null===(t=this._posthog.surveys)||void 0===t||null===(t=t._surveyEventReceiver)||void 0===t?void 0:t.getSurveys();return!!(null==i?void 0:i.includes(e.id))}_checkFlags(e){var t;return!(null===(t=e.feature_flag_keys)||void 0===t?void 0:t.length)||e.feature_flag_keys.every(({key:e,value:t})=>!e||!t||this._isSurveyFeatureFlagEnabled(t))}_shouldDisplaySurvey(e){return this.checkSurveyEligibility(e).eligible&&this._isSurveyConditionMatched(e)&&this._hasActionOrEventTriggeredSurvey(e)&&this._checkFlags(e)}_removeSurveyFromDom(e){try{const t=Wf.querySelector(af(e,!0));(null==t?void 0:t.shadowRoot)&&(q_(null,t.shadowRoot),this._renderedTargets.delete(t.shadowRoot)),null==t||t.remove()}catch(t){wg.warn(`Failed to remove survey ${e.id} from DOM:`,t)}}getTestAPI(){return{addSurveyToFocus:this._addSurveyToFocus,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyInFocus:this._surveyInFocus,surveyTimeouts:this._surveyTimeouts,handleWidget:this._handleWidget,handlePopoverSurvey:this.handlePopoverSurvey,manageWidgetSelectorListener:this._manageWidgetSelectorListener,sortSurveysByAppearanceDelay:this._sortSurveysByAppearanceDelay,checkFlags:this._checkFlags.bind(this),isSurveyFeatureFlagEnabled:this._isSurveyFeatureFlagEnabled.bind(this),onLanguageChange:this._onLanguageChange.bind(this),currentLanguage:this._currentLanguage,surveyIsRendered:this._surveyIsRendered}}};function Qf(e,t){if(!Wf||!Uf)return;const i=new Gf(e);if(e.config.disable_surveys_automatic_display)return wg.info("Surveys automatic display is disabled. Skipping call surveys and evaluate display logic."),i;if(!1===t)return wg.info("There are no surveys to load or Surveys is disabled in the project settings."),i;let s;i.callSurveysAndEvaluateDisplayLogic(!0);const n=()=>{It(s)&&(s=setInterval(()=>{i.callSurveysAndEvaluateDisplayLogic(!1)},1e3))},r=()=>{It(s)||(clearInterval(s),s=void 0)};n();const o=()=>{Wf.hidden?r():(i.callSurveysAndEvaluateDisplayLogic(!1),n())};return sr(Wf,"visibilitychange",o),i.setAutomaticDisplayDispose(()=>{r(),Wf.removeEventListener("visibilitychange",o)}),i}function Kf({survey:e,removeSurveyFromFocus:t=()=>{},setSurveyVisible:i,isPreviewMode:s=!1,posthog:n}){Y_(()=>{var r;if(s||!(null===(r=e.conditions)||void 0===r?void 0:r.url))return;const o=()=>{var s;const r=e.type===_g.Widget,o=ef(e,n),a=(null===(s=e.appearance)||void 0===s?void 0:s.widgetType)===dg.Tab&&r;if(!o)return wg.info(`Hiding survey ${e.id} because URL does not match`),i(!1),t(e);a&&(wg.info(`Showing survey ${e.id} because it is a feedback button tab and URL matches`),i(!0))};sr(Uf,"popstate",o),sr(Uf,"hashchange",o);const a=Uf.history.pushState,l=Uf.history.replaceState;return Uf.history.pushState=function(...e){a.apply(this,e),o()},Uf.history.replaceState=function(...e){l.apply(this,e),o()},()=>{Uf.removeEventListener("popstate",o),Uf.removeEventListener("hashchange",o),Uf.history.pushState=a,Uf.history.replaceState=l}},[s,e,t,i,n])}const Zf=200;function Jf(e=pg.Right){switch(e){case pg.Top:return{top:"0",left:"50%",transform:"translateX(-50%)"};case pg.Left:return{top:"50%",left:"0",transform:"rotate(90deg) translateY(-100%)",transformOrigin:"left top"};case pg.Bottom:return{bottom:"0",left:"50%",transform:"translateX(-50%)"};default:return{top:"50%",right:"0",transform:"rotate(-90deg) translateY(-100%)",transformOrigin:"right top"}}}function Yf({survey:e,forceDisableHtml:t,posthog:i,style:s={},previewPageIndex:n,removeSurveyFromFocus:r=()=>{},isPopup:o=!0,onPreviewSubmit:a=()=>{},onPreviewBack:l=()=>{},onPopupSurveyDismissed:c=()=>{},onCloseConfirmationMessage:u=()=>{},properties:d,isSurveyCompleted:h,skipShownEvent:p,surveyLanguage:_}){var g,f,v,m,y,b,S,w,k,C,E,x;const I=X_(null),T=Number.isInteger(n),{isPopupVisible:M,isSurveySent:R,hidePopupWithAnimation:P}=function(e,t,i,s,n,r,o,a,l){const[c,u]=J_(s||0===i||e.type===_g.ExternalSurvey),[d,h]=J_(!1),p=X_(!1),_=()=>{const t=()=>{r&&n(e),u(!1)};if(p.current)return;const i=null==o?void 0:o.current;i?(p.current=!0,i.style.transition=`opacity ${Zf}ms ease-out`,i.style.opacity="0",setTimeout(()=>{p.current=!1,t()},250)):t()},g=t=>{t.detail.surveyId===e.id&&_()};return Y_(()=>{if(!t)return void wg.error("usePopupVisibility hook called without a PostHog instance.");if(s)return;let n;const r=t=>{var i,s;if(t.detail.surveyId===e.id){if(!(null===(i=e.appearance)||void 0===i?void 0:i.displayThankYouMessage))return _();h(!0),(null===(s=e.appearance)||void 0===s?void 0:s.autoDisappear)&&(n&&clearTimeout(n),n=setTimeout(_,5e3))}},o=()=>{if(ef(e,t)){var i;u(!0),Uf.dispatchEvent(new Event("PHSurveyShown")),a||t.capture(mg.SHOWN,ct(ct({[yg.SURVEY_NAME]:e.name,[yg.SURVEY_ID]:e.id,[yg.SURVEY_ITERATION]:e.current_iteration,[yg.SURVEY_ITERATION_START_DATE]:e.current_iteration_start_date},l&&{[yg.SURVEY_LANGUAGE]:l}),{},{sessionRecordingUrl:null===(i=t.get_session_replay_url)||void 0===i?void 0:i.call(t)}));try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}};sr(Uf,"PHSurveyClosed",g),sr(Uf,"PHSurveySent",r);const c=i>0?setTimeout(o,i):void 0;return It(c)&&o(),()=>{It(c)||clearTimeout(c),It(n)||clearTimeout(n),Uf.removeEventListener("PHSurveyClosed",g),Uf.removeEventListener("PHSurveySent",r)}},[]),Kf({survey:e,removeSurveyFromFocus:n,setSurveyVisible:u,isPreviewMode:s,posthog:t}),{isPopupVisible:c,isSurveySent:d,setIsPopupVisible:u,hidePopupWithAnimation:_}}(e,i,(null===(g=e.appearance)||void 0===g?void 0:g.surveyPopupDelaySeconds)?1e3*e.appearance.surveyPopupDelaySeconds:0,T,r,o,I,p,_),F=R||n===e.questions.length||!0===h,[L,A]=J_(!1),O=eg(()=>!!nf(e),[e]),D=!(!(null===(f=e.appearance)||void 0===f?void 0:f.introScreenHeader)&&!(null===(v=e.appearance)||void 0===v?void 0:v.introScreenDescription)),N=T?-1===n:!!(null===(m=e.appearance)||void 0===m?void 0:m.displayIntroScreen)&&D&&!L&&!O,B=eg(()=>{const t=nf(e),s=(null==t?void 0:t.surveySubmissionId)||Ra();return{isPreviewMode:T,previewPageIndex:n,onPopupSurveyDismissed(){_?zg(e,i,T,_):zg(e,i,T),c()},isPopup:o||!1,surveySubmissionId:s,onPreviewSubmit:a,onPreviewBack:l,posthog:i,properties:d,surveyLanguage:_}},[T,n,o,i,e,c,a,l,d,_]);return M?uf(Jg.Provider,{value:B,children:uf("div",{className:"ph-survey",style:ct(ct({},lf(e.type,null===(y=e.appearance)||void 0===y?void 0:y.position,null===(b=e.appearance)||void 0===b?void 0:b.widgetType)),s),ref:I,children:F?uf(Ef,{header:(null===(S=e.appearance)||void 0===S?void 0:S.thankYouMessageHeader)||"Thank you!",description:(null===(w=e.appearance)||void 0===w?void 0:w.thankYouMessageDescription)||"",forceDisableHtml:!!t,contentType:null===(k=e.appearance)||void 0===k?void 0:k.thankYouMessageDescriptionContentType,appearance:e.appearance||$g,onClose(){P(),u()}}):N?uf(xf,{header:(null===(C=e.appearance)||void 0===C?void 0:C.introScreenHeader)||"",description:(null===(E=e.appearance)||void 0===E?void 0:E.introScreenDescription)||"",forceDisableHtml:!!t,contentType:null===(x=e.appearance)||void 0===x?void 0:x.introScreenDescriptionContentType,appearance:e.appearance||$g,onStart:()=>A(!0)}):uf(Xf,{survey:e,forceDisableHtml:!!t,posthog:i})})}):null}function Xf({survey:e,forceDisableHtml:t,posthog:i}){var s,n;const r=eg(()=>{const t=nf(e);if(!t)return null;const i=Ft(t.lastQuestionIndex);return!i||i&&t.lastQuestionIndex>=0&&e.questions.length>t.lastQuestionIndex?t:(of(e),null)},[e]),[o,a]=J_(()=>((null==r?void 0:r.responses)&&wg.info("Survey is already in progress, filling in initial responses"),(null==r?void 0:r.responses)||{})),[l,c]=J_(!1),{previewPageIndex:u,onPopupSurveyDismissed:d,isPopup:h,onPreviewSubmit:p,onPreviewBack:_,surveySubmissionId:g,isPreviewMode:f,properties:v,surveyLanguage:m}=tg(Jg),[y,b]=J_(()=>{const t=null==r?void 0:r.lastQuestionIndex,i=Ft(t)&&t>=0&&e.questions.length>t?t:0;return Ft(u)&&u>=0?u:i}),[S,w]=J_(()=>{var t;return(null!==(t=null==r?void 0:r.visitedIndices)&&void 0!==t?t:[]).filter(t=>t>=0&&e.questions.length>t)}),[k,C]=J_(()=>{var t;const i=nf(e);return null!==(t=null==i?void 0:i.questionSnapshots)&&void 0!==t?t:{}}),E=eg(()=>Qg(Kg(e,r)),[e.id,r]),x=eg(()=>{if(!E||new Set(E).size!==E.length)return Kg(e,r);const t=new Map(e.questions.map(e=>[e.id,e])),i=E.map(e=>t.get(e)).filter(e=>!!e);return i.length===E.length?i:e.questions},[E,e.questions,e,r]);Y_(()=>{!f||It(u)||0>u||b(u)},[u,f]);const I=!!(null===(s=e.appearance)||void 0===s?void 0:s.allowGoBack)&&(f?(null!=u?u:0)>0:S.length>0),T=x.at(y);return T?uf("form",{className:"survey-form",name:"surveyForm",children:[h&&!0!==(null===(n=e.appearance)||void 0===n?void 0:n.hideCancelButton)&&uf(kf,{onClick(){d()}}),uf("div",{className:"survey-box","data-question-index":y,children:[l&&uf("p",{role:"alert",children:"Your response could not be sent. Please try again later."}),tv({question:T,forceDisableHtml:t,displayQuestionIndex:y,appearance:e.appearance||$g,onSubmit:t=>(({res:t,displayQuestionIndex:s,questionId:n})=>{if(!i)return void wg.error("onNextButtonClick called without a PostHog instance.");if(!Cg(i))return void c(!0);if(c(!1),!n)return void wg.error("onNextButtonClick called without a questionId.");const r=tl(n),l=ct(ct({},o),{},{[r]:t});a(l);const u=x[s],d=(null==u?void 0:u.id)?ct(ct({},k),{},{[u.id]:u.question}):k;C(d);const h=Bf(e,s,t),p=h===fg.End,_=[...S,s];if(p||(w(_),b(h),sf(e,{surveySubmissionId:g,responses:l,lastQuestionIndex:h,questionOrder:Qg(x),visitedIndices:_,surveyLanguage:m,questionSnapshots:d})),e.enable_partial_responses||p){const t=new Set(_.map(e=>{var t;return null===(t=x[e])||void 0===t?void 0:t.id}).filter(e=>!!e).map(e=>tl(e))),s=Object.fromEntries(Object.entries(l).filter(([e])=>t.has(e)));Ug({responses:s,survey:e,surveySubmissionId:g,isSurveyCompleted:p,posthog:i,properties:v,surveyLanguage:m,questionSnapshots:d})}})({res:t,displayQuestionIndex:y,questionId:T.id}),onPreviewSubmit:p,initialValue:T.id?o[tl(T.id)]:void 0,canGoBack:I,onBack(){if(f)return void _();if(0===S.length)return;const t=S[S.length-1],i=S.slice(0,-1);w(i),b(t),sf(e,{surveySubmissionId:g,responses:o,lastQuestionIndex:t,questionOrder:Qg(x),visitedIndices:i,surveyLanguage:m,questionSnapshots:k})}})]})]}):null}function ev({survey:e,forceDisableHtml:t,posthog:i,readOnly:s,surveyLanguage:n}){var r,o,a,l,c,u,d;const[h,p]=J_(!0),[_,g]=J_(!1),[f,v]=J_({}),m=X_(void 0),y=()=>{(_||!i||s||Cg(i))&&g(!_)};if(Y_(()=>{var t;if(!i)return void wg.error("FeedbackWidget called without a PostHog instance.");if(s)return;"tab"===(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)&&v({top:"50%",bottom:"auto"});const n=t=>{var i;const s=t;(null===(i=s.detail)||void 0===i?void 0:i.surveyId)===e.id&&(wg.info(`Received show event for feedback button survey ${e.id}`),v(s.detail.position||{}),y())};return sr(Uf,zf,n),()=>{It(m.current)||(clearTimeout(m.current),m.current=void 0),Uf.removeEventListener(zf,n)}},[i,s,e.id,null===(r=e.appearance)||void 0===r?void 0:r.widgetType,null===(o=e.appearance)||void 0===o?void 0:o.widgetSelector,null===(a=e.appearance)||void 0===a?void 0:a.borderColor]),Kf({survey:e,setSurveyVisible:p,posthog:i}),!h)return null;const b=()=>{e.schedule!==vg.Always&&p(!1),It(m.current)||clearTimeout(m.current),m.current=setTimeout(()=>{m.current=void 0,g(!1)},200)};return uf(b_,{children:["tab"===(null===(l=e.appearance)||void 0===l?void 0:l.widgetType)&&uf("button",{className:"ph-survey-widget-tab "+((null===(c=e.appearance)||void 0===c?void 0:c.tabPosition)===pg.Top?"widget-tab-top":""),onClick:y,disabled:s,style:Jf(null===(u=e.appearance)||void 0===u?void 0:u.tabPosition),children:(null===(d=e.appearance)||void 0===d?void 0:d.widgetLabel)||""}),_&&uf(Yf,{posthog:i,survey:e,forceDisableHtml:t,style:f,onPopupSurveyDismissed:b,onCloseConfirmationMessage:b,surveyLanguage:n})]})}const tv=({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:s,onSubmit:n,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l})=>{const c={forceDisableHtml:t,appearance:s,onPreviewSubmit(e){r(e)},onSubmit(e){n(e)},initialValue:o,displayQuestionIndex:i,canGoBack:a,onBack:l};switch(e.type){case gg.Open:return m_(Tf,ct(ct({},c),{},{question:e,key:e.id}));case gg.Link:return m_(Mf,ct(ct({},c),{},{question:e,key:e.id}));case gg.Rating:return m_(Rf,ct(ct({},c),{},{question:e,key:e.id}));case gg.SingleChoice:case gg.MultipleChoice:return m_(Ff,ct(ct({},c),{},{question:e,key:e.id}));default:return wg.error(`Unsupported question type: ${e.type}`),null}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.generateSurveys=Qf,h.extendPostHogWithSurveys=Qf;const iv=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},sv=1e4,nv=(e,t,i)=>i.remaining>0?t.length>i.remaining?(e.push(t.slice(0,i.remaining)),i.remaining=0,i.truncated=!0,!1):(e.push(t),i.remaining-=t.length,!0):(i.truncated=!0,!1),rv=(e,t,i)=>{const s=JSON.stringify(e);if(i.remaining>=s.length)return nv(t,s,i);if(i.truncated=!0,2>i.remaining)return!1;let n=0,r=Math.min(e.length,i.remaining-2);for(;r>n;){const t=Math.ceil((n+r)/2);JSON.stringify(e.slice(0,t)).length>i.remaining?r=t-1:n=t}return nv(t,JSON.stringify(e.slice(0,n)),i)},ov=e=>void 0!==e&&"function"!=typeof e&&"symbol"!=typeof e&&"bigint"!=typeof e,av=(e,t,i)=>{if(!i.truncated){if(i.keysRemaining-=1,i.sizeRemaining-=String(t).length+e.length,0>=i.keysRemaining||0>=i.sizeRemaining)return i.truncated=!0,void(i.result.attributes_truncated=!0);i.result[e]=t}},lv=(e,t,i)=>{if(!i.truncated)if(Et(e)){if(i.seen.has(e))return void av(t||"circular","[Circular]",i);i.seen.add(e);try{for(const s in e)try{if(!{}.hasOwnProperty.call(e,s))continue;if(lv(e[s],t?`${t}.${s}`:s,i),i.truncated)return}catch(e){continue}}catch(e){}}else av(t,e,i)},cv=(e,t,i,s,n=!1,r)=>{if(!ov(e))return!n||nv(t,"null",i);if(Rt(e)||(e=>{try{return Ft(e)||At(e)}catch(e){return!1}})(e))return nv(t,JSON.stringify(e),i);if("string"==typeof e)return rv(e,t,i);if(!Et(e)&&!kt(e))return nv(t,JSON.stringify(e),i);if(s.has(e))return rv("[Circular]",t,i);s.add(e);try{const r=e.toJSON;if(Ct(r))return cv(r.call(e),t,i,s,n)}catch(e){}try{const s={}.toString.call(e);if("[object String]"===s)return rv(String(e.valueOf()),t,i);if("[object Number]"===s||"[object Boolean]"===s)return nv(t,JSON.stringify(e.valueOf()),i)}catch(e){}if(e instanceof Error){const o={};try{for(const t in e)({}).hasOwnProperty.call(e,t)&&(o[t]=e[t])}catch(e){}try{o.name=e.name}catch(e){}try{o.message=e.message}catch(e){}try{o.stack=e.stack}catch(e){}return cv(o,t,i,s,n,r)}if(kt(e)){if(!nv(t,"[",i))return!1;for(let n=0;e.length>n;n++){if(n>0&&!nv(t,",",i))return!1;let r;try{r=e[n]}catch(e){r=void 0}if(!cv(r,t,i,s,!0))return!1}return nv(t,"]",i)}if(!nv(t,"{",i))return!1;let o=!0;try{for(const n in e){if(!{}.hasOwnProperty.call(e,n))continue;if(0>=i.remaining)return i.truncated=!0,!1;let a;try{a=e[n]}catch(e){continue}if(r)try{lv(a,n,r)}catch(e){}if(!ov(a))continue;const l=`${o?"":","}${JSON.stringify(n)}:`;if(l.length>=i.remaining)return i.truncated=!0,!1;const c=t.length,u=i.remaining,d=i.truncated;if(!nv(t,l,i))return!1;const h=t.length,p=cv(a,t,i,s,!1),_=i.truncated;if(t.length!==h){if(o=!1,!p)return!1}else if(t.length=c,i.remaining=u,i.truncated=p?d:_,!p)return!1}}catch(e){}return nv(t,"}",i)},uv=(e,t)=>{const i=[],s={remaining:t,truncated:!1},n=Et(e[0])?{result:{},keysRemaining:50,sizeRemaining:sv,truncated:!1,seen:new WeakSet([e[0]])}:void 0;for(let t=0;e.length>t&&(0>=t||nv(i," ",s))&&cv(e[t],i,s,new WeakSet,!1,0===t?n:void 0);t++);return{body:i.join("")+(s.truncated?"...":""),truncated:s.truncated,attributes:(null==n?void 0:n.result)||{}}},dv={debug:"debug",log:"info",warn:"warn",error:"error",info:"info"},hv=e=>"canCapture"in e,pv=e=>hv(e)?e.canCapture?e.getExtension(Fg):void 0:e.is_capturing()?e.logs:void 0,_v=(e,t,i)=>{if(hv(e))return void t.captureConsoleLog(i);const s=(e=>{const t=/^1\.(\d+)\.(\d+)$/.exec(e);if(!t)return;const i=Number(t[1]),s=Number(t[2]);return 392>i||i>419?void 0:410===i?s>4?s>10?void 0:"de":"le":418===i?s>3?s>10?s>14?s>17?void 0:"vi":"ci":"ui":"he":419===i?s>2?void 0:"vi":410>i?"le":"he"})(e.version),n=s?t[s]:void 0;Ct(n)&&n.call(t,i)};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.logs={initializeLogs(e){let t=e;const i=[],s={host:h.location.host};let n=!1;for(const e of Object.keys(dv)){const r=i=>(...r)=>{let o=!1;try{const i=t;if(r.length>0&&!n&&i){const t=pv(i);if(t){n=!0,o=!0;const{body:a,truncated:l,attributes:c}=uv(r,sv),u=ct(ct({},s),l?{body_truncated:"true"}:{}),d={level:dv[e],body:a,attributes:ct(ct({"log.source":`console.${e}`},u),c)};_v(i,t,d)}}}catch(e){}finally{o&&(n=!1),i.apply(h.console,r)}},o=h.console[e];i.push(Sp(h.console,e,e=>{const t=r(e);return t.__rrweb_original__=iv(o),t}))}return()=>{t=void 0,i.forEach(e=>e())}},replayConsoleBuffer(e,t){const i=pv(e);if(i)for(const e of t)try{var s;const{body:t,truncated:n,attributes:r}=uv(e.args,sv);null===(s=i.captureBufferedConsoleLog)||void 0===s||s.call(i,{level:dv[e.level],body:t,attributes:ct(ct({"log.source":`console.${e.level}`,host:h.location.host},n?{body_truncated:"true"}:{}),r)},e.context,e.occurredAtMs)}catch(e){}}};const gv=e=>qt(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),fv=Gn("[Error tracking]"),vv="webkit-masked-url:",mv=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],yv=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",vv],bv=["__firefox__","__gCrWeb"];function Sv(){return new vs([new Ns,new Qs,new qs,new Bs,new Vs,new js,new Us,new Gs],function(e,...t){return(i,s=0)=>{const n=[],r=i.split("\n"),o=Math.min(r.length,s+1e3),a=[];for(let i=s;o>i;i++){const s=r[i];if(s.length>1024)continue;const o=Rs.test(s)?s.replace(Rs,"$1"):s;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){n.push(t);const e=Fs(n);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if(Ds(n,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=As(n,c);n.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Ls(n,e);return a.some(e=>0===e.start&&n.length===e.length)&&function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)$s(t,e,i)&&(i=e);e.push(...e.splice(0,i))}(n),function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return ct(ct({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(n)}}("web:javascript",xs,Ms))}const wv=Gn("[ExceptionAutocapture]"),kv=Sv(),Cv=(e,t)=>{try{return e()}catch(e){return t}},Ev=(e,t)=>Cv(()=>e(t()),void 0),xv=e=>Cv(()=>Ct(e)&&Ct(e.call),!1),Iv=(e,t)=>Cv(()=>{e[t].__POSTHOG_INSTRUMENTED__=!0},void 0),Tv=(e,t,i)=>{Cv(()=>{var i;null===(i=e[t])||void 0===i||delete i.__POSTHOG_INSTRUMENTED__},void 0),Cv(()=>{e[t]=i},void 0)},Mv=t=>{const i=e;i||wv.info("window not available, cannot wrap onerror");const s=Cv(()=>i.onerror,void 0);return i.onerror=function(...e){var i;return Ev(t,()=>kv.buildFromUnknown((([e,t,i,s,n])=>{if(null!=n)return n;if(Tt(e)&&Tt(t)&&t.length>0&&"undefined"!=typeof ErrorEvent)try{return new ErrorEvent("error",{message:e,filename:t,lineno:i,colno:s})}catch(t){return e}return e})(e),{mechanism:{handled:!1}})),!!xv(s)&&null!==(i=s(...e))&&void 0!==i&&i},Iv(i,"onerror"),()=>Tv(i,"onerror",s)},Rv=(t,i=!1)=>{const s=e;s||wv.info("window not available, cannot wrap onUnhandledRejection");const n=Cv(()=>s.onunhandledrejection,void 0);return s.onunhandledrejection=function(e){var s;return Ev(t,()=>kv.buildFromUnknown(e,{mechanism:{handled:!1}})),xv(n)?null!==(s=n(e))&&void 0!==s&&s:i},Iv(s,"onunhandledrejection"),()=>Tv(s,"onunhandledrejection",n)},Pv={wrapOnError:Mv,wrapUnhandledRejection:Rv,wrapConsoleError(e){const t=console;t||wv.info("console not available, cannot wrap console.error");const i=Cv(()=>t.error,void 0);return t.error=function(...t){Cv(()=>t.length>1&&Tt(t[0])&&(/^\[PostHog\.js\](?: |$)/.test(t[0])||"rrweb logger error:"===t[0]),!1)||Ev(e,()=>{let e;e=1==t.length?t[0]:t.join(" ");const i=t.find(e=>e instanceof Error);return kv.buildFromUnknown(i||e,{mechanism:{handled:!0,type:"onconsole"},syntheticException:new Error("PostHog syntheticException"),skipFirstLines:2})}),xv(i)&&i(...t)},Iv(t,"error"),()=>Tv(t,"error",i)}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.errorWrappingFunctions=Pv,h.posthogErrorWrappingFunctions=Pv;const Fv=(e,t)=>{if(!Ct(null==e?void 0:e.capture))return;const i=null==t?void 0:t.autocaptureExceptions,s=!Rt(i)&&"object"==typeof i&&kt(i.errors_to_ignore)?i.errors_to_ignore.reduce((e,t)=>{try{e.push(new RegExp(t))}catch(e){wv.error("Ignoring invalid legacy exception exclusion rule",t,e)}return e},[]):[],n=t=>{try{var i;null===(i=e.capture)||void 0===i||i.call(e,"$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",_noHeatmaps:!0})}catch(e){wv.error("Failed to capture exception for a legacy client",e)}};Mv(e=>{s.some(t=>e.$exception_list.some(e=>t.test(e.value||"")))||n(e)}),Rv(n,!0)};h.extendPostHogWithExceptionAutoCapture=Fv,h.extendPostHogWithExceptionAutocapture=Fv;const Lv="X-POSTHOG-SESSION-ID",Av="X-POSTHOG-WINDOW-ID",Ov="X-POSTHOG-DISTINCT-ID",Dv=[Lv,Av,Ov],$v=["attributionReporting","body","browsingTopics","cache","credentials","dispatcher","duplex","integrity","keepalive","method","mode","priority","redirect","referrer","referrerPolicy","signal","window"],Nv=(e,t)=>({}.hasOwnProperty.call(e,t)),Bv=e=>"object"==typeof e&&!Rt(e)||Ct(e),qv=e=>"undefined"!=typeof Request&&(e instanceof Request||"[object Request]"==={}.toString.call(e)),Hv=t=>{try{var i;return qv(t)?t.url:new URL(t instanceof URL?t.toString():String(t),null==e||null===(i=e.location)||void 0===i?void 0:i.href).toString()}catch(e){return}},Uv=(e,t,i,s,n)=>{let r;try{r=new URL(s).hostname}catch(e){return!1}if(!e)return!1;if(kt(e)&&!e.includes(r))return!1;let o=!1;if(i){const{sessionId:e,windowId:t}=i.checkAndGetSessionAndWindowId(!0);n.set(Lv,e),n.set(Av,t),o=!0}const a=(e=>Ct(e)?e():e)(t);return a&&"$posthog_cookieless"!==a&&(n.set(Ov,a),o=!0),o};h.__PosthogExtensions__=h.__PosthogExtensions__||{};const Wv={_patchFetch:(t,i,s)=>Sp(e,"fetch",e=>function(n,r){const o=arguments.length>1?[n,r]:[n];let a=o;try{const e=Hv(n);if(e)if(qv(n)){const e=new Request(n,r);Uv(t,i,s,e.url,e.headers),a=[e]}else{const o=new Headers(Bv(r)?r.headers:void 0);if(Uv(t,i,s,e,o)){const e=((e,t)=>{if(It(e)||Rt(e))return{headers:t};if(!Bv(e))return;const i=e;if("undefined"==typeof Proxy||"undefined"==typeof Reflect){const e=Object.create(i);return Object.defineProperty(e,"headers",{configurable:!0,enumerable:!0,value:t,writable:!0}),e}return new Proxy({headers:t},{get:(e,t)=>Nv(e,t)?Reflect.get(e,t):Reflect.get(i,t,i),has:(e,t)=>Nv(e,t)||t in i,ownKeys(e){const t=new Set(Reflect.ownKeys(e));return Reflect.ownKeys(i).forEach(e=>t.add(e)),$v.forEach(e=>{e in i&&t.add(e)}),Array.from(t)},getOwnPropertyDescriptor(e,t){const s=Reflect.getOwnPropertyDescriptor(e,t);if(s)return s;if("string"==typeof t&&$v.includes(t)&&t in i)return{configurable:!0,enumerable:!0,get(){return Reflect.get(i,t,i)}};const n=Reflect.getOwnPropertyDescriptor(i,t);return n?ct(ct({},n),{},{configurable:!0}):void 0},getPrototypeOf:()=>Object.getPrototypeOf(i)})})(r,o);e&&(a=[n,e])}}}catch(e){a=o}return e.apply(this,a)}),_patchXHR:(t,i,s)=>Sp(e.XMLHttpRequest.prototype,"open",e=>function(n,r,o=!0,a,l){const c=this,u=new Headers,d=Hv(r);d&&Uv(t,i,s,d,u);const h=e.call(c,n,r,o,a,l);return Dv.forEach(e=>{const t=u.get(e);if(t)try{c.setRequestHeader(e,t)}catch(e){}}),h})};h.__PosthogExtensions__.tracingHeadersPatchFns=Wv,h.postHogTracingHeadersPatchFns=Wv,"function"!=typeof[].at&&Object.defineProperty(Array.prototype,"at",{value(e){const t=this.length;let i=Math.trunc(e)||0;return 0>i&&(i+=t),0>i||i>=t?void 0:this[i]},writable:!0,enumerable:!1,configurable:!0}),"function"!=typeof[].findLast&&Object.defineProperty(Array.prototype,"findLast",{value(e,t){for(let i=this.length-1;i>=0;i--){const s=this[i];if(e.call(t,s,i,this))return s}},writable:!0,enumerable:!1,configurable:!0});var zv=class{constructor(){this.t=void 0,this.o=0,this.i=[]}l(e){var t;if(e.hadRecentInput)return;const i=this.i[0],s=this.i.at(-1);this.o&&i&&s&&1e3>e.startTime-s.startTime&&5e3>e.startTime-i.startTime?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const jv=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Vv=e=>{if("loading"===document.readyState)return"loading";const t=jv();if(t){if(t.domInteractive>e)return"loading";if(0===t.domContentLoadedEventStart||t.domContentLoadedEventStart>e)return"dom-interactive";if(0===t.domComplete||t.domComplete>e)return"dom-content-loaded"}return"complete"},Gv=e=>{const t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},Qv=e=>{let t="";try{for(;9!==(null==e?void 0:e.nodeType);){var i;const s=e,n=s.id?"#"+s.id:[Gv(s),...Array.from(null!==(i=s.classList)&&void 0!==i?i:[]).sort()].join(".");if(t.length+n.length>99)return t||n;if(t=t?n+">"+t:n,s.id)break;e=s.parentNode}}catch(e){}return t},Kv=new WeakMap;function Zv(e,t){let i=Kv.get(t);return i||(i=new WeakMap,Kv.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}let Jv=-1;const Yv=()=>Jv,Xv=e=>{addEventListener("pageshow",t=>{t.persisted&&(Jv=t.timeStamp,e(t))},!0)},em=(e,t,i,s)=>{let n,r;return o=>{var a;t.value>=0&&(o||s)&&(r=t.value-(null!==(a=n)&&void 0!==a?a:0),(r||void 0===n)&&(n=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},tm=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},im=()=>{var e,t;return null!==(e=null===(t=jv())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let sm=-1;const nm=new Set,rm=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,om=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of nm)e();isFinite(sm)||(sm="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",om,!0))}},am=(e=!1)=>{if(e&&(sm=1/0),0>sm){var t;const e=im(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;sm=null!=i?i:rm(),addEventListener("visibilitychange",om,!0),addEventListener("prerenderingchange",om,!0),Xv(()=>{setTimeout(()=>{sm=rm()})})}return{get firstHiddenTime(){return sm},onHidden(e){nm.add(e)}}},lm=(e,t=-1,i,s=0,n,r,o)=>{const a=jv(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>Yv()?a&&(document.prerendering||im()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:s||l,navigationInteractionId:n,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},cm=(e,t,i={})=>{try{const s=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(s.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();s.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of s)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},um=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},dm=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},hm=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var pm=class{constructor(){this.u=void 0}};const _m=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},gm=[1800,3e3],fm=(e,t={})=>{const i=um(t);_m(()=>{const s=Zv(t,pm),n=am();let r,o=lm("FCP");const a=cm(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),n.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-im(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=em(e,o,gm,t.reportAllChanges),Xv(i=>{o=lm("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Yv()),r=em(e,o,gm,t.reportAllChanges),tm(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&cm(["soft-navigation"],i=>{i.forEach(i=>{s.u&&i.navigationId&&dm(s.u,i);const n=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=lm("FCP",n,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=em(e,o,gm,t.reportAllChanges),r(!0)})},t)})},vm=[.1,.25],mm=e=>e.find(e=>{var t;return 1===(null===(t=e.node)||void 0===t?void 0:t.nodeType)})||e[0],ym=(e,t={})=>{const i=Zv(t=Object.assign({},t),zv),s=new WeakMap;i.t=e=>{var i;if(null==e||null===(i=e.sources)||void 0===i?void 0:i.length){const i=mm(e.sources),o=null==i?void 0:i.node;if(o){var n,r;const e=null!==(n=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,o))&&void 0!==n?n:Qv(o);s.set(i,e)}}},((e,t={})=>{const i=am();fm(hm(()=>{let s,n=lm("CLS",0);const r=Zv(t,zv),o=(i,o,a,l,c)=>{n=lm("CLS",0,i,o,a,l,c),r.o=0,s=em(e,n,vm,t.reportAllChanges)},a=(e=!1)=>{r.o>n.value&&(n.value=r.o,n.entries=r.i),s(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.l(t):l(t);a()},u=["layout-shift"];um(t)&&u.push("soft-navigation");const d=cm(u,c);d&&(s=em(e,n,vm,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),s(!0)}),Xv(()=>{o("back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,Yv()),tm(s)}),setTimeout(s))}))})(t=>{e((e=>{let t={};if(e.entries.length){var i;const n=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(null==n||null===(i=n.sources)||void 0===i?void 0:i.length){const e=mm(n.sources);e&&(t={largestShiftTarget:s.get(e),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:Vv(n.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},bm=(e,t={})=>{const i=Zv(t=Object.assign({},t),pm);um(t)&&(i.u=new Map),fm(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:Vv(Yv())};if("soft-navigation"!==e.navigationType){if(e.entries.length){const i=jv(),s=e.entries.at(-1);if(i){const n=Math.max(0,i.responseStart-(i.activationStart||0));t={timeToFirstByte:n,firstByteToFCP:e.value-n,loadState:Vv(e.entries[0].startTime),navigationEntry:i,fcpEntry:s}}}}else{var s;const n=null===(s=i.u)||void 0===s?void 0:s.get(e.navigationId);n&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:"complete",navigationEntry:n})}return Object.assign(e,{attribution:t})})(t))},t)};let Sm=0,wm=1/0,km=0;const Cm=e=>{for(const t of e)t.interactionId&&(wm=Math.min(wm,t.interactionId),km=Math.max(km,t.interactionId),Sm=km?(km-wm)/7+1:0)};let Em;const xm=()=>{var e;return Em?Sm:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var Im=class{constructor(){this.h=0,this.v=[],this.p=new Map,this.m=void 0,this.M=void 0}T(){return xm()-this.h}D(){this.h=xm(),this.v.length=0,this.p.clear()}S(e){const t=this.T(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{k:8,id:-1,entries:[]}}l(e){var t;if(null===(t=this.m)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let s=this.p.get(e.interactionId);if(s||10>this.v.length||e.duration>i.k){var n;if(s?e.duration>s.k?(s.entries=[e],s.k=e.duration):e.duration===s.k&&e.startTime===s.entries[0].startTime&&s.entries.push(e):(s={id:e.interactionId,entries:[e],k:e.duration},this.p.set(s.id,s),this.v.push(s)),this.v.sort((e,t)=>t.k-e.k),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.p.delete(t.id)}null===(n=this.M)||void 0===n||n.call(this,s)}}};const Tm=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,s=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const n=hm(e);let r=-1;const o=()=>{s(r),n()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),n()},{timeout:t})}},Mm=[200,500],Rm=(e,t={})=>{const i=Zv(t=Object.assign({},t),Im);let s=[],n=[],r=0;const o=new WeakMap,a=new WeakMap;let l=!1;const c=()=>{l||(Tm(u),l=!0)},u=()=>{const e=new Set(i.v.map(e=>o.get(e.entries[0]))),t=n.length-10;n=n.filter((i,s)=>s>=t||e.has(i));const a=new Set;for(const e of n){const t=d(e.startTime,e.processingEnd);for(const e of t)a.add(e)}s=s.filter(e=>e.startTime>r||a.has(e)),l=!1};i.m=e=>{const i=e.startTime+e.duration;let s;r=Math.max(r,e.processingEnd);for(let r=n.length-1;r>=0;r--){const o=n[r];if(8>=Math.abs(i-o.renderTime)){s=o,s.startTime=Math.min(e.startTime,s.startTime),s.processingStart=Math.min(e.processingStart,s.processingStart),s.processingEnd=Math.max(e.processingEnd,s.processingEnd),t.includeProcessedEventEntries&&s.entries.push(e);break}}s||(s={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:i,entries:t.includeProcessedEventEntries?[e]:[]},n.push(s)),e.interactionId&&o.set(e,s),c()},i.M=e=>{if(!a.get(e)){var i;const o=null===(i=e.entries.find(e=>e.target))||void 0===i?void 0:i.target;if(o){var s,n;const i=null!==(s=null===(n=t.generateTarget)||void 0===n?void 0:n.call(t,o))&&void 0!==s?s:Qv(o);a.set(e,i)}else{var r;const t=null===(r=e.entries.find(e=>e.targetSelector))||void 0===r?void 0:r.targetSelector;t&&a.set(e,t)}}};const d=(e,t)=>{const i=[];for(const n of s)if(n.startTime+n.duration>=e){if(n.startTime>t)break;i.push(n)}return i};cm(["long-animation-frame"],e=>{s=s.concat(e),c()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=am();_m(()=>{var s;"interactionCount"in performance||Em||(Em=cm(["event"],Cm,{durationThreshold:0}));let n,r=lm("INP");const o=Zv(t,Im),a=(i,s,a,l,c)=>{o.D(),r=lm("INP",-1,i,s,a,l,c),n=em(e,r,Mm,t.reportAllChanges)},l=()=>{const e=o.S(r.navigationType);e&&e.k!==r.value&&(r.value=e.k,r.entries=e.entries,n())},c=e=>{l(),n(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{Tm(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.l(t):c(t);l(),t&&n(!0)})},d=["event","first-input"];um(t)&&d.push("soft-navigation");const h=cm(d,u,ct(ct({},t),{},{durationThreshold:null!==(s=t.durationThreshold)&&void 0!==s?s:40}));n=em(e,r,Mm,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),Xv(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,Yv())}))})})(t=>{e((e=>{if(0===e.entries.length){const t={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:Vv(e.navigationStartTime||0)};return Object.assign(e,{attribution:t})}const t=e.entries[0],s=o.get(t),n=Math.max(s.processingStart,t.startTime),r=Math.max(t.startTime+t.duration,n),l=Math.min(s.processingEnd,r),c=s.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,l),h=i.p.get(t.interactionId),p={interactionTarget:a.get(h),interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:r,processedEventEntries:c,longAnimationFrameEntries:u,inputDelay:n-t.startTime,processingDuration:l-n,presentationDelay:r-l,loadState:Vv(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;const i=e.interactionTime,s=e.nextPaintTime;if(!(null===(t=e.longAnimationFrameEntries)||void 0===t?void 0:t.length)||!i||!s)return;const n=e.inputDelay,r=e.processingDuration;let o,a,l=0,c=0,u=0,d=0;for(const t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(const e of t.scripts){const t=e.startTime+e.duration;if(i>t)continue;const s=t-Math.max(i,e.startTime),u=e.duration?s/e.duration*e.forcedStyleAndLayoutDuration:0;l+=s-u,c+=u,s>d&&(a=i+n>e.startTime?"input-delay":i+n+r>e.startTime?"processing-duration":"presentation-delay",o=e,d=s)}}const h=e.longAnimationFrameEntries.at(-1),p=h?h.startTime+h.duration:0;p>=i+n+r&&(u=s-p),o&&a&&(e.longestScript={entry:o,subpart:a,intersectingDuration:d}),e.totalScriptDuration=l,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=u,e.totalUnattributedDuration=s-i-l-c-u})(p),Object.assign(e,{attribution:p})})(t))},t)};var Pm=class{constructor(){this.m=void 0,this.u=void 0}l(e){var t;null===(t=this.m)||void 0===t||t.call(this,e)}};const $=[2500,4e3];let Fm=50;const Lm=[];cm(["resource"],e=>{for(const t of e)Lm.push(t),Lm.length>Fm&&Lm.shift()});const Am=(e,t={})=>{null!=(t=Object.assign({},t)).resourceBufferSize&&(Fm=t.resourceBufferSize);const i=Zv(t,Pm),s=new WeakMap;um(t)&&(i.u=new Map),i.m=e=>{const i=e.element;if(i){var n,r;const o=null!==(n=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,i))&&void 0!==n?n:Qv(i);s.set(e,o)}else e.id&&s.set(e,`#${e.id}`)},((e,t={})=>{let i=!1;const s=um(t);_m(()=>{let n,r=am(),o=lm("LCP");const a=Zv(t,Pm),l=(s,a,l,c,u)=>{o=lm("LCP",-1,s,a,l,c,u),n=em(e,o,$,t.reportAllChanges),i=!1,"soft-navigation"===s&&(r=am(!0))},c=e=>{var t;a.u&&e.navigationId&&dm(a.u,e),i||n(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const s=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);s&&u([s])},u=e=>{t.reportAllChanges||s||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,s=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-im(),0),a.l(t),s=[t];else if("interaction-contentful-paint"===t.entryType){var i;const n=t;if(!o.navigationId)continue;if("interactionId"in n&&n.interactionId!=o.navigationInteractionId)continue;l=(null===(i=n.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),n.largestContentfulPaint&&(a.l(n.largestContentfulPaint),s=[n.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=s,n())}},d=["largest-contentful-paint"];s&&d.push("interaction-contentful-paint","soft-navigation");const h=cm(d,u);if(h){n=em(e,o,$,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;Tm(()=>{if(!i){if(!s){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,n(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});Xv(s=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Yv()),n=em(e,o,$,t.reportAllChanges),tm(()=>{o.value=performance.now()-s.timeStamp,i=!0,n(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){var n,r,o;const a=e.entries.at(-1),l=a.url&&(Lm.findLast(e=>e.name===a.url)||performance.getEntriesByType("resource").findLast(e=>e.name===a.url));let c;t.target=s.get(a),t.lcpEntry=a,a.url&&(t.url=a.url),l&&(t.lcpResourceEntry=l);let u=0,d=0;if("soft-navigation"!==e.navigationType?(c=jv(),u=null!==(n=null==c?void 0:c.activationStart)&&void 0!==n?n:0,d=null!==(r=null==c?void 0:c.responseStart)&&void 0!==r?r:0):(u=e.navigationStartTime||0,c=null===(o=i.u)||void 0===o?void 0:o.get(e.navigationId)),c){const i=Math.max(0,d-u),s=Math.max(i,l?(l.requestStart||l.startTime)-u:0),n=Math.min(e.value,Math.max(s,l?l.responseEnd-u:0));t=ct(ct({},t),{},{timeToFirstByte:i,resourceLoadDelay:s-i,resourceLoadDuration:n-s,elementRenderDelay:e.value-n,navigationEntry:c})}}return Object.assign(e,{attribution:t})})(t))},t)};let Om=-1;const Dm=()=>Om,$m=e=>{addEventListener("pageshow",t=>{t.persisted&&(Om=t.timeStamp,e(t))},!0)},Nm=(e,t,i,s)=>{let n,r;return o=>{var a;t.value>=0&&(o||s)&&(r=t.value-(null!==(a=n)&&void 0!==a?a:0),(r||void 0===n)&&(n=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},Bm=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},qm=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Hm=()=>{var e,t;return null!==(e=null===(t=qm())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let Um=-1;const Wm=new Set,zm=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,jm=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of Wm)e();isFinite(Um)||(Um="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",jm,!0))}},Vm=(e=!1)=>{if(e&&(Um=1/0),0>Um){var t;const e=Hm(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;Um=null!=i?i:zm(),addEventListener("visibilitychange",jm,!0),addEventListener("prerenderingchange",jm,!0),$m(()=>{setTimeout(()=>{Um=zm()})})}return{get firstHiddenTime(){return Um},onHidden(e){Wm.add(e)}}},Gm=(e,t=-1,i,s=0,n,r,o)=>{const a=qm(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>Dm()?a&&(document.prerendering||Hm()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:s||l,navigationInteractionId:n,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},Qm=new WeakMap;function Km(e,t){let i=Qm.get(t);return i||(i=new WeakMap,Qm.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}var Zm=class{constructor(){this.t=void 0,this.i=0,this.o=[]}h(e){var t;if(e.hadRecentInput)return;const i=this.o[0],s=this.o.at(-1);this.i&&i&&s&&1e3>e.startTime-s.startTime&&5e3>e.startTime-i.startTime?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const Jm=(e,t,i={})=>{try{const s=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(s.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();s.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of s)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},Ym=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},Xm=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},ey=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var ty=class{constructor(){this.l=void 0}};const iy=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},sy=[1800,3e3],ny=(e,t={})=>{const i=Ym(t);iy(()=>{const s=Km(t,ty),n=Vm();let r,o=Gm("FCP");const a=Jm(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),n.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-Hm(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=Nm(e,o,sy,t.reportAllChanges),$m(i=>{o=Gm("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Dm()),r=Nm(e,o,sy,t.reportAllChanges),Bm(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&Jm(["soft-navigation"],i=>{i.forEach(i=>{s.l&&i.navigationId&&Xm(s.l,i);const n=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=Gm("FCP",n,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=Nm(e,o,sy,t.reportAllChanges),r(!0)})},t)})},ry=[.1,.25],oy=(e,t={})=>{const i=Vm();ny(ey(()=>{let s,n=Gm("CLS",0);const r=Km(t,Zm),o=(i,o,a,l,c)=>{n=Gm("CLS",0,i,o,a,l,c),r.i=0,s=Nm(e,n,ry,t.reportAllChanges)},a=(e=!1)=>{r.i>n.value&&(n.value=r.i,n.entries=r.o),s(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.h(t):l(t);a()},u=["layout-shift"];Ym(t)&&u.push("soft-navigation");const d=Jm(u,c);d&&(s=Nm(e,n,ry,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),s(!0)}),$m(()=>{o("back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,Dm()),Bm(s)}),setTimeout(s))}))};let ay=0,ly=1/0,cy=0;const uy=e=>{for(const t of e)t.interactionId&&(ly=Math.min(ly,t.interactionId),cy=Math.max(cy,t.interactionId),ay=cy?(cy-ly)/7+1:0)};let dy;const hy=()=>{var e;return dy?ay:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var py=class{constructor(){this.u=0,this.v=[],this.m=new Map,this.p=void 0,this.T=void 0}_(){return hy()-this.u}M(){this.u=hy(),this.v.length=0,this.m.clear()}L(e){const t=this._(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{P:8,id:-1,entries:[]}}h(e){var t;if(null===(t=this.p)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let s=this.m.get(e.interactionId);if(s||10>this.v.length||e.duration>i.P){var n;if(s?e.duration>s.P?(s.entries=[e],s.P=e.duration):e.duration===s.P&&e.startTime===s.entries[0].startTime&&s.entries.push(e):(s={id:e.interactionId,entries:[e],P:e.duration},this.m.set(s.id,s),this.v.push(s)),this.v.sort((e,t)=>t.P-e.P),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.m.delete(t.id)}null===(n=this.T)||void 0===n||n.call(this,s)}}};const _y=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,s=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const n=ey(e);let r=-1;const o=()=>{s(r),n()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),n()},{timeout:t})}},gy=[200,500],fy=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=Vm();iy(()=>{var s;"interactionCount"in performance||dy||(dy=Jm(["event"],uy,{durationThreshold:0}));let n,r=Gm("INP");const o=Km(t,py),a=(i,s,a,l,c)=>{o.M(),r=Gm("INP",-1,i,s,a,l,c),n=Nm(e,r,gy,t.reportAllChanges)},l=()=>{const e=o.L(r.navigationType);e&&e.P!==r.value&&(r.value=e.P,r.entries=e.entries,n())},c=e=>{l(),n(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{_y(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.h(t):c(t);l(),t&&n(!0)})},d=["event","first-input"];Ym(t)&&d.push("soft-navigation");const h=Jm(d,u,ct(ct({},t),{},{durationThreshold:null!==(s=t.durationThreshold)&&void 0!==s?s:40}));n=Nm(e,r,gy,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),$m(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,Dm())}))})};var vy=class{constructor(){this.p=void 0,this.l=void 0}h(e){var t;null===(t=this.p)||void 0===t||t.call(this,e)}};const my=[2500,4e3],yy=(e,t={})=>{let i=!1;const s=Ym(t);iy(()=>{let n,r=Vm(),o=Gm("LCP");const a=Km(t,vy),l=(s,a,l,c,u)=>{o=Gm("LCP",-1,s,a,l,c,u),n=Nm(e,o,my,t.reportAllChanges),i=!1,"soft-navigation"===s&&(r=Vm(!0))},c=e=>{var t;a.l&&e.navigationId&&Xm(a.l,e),i||n(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const s=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);s&&u([s])},u=e=>{t.reportAllChanges||s||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,s=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-Hm(),0),a.h(t),s=[t];else if("interaction-contentful-paint"===t.entryType){var i;const n=t;if(!o.navigationId)continue;if("interactionId"in n&&n.interactionId!=o.navigationInteractionId)continue;l=(null===(i=n.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),n.largestContentfulPaint&&(a.h(n.largestContentfulPaint),s=[n.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=s,n())}},d=["largest-contentful-paint"];s&&d.push("interaction-contentful-paint","soft-navigation");const h=Jm(d,u);if(h){n=Nm(e,o,my,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;_y(()=>{if(!i){if(!s){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,n(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});$m(s=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Dm()),n=Nm(e,o,my,t.reportAllChanges),Bm(()=>{o.value=performance.now()-s.timeStamp,i=!0,n(!0)})})}})},by={onLCP:Am,onCLS:ym,onFCP:bm,onINP:Rm,withoutAttribution:{onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution-soft-navs"]=by,h.__PosthogExtensions__.postHogWebVitalsCallbacks=by,h.postHogWebVitalsCallbacks=by;const Sy={onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-soft-navs"]=Sy,h.__PosthogExtensions__.postHogWebVitalsCallbacks=Sy,h.postHogWebVitalsCallbacks=Sy,h.__PosthogExtensions__.loadWebVitalsCallbacks=()=>Sy;const wy={onLCP:Am,onCLS:ym,onFCP:bm,onINP:Rm,withoutAttribution:{onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution"]=wy,h.__PosthogExtensions__.postHogWebVitalsCallbacks=wy,h.postHogWebVitalsCallbacks=wy;const ky={onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals"]=ky,h.__PosthogExtensions__.postHogWebVitalsCallbacks=ky,h.postHogWebVitalsCallbacks=ky,h.__PosthogExtensions__.loadWebVitalsCallbacks=()=>ky;var Cy=class{constructor(e){this.disabled=!1===e;const t=Et(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;const 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}};const Ey="$copy_autocapture",xy=Gn("[AutoCapture]");function Iy(e,t){return t.length>e?t.slice(0,e)+"...":t}function Ty(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!vr(t));return t}function My(t,{e:i,maskAllElementAttributes:s,maskAllText:n,elementAttributeIgnoreList:r,elementsChainAsString:o,disableCaptureUrlHashes:a}){var l,c;if(!vr(t))return{props:{}};const u=[t],d=new Set([t]);let h=t;for(;h.parentNode&&!mr(h,"body")&&1e3>u.length;){if(br(h.parentNode)){const e=h.parentNode.host;if(d.has(e))break;d.add(e),u.push(e),h=e;continue}if(!vr(h.parentNode))break;if(d.has(h.parentNode))break;d.add(h.parentNode),u.push(h.parentNode),h=h.parentNode}const p="click"===i.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?u.findIndex(e=>mr(e,"button")||mr(e,"a")):-1;p>0&&(n=n||u.slice(0,p+1).some(e=>!Ur(e)||Wr(e)));const _=[],g={};let f,v=!1,m=!1;if(Kn(u,e=>{const t=Ur(e);if(mr(e,"a")&&!s&&!(null==r?void 0:r.includes("href"))){const i=e.getAttribute("href");v=!!(t&&i&&Jr(i))&&(a?ls(i):i)}ft(kr(e),"ph-no-capture")&&(m=!0),_.push(function(e,t,i,s,n=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};Ir.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?Iy(1024,Yr(e)):Iy(1024,Er(e)));const a=kr(e);t||(null==s?void 0:s.includes("class"))||0>=a.length||(o.classes=a.filter(function(e){return""!==e})),Kn(e.attributes,function(i){var r;if((!Wr(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==s?void 0:s.includes(i.name))&&!t&&Jr(i.value)&&(!Tt(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=Sr(e).join(" ")),o["attr__"+i.name]=Iy(1024,"href"===i.name&&n?ls(e):e)}});let l=1,c=1,u=e;for(;u=Ty(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}(e,s,n,r,a)),Kn(function(e){if(!Ur(e))return{};const t={};return Kn(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Jr(s)&&(t[i]=s)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(g,t)||(g[t]=e)})}),m)return{props:{},explicitNoCapture:m};if(p>0&&(t=u[p],_.splice(0,p)),n||(_[0].$el_text=mr(t,"a")||mr(t,"button")?Yr(t):Er(t)),v){var y,b;_[0].attr__href=v;const t=null===(y=ar(v))||void 0===y?void 0:y.host,i=null==e||null===(b=e.location)||void 0===b?void 0:b.host;t&&i&&t!==i&&(f=v)}return{props:Zn((w=i.type,{$event_type:w,$ce_version:1}),o?{}:{$elements:_},{$elements_chain:(S=_,kt(S)?function(e){return e.map(e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n=ct(ct(ct(ct({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return Jn(n).sort(([e],[t])=>function(e,t){return t>e?-1:e>t?1:0}(e,t)).forEach(([e,t])=>r[eo(e.toString())]=eo(t.toString())),s+=":",s+=Jn(r).map(([e,t])=>`${e}="${t}"`).join(""),s}).join(";")}(function(e){return e.map(e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:to(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Jn(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>s.attributes[e]=t),s})}(S)):"")},(null===(l=_[0])||void 0===l?void 0:l.$el_text)?{$el_text:null===(c=_[0])||void 0===c?void 0:c.$el_text}:{},f&&"click"===i.type?{$external_click_url:f}:{},g),target:t};var S,w}var Ry=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!Ur(e))return!0;const i=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:Pr,s=new Set;let n=e;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const e=n,t=kr(e);if(ft(t,"ph-no-capture")||ft(t,"ph-sensitive")||Wr(e)||i.some(t=>Tr(e,t)))return!0;const r=n.parentNode;n=br(r)?r.host:r&&vr(r)?r:null}return!1}_trackPointer(e){if(!this.isEnabled||"pointercancel"===e.type)return void this._clearPointer();if("pointerdown"===e.type){this._clearPointer();const i=xr(e);var t;return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&vr(i)&&(this._pointerDown={target:i,excluded:this._isExcludedPointerTarget(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this._client)||void 0===t?void 0:t.distinctId}))}const i=this._pointerDown;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this._clearPointer():"pointerup"===e.type&&(i.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){var t;const i=this._pointerDown;this._clearPointer();const n=xr(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this._client)||void 0===t?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)&&n&&(mr(n,"html")||mr(n,"body"))){var r;if(i.excluded)return null;const e=null!==(r=this._refreshConfig().css_selector_ignorelist)&&void 0!==r?r:Pr;return[n,null==s?void 0:s.documentElement,null==s?void 0:s.body].some(t=>{if(!t)return!1;const i=kr(t);return ft(i,"ph-no-capture")||ft(i,"ph-sensitive")||!Ur(t)||Wr(t)||e.some(e=>Tr(t,e))})?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 Cy(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;const 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)||void 0===e||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?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null===(t=this._config.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){if(!this.isBrowserSupported())return void xy.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!s)return;const t=this._domEventHandler=t=>{t=t||(null==e?void 0:e.event);try{if("blur"===t.type)return void this._clearPointer();if(0===t.type.indexOf("pointer"))return void this._trackPointer(t);const e="click"===t.type?this._recoverClickTarget(t):void 0;if(Rt(e))return;this._captureEvent(t,"$autocapture",e)}catch(e){xy.error("Failed to capture event",e)}};if(sr(e,"blur",t),sr(s,"submit",t,{capture:!0}),sr(s,"change",t,{capture:!0}),sr(s,"click",t,{capture:!0}),Kn(["pointerdown","pointermove","pointerup","pointercancel"],e=>{sr(s,e,t,{capture:!0})}),this._refreshConfig().capture_copied_text){const t=this._copiedTextHandler=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t,Ey)}catch(e){xy.error("Failed to capture clipboard event",e)}};sr(s,"copy",t,{capture:!0}),sr(s,"cut",t,{capture:!0}),sr(s,"paste",t,{capture:!0})}}_removeDomEventHandlers(){this._clearPointer(),this._domEventHandler&&(null==e||e.removeEventListener("blur",this._domEventHandler),Kn(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==s||s.removeEventListener(e,this._domEventHandler,!0)}),null==s||s.removeEventListener("submit",this._domEventHandler,!0),null==s||s.removeEventListener("change",this._domEventHandler,!0),null==s||s.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==s||s.removeEventListener("copy",this._copiedTextHandler,!0),null==s||s.removeEventListener("cut",this._copiedTextHandler,!0),null==s||s.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)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);const i=t.autocapture_opt_out;var s;At(i)&&(null===(s=this._client)||void 0===s||s.kv.set("$autocapture_disabled_server_side",i),this._isDisabledServerSide=i),this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e,t){var i;const n=[];return null===(i=this._elementSelectors)||void 0===i||i.forEach(i=>{const r=null==s?void 0:s.querySelectorAll(i);null==r||r.forEach(s=>{e!==s&&t!==s||ft(n,i)||n.push(i)})}),n}get isEnabled(){var e,t;if(this._disposed)return!1;const i=null===(e=this._client)||void 0===e?void 0:e.kv.get(C),s=this._isDisabledServerSide,n=this._refreshConfig();if(!n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;const r=n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(Rt(s)&&!At(i)&&!r)return!1;const o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!n.enabled&&!o}_captureEvent(t,i="$autocapture",s){if(!this.isEnabled)return void this._clearPointer();let n=s||xr(t);yr(n)&&(n=n.parentNode||null);const r=this._compileUrlPatterns();var o;"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&r.rageclick&&(null===(o=this.rageclicks)||void 0===o?void 0:o.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime()))&&Br(n,r.rageclick)&&this._captureEvent(t,"$rageclick",s);const a=i===Ey,l=a?ct(ct({},r),{},{dom_event_allowlist:void 0}):r;if(n&&function(t,i,s,n,r,o){var a;if(!e||qr(t))return!1;if((null==s?void 0:s.url_allowlist)&&!wr(s.url_allowlist,o))return!1;if((null==s?void 0:s.url_ignorelist)&&wr(s.url_ignorelist,o))return!1;if(null==s?void 0:s.dom_event_allowlist){const e=s.dom_event_allowlist;if(e&&!e.some(e=>i.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=Hr(t,n);if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(It(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,s))return!1;if(!Mr(c,null==s?void 0:s.css_selector_allowlist))return!1;if(Mr(c,null!==(a=null==s?void 0:s.css_selector_ignorelist)&&void 0!==a?a:Pr))return!1;try{const s=e.getComputedStyle(t);if(s&&"pointer"===s.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(e){}const u=t.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(r||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(i.type)>=0;default:return l?(r||["click"]).indexOf(i.type)>=0:(r||["click"]).indexOf(i.type)>=0&&(Ir.indexOf(u)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,l,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var c;const{props:s,explicitNoCapture:o,target:a}=My(n,{e:t,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(o)return!1;const l=this.getElementSelectors(n,a);if(l&&l.length>0&&(s.$element_selectors=l),i===Ey){const i=t.type||"clipboard";if("paste"!==i){var u,d;const t=null==e||null===(u=e.getSelection())||void 0===u?void 0:u.toString(),i=Cr(t);if(!i)return!1;s.$selected_content=i,s.$clipboard_text_length=null!==(d=null==t?void 0:t.length)&&void 0!==d?d:0}s.$copy_type=i}return null===(c=this._client)||void 0===c||c.capture(i,s).catch(e=>xy.error("Failed to capture event",e)),!0}}isBrowserSupported(){return Ct(null==s?void 0:s.querySelectorAll)}};const Py={};function Fy(e,t){const i=xr(e);return i?ct({node:i,originalEvent:e,timestamp:Date.now()},t):null}function Ly(e,t){return Math.abs(e)<Math.abs(t)?0>t?"up":"down":0>e?"left":"right"}function Ay(e){return"swipe"===e.type?"$dead_swipe":"$dead_click"}const Oy="canvas,video,audio,embed,object";function Dy(e,t){return Ft(e)&&e>=t}function $y(e,t=1e3){return e>=0&&t>e?e:void 0}function Ny(e,t,i=1e3){return Ft(t)?$y(e-t,i):void 0}var By=class{_asRequiredConfig(e){var t,i,s,n,r,o,a,l;const c=this._defaultConfig((null==e?void 0:e.__onCapture)||this._captureDeadClick.bind(this));return{element_attribute_ignorelist:null!==(t=null==e?void 0:e.element_attribute_ignorelist)&&void 0!==t?t:c.element_attribute_ignorelist,scroll_threshold_ms:null!==(i=null==e?void 0:e.scroll_threshold_ms)&&void 0!==i?i:c.scroll_threshold_ms,selection_change_threshold_ms:null!==(s=null==e?void 0:e.selection_change_threshold_ms)&&void 0!==s?s:c.selection_change_threshold_ms,mutation_threshold_ms:null!==(n=null==e?void 0:e.mutation_threshold_ms)&&void 0!==n?n:c.mutation_threshold_ms,capture_clicks_with_modifier_keys:null!==(r=null==e?void 0:e.capture_clicks_with_modifier_keys)&&void 0!==r?r:c.capture_clicks_with_modifier_keys,capture_dead_swipes:null!==(o=null==e?void 0:e.capture_dead_swipes)&&void 0!==o?o:c.capture_dead_swipes,swipe_threshold_px:null!==(a=null==e?void 0:e.swipe_threshold_px)&&void 0!==a?a:c.swipe_threshold_px,max_dead_swipes_per_page_load:null!==(l=null==e?void 0:e.max_dead_swipes_per_page_load)&&void 0!==l?l:c.max_dead_swipes_per_page_load,css_selector_ignorelist:null==e?void 0:e.css_selector_ignorelist,__onCapture:c.__onCapture}}constructor(e,t){this.instance=e,this._hadSelection=!1,this._clicks=[],this._deadSwipesCaptured=0,this._defaultConfig=e=>({element_attribute_ignorelist:[],scroll_threshold_ms:100,selection_change_threshold_ms:100,mutation_threshold_ms:2500,capture_clicks_with_modifier_keys:!1,capture_dead_swipes:!0,swipe_threshold_px:30,max_dead_swipes_per_page_load:10,__onCapture:e}),this._clearMouseSelection=()=>{clearTimeout(this._mouseSelectionTimer),this._mouseSelectionTimer=void 0,this._mouseSelection=void 0},this._onMouseDown=e=>{if(this._clearMouseSelection(),0===e.button){const t={path:e.composedPath(),trusted:e.isTrusted,selectionChanged:!1,selectionInitiallyRelated:!1},i=null==s?void 0:s.getSelection();t.selectionInitiallyRelated="Range"===(null==i?void 0:i.type)&&this._selectionTouchesGesture(i,t),this._mouseSelection=t}},this._onMouseOut=e=>{Rt(e.relatedTarget)&&this._clearMouseSelection()},this._onMouseUp=e=>{const t=this._mouseSelection,i=e;if(!t||0!==i.button||e.isTrusted!==t.trusted)return;const s=e.composedPath();for(const e of t.path)if(vr(e)&&-1!==s.indexOf(e)){t.clickTarget=e;break}t.clickDetail=i.detail,this._mouseSelectionTimer=h.setTimeout(this._clearMouseSelection,0)},this._onClick=e=>{const t=e,i=Fy(t,{type:"click"}),s=this._mouseSelection;i&&s&&0===t.button&&t.detail>0&&t.detail===s.clickDetail&&e.isTrusted===s.trusted&&i.node===s.clickTarget&&(i.selectionChangedDuringGesture=s.selectionChanged&&this._config.selection_change_threshold_ms>0,this._clearMouseSelection()),Rt(i)||this._ignore(i)||this._queueCandidate(i),this._scheduleCheck()},this._onScroll=()=>{const e=Date.now();this._lastScroll=e,e%50==0&&this._clicks.forEach(t=>{It(t.scrollDelayMs)&&(t.scrollDelayMs=e-t.timestamp)})},this._onSelectionChange=e=>{var t,i;const n=null==s?void 0:s.getSelection(),r=this._hadSelection;this._hadSelection="Range"===(null==n?void 0:n.type);const o=null==n?void 0:n.focusNode,a=o&&(vr(o)?o:o.parentElement),l=null==s?void 0:s.activeElement;let c=l;for(;null==c||null===(t=c.shadowRoot)||void 0===t?void 0:t.activeElement;)c=c.shadowRoot.activeElement;const u=Nr(xr(e))||Nr(null!=a?a:null)||Nr(null!==(i=c)&&void 0!==i?i:null),d="Caret"===(null==n?void 0:n.type)&&c&&!c.shadowRoot&&o&&o!==l&&o.contains(null!=l?l:null);if(!(r||this._hadSelection||u||d))return;const h=Date.now();this._lastSelectionChanged=h;const p=this._mouseSelection;if(p&&(r||this._hadSelection||u)){const t=xr(e);let i;if(Nr(t))i=t;else if("Caret"===(null==n?void 0:n.type)){var _;Nr(null!==(_=c)&&void 0!==_?_:null)||d?i=c:u&&(i=a)}const s=i?this._selectionIsInGesture(i,p):n&&(o||n.anchorNode)?this._selectionTouchesGesture(n,p):r&&!this._hadSelection&&p.selectionInitiallyRelated;p.selectionChanged=p.selectionChanged||s}this._clicks.forEach(e=>{const t=h-e.timestamp;0>t||!It(e.selectionChangedDelayMs)&&t>=e.selectionChangedDelayMs||(e.selectionChangedDelayMs=t)})},this._onVisibilityChange=()=>{"hidden"===(null==s?void 0:s.visibilityState)&&this._clearMouseSelection();const e=Date.now();this._lastVisibilityChange=e,this._recordLivenessSignal("visibilityChangedDelayMs",e)},this._onFocusChange=()=>{const e=Date.now();this._lastFocusChange=e,this._recordLivenessSignal("focusChangedDelayMs",e)},this._onTouchStart=e=>{const t=e.touches,i=1===(null==t?void 0:t.length)?t[0]:void 0;this._touchStart=i?{x:i.clientX,y:i.clientY,timestamp:Date.now()}:void 0},this._onTouchCancel=()=>{this._touchStart=void 0},this._onTouchEnd=e=>{var t;const i=this._touchStart;if(this._touchStart=void 0,It(i)||this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)return;const n=e,r=null===(t=n.changedTouches)||void 0===t?void 0:t[0];if(!r)return;const o=r.clientX-i.x,a=r.clientY-i.y,l=o*o+a*a,c=this._config.swipe_threshold_px;if(c*c>l)return;if([this._lastScroll,this._lastMutation,this._lastSelectionChanged].some(e=>Ft(e)&&e>=i.timestamp))return;var u,d;if(this._pageHasUnobservableSurfaces()&&(null!==(u=null==s||null===(d=s.elementsFromPoint)||void 0===d?void 0:d.call(s,i.x,i.y))&&void 0!==u?u:[]).some(e=>{var t;return null===(t=e.matches)||void 0===t?void 0:t.call(e,Oy)}))return;const h=Fy(n,{type:"swipe",swipeDirection:Ly(o,a),swipeDistancePx:Math.round(Math.sqrt(l))});Rt(h)||this._ignore(h)||this._queueCandidate(h),this._scheduleCheck()},this._config=this._asRequiredConfig(t),this._onCapture=this._config.__onCapture}start(e){this._startClickObserver(),this._startScrollObserver(),this._startSelectionChangedObserver(),this._startVisibilityChangeObserver(),this._startFocusChangeObserver(),this._startMutationObserver(e),this._config.capture_dead_swipes&&this._startSwipeObserver()}_startMutationObserver(t){if(!this._mutationObserver){const i=function(t){return function(t,i){const s=Py[t];if(s)return s;let n=i[t];if((e=>Ct(e)&&-1!==e.toString().indexOf("[native code]"))(n)&&!(null==e?void 0:e.Zone))return Py[t]=n.bind(i);const r=i.document;if(r&&Ct(r.createElement)){let e,s=!1;try{e=r.createElement("iframe"),e.hidden=!0,r.head.appendChild(e);const l=e.contentWindow;var o,a;l&&l[t]&&(n=l[t],"MutationObserver"===t&&function(e){return ft(e,"AppleWebKit")&&!ft(e,"Chrome")}(null!==(o=null===(a=i.navigator)||void 0===a?void 0:a.userAgent)&&void 0!==o?o:"")&&(e.classList.add("rr-block","ph-no-capture"),s=!0))}catch(e){Vn.warn(`Could not create sandbox iframe for ${t} check, bailing to assignableWindow.${t}: `,e)}finally{!s&&(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}}return n&&Ct(n)?Py[t]=n.bind(i):n}("MutationObserver",t)}(h);this._mutationObserver=new i(e=>{this._onMutation(e)}),this._mutationObserver.observe(t,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}}stop(){var e;null===(e=this._mutationObserver)||void 0===e||e.disconnect(),this._mutationObserver=void 0,h.removeEventListener("click",this._onClick,{capture:!0}),h.removeEventListener("mousedown",this._onMouseDown,{capture:!0}),h.removeEventListener("mouseup",this._onMouseUp,{capture:!0}),h.removeEventListener("mouseout",this._onMouseOut,{capture:!0}),h.removeEventListener("dragstart",this._clearMouseSelection,{capture:!0}),h.removeEventListener("pointercancel",this._clearMouseSelection,{capture:!0}),h.removeEventListener("blur",this._clearMouseSelection),this._clearMouseSelection(),h.removeEventListener("scroll",this._onScroll,{capture:!0}),null==s||s.removeEventListener("selectionchange",this._onSelectionChange),h.removeEventListener("touchstart",this._onTouchStart,{capture:!0}),h.removeEventListener("touchend",this._onTouchEnd,{capture:!0}),h.removeEventListener("touchcancel",this._onTouchCancel,{capture:!0}),null==s||s.removeEventListener("visibilitychange",this._onVisibilityChange),h.removeEventListener("blur",this._onFocusChange),h.removeEventListener("focus",this._onFocusChange),this._touchStart=void 0}_onMutation(e){this._lastMutation=Date.now()}_startClickObserver(){sr(h,"click",this._onClick,{capture:!0}),sr(h,"mousedown",this._onMouseDown,{capture:!0}),sr(h,"mouseup",this._onMouseUp,{capture:!0}),sr(h,"mouseout",this._onMouseOut,{capture:!0}),sr(h,"dragstart",this._clearMouseSelection,{capture:!0}),sr(h,"pointercancel",this._clearMouseSelection,{capture:!0}),sr(h,"blur",this._clearMouseSelection)}_queueCandidate(e){e.selectionChangedDelayMs=Ny(e.timestamp,this._lastSelectionChanged,this._config.selection_change_threshold_ms),e.visibilityChangedDelayMs=Ny(e.timestamp,this._lastVisibilityChange),e.focusChangedDelayMs=Ny(e.timestamp,this._lastFocusChange),this._clicks.push(e)}_scheduleCheck(){this._clicks.length&&It(this._checkClickTimer)&&(this._checkClickTimer=h.setTimeout(()=>{this._checkClicks()},1e3))}_startScrollObserver(){sr(h,"scroll",this._onScroll,{capture:!0})}_startSelectionChangedObserver(){var e;this._hadSelection="Range"===(null==s||null===(e=s.getSelection())||void 0===e?void 0:e.type),sr(s,"selectionchange",this._onSelectionChange)}_selectionIsInGesture(e,t){const i=t.path[0];for(;e;){if(-1!==t.path.indexOf(e)||vr(i)&&i.contains(e))return!0;e=e.getRootNode().host}return!1}_selectionTouchesGesture(e,t){const i=t.path[0],s=e.rangeCount>0?e.getRangeAt(0):void 0;if(s&&vr(i)&&s.startContainer.getRootNode()===i.getRootNode()){var n;if(!s.collapsed)return s.intersectsNode(i);const e=vr(s.startContainer)&&null!==(n=s.startContainer.childNodes[s.startOffset])&&void 0!==n?n:s.startContainer;return this._selectionIsInGesture(e,t)}return this._selectionIsInGesture(e.focusNode,t)||this._selectionIsInGesture(e.anchorNode,t)}_startVisibilityChangeObserver(){sr(s,"visibilitychange",this._onVisibilityChange)}_startFocusChangeObserver(){sr(h,"blur",this._onFocusChange),sr(h,"focus",this._onFocusChange)}_recordLivenessSignal(e,t){this._clicks.forEach(i=>{const s=$y(t-i.timestamp);Ft(s)&&(It(i[e])||i[e]>s)&&(i[e]=s)})}_startSwipeObserver(){sr(h,"touchstart",this._onTouchStart,{capture:!0,passive:!0}),sr(h,"touchend",this._onTouchEnd,{capture:!0,passive:!0}),sr(h,"touchcancel",this._onTouchCancel,{capture:!0,passive:!0})}_pageHasUnobservableSurfaces(){const e=It(this._surfacesCheckedAt)||Ft(this._lastMutation)&&this._lastMutation>this._surfacesCheckedAt;return(It(this._hasUnobservableSurfaces)||e)&&(this._surfacesCheckedAt=Date.now(),this._hasUnobservableSurfaces=!!(null==s?void 0:s.querySelector(Oy))),!!this._hasUnobservableSurfaces}_ignore(e){return!e||("swipe"===e.type?this._ignoreCommon(e):this._ignoreClick(e))}_ignoreCommon(t){return!(!fr(t.node)&&!this._clicks.some(e=>e.type===t.type&&e.node===t.node&&1e3>Math.abs(e.timestamp-t.timestamp))&&!mr(t.node,"html")&&vr(t.node)&&function(t,i){var s;if(!e||qr(t))return!1;const n=At(i)?Or:null!==(s=null==i?void 0:i.css_selector_ignorelist)&&void 0!==s?s:Or,{targetElementList:r}=Hr(t,!1);return!Mr(r,n)}(t.node,{css_selector_ignorelist:this._config.css_selector_ignorelist}))}_ignoreClick(t){return!(this._config.capture_clicks_with_modifier_keys||(i=t.originalEvent,!(i.ctrlKey||i.metaKey||i.altKey||i.shiftKey)))||!!this._ignoreCommon(t)||function(t){if(!e||qr(t))return!1;const{targetElementList:i}=Hr(t,!1);return i.some(e=>mr(e,"a"))}(t.node);var i}_checkClicks(){if(!this._clicks.length)return;clearTimeout(this._checkClickTimer),this._checkClickTimer=void 0;const e=this._clicks;this._clicks=[];for(const i of e){var t;i.mutationDelayMs=null!==(t=i.mutationDelayMs)&&void 0!==t?t:this._lastMutation&&this._lastMutation>=i.timestamp?this._lastMutation-i.timestamp:void 0,i.absoluteDelayMs=Date.now()-i.timestamp;const e=Dy(i.scrollDelayMs,this._config.scroll_threshold_ms),s=Dy(i.selectionChangedDelayMs,this._config.selection_change_threshold_ms),n=Dy(i.mutationDelayMs,this._config.mutation_threshold_ms),r=Dy(i.absoluteDelayMs,1.1*this._config.mutation_threshold_ms),o=Ft(i.scrollDelayMs)&&this._config.scroll_threshold_ms>i.scrollDelayMs,a=Ft(i.mutationDelayMs)&&this._config.mutation_threshold_ms>i.mutationDelayMs,l=i.selectionChangedDuringGesture||Ft(i.selectionChangedDelayMs)&&this._config.selection_change_threshold_ms>i.selectionChangedDelayMs,c=Ft(i.visibilityChangedDelayMs),u=Ft(i.focusChangedDelayMs);if(!(o||a||l||c||u))if(e||n||r||s){const t=Ay(i);if("$dead_swipe"===t){if(this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)continue;this._deadSwipesCaptured++}this._onCapture(i,{[`${t}_last_mutation_timestamp`]:this._lastMutation,[`${t}_event_timestamp`]:i.timestamp,[`${t}_scroll_timeout`]:e,[`${t}_mutation_timeout`]:n,[`${t}_absolute_timeout`]:r,[`${t}_selection_changed_timeout`]:s,[`${t}_visibility_changed_timeout`]:!1})}else this._config.mutation_threshold_ms>i.absoluteDelayMs&&this._clicks.push(i)}this._scheduleCheck()}_captureDeadClick(e,t){const i=Ay(e);this.instance.capture(i,ct(ct(ct({},t),My(e.node,{e:e.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:!1,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}).props),{},{[`${i}_scroll_delay_ms`]:e.scrollDelayMs,[`${i}_mutation_delay_ms`]:e.mutationDelayMs,[`${i}_absolute_delay_ms`]:e.absoluteDelayMs,[`${i}_selection_changed_delay_ms`]:e.selectionChangedDelayMs,[`${i}_visibility_changed_delay_ms`]:e.visibilityChangedDelayMs,[`${i}_focus_changed_delay_ms`]:e.focusChangedDelayMs,$dead_swipe_direction:e.swipeDirection,$dead_swipe_distance_px:e.swipeDistancePx}),{timestamp:new Date(e.timestamp)})}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.initDeadClicksAutocapture=(e,t)=>new By(e,t);var qy=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(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){const e=this._storage._get(this._storageKey);return zt(e)?1:ft(jt,e)?0:-1}get _storage(){const e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?$a:Oa,i=t._is_supported()?t:Ka;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;const t="localStorage"===e?Oa:$a;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(zt(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,h.doNotTrack,null==i?void 0:i.globalPrivacyControl].some(e=>zt(e))}};const Hy=Gn("[Dead Clicks]"),Uy=()=>!0,Wy=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property(R)),s=e.instance.config.capture_dead_clicks;return At(s)?s:!!Et(s)||i};var zy=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)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[R]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",t=>{t?Hy.error("failed to load script",t):e()})}_start(){var e;if(s){if(!this._lazyLoadedDeadClicksAutocapture&&(null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=Et(this.instance.config.capture_dead_clicks)?ct({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=h.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(s),Hy.info("starting...")}}else Hy.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Hy.info("stopping..."))}};const jy=Gn("[SegmentIntegration]");function Vy(e,t,i=!0){const s=e.config.segment;if(!s)return t();const{analytics:n,filterProperties:r}=(e=>Ct(e.register))(o=s)?{analytics:o}:o;var o;!function(e,t,i,s){const n=t=>{const n=()=>t.anonymousId()||Ra();e.config.get_device_id=n,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:n()}),e.persistence.set_property(xe,Ze)),i(s?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&Ct(r.then)?r.then(n):n(r)}(e,n,i=>{n.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||jy.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!t&&s.event.anonymousId===t&&!s.event.userId;r||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(jy.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(jy.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));let o=e.calculateEventProperties(n,s.event.properties);if(!Pt(i)){const e=s.event.properties||{},t={};for(const i of Object.keys(o))St.call(e,i)||(t[i]=o[i]);const n=((e,t)=>{const i=kt(e)?e:[e];let s=ct({},t);for(const e of i)try{if(s=e(s),Pt(s))return null}catch(e){return jy.error("Error in Segment filterProperties:",e),null}return s})(i,t);if(Pt(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return s(e,e.event.event)},page(e){return s(e,et)},identify(e){return s(e,it)},screen(e){return s(e,"$screen")}}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{jy.error("Failed to register the Segment integration",e),t()})},i)}const Gy="posthog-js";function Qy(e,{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==n&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],_=p.map(e=>ct(ct({},e),{},{stacktrace:e.stacktrace?ct(ct({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>ct(ct({},e),{},{platform:"web:javascript"}))}):void 0})),g={$exception_message:(null===(l=p[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=p[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:_,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=p[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=p[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var f;return t&&i&&(g.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(f=e.exceptions)||void 0===f||f.sendExceptionEvent(g)),o}}var Ky=class{constructor(e,t,i,s,n,r){this.name=Gy,this.setupOnce=function(o){o(Qy(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},Zy=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Vn.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?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null===(e=this._unsubscribeSessionId)||void 0===e||e.call(this),this._unsubscribeSessionId=void 0}doPageView(t,i){var s;const n=this._previousPageViewProperties(t,i);return this._currentPageview={pathname:null!==(s=null==e?void 0:e.location.pathname)&&void 0!==s?s:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),n}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){const i=this._currentPageview;if(!i)return{$pageview_id:t};let s={$pageview_id:t,$prev_pageview_id:i.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=n;if(!(It(e)||It(t)||It(i)||It(r)||It(o)||It(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const n=e>1?Qt(t/e,0,1,Vn):1,l=e>1?Qt(i/e,0,1,Vn):1,c=r>1?Qt(o/r,0,1,Vn):1,u=r>1?Qt(a/r,0,1,Vn):1;s=Zn(s,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}};const Jy=["flags","surveys"],Yy={[p]:{exposure:"hidden"},[v]:{exposure:"hidden"},[m]:{exposure:"hidden"},[k]:{exposure:"hidden"},[b]:{exposure:"hidden"},[w]:{exposure:"hidden"},[C]:{exposure:"event"},[E]:{exposure:"hidden"},[F]:{exposure:"hidden"},[x]:{exposure:"event"},[I]:{exposure:"hidden"},[T]:{exposure:"event"},[M]:{exposure:"event"},[R]:{exposure:"event"},[P]:{exposure:"hidden"},[L]:{exposure:"event"},[A]:{exposure:"hidden"},[O]:{exposure:"hidden"},[U]:{exposure:"hidden"},[W]:{exposure:"event"},[D]:{exposure:"event",shouldSkipFromEventProperties:e=>Rt(e)},[z]:{exposure:"event"},[j]:{exposure:"event"},[V]:{exposure:"event"},[Z]:{exposure:"event"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden",storageGroup:"flags"},[X]:{exposure:"hidden",storageGroup:"flags"},[ee]:{exposure:"hidden"},[te]:{exposure:"hidden",storageGroup:"flags"},[ie]:{exposure:"hidden",storageGroup:"flags"},[se]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ne]:{exposure:"hidden",storageGroup:"flags"},[re]:{exposure:"hidden"},[oe]:{exposure:"hidden"},[ae]:{exposure:"hidden"},[le]:{exposure:"hidden"},[ue]:{exposure:"hidden",storageGroup:"surveys"},[de]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[he]:{exposure:"event"},[pe]:{exposure:"hidden"},[_e]:{exposure:"hidden"},[ge]:{exposure:"hidden"},[fe]:{exposure:"hidden"},[ve]:{exposure:"hidden"},[me]:{exposure:"event"},[ye]:{exposure:"event"},[be]:{exposure:"event"},[Se]:{exposure:"event"},[we]:{exposure:"hidden"},[ke]:{exposure:"hidden"},[ce]:{exposure:"event"},[Ce]:{exposure:"hidden"},[Ee]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[xe]:{exposure:"hidden"},[Ie]:{exposure:"hidden"},[Te]:{exposure:"hidden"},[Me]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[Fe]:{exposure:"hidden"},[N]:{exposure:"event"},[B]:{exposure:"event"},[q]:{exposure:"event"},[H]:{exposure:"event"},[Oe]:{exposure:"event"},[De]:{exposure:"event"},[$e]:{exposure:"event"},[Ne]:{exposure:"event"},[Be]:{exposure:"event"},[qe]:{exposure:"event"},[He]:{exposure:"event"},[Ue]:{exposure:"event"},[We]:{exposure:"event"},[ze]:{exposure:"event"},[Ge]:{exposure:"event"}},Xy=[[G,{exposure:"hidden"}],[Q,{exposure:"hidden"}],[K,{exposure:"hidden"}]],eb=e=>{const t=Yy[e];if(t)return t;for(const[t,i]of Xy)if(0===e.indexOf(t))return i},tb={flags:Ee,surveys:de},ib=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],sb=e=>`${e}_cookie_identity_change_pending`,nb=e=>{let t="",i=0;for(const s of e){const e=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+e>1e3)break;t+=s,i+=e}return t},rb="main",ob=[Y,X,te,ie,se,Ee,ne,ae],ab=e=>-1!==ob.indexOf(e),lb=[b,w],cb=e=>-1!==lb.indexOf(e),ub=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},db=e=>{if(!e)return{};const t=JSON.parse(e);return Et(t)?t:{}},hb=(e,t)=>{Kn(e,(i,s)=>{const n=eb(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})};var pb=class{constructor(t,i,s=!0){if(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._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=t,this._ownsSplitStorage=s,this.props={},this._campaign_params_url=void 0,this._name=(e=>{let t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(t),this._storage=this._buildStorage(t),this._splitStorage=this._resolveSplitStorage(t),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),t.debug&&Vn.info("Persistence loaded",t.persistence,ct({},this.props)),this.update_config(t,t,i),this.save(),e){const t=()=>this.flush();sr(e,"beforeunload",t,{capture:!1}),sr(e,"pagehide",t,{capture:!1}),this._onStorage=t=>{if(this._splitStorageEligible&&(!t.storageArea||t.storageArea===(null==e?void 0:e.localStorage))&&t.key)if(t.key!==this._name){if(this._splitStorage){const e=Jy.find(e=>t.key===this._groupEntryName(e));e&&this._syncCrossTabFeatureFlagProperties(t.key,e)}}else this._syncCrossTabFeatureFlagProperties(t.key,rb)},sr(e,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!ab(e)||!0===i)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(i||[]);t.forEach(e=>s.add(e)),s.size&&this._setCrossTabFeatureFlagChangesPending(e,s)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&e&&(e.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i=!0){if(this._disabled)return!1;let s,n;try{if(n=$a._get(e),Rt(n)){const e=this._slotWriteState(t);return e.storageValue=null,t!==rb&&(e.persisted=!1),!1}s=db(n)}catch(e){return!1}const r=t===rb?s:$a._parse(this._name);if(r&&this._hasCrossTabFeatureFlagIdentityMismatch(r))return!1;const o=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===rb&&this._splitStorage&&!ub(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,n),o}_hasCrossTabFeatureFlagIdentityMismatch(e){const t=this.props[_],i=e[_];return!It(t)&&!It(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){const n=this._slotWriteState(t);n.storageValue=s,t!==rb&&(n.persisted=i);try{n.fingerprint=this._entryFingerprint(e,t)}catch(e){n.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){let s=!1;return ob.forEach(i=>{var n;const r=null===(n=eb(i))||void 0===n?void 0:n.storageGroup;if(t===rb&&this._splitStorage&&r||t!==rb&&r!==t)return;const 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&&ub(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;const e=$a._get(this._name),t=this._slotWriteState(rb);let i,s=!1,n=!1;if(e!==t.storageValue)if(Rt(e))t.storageValue=null;else{if(i=db(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(i),this._crossTabFeatureFlagIdentityMismatch)return!1;n=this._mergeCrossTabFeatureFlagProperties(i,rb,!1),!this._splitStorage||ub(this._partitionProps().main,i)?this._rememberCrossTabStorageFingerprint(i,rb,!0,e):t.storageValue=e,s=!0}return this._splitStorage&&Jy.forEach(e=>{const t=$a._get(this._groupEntryName(e)),r=this._slotWriteState(e),o=i||{},a=s&&ob.some(t=>{var i;return(null===(i=eb(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(Rt(t))return r.storageValue=null,r.persisted=!1,void(a&&(n=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||n));const l=db(t);n=this._mergeCrossTabFeatureFlagProperties(l,e,!1)||n,this._rememberCrossTabStorageFingerprint(l,e,!0,t)}),n}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);const i=eb(e);(null==i?void 0:i.volatile)||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||rb).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){ob.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{const e=$a._get(this._name),t=db(e);this._slotWriteState(rb).storageValue=e,ob.forEach(e=>{var i;const s=this._splitStorage?null===(i=eb(e))||void 0===i?void 0:i.storageGroup:void 0,n=s?$a._get(this._groupEntryName(s)):null;if(s){const e=this._slotWriteState(s);e.storageValue=n,e.persisted=!Rt(n)}const r=s&&!Rt(n)?db(n):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,r[e],this.props[e]):e in r&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const s=new Set(kt(t)?t:[]),n=new Set(kt(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?s.add(e):s.delete(e)),Array.from(s)}const s=Et(t)?ct({},t):{},n=Et(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in n?s[e]=n[e]:delete s[e]}),s}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(!ab(e))return;const s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===s)return;let n=t;if(this._splitStorageEligible)try{var r;const t=this._splitStorage?null===(r=eb(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this._groupEntryName(t):this._name;n=db($a._get(i))[e]}catch(e){}const o=new Set(s||[]);if("$active_feature_flags"===e){if(!It(t)&&!kt(t)||!It(n)&&!kt(n)||!kt(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(t||[]),r=new Set(n||[]),a=new Set(i);new Set([...s,...a]).forEach(e=>{s.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!Et(i))return void(ub(n,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!It(t)&&!Et(t)||It(t)&&xt(i)&&It(n))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=Et(t)?t:{},r=Et(n)?n:{};new Set([...Object.keys(s),...Object.keys(i)]).forEach(e=>{e in s==e in i&&ub(s[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&ub(r[e],i[e])&&o.delete(e)})}}o.size?this._setCrossTabFeatureFlagChangesPending(e,o):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){var e;const t=null===(e=this._config)||void 0===e?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{const t=Wa(e,this._config.cookie_persisted_properties||[]),i=ja(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),n=Oa._get(this._name)||void 0;n&&Ga(this._name,n)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=n)}catch(e){}else try{const e=Oa._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?Ga(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=Oa._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;const s=Ga(this._name,i);let n;try{n=Ua(JSON.parse(i))}catch(e){return!1}if((Oa._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=i;const r=Va(this._name,i),o=[...Ba,...r.properties],a={};if(Object.keys(n).forEach(e=>{const t=n[e];(It(t)||Rt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete n[e])}),xt(n))return!1;const l="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,c=this.props,u=c[_],d=c[xe],h=Zn({},c);[...Ba,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in n)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){const t=h[e];(r.isValid||-1===Ba.indexOf(e)||!1!==t&&0!==t)&&delete h[e]}}),this.props=Zn(h,n),ob.forEach(e=>{const t=e in this.props;e in c===t&&ub(c[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,c[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this._setProp(xe,Ke);const p=this.props[_],g=this.props[xe];return!l||p===u&&g===d||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Ja._set(sb(this._name),!0),this._deleteProp(ae),this._deleteProp(X),this._deleteProp(Y),this._deleteProp(te),this._deleteProp(ie),this._deleteProp(se),this._deleteProp(Ee),this._deleteProp(Ce),this._deleteProp(we),"anonymous"!==g||"identified"!==d&&"anonymous"!==n.$user_state&&(It(u)||p===u)||(hb(this.props,n),this._deleteProp(le)),"identified"===g?this.props.$user_id=p:delete this.props.$user_id,this._deleteProp(v)),!0}consumeCookieIdentityChange(){const e=sb(this._name),t=this._cookieIdentityChangePending||!!Ja._get(e);return this._cookieIdentityChangePending=!1,t&&Ja._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[rb],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(t){-1===ib.indexOf(t.persistence.toLowerCase())&&(Vn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");const i=((t=[],i=!1)=>{const s=[...Ba,...t];return ct(ct({},$a),{},{_parse(e){try{let n,r={};try{n=Oa._get(e)||void 0,r=n?Ua(JSON.parse(n)):{}}catch(e){}const o=JSON.parse($a._get(e)||"{}");let a;if(i){const i=Va(e,n),l=[...Ba,...i.properties],c={};Object.keys(r).forEach(e=>{const t=r[e];Rt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var t;const e=o[_],n=null!==(t=o.$user_state)&&void 0!==t?t:Ke;s.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const t=o[e];(i.isValid||-1===Ba.indexOf(e)||!1!==t&&0!==t)&&delete o[e]}}),!u||"$user_state"in r||"$user_state"in o||(o[xe]=Ke),!u||("distinct_id"in c?c[_]:o[_])===e&&("$user_state"in c?c[xe]:o[xe])===n||(Na.forEach(e=>delete o[e]),"identified"===c.$user_state&&"distinct_id"in c?o.$user_id=c[_]:delete o.$user_id,"identified"!==c.$user_state&&(delete o[ce],delete o[le]),delete o.__alias)}a=Zn(o,c)}else a=Zn(r,o);return $a._set(e,a),a}catch(e){}return null},_set(e,s,n,r,o,a){const l=$a._set(e,s,void 0,void 0,a);try{const c=Wa(s,t);if(Object.keys(c).length){if(i){const i=qa(e),u=ja(c,t);if(Oa._set(i,u,n,r,o,a),Oa._get(i)!==JSON.stringify(u)){Oa._remove(i,r);const t=Wa(s);return Oa._set(e,t,n,r,o,a),l}}Oa._set(e,c,n,r,o,a)}}catch(e){$a._error(e)}return l},_remove(t,i){try{null==e||e.localStorage.removeItem(t),Oa._remove(t,i),Oa._remove(qa(t),i)}catch(e){$a._error(e)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict);let s,n=!1,r=!1;const o=t.persistence.toLowerCase();return"localstorage"===o&&$a._is_supported()?(s=$a,r=!0):"localstorage+cookie"===o&&i._is_supported()?(s=i,r=!0,n=!0):"sessionstorage"===o&&Ja._is_supported()?s=Ja:"memory"===o?s=Ka:"cookie"===o&&Oa._is_supported()?(s=Oa,n=!0):i._is_supported()?(s=i,r=!0,n=!0):Oa._is_supported()?(s=Oa,n=!0):s=Ka,this._splitStorageEligible=r,this._storesIdentityInCookie=n,s}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){const e={};return Kn(this.props,(t,i)=>{const s=eb(i);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,t))return;e[i]=t}}),e}load(e=!1){if(this._disabled&&!e)return;const t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?$a._parse(this._name):null;let s={};if(t)try{s=Ua(Oa._parse(this._name)),Kn(s,(e,t)=>{(It(e)||Rt(e)||""===e)&&delete s[t]})}catch(e){}const n=this._storage._parse(this._name);if(n&&(this.props=Zn({},n)),this._splitStorage&&this._loadGroupEntries(),t&&n){var r,o;const e=null==i?void 0:i[_],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Ke,a=n[_],l=null!==(o=n.$user_state)&&void 0!==o?o:Ke;if(a!==e||l!==t){this._cookieIdentityChangePending=!0,Ja._set(sb(this._name),!0);const i=Zn({},this.props);Na.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==s.$user_state&&(It(e)||a===e)||(hb(i,s),delete i[le]),this.props=i;const n=new Set;Na.forEach(e=>{var t;const i=null===(t=eb(e))||void 0===t?void 0:t.storageGroup;i&&n.add(i)}),n.forEach(e=>{const t={};Kn(this.props,(i,s)=>{var n;(null===(n=eb(s))||void 0===n?void 0:n.storageGroup)===e&&(t[s]=i)}),xt(t)?($a._remove(this._groupEntryName(e)),this._slotState[e]={}):$a._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Ja._get(sb(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(const e of Jy){const t=$a._parse(this._groupEntryName(e));if(t&&!xt(t)){const i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Zn(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=eb(t))||void 0===i?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){const i=tb[e];if(!i)return!1;const s=t[i],n=this.props[i];return Ft(s)&&Ft(n)&&n>s}refreshKey(e){var t;if(this._disabled)return;if(this._metaIdentifierChangePending.has(e))return;const i=this._splitStorage?null===(t=eb(e))||void 0===t?void 0:t.storageGroup:void 0,s=i?$a._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){const t=this._storage._parse(this._name);if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}}save(){if(this._disabled)return;const e=this._saveDebounceMs();e>0?It(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||lb.forEach(e=>this.refreshKey(e)));const t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);const i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&Vn.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));const s=this._writeEntry(this._storage,this._name,this.props,rb);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){const{main:e,groups:t}=this._partitionProps(),i=this._writeEntry(this._storage,this._name,e,rb);"written"===i&&this._rememberCurrentCookieProperties(e),"failed"!==i&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),ob.forEach(e=>{var t;(null===(t=eb(e))||void 0===t?void 0:t.storageGroup)||this._pendingCrossTabFeatureFlagChanges.delete(e)}));for(const e of Jy){var s;const i=t[e];if(xt(i)&&!(null===(s=this._slotState[e])||void 0===s?void 0:s.persisted)){ob.forEach(t=>{var i;(null===(i=eb(t))||void 0===i?void 0:i.storageGroup)===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}const n=this._writeEntry($a,this._groupEntryName(e),i,e);"failed"!==n&&ob.forEach(t=>{const i=eb(t);(null==i?void 0:i.storageGroup)!==e||"written"!==n&&i.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){const e={},t={flags:{},surveys:{}};return Kn(this.props,(i,s)=>{var n;const r=null===(n=eb(s))||void 0===n?void 0:n.storageGroup;r?t[r][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===rb)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;const i={};return Kn(e,(e,t)=>{var s;i[t]=(null===(s=eb(t))||void 0===s?void 0:s.volatile)?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){const n=this._slotWriteState(s);if(s!==rb&&!n.dirty&&!It(n.fingerprint))return"skipped";let r;try{if(r=this._entryFingerprint(i,s),r===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!==rb&&(n.persisted=!0),It(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=$a._get(t)),"written"):(this._config.debug&&Vn.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(const e of Jy)$a._remove(this._groupEntryName(e));e?delete this._slotState[rb]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Et(e)){this.syncCookieProperties(),It(t)&&(t="None"),this._expire_days=It(i)?this._default_expiry:i;let s=!1;if(Kn(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(Et(e)){this.syncCookieProperties(),this._expire_days=It(t)?this._default_expiry:t;let i=!1;if(Kn(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||Et(t)||kt(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this._deleteProp(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==s?void 0:s.URL;if(e===this._campaign_params_url)return;const t=Ml(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!xt(Xn(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}update_search_keyword(){this.register(function(){const e=null==s?void 0:s.referrer;return e?Pl(e):{}}())}update_referrer_info(){var e;this.register_once({$referrer:Ol(),$referring_domain:(null==s?void 0:s.referrer)&&(null===(e=ar(s.referrer))||void 0===e?void 0:e.host)||Al},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Dl(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Pe]:this._storesIdentityInCookie?{r:nb(e.r),u:e.u?nb(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Kn([Re,Me],t=>{const i=this.props[t];i&&Kn(i,function(t,i){e["$initial_"+mt(i)]=t})});const t=this.props[Pe];if(t){const i=function(e,t=!1){const i=$l(e,t),s={};return Kn(i,function(e,t){s[`$initial_${mt(t)}`]=e}),s}(t,this._config.disable_capture_url_hashes);Zn(e,i)}return e}safe_merge(e){return Kn(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const s=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=s||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this._disabled&&!a;a||this._syncCookieProperties(t,l),this._config=e,!a&&(s||n||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(ct(ct({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();const u=this._resolveSplitStorage(e),d=r||u!==this._splitStorage,h=!a&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(l);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this._storage=c,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=c,a||(delete this._slotState[rb],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){const e=this.props[Pe];if(!this._storesIdentityInCookie||!Et(e)||"string"!=typeof e.r)return;const t=nb(e.r),i="string"==typeof e.u?nb(e.u):e.u;t===e.r&&i===e.u||this._setProp(Pe,ct(ct({},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){const i=this.props.__timers||{};i[e]=t,this._setProp(k,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return It(i)||(delete t[e],this._setProp(k,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=!0){var s;const n=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||n===t||(this._localIdentityChangePending=!0),cb(e)&&!ub(n,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,n,t),(null===(s=eb(e))||void 0===s?void 0:s.volatile)||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(ab(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),cb(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t;const i=null===(t=eb(e))||void 0===t?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}};const _b={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},gb={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},fb={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},vb=Gn("[RateLimiter]");var mb=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{vb.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void vb.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?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,i,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),a=null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*r,a.last=o,a.tokens>n&&(a.tokens=n);const l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){const e=(Ft(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this._captureWarning(e)&&(a.dropped=0)}return this.lastEventRateLimited=l,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){const t=this.instance.config.property_denylist;return!kt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&(null==n?void 0:n.pathname))return`${null!==(e=n.origin)&&void 0!==e?e:""}${n.pathname}`}_captureWarning(e){var t,i;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const yb=Gn("[RemoteConfig]");var bb=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=h._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}_loadRemoteConfigJs(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,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 yb.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void yb.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return yb.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){yb.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||yb.warn("Failed to fetch remote config from PostHog."):yb.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){yb.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)||void 0===i||i.ensureFlagsLoaded()}catch(e){yb.error("Error loading feature flags",e)}}};const Sb=["fatal","error","warning","log","info","debug"],wb=!!o||!!r,kb=new WeakMap,Cb="text/plain";let Eb=0,xb=!1;const Ib=(e,t)=>{const[i,s]=e.split("#"),[n,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},Tb=(e,t,i=!0)=>{var s;const[n,r]=e.split("?"),o=ct({},t),a=null!==(s=null==r?void 0:r.split("&").map(e=>{var t;const[s,n]=e.split("="),r=i&&null!==(t=o[s])&&void 0!==t?t:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],l=lr(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},Mb=e=>{if(e._encodedBody)return e._encodedBody;const{data:t,compression:i}=e;if(!t)return;if(i===cg.GZipJS){const e=ba(Sa(or(t)),{mtime:0});return{contentType:Cb,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===cg.Base64){const e=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(or(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:or(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=or(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},Rb=e=>{const t=()=>"sendBeacon"===e.transport?{url:Tb(e.url,{compression:cg.Base64}),encodedBody:Mb(ct(ct({},e),{},{compression:cg.Base64,_encodedBody:void 0}))}:{url:Ib(e.url,"compression"),encodedBody:Mb(ct(ct({},e),{},{compression:void 0,_encodedBody:void 0}))};let i;try{i=Mb(e)}catch(i){if(cn(e.compression,cr(e.url,"compression")))return Vn.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&cn(e.compression,cr(e.url,"compression"))&&!((s=i.body)instanceof ArrayBuffer?ln(new Uint8Array(s)):ArrayBuffer.isView(s)&&ln(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(xb=!0,t()):{url:e.url,encodedBody:i};var s},Pb=e=>{try{return Rb(e)}catch(i){var t;return Vn.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},Fb=function(){var e=rt(function*(e){const t=yield fn(or(e.data),Ya.DEBUG,{rethrow:!0});if(!t)return e;const i=yield t.arrayBuffer();return ct(ct({},e),{},{_encodedBody:{contentType:Cb,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),Lb=/Failed to fetch|NetworkError|Load failed/i,Ab=e=>"TypeError"===(null==e?void 0:e.name)&&Lb.test((null==e?void 0:e.message)||""),Ob=e=>{try{const t=function(e,t=Date.now()){if("string"!=typeof e||!e)return;const i=e.trim(),s=/^\d+\s*,/.test(i)?i.slice(0,i.indexOf(",")).trim():i;if(/^\d+$/.test(s)){const e=1e3*Math.min(Number(s),300);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,r=Date.parse(n)-t;return Number.isFinite(r)&&r>0?Math.min(r,ss):void 0}(e());return It(t)?void 0:Math.min(t,3e4)}catch(e){return}},Db=e=>{const t=Pb(e);if(!t)return;const i=new o;kb.set(i,!0);const{url:s,encodedBody:n}=t;i.open(e.method||"GET",s,!0);const{contentType:r,body:a}=null!=n?n:{};Kn(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t;const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s,Ob(()=>i.getResponseHeader("Retry-After")))}},i.send(a)},$b=e=>{const t=Pb(e);if(!t)return;const{url:i,encodedBody:s}=t,{contentType:n,body:o,estimatedSize:l}=null!=s?s:{},c=new Headers;Kn(e.headers,function(e,t){c.append(t,e)}),n&&c.append("Content-Type",n);let u=null,d=!1;if(a){const t=new a;u={signal:t.signal,timeout:setTimeout(()=>{var i;d=!0,t.abort(as("AbortError","PostHog request timed out"+((i=e.timeout)?` after ${i}ms`:"")))},e.timeout)}}const h=t=>{var i;d&&"AbortError"===(null==t?void 0:t.name)||Ab(t)?Vn.warn(t):Vn.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t})};let p=0;const _=()=>{Eb-=p,p=0,u&&clearTimeout(u.timeout)};try{const t=ct({method:(null==e?void 0:e.method)||"GET",headers:c,body:o,signal:null==u?void 0:u.signal},e.fetchOptions),s=null!=l?l:It(o)?0:void 0;t.keepalive="POST"===t.method&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===o&&!It(s)&&s>=0&&52428.8>Eb+s,t.keepalive&&(p=s,Eb+=p),r(i,t).then(t=>t.text().then(i=>{var s;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){Vn.error(e)}_(),null===(s=e.callback)||void 0===s||s.call(e,n,Ob(()=>t.headers.get("Retry-After")))})).catch(e=>{_(),h(e)}).finally(_)}catch(e){_(),h(e)}},Nb=e=>{try{var t;const{url:s,encodedBody:n}=Rb(e),{contentType:o,body:a,estimatedSize:l}=null!=n?n:{};if(!a)return;const c=a instanceof Blob?a:new Blob([a],{type:o});if(i.sendBeacon(s,c))return;const u=kt(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(kt(u)&&u.length>1&&(null!=l?l:0)>16384){const t=Math.ceil(u.length/2),i=t=>kt(e.data)?t:ct(ct({},e.data),{},{batch:t});return Nb(ct(ct({},e),{},{data:i(u.slice(0,t))})),void Nb(ct(ct({},e),{},{data:i(u.slice(t))}))}Vn.warn(`Beacon of ~${null!=l?l:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?$b(ct(ct({},e),{},{_keepaliveDisabled:!0})):Db(e)}catch(e){Vn.warn("Beacon send failed",e)}},Bb=(e,t,i,s)=>{const n="query"===s?"POST"===t?"sent_at":"_":void 0;return Tb(i===cg.GZipJS?Ib(e,"compression"):e,ct(ct({},n?{[n]:Date.now().toString()}:{}),i===cg.GZipJS?{}:{compression:i}))},qb=(()=>{const e=[];return r&&e.push({transport:"fetch",method:$b}),o&&e.push({transport:"XHR",method:Db}),(null==i?void 0:i.sendBeacon)&&e.push({transport:"sendBeacon",method:Nb}),e})();let Hb=!wb&&-1===(null==c?void 0:c.indexOf("MSIE"))&&-1===(null==c?void 0:c.indexOf("Mozilla"));function Ub(e,t,i){var s,n,r;i&&(t=ct(ct({},t),{},{callback:e=>i(e)})),e.__loaded?Hb?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(n=t.callback)||void 0===n||n.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=ct(ct({},e.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(s=e.compression)&&void 0!==s?s:t.compressionFallback:t.compression,(It(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{var i,s,n;const r=ct(ct({},e),{},{callback:null!=t?t:t=>{var i;return null===(i=e.callback)||void 0===i?void 0:i.call(e,t)}});r.timeout=r.timeout||6e4;const o=null!==(i=r.transport)&&void 0!==i?i:"fetch";"sendBeacon"===o&&It(r.compression)&&r.data&&(r.compression=cg.Base64),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(e=>{var t,i;const s=(kt(e)?e:[e]).map(e=>ct(ct({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(t=null==n||null===(i=n.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((e,t=(new Date).toISOString())=>kt(e)?e.map(e=>ct(ct({},e),{},{sent_at:t})):ct(ct({},e),{},{sent_at:t}))(r.data))),r.url=Bb(r.url,r.method,r.compression,r.timestampMode);const a=qb.filter(e=>!r.disableTransport||!e.transport||!r.disableTransport.includes(e.transport)),c=null!==(s=null===(n=function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]}(a,e=>e.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:a[0].method;if(!c)throw new Error("No available transport method");const u=e=>{try{c(e)}catch(e){var t;Ab(e)?Vn.warn(e):Vn.error(e),null===(t=r.callback)||void 0===t||t.call(r,{statusCode:0,error:e})}};"sendBeacon"!==o&&r.data&&r.compression===cg.GZipJS&&l&&"undefined"!=typeof Promise&&!xb?Fb(r).then(e=>{u(e)}).catch(t=>{if(un(t))return xb=!0,void u(ct(ct({},r),{},{compression:void 0,url:Bb(e.url,e.method,void 0,e.timestampMode)}));dn(t)&&(xb=!0),u(r)}):c(r)})(t,(s,n)=>{var r,o,a;e.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=e.config).on_request_error)||void 0===r||r.call(o,s),i?i(s,n):null===(a=t.callback)||void 0===a||a.call(t,s)})):t.fireCallbackOnDrop&&(null===(r=t.callback)||void 0===r||r.call(t,{statusCode:0}))}var Wb=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Qt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Vn.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();const e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(e,"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){const e=this._formatQueue();for(const t in e)this._sendRequestSafely(e[t])}},this._flushTimeoutMs))}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Vn.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){const e={};return Kn(this._queue,t=>{var i;const s=t,n=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");It(e[n])&&(e[n]=ct(ct({},s),{},{data:[]})),null===(i=e[n].data)||void 0===i||i.push(s.data)}),this._queue=[],e}};const zb=["retriesPerformedSoFar"];var jb=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!It(e)&&"onLine"in e.navigator){if(this._areWeOnline=e.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},sr(e,"online",this._onlineListener),sr(e,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,s=mn(e,zb);Lt(i)&&(s.url=Tb(s.url,{retry_count:i})),Ub(this._instance,t?ct(ct({},s),{},{transport:t}):s,(e,t)=>{var n;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=i?i:0))return void this._enqueue(ct({retriesPerformedSoFar:i},s),t);0===e.statusCode&&Vn.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!=i?i:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,e)})}_enqueue(e,t){const i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;const s=Math.max(function(e){const t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)}(i),null!=t?t:0),n=Date.now()+s;this._queue.push({retryAt:n,requestOptions:e});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),Vn.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(){const e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,It(e)||(this._onlineListener&&(e.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(e.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0));for(const{requestOptions:e}of this._queue)try{this._instance._send_request(ct(ct({},e),{},{transport:"sendBeacon"}))}catch(e){Vn.error(e)}this._queue=[]}},Vb=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this._context.lastScrollY=Math.ceil(r),this._context.maxScrollY=Math.max(r,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){const e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){sr(e,"scroll",this._updateScrollData,{capture:!0}),sr(e,"scrollend",this._updateScrollData,{capture:!0}),sr(e,"resize",this._updateScrollData)}scrollElement(){if(this._scrollRoot){const i=kt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(const s of i){var t;const i=null==e||null===(t=e.document)||void 0===t?void 0:t.querySelector(s);if(i)return i}return}var i;return null==e||null===(i=e.document)||void 0===i?void 0:i.documentElement}_scrollPosition(t){var i,s;const n="y"===t?"scrollTop":"scrollLeft";if(this._scrollRoot){const e=this.scrollElement();return e&&e[n]||0}return e?"y"===t?e.scrollY||e.pageYOffset||(null===(i=e.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollTop)||0:e.scrollX||e.pageXOffset||(null===(s=e.document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}};const Gb=e=>Dl(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);var Qb=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{const t=this._getStored();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[Ie]:i})},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Gb,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Ie]}getSetOnceProps(){var e;const t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?$l(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(){const e={};return Kn(Xn(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${mt(i)}`]=t}),e}},Kb=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(const i of this._events[e]||[])i(t);for(const i of this._events["*"]||[])i(e,t)}constructor(){this._events={}}};const Zb=Gn("[SessionId]"),Jb=864e5;var Yb=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 Kb,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Lt(e)||!Lt(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||Ra,this._windowIdGenerator=i||Ra;const n=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Qt(this._config.session_idle_timeout_seconds||1800,60,36e3,Zb.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){const e=Ja._parse(this._window_id_storage_key),t=Ja._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:Ja._remove(this._window_id_storage_key),Ja._set(this._primary_window_exists_storage_key,!0)}(null===(s=this._config.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return It(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&&Ja._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Ja._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Ja._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){const t=this._lastPersistedActivityTimestamp;return!Rt(t)&&!Rt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){const s=t!==this._sessionActivityTimestamp,n=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,n&&!s||n&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[U]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return Lt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(U):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(Rt(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();const[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[U]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){const[e]=this._getSessionId(),t=Lt(e)?e:0,i=Lt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){const e=this._persistence.props[U];return kt(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=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Zb.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Zb.error("Invalid sessionID in bootstrap",e)}})(e);return!It(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&&e&&(e.removeEventListener(Xe,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Ja._remove(this._primary_window_exists_storage_key)},sr(e,Xe,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=t||(new Date).getTime(),n=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(Rt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var r,o;null===(r=(o=this._persistence).syncCookieProperties)||void 0===r||r.call(o),this._lastCookieSyncTimestamp=s}let[,a,l]=this._getSessionId();const c=!It(n)&&a!==n,u=this._freshestActivityTimestamp();let d=this._getWindowId();const h=this._pendingBootstrapSession,p=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Jb),_=h?p:Lt(l)&&Math.abs(s-l)>Jb;let g=!1,f=c;const v=!a||!!h,m=a;let y=!v&&!e&&this._sessionHasBeenIdleTooLong(s,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(s),y||Zb.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this._getSessionId()),v||y||_){f=!1;const e=h&&!p;a=e?h.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),Zb.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:v,activityTimeout:y,sessionPastMaximumLength:_}}),l=e?h.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,g=!0}else d||(d=this._windowIdGenerator(),g=!0),f=f||a!==m,f&&(Zb.info("adopted cross-tab session id",{sessionId:a,windowId:d}),g=!0);const b=Lt(u)&&e&&!_?u:s,S=Lt(l)?l:(new Date).getTime();this._setWindowId(d),this._setSessionId(a,b,S),e||this._resetIdleTimer();const w={noSessionId:v,activityTimeout:y,sessionPastMaximumLength:_,crossTabAdoption:f};return g&&this._sessionIdChangedHandlers.forEach(e=>e(a,d,w)),{sessionId:a,windowId:d,sessionStartTimestamp:S,changeReason:g?w:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){const e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};const Xb=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Gt(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>Gt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function eS(){return eS=rt(function*(){const e=null==i?void 0:i.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return Tt(i)&&i.length>0?i:void 0}catch(e){return void Vn.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}),eS.apply(this,arguments)}const tS="custom",iS="i.posthog.com",sS=/^\/static\//,nS=["/s/","/e/","/i/"];var rS=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${iS}`,".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":tS),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!sS.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}_urlKey(e){const t=ar(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;let s=i;const n=this.instance.config.rewriteRequestPath;if(n){var r;const e=(null===(r=ar(i))||void 0===r?void 0:r.href)||i;s=n(new URL(e)).toString()}if(n&&"api"===e&&nS.some(e=>0===t.indexOf(e))){const e=this._urlKey(s);if(e){const t=this.apiHost;let i=this._ingestionEndpoints;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===n||(i={apiHost:t,rewriteRequestPath:n,urls:new Set},this._ingestionEndpoints=i),i.urls.add(e)}}return s}isIngestionEndpoint(e){const 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(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){const i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,`${i}${t}`)}if(this.region===tS)return this._prepareEndpoint(e,t,this.apiHost+t);const i=iS+t;switch(e){case"assets":return this._prepareEndpoint(e,t,`https://${this.region}-assets.${i}`);case"api":return this._prepareEndpoint(e,t,`https://${this.region}.${i}`)}}};const oS=Gn("[PostHog ExternalIntegrations]"),aS={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var lS=class{constructor(e){this._instance=e}_loadScript(e,t){var i,s;null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,e,e=>{if(e)return oS.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[n,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,s;r&&!(null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[n])&&this._loadScript(aS[n],()=>{var e;null===(e=h.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[n])||void 0===e||e.start(this._instance)}),!r&&(null===(i=h.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&(null===(s=h.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},cS=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return rt(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{const i=e.setup(t._client);i&&(yield i)}catch(i){const 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)return;this._disposed=!0;const e=Array.from(this._extensions.values()).reverse();this._extensions.clear();for(const t of e)this._disposeExtension(t)}_disposeExtension(e){try{var t;const i=null===(t=e.dispose)||void 0===t?void 0:t.call(e);i&&Ct(i.then)&&i.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)}}},uS=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const s of e){const e=null==t?void 0:t.get_property(s);It(e)||(i[s]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}};const dS="extensionsRemoteConfig";var hS=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=Vn,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new uS(e),this.onEvent=e=>Sg(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 Sg(()=>{});const t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(dS,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),Sg(i)},this._runtime=new cS(Vn.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(){const e=this.instance.get_property(g);return"string"==typeof e?e:void 0}get library(){return{name:Ya.LIB_NAME,version:Ya.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s;const n=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==n?void 0:n.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==n?void 0:n.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.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 rt(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 Sg(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(dS,e))}sendRequest(e){var t=this;return rt(function*(e,i={}){var s;const n=t.instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),r={method:i.method,url:i.query?Tb(n,i.query):n,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?dt.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(t.instance._send_request(r),{statusCode:202}):new Promise(e=>{r.callback=e,t.instance._send_request(r)})}).apply(this,arguments)}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}};const pS={};let _S=0;const gS=()=>{},fS='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',vS="Surveys module not available",mS="sanitize_properties is deprecated. Use before_send instead",yS="Invalid value for property_denylist config: ",bS=/^[A-Za-z0-9_-]{1,400}$/,SS=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,wS=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,kS=["token","distinct_id",Ae],CS="posthog",ES=e=>{const 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},xS=t=>{var i;return ct({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ir(null==s?void 0:s.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:gS,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:n&&Tt(null==n?void 0:n.search)&&-1!==n.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==e||null===(i=e.location)||void 0===i?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){Vn.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:Je,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:gS},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Lr,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:ES(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)}))(t))},IS=[["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"]],TS=e=>{const t={};for(const[i,s]of IS)It(e[i])||(t[s]=e[i]);const i=Zn({},t,e),s=e.__preview_external_dependency_versioned_paths;return It(s)||(It(e.strict_script_versioning)&&(i.strict_script_versioning=!!s),Tt(s)&&It(e.asset_host)&&(i.asset_host=s)),kt(e.property_blacklist)&&(It(e.property_denylist)?i.property_denylist=e.property_blacklist:kt(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Vn.error(yS+e.property_denylist)),i};var MS=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Vn.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},RS=class t{_removeExtension(e){if(!e)return;const t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}_replaceExtension(e,t){var i;return this._removeExtension(e),this._extensions.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this._inCookielessMode())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this._hasStableInitialDistinctId)return;let t,i,s;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}_healCookielessSentinelDistinctId(){if(this._inCookielessMode()||"$posthog_cookieless"!==this.get_distinct_id())return;const e=this.persistence;if(!e)return;this._is_persistence_disabled()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(Ra());this.register({distinct_id:t,$device_id:t}),e.set_property(xe,Ke)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new MS,this._personProcessingSetOncePropertiesSent=!1,this.version=Ya.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Kb,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=xS(),this.SentryIntegration=Ky,this.sentryIntegration=e=>function(e,t){const i=Qy(e,t);return{name:Gy,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 Vb(this),this.pageViewManager=new Zy(this),this.rateLimiter=new mb(this),this.requestRouter=new rS(this),this.consent=new qy(this),this.externalIntegrations=new lS(this);const i=null!==(e=t.__defaultExtensionClasses)&&void 0!==e?e:{};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)=>{const s=Tt(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=Tt(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>Vn.info(`send "${null==e?void 0:e.event}"`,e))}init(e,i,s){if(s&&s!==CS){var n;const r=null!==(n=pS[s])&&void 0!==n?n:new t;return r._init(e,i,s),pS[s]=r,pS[CS][s]=r,r}return this._init(e,i,s)}_init(t,i={},s){var n,r,o;const a=Tt(t)?t.trim():"";if(!a)return Vn.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=xS(i.defaults),i.debug=this._checkLocalStorageForDebug(i.debug),this._originalUserConfig=i,this._triggered_notifs=[],i.person_profiles?this._initialPersonProfilesConfig=i.person_profiles:i.process_person&&(this._initialPersonProfilesConfig=i.process_person);const c=xS(i.defaults),u=TS(i),d=Zn({},c,u,{name:s,token:a});Et(c.rageclick)&&Et(u.rageclick)&&(d.rageclick=Zn({},c.rageclick,u.rageclick)),Et(c.session_recording)&&Et(u.session_recording)&&(d.session_recording=Zn({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Vn.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:cg.GZipJS;const h=this._is_persistence_disabled();if(this.persistence=new pb(this.config,h),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new pb(ct(ct({},this.config),{},{persistence:"sessionStorage"}),h,!1),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&Ja._is_supported()){const e=Ja._parse(this._sessionRegisteredPropertiesStorageKey);kt(e)&&e.forEach(e=>{Tt(e)&&this._sessionRegisteredPropKeys.add(e)})}else Ja._remove(this._sessionRegisteredPropertiesStorageKey);const p=ct({},this.persistence.props),_=ct({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Wb((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new jb(this),this.__request_queue=[];const g=this._inCookielessMode();g||(this.sessionManager=new Yb(this),this.sessionPropsManager=new Qb(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Vn.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._initExtensions(g)},0)):(Vn.info("Initializing extensions synchronously"),this._initExtensions(g)),Ya.DEBUG=Ya.DEBUG||this.config.debug,Ya.DEBUG&&Vn.info("Starting in debug mode",{this:this,config:i,thisC:ct({},this.config),p:p,s:_}),this.config.identity_distinct_id&&!(null===(n=i.bootstrap)||void 0===n?void 0:n.distinctID)&&(i.bootstrap=ct(ct({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const v=null===(r=i.bootstrap)||void 0===r?void 0:r.distinctID;if(this._hasStableInitialDistinctId=!!v&&!Mt(v),null===(o=i.bootstrap)||void 0===o?void 0:o.distinctID){const e=i.bootstrap.distinctID,t=this.get_distinct_id(),s=this.persistence.get_property(xe);if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"anonymous"===s)this.identify(e);else if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"identified"===s)Vn.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const t=this.config.get_device_id(Ra()),s=i.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(xe,i.bootstrap.isIdentifiedID?Ze:Ke),this.register({distinct_id:e,$device_id:s})}}if(g)this.register_once({distinct_id:Le,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(Ra());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(xe,Ke)}return sr(e,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),sr(e,"pageshow",()=>{var e;this._isPageUnloading=!1,this._isShutdown||null===(e=this._retryQueue)||void 0===e||e.resume()}),i.segment?Vy(this,()=>this._loaded()):this._loaded(),Ct(this.config._onCapture)&&this.config._onCapture!==gS&&(Vn.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Vn.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 eS.apply(this,arguments)}().then(e=>{e&&this.register({[f]:e})}).catch(gS),this}_isSharedExtension(e){const t=e;return Tt(t.name)&&Ct(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>{var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}).catch(t=>{Vn.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this._extensions.push(e)}_enrollFeatureFlags(){var e,i,s;const n=null!==(e=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==e?e:null===(s=t.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,a;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this._featureFlagsReloadingUnsubscribe)||void 0===r||r.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new n(this)),Ct(this.featureFlags.onReloading)&&Ct(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):null===(o=(a=this.featureFlags).initialize)||void 0===o||o.call(a))}_initExtensions(e){const i=performance.now(),s=ct(ct({},t.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,d;s.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this._extensions.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this._extensions.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this._extensions.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this._enrollExtension(this.autocapture=new s.autocapture(this),n),s.surveys&&this._enrollExtension(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this._enrollExtension(this.logs=null!==(a=this.logs)&&void 0!==a?a:new s.logs(this),n),s.metrics&&this._extensions.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new s.metrics(this)),s.conversations&&this._extensions.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new s.conversations(this)),s.productTours&&this._extensions.push(this.productTours=new s.productTours(this)),s.heatmaps&&this._extensions.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this._extensions.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,Wy)),s.toolbar&&this._extensions.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this._extensions.forEach(e=>{e.initialize&&n.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),n.push(()=>{if(this._pendingRemoteConfig){const e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this._processInitTaskQueue(n,i)}_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);const i=e.shift();if(i)try{i()}catch(e){Vn.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[Oe]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[De]:i}),this.config.__preview_deferred_init_extensions&&Vn.info(`PostHog extensions initialized (${i}ms)`)}_onRemoteConfig(e){var t;if(!s||!s.body)return Vn.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;const t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=ft(t.supportedCompression,cg.GZipJS)?cg.GZipJS:ft(t.supportedCompression,cg.Base64)?cg.Base64:void 0),(null===(i=t.analytics)||void 0===i?void 0:i.endpoint)&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Je}),null===(t=this._browserClientAdapter)||void 0===t||t.handleRemoteConfig(e),this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}_loaded(){try{this.config.loaded(this)}catch(e){Vn.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&(null==n?void 0:n.hostname)){const e=n.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 bb(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&Qn(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,n,r;this._isPageUnloading=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(tt),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this._requestQueue)||void 0===n||n.unload(),null===(r=this._retryQueue)||void 0===r||r.unload()):this._shouldCapturePageleave()&&this.capture(tt,null,{transport:"sendBeacon"})}_send_request(e){Ub(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?ct(ct({},e),{},{transport:t}):e)}_execute_array(e){_S++;try{let t;const i=[],s=[],n=[];Qn(e,e=>{if(e)if(t=e[0],kt(t))n.push(e);else if(Ct(e))try{e.call(this)}catch(t){Vn.error("Error executing queued PostHog call",e,t)}else kt(e)&&"alias"===t?i.push(e):kt(e)&&-1!==t.indexOf("capture")&&Ct(this[t])?n.push(e):s.push(e)});const r=function(e,t){Qn(e,function(e){try{if(kt(e[0])){let i=t;Kn(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Vn.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(s,this),r(n,this)}finally{_S--}}push(e){if(_S>0&&kt(e)&&Tt(e[0])){const i=t.prototype[e[0]];return void(Ct(i)&&i.apply(this,e.slice(1)))}this._execute_array([e])}get _facebookClickIdChannel(){return{property:y,persistenceKey:b,cookieName:"_fbc",pattern:SS,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[b]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(b)}}}get _facebookBrowserIdChannel(){return{property:S,persistenceKey:w,cookieName:"_fbp",pattern:wS,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[w]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(w)}}}_getPersistedMetaIdentifier(e){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(e.persistenceKey);return Tt(i)&&e.pattern.test(i)?{value:i,delivered:!1}:Et(i)&&Tt(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;const t=Ca(e.cookieName);return Tt(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,i,s){if(!this.persistence)return;const n=this._facebookClickIdChannel;this.persistence.refreshKey(n.persistenceKey);const r=this._getPersistedMetaIdentifier(n);if(s)return void n.unregister();if(i)return Tt(t)&&SS.test(t)?this._storeMetaIdentifier(n,t,r):void n.unregister();const o=Tt(e)&&bS.test(e)?e:void 0,a=this._readMetaCookie(n);return a&&((e,t,i)=>{const s=e.split(".");if(t)return s[3]===t;if(!i)return!0;const n=i.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(a,o,r)?this._storeMetaIdentifier(n,a,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this._storeMetaIdentifier(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}_updateFacebookBrowserId(e,t,i){if(!this.persistence)return;const s=this._facebookBrowserIdChannel;this.persistence.refreshKey(s.persistenceKey);const n=this._getPersistedMetaIdentifier(s);if(i)return void s.unregister();if(t)return Tt(e)&&wS.test(e)?this._storeMetaIdentifier(s,e,n):void s.unregister();const r=this._readMetaCookie(s);return r?this._storeMetaIdentifier(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);const i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}capture(e,t,i){var s,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void Vn.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(It(e)||!Tt(e))return void Vn.error("No event name provided to posthog.capture");this._healCookielessSentinelDistinctId();const r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;const o=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==o?void 0:o.isRateLimited)return void Vn.critical("This capture call is ignored due to client rate limiting.");let a;(null==t?void 0:t.$current_url)&&!Tt(null==t?void 0:t.$current_url)&&(Vn.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?void 0:i._originatedFromCaptureException)||Vn.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&&(a=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const l=new Date,c=(null==i?void 0:i.timestamp)||l,u=os(null==i?void 0:i.uuid,Ra);let d={uuid:u,event:e,properties:this.calculateEventProperties(e,t||{},c,u)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&r&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),o&&(d.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens);const h="$feature_flag_called"===e&&!1===d.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!h&&(d.$set=null==i?void 0:i.$set);const p=Et(null==t?void 0:t.$set)?t.$set:void 0,_=kt(null==t?void 0:t.$unset)?t.$unset:[],g=(null==i?void 0:i.$unset)||[],f=e=>{var t;const s=!!(null==i?void 0:i.$set)&&e in i.$set;return{hasProvided:s||!!p&&e in p,provided:s?null==i||null===(t=i.$set)||void 0===t?void 0:t[e]:null==p?void 0:p[e],unset:-1!==_.indexOf(e)||-1!==g.indexOf(e)}},v=f(y),m=f(S),b=[{channel:this._facebookClickIdChannel,hasProvided:v.hasProvided,update:this._updateFacebookClickId(null==a?void 0:a.fbclid,v.provided,v.hasProvided,v.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:m.hasProvided,update:this._updateFacebookBrowserId(m.provided,m.hasProvided,m.unset)}];for(const{channel:e,hasProvided:t,update:i}of b)i&&!0===d.properties.$process_person_profile&&i.pending&&!t&&!h&&(d.$set=ct({[e.property]:i.value},d.$set));const w=null==i?void 0:i.$unset;w&&(d.$unset=w);const k=h?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==st,e===it);if(k&&(d.$set_once=k),(null==i?void 0:i._noTruncate)||(C=this.config.properties_string_max_length,d=function(e,t){const i=new Set;return function e(s,n){if(s!==Object(s))return t?t(s):s;if(i.has(s))return;let r;if(i.add(s),kt(s))r=[],Qn(s,t=>{r.push(e(t))});else{const t={};Kn(qt(s)?er(s):s,(s,n)=>{i.has(s)||(t[n]=e(s,n))}),r=t}return r}(e)}(d,e=>Tt(e)?e.slice(0,C):e)),d.timestamp=c,It(null==i?void 0:i.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=l),h&&(d.properties=((e,t=[])=>{const i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return on.forEach(s),t.forEach(s),i})(d.properties,kS)),e===mg.DISMISSED||e===mg.SENT){const i=null==t?void 0:t[yg.SURVEY_ID],s=null==t?void 0:t[yg.SURVEY_ITERATION];Mg({id:i,current_iteration:s}),d.$set=ct(ct({},d.$set),{},{[rl({id:i,current_iteration:s},e===mg.SENT?"responded":"dismissed")]:!0})}else e===mg.SHOWN&&(d.$set=ct(ct({},d.$set),{},{[yg.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var C;if(e===gb.SHOWN){const e=null==t?void 0:t[fb.TOUR_TYPE];e&&(d.$set=ct(ct({},d.$set),{},{[`${fb.TOUR_LAST_SEEN_DATE}/${e}`]:(new Date).toISOString()}))}const E=ct(ct({},d.properties.$set),d.$set);if(xt(E)||this.setPersonPropertiesForFlags(E),!Pt(this.config.before_send)){const e=this._runBeforeSend(d);if(!e)return;d=e,d.uuid=os(d.uuid,Ra)}const x=b.filter(({channel:e,update:t})=>{var i,s,n;const r=null!==(i=null===(s=d.$set)||void 0===s?void 0:s[e.property])&&void 0!==i?i:Et(null===(n=d.properties)||void 0===n?void 0:n.$set)?d.properties.$set[e.property]:void 0;return(null==t?void 0:t.pending)&&r===t.value});this._internalEventEmitter.emit("eventCaptured",d);const I=null!==(s=null==i?void 0:i._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),T="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(I),M=ct(ct(ct({method:"POST",url:I,data:d,compression:"best-available",timestampMode:T?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},T&&(null===(n=d.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),x.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(const{channel:e,update:t}of x)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)||x.length){var R;let e;!M.transport&&!M.callback&&xt(null!==(R=this.config.request_headers)&&void 0!==R?R:{})&&this._isPageUnloading&&(e="sendBeacon"),this._send_retriable_request(M,e)}else this._requestQueue.enqueue(M);return d}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this._browserClientAdapter)||void 0===t?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new hS(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}_processCookieIdentityChange(e=!0){var t,i,s;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this._cachedPersonProperties=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,i,r,o,a){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this._processCookieIdentityChange();const l=a?void 0:this.persistence.remove_event_timer(t);let u=ct({},i);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this._inCookielessMode()&&(u[Ae]=!0),"$snapshot"===t){const e=ct(ct({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=e.distinct_id,(!Tt(u.distinct_id)&&!Ft(u.distinct_id)||Mt(u.distinct_id))&&Vn.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}const d=function(t,i,s,r=!1){var o,a,l,u;if(!c)return{};const d=t?[...El,...i||[]]:[],[h,p]=Qi(c),[_,g]=function(e){for(let t=0;Yi.length>t;t++){const[i,s,n]=Yi[t],r=e.match(i);if(r){const t=n&&e.match(n)||r;return[s,(null==t?void 0:t[1])||""]}}return["",""]}(c),f=function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}}(),v={};It(s)||(v.detectGoogleSearchApp=s);const m={},y=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,b=null===(a=navigator)||void 0===a?void 0:a.maxTouchPoints,S=null==e||null===(l=e.screen)||void 0===l?void 0:l.width,w=null==e||null===(u=e.screen)||void 0===u?void 0:u.height,k=null==e?void 0:e.devicePixelRatio;It(y)||(m.userAgentDataPlatform=y),It(b)||(m.maxTouchPoints=b),It(S)||(m.screenWidth=S),It(w)||(m.screenHeight=w),It(k)||(m.devicePixelRatio=k);const C=Zn(Xn({$os:h,$os_version:p,$browser:zi(c,navigator.vendor,f,v),$webview_app:_,$webview_app_version:g,$device:Ki(c),$device_type:Zi(c,m),$timezone:Nl(),$timezone_offset:Bl()}),{$current_url:ur(r?ls(null==n?void 0:n.href):null==n?void 0:n.href,d,Il),$host:null==n?void 0:n.host,$pathname:null==n?void 0:n.pathname,$raw_user_agent:c.length>1e3?c.substring(0,997)+"...":c,$browser_version:Vi(c,navigator.vendor,f,v),$browser_language:Fl(),$browser_language_prefix:Ll(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:zn.LIB_NAME,$lib_version:zn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return zn.SDK_DIST_CHANNEL&&(C.$sdk_dist_channel=zn.SDK_DIST_CHANNEL),C}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(a,r.getTime(),!0);u.$session_id=e,u.$window_id=t}this.sessionPropsManager&&Zn(u,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&Zn(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=null===(h=this._retryQueue)||void 0===h?void 0:h.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}let p;if(this.requestRouter.region===tS&&(u.$lib_custom_api_host=this.config.api_host),p="$pageview"!==t||a?"$pageleave"!==t||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),u=Zn(u,p),"$pageview"===t&&s&&(u.title=s.title),!It(l)){const e=r.getTime()-l;u.$duration=parseFloat((e/1e3).toFixed(3))}c&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser");const _=this.persistence.properties(),g=this.sessionPersistence.properties(),f=u.$groups,v=_.$groups;Et(f)&&!xt(f)&&(u.$groups=ct(ct({},Et(v)?v:{}),f)),Kn(["$referrer","$referring_domain"],e=>{e in _&&delete g[e]});const m={};if(this._extensionEventPropertyProducers.length>0)for(const e of this._extensionEventPropertyProducers.slice())try{Zn(m,e())}catch(e){Vn.error("Failed to produce browser extension event properties",e)}u=Zn({},d,_,g,ct(ct({},m),u)),u.$is_identified=this._isIdentified(),kt(this.config.property_denylist)?Kn(this.config.property_denylist,function(e){delete u[e]}):Vn.error(yS+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(Vn.error(mS),u=y(u,t));const b=this._hasPersonProcessing();return u.$process_person_profile=b,b&&!a&&this._requirePersonProcessing("_calculate_event_properties"),u}_calculate_set_once_properties(e,t=!0,i=!1){var s;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Zn({},n,r||{},e||{});const a=this.config.sanitize_properties;return a&&(Vn.error(mS),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),xt(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this._processCookieIdentityChange(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),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)||void 0===t||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(!this._sessionRegisteredPropertiesStorageKey)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e._disabled)||!Ja._is_supported())return void Ja._remove(this._sessionRegisteredPropertiesStorageKey);const t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Ja._set(this._sessionRegisteredPropertiesStorageKey,t):Ja._remove(this._sessionRegisteredPropertiesStorageKey)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var s;return null===(s=this.featureFlags)||void 0===s?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:vS}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:vS})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:vS})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=Pg){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:vS}}canRenderSurveyAsync(e,t=!1){var i,s;return null!==(i=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:vS})}_validateIdentifyId(e){return!e||Mt(e)?(Vn.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Vn.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())||(Vn.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 Vn.uninitializedWarning("posthog.identify");if(Ft(e)&&(e=e.toString(),Vn.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))return;if(!this._requirePersonProcessing("posthog.identify"))return;this._healCookielessSentinelDistinctId();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property("__alias")&&(this.unregister(v),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Ke,c=e!==s,u=!c&&o;if(c&&o){var l;const n=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:s};this.persistence.set_property(xe,Ze),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",n,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=vl(e,t,i)),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(u){this.persistence.set_property(xe,Ze);const s=t||{},n=i||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:s,$set_once:n})&&(this._cachedPersonProperties=vl(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);c||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(we)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this._requirePersonProcessing("posthog.setPersonProperties"))return;const i=vl(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)):Vn.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(kt(e)?e:[e]).filter(e=>Tt(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var s;if(!e||!t)return void Vn.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this._processCookieIdentityChange();const n=this.getGroups(),r=n[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ct(ct({},n),{},{[e]:t})}),(r||i)&&this._hasPersonProcessing()){const s={$group_type:e,$group_key:t};i&&(s.$group_set=i),this.capture(st,s)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=At(e)?e:null==e?void 0:e.resetDeviceID,i=At(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t=!1,i){var s,n,r,o,a,l;if(Vn.info("reset"),!this.__loaded)return Vn.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(s=this._originalUserConfig)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this._shouldDisableFlags());const u=this.get_property(g),d=this.get_property(f),h=this.get_property(A);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const 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.");const _=null===(a=this.persistence)||void 0===a||null===(l=a._beginCookieSyncSuppression)||void 0===l?void 0:l.call(a);let v=!1;try{var m,y,b,S,w,k,C,E,x,I,T,M,R;if(null===(m=this.persistence)||void 0===m||m.clear(),null===(y=this.sessionPersistence)||void 0===y||y.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),It(h)||null===(I=this.persistence)||void 0===I||I.register({$session_recording_remote_config:h}),null===(b=this.surveys)||void 0===b||b.reset(),null===(S=this.featureFlags)||void 0===S||S.reset(),null===(w=this.conversations)||void 0===w||w.reset(),null===(k=this.logs)||void 0===k||k.reset(),null===(C=this.metrics)||void 0===C||C.reset(),null===(E=this.persistence)||void 0===E||E.set_property("$user_state","anonymous"),null===(x=this.sessionManager)||void 0===x||x.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Le,$device_id:null},"");else{const t=this.config.get_device_id(Ra());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||It(d)||this.register({[f]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(i.distinctID&&!this._inCookielessMode()&&(null===(R=this.persistence)||void 0===R||R.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(T=this.featureFlags)||void 0===T||T.initialize(),!Pt(c)&&!(null===(M=this.sessionManager)||void 0===M?void 0:M.setBootstrapSessionId(c,!0))){const e=ct({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,v=!0}finally{var P,F;_&&(null===(P=this.persistence)||void 0===P||null===(F=P._endCookieSyncSuppression)||void 0===F||F.call(P,v))}this.reloadFeatureFlags()}shutdown(e){var t=this;return rt(function*(){var e,i,s,n,r,o,a,l;if(t.__loaded){t._isShutdown=!0,t._getBrowserClientAdapter().dispose(),null===(e=t.sessionRecording)||void 0===e||e.dispose(),null===(i=t.logs)||void 0===i||i.flushLogs("sendBeacon"),null===(s=t.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=t.metrics)||void 0===n||n.dispose(),null===(r=t._requestQueue)||void 0===r||r.unload(),null===(o=t._retryQueue)||void 0===o||o.unload();try{var c;null===(c=t.featureFlags)||void 0===c||c.destroy()}catch(e){Vn.error("Error while destroying feature flags",e)}null===(a=t.persistence)||void 0===a||a.destroy(),null===(l=t.sessionPersistence)||void 0===l||l.destroy()}else Vn.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)||void 0===i||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)||void 0===e||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?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(Vn.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(It(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(v,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Vn.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=ct({},this.config);if(Et(e)){var i,s,n,r,o,a,l,c,u,d,h,p,_,g;Zn(this.config,TS(e));const v=this._is_persistence_disabled();null===(i=this.persistence)||void 0===i||i.update_config(this.config,t,v),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new pb(ct(ct({},this.config),{},{persistence:"sessionStorage"}),v,!1);const m=this._checkLocalStorageForDebug(this.config.debug);var f;At(m)&&(this.config.debug=m),At(this.config.debug)&&(this.config.debug?(Ya.DEBUG=!0,$a._is_supported()&&$a._set("ph_debug",!0),Vn.info("set_config",{config:e,oldConfig:t,newConfig:ct({},this.config)})):(Ya.DEBUG=!1,$a._is_supported()&&$a._remove("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this._shouldDisableFlags()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(c=this.tracingHeaders)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(f=this.historyAutocapture)||void 0===f||f.startIfEnabledOrStop()),null===(h=this.exceptionObserver)||void 0===h||h.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(_=this.surveys)||void 0===_||_.loadIfEnabled(),this._sync_opt_out_with_persistence(),null===(g=this.externalIntegrations)||void 0===g||g.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&Vy(this,gS,!1)}}_overrideSDKInfo(e,t){Ya.LIB_NAME=e,Ya.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var s,n,r,o,a;Object.values(i).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!!(null===(e=this.sessionRecording)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(ct(ct({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var e,i;return null!==(e=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==e?e:t._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?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:CS;return t!==CS&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?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()&&xt(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0: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?(Vn.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(Fe,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;const 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;const i=this._is_persistence_disabled();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s._onOptOut(),(null===(e=this.persistence)||void 0===e?void 0:e._disabled)!==i&&(null===(n=this.persistence)||void 0===n||n.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t._disabled)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),i&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),i}opt_in_capturing(e){var i;if("always"!==this.config.cookieless_mode){if(this._inCookielessMode()){var s,n,r,o,a,l;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Yb(this),this.pageViewManager=new Zy(this),this.persistence&&(this.sessionPropsManager=new Qb(this,this.sessionManager,this.persistence));const e=null!==(o=null===(a=this.config.__extensionClasses)||void 0===a?void 0:a.sessionRecording)&&void 0!==o?o:null===(l=t.__defaultExtensionClasses)||void 0===l?void 0:l.sessionRecording;var c,u;e&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new e(this)),this._lastRemoteConfig&&(null===(c=this.sessionRecording)||void 0===c||null===(u=c.onRemoteConfig)||void 0===u||u.call(c,this._lastRemoteConfig)))}var d,h;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(It(null==e?void 0:e.captureEventName)||(null==e?void 0:e.captureEventName))&&this.capture(null!==(h=null==e?void 0:e.captureEventName)&&void 0!==h?h:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else Vn.warn(fS)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void Vn.warn(fS);const e="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var t,i;null==e||e.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:Le,$device_id:null}),this._removeExtension(e),this.sessionRecording=void 0,null===(t=this.sessionManager)||void 0===t||t.destroy(),null===(i=this.pageViewManager)||void 0===i||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const 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 i?Xb(i,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){s&&("visible"===s.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(et,{title:s.title},{send_instantly:!0}),this._visibilityStateListener&&(s.removeEventListener(Ye,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),sr(s,Ye,this._visibilityStateListener)))}debug(t){!1===t?(null==e||e.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==e||e.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){const 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?(Vn.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,n){const r=t in e&&!Pt(e[t]),o=i in e&&!Pt(e[i]);return r?e[t]:!!o&&(n&&n.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,Vn)}_runBeforeSend(e){var t;if(Pt(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter($t),s=kt(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=e;for(const t of s)try{if(n=t(n),Pt(n)){const t=`Event '${e.event}' was rejected in beforeSend function`;return Dt(e.event)?Vn.warn(`${t}. This can cause unexpected behavior.`):Vn.info(t),null}n.properties&&!xt(n.properties)||Vn.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Vn.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(n.properties&&Pt(n.properties[t]))return Vn.warn(`Event '${e.event}' had its '${t}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var e;return null===(e=this.pageViewManager._currentPageview)||void 0===e?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){const t=At(e)&&!e,i=$a._is_supported()&&"true"===$a._get("ph_debug");return!t&&(!!i||e)}};RS.__defaultExtensionClasses={},RS._noopLogger=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Yn(e.prototype[t[i]])}(RS,["identify"]);var PS=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,i=Et(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}};const FS=Gn("[ExceptionAutocapture]"),LS=Gn("[TracingHeaders]"),AS=Gn("[Web Vitals]"),OS=9e5,DS=["CLS","FCP","INP","LCP"],$S=["INP","LCP"],NS=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],BS=Gn("[SessionRecording]"),qS=Gn("[Heatmaps]");function HS(e){return Et(e)&&"clientX"in e&&"clientY"in e&&Ft(e.clientX)&&Ft(e.clientY)}const US=Gn("[Product Tours]"),WS=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(P))},zS=["$set_once","$set"],jS=Gn("[SiteApps]"),VS="Error while initializing PostHog app with config id ",GS=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),QS="SDK is not enabled or survey functionality is not yet loaded",KS="Disabled. Not loading surveys.";var ZS=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)return;if(this._config.disableSurveys)return;if(!e.ok)return wg.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(Pt(t))return wg.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=At(t)?t:t.length>0,wg.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()}}setup(e){if(!this._disposed)return this._initializingClient=e,GS(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(s=i.dispose)||void 0===s||s.call(i),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)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let e=0;e<localStorage.length;e++){const i=localStorage.key(e);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&t.push(i)}t.forEach(e=>localStorage.removeItem(e))}catch(e){}}loadIfEnabled(){if(this._disposed||!this._client)return;const e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void wg.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void wg.info(KS);if(e.cookielessMode&&this._configSource.isOptedOut())return void wg.info("Not loading surveys in cookieless mode without consent.");const t=this._configSource.getExtensions();if(!t)return void wg.error("PostHog Extensions not found.");if(It(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;const i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0;try{const e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,i),void(this._isInitializingSurveys=!1);const s=t.loadExternalDependency;if(!s)return this._handleSurveyLoadError(Qe),void(this._isInitializingSurveys=!1);s(e=>{try{if(this._disposed)return;const t=this._configSource.getExtensions();e||!(null==t?void 0: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}}_completeSurveyInitialization(e,t){this._disposed||(this._surveyManager=e(t),this._surveyEventReceiver=this._configSource.createEventReceiver(),wg.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0}))}_handleSurveyLoadError(e,t){wg.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=!1){var i;const s=null!==(i=this._client)&&void 0!==i?i:this._initialClientState;if(!s||this._disposed)return;if(this._config.disableSurveys)return wg.info(KS),e([]);const n=s.kv.get(ue);if(n&&!t)return e(n,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:i})=>{this._disposed||e(t,i)}).catch(e=>wg.error("Error in survey callback",e));const r=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 wg.error("Error processing surveys response",e),this._handleSurveyResponse(s,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(s,{statusCode:0,error:e}));this._getSurveysInFlightPromise=r;const o=()=>{this._getSurveysInFlightPromise===r&&(this._getSurveysInFlightPromise=null)};r.then(t=>{o(),this._disposed||e(t.surveys,t.context)},o).catch(e=>wg.error("Error in survey callback",e))}_sendSurveysRequest(e,t){const i=this._client;return i?i.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:new Error(QS)}))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:QS}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?wg.error(e):t.error||wg.warn(e),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;const s=t.json.surveys||[],n=s.filter(e=>Eg(e)&&(dl(e)||xg(e)));var r;return n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n)),e.kv.set({[ue]:s,[de]:Date.now()}),{surveys:s,context:{isLoaded:!0}}}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e,t;const i=null===(e=null!==(t=this._client)&&void 0!==t?t:this._initialClientState)||void 0===e?void 0:e.kv.get(de);return Ft(i)&&Date.now()-i>3e5}_isSurveyRefreshBackingOff(){return Ft(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;const s={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Mg(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}_notifySurveyCallbacks(e){for(const t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){wg.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t=!1){if(!Pt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);wg.warn("init was not called")}_getSurveyById(e){let 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:QS};const t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){if(!this._configSource.isCapturing())return{eligible:!1,reason:kg};if(Pt(this._surveyManager))return{eligible:!1,reason:QS};const 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 wg.warn("init was not called"),{visible:!1,disabledReason:QS};const t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Pt(this._surveyManager)?(wg.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:QS})):new Promise(i=>{this.getSurveys(t=>{var s;const n=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(n){const e=this._checkSurveyRenderability(n);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var n;if(!this._configSource.isCapturing())return;if(Pt(this._surveyManager))return void wg.warn("init was not called");const r="string"==typeof e?this._getSurveyById(e):e;if(!(null==r?void 0:r.id))return void wg.warn("Survey not found");if(!Rg.includes(r.type))return void wg.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const o=null==s?void 0:s.querySelector(t);if(o){if(null===(n=r.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds){wg.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,s;this._renderTimeouts.delete(e),!this._disposed&&this._configSource.isCapturing()&&(wg.info(`Rendering survey ${r.id} with delay of ${null===(t=r.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(r,o,i),wg.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this._renderTimeouts.add(e)}this._surveyManager.renderSurvey(r,o,i)}else wg.warn("Survey element not found")}displaySurvey(e,t){var i;if(!this._configSource.isCapturing())return;if(Pt(this._surveyManager))return void wg.warn("init was not called");const s=this._getSurveyById(e);if(!s)return void wg.warn("Survey not found");let n=s;if((null===(i=s.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)&&t.ignoreDelay&&(n=ct(ct({},s),{},{appearance:ct(ct({},s.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==bg.Popover&&t.initialResponses&&wg.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this._checkSurveyEligibility(s);if(!e.eligible)return void wg.warn("Survey is not eligible to be displayed: ",e.reason)}t.displayType!==bg.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}cancelPendingSurvey(e){Pt(this._surveyManager)?wg.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}};function JS(e,t,i){if(Pt(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var YS=class{constructor(e){this._instance=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Kb,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?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;It(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this._captureHookUnsubscribe=null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;null===(e=this._captureHookUnsubscribe)||void 0===e||e.call(this),this._captureHookUnsubscribe=void 0,this._debugEventEmitter=new Kb}register(e){var t,i;if(!It(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null===(i=this._instance)||void 0===i?void 0:i.autocapture)){const e=new Set;this._actionRegistry.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._instance.autocapture.setElementSelectors(e)}}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(const 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?void 0:t.url){var i;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!JS(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?void 0:t.href))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>JS(e.href,t.href,t.href_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&JS(function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""}(n),t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(!(null==t?void 0:t.text))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>JS(e.text,t.text,t.text_matching||"exact")||JS(e.$el_text,t.text,t.text_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&(r=function(e){const t=[],i=/(?::|")text="(.*?)"/g;let s;for(;!Pt(s=i.exec(e));)t.includes(s[1])||t.push(s[1]);return t}(n),o=t.text,a=t.text_matching||"exact",r.some(e=>JS(e,o,a)));var r,o,a}_checkStepSelector(e,t){var i,s;if(!(null==t?void 0:t.selector))return!0;const n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==n?void 0:n.includes(t.selector))return!0;const r=(null==e||null===(s=e.properties)||void 0===s?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?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||fl(t.properties.reduce((e,t)=>{const i=kt(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)}},XS=class{constructor(e){var t,i;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,this._sessionIdUnsubscribe=null===(t=this._instance)||void 0===t||null===(i=t.onSessionId)||void 0===i?void 0:i.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&fl(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){const i=new Map;return e.forEach(e=>{var s;null===(s=e.conditions)||void 0===s||null===(s=s[t])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(t=>{if(null==t?void 0:t.name){const s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}_getMatchingItems(e,t,i){const s=(i===ug.Activation?this._eventToItems:this._cancelEventToItems).get(e);let n=[];return this._getItems(e=>{n=e.filter(e=>null==s?void 0:s.includes(e.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[i])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(t=>t.name===e);return this._doesEventMatchFilter(r,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){var i;It(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var s;if(t&&this._actionToItems.clear(),0===i.length)return void(t&&(null===(s=this._actionMatcher)||void 0===s||s.replace([])));this._actionMatcher||(this._actionMatcher=new YS(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));const n=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(n.push(t),t.name){var i;const s=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];s.includes(e.id)||s.push(e.id),this._actionToItems.set(t.name,s)}})}),t?this._actionMatcher.replace(n):this._actionMatcher.register(n)}_mergeItemMaps(e,t){t.forEach((t,i)=>{var s;const n=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{n.includes(e)||n.push(e)}),e.set(i,n)})}_setupEventBasedItems(e,t){var i,s;const n=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=this._buildEventToItemMap(e,ug.Activation),a=this._buildEventToItemMap(e,ug.Cancellation);t?(this._eventToItems=o,this._cancelEventToItems=a):(this._mergeItemMaps(this._eventToItems,o),this._mergeItemMaps(this._cancelEventToItems,a)),(0!==n.length||0!==r.length)&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s;const n=this._getLogger(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(s=t.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const t=this._activationOutcome(e,r);if("consume"===t)return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._deactivateItems([r]);if("persist"===t)return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this._persistActivation(r),void this._clearActivationTimestamps([r])}if(this._cancelEventToItems.has(e)){const i=this._getMatchingItems(e,t,ug.Cancellation);i.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._deactivateItems(i.map(e=>e.id)),i.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});const o=this._getMatchingItems(e,t,ug.Activation);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){var t,i;if(0===e.length)return;const s=!!(null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t)),n=[];for(const t of e)s&&this._shouldPersistArmedActivation(t)?this._persistActivation(t)&&this._recordActivationTimestamp(t):n.push(t);n.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...n])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()})}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);const t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){const t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));const 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;const t=this._getActivationTimestampsKey();if(!t)return{};const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[t];return i&&"object"==typeof i?i:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps();this._writeActivationTimestamps(ct(ct({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps(),i={};let s=!1;for(const[n,r]of Object.entries(t))e.includes(n)?s=!0:i[n]=r;s&&(xt(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;const t=this._getRawActivationTimestamps()[e];return Ft(t)?t:void 0}_getRawPersistedActivatedIds(){var e;const t=this._getActivatedKey();return(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,i;const s=this._getRawPersistedActivatedIds();if(0===s.length)return[];const n=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[this._getActivatedSessionKey()],r=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);return r&&n===r?s:[]}_stampActivationSession(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(t=e.get_session_id)||void 0===t?void 0:t.call(e);i&&this._setActivatedSession(i)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this._getActivatedSessionKey()];if(i&&i!==e){const e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>Ft(t[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)||void 0===e||e.call(this),this._sessionIdUnsubscribe=void 0,null===(t=this._captureHookUnsubscribe)||void 0===t||t.call(this),this._captureHookUnsubscribe=void 0,null===(i=this._actionMatcher)||void 0===i||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}},ew=class extends XS{constructor(e){super(e)}_getActivatedKey(){return he}_getActivatedSessionKey(){return pe}_getActivationTimestampsKey(){return _e}_writeActivationTimestamps(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated_timestamps:e})}_clearActivationTimestampsStore(){var e;null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.unregister("$surveys_activated_timestamps")}_shouldPersistArmedActivation(e){var t;let i;this._getItems(t=>{i=t.find(t=>t.id===e)});const s=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return Ft(s)&&s>0}_getShownEventName(){return mg.SHOWN}_getItems(e){var t;null===(t=this._instance)||void 0===t||t.getSurveys(e)}_cancelPendingItem(e){var t;null===(t=this._instance)||void 0===t||t.cancelPendingSurvey(e)}_getLogger(){return wg}_setActivatedItems(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated:e})}_setActivatedSession(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated_session:e})}_clearActivatedSession(){var e;null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.unregister("$surveys_activated_session")}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){let i;return this._getItems(e=>{i=e.find(e=>e.id===t)}),!i||hl(i)?e===mg.SHOWN?"consume":"ignore":e===mg.SHOWN?"persist":e===mg.DISMISSED||e===mg.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},tw=class{constructor(e){this._instance=e}initialize(){}get(e){if("string"==typeof e)return this._instance.get_property(e);const t={};for(const i of e){const e=this._instance.get_property(i);It(e)||(t[i]=e)}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)}},iw=class{constructor(e){this._instance=e}get(){const 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()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=null==h?void 0:h.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:i}=e;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:i?e=>i(this._instance,"surveys",e):void 0}}createEventReceiver(){return new ew(this._instance)}};const sw=(null==e?void 0:e.location)?dr(e.location.hash,"__posthog")||dr(location.hash,"state"):null,nw="_postHogToolbarParams",rw=Gn("[Toolbar]"),ow=Gn("[FeatureFlags]");var aw=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,s,n,r,o,a,l;return{bootstrap:{featureFlags:null!==(i=null===(s=e.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},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!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:It(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(l=e.evaluation_contexts)&&void 0!==l?l:e.evaluation_environments)&&void 0!==a?a:[],flagKeys:kt(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(ow.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),It(e.flag_keys)||kt(e.flag_keys)||ow.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}};const lw=Gn("[FeatureFlags]"),cw=Gn("[FeatureFlags]",{debugEnabled:!0}),uw="\" failed. Feature flags didn't load in time.",dw=["click","keydown","wheel","touchstart","pointerdown"],hw="connection_error",pw=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},_w=e=>{const t={};for(const[i,s]of Jn(e||{}))s&&(t[i]=s);return t},gw="Refusing to render web experiment since the viewer is a likely bot",fw={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>pl(t,e),not_regex:(e,t)=>!pl(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},vw=Gn("[Conversations]"),mw="Conversations not available yet.";function yw(e,t){var s,n,r,o,a,l,c;const u=null!==(s=null==e?void 0:e.flushIntervalMs)&&void 0!==s?s:3e3,d=null!==(n=null==e?void 0:e.maxBufferSize)&&void 0!==n?n:100,h=(null==t?void 0:t.consoleCapture)?void 0:null!==(r=null==e?void 0:e.maxLogsPerInterval)&&void 0!==r?r:1e3,p=It(h)?Math.max(d,2048):Math.max(d,h),_=ct(ct({},function(){let e="",t="";try{const s=null==i?void 0:i.userAgent;s&&([e,t]=Qi(s))}catch(e){}return function(e,t){const i=function(e){if(e)return{}.hasOwnProperty.call(In,e)?In[e]:e}(e);return ct(ct({},i?{"os.name":i}:{}),t?{"os.version":t}:{})}(e,t)}()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(o=null!==(a=null==_?void 0:_["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==_?void 0:_["service.version"])&&void 0!==l?l:null==e?void 0:e.serviceVersion,environment:null!==(c=null==_?void 0:_["deployment.environment"])&&void 0!==c?c:null==e?void 0:e.environment,resourceAttributes:_,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:d,maxQueueSize:p,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const bw=["debug","log","warn","error","info"],Sw="console",ww="__posthogHandledLogsRequestError",kw=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[ww]=!0,i},Cw=e=>!!e&&"object"==typeof e&&!0===e[ww],Ew=Gn("[NetworkMetrics]"),xw=()=>{var t;return(null==e||null===(t=e.performance)||void 0===t?void 0:t.now)?e.performance.now():Date.now()},Iw=e=>e?`${Math.floor(e/100)}xx`:"missing",Tw=(e,t)=>{var i;const s=String(t);return{method:String(e).toUpperCase(),url:(null===(i=ar(s))||void 0===i?void 0:i.href)||s}},Mw=(e,t,i,s,n)=>{try{var r,o,a;const c=n();if(!c)return;const u=i||void 0,d=xw()-s,h=ar(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const p={url:(null==h?void 0:h.href)||t.url,method:t.method},_=Ct(c.name)?c.name(p):Tt(c.name)?c.name:"http.client.request.duration";if(!_)return;const g=ct({method:p.method,host:null!==(r=null==h?void 0:h.hostname)&&void 0!==r?r:"",path:h?(l=h.pathname,l.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/")):"",status_class:Iw(u)},null===(o=c.attributes)||void 0===o?void 0:o.call(c,p,{status:u,durationMs:d}));null===(a=e.metrics)||void 0===a||a.histogram(_,d,{unit:"ms",attributes:g})}catch(e){Ew.error("Failed to record network metric",e)}var l},Rw=()=>{},Pw=(t,i)=>Ct(null==e?void 0:e.fetch)?Sp(e,"fetch",e=>function(...s){const n=xw(),r=e.apply(this,s);if(!i())return r;try{var o,a,l;const[e,c]=s,u=Tw(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==e?void 0:e.method)&&void 0!==o?o:"GET",null!==(l=null==e?void 0:e.url)&&void 0!==l?l:e);return r.then(e=>(Mw(t,u,null==e?void 0:e.status,n,i),e),e=>{throw Mw(t,u,void 0,n,i),e})}catch(e){return Ew.error("Failed to observe fetch",e),r}}):Rw,Fw=(t,i)=>{var s;const n=null==e||null===(s=e.XMLHttpRequest)||void 0===s?void 0:s.prototype;if(!n)return Rw;const r=new WeakMap,o=Sp(n,"open",e=>function(...t){try{(()=>kb.has(this))()||r.set(this,Tw(t[0],t[1]))}catch(e){Ew.error("Failed to observe XHR open",e)}return e.apply(this,t)}),a=Sp(n,"send",e=>function(...s){let n;try{const e=r.get(this);if(e&&i()){const s=xw();n=()=>{this.removeEventListener("loadend",n),Mw(t,e,this.status,s,i)},sr(this,"loadend",n)}}catch(e){Ew.error("Failed to observe XHR send",e)}try{return e.apply(this,s)}catch(e){throw n&&this.removeEventListener("loadend",n),e}});return()=>{o(),a()}},Lw={featureFlags:class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=lw,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._hadUserInteraction=!1,this._onOnline=()=>{const e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t;const i=this._refreshIntervalMs,n=null!==(e=this._dueRefreshIntervalMs)&&void 0!==e?e:i;It(i)||It(n)||this._config.remoteRequestsDisabled||!s||"hidden"===s.visibilityState||Date.now()-(null!==(t=this._lastRefreshAt)&&void 0!==t?t:0)<n||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?i:Math.min(2*n,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{"visible"===(null==s?void 0:s.visibilityState)&&this._resumeConfiguredInterval()},"get"in e?this._configSource=e:(this._instance=e,this._mutableConfigSource=new aw(e.config,e._shouldDisableFlags()),this._configSource=this._mutableConfigSource)}updateConfig(e,t){var i;null===(i=this._mutableConfigSource)||void 0===i||i.update(e,t),this._client&&this._syncAutomaticRefresh()}setup(e){return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),GS(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(t){var i;if(this._client===t)return e&&sr(e,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=t.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){const e=this._config.refreshIntervalMs,t=!this._config.remoteRequestsDisabled&&s&&!It(e)&&e>0?e:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=t),t!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),It(t)||(this._refreshIntervalMs=t,this._dueRefreshIntervalMs=t,this._scheduleNextRefresh(),(null==s?void 0:s.addEventListener)&&(sr(s,Ye,this._onVisibilityChange),Qn(dw,e=>{sr(s,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){It(this._refreshIntervalMs)||(It(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e;It(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null==s||null===(e=s.removeEventListener)||void 0===e||e.call(s,"visibilitychange",this._onVisibilityChange),Qn(dw,e=>{var t;null==s||null===(t=s.removeEventListener)||void 0===t||t.call(s,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var t,i;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._client&&(this._clearDebouncer(),null===(t=this._dynamicProperties)||void 0===t||t.dispose(),this._dynamicProperties=void 0,null===(i=this._crossTabPersistenceUnsubscribe)||void 0===i||i.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null==e||e.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?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!It(null===(e=this._client)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!e.$enabled_feature_flags)return;const n=this._prop("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,c=l?a:i&&!kt(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),u=this._prop("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},h=l||i?c:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),p=!l&&!i,_=!!p||c,g=!!p||h,f={[X]:_,[Y]:_,[ie]:g};e.$feature_flag_details&&(f[te]=_);for(const t of[se,Ee,ne])It(e[t])||(f[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(f)}_remove(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){const e={};for(const t of[X,ie,se,re]){const i=this._prop(t);It(i)||(e[t]=i)}this._baseEventProperties=e;const t=ct({},e),i=this._prop(Y);if(i)for(const[e,s]of Object.entries(i))t[`$feature/${e}`]=s;this._eventPropertiesWithFlagValues=t}_isCacheStale(){const e=this._config.cacheTtlMs;if(!e||0>=e)return!1;const t=this._prop(Ee);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(){const e=this._config.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const 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(){const e=this._config.flagKeys;if(!It(e))return e.filter(e=>{const 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;const i=this._config,s=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var n,r;const e=null!==(n=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},t=Object.keys(s).filter(e=>!It(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this._receivedFeatureFlags({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var s,n;const r=(null==i?void 0:i.merge)&&null!==(s=this._prop("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==i?void 0:i.merge)&&null!==(n=this._prop("$feature_flag_payloads"))&&void 0!==n?n:{},a=ct(ct({},r),e),l=ct(ct({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:nn(t),variant:rn(t),reason:void 0,metadata:It(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this._prop(te),t=this._prop(re),i=this._prop(oe);if(!i&&!t)return e||{};const s=Zn({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of n){var r;const n=s[e],a=null==t?void 0:t[e],l=It(a)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!a,c=It(a)?null==n?void 0:n.variant:"string"==typeof a?a:void 0,u=null==i?void 0:i[e],d=ct(ct({},n),{},{enabled:l,variant:l?null!=c?c:null==n?void 0:n.variant:void 0});var o;l!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),c!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=ct(ct({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[e]=d}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this._override_warning=!0),s}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const s=e[i];return{key:i,enabled:nn(s),variant:rn(s),payload:sn(t[i])}})}getFlagVariants(){const e=this._prop(Y),t=this._prop(re);if(!t)return e||{};const i=Zn({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){const e=this._prop(ie),t=this._prop(oe);if(!t)return e||{};const i=Zn({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];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(we)}_callFlagsEndpoint(e){this._clearDebouncer();const t=this._client;if(!t||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return;if(this._requestInFlight)return void(this._additionalReloadRequested=!0);const i={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:ct(ct(ct({},t.initialPersonProperties),this._prop("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this._prop(le),timezone:Nl()};It(t.deviceId)||(i.$device_id=t.deviceId),((null==e?void 0:e.disableFlags)||this._config.featureFlagsDisabled)&&(i.disable_flags=!0);const s=this._getValidEvaluationEnvironments();s.length&&(i.evaluation_contexts=s);const n=this._getValidFlagKeys();It(n)||(i.flag_keys=n);const r=this._config.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),a=this._requestGeneration;this._requestInFlight=!0;const l=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},c=e=>{var t,s;const n=null!==(t=e.json)&&void 0!==t?t:{},o=200!==e.statusCode;if(this._requestInFlight=!1,a!==this._requestGeneration)return void l();if(this._trackStatusZeroReachability(e.statusCode),o||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),i.disable_flags&&!this._additionalReloadRequested)return;this._flagsLoadedFromRemote=!o;const c=[];e.error?c.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?hw:"unknown_error"):200!==e.statusCode&&c.push(`api_error_${e.statusCode}`),n.errorsWhileComputingFlags&&c.push("errors_while_computing_flags");const u=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));u&&c.push("quota_limited"),this._set({[Ce]:c}),u?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(n,o,{partialResponse:r}),l()},u=e=>{this._requestInFlight=!1,a===this._requestGeneration?(this._set({[Ce]:[hw]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),l()):l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:i,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(c).catch(u)}catch(e){u(e)}}_hasStatusZeroCircuitBreakerTripped(){return hr(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=pr(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(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlag for key "'+e+uw);if(this._checkAndTriggerStaleRefresh())return;const s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlagResult for key "'+e+uw);if(this._checkAndTriggerStaleRefresh())return;const i=this.getFlagVariants(),s=e in i,n=i[e],r=this.getFlagPayloads()[e],o=String(n),a=this._prop("$feature_flag_request_id")||void 0,l=this._prop("$feature_flag_evaluated_at")||void 0;let c,u=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var d;const e=null===(d=this._client)||void 0===d?void 0:d.session.sessionId,t=this._prop(ke);e&&e!==t&&(u={},c=e)}if(t.send_event||!("send_event"in t))if(e in u&&u[e].includes(o))c&&this._set({[we]:u,[ke]:c});else{var h,p,_,g,f,v,m,y,b,S,w,k;kt(u[e])?u[e].push(o):u[e]=[o],this._set(ct({[we]:u},c?{[ke]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(h=this._prop("$feature_flag_errors"))&&void 0!==h?h:[]];It(n)&&i.push("flag_missing");const s={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(p=null===(_=this._config.bootstrap)||void 0===_||null===(_=_.featureFlags)||void 0===_?void 0:_[e])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(g=null===(f=this._config.bootstrap)||void 0===f||null===(f=f.featureFlagPayloads)||void 0===f?void 0:f[e])&&void 0!==g?g:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};It(null==t||null===(v=t.metadata)||void 0===v?void 0:v.has_experiment)||(s.$feature_flag_has_experiment=t.metadata.has_experiment),It(null==t||null===(m=t.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=t.metadata.version);const d=null!==(y=null==t||null===(b=t.reason)||void 0===b?void 0:b.description)&&void 0!==y?y:null==t||null===(S=t.reason)||void 0===S?void 0:S.code;var C;d&&(s.$feature_flag_reason=d),(null==t||null===(w=t.metadata)||void 0===w?void 0:w.id)&&(s.$feature_flag_id=t.metadata.id),It(null==t?void 0:t.original_variant)&&It(null==t?void 0:t.original_enabled)||(s.$feature_flag_original_response=It(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(k=t.metadata)||void 0===k?void 0:k.original_payload)&&(s.$feature_flag_original_payload=null==t||null===(C=t.metadata)||void 0===C?void 0:C.original_payload),i.length&&(s.$feature_flag_error=i.join(",")),this._captureFeatureFlagCalled(s)}else c&&this._set({[we]:u,[ke]:c});return s?{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:sn(r)}:void 0}_captureFeatureFlagCalled(e){try{var t;null===(t=this._client)||void 0===t||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 rt(function*(){const s=i._client;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=i._getValidEvaluationEnvironments();r.length&&(n.evaluation_contexts=r);const o=i._getValidFlagKeys();let a;It(o)||(n.flag_keys=o);try{var l;const t=null===(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+uw),t.defaultValue;const i=this.getFeatureFlag(e,t);return It(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)return;this._hasLoadedFlags=!0;const s=((e,t={},i={},s={},n,r=lw)=>{const o=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),s=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!It(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return ct(ct({},e),{},{featureFlags:t,featureFlagPayloads:s})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,r),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(!l)return;const u=e.requestId,d=e.evaluatedAt;if(kt(l)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(l)for(let t=0;l.length>t;t++)e[l[t]]=!0;return{[X]:l,[Y]:e,[ne]:!1}}let h=l,p=c,_=a;if(null==n?void 0:n.partialResponse){const e=Object.keys(h),n=p||{};h=ct(ct({},t),h),p=ct(ct({},i),n),e.forEach(e=>{e in n||null==p||delete p[e]}),_=ct(ct({},s),_)}else if(e.errorsWhileComputingFlags)if(a){const e=new Set(Object.keys(a).filter(e=>{var t;return!(null===(t=a[e])||void 0===t?void 0:t.failed)}));h=ct(ct({},t),Object.fromEntries(Object.entries(h).filter(([t])=>e.has(t))));const n=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=ct(ct({},i),n),e.forEach(e=>{e in n||null==p||delete p[e]}),_=ct(ct({},s),Object.fromEntries(Object.entries(_||{}).filter(([t])=>e.has(t))))}else h=ct(ct({},t),h),p=ct(ct({},i),p),_=ct(ct({},s),_);return ct(ct({[X]:Object.keys(_w(h)),[Y]:h||{},[ie]:p||{},[te]:_||{},[ne]:!0===e.minimalFlagCalledEvents},u?{[se]:u}:{}),d?{[Ee]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(s)if(!1===(null==i?void 0:i.persist)){const e=!It(this._client.kv.get(Y));this._bootstrapState=s,e||this._set(s)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(s,e,!!(null==i?void 0:i.partialResponse)),this._set(s);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,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([re,oe]),this._fireFeatureFlagsCallbacks(),void cw.info("All overrides cleared");if(kt(e))return this._set({[re]:pw(e)}),this._fireFeatureFlagsCallbacks(),void cw.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const s={},n=i.flags,r=i.payloads;return n&&(s[re]=kt(n)?pw(n):n),r&&(s[oe]=r),Object.keys(s).length&&this._set(s),!1===n&&!1===r?this._remove([re,oe]):!1===n?this._remove(re):!1===r&&this._remove(oe),this._fireFeatureFlagsCallbacks(),!1===n?cw.info("Flag overrides cleared"):n&&cw.info("Flag overrides set",{flags:n}),void(!1===r?cw.info("Payload overrides cleared"):r&&cw.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this._set({[re]:e}),this._fireFeatureFlagsCallbacks(),void cw.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){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;const n=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i);const a=ct(ct({},this.getFlagVariants()),{},{[e]:t});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this._set({[X]:Object.keys(_w(a)),[Y]:a,[ae]:ct(ct({},this._prop("$stored_person_properties")||{}),r)}),this._fireFeatureFlagsCallbacks();try{var l;null===(l=this._client)||void 0===l||l.capture("$feature_enrollment_update",o).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=!1,i){const s=this._prop(ee);!s||t?this._getEarlyAccessFeatures(e,i):e(s)}_getEarlyAccessFeatures(e,t){var i=this;return rt(function*(){const s=i._client;if(!s)return;const n=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let r;try{const e=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;r=e.json.earlyAccessFeatures,i._set({[ee]: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(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(s=>{try{s(t,i,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}})}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){const i=this._prop("$stored_person_properties")||{},s=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),n=null==e?void 0:e.$set_once,r={};if(n)for(const e in n)({}).hasOwnProperty.call(n,e)&&(e in i||(r[e]=n[e]));this._set({[ae]:ct(ct(ct({},i),r),s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=ct({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[ae]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(ae),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this._prop("$stored_group_properties")||{},s=ct({},i);for(const t of Object.keys(e))s[t]=ct(ct({},i[t]),e[t]);this._set({[le]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this._prop("$stored_group_properties")||{};this._set({[le]:ct(ct({},t),{},{[e]:{}})})}else this._remove(le)}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}}},Aw={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!!(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0: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?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=_o,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var t,i;if(!(null==s?void 0:s.visibilityState)||"visible"===s.visibilityState)return!0;const n=null==e||null===(t=e.performance)||void 0===t||null===(i=t.getEntriesByType)||void 0===i?void 0:i.call(t,"visibility-state");return!(null==n?void 0:n.length)||n.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e,t;"visible"===(null==s?void 0:s.visibilityState)&&(this._documentWasEverVisible=!0,null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw BS.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==s?void 0:s.addEventListener)&&sr(s,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,null==s||null===(t=s.removeEventListener)||void 0===t||t.call(s,"visibilitychange",this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var t;const i=!!(null===(t=this._instance.get_property("$session_recording_remote_config"))||void 0===t?void 0:t.enabled),s=!this._config.disable_session_recording,n=this._config.disable_session_recording||this._instance.consent.isOptedOut();return e&&i&&s&&!n}startIfEnabledOrStop(e){var t;if(this._sessionRecordingDisposed)return;if(this._isRecordingEnabled&&(null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.isStarted))return;const i=!It(Object.assign)&&!It(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),BS.info("starting")):(this._recordingStatus=_o,this.stopRecording())}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=yo),(null==h||null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=h.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this._onScriptLoaded(e);else{var s,n;const t=this._instance.sessionManager;null===(s=h.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this._scriptName,i=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),BS.error("could not load recorder",i)):void this._onScriptLoaded(e);this._recordingStatus="disabled"})}}stopRecording(){var e,t;null===(e=this._persistFlagsOnSessionListener)||void 0===e||e.call(this),this._persistFlagsOnSessionListener=void 0,null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.stop()}_discardRecording(e=!1){var t,i;null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=void 0,null===(i=this._lazyLoadedSessionRecording)||void 0===i||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null===(e=this._persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._persistence)||void 0===t||t.unregister("$replay_sample_rate")}_validateSampleRate(e,t){if(Pt(e))return null;const i=Ft(e)?e:parseFloat(e);return"number"!=typeof(s=i)||!Number.isFinite(s)||0>s||s>1?(BS.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var s}_persistRemoteConfig(e){if(this._persistence){var t,i;const s=this._persistence,n=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null===(t=this._config.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=n?n:r;Pt(o)&&this._resetSampling();const a=null==i?void 0:i.minimumDurationMilliseconds;s.register({[A]:ct(ct({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:ct({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:o,minimumDurationMilliseconds:It(a)?null:a,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)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(n)}}onRemoteConfig(e){const 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",BS.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.log)?this._lazyLoadedSessionRecording.log(e,t):BS.warn("log called before recorder was ready")}get _scriptName(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(A);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){const e=this._instance.get_property(A);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return BS.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!Pt(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,i,s;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return BS.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[$e]:!0});var n;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null===(n=h.__PosthogExtensions__)||void 0===n?void 0:n.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",BS.info("persisted remote config is stale, requesting fresh config before starting"),void new bb(this._instance).load()}this._recordingStatus=yo,null===(i=(s=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||void 0===i||i.call(s,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=_o}onRRwebEmit(e){var t,i;null===(t=this._lazyLoadedSessionRecording)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null===(i=this._persistence)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!!(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},Ow={autocapture:class extends Ry{constructor(e){super(new PS(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(Vn.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,Vn.info("History API monitoring stopped")}monitorHistoryChanges(){e&&e.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(t){var i;if(!e||(null===(i=e.history[t])||void 0===i?void 0:i.__posthog_wrapped__))return;const s=this;Sp(e.history,t,e=>function(i,n,r){e.call(this,i,n,r),s._capturePageview(t)})}_getCurrentLocation(){const t=null==e?void 0:e.location;if(null==t?void 0:t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}_getCaptureOptions(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:Et(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){const 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{const t=this._getCurrentLocation();if(!t)return;this._hasLocationChanged(t)&&this._instance.capture(et,{navigation_type:e}),this._lastLocation=t}catch(t){Vn.error(`Error capturing ${e} pageview`,t)}}_setupPopstateListener(){if(this._popstateListener)return;const t=()=>{this._capturePageview("popstate")};sr(e,"popstate",t),this._popstateListener=()=>{e&&e.removeEventListener("popstate",t)}}_setupHashchangeListener(){if(this._hashchangeListener)return;const t=()=>{this._capturePageview("hashchange")};sr(e,"hashchange",t),this._hashchangeListener=()=>{e&&e.removeEventListener("hashchange",t)}}},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)||void 0===t?void 0:t.props[E]),this.rageclicks=new Cy(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return Et(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;qS.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)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[E]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){const e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){HS(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval="visible"===(null==s?void 0:s.visibilityState)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){e&&s&&(this._flushHandler=this._flush.bind(this),sr(e,Xe,this._flushHandler),this._onClickHandler=t=>this._onClick(t||(null==e?void 0:e.event)),sr(s,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=t=>this._onMouseMove(t||(null==e?void 0:e.event)),sr(s,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new zy(this.instance,Uy,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),sr(s,Ye,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var t;e&&s&&(this._flushHandler&&e.removeEventListener(Xe,this._flushHandler),this._onClickHandler&&s.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&s.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&s.removeEventListener(Ye,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null===(t=this._deadClicksCapture)||void 0===t||t.stop(),this._initialized=!1)}_getProperties(t,i){const s=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(t,i,s){let n=t;for(;n&&vr(n)&&!mr(n,"body");){if(n===s)return!1;let t;try{var r,o,a;t=null===(r=null!==(o=null===(a=n.ownerDocument)||void 0===a?void 0:a.defaultView)&&void 0!==o?o:e)||void 0===r?void 0:r.getComputedStyle(n).position}catch(e){return!1}if(ft(i,t))return!0;n=Rr(n)}return!1}(xr(t),["fixed","sticky"],r);return{x:t.clientX+(o?0:n),y:t.clientY+(o?0:s),target_fixed:o,type:i}}_onClick(e,t="click"){var i;if(fr(e.target)||!HS(e))return;const s=this._getProperties(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&Br(xr(e),this.instance.config.rageclick)&&this._capture(ct(ct({},s),{},{type:"rageclick"})),this._capture(s)}_onMouseMove(e){!fr(e.target)&&HS(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(t){if(!e)return;const i=this._config.disable_capture_url_hashes?ls(e.location.href):e.location.href,s=this._config.custom_personal_data_properties,n=this._config.mask_personal_data_properties?[...El,...s||[]]:[],r=ur(i,n,Il);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(t)}_flush(){this._buffer&&!xt(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:zy,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",ct({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>ct(ct({},e),{},{[`$web_vitals_${t.name}_event`]:ct({},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))return void AS.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this._maskedURL(i);if(It(s))return;const n=Ft(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${s}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void AS.error("Ignoring metric with value >= "+this._maxAllowedValue,e);this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),It(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=s),this._buffer.firstMetricTimestamp=It(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=ct(ct(ct({},e),i?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,Et(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of NS){const s="url"===i&&"string"==typeof e.attribution[i]?this._maskedURL(e.attribution[i]):e.attribution[i];It(s)||(t[i]=s)}o.attribution=t}else delete o.attribution;It(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this._buffer.metrics.push(o),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let e,t,i,s,n=!1;const r=h.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&It(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!It(a)){const r=a.withoutAttribution,o=this.attributionMetrics;n=!It(r),e=o.indexOf("LCP")>-1?a.onLCP:(null==r?void 0:r.onLCP)||a.onLCP,t=o.indexOf("CLS")>-1?a.onCLS:(null==r?void 0:r.onCLS)||a.onCLS,i=o.indexOf("FCP")>-1?a.onFCP:(null==r?void 0:r.onFCP)||a.onFCP,s=o.indexOf("INP")>-1?a.onINP:(null==r?void 0:r.onINP)||a.onINP}if(!(e&&t&&i&&s))return void AS.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},c=n&&this.attributionMetrics.indexOf("INP")>-1?ct(ct({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this),c),this._initialized=!0},this._enabledServerSide=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[M]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=Et(this._perfConfig)?null===(e=this._perfConfig)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return Pt(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||DS:i}get flushToCaptureTimeoutMs(){return(Et(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=Et(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return At(e)?e?DS:[]:kt(e)?e:$S}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=Et(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){const e=Et(this._perfConfig)&&Ft(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:OS;return e>0&&6e4>=e?OS:e}get isEnabled(){const e=null==n?void 0:n.protocol;if("http:"!==e&&"https:"!==e)return AS.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=Et(this._perfConfig)?this._perfConfig.web_vitals:At(this._perfConfig)?this._perfConfig:void 0;return At(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(AS.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=Et(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=Et(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[M]:i}),this._instance.persistence.register({[L]: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;const i=h.__PosthogExtensions__,s=this._callbackFlavor,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&It(n)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,s,t=>{t?AS.error("failed to load script",t):e()})}_maskedURL(t){const i=t||(null==e?void 0:e.location.href);if(!i)return void AS.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?ls(i):i,n=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...El,...n||[]]:[];return ur(s,r,Il)}}},Dw={exceptionObserver:class{constructor(t){var i;this._startCapturing=()=>{var t;if(!e||!this.isEnabled||!(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions))return;const i=h.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=h.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=h.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=i(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=s(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=n(this.captureException.bind(this)))}catch(e){FS.error("failed to start",e),this._stopCapturing()}},this._instance=t,this._remoteEnabled=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[x]),this._rateLimiter=new Kt(ct(ct({},function(e={}){var t,i,s,n;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(n=e.exceptionRateLimiterBucketSize)&&void 0!==n?n:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:FS})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Et(e)?t=ct(ct({},t),e):(It(e)?this._remoteEnabled:e)&&(t=ct(ct({},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?(FS.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"exception-autocapture",t=>{if(t)return FS.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null===(e=this._unwrapOnError)||void 0===e||e.call(this),this._unwrapOnError=void 0,null===(t=this._unwrapUnhandledRejection)||void 0===t||t.call(this),this._unwrapUnhandledRejection=void 0,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[x]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,s;const n=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(n))return void FS.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=Sv(),this._instance=e,this._suppressionRules=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=Xs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new en(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Xs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if(!e.ok)return;const n=e.config;if(!("errorTracking"in n))return;const r=null!==(t=null===(i=n.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[I]:this._suppressionRules,[T]:o})}get _captureExtensionExceptions(){var e;const t=!!this._instance.get_property(T),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!Tt(e)||0===e.trim().length)return void fv.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:s}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>Js.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));s.length>0&&fv.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this._exceptionStepsBuffer.add(ct({[Ks]:e,[Zs]:(new Date).toISOString()},i))}catch(e){fv.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void fv.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 fv.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 fv.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 fv.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this._exceptionStepsConfig.enabled&&Pt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,s=function(){const e=globalThis._posthogReleaseId;return"string"==typeof e&&e.length>0?e:void 0}();s&&(i.$release_id=s);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){return gv(e)||fv.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void(gv(e)||fv.error("Failed to process exception event. Ignoring this exception.",e))}}_addBufferedExceptionSteps(e){try{const t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:ct(ct({},e),{},{$exception_steps:t})}catch(t){return fv.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Ks]:e,[Zs]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Et(e)?ct({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(Tt(t)&&t.length>0&&e.$exception_types.push(t),Tt(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{const i=e.values.map(e=>{const i=gl[e.operator],s=t[e.key];if(!i||!s)return!1;const n=kt(e.value)?e.value:[e.value];return n.length>0&&i(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return fv.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&yv.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(vv))||e.some(({type:e,value:t})=>"NoResponse"===e||Tt(t)&&mv.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(vv))))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>Tt(e)&&bv.some(t=>e.includes(t)))}_isPostHogException(e){if(e.length>0){var t,i,s,n;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!Pt(e)&&kt(e)}}},$w=ct({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)return;const t=e.config;if("productTours"in t){var i,s;if(this._persistence&&this._persistence.register({[P]:!!t.productTours}),!WS(this._instance))return!this._productTourManager&&Pt(null===(i=this._persistence)||void 0===i?void 0:i.props.ph_product_tours)||US.info("product tours disabled; stopping and clearing cached tours"),null===(s=this._productTourManager)||void 0===s||s.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&WS(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"product-tours",t=>{t?US.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&(null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this._productTourManager=h.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(kt(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});const i=this._persistence;if(i){const s=i.props[ge];if(kt(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(!WS(this._instance))return void e([],{isLoaded:!0});const s=t.statusCode;if(200!==s||!t.json){const i=`Product Tours API could not be loaded, status: ${s}`;return 0===s?t.error||US.warn(i):US.error(i),void e([],{isLoaded:!1,error:i})}const n=kt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[ge]:n}),e(n,{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)||void 0===t||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null===(t=this._productTourManager)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this._productTourManager)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this._productTourManager)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this._productTourManager)||void 0===e||e.previousStep()}clearCache(){var e;this._cachedTours=null,null===(e=this._persistence)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this._productTourManager)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.cancelPendingTour(e)}}},Lw),Nw={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)return;const 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=h._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,i,s,n,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:ct(ct({},mn(e,zS)),{},{properties:ct(ct(ct({},e.properties),h?{$set:ct(ct({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:ct(ct({},null!==(s=null===(n=e.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_prepareElementForSiteApp(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();if("style"===i&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(e)||(jS.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===i&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(e)||(jS.error("prepare_external_dependency_script returned null"),null)}return e}_patchSiteAppElementInsertionMethods(){var e,t,i,n,r,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const c=null==s?void 0:s.defaultView,u=null==c||null===(e=c.Node)||void 0===e?void 0:e.prototype;if(!c||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();const d=[],h=this,p=new WeakSet,_=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const s=e[t];e[t]=i(s),d.push(()=>{e[t]=s})},g=e=>{if(p.has(e))return e;const t=h._prepareElementForSiteApp(e);return t&&p.add(t),t},f=e=>e.map(e=>"string"==typeof e?e:g(e)).filter(e=>!Rt(e));return _(u,"appendChild",e=>function(t){const i=g(t);return i?e.call(this,i):t}),_(u,"insertBefore",e=>function(t,i){const s=g(t);return s?e.call(this,s,i):t}),_(u,"replaceChild",e=>function(t,i){const s=g(t);return s?e.call(this,s,i):i}),[null===(t=c.Element)||void 0===t?void 0:t.prototype,null===(i=c.Document)||void 0===i?void 0:i.prototype,null===(n=c.DocumentFragment)||void 0===n?void 0:n.prototype].forEach(e=>{_(e,"append",e=>function(...t){return e.apply(this,f(t))}),_(e,"prepend",e=>function(...t){return e.apply(this,f(t))})}),[null===(r=c.Element)||void 0===r?void 0:r.prototype,null===(o=c.CharacterData)||void 0===o?void 0:o.prototype,null===(a=c.DocumentType)||void 0===a?void 0:a.prototype].forEach(e=>{_(e,"before",e=>function(...t){return e.apply(this,f(t))}),_(e,"after",e=>function(...t){return e.apply(this,f(t))}),_(e,"replaceWith",e=>function(...t){const i=f(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),_(null===(l=c.Element)||void 0===l?void 0:l.prototype,"insertAdjacentElement",e=>function(t,i){const s=g(i);return s?e.call(this,t,s):null}),this._restoreSiteAppElementPatches=()=>{d.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null===(t=this._restoreSiteAppElementPatches)||void 0===t||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){const i=this._patchSiteAppElementInsertionMethods();try{const s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(jS.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this._stopBuffering)||void 0===i||i.call(this))};let s=!1;const n=n=>{t.errored=!n,t.loaded=!0,jS.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),s&&i()};try{const{processEvent:i}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),n(e)}}),!1);i&&(t.processEvent=i),s=!0}catch(t){jS.error(VS+e.id,t),n(!1)}if(s&&t.loaded)try{i()}catch(i){jS.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}_setupSiteApps(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}_onCapturedEvent(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){jS.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,s;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void jS.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this._stopBuffering)||void 0===i||i.call(this),!e.ok)return;const n=e.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:e,url:t}of n.siteApps){var r,o;h[`__$$ph_site_app_${e}`]=this._instance,null===(r=h.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return jS.error(VS+e,t)})}else jS.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Bw={tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{const e=this._syncHostnamesForPatch();var t,i;e?(It(this._restoreXHRPatch)&&(this._restoreXHRPatch=null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),It(this._restoreFetchPatch)&&(this._restoreFetchPatch=null===(i=h.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"tracing-headers",t=>{if(t)return LS.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(){const e=this._getConfiguredHostnames();return kt(e)?(kt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(kt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},qw=ct({surveys:class extends ZS{constructor(e){var t;super(new iw(e),(t=e,{get projectToken(){return t.config.token},kv:new tw(t)})),this._instance=e}_sendSurveysRequest(e,t){const i=t.query?Tb(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})})}}},Lw),Hw={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){h.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=h.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,i=void 0,n=void 0){var r,o;if(nr(this.instance.config))return!1;if(!e||!s)return!1;t=null!==(r=t)&&void 0!==r?r:e.location,n=null!==(o=n)&&void 0!==o?o:e.history;try{if(!i){try{e.localStorage.setItem("test","test"),e.localStorage.removeItem("test")}catch(e){return!1}i=null==e?void 0:e.localStorage}const s=sw||dr(t.hash,"__posthog")||dr(t.hash,"state");let r;const o=s?cs(()=>JSON.parse(atob(decodeURIComponent(s))))||cs(()=>JSON.parse(decodeURIComponent(s))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?t.hash=o.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):(r=JSON.parse(i.getItem(nw)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){const t=h.ph_load_toolbar||h.ph_load_editor;!Pt(t)&&Ct(t)?t(e,this.instance):rw.warn("No toolbar load function found")}loadToolbar(t){const i=!!(null==s?void 0:s.getElementById("__POSTHOG_TOOLBAR__"));if(!e||i)return!1;const n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=ct(ct({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(e.localStorage.setItem(nw,JSON.stringify(ct(ct({},r),{},{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var o,a;this._setToolbarState(1),null===(o=h.__PosthogExtensions__)||void 0===o||null===(a=o.loadExternalDependency)||void 0===a||a.call(o,this.instance,"toolbar",e=>{if(e)return rw.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),sr(e,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},Uw=ct({experiments:class t{get _config(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(e=!1)=>{this.getWebExperiments(e=>{t._logInfo("retrieved web experiments from the server"),this._flagToExperiments=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;this._flagToExperiments&&(t._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=this._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e));const s=this._instance.getFeatureFlag(e.feature_flag_key);Tt(s)&&e.variants[s]&&this._applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(const i in e.variants){const s=e.variants[i];t._matchesTestVariant(s,this._instance)&&this._applyTransforms(e.name,i,s.transforms)}})},e)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t._logInfo(gw);else if(!this._config.disable_web_experiments){if(Pt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t._logInfo("applying feature flags",e),e.forEach(e=>{var t;if(this._flagToExperiments&&(null===(t=this._flagToExperiments)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),s=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&(null==s?void 0:s.variants[t])&&this._applyTransforms(s.name,t,s.variants[t].transforms)}})}}previewWebExperiment(){const e=t.getWindowLocation();if(null==e?void 0:e.search){const i=cr(null==e?void 0:e.search,"__experiment_id"),s=cr(null==e?void 0:e.search,"__experiment_variant");i&&s&&(t._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([]);const s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this._config.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,i,s){const n=s.filter(t=>t.id===e);n&&n.length>0&&(t._logInfo(`Previewing web experiment [${n[0].name}] with variant [${i}]`),this._applyTransforms(n[0].name,i,n[0].variants[i].transforms))}static _matchesTestVariant(e,i){return!Pt(e.conditions)&&t._matchUrlConditions(e,i)&&t._matchUTMConditions(e)}static _matchUrlConditions(e,i){var s;if(Pt(e.conditions)||Pt(null===(s=e.conditions)||void 0===s?void 0:s.url))return!0;const n=t.getWindowLocation();if(n){var r,o,a;const t=_r(i,n.href);return!(null===(r=e.conditions)||void 0===r?void 0:r.url)||fw[null!==(o=null===(a=e.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](e.conditions.url,t)}return!1}static getWindowLocation(){return null==e?void 0:e.location}static _matchUTMConditions(e){var t;if(Pt(e.conditions)||Pt(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=Ml();if(i.utm_source){var s,n,r,o,a,l,c,u;const t=!(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,p=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&p&&d}return!1}static _logInfo(e,...t){Vn.info(`[WebExperiments] ${e}`,t)}_applyTransforms(e,i,s){this._is_bot()?t._logInfo(gw):"control"!==i?s.forEach(s=>{if(s.selector){var n;t._logInfo(`applying transform of variant ${i} for experiment ${e} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(e=>{const t=e;s.html&&(t.innerHTML=s.html),s.css&&t.setAttribute("style",s.css)})}}):t._logInfo("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?Xb(i,this._config.custom_blocked_useragents):void 0}}},Lw),Ww={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)return;if(this._remoteConfigSuccessful=e.ok,!e.ok)return;const t=e.config.conversations;Pt(t)||(At(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this._isInitializing)return;if(this._instance.config.disable_conversations)return;if(nr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==h?void 0:h.__PosthogExtensions__;if(e&&!It(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{const t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);const i=e.loadExternalDependency;if(!i)return void this._handleLoadError(Qe);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 vw.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,vw.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else vw.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){vw.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():vw.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!Rt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":nr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":It(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?Pt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":(null==h?void 0:h.__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?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return rt(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(vw.warn(mw),null)})()}getMessages(e,t){var i=this;return rt(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(vw.warn(mw),null)})()}markAsRead(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(vw.warn(mw),null)})()}getTickets(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(vw.warn(mw),null)})()}requestRestoreLink(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(vw.warn(mw),null)})()}restoreFromToken(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(vw.warn(mw),null)})()}restoreFromUrlToken(){var e=this;return rt(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(vw.warn(mw),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}_onIdentityCleared(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},zw={logs:class{constructor(t){var i;this._instance=t,this.name=Fg,this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=Gn("[logs]"),this._coreLogger=ct(ct({},this._logger),{},{error:(...e)=>{e.some(Cw)||this._logger.error(...e)}}),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)||void 0===e||e.onReconnect(),null===(t=this._consoleCore)||void 0===t||t.onReconnect())},this._instance&&(null===(i=this._instance.config.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this._isLogsEnabled=!0),e&&sr(e,"online",this._onReconnect)}_buildCore(e,t,i,s){var n;const r=yw(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,i);return[new $n(this._createHost(e,t),r,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,s),r]}_getCore(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs;var i;return this._consoleCore&&this._consoleResolvedFrom===t||(null===(i=this._consoleCore)||void 0===i||i.reset(),this._consoleResolvedFrom=t,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Sw)),this._consoleCore}setup(e){var t;if(this._disposed)return;this._client=e,(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t||null===(t=t.logs)||void 0===t?void 0:t.captureConsoleLogs)&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._remoteConfigWillArrive()&&this._persistedCaptureHint())&&this._startConsoleRecorder();let i=!1;const s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?s.dispose():(this._remoteConfigSubscription=s,i||this.loadIfEnabled())}dispose(){var t,i,s,n;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null===(t=this._remoteConfigSubscription)||void 0===t||t.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null==e||e.removeEventListener("online",this._onReconnect),null===(i=this._consoleLogsDispose)||void 0===i||i.call(this),this._consoleLogsDispose=void 0,null===(s=this._core)||void 0===s||s.reset(),null===(n=this._consoleCore)||void 0===n||n.reset())}onRemoteConfig(e){var t,i;if(this._disposed)return;const s=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;Pt(s)?this._stopRecorderStartedByPersistedHint():(null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$logs_capture_enabled_server_side:!!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)||void 0===e||e.clearQueue(),this._queue=[],null===(t=this._core)||void 0===t||t.reset(),null===(i=this._consoleCore)||void 0===i||i.clearQueue(),this._consoleQueue=[],null===(s=this._consoleCore)||void 0===s||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)||void 0===e||null===(e=e.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e[F])}_remoteConfigWillArrive(){var e,t,i;return!(null===(e=this._instance)||void 0===e||null===(t=e._shouldDisableFlags)||void 0===t?void 0:t.call(e))||!!(null===(i=h._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[this._instance.config.token])||void 0===i?void 0:i.config)}_onOptOut(){var e;this._stopConsoleRecorder(),null===(e=this._consoleCore)||void 0===e||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!(null==h?void 0:h.console))return;const t=yw(null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs).maxBufferSize;let i=!0;this._consoleRecorderUnpatchers.push(()=>{i=!1});for(const e of bw){let s;try{s=iv(h.console[e])}catch(e){continue}s&&this._consoleRecorderUnpatchers.push(Sp(h.console,e,n=>{const r=(...s)=>{try{i&&this._recordConsoleEntry(e,s,t)}catch(e){}return n.apply(h.console,s)};return r.__rrweb_original__=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)||void 0===s?void 0: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){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0);for(const e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){const 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){Cw(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;const e=null==h?void 0:h.__PosthogExtensions__;if(!e)return this._logger.error("PostHog Extensions not found."),void this._stopConsoleRecorder();const t=e.loadExternalDependency;if(!t)return this._logger.error(Qe),void this._stopConsoleRecorder();this._isLoading=!0;try{t(this._instance,"logs",t=>{if(this._isLoading=!1,this._disposed||!this._isLogsEnabled)return;const i=e.logs;if(t||!(null==i?void 0:i.initializeLogs))this._logger.error("Could not load logs script",t),this._stopConsoleRecorder();else{var s;const e=this._takeConsoleBuffer();var n,r;this._consoleLogsDispose=i.initializeLogs(null!==(s=this._client)&&void 0!==s?s:this._instance),this._isLoaded=!0,e.length>0&&(null===(n=i.replayConsoleBuffer)||void 0===n||n.call(i,null!==(r=this._client)&&void 0!==r?r:this._instance,e))}})}catch(e){throw this._isLoading=!1,e}}_createHost(e,t){const i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===ut.LogsQueue?e():void 0,setPersistedProperty(e,i){var s;e===ut.LogsQueue&&t(null!==(s=i)&&void 0!==s?s:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>Ya.LIB_NAME,getLibraryVersion:()=>Ya.LIB_VERSION}}_sendLogsBatch(e){return new Promise(t=>{if(hr(this._consecutiveStatusZeroFailures,3))return void t({kind:"fatal",error:kw(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const s=e=>{i||(i=!0,clearTimeout(n),t(e))},n=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:kw(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=>{const 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:kw(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=pr(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,Ya.LIB_NAME,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,Sw,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,s,n){if(0===t.length)return;const r=t.map(e=>e.record);n([]);const o=Ln(r,Fn(i,Ya.LIB_NAME,Ya.LIB_VERSION),s,Ya.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;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:e,windowId:i,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=e,t.windowId=i,Pt(s)||(t.sessionStartTimestamp=s),Pt(n)||(t.lastActivityTimestamp=n)}if((null==h||null===(e=h.location)||void 0===e?void 0:e.href)&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ls(h.location.href):h.location.href),this._instance.featureFlags){const e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},jw={metrics:class{constructor(e){this._instance=e,this._logger=Gn("[metrics]"),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this._disposed)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,s=Pw(e,i),n=Fw(e,i);return()=>{t=!1,s(),n()}})(this._instance):!t&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,this._core=new Hn(this._createHost(),function(e){var t,i,s,n,r;const 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!==(n=null==e?void 0:e.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(t),this._logger)),this._core}count(e,t=1,i){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){const 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)||void 0===e||e.reset()}dispose(){var e,t;this._disposed=!0,null===(e=this._stopNetworkMetrics)||void 0===e||e.call(this),this._stopNetworkMetrics=void 0,null===(t=this._core)||void 0===t||t.reset()}_createHost(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>Ya.LIB_NAME,getLibraryVersion:()=>Ya.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{let s=!1;const n=e=>{s||(s=!0,clearTimeout(r),i(e))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(ct(ct({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};RS.__defaultExtensionClasses=ct({},ct(ct(ct(ct(ct(ct(ct(ct(ct(ct(ct(ct(ct({},Lw),Aw),Ow),Dw),$w),Nw),qw),Bw),Hw),Uw),Ww),zw),jw));const Vw=function(){Ya.SDK_DIST_CHANNEL="npm";const t=pS[CS]=new RS;return function(){function t(){t.done||(t.done=!0,Hb=!1,Kn(pS,function(e){e._dom_loaded()}))}(null==s?void 0:s.addEventListener)?"complete"===s.readyState?t():sr(s,"DOMContentLoaded",t,{capture:!1}):e&&Vn.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();var Gw=Vw;export{cg as Compression,_b as DEFAULT_PRODUCT_TOUR_APPEARANCE,bg as DisplaySurveyType,RS as PostHog,gb as ProductTourEventName,fb as ProductTourEventProperties,mg as SurveyEventName,yg as SurveyEventProperties,ug as SurveyEventType,hg as SurveyPosition,fg as SurveyQuestionBranchingType,gg as SurveyQuestionType,vg as SurveySchedule,pg as SurveyTabPosition,_g as SurveyType,dg as SurveyWidgetType,Gw as default,Vw as posthog,Sb as severityLevels};
1
+ const e="u">typeof window?window:void 0,t="u">typeof globalThis?globalThis:e,i=null==t?void 0:t.navigator,s=null==t?void 0:t.document,n=null==t?void 0:t.location,r=null==t?void 0:t.fetch,o=(null==t?void 0:t.XMLHttpRequest)&&"withCredentials"in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,a=null==t?void 0:t.AbortController,l=null==t?void 0:t.CompressionStream,c=null==i?void 0:i.userAgent;function u(){return!(!e||!1===e.navigator.onLine)}const d="undefined"!=typeof globalThis?globalThis:e;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});const h=null!=e?e:{},p="$people_distinct_id",_="distinct_id",g="$device_id",f="$device_model",v="__alias",m="__cmpns",y="$fbc",b="$fbc_persistence",S="$fbp",w="$fbp_persistence",k="__timers",C="$autocapture_disabled_server_side",E="$heatmaps_enabled_server_side",x="$exception_capture_enabled_server_side",I="$error_tracking_suppression_rules",T="$error_tracking_capture_extension_exceptions",M="$web_vitals_enabled_server_side",R="$dead_clicks_enabled_server_side",P="$product_tours_enabled_server_side",F="$logs_capture_enabled_server_side",L="$web_vitals_allowed_metrics",A="$session_recording_remote_config",O="$session_recording_enabled_server_side",D="$replay_sample_rate",N="$replay_override_sampling",B="$replay_override_linked_flag",q="$replay_override_url_trigger",H="$replay_override_event_trigger",U="$sesid",W="$session_is_sampled",z="$session_past_minimum_duration",j="$session_recording_url_trigger_activated_session",V="$session_recording_event_trigger_activated_session",G="$posthog_sr_group_event_trigger_",Q="$posthog_sr_group_url_trigger_",K="$posthog_sr_group_sampling_",Z="$debug_first_full_snapshot_timestamp",J="$sess_rec_flush_size",Y="$enabled_feature_flags",X="$active_feature_flags",ee="$early_access_features",te="$feature_flag_details",ie="$feature_flag_payloads",se="$feature_flag_request_id",ne="$minimal_flag_called_events",re="$override_feature_flags",oe="$override_feature_flag_payloads",ae="$stored_person_properties",le="$stored_group_properties",ce="$groups",ue="$surveys",de="$surveys_loaded_at",he="$surveys_activated",pe="$surveys_activated_session",_e="$surveys_activated_timestamps",ge="ph_product_tours",fe="$product_tours_activated",ve="$product_tours_activated_session",me="$conversations_widget_session_id",ye="$conversations_ticket_id",be="$conversations_widget_state",Se="$conversations_user_traits",we="$flag_call_reported",ke="$flag_call_reported_session_id",Ce="$feature_flag_errors",Ee="$feature_flag_evaluated_at",xe="$user_state",Ie="$client_session_props",Te="$capture_rate_limit",Me="$initial_campaign_params",Re="$initial_referrer_info",Pe="$initial_person_info",Fe="$epp",Le="$posthog_cookieless",Ae="$cookieless_mode",Oe="$sdk_debug_extensions_init_method",De="$sdk_debug_extensions_init_time_ms",$e="$sdk_debug_recording_script_not_loaded",Ne="$sdk_debug_replay_event_trigger_status",Be="$sdk_debug_replay_linked_flag_trigger_status",qe="$sdk_debug_replay_matched_recording_trigger_groups",He="$sdk_debug_replay_pending_trigger_conditions",Ue="$sdk_debug_replay_remote_trigger_matching_config",We="$sdk_debug_replay_trigger_groups_count",ze="$sdk_debug_replay_url_trigger_status",je="$sdk_debug_rrweb_attached",Ve="$sdk_debug_rrweb_start_attempted",Ge="$session_recording_start_reason",Qe="PostHog loadExternalDependency extension not found.",Ke="anonymous",Ze="identified",Je="identified_only",Ye="visibilitychange",Xe="beforeunload",et="$pageview",tt="$pageleave",it="$identify",st="$groupidentify";function nt(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,n)}function rt(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(e){nt(r,s,n,o,a,"next",e)}function a(e){nt(r,s,n,o,a,"throw",e)}o(void 0)})}}function ot(e){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ot(e)}function at(e,t,i){return(t=function(e){var t=function(e){if("object"!=ot(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=ot(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ot(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function lt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function ct(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(i),!0).forEach(function(t){at(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):lt(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var ut=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}({}),dt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});const ht="min_length",pt="max_length",_t=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],gt=["token"];function ft(e,t){return-1!==e.indexOf(t)}const vt=function(e){return e.trim()},mt=function(e){return e.replace(/^\$/,"")};function yt(e){var t;const 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"}const bt=Object.prototype,St=bt.hasOwnProperty,wt=bt.toString,kt=Array.isArray||function(e){return"[object Array]"===wt.call(e)},Ct=e=>"function"==typeof e,Et=e=>e===Object(e)&&!kt(e),xt=e=>{if(Et(e)){for(const t in e)if(St.call(e,t))return!1;return!0}return!1},It=e=>void 0===e,Tt=e=>"[object String]"==wt.call(e),Mt=e=>Tt(e)&&0===e.trim().length,Rt=e=>null===e,Pt=e=>It(e)||Rt(e),Ft=e=>"[object Number]"==wt.call(e)&&e==e,Lt=e=>Ft(e)&&e>0,At=e=>"[object Boolean]"===wt.call(e),Ot=e=>e instanceof FormData,Dt=e=>ft(_t,e),$t=e=>ft(gt,e);function Nt(e){return null===e||"object"!=typeof e}function Bt(e,t){return{}.toString.call(e)===`[object ${t}]`}function qt(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 Ut(e,Error)}}function Ht(e){return"u">typeof Event&&Ut(e,Event)}function Ut(e,t){try{return e instanceof t}catch(e){return!1}}const Wt=[!0,"true",1,"1","yes"],zt=e=>ft(Wt,e),jt=[!1,"false",0,"0","no"],Vt=["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"],Gt=function(e,t=[]){if(!e)return!1;const i=e.toLowerCase();return Vt.concat(t).some(e=>{const t=e.toLowerCase();return-1!==i.indexOf(t)})};function Qt(e,t,i,s,n){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: "+n),Qt(null!=n?n:i,t,i,s))}var Kt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Qt(e.bucketSize,0,100,e._logger),this._refillRate=Qt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Qt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){const 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;const i=Date.now(),s=String(e);let n=this._buckets[s];return n?this._applyRefill(n,i):(n={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(t=this._onBucketRateLimited)||void 0===t||t.call(this,e)),0===n.tokens)}stop(){this._buckets={}}};const Zt="Mobile",Jt="Android",Yt="Tablet",Xt="Android Tablet",ei="iPad",ti="Apple Watch",ii="Safari",si="BlackBerry",ni="Samsung Internet",ri="Chrome",oi="Chrome iOS",ai="Internet Explorer",li="Internet Explorer Mobile",ci="Opera",ui="Microsoft Edge",di="Firefox",hi="Firefox iOS",pi="Nintendo",_i="PlayStation",gi="Xbox",fi="Android Mobile",vi="Mobile Safari",mi="Windows",yi="Windows Phone",bi="Nokia",Si="Ouya",wi="Generic "+Zt.toLowerCase(),ki="Generic "+Yt.toLowerCase(),Ci="Konqueror",Ei="Oculus Browser",xi="Vivaldi",Ii="Yandex",Ti="Whale",Mi="DuckDuckGo",Ri="Pale Moon",Pi="Waterfox",Fi="Brave",Li="Claude",Ai="Codex",Oi="ChatGPT",Di="Google Search App",$i=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ni=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Bi=new RegExp(gi,"i"),qi=new RegExp("PlayStation \\w+","i"),Hi=new RegExp("Nintendo \\w+","i"),Ui=new RegExp("BlackBerry|PlayBook|BB10","i"),Wi={"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"},zi=function(e,t,i,s){t=t||"";const n=function(e){return(null==e?void 0:e.brave)?Fi:null}(i);return n||((null==s?void 0:s.detectGoogleSearchApp)&&ft(e,"GSA/")?Di:ft(e," OPR/")&&ft(e,"Mini")?"Opera Mini":ft(e," OPR/")?ci:Ui.test(e)?si:ft(e,"IEMobile")||ft(e,"WPDesktop")?li:ft(e,"OculusBrowser")?Ei:ft(e,"SamsungBrowser")?ni:ft(e,"Edge")||ft(e,"Edg/")?ui:ft(e,"Vivaldi/")?xi:ft(e,"YaBrowser/")?Ii:ft(e,"Whale/")?Ti:ft(e,"DuckDuckGo/")||ft(e,"Ddg/")?Mi:ft(e,"Claude/")?Li:ft(e,"Codex/")?Ai:ft(e,"ChatGPT/")?Oi:ft(e,"FBIOS")?"Facebook Mobile":ft(e,"UCWEB")||ft(e,"UCBrowser")?"UC Browser":ft(e,"CriOS")?oi:ft(e,"CrMo")||ft(e,ri)?ri:ft(e,Jt)&&ft(e,ii)?fi:ft(e,"FxiOS")?hi:ft(e.toLowerCase(),Ci.toLowerCase())?Ci:ft(e,"Brave/")?Fi:((e,t)=>t&&ft(t,"Apple")||function(e){return ft(e,ii)&&!ft(e,ri)&&!ft(e,Jt)}(e))(e,t)?ft(e,Zt)?vi:ii:ft(e,"PaleMoon/")?Ri:ft(e,"Waterfox/")?Pi:ft(e,di)?di:ft(e,"MSIE")||ft(e,"Trident/")?ai:ft(e,"Gecko")?di:"")},ji={[li]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ui]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ri]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[oi]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ii]:[$i],[vi]:[$i],[ci]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[di]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[hi]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[si]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),$i],[fi]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ni]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Ei]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[xi]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Ii]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Ti]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Fi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Li]:[Ni],[Ai]:[Ni],[Oi]:[Ni],[Mi]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Ri]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Pi]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Di]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ai]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Vi=function(e,t,i,s){const n=zi(e,t,i,s),r=ji[n];if(It(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},Gi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[gi,e&&e[1]||""]],[new RegExp(pi,"i"),[pi,""]],[new RegExp(_i,"i"),[_i,""]],[Ui,[si,""]],[new RegExp(mi,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[yi,""];if(new RegExp(Zt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=Wi[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[mi,e]}return[mi,""]}],[/((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=>{let t="";return e&&e.length>=3&&(t=It(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Jt,[e[2],e[3],e[4]||"0"].join(".")]:[Jt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const 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",""]]],Qi=function(e){for(let t=0;Gi.length>t;t++){const[i,s]=Gi[t],n=i.exec(e),r=n&&(Ct(s)?s(n,e):s);if(r)return r}return["",""]},Ki=function(e){return Hi.test(e)?pi:qi.test(e)?_i:Bi.test(e)?gi:new RegExp(Si,"i").test(e)?Si:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?yi:/iPad/.test(e)?ei:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ti:Ui.test(e)?si:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(bi,"i").test(e)?bi:/(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(Zt).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)?Jt:Xt:new RegExp("(pda|Mobile)","i").test(e)?wi:new RegExp(Yt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?ki:""},Zi=function(e,t){var i;const s=Ki(e);return s===ei||s===Xt||"Kobo"===s||"Kindle Fire"===s||s===ki?Yt:s===pi||s===gi||s===_i||s===Si?"Console":s===ti?"Wearable":s?Zt:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(n=null==t?void 0:t.screenWidth)&&void 0!==n?n:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?Zt:Yt:"Desktop";var n,r,o},Ji=/\bFBAV\/(\d+(?:\.\d+)*)/i,Yi=[[/\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"]],Xi="[Truncated]",es="[Unserializable]";function ts(e){let t="";for(let i=0;e.length>i;i++){const s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"�";else{const s=e.charCodeAt(i+1);56320>s||s>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}function is(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const s of i){let i;try{i=t[s]}catch(e){i=es}Object.defineProperty(e,s,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const ss=3e5;var ns=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),s=Math.min(e.retryAfterMs,ss);if(!t)return this._installedAt=i,void(this._until=i+s);this._until=Math.max(this._until,Math.min(i+s,this._installedAt+ss))}remainingMs(){const e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;const t=Math.min(ss,Math.max(0,this._until-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}};const rs=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function os(e,t){return"string"==typeof(i=e)&&rs.test(i)?e:t();var i}function as(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function ls(e){return e?e.split("#")[0]:e}function cs(e){try{return e()}catch(e){return}}function us(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function ds(e,t,i){return hs.apply(this,arguments)}function hs(){return(hs=rt(function*(e,t,i){let s;try{return yield Promise.race([e,new Promise((e,n)=>{s=us(()=>{try{null==i||i(),e()}catch(e){n(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let ps,_s,gs;function fs(e){const t=globalThis._posthogChunkIds;if(!t)return;const i=Object.keys(t);return gs&&i.length===_s||(_s=i.length,gs=i.reduce((i,s)=>{ps||(ps={});const n=ps[s];if(n)i[n[0]]=n[1];else{const n=e(s);for(let e=n.length-1;e>=0;e--){const r=n[e],o=null==r?void 0:r.filename,a=t[s];if(o&&a){i[o]=a,ps[s]=[o,a];break}}}return i},{})),gs}var vs=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return rt(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&kt(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?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){let i,s;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),ct(ct({},e),{},{cause:i,stack:s})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return rt(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){var i,s,n;const r={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(r.stacktrace={type:"raw",frames:e.stack});const o=[r];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,ct(ct({},t),{},{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:fs(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i=0){const s=(i,s)=>{if(4>=s){const n=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,n)}};return ct(ct({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,i),next:e=>s(e,i+1)})}};const ms=/^([a-z][a-z0-9.+-]+):/i,ys=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function bs(e){if(!e||"<anonymous>"===e)return!1;const t=ms.exec(e);return!t||ys.includes(t[1].toLowerCase())}function Ss(e,t,i,s,n){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:bs(t)};return It(s)||(r.lineno=s),It(n)||(r.colno=n),r}const ws=(e,t)=>{const 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]},ks=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Cs=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Es=/\((\S*)(?::(\d+))(?::(\d+))\)/,xs=(e,t)=>{const i=ks.exec(e);if(i){const[,e,s,n]=i;return Ss(t,e,"?",+s,+n)}const s=Cs.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){const e=Es.exec(s[2]);e&&(s[2]=e[1],s[3]=e[2],s[4]=e[3])}const[e,i]=ws(s[1]||"?",s[2]);return Ss(t,i,e,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},Is=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ts=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ms=(e,t)=>{const i=Is.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Ts.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],s=i[1]||"?";return[s,e]=ws(s,e),Ss(t,e,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Rs=/\(error: (.*)\)/;function Ps(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Fs(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let s=!0;for(let n=0;t>n;n++)if(!Ps(e[i+n],e[i+t+n])){s=!1;break}if(s){for(let s=0;t>s;s++)e[i+s]=e[i+t+s];return e.length=i+t,{start:i,length:t}}}}function Ls(e,t){const i=t.start+t.length,s=Os(e,t);s&&e.splice(i+s===e.length?i:t.start,s)}function As(e,t){let i=t.start;for(;i>0&&Ps(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function Os(e,t){const i=t.start+t.length;let s=i;for(;e.length>s&&Ps(e[s],e[s-t.length]);)s++;return s-i}function Ds(e,t){const i=t[0];let s=e.length-(i?As(e,i):0);for(const i of t)s-=Os(e,i);return s}function $s(e,t,i){for(let s=0;e.length>s;s++){const n=e[(t+s)%e.length],r=e[(i+s)%e.length];if(n!==r)return r>n}return!1}var Ns=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const i=Tt(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){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Bt(e,"DOMException")}isDOMError(e){return Bt(e,"DOMError")}},Bs=class{match(e){return qt(e)}coerce(e,t){var i;const s=this.getStack(e),n=void 0===s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const 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}},qs=class{match(e){return!!Bt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const s=t.apply(e.message);return ct(ct({},s),{},{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:s.stack,synthetic:!0})}_hasUsableMessage(e){return Tt(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i;const s=e,n=null!==(t=s.lineno)&&void 0!==t?t:0,r=null!==(i=s.colno)&&void 0!==i?i:0;if(Tt(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Hs=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Us=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[s,n]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const s=e.match(Hs);return s&&(t=s[1],i=s[2]),[t,i]}};const Ws=["fatal","error","warning","log","info","debug"];function zs(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const s=i.slice(0,e).join(", ");if(t>=s.length)return e===i.length?s:s.length>t?`${s.slice(0,t)}...`:s}return""}var js=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s;const n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{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?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ht(e))return e.constructor.name;const t="name"in e?e.name:void 0;return Tt(t)&&!Mt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let 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;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${zs(e)}`}isSeverityLevel(e){return Tt(e)&&!Mt(e)&&Ws.indexOf(e)>=0}getStack(e){try{return Tt(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Tt(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(qt(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},Vs=class{match(e){return Ht(e)}coerce(e,t){var i;const s=e.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${zs(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},Gs=class{match(e){return Nt(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?void 0:i.stack,synthetic:!0}}},Qs=class{match(e){return Bt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ht(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const s=this.getUnhandledRejectionReason(e);return Nt(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(i=t.syntheticException)||void 0===i?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}};const Ks="$message",Zs="$timestamp",Js=new Set([Ks,Zs]),Ys={enabled:!0,max_bytes:32768};function Xs(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Ys.enabled,max_bytes:tn(e.max_bytes,Ys.max_bytes)}:ct({},Ys)}var en=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=Xs(e)}setConfig(e){this._config=Xs(e),this._trimToMaxBytes()}add(e){const t=function(e){let t;try{t=yt(e)}catch(e){return}try{const e=JSON.parse(t);if(!Et(e))return;const i=e,s=i[Ks],n=i[Zs];if(!Tt(s)||0===s.trim().length)return;if(!Tt(n)&&!Ft(n))return;return{step:i,json:t}}catch(e){return}}(e);if(!t)return;const i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=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;){const e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function tn(e,t){if(!Ft(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const sn=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function nn(e){return"string"==typeof e||e}function rn(e){return"string"==typeof e?e:void 0}const on=["$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"],an="NativeGzipValidationError",ln=e=>e.length>=2&&31===e[0]&&139===e[1],cn=(e,t)=>e===dt.GZipJS||t===dt.GZipJS||"gzip"===t,un=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),dn=e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return un(e)||t===an};let hn;const pn=e=>{throw as(an,`Native gzip produced invalid output: ${e}`)},_n=(gn=rt(function*(e,t){18>e.size&&pn("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());ln(i)&&8===i[2]||pn("invalid-header");const s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{const t=(()=>{if(hn)return hn;hn=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;hn[e]=t>>>0}return hn})();let i=4294967295;for(let s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&pn("invalid-crc");const n=t.length>>>0;s.getUint32(4,!0)!==n&&pn("invalid-size")}),function(e,t){return gn.apply(this,arguments)});var gn;function fn(e){return vn.apply(this,arguments)}function vn(){return vn=rt(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),n=i.writable.getWriter(),r=n.write(t).then(()=>n.close()).catch((s=rt(function*(e){try{yield n.abort(e)}catch(e){}throw e}),function(e){return s.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield _n(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var s}),vn.apply(this,arguments)}function mn(e,t){if(null==e)return{};var i,s,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;i[s]=e[s]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;r.length>s;s++)t.includes(i=r[s])||{}.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}const yn={}.propertyIsEnumerable;function bn(e,t){try{return kn(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Sn(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:Xi};if(i.remainingNodes--,At(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){const 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)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:ts(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:Xi};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?ts(i):String(i)}}i.ancestors.add(e);try{try{const n=e.toJSON;if("function"==typeof n)return Sn(n.call(e),t,i,s+1)}catch(e){}return kt(e)?{arrayValue:{values:wn(e,t,i,s+1)}}:{kvlistValue:{values:kn(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:ts(String(e))}}function wn(e,t,i,s){const n=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(Pt(r))continue;n.push(Sn(r,t,i,s))}catch(e){n.push({stringValue:es})}return e.length>o&&n.push({stringValue:Xi}),n}function kn(e,t,i,s){const n=[];for(const r in e)if(yn.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(Rt(o)||It(o))continue;n.push({key:ts(r),value:Sn(o,t,i,s)})}catch(e){n.push({key:ts(r),value:{stringValue:es}})}}return n}function Cn(e,t,i){return ct(ct(ct(ct({},is({},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})}const En=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function xn(e,t){const i=is({},e),s={};for(const e of En)({}).hasOwnProperty.call(i,e)&&(s[e]=i[e],delete i[e]);return[...bn(i,t),...bn(s,t)]}const In={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const Tn={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}},Mn=Tn.info;function Rn(e){try{return ts(String(e))}catch(e){return es}}function Pn(e,t,i,s){const n=e.level||"info",{text:r,number:o}=Tn[n]||Mn,a=function(e=Date.now()){return String(e)+"000000"}(Ft(s)?s:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),Pt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),Pt(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=ct({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const t of e){let e;try{e=u[t]}catch(t){e=es}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:Rn(e.body)},attributes:bn(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),It(e.trace_flags)||(d.flags=e.trace_flags),d}function Fn(e,t,i){return Cn(e,t,i)}function Ln(e,t,i,s){return{resourceLogs:[{resource:{attributes:xn(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var An=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=us(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&(clearTimeout(this._timer),this._timer=void 0)}};function On(){return.75+.5*Math.random()}function Dn(e,t,i,s){const n=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,e)))*i)}var $n=class{constructor(e,t,i,s,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this._config=t,this._logger=i,this._getContext=s,this._onReady=n,this._waitForStoragePersist=r,this._scopeName=o,this._flushTimer=new An(()=>this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new ns,this._consecutiveFlushFailures=0,this._flushJitter=1,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(ut.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const s=this._runBeforeSend(e);if(null===s)return;if(!s.body)return void this._logger.info("Log was rejected in beforeSend function");if(!this._checkRateLimit())return;const n={record:Pn(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(n))}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Log was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return s}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;const 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 rt(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return rt(function*(){var t;e._flushTimer.clear();let i=null!==(t=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const s=i.length;let n=0;for(;i.length>0&&s>n;){var r,o;const t=e._queueGeneration;e._evictedSinceAdvance=0;const s=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,s),l=Ln(a.map(e=>e.record),e._buildResourceAttributes(),null!==(r=e._scopeName)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(l);if(e._queueGeneration!==t)return;if("too-large"===c.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else{if(e._retryAfter.record(c),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===c.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),i=null!==(o=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==o?o:[],n+=a.length,"fatal"===c.kind)throw c.error}}})()}_persistQueueAdvance(e){var t=this;return rt(function*(){var i;const s=Math.max(0,e-t._evictedSinceAdvance),n=null!==(i=t._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(ut.LogsQueue,n.slice(s)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return Fn(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(ut.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(ut.LogsQueue,i),this._maxBufferSize>i.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackground()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(Dn(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){const e=this._instance.getPersistedProperty(ut.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return rt(function*(){t._flushTimer.clear();const i=t.flush().catch(()=>{});void 0!==e?yield ds(i,e):yield i})()}flushWithTimeout(e){var t=this;return rt(function*(){const i=t.flush();yield ds(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=On(),this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}};const Nn=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Bn(e){return String(e)+"000000"}function qn(e,t,i,s){let n="";return s&&(n=Object.keys(s).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(s[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${n}`}var Hn=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushTimer=new An(()=>this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._retryAfter=new ns,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,i){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;const t=this._flushPromise,i=function(){var i=rt(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;const 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._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),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)return;const t=this._runBeforeSend(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this._logger.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"===t.type&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,s;try{i=t.attributes?ct({},t.attributes):void 0,s=qn(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let n=this._series.get(s);if(!n){if(!this._admitNewSeries())return;n={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this._series.set(s,n)}const r=this._typeByName.get(t.name);void 0===r?this._typeByName.set(t.name,t.type):r===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn(`Metric name '${t.name}' is already used as a ${r}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this._fold(n,t.value),this._armFlushTimer()}_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){switch(e.type){case"count":var i;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(Nn.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,Nn)]+=1;break}}}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Metric was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return s}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(Dn(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return rt(function*(){if(e._flushTimer.clear(),0===e._series.size)return;const t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;const i=e._generation,s=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(e._retryAfter.record(s),"retry-later"===s.kind?(e._consecutiveFlushFailures++,e._flushJitter=On()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),s.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._flushTimer.armNoEarlierThan(e._nextFlushDelay());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 Cn(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:xn(i)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,i,s,n}_buildMetrics(e){const t=Bn(Date.now()),i=new Map;for(const o of e.values()){var s;const e=qn(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=ct({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=bn(null!==(s=o.attributes)&&void 0!==s?s:{},this._logger),c=Bn(o.windowStartMs);if("count"===o.type){var n;const e={attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(n=o.total)&&void 0!==n?n:0};a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e={attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0};a.gauge.dataPoints.push(e)}else o.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Nn})}return Array.from(i.values())}_mergeWindowBack(e){for(const[s,n]of e){const e=this._series.get(s);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,n.windowStartMs),e.type){case"count":var t,i;e.total=(null!==(t=e.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(e.hist){e.hist.count+=n.hist.count,e.hist.sum+=n.hist.sum,e.hist.min=Math.min(e.hist.min,n.hist.min),e.hist.max=Math.max(e.hist.max,n.hist.max);for(let t=0;e.hist.bucketCounts.length>t;t++)e.hist.bucketCounts[t]+=n.hist.bucketCounts[t]}else e.hist=n.hist}else this._admitNewSeries()&&this._series.set(s,n)}}};function Un(e,t){if(!e)return;const i=e.find(e=>e.type===t);return null==i?void 0:i.value}const Wn="0.8.3",zn={DEBUG:!1,LIB_VERSION:Wn,LIB_NAME:"browser-common",JS_SDK_VERSION:Wn},jn=(t,{debugEnabled:i}={})=>{const s={_log(s,...n){e&&(zn.DEBUG||e.POSTHOG_DEBUG||i)&&!It(e.console)&&e.console&&("__rrweb_original__"in e.console[s]?e.console[s].__rrweb_original__:e.console[s])(t,...n)},debug(...e){s._log("debug",...e)},info(...e){s._log("log",...e)},warn(...e){s._log("warn",...e)},error(...e){s._log("error",...e)},critical(...e){console.error(t,...e)},uninitializedWarning(e){s.error(`You must initialize PostHog before calling ${e}`)},createLogger:(e,i)=>jn(`${t} ${e}`,i)};return s},Vn=jn("[PostHog.js]"),Gn=Vn.createLogger;function Qn(e,t){kt(e)&&e.forEach(t)}function Kn(e,t){if(!Pt(e))if(kt(e))e.forEach(t);else if(Ot(e))e.forEach((e,i)=>t(e,i));else for(const i in e)St.call(e,i)&&t(e[i],i)}const Zn=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function Jn(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const Yn=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Vn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Vn.critical(e)}}},Xn=function(e){const t={};return Kn(e,function(e,i){(Tt(e)&&e.length>0||Ft(e))&&(t[i]=e)}),t};function er(e){const t=ct({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const tr=["herokuapp.com","vercel.app","netlify.app"];function ir(e){const t=null==e?void 0:e.hostname;if(!Tt(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of tr)if(i===e)return!1;return!0}function sr(e,t,i,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:n,passive:r})}function nr(e){return"ph_toolbar_internal"===e.name}const rr=["localhost","127.0.0.1"],or=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var s;return qt(t)?(null!==(s=i)&&void 0!==s||(i=new WeakMap),i.has(t)||i.set(t,er(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return yt(e)}},ar=e=>{const t=null==s?void 0:s.createElement("a");return It(t)?null:(t.href=e,t)},lr=function(e,t="&"){let i,s;const n=[];return Kn(e,function(e,t){It(e)||It(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),n[n.length]=s+"="+i)}),n.join(t)},cr=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let e=0;i.length>e;e++){const n=i[e].split("=");if(n[0]===t){s=n;break}}if(!kt(s)||2>s.length)return"";{let e=s[1];try{e=decodeURIComponent(e)}catch(t){Vn.error("Skipping decoding for malformed query param: "+e)}return e.replace(/\+/g," ")}},ur=function(e,t,i){if(!e||!t||!t.length)return e;const s=e.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const s=l[e].split("=");kt(s)&&(t.includes(s[0])?c.push(s[0]+"="+i):c.push(l[e]))}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=n&&(u+="#"+n),u},dr=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},hr=(e,t)=>e>=t&&u(),pr=(e,t,i,s)=>{if(0===e){if(u()){const e=t+1;return e===i&&s(),e}return t}return 0};function _r(e,t){var i;const s=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!Ct(s))return t;try{const e=s(t);return Tt(e)&&e?e:t}catch(e){return Vn.error("Error in get_current_url, falling back to window.location.href",e),t}}function gr(t){var i;const s=null==e||null===(i=e.location)||void 0===i?void 0:i.href;return It(s)?void 0:_r(t,s)}function fr(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function vr(e){return!!e&&1===e.nodeType}function mr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function yr(e){return!!e&&3===e.nodeType}function br(e){return!!e&&11===e.nodeType&&vr(e.host)}function Sr(e){return e?vt(e).split(/\s+/):[]}function wr(e,t){const i=gr(t);return!!(i&&e&&e.some(e=>i.match(e)))}function kr(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Sr(t)}function Cr(e){return Pt(e)?null:vt(e).split(/(\s+)/).filter(e=>Jr(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Er(e){let t="";return Ur(e)&&!Wr(e)&&e.childNodes&&e.childNodes.length&&Kn(e.childNodes,function(e){var i;yr(e)&&e.textContent&&(t+=null!==(i=Cr(e.textContent))&&void 0!==i?i:"")}),vt(t)}function xr(e){var t;return It(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const Ir=["a","button","form","input","select","textarea","label"];function Tr(e,t){const 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 Mr(e,t){if(It(t))return!0;for(const i of e)if(t.some(e=>Tr(i,e)))return!0;return!1}function Rr(e){const t=e.parentNode;return!(!t||!vr(t))&&t}const Pr=[".ph-no-autocapture","[data-ph-no-autocapture]"],Fr=["next","previous","prev",">","<"],Lr=[...Fr,"+","-","−","–"],Ar=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Or=[".ph-no-deadclick",".ph-no-capture"],Dr=[".ph-no-rageclick",".ph-no-capture"],$r=["","text","search","email","password","url","tel","number"];function Nr(e){return!(!e||!vr(e))&&(!!mr(e,"textarea")||(mr(e,"input")?ft($r,(e.getAttribute("type")||"").toLowerCase()):function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i}(e)))}function Br(t,i){if(!e||qr(t))return!1;let s,n,r;var o,a;if(At(i)?(s=!!i&&Dr,n=void 0,r=!1):(s=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Dr,n=null==i?void 0:i.content_ignorelist,r=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===s)return!1;if(r&&Nr(t))return!1;const{targetElementList:l}=Hr(t,!1);return!function(e,t){if(!1===e||It(e))return!1;let i;if(!0===e)i=Fr;else{if(!kt(e))return!1;if(e.length>10)return Vn.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(({safeText:e,ariaLabel:t})=>i.some(i=>Ar(e,i)||Ar(t,i)))}(n,l.map(e=>{var t;return{safeText:Er(e).toLowerCase(),ariaLabel:(null===(t=e.getAttribute("aria-label"))||void 0===t?void 0:t.toLowerCase().trim())||""}}))&&!Mr(l,s)}const qr=e=>!e||mr(e,"html")||!vr(e),Hr=(t,i)=>{if(!e||qr(t))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const n=[t];let r=t;for(;r.parentNode&&!mr(r,"body");){if(br(r.parentNode)){n.push(r.parentNode.host),r=r.parentNode.host;continue}const t=Rr(r);if(!t)break;if(i||Ir.indexOf(t.tagName.toLowerCase())>-1)s=!0;else try{const i=e.getComputedStyle(t);i&&"pointer"===i.getPropertyValue("cursor")&&(s=!0)}catch(e){}n.push(t),r=t}return{parentIsUsefulElement:s,targetElementList:n}};function Ur(e){const t=new Set;let i=0;for(let s=e;s.parentNode&&!mr(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);const e=kr(s);if(ft(e,"ph-sensitive")||ft(e,"ph-no-capture"))return!1}if(ft(kr(e),"ph-include"))return!0;const s=e.type||"";if(Tt(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=e.name||e.id||"";return!Tt(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Wr(e){return!!(mr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||mr(e,"select")||mr(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const zr=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),jr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Vr=[16,15,14,13],Gr=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Qr=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Kr=/[0-9A-Za-z_]/;function Zr(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function Jr(e,t=!0){if(Pt(e))return!1;if(Tt(e)){if(e=vt(e),t?zr.test((e||"").replace(/[- ]/g,"")):function(e){let t;for(jr.lastIndex=0;t=jr.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of Vr){const s=e+t;if(i.length>=s){const t=i.slice(e,s);if(zr.test(t)&&Zr(t))return!0}}}return!1}(e))return!1;if(t?Gr.test(e):function(e){let t;for(Qr.lastIndex=0;t=Qr.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&Kr.test(e)&&Kr.test(i)))return!0}return!1}(e))return!1}return!0}function Yr(e){let t=Er(e);return t=`${t} ${Xr(e)}`.trim(),Jr(t)?t:""}function Xr(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Kn(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=Er(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${Xr(e)}`.trim())}catch(e){Vn.error("[AutoCapture]",e)}}),t}function eo(e){return e.replace(/"|\\"/g,'\\"')}function to(e){const t=e.attr__class;if(t)return kt(t)?t:Sr(t)}const io=1e6;function so(e){var t;return Math.min(io,null!==(t=e.payloadSizeLimitBytes)&&void 0!==t?t:io)}const no={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:io,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","google-analytics.com","analytics.google.com","nr-data.net","datadoghq.com","datadoghq.eu","ddog-gov.com","segment.io","rudderstack.com","amplitude.com","mixpanel.com","hotjar.com","hotjar.io","fullstory.com"],streamNetworkBody:!1},ro=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],oo=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],ao=["auth","token","secret","session","api-key","apikey","api_key","credential","password","passwd","cookie","csrf","xsrf"],lo=e=>{Pt(e)||Kn(Object.keys(e),t=>{(e=>{const t=e.toLowerCase();return ro.includes(t)||ao.some(e=>t.includes(e))})(t)&&(e[t]="redacted")})},co=["/s/","/e/","/i/"];function uo(e,t,i,s){if(Pt(e))return e;let n=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return Tt(n)&&(n=parseInt(n)),n>i?`[SessionRecording] ${s} body too large to record (${n} bytes)`:e}function ho(e,t){if(Pt(e))return e;let i=e;return Jr(i,!1)||(i="[SessionRecording] "+t+" body redacted"),Kn(oo,e=>{(null==i?void 0:i.length)&&-1!==(null==i?void 0:i.indexOf(e))&&(i="[SessionRecording] "+t+" body redacted as might contain: "+e)}),i}const po=new WeakSet,_o="disabled",go="sampled",fo="active",vo="buffering",mo="paused",yo="lazy_loading",bo="rrweb_error",So="trigger_activated",wo="trigger_pending",ko="trigger_disabled";function Co(e,t,i,s,n,r){return 0===t?ko:(null==e?void 0:e.get_property(i?s+i:n))===r?So:wo}function Eo(e,t,i){return t.some(t=>{var s;return"regex"===t.matching&&(null!==(s=null==i?void 0:i.get(t.url))&&void 0!==s?s:new RegExp(t.url)).test(e)})}function xo(e){return e.includes("trigger_activated")?So:e.includes("trigger_pending")?wo:ko}function Io(e){const t=new Set(e);switch(t.delete(ko),t.size){case 0:return ko;case 1:return Array.from(t)[0];default:return wo}}var To=class{constructor(e){this._matchers=e}triggerStatus(e){return xo(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return xo(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},Mo=class{constructor(e){this._matchers=e}triggerStatus(e){return Io(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return Io(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},Ro=class{triggerStatus(){return this.triggerStatusNoSideEffects()}triggerStatusNoSideEffects(){return So}stop(){}};const Po=e=>"sessionRecording"in e;var Fo=class{constructor(e,t){this._instance=e,this._urlTriggers=[],this._urlBlocklist=[],this._compiledTriggerRegexes=new Map,this._compiledBlocklistRegexes=new Map,this._lastCheckedUrl="",this.urlBlocked=!1,this._groupId=t}onConfig(e){var t,i;this._urlTriggers=(Po(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.urlTriggers:[]:null==e?void 0:e.urlTriggers)||[],this._urlBlocklist=(Po(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.urlBlocklist:[]:null==e?void 0:e.urlBlocklist)||[],this._compileRegexCache()}_compileRegexCache(){this._compiledTriggerRegexes.clear(),this._compiledBlocklistRegexes.clear();for(const e of this._urlTriggers)if("regex"===e.matching&&!this._compiledTriggerRegexes.has(e.url))try{this._compiledTriggerRegexes.set(e.url,new RegExp(e.url))}catch(t){Vn.error("Invalid URL trigger regex pattern:",e.url,t)}for(const e of this._urlBlocklist)if("regex"===e.matching&&!this._compiledBlocklistRegexes.has(e.url))try{this._compiledBlocklistRegexes.set(e.url,new RegExp(e.url))}catch(t){Vn.error("Invalid URL blocklist regex pattern:",e.url,t)}}onRemoteConfig(e){this.onConfig(e)}_urlTriggerStatus(e){return Co(this._instance,this._urlTriggers.length,this._groupId,Q,j,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[ze]:t}),t}triggerStatusNoSideEffects(e){return this._urlTriggerStatus(e)}isCurrentUrlBlocked(){const e=gr(this._instance);if(!e)return!1;try{return Eo(e,this._urlBlocklist,this._compiledBlocklistRegexes)}catch(e){return!0}}checkUrlBlocklist(e,t){const i=gr(this._instance);if(!i)return;if(i===this._lastCheckedUrl)return;this._lastCheckedUrl=i;const s=this.urlBlocked,n=Eo(i,this._urlBlocklist,this._compiledBlocklistRegexes);s&&n||(n&&!s?e():!n&&s&&t())}checkUrlTriggerConditions(e,t,i,s){const n=gr(this._instance);if(!n)return;if(n===this._lastCheckedUrl)return;this._lastCheckedUrl=n;const r=this.urlBlocked,o=Eo(n,this._urlBlocklist,this._compiledBlocklistRegexes);o&&!r?e():!o&&r&&t();const a=this._urlTriggerStatus(s)===So,l=Eo(n,this._urlTriggers,this._compiledTriggerRegexes);!a&&l&&i("url",n)}stop(){this._lastCheckedUrl=""}},Lo=class{constructor(e){this._instance=e,this.linkedFlag=null,this.linkedFlagSeen=!1,this._flagListenerCleanup=()=>{}}triggerStatus(){const e=this.triggerStatusNoSideEffects();return this._instance.register_for_session({[Be]:e}),e}triggerStatusNoSideEffects(){let e=wo;return Pt(this.linkedFlag)&&(e=ko),this.linkedFlagSeen&&(e=So),e}onConfig(e,t){var i;if(this.linkedFlag=(Po(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.linkedFlag:null:null==e?void 0:e.linkedFlag)||null,!Pt(this.linkedFlag)&&!this.linkedFlagSeen){const e=Tt(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,i=Tt(this.linkedFlag)?null:this.linkedFlag.variant;this._flagListenerCleanup=this._instance.onFeatureFlags((s,n)=>{let r=!1;if(Et(n)&&e in n){const t=n[e];r=At(t)?!0===t:i?t===i:!!t}const o=r&&!this.linkedFlagSeen;this.linkedFlagSeen=r,o&&t(e,i)})}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this._flagListenerCleanup()}},Ao=class{constructor(e,t){this._instance=e,this._eventTriggers=[],this._groupId=t}onConfig(e){var t;this._eventTriggers=(Po(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.eventTriggers:[]:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}_eventTriggerStatus(e){return Co(this._instance,this._eventTriggers.length,this._groupId,G,V,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[Ne]:t}),t}triggerStatusNoSideEffects(e){return this._eventTriggerStatus(e)}checkEventTriggerConditions(e,t,i){if(0===this._eventTriggers.length)return;const s=this._eventTriggerStatus(i)===So,n=this._eventTriggers.includes(e);!s&&n&&t("event",e)}stop(){}},Oo=class{constructor(e,t,i){if(this._instance=e,this.group=t,this._urlTriggerMatching=new Fo(e,t.id),this._eventTriggerMatching=new Ao(e,t.id),this._linkedFlagMatching=new Lo(e),t.conditions.events&&t.conditions.events.length>0||t.conditions.urls&&t.conditions.urls.length>0||t.conditions.flag){const e=(t.conditions.events||[]).map(e=>e.name),s={urlTriggers:t.conditions.urls||[],eventTriggers:e,linkedFlag:t.conditions.flag||null,urlBlocklist:[]};this._urlTriggerMatching.onConfig(s),this._eventTriggerMatching.onConfig(s),this._linkedFlagMatching.onConfig(s,i);const n=[this._eventTriggerMatching,this._urlTriggerMatching,this._linkedFlagMatching];this._combinedMatching="any"===t.conditions.matchType?new To(n):new Mo(n)}else this._combinedMatching=new Ro}triggerStatus(e){return this._combinedMatching.triggerStatus(e)}triggerStatusNoSideEffects(e){return this._combinedMatching.triggerStatusNoSideEffects(e)}getPendingTriggerConditions(e){return"trigger_pending"!==this.triggerStatusNoSideEffects(e)?[]:[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===wo).map(({label:e})=>e)}checkEventTriggerConditions(e,t,i){this._eventTriggerMatching.checkEventTriggerConditions(e,t,i)}checkUrlTriggerConditions(e,t,i,s){this._urlTriggerMatching.checkUrlTriggerConditions(e,t,i,s)}activateTrigger(e,t){var i;const s="url"===e?Q+this.group.id:G+this.group.id;null===(i=this._instance.persistence)||void 0===i||i.register({[s]:t})}stop(){this._urlTriggerMatching.stop(),this._eventTriggerMatching.stop(),this._linkedFlagMatching.stop()}};function Do(e){if(e.rrwebError)return bo;if(!e.receivedFlags)return vo;if(!e.isRecordingEnabled)return _o;if(e.urlTriggerMatching.urlBlocked)return mo;const t=!0===e.isSampled,i=new To([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?go:"trigger_activated"===i?fo:"trigger_pending"===i?vo:!1===e.isSampled?_o:fo}function $o(e){if(e.rrwebError)return bo;if(!e.receivedFlags)return vo;if(!e.isRecordingEnabled)return _o;if(e.urlTriggerMatching.urlBlocked)return mo;const t=new Mo([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),i=t!==ko,s=At(e.isSampled);return i&&"trigger_pending"===t?vo:i&&"trigger_disabled"===t||s&&!e.isSampled?_o:!0===e.isSampled?go:fo}function No(){const e=[];return function(t,i){if(Et(i)||kt(i)){for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i}}function Bo(e){const t=JSON.stringify(e,No());return t?new Blob([t]).size:0}function qo(e){if(Rt(e))return 4;if(It(e))return 0;switch(typeof e){case"string":return e.length+2;case"number":return String(e).length;case"boolean":return e?4:5;case"object":{if(kt(e)){let t=2;for(let i=0;e.length>i;i++){i>0&&(t+=1);const s=e[i];t+=It(s)||Rt(s)?4:qo(s)}return t}const t=e;let i=2,s=!0;for(const e in t){if(!{}.hasOwnProperty.call(t,e))continue;const n=t[e];It(n)||(s||(i+=1),s=!1,i+=e.length+3+qo(n))}return i}default:return 0}}function Ho(e,t=6606028.8){if(e.size>=t&&e.data.length>1){const t=Math.floor(e.data.length/2),i=e.sizes.slice(0,t),s=e.sizes.slice(t);return[Ho({size:i.reduce((e,t)=>e+t,0),data:e.data.slice(0,t),sizes:i,sessionId:e.sessionId,windowId:e.windowId}),Ho({size:s.reduce((e,t)=>e+t,0),data:e.data.slice(t),sizes:s,sessionId:e.sessionId,windowId:e.windowId})].flatMap(e=>e)}return[e]}var Uo=Uint8Array,Wo=Uint16Array,zo=Uint32Array,jo=new Uo([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]),Vo=new Uo([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]),Go=new Uo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qo=function(e,t){for(var i=new Wo(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var n=new zo(i[30]);for(s=1;30>s;++s)for(var r=i[s];i[s+1]>r;++r)n[r]=r-i[s]<<5|s;return[i,n]},Ko=Qo(jo,2),Zo=Ko[1];Ko[0][28]=258,Zo[258]=28;for(var Jo=Qo(Vo,0)[1],Yo=new Wo(32768),Xo=0;32768>Xo;++Xo){var ea=(43690&Xo)>>>1|(21845&Xo)<<1;Yo[Xo]=((65280&(ea=(61680&(ea=(52428&ea)>>>2|(13107&ea)<<2))>>>4|(3855&ea)<<4))>>>8|(255&ea)<<8)>>>1}var ta=function(e,t,i){for(var s=e.length,n=0,r=new Wo(t);s>n;++n)++r[e[n]-1];var o,a=new Wo(t);for(n=0;t>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new Wo(1<<t);var l=15-t;for(n=0;s>n;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[Yo[d]>>>l]=c}else for(o=new Wo(s),n=0;s>n;++n)o[n]=Yo[a[e[n]-1]++]>>>15-e[n];return o},ia=new Uo(288);for(Xo=0;144>Xo;++Xo)ia[Xo]=8;for(Xo=144;256>Xo;++Xo)ia[Xo]=9;for(Xo=256;280>Xo;++Xo)ia[Xo]=7;for(Xo=280;288>Xo;++Xo)ia[Xo]=8;var sa=new Uo(32);for(Xo=0;32>Xo;++Xo)sa[Xo]=5;var na=ta(ia,9,0),ra=ta(sa,5,0),oa=function(e){return(e/8|0)+(7&e&&1)},aa=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Wo?Wo:e instanceof zo?zo:Uo)(i-t);return s.set(e.subarray(t,i)),s},la=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},ca=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},ua=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new Uo(0),0];if(1==n){var o=new Uo(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;n>s;++s)r[s].s>h&&(h=r[s].s);var p=new Wo(h+1),_=da(i[u-1],p,0);if(_>t){s=0;var g=0,f=_-t,v=1<<f;for(r.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});n>s;++s){var m=r[s].s;if(t>=p[m])break;g+=v-(1<<_-p[m]),p[m]=t}for(g>>>=f;g>0;){var y=r[s].s;t>p[y]?g-=1<<t-p[y]++-1:++s}for(;s>=0&&g;--s){var b=r[s].s;p[b]==t&&(--p[b],++g)}_=t}return[new Uo(p),_]},da=function(e,t,i){return-1==e.s?Math.max(da(e.l,t,i+1),da(e.r,t,i+1)):t[e.s]=i},ha=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Wo(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},pa=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},_a=function(e,t,i){var s=i.length,n=oa(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;s>r;++r)e[n+r+4]=i[r];return 8*(n+4+s)},ga=function(e,t,i,s,n,r,o,a,l,c,u){la(t,u++,i),++n[256];for(var d=ua(n,15),h=d[0],p=d[1],_=ua(r,15),g=_[0],f=_[1],v=ha(h),m=v[0],y=v[1],b=ha(g),S=b[0],w=b[1],k=new Wo(19),C=0;m.length>C;++C)k[31&m[C]]++;for(C=0;S.length>C;++C)k[31&S[C]]++;for(var E=ua(k,7),x=E[0],I=E[1],T=19;T>4&&!x[Go[T-1]];--T);var M,R,P,F,L=c+5<<3,A=pa(n,ia)+pa(r,sa)+o,O=pa(n,h)+pa(r,g)+o+14+3*T+pa(k,x)+(2*k[16]+3*k[17]+7*k[18]);if(A>=L&&O>=L)return _a(t,u,e.subarray(l,l+c));if(la(t,u,1+(A>O)),u+=2,A>O){M=ta(h,p,0),R=h,P=ta(g,f,0),F=g;var D=ta(x,I,0);for(la(t,u,y-257),la(t,u+5,w-1),la(t,u+10,T-4),u+=14,C=0;T>C;++C)la(t,u+3*C,x[Go[C]]);u+=3*T;for(var N=[m,S],B=0;2>B;++B){var q=N[B];for(C=0;q.length>C;++C)la(t,u,D[H=31&q[C]]),u+=x[H],H>15&&(la(t,u,q[C]>>>5&127),u+=q[C]>>>12)}}else M=na,R=ia,P=ra,F=sa;for(C=0;a>C;++C)if(s[C]>255){var H;ca(t,u,M[257+(H=s[C]>>>18&31)]),u+=R[H+257],H>7&&(la(t,u,s[C]>>>23&31),u+=jo[H]);var U=31&s[C];ca(t,u,P[U]),u+=F[U],U>3&&(ca(t,u,s[C]>>>5&8191),u+=Vo[U])}else ca(t,u,M[s[C]]),u+=R[s[C]];return ca(t,u,M[256]),u+R[256]},fa=new zo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),va=new Uo(0),ma=function(){for(var e=new zo(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),ya=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ba(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=ma[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var n,r,o,a,l,c=(n=e,r=t,o=function(e){return 10+(e.filename&&e.filename.length+1||0)}(t),a=8,function(e,t,i,s,n,r){var o=e.length,a=new Uo(s+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(s,a.length-n),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=_a(l,c,e.subarray(u,d)):(l[u]=r,c=_a(l,c,e.subarray(u,o)))}else{for(var h=fa[t-1],p=h>>>13,_=8191&h,g=(1<<i)-1,f=new Wo(32768),v=new Wo(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},S=new zo(25e3),w=new Wo(288),k=new Wo(32),C=0,E=0,x=(u=0,0),I=0,T=0;o>u;++u){var M=b(u),R=32767&u,P=v[M];if(f[R]=P,v[M]=R,u>=I){var F=o-u;if((C>7e3||x>24576)&&F>423){c=ga(e,l,0,S,w,k,E,x,T,u-T,c),x=C=E=0,T=u;for(var L=0;286>L;++L)w[L]=0;for(L=0;30>L;++L)k[L]=0}var A=2,O=0,D=_,N=R-P&32767;if(F>2&&M==b(u-N))for(var B=Math.min(p,F)-1,q=Math.min(32767,u),H=Math.min(258,F);q>=N&&--D&&R!=P;){if(e[u+A]==e[u+A-N]){for(var U=0;H>U&&e[u+U]==e[u+U-N];++U);if(U>A){if(A=U,O=N,U>B)break;var W=Math.min(N,U-2),z=0;for(L=0;W>L;++L){var j=u-N+L+32768&32767,V=j-f[j]+32768&32767;V>z&&(z=V,P=j)}}}N+=(R=P)-(P=f[R])+32768&32767}if(O){S[x++]=268435456|Zo[A]<<18|Jo[O];var G=31&Zo[A],Q=31&Jo[O];E+=jo[G]+Vo[Q],++w[257+G],++k[Q],I=u+A,++C}else S[x++]=e[u],++w[e[u]]}}c=ga(e,l,r,S,w,k,E,x,T,u-T,c),r||(c=_a(l,c,va))}return aa(a,0,s+oa(c)+n)}(n,null==r.level?6:r.level,null==r.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+r.mem,o,a,!l)),u=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&&ya(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),ya(c,u-8,i.d()),ya(c,u-4,s),c}function Sa(e,t){var i=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new Uo(e.length+(e.length>>>1)),n=0,r=function(e){s[n++]=e},o=0;i>o;++o){if(n+5>s.length){var a=new Uo(n+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);128>l||t?r(l):2048>l?(r(192|l>>>6),r(128|63&l)):l>55295&&57344>l?(r(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),r(128|l>>>12&63),r(128|l>>>6&63),r(128|63&l)):(r(224|l>>>12),r(128|l>>>6&63),r(128|63&l))}return aa(s,0,n)}function wa(e,t){var i="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var s=0;e.length>s;){var n=e[s++];128>n||t?i+=String.fromCharCode(n):224>n?i+=String.fromCharCode((31&n)<<6|63&e[s++]):240>n?i+=String.fromCharCode((15&n)<<12|(63&e[s++])<<6|63&e[s++]):(n=((15&n)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,i+=String.fromCharCode(55296|n>>10,56320|1023&n))}return i}var ka=class{constructor(e,t={}){var i,s,n,r;this._rrweb=e,this._options=t,this._loggedTracker={},this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0,this._refillByteBudget=()=>{const e=Date.now(),t=e-this._lastByteRefill;t>0?(this._byteTokens=Math.min(this._bytesBucketSize,this._byteTokens+t/1e3*this._bytesRefillRate),this._lastByteRefill=e):this._lastByteRefill=e},this._onNodeRateLimited=e=>{if(!this._loggedTracker[e]){var t,i;this._loggedTracker[e]=!0;const s=this._getNode(e);null===(t=(i=this._options).onBlockedNode)||void 0===t||t.call(i,e,s)}},this._getNodeOrRelevantParent=e=>{const t=this._getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){const e=t.closest("svg");if(e)return[this._rrweb.mirror.getId(e),e]}return[e,t]},this._getNode=e=>this._rrweb.mirror.getNode(e),this._numberOfChanges=e=>{var t,i,s,n,r,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null===(n=e.attributes)||void 0===n?void 0:n.length)&&void 0!==s?s:0)+(null!==(r=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==r?r:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;const t=e.data,i=this._numberOfChanges(t);if(t.attributes){const e=t.attributes.length;t.attributes=t.attributes.filter(e=>{const[t]=this._getNodeOrRelevantParent(e.id);return!this._rateLimiter.consumeRateLimit(t)&&e});const i=e-t.attributes.length;var s,n;i>0&&(null===(s=(n=this._options).onDroppedAttributeMutations)||void 0===s||s.call(n,i))}const r=this._numberOfChanges(t);if(0===r&&i!==r)return;if(this._byteBudgetDisabled)return e;this._refillByteBudget();const o=qo(e);var a,l;return o>this._byteTokens?(null===(a=(l=this._options).onDroppedOversizedMutation)||void 0===a||a.call(l,o),void this._scheduleResync()):(this._byteTokens-=o,e)},this._scheduleResync=()=>{if(this._resyncTimer)return;const e=Math.max(0,this._resyncIntervalMs-(Date.now()-this._lastResyncAt));this._resyncTimer=setTimeout(()=>{var e,t;this._resyncTimer=void 0,this._lastResyncAt=Date.now(),null===(e=(t=this._options).requestFullSnapshot)||void 0===e||e.call(t)},e)},this._rateLimiter=new Kt({bucketSize:null!==(i=this._options.bucketSize)&&void 0!==i?i:100,refillRate:null!==(s=this._options.refillRate)&&void 0!==s?s:10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited,_logger:Vn}),this._bytesBucketSize=null!==(n=this._options.bytesBucketSize)&&void 0!==n?n:0,this._bytesRefillRate=null!==(r=this._options.bytesRefillRate)&&void 0!==r?r:25600,this._byteBudgetDisabled=!Number.isFinite(this._bytesBucketSize)||0>=this._bytesBucketSize,this._byteTokens=this._bytesBucketSize;const o=this._options.resyncIntervalMs;this._resyncIntervalMs=Ft(o)&&Number.isFinite(o)&&o>0?o:3e5}reset(){this._loggedTracker={},this._resyncTimer&&(clearTimeout(this._resyncTimer),this._resyncTimer=void 0),this._lastResyncAt=Date.now()}stop(){this._rateLimiter.stop(),this.reset(),this._byteTokens=this._bytesBucketSize,this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0}};const Ca=e=>{if(s){try{const t=e+"=",i=s.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(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 Ea=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,n){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(n)||0>t||0>i||0>s||0>n||t>0xffffffffffff||i>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new e(r)}toString(){let e="";for(let 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(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},xa=class{generate(){const e=this.generateOrAbort();if(!It(e))return e;{this._timestamp=0;const e=this.generateOrAbort();if(It(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return Ft(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Ea.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 Ta}};let Ia=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!It(e.crypto)&&crypto.getRandomValues&&(Ia=e=>crypto.getRandomValues(e));var Ta=class{nextUint32(){return this._buffer.length>this._cursor||(Ia(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}};let Ma;const Ra=()=>Pa().toString(),Pa=()=>(Ma||(Ma=new xa)).generate();let Fa="";const La=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Aa=null;const Oa={_is_supported(){if(!Rt(Aa))return Aa;if(Aa=!1,s)try{const e=`__ph_cookie_support_${Ra()}`;Oa._set(e,"xyz"),Aa='"xyz"'===Ca(e),Oa._remove(e)}catch(e){Aa=!1}return Aa},_error(e){Vn.error("cookieStore error: "+e)},_get:Ca,_parse(e){let t;try{t=JSON.parse(Oa._get(e))||{}}catch(e){}return t},_set(e,t,i,n,r){if(!s)return!1;try{let o="",a="";const l=function(e,t){if(t){let t=function(e,t=s){if(Fa)return Fa;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let n=Math.min(i.length,8);const r="dmn_chk_"+Ra();for(;!Fa&&n--;){const e=i.slice(n).join("."),s=r+"=1;domain=."+e+";path=/";t.cookie=s+";max-age=3",t.cookie.includes(r)&&(t.cookie=s+";max-age=0",Fa=e)}return Fa}(e);if(!t){const i=(e=>{const t=e.match(La);return t?t[0]:""})(e);i!==t&&Vn.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}(s.location.hostname,n);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),o="; expires="+e.toUTCString()}r&&(a="; secure");const c=e+"="+encodeURIComponent(JSON.stringify(t))+o+"; SameSite=Lax; path=/"+l+a;return c.length>3686.4&&Vn.warn("cookieStore warning: large cookie, len="+c.length),s.cookie=c,!0}catch(e){return!1}},_remove(e,t){if(null==s?void 0:s.cookie)try{Oa._set(e,"",-1,t)}catch(e){return}}};let Da=null;const $a={_is_supported(){if(!Rt(Da))return Da;let t=!0;if(It(e))t=!1;else try{const e="__mplssupport__";$a._set(e,"xyz"),'"xyz"'!==$a._get(e)&&(t=!1),$a._remove(e)}catch(e){t=!1}return t||Vn.error("localStorage unsupported; falling back to cookie store"),Da=t,t},_error(e){Vn.error("localStorage error: "+e)},_get(t){try{return null==e?void 0:e.localStorage.getItem(t)}catch(e){$a._error(e)}return null},_parse(e){try{return JSON.parse($a._get(e))||{}}catch(e){}return null},_set(t,i){try{return null==e||e.localStorage.setItem(t,JSON.stringify(i)),!0}catch(e){$a._error(e)}return!1},_remove(t){try{null==e||e.localStorage.removeItem(t)}catch(e){$a._error(e)}}},Na=[ae,X,Y,te,ie,se,Ee,Ce,we],Ba=[g,_,U,W,Fe,Pe,b,xe],qa=e=>e+"_cpm",Ha=["__proto__","constructor","prototype"],Ua=e=>{if(!Et(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===Ha.indexOf(i)&&(t[i]=e[i])}),t},Wa=(e,t=[])=>{const i={};return[...Ba,...t].forEach(t=>{const s=e[t];It(s)||Rt(s)||""===s||(i[t]=s)}),i},za=e=>{let t=5381,i=2166136261;for(let s=0;e.length>s;s++){const n=e.charCodeAt(s);t=33*t^n,i=Math.imul(i^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},ja=(e,t)=>({p:t,f:za(JSON.stringify(e))}),Va=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=Oa._parse(qa(e)),s=(null==i?void 0:i.f)===za(t)&&kt(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Ga=(e,t)=>t+"|"+(Oa._get(qa(e))||""),Qa={},Ka={_is_supported:()=>!0,_error(e){Vn.error("memoryStorage error: "+e)},_get:e=>e in Qa?Qa[e]:null,_parse:e=>e in Qa?Qa[e]:null,_set:(e,t)=>(Qa[e]=t,!0),_remove(e){delete Qa[e]}};let Za=null;const Ja={_is_supported(){if(!Rt(Za))return Za;if(Za=!0,It(e))Za=!1;else try{const e="__support__";Ja._set(e,"xyz"),'"xyz"'!==Ja._get(e)&&(Za=!1),Ja._remove(e)}catch(e){Za=!1}return Za},_error(e){Vn.error("sessionStorage error: ",e)},_get(t){try{return null==e?void 0:e.sessionStorage.getItem(t)}catch(e){Ja._error(e)}return null},_parse(e){try{return JSON.parse(Ja._get(e))||null}catch(e){}return null},_set(t,i){try{return null==e||e.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(e){Ja._error(e)}return!1},_remove(t){try{null==e||e.sessionStorage.removeItem(t)}catch(e){Ja._error(e)}}};zn.DEBUG=!1,zn.LIB_VERSION="1.433.3",zn.LIB_NAME="web";var Ya=zn,Xa=class{constructor(e){if(!e.persistence)throw new Error("it is not valid to not have persistence and be this far into setting up the application");this._getProperty=e.get_property.bind(e),this._setProperty=e.persistence.set_property.bind(e.persistence)}trackSize(e,t){this._setProperty(J,{sessionId:e,size:this.currentTrackedSize(e)+t})}currentTrackedSize(e){const t=this._getProperty(J);return Et(i=t)&&Tt(i.sessionId)&&Ft(i.size)&&t.sessionId===e?t.size:0;var i}};function el(e,t){return function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<Qt(100*t,0,100,Vn)}function tl(e){return`$survey_response_${e}`}function il(e,t){if(!t)return null;const i=e[tl(t)];return kt(i)?[...i]:i}function sl(e={},t,i){const s={};return t.questions.forEach(t=>{if(It(t.originalQuestionIndex))return;const i=0===(n=t.originalQuestionIndex)?"$survey_response":`$survey_response_${n}`;var n;const r=il(e,t.id);It(r)||(s[i]=r)}),ct(ct({$survey_questions:t.questions.map(t=>{var s,n;return{id:t.id,question:null!==(s=null==i?void 0:i[null!==(n=t.id)&&void 0!==n?n:""])&&void 0!==s?s:t.question,response:il(e,t.id)}})},e),s)}function nl(e={}){return Object.values(e).some(e=>!Pt(e))}function rl(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function ol(e){return"string"==typeof e&&e.trim()?e.trim():null}function al(e){return e.toLowerCase()}function ll(e,t,i){if(!e||!t)return null;const s=al(t),n=Object.keys(e).find(e=>al(e)===s);if(n)return null==i||i.debug(`Found exact translation match: ${n}`),n;if(s.includes("-")){const n=s.split("-")[0],r=Object.keys(e).find(e=>al(e)===n);if(r)return null==i||i.debug(`Found base language translation match: ${r} (from ${t})`),r}return null}const cl=["thankYouMessageHeader","thankYouMessageDescription","thankYouMessageCloseButtonText","introScreenHeader","introScreenDescription","introScreenButtonText","submitButtonText","backButtonText"];function ul(e,t,i){var s;const n=ll(e.translations,t,i),r=ct({},e);let o=!1;if(n){var a;const t=null===(a=e.translations)||void 0===a?void 0:a[n];if(t)if(null==i||i.info(`Applying survey-level translation for language: ${n}`),It(t.name)||(r.name=t.name,o=!0),r.appearance){const e=ct({},r.appearance);for(const i of cl){const s=t[i];It(s)||(e[i]=s,o=!0)}r.appearance=e}else(function(e){return cl.some(t=>!It(e[t]))})(t)&&(o=!0)}const l=e.questions.map(e=>function(e,t,i){var s;const n=ll(e.translations,t,i);if(!n)return{question:e,matchedKey:null,hasChanges:!1};const r=null===(s=e.translations)||void 0===s?void 0:s[n];if(!r)return{question:e,matchedKey:null,hasChanges:!1};const o=ct({},e);let a=!1;return It(r.question)||(o.question=r.question,a=!0),It(r.description)||(o.description=r.description,a=!0),It(r.buttonText)||(o.buttonText=r.buttonText,a=!0),"link"in o&&!It(r.link)&&(o.link=r.link,a=!0),"lowerBoundLabel"in o&&!It(r.lowerBoundLabel)&&(o.lowerBoundLabel=r.lowerBoundLabel,a=!0),"upperBoundLabel"in o&&!It(r.upperBoundLabel)&&(o.upperBoundLabel=r.upperBoundLabel,a=!0),"choices"in o&&function(e){return kt(e.choices)}(r)&&(o.choices=r.choices,a=!0),{question:a?o:e,matchedKey:a?n:null,hasChanges:a}}(e,t,i)),c=l.map(e=>e.question),u=l.some(e=>e.hasChanges);let d=null;return n||(d=(null===(s=l.find(e=>e.matchedKey))||void 0===s?void 0:s.matchedKey)||null),u&&(r.questions=c,o=!0,null==i||i.info(`Applied question-level translations for language: ${t}`)),{survey:r,matchedKey:o?n||d:null}}function dl(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}function hl(e){var t;return dl(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule}const pl=(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}},_l=e=>e.toLowerCase(),gl={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=>pl(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!pl(t,e))),icontains:(e,t)=>t.map(_l).some(t=>e.map(_l).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(_l).every(t=>e.map(_l).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function fl(e,t){return!e||Object.entries(e).every(([e,i])=>{const s=null==t?void 0:t[e];if(null==s)return!1;const n=gl[i.operator];return!!n&&n(i.values,[String(s)])})}function vl(e,t,i){return or({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const ml=new Set(["is_not","not_icontains","not_regex"]);function yl(e,t,i){return!e||0===e.length||e.every(e=>{const s="person"===e.type?i:t,n=null==s?void 0:s[e.key],r=e.operator||"exact";if(It(n)||Rt(n))return ml.has(r);const o=gl[r];return!!o&&!It(e.value)&&!Rt(e.value)&&o(kt(e.value)?e.value.map(String):[String(e.value)],kt(n)?n.map(String):[String(n)])})}const bl=Gn("[SessionRecording]");function Sl(e,t){return t?e:"!"+e}function wl(e,t){return e===t||e!=="!"+t&&null}var kl=class{constructor(e,t,i,s,n,r,o){this._instance=e,this._urlTriggerMatching=t,this._eventTriggerMatching=i,this._linkedFlagMatching=s,this._reportStarted=n,this._tryTakeFullSnapshot=r,this._onTriggerActivated=o,this._sampleRate=null,this._recordingStatusFunction=$o}onRemoteConfig(e){this._sampleRate=Ft(e.sampleRate)?e.sampleRate:null,"any"===e.triggerMatchType?(this._triggerStatusMatcher=new To([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=Do):(this._triggerStatusMatcher=new Mo([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=$o),this._instance.register_for_session({[Ue]:e.triggerMatchType}),this._urlTriggerMatching.onConfig(e),this._eventTriggerMatching.onConfig(e),this._linkedFlagMatching.onConfig(e,(e,t)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:t}),this._onTriggerActivated()})}getStatus(e){return this._recordingStatusFunction({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId})}getMinimumDuration(e){const t=this._instance.get_property("$session_recording_remote_config"),i=null==t?void 0:t.minimumDurationMilliseconds;return Ft(i)?i:null}checkUrlTriggers(e,t,i,s){this._urlTriggerMatching.checkUrlTriggerConditions(t,i,s,e)}setupEventTriggerListeners(e,t,i){if(0!==this._eventTriggerMatching._eventTriggers.length&&Pt(this._removeEventTriggerCaptureHook))return this._removeEventTriggerCaptureHook=e(e=>{try{this._eventTriggerMatching.checkEventTriggerConditions(e.event,i,t)}catch(e){bl.error("Could not activate event trigger",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){var t;const i=this._sampleRate;var s,n;if(!Ft(i))return null===(s=this._instance.persistence)||void 0===s||s.unregister("$session_is_sampled"),void(null===(n=this._instance.persistence)||void 0===n||n.unregister("$replay_sample_rate"));const r=this._instance.get_property(W),o=this._instance.get_property(D),a=wl(r,e),l=Ft(o)&&o!==i,c=It(o)&&r===e,u=l||c||!At(a),d=u?el(e,i):a;u&&(d?this._reportStarted("sampled"):bl.warn(`Sample rate (${i}) has determined that this sessionId (${e}) will not be sent to the server.`)),null===(t=this._instance.persistence)||void 0===t||t.register({$session_is_sampled:Sl(e,d),$replay_sample_rate:Rt(o)&&r===e?null:i})}ensureSamplingDecision(e){if(!Ft(this._sampleRate))return;const t=this._instance.get_property(W);At(wl(t,e))||this.makeSamplingDecisions(e)}onFlushComplete(){}clearConditionalRecordingPersistence(){var e,t,i,s,n;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_recording_event_trigger_activated_session"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$session_recording_url_trigger_activated_session"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_is_sampled"),null===(s=this._instance.persistence)||void 0===s||s.unregister("$replay_sample_rate"),null===(n=this._instance.persistence)||void 0===n||n.unregister("$session_past_minimum_duration")}updateActiveTriggers(e){}hasPendingTriggers(e){var t;return(null===(t=this._triggerStatusMatcher)||void 0===t?void 0:t.triggerStatus(e))===wo}getPendingTriggerConditions(e){return[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===wo).map(({label:e})=>e)}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._eventTriggerMatching.stop(),this._urlTriggerMatching.stop(),this._linkedFlagMatching.stop()}},Cl=class{constructor(e,t,i,s,n){this._instance=e,this._urlTriggerMatching=t,this._reportStarted=i,this._tryAddCustomEvent=s,this._onTriggerActivated=n,this._triggerGroupMatchers=[],this._triggerGroupSamplingResults=new Map,this._hasCompletedInitialFlush=!1}onRemoteConfig(e){e.triggerGroups&&0!==e.triggerGroups.length?(this._setupTriggerGroups(e.triggerGroups),this._instance.register_for_session({[Ue]:"v2_trigger_groups",[We]:e.triggerGroups.length}),this._urlTriggerMatching.onConfig(e)):bl.warn("[V2Strategy] No trigger groups configured")}getStatus(e){return function(e){if(e.rrwebError)return bo;if(!e.receivedFlags)return vo;if(!e.isRecordingEnabled)return _o;if(e.urlTriggerMatching.urlBlocked)return mo;const t=e.triggerGroupMatchers,i=e.triggerGroupSamplingResults;if(0===t.length)return _o;let s=!1,n=!1;for(const r of t){const t=r.triggerStatus(e.sessionId);if("trigger_activated"===t){const e=r.group.id,t=i.get(e);It(t)?Vn.warn("[V2 Triggers] Group activated but no sampling decision found",{groupId:e}):!0===t&&(n=!0)}else"trigger_pending"===t&&(s=!0)}return n?go:s?vo:_o}({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId,triggerGroupMatchers:this._triggerGroupMatchers,triggerGroupSamplingResults:this._triggerGroupSamplingResults,minimumDuration:this.getMinimumDuration(e.sessionId)})}getMinimumDuration(e){let t=null;for(const i of this._triggerGroupMatchers)if("trigger_activated"===i.triggerStatus(e)){const e=i.group.minDurationMs;Ft(e)&&(Rt(t)||t>e)&&(t=e)}return t}checkUrlTriggers(e,t,i,s){this._urlTriggerMatching.checkUrlBlocklist(t,i);for(const s of this._triggerGroupMatchers)s.checkUrlTriggerConditions(t,i,t=>{this._checkGroupLevelProperties(s,void 0)&&(s.activateTrigger(t,e),this.updateActiveTriggers(e),this._onTriggerActivated(t))},e)}setupEventTriggerListeners(e,t,i){return this._removeEventTriggerCaptureHook=e(e=>{var i;if(this._hasCompletedInitialFlush)return bl.info("[SessionRecorder] Stopping trigger checks - initial buffer flushed"),null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),void(this._removeEventTriggerCaptureHook=void 0);try{for(const i of this._triggerGroupMatchers)i.checkEventTriggerConditions(e.event,s=>{if(!this._checkGroupLevelProperties(i,e.properties))return;const n=(i.group.conditions.events||[]).filter(t=>t.name===e.event),r=this._instance.get_property(ae);n.some(t=>!t.properties||0===t.properties.length||yl(t.properties,e.properties,r))&&(i.activateTrigger(s,t),this.updateActiveTriggers(t),this._onTriggerActivated(s))},t)}catch(e){bl.error("Could not activate event trigger for trigger groups",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){for(const i of this._triggerGroupMatchers){var t;const s=i.group,n=s.id,r=s.sampleRate,o=K+n,a=this._instance.get_property(o);let l=null,c=!1,u=!1,d=!1;if(Et(a)){const t=a.sessionId,i=a.sampleRate,s=a.sampled;c="string"==typeof t&&t!==e,u=Ft(i)&&i!==r,l=t===e&&Ft(i)&&i===r&&At(s)?s:null}else l=a===e||null,c="string"==typeof a&&a!==e,d=a===e;const h=c||u||d||!At(l),p=h?el(e+n,r):l;h&&this._tryAddCustomEvent("triggerGroupSamplingDecisionMade",{group_id:n,group_name:s.name,sampleRate:r,isSampled:p}),this._triggerGroupSamplingResults.set(n,p),null===(t=this._instance.persistence)||void 0===t||t.register({[o]:{sessionId:e,sampleRate:r,sampled:p}})}this.updateActiveTriggers(e)}ensureSamplingDecision(e){}onFlushComplete(){this._hasCompletedInitialFlush=!0}clearConditionalRecordingPersistence(){var e,t,i;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$replay_sample_rate"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_past_minimum_duration");for(const e of this._triggerGroupMatchers){var s,n,r;const t=e.group.id;null===(s=this._instance.persistence)||void 0===s||s.unregister("$posthog_sr_group_event_trigger_"+t),null===(n=this._instance.persistence)||void 0===n||n.unregister("$posthog_sr_group_url_trigger_"+t),null===(r=this._instance.persistence)||void 0===r||r.unregister("$posthog_sr_group_sampling_"+t)}}updateActiveTriggers(e){const t=[];for(const i of this._triggerGroupMatchers){const s=i.group,n=s.id,r="trigger_activated"===i.triggerStatus(e),o=!0===this._triggerGroupSamplingResults.get(n);r&&t.push({id:n,name:s.name,matched:!0,sampled:o})}this._instance.register_for_session({[qe]:t})}hasPendingTriggers(e){for(const t of this._triggerGroupMatchers)if("trigger_pending"===t.triggerStatus(e))return!0;return!1}getPendingTriggerConditions(e){return this._triggerGroupMatchers.flatMap(t=>"trigger_pending"!==t.triggerStatusNoSideEffects(e)?[]:t.getPendingTriggerConditions(e).map(e=>`trigger group "${t.group.name}": ${e}`))}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear(),this._urlTriggerMatching.stop()}_checkGroupLevelProperties(e,t){const i=e.group.conditions.properties;return!i||0===i.length||yl(i,t,this._instance.get_property(ae))}_setupTriggerGroups(e){this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear();for(const t of e){const e=new Oo(this._instance,t,(e,i)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:i,group_id:t.id,group_name:t.name}),this._onTriggerActivated()});this._triggerGroupMatchers.push(e)}}};const El=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],xl=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...El],Il="<masked>",Tl=["li_fat_id"];function Ml(e,t,i){if(!s)return{};const n=t?[...El,...i||[]]:[],r=Rl(ur(s.URL,n,Il),e),o=function(){const e={};return Kn(Tl,function(t){const i=Ca(t);e[t]=i||null}),e}();return Zn(o,r)}function Rl(e,t){const i=xl.concat(t||[]),s={};return Kn(i,function(t){const i=cr(e,t);s[t]=i||null}),s}function Pl(e){const 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",n={};if(!Rt(t)){n.$search_engine=t;const e=s?cr(s.referrer,i):"";e.length&&(n.ph_keyword=e)}return n}function Fl(){return navigator.language||navigator.userLanguage}function Ll(){const e=Fl();return"string"==typeof e?e.split("-")[0]:void 0}const Al="$direct";function Ol(){return(null==s?void 0:s.referrer)||Al}function Dl(e,t,i=!1){const s=e?[...El,...t||[]]:[],r=i?ls(null==n?void 0:n.href):null==n?void 0:n.href,o=null==r?void 0:r.substring(0,1e3);return{r:Ol().substring(0,1e3),u:o?ur(o,s,Il):void 0}}function $l(e,t=!1){var i;const{r:s,u:n}=e,r=t?ls(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Al?Al:null===(i=ar(s))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=ar(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Rl(r);Zn(o,t)}if(s){const e=Pl(s);Zn(o,e)}return o}function Nl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Bl(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const ql=1e5,Hl=/^[A-Za-z0-9]*[A-Za-z][A-Za-z0-9]*$/,Ul=[],Wl=()=>!1,zl="@type @id actionStatus availability bestRating contentRating encodingFormat eventAttendanceMode eventStatus highPrice inLanguage isAccessibleForFree isFamilyFriendly itemCondition itemListOrder lowPrice maximumAttendeeCapacity nonprofitStatus numberOfItems offerCount position price priceCurrency priceValidUntil publicAccess ratingCount ratingValue reviewCount smokingAllowed worstRating".split(" "),jl="Action BorrowAction ReadAction SearchAction SeekToAction SolveMathAction WatchAction".split(" "),Vl="AutoDealer Bakery BarOrPub CafeOrCoffeeShop CollegeOrUniversity Corporation DaySpa Dentist EducationalOrganization Electrician FoodEstablishment GovernmentOrganization HealthClub Hotel LegalService Library LibrarySystem LocalBusiness Locksmith LodgingBusiness MedicalBusiness NGO OnlineStore Organization PerformingGroup Pharmacy Physician Plumber RealEstateAgent Restaurant School SportsOrganization Store".split(" "),Gl="Accommodation AdministrativeArea Country Place State".split(" "),Ql={AggregateOffer:{offers:["Offer"]},Brand:{name:!0},BreadcrumbList:{itemListElement:["ListItem"]},CreativeWork:{genre:!0,dateCreated:!0,dateModified:!0,datePublished:!0,expires:!0,learningResourceType:!0,educationalLevel:!0,educationalUse:!0,interactivityType:!0,aggregateRating:["AggregateRating"],potentialAction:jl,publisher:Vl},Event:{startDate:!0,endDate:!0,previousStartDate:!0,aggregateRating:["AggregateRating"],offers:["AggregateOffer","Offer"]},ItemList:{itemListElement:["ListItem"]},ListItem:{item:Ul},Offer:{seller:Vl},Organization:{name:!0,legalName:!0,foundingDate:!0,dissolutionDate:!0,aggregateRating:["AggregateRating"],brand:["Brand"]},Place:{aggregateRating:["AggregateRating"]},Product:{name:!0,sku:!0,mpn:!0,gtin:!0,gtin8:!0,gtin12:!0,gtin13:!0,gtin14:!0,productID:!0,productGroupID:!0,asin:!0,model:!0,category:!0,color:!0,material:!0,pattern:!0,size:!0,productionDate:!0,releaseDate:!0,brand:["Brand","Organization"],manufacturer:Vl,offers:["Offer","AggregateOffer"],aggregateRating:["AggregateRating"]},Service:{name:!0,serviceType:!0,category:!0,provider:Vl,areaServed:Gl,offers:["AggregateOffer","Offer"],aggregateRating:["AggregateRating"]},OfferCatalog:{name:!0,itemListElement:Ul}},Kl=[["3DModel AboutPage Answer Article AudioObject Blog BlogPosting Book Clip CollectionPage Comment ContactPage Course CreativeWorkSeason CreativeWorkSeries DataCatalog DataDownload DataFeed Dataset DiscussionForumPosting Episode FAQPage Game HowTo HowToDirection HowToSection HowToStep HowToTip ImageObject LearningResource MediaObject Message MobileApplication Movie MusicPlaylist MusicRecording NewsArticle Photograph PodcastEpisode PodcastSeries ProfilePage QAPage Question Quiz Recipe Review ScholarlyArticle SearchResultsPage SiteNavigationElement SocialMediaPosting SoftwareApplication TVEpisode TVSeries TechArticle VacationRental VideoGame VideoObject WebApplication WebPage WebPageElement WebSite".split(" "),Ql.CreativeWork],["BroadcastEvent BusinessEvent EducationEvent Festival MusicEvent SportsEvent TheaterEvent".split(" "),Ql.Event],[Vl,Ql.Organization],[Gl,Ql.Place],["Car IndividualProduct ProductGroup ProductModel".split(" "),Ql.Product]];function Zl(e,t){return St.call(e,t)?e[t]:void 0}function Jl(e){const t=typeof e;return Rt(e)||"string"===t||"number"===t||"boolean"===t}function Yl(e,t){return t&&function(e){return Tt(e)&&/^(https?:\/\/|\/|\.\.?\/)/i.test(e.trim())}(e)?t(e.trim())||void 0:e}function Xl(e,t){return kt(e)&&e.every(Jl)?e.map(e=>Yl(e,t)).filter(e=>!It(e)):Jl(e)?Yl(e,t):void 0}function ec(e,t){if("string"!=typeof e)return;const i=e.trim(),s=i.indexOf("#"),n=0>s?i:i.slice(s+1);if(!(!n||0>s&&(/^[a-z][a-z\d+.-]*:/i.test(i)||i.includes("/")||i.includes("?"))))try{return t(n)?n:void 0}catch(e){return}}function tc(e){if(St.call(Ql,e))return Ql[e];for(const[t,i]of Kl)if(t.includes(e))return i}function ic(e,t,i){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0})}function sc(e,t,i,s){if(kt(e)){const n=e.map(e=>sc(e,t,i,s)).filter(e=>!It(e));return n.length?n:void 0}return nc(e,t,i,s)||void 0}function nc(e,t,i,s){if(!Et(e)||!function(e){return e.remainingNodes?(e.remainingNodes--,!0):(e.exceeded=!0,!1)}(i))return null;const n=Zl(e,"@type"),r=function(e){const t=new Set,i="string"==typeof e?[e]:kt(e)?e:[],s=[];for(const e of i){if("string"!=typeof e)continue;const i=e.replace(/^https?:\/\/schema\.org\//,"");if(100>=i.length&&Hl.test(i)&&!t.has(i)&&(t.add(i),s.push(i),20===s.length))break}return s}(n),o=r.filter(e=>!!tc(e)&&(!s||!s.length||s.includes(e))),a={};for(const s of zl){const o="@type"===s?r.length?"string"==typeof n?r[0]:r:void 0:"@id"===s?ec(Zl(e,s),t):Xl(Zl(e,s),i.maskUrl);It(o)||ic(a,s,o)}for(const s of o){const n=tc(s);for(const s of Object.keys(n)){const r=Zl(e,s),o=n[s];if(!0===o){const e=Xl(r,i.maskUrl);It(e)||ic(a,s,e)}else{const e=sc(r,t,i,o);It(e)||ic(a,s,e)}}}const l=sc(Zl(e,"@graph"),t,i);return It(l)||ic(a,"@graph",l),Object.keys(a).length?a:null}function rc(e,t,i){if(!Et(e))return null;const s=Zl(e,"@context");if("string"!=typeof s||!/^https?:\/\/schema\.org\/?$/.test(s))return null;const n=nc(e,t,i);return n?ct({"@context":"https://schema.org"},n):null}function oc(e){var t;return"SCRIPT"===e.nodeName&&"application/ld+json"===(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.trim().toLowerCase())}function ac(e,t,i){if("string"==typeof t?e.classList.contains(t):t&&Array.from(e.classList).some(e=>(t.lastIndex=0,t.test(e))))return!0;try{return!!i&&e.matches(i)}catch(e){return!1}}function lc(e,t,i){for(let s=e;s;){if(ac(s,t,i))return!0;const e=s.parentNode;s=s.parentElement||(e&&e.nodeType===e.DOCUMENT_FRAGMENT_NODE?e.host:null)}return!1}function cc(e){return oc(e)?[e]:e.nodeType!==e.ELEMENT_NODE?[]:Array.from(e.querySelectorAll("script")).filter(oc)}function uc(e){return It(e)?void 0:Math.round(e)}function dc(e){return Et(e)?e.network_timing:e}const hc=Gn("[SessionRecording]"),pc=[1,2,3,4,5,6,7,12],_c=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function gc(){var e;return null==h||null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.rrweb}function fc(){var e;return null===(e=gc())||void 0===e?void 0:e.record}function vc(e){try{return JSON.stringify(e)}catch(t){return JSON.stringify(e,No())}}function mc(e){return wa(ba(Sa(vc(e))),!0)}function yc(e){return bc.apply(this,arguments)}function bc(){return(bc=rt(function*(e){const t=yield fn(vc(e),Ya.DEBUG,{rethrow:!0});return wa(new Uint8Array(yield t.arrayBuffer()),!0)})).apply(this,arguments)}let Sc,wc;const kc="undefined"!=typeof globalThis&&"CompressionStream"in globalThis&&"TextEncoder"in globalThis&&"Response"in globalThis&&"function"==typeof Response.prototype.blob;let Cc=!1;function Ec(e){var t;return kt(e)&&0===e.length?(Sc=null!==(t=Sc)&&void 0!==t?t:mc([]),Sc):mc(e)}function xc(e){return Ic.apply(this,arguments)}function Ic(){return(Ic=rt(function*(e){var t;return kt(e)&&0===e.length?Sc||(wc=null!==(t=wc)&&void 0!==t?t:yc([]).then(e=>(Sc=e,e)).catch(e=>{throw Sc=void 0,wc=void 0,e}),wc):yc(e)})).apply(this,arguments)}function Tc(e){return kc&&!Cc&&function(e){return 2===e.type||3===e.type&&(0===e.data.source||8===e.data.source)}(e)}function Mc(e){return{event:e,size:qo(e)}}function Rc(e,t){return ct(ct({},e),{},{data:t,cv:"2024-10"})}function Pc(e,t){return ct(ct({},e),{},{cv:"2024-10",data:ct(ct({},e.data),t)})}function Fc(e){try{if(2===e.type)return Mc(Rc(e,mc(e.data)));if(3===e.type&&0===e.data.source)return Mc(Pc(e,{texts:Ec(e.data.texts),attributes:Ec(e.data.attributes),removes:Ec(e.data.removes),adds:Ec(e.data.adds)}));if(3===e.type&&8===e.data.source)return Mc(Pc(e,{adds:e.data.adds?mc(e.data.adds):void 0,removes:e.data.removes?mc(e.data.removes):void 0}))}catch(e){hc.error("could not compress event - will use uncompressed event",e)}return{event:e,size:Bo(e)}}function Lc(){return Lc=rt(function*(e){try{if(2===e.type)return Mc(Rc(e,yield yc(e.data)));if(3===e.type&&0===e.data.source){const[t,i,s,n]=yield Promise.all([xc(e.data.texts),xc(e.data.attributes),xc(e.data.removes),xc(e.data.adds)]);return Mc(Pc(e,{texts:t,attributes:i,removes:s,adds:n}))}if(3===e.type&&8===e.data.source){const[t,i]=yield Promise.all([e.data.adds?yc(e.data.adds):void 0,e.data.removes?yc(e.data.removes):void 0]);return Mc(Pc(e,{adds:t,removes:i}))}}catch(t){return dn(t)&&(Cc=!0),hc.error("could not compress event asynchronously - trying synchronous compression",t),Fc(e)}return{event:e,size:Bo(e)}}),Lc.apply(this,arguments)}function Ac(e,t){return 5===e.type&&e.data.tag===t}function Oc(e){return Ac(e,"sessionIdle")}function Dc(e){return Ac(e,"$session_ending")}function $c(e){return Ac(e,"$session_starting")}var Nc=class{get sessionId(){return this._sessionId}get _sessionManager(){if(!this._instance.sessionManager)throw new Error("[SessionRecording] must be started with a valid sessionManager.");return this._instance.sessionManager}get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get _isSampled(){return wl(this._instance.get_property(W),this.sessionId)}get _sampleRate(){var e;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.sampleRate;return Ft(t)?t:null}get _minimumDuration(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getMinimumDuration(this.sessionId))&&void 0!==e?e:null}constructor(e,t){this._instance=e,this._endpoint="/s/",this._forceAllowLocalhostNetworkCapture=!1,this._stopRrweb=void 0,this._jsonLdCaptureReady=!1,this._lastActivityTimestamp=Date.now(),this._isActivatingTrigger=!1,this._queuedRRWebEvents=[],this._isIdle="unknown",this._eventsDroppedWhileIdle=0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,this._holdFlushUntilInteraction=!1,this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed=!1,this._suppressNextFreshStartHold=!1,this._rrwebError=!1,this._rrwebStartAttempted=!1,this._maxDepthExceeded=!1,this._snapshotCostErrorLogged=!1,this._hasWarnedClientMaskingOverride=!1,this._hasWarnedExclusiveAttributeMasking=!1,this._maskRegionsFnFailed=!1,this._hasLoggedRecorderCallbackError=!1,this._fullSnapshotTimestamps=[],this._lastFullSnapshotSessionId=void 0,this._fullSnapshotHealAttemptedFor=void 0,this._pendingBufferRestored=!1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueueGeneration=0,this._isStoppingAfterCompression=!1,this._removePageViewCaptureHook=void 0,this._removeEventTriggerCaptureHook=void 0,this._onSessionIdListener=void 0,this._onSessionIdleResetForcedListener=void 0,this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback=(e,t,i)=>{var s,n,r,o;if(!i)return;if(e===this._sessionId&&t===this._windowId)return;const a=!i.noSessionId&&(i.activityTimeout||i.sessionPastMaximumLength),l=this._sessionId,c=this._windowId;var u;if(a&&this._tryAddCustomEvent("$session_ending",{currentSessionId:l,currentWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp,flushed_size:null===(u=this._flushedSizeTracker)||void 0===u?void 0:u.currentTrackedSize(l)}),null===(s=this._instance.persistence)||void 0===s||s.unregister("$debug_first_full_snapshot_timestamp"),this._maxDepthExceeded=!1,null===(n=gc())||void 0===n||null===(r=n.resetMaxDepthState)||void 0===r||r.call(n),this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),this._clearConditionalRecordingPersistence(),!(!1===this._isIdle&&this.isStarted||this._sessionId===e&&this._windowId===t)){const t=this._sessionId!==e&&!1!==this._isIdle;this._isIdle="unknown",this._restartForSessionIdChange(t)}a&&this._tryAddCustomEvent("$session_starting",{previousSessionId:l,previousWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp}),null===(o=this._strategy)||void 0===o||o.makeSamplingDecisions(e)},this._isRestartingForSessionIdChange=!1,this._hasPassedMinimumDuration=()=>{var e;return(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[z])===this._sessionId},this._getBufferDuration=()=>{var e,t;if(0===this._buffer.data.length)return null;const i=null===(e=this._buffer.data[0])||void 0===e?void 0:e.timestamp,s=null===(t=this._buffer.data[this._buffer.data.length-1])||void 0===t?void 0:t.timestamp;return Ft(i)&&Ft(s)?s-i:null},this._isBelowMinimumDuration=()=>{var e,t;const i=this._minimumDuration;if(!Ft(i))return!1;if(null===(e=null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.strictMinimumDuration)||void 0===e||!e){const e=this._sessionDuration;return Ft(e)&&e>=0&&i>e}if(this._hasPassedMinimumDuration())return!1;const s=this._getBufferDuration();return!!Rt(s)||i>s||(null===(n=this._instance.persistence)||void 0===n||n.register({$session_past_minimum_duration:this._sessionId}),!1);var n},this._onBeforeUnload=()=>{"buffering"!==this.status?(this._holdFlushUntilInteraction&&this._heldEpochShipsOnUnload&&this._documentWasEverVisible&&!this._heldBufferOverflowed&&this._setFlushHold(void 0),this._drainCompressionQueueSync(),this._flushBuffer(!0)):this._clearBuffer()},this._onPageHide=()=>{this._onBeforeUnload()},this._onOffline=()=>{this._tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this._tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{(null==s?void 0:s.visibilityState)&&("visible"===s.visibilityState&&(this._documentWasEverVisible=!0),this._tryAddCustomEvent("window "+s.visibilityState,{}))},this._documentWasEverVisible=null==t||t;const{sessionId:i,windowId:n,sessionStartTimestamp:r}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=i,this._windowId=n,this._sessionStartTimestamp=r,this._linkedFlagMatching=new Lo(this._instance),this._urlTriggerMatching=new Fo(this._instance),this._eventTriggerMatching=new Ao(this._instance),this._buffer=this._clearBuffer(),this._pendingBufferStorageKey="ph_replay_pending_buffer_"+JSON.stringify([this._instance.config.persistence_name||this._instance.config.token,this._instance.config.token]),this._sessionManager.sessionTimeoutMs>this._sessionIdleThresholdMilliseconds||hc.warn(`session_idle_threshold_ms (${this._sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this._sessionManager.sessionTimeoutMs}). Session will never be detected as idle`),this._flushedSizeTracker=new Xa(this._instance)}setDocumentWasEverVisible(e){e&&(this._documentWasEverVisible=!0)}get _masking(){var e,t,i,s,n,r,o,a,l;const c=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking,u={maskAllInputs:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.maskAllInputs,maskTextSelector:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.maskTextSelector,blockSelector:null===(s=this._instance.config.session_recording)||void 0===s?void 0:s.blockSelector,maskAllElementAttributes:null===(n=this._instance.config.session_recording)||void 0===n?void 0:n.maskAllElementAttributes},d=null!==(r=null==u?void 0:u.maskAllInputs)&&void 0!==r?r:null==c?void 0:c.maskAllInputs,h=null!==(o=null==u?void 0:u.maskTextSelector)&&void 0!==o?o:null==c?void 0:c.maskTextSelector,p=null!==(a=null==u?void 0:u.blockSelector)&&void 0!==a?a:null==c?void 0:c.blockSelector,_=null!==(l=null==u?void 0:u.maskAllElementAttributes)&&void 0!==l?l:null==c?void 0:c.maskAllElementAttributes;return It(d)&&It(h)&&It(p)&&It(_)?void 0:{maskAllInputs:null==d||d,maskTextSelector:h,blockSelector:p,maskAllElementAttributes:_}}_warnIfClientMaskingShadowsServer(){var e;if(this._hasWarnedClientMaskingOverride)return;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking;if(Pt(t))return;const i=this._instance.config.session_recording,s=["maskAllInputs","maskTextSelector","blockSelector","maskAllElementAttributes"].filter(e=>{const s=null==i?void 0:i[e],n=t[e];return!It(s)&&s!==n});0!==s.length&&(this._hasWarnedClientMaskingOverride=!0,hc.warn('Session recording masking is configured both in `posthog.init` and in your project settings, and they differ. The `session_recording` options in `posthog.init` take precedence, so the project ("Privacy and masking") setting is ignored for: '+s.join(", ")+". Remove these masking options from `posthog.init` to use the project setting instead. See https://posthog.com/docs/session-replay/privacy",{client:{maskAllInputs:null==i?void 0:i.maskAllInputs,maskTextSelector:null==i?void 0:i.maskTextSelector,blockSelector:null==i?void 0:i.blockSelector,maskAllElementAttributes:null==i?void 0:i.maskAllElementAttributes},project:t}))}get _canvasResolutionScale(){var e;return Qt(null===(e=this._instance.config.session_recording.canvasCapture)||void 0===e?void 0:e.resolutionScale,.1,1,Gn("canvas recording resolution scale"),1)}get _canvasRecording(){var e,t,i,s,n,r,o;const a=this._instance.config.session_recording.captureCanvas,l=null===(e=this._remoteConfig)||void 0===e?void 0:e.canvasRecording,c=null!==(t=null!==(i=null==a?void 0:a.recordCanvas)&&void 0!==i?i:null==l?void 0:l.enabled)&&void 0!==t&&t,u=null!==(s=null!==(n=null==a?void 0:a.canvasFps)&&void 0!==n?n:null==l?void 0:l.fps)&&void 0!==s?s:4;let d=null!==(r=null!==(o=null==a?void 0:a.canvasQuality)&&void 0!==o?o:null==l?void 0:l.quality)&&void 0!==r?r:.4;if("string"==typeof d){const e=parseFloat(d);d=isNaN(e)?.4:e}return{enabled:c,fps:Qt(u,0,12,Gn("canvas recording fps"),4),quality:Qt(d,0,1,Gn("canvas recording quality"),.4)}}get _isConsoleLogCaptureEnabled(){var e;const t=!!(null===(e=this._remoteConfig)||void 0===e?void 0:e.consoleLogRecordingEnabled),i=this._instance.config.enable_recording_console_log;return null!=i?i:t}get _networkPayloadCapture(){var e,t,i;const s=null===(e=this._remoteConfig)||void 0===e?void 0:e.networkPayloadCapture,n={recordHeaders:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.recordHeaders,recordBody:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.recordBody},r=(null==n?void 0:n.recordHeaders)||(null==s?void 0:s.recordHeaders),o=(null==n?void 0:n.recordBody)||(null==s?void 0:s.recordBody),a=dc(this._instance.config.capture_performance),l=dc(null==s?void 0:s.capturePerformance),c=!!(At(a)?a:l);return r||o||c?{recordHeaders:r,recordBody:o,recordPerformance:c}:void 0}_gatherRRWebPlugins(){var e,t;const i=[],s=null===(e=h.__PosthogExtensions__)||void 0===e||null===(e=e.rrwebPlugins)||void 0===e?void 0:e.getRecordConsolePlugin;s&&this._isConsoleLogCaptureEnabled&&i.push(s());const r=null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.rrwebPlugins)||void 0===t?void 0:t.getRecordNetworkPlugin;if(this._networkPayloadCapture&&Ct(r))if(!rr.includes(n.hostname)||this._forceAllowLocalhostNetworkCapture){const e=Ct(this._instance.requestRouter.isIngestionEndpoint)?this._instance.requestRouter.isIngestionEndpoint.bind(this._instance.requestRouter):void 0;i.push(r(((e,t,i)=>{const s={payloadSizeLimitBytes:no.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...no.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...no.payloadHostDenyList]},n=!1!==e.session_recording.recordHeaders&&t.recordHeaders,r=!1!==e.session_recording.recordBody&&t.recordBody,o=!1!==e.capture_performance&&t.recordPerformance,a=(e=>{const t=so(e);return e=>((null==e?void 0:e.requestBody)&&(e.requestBody=uo(e.requestBody,e.requestHeaders,t,"Request")),(null==e?void 0:e.responseBody)&&(e.responseBody=uo(e.responseBody,e.responseHeaders,t,"Response")),e)})(s),l=t=>{return a(((e,t,i)=>{var s;if(null==i?void 0:i(e.name))return;const n=ar(e.name);let r=0===t.indexOf("http")?null===(s=ar(t))||void 0===s?void 0:s.pathname:t;"/"===r&&(r="");const o=null==n?void 0:n.pathname.replace(r||"","");return n&&o&&co.some(e=>0===o.indexOf(e))?void 0:e})((lo((s=t).requestHeaders),lo(s.responseHeaders),s),e.api_host,i));var s},c=Ct(e.session_recording.maskNetworkRequestFn);return c&&Ct(e.session_recording.maskCapturedNetworkRequestFn)&&Vn.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),c&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{const i=e.session_recording.maskNetworkRequestFn({url:t.name});return!i&&t.isInitial?i:ct(ct({},t),{},{name:null==i?void 0:i.url})}),s.maskRequestFn=Ct(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s;const n=l(t);if(!n)return;const r=n.isInitial?{name:"",entryType:n.entryType,startTime:n.startTime,duration:n.duration,endTime:n.endTime,timeOrigin:n.timeOrigin,timestamp:n.timestamp,isInitial:!0}:void 0,o=null===(i=(s=e.session_recording).maskCapturedNetworkRequestFn)||void 0===i?void 0:i.call(s,n);return Pt(o)&&r?(po.add(r),r):null!=o?o:void 0}:e=>function(e){if(!It(e))return e.requestBody=ho(e.requestBody,"Request"),e.responseBody=ho(e.responseBody,"Response"),e}(l(e)),ct(ct(ct({},no),s),{},{recordHeaders:n,recordBody:r,recordPerformance:o,recordInitialRequests:o,streamNetworkBody:!0===e.session_recording.streamNetworkBody})})(this._instance.config,this._networkPayloadCapture,e)))}else hc.info("NetworkCapture not started because we are on localhost.");return i}_stripUrlHash(e){return this._instance.config.disable_capture_url_hashes?ls(e):e}_maskReplayUrl(e,t=!1){const i=t?ls(e):this._stripUrlHash(e),s=this._instance.config.mask_personal_data_properties?[...El,...this._instance.config.custom_personal_data_properties||[]]:[];return this._maskUrl(ur(i,s,Il))}_maskUrl(e){const t=this._instance.config.session_recording;if(t.maskCapturedNetworkRequestFn){var i;const s=t.maskCapturedNetworkRequestFn({name:e});return null!==(i=null==s?void 0:s.name)&&void 0!==i?i:null==s?void 0:s.url}if(t.maskNetworkRequestFn){const i=t.maskNetworkRequestFn({url:e});return null==i?void 0:i.url}return e}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return 10>this._queuedRRWebEvents.length?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt+1,rrwebMethod:e.rrwebMethod}):hc.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(_c(()=>fc().addCustomEvent(e,t)))}_canCaptureJsonLd(){var e;return this._jsonLdCaptureReady&&!0===(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)&&!this._urlTriggerMatching.urlBlocked&&!0!==this._isIdle}_tryAddJsonLdEvent(e){if(!this._canCaptureJsonLd())return!1;try{const t=fc();return!!t&&(t.addCustomEvent("$json_ld",e),this._canCaptureJsonLd())}catch(e){return!1}}_scheduleJsonLdScan(e=!1){Promise.resolve().then(()=>{var t;return null===(t=this._jsonLdCapture)||void 0===t?void 0:t.scan(e)})}_pageViewFallBack(){try{if(this._instance.config.capture_pageview||!e)return;const t=new URL(e.location.href),i=this._maskReplayUrl(t.origin+t.pathname+t.search);this._lastHref!==i&&(this._lastHref=i,this._tryAddCustomEvent("$url_changed",{href:i}))}catch(e){}}_processQueuedEvents(){if(this._queuedRRWebEvents.length){const e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach(e=>{Date.now()-e.enqueuedAt>2e3||this._tryRRWebMethod(e)})}}_tryTakeFullSnapshot(){return this._tryRRWebMethod(_c(()=>fc().takeFullSnapshot()))}get _fullSnapshotIntervalMillis(){var e,t,i;if((null===(e=this._strategy)||void 0===e?void 0:e.hasPendingTriggers(this.sessionId))&&!["sampled","active"].includes(this.status)){var s;const e=null===(s=this._instance.config.session_recording)||void 0===s?void 0:s.trigger_pending_buffer_interval_millis;return Ft(e)&&Number.isFinite(e)&&e>=1e3&&36e5>=e?e:6e4}return null!==(t=null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.full_snapshot_interval_millis)&&void 0!==t?t:3e5}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0===this._isIdle)return;const e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},e))}_onTriggerActivated(e){"event"===e&&this._releaseHoldAndFlush(),!this._urlTriggerMatching.urlBlocked&&["sampled","active"].includes(this.status)&&this._scheduleFullSnapshot()}_pauseRecording(){var e;this._urlTriggerMatching.urlBlocked||(this._urlTriggerMatching.urlBlocked=!0,null===(e=this._jsonLdCapture)||void 0===e||e.scan(),clearInterval(this._fullSnapshotTimer),hc.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){var e;this._urlTriggerMatching.urlBlocked&&(null===(e=this._jsonLdCapture)||void 0===e||e.scan(),this._urlTriggerMatching.urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),hc.info("recording resumed"))}_activateTrigger(e,t){var i;if("event"===e&&this._releaseHoldAndFlush(),!this._isActivatingTrigger&&(null===(i=this._strategy)||void 0===i?void 0:i.hasPendingTriggers(this.sessionId))){this._isActivatingTrigger=!0;try{var s,n;const i="url"===e?j:V;null===(s=this._instance.persistence)||void 0===s||s.register({[i]:this.sessionId}),null===(n=this._strategy)||void 0===n||n.updateActiveTriggers(this.sessionId),this._onTriggerActivated(),this._flushBuffer(),this._reportStarted(e+"_trigger_matched",{["url"===e?"matchedUrl":"matchedEvent"]:t})}finally{this._isActivatingTrigger=!1}}}get isStarted(){return!!this._stopRrweb}get _remoteConfig(){const e=this._instance.get_property(A);if(!e)return;let t;try{t=Et(e)?e:JSON.parse(e)}catch(e){return void hc.warn("persisted remote config for session recording is invalid and will be ignored",e)}if(!this.isStarted&&!this._isRestartingForSessionIdChange){var i;const s=null!==(i=t.cache_timestamp)&&void 0!==i?i:Date.now();if(Date.now()-s>36e5)return void hc.info("persisted remote config for session recording is stale and will be ignored",{cacheTimestamp:s,persistedConfig:e})}return t}_checkOverride(e,t,i){this._instance.get_property(e)&&(t(),i())}start(t){var i,n;const r=this._remoteConfig;if(!r)return void hc.info("remote config must be stored in persistence before recording can start");if(!this.isStarted){const e=!1!==this._isIdle&&!this._suppressNextFreshStartHold;this._setFlushHold(e?"no_interaction_since_recording_started":void 0),this._suppressNextFreshStartHold=!1,this._heldEpochShipsOnUnload=e,this._heldBufferOverflowed=!1}this._isStoppingAfterCompression&&(this._invalidateCompressionQueue(),this._clearBuffer());const{sessionId:o,windowId:a,sessionStartTimestamp:l}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=o,this._windowId=a,this._sessionStartTimestamp=l,this._restorePendingBuffer(),null===(i=this._instance.persistence)||void 0===i||i.unregister("$debug_first_full_snapshot_timestamp"),(null==r?void 0:r.endpoint)&&(this._endpoint=null==r?void 0:r.endpoint),this._strategy=2===(null==r?void 0:r.version)&&(null==r?void 0:r.triggerGroups)&&r.triggerGroups.length>0?new Cl(this._instance,this._urlTriggerMatching,this._reportStarted.bind(this),this._tryAddCustomEvent.bind(this),this._onTriggerActivated.bind(this)):new kl(this._instance,this._urlTriggerMatching,this._eventTriggerMatching,this._linkedFlagMatching,this._reportStarted.bind(this),this._tryTakeFullSnapshot.bind(this),this._onTriggerActivated.bind(this)),this._strategy.onRemoteConfig(r),null===(n=this._removeEventTriggerCaptureHook)||void 0===n||n.call(this),this._removeEventTriggerCaptureHook=this._strategy.setupEventTriggerListeners(this._instance.on.bind(this._instance,"eventCaptured"),this.sessionId,(e,t)=>this._activateTrigger(e,t)),this._checkOverride(N,()=>{this.overrideSampling()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(N)}),this._checkOverride(B,()=>{this.overrideLinkedFlag()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(B)}),this._checkOverride(H,()=>{this.overrideTrigger("event")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(H)}),this._checkOverride(q,()=>{this.overrideTrigger("url")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(q)}),this._strategy.makeSamplingDecisions(this.sessionId),this._startRecorder(),this._rrwebError||(sr(e,"beforeunload",this._onBeforeUnload),sr(e,"pagehide",this._onPageHide),sr(e,"offline",this._onOffline),sr(e,"online",this._onOnline),sr(s,"visibilitychange",this._onVisibilityChange),!this._onSessionIdListener&&Ct(this._sessionManager.onSessionId)&&(this._onSessionIdListener=this._sessionManager.onSessionId(this._onSessionIdCallback)),!this._onSessionIdleResetForcedListener&&Ct(this._sessionManager.on)?this._onSessionIdleResetForcedListener=this._sessionManager.on("forcedIdleReset",()=>{this._clearConditionalRecordingPersistence(),this._isIdle="unknown",this.stop(),this._forceIdleSessionIdListener=this._sessionManager.onSessionId((e,t,i)=>{var s;null===(s=this._forceIdleSessionIdListener)||void 0===s||s.call(this),this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback(e,t,i)})}):Ct(this._sessionManager.on)||hc.warn("bundled core has no SessionIdManager.on (requires posthog-js >= 1.268.6); recording will start but skip forced-idle-reset handling"),Pt(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this._instance.on("eventCaptured",e=>{try{if("$pageview"===e.event){const t=(null==e?void 0:e.properties.$current_url)?this._maskReplayUrl(e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){hc.error("Could not add $pageview to rrweb session",e)}})),"active"===this.status&&this._reportStarted(t||"recording_initialized"))}_teardown(){var t,i,n,r,o,a;null==e||e.removeEventListener("beforeunload",this._onBeforeUnload),null==e||e.removeEventListener("pagehide",this._onPageHide),null==e||e.removeEventListener("offline",this._onOffline),null==e||e.removeEventListener("online",this._onOnline),null==s||s.removeEventListener("visibilitychange",this._onVisibilityChange),clearInterval(this._fullSnapshotTimer),this._clearFlushBufferTimer(),null===(t=this._removePageViewCaptureHook)||void 0===t||t.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(n=this._onSessionIdListener)||void 0===n||n.call(this),this._onSessionIdListener=void 0,null===(r=this._onSessionIdleResetForcedListener)||void 0===r||r.call(this),this._onSessionIdleResetForcedListener=void 0,null===(o=this._forceIdleSessionIdListener)||void 0===o||o.call(this),this._forceIdleSessionIdListener=void 0,null===(a=this._strategy)||void 0===a||a.stop(),this._stopRecordingProducers(),this._invalidateCompressionQueue()}_invalidateCompressionQueue(){this._compressionQueueGeneration+=1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueue=void 0,this._isStoppingAfterCompression=!1}_stopRecordingProducers(){var e,t;null===(e=this._mutationThrottler)||void 0===e||e.stop(),this._queuedRRWebEvents=[],null===(t=this._jsonLdCapture)||void 0===t||t.stop(),this._jsonLdCapture=void 0,this._jsonLdCaptureReady=!1;try{var i;null===(i=this._stopRrweb)||void 0===i||i.call(this)}catch(e){hc.warn("could not stop rrweb",e)}this._stopRrweb=void 0}_stopAfterCompressionQueueDrains(){if(!this._compressionQueue||0===this._queuedCompressionEvents)return!1;if(this._isStoppingAfterCompression)return!0;this._isStoppingAfterCompression=!0,this._flushHoldReason=void 0;const e=this._compressionQueueGeneration;return this._clearFlushBufferTimer(),this._stopRecordingProducers(),this._compressionQueue.catch(()=>{}).then(()=>{e===this._compressionQueueGeneration&&(this._isStoppingAfterCompression=!1,this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),hc.info("stopped"))}).catch(()=>{this._isStoppingAfterCompression=!1,this._releaseHoldAfterStop(),this._teardown(),hc.info("stopped")}),!0}stop(){if(this._stopRecordingProducers(),this._isRestartingForSessionIdChange)this._drainCompressionQueueSync();else if(this._stopAfterCompressionQueueDrains())return;this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),hc.info("stopped")}_releaseHoldAfterStop(){this._setFlushHold(void 0,{preserveLogDedup:this._isRestartingForSessionIdChange}),this._heldEpochShipsOnUnload=!1}flushBeforeIdentityReset(){(this.isStarted||this._isStoppingAfterCompression)&&(this._drainCompressionQueueSync(),this._flushBuffer())}_restartForSessionIdChange(e){this._isRestartingForSessionIdChange=!0,this._lastActivityTimestamp=Date.now();try{var t,i;this.stop(),this._slowestFullSnapshot=void 0,this._lastSeenSnapshotCost=void 0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,null===(t=gc())||void 0===t||null===(i=t.resetSnapshotCostState)||void 0===i||i.call(t),this.start("session_id_changed")}finally{this._isRestartingForSessionIdChange=!1}this._setFlushHold(e?"no_interaction_since_session_rotated":void 0),this._heldEpochShipsOnUnload=!1}_setFlushHold(e,{preserveLogDedup:t=!1}={}){if(this._holdFlushUntilInteraction=!It(e),this._flushHoldReason=e,It(e))return void(t||(this._lastLoggedFlushHold=void 0));if(this._isRestartingForSessionIdChange)return;const i=`${this.sessionId}:${e}`;i!==this._lastLoggedFlushHold&&(this._lastLoggedFlushHold=i,hc.info(`holding buffer: ${e}. nothing is uploaded until the user interacts with the page`))}_releaseHoldAndFlush(){this.isStarted||(this._suppressNextFreshStartHold=!0),this._holdFlushUntilInteraction&&(this._setFlushHold(void 0),this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed&&(this._heldBufferOverflowed=!1,this._tryTakeFullSnapshot()),this._scheduleFlushBuffer())}discard({discardProducerEvents:e=!1}={}){this._holdFlushUntilInteraction=!0,e&&(this._clearBuffer(),this._stopRecordingProducers()),this._clearBuffer(),this._teardown(),this._clearBuffer(),this._releaseHoldAfterStop(),hc.info("discarded")}_captureProcessedEvent(e,t,i,s,n){const r={$snapshot_bytes:i,$snapshot_data:t,$session_id:s,$window_id:n};"disabled"!==this.status?(this._ensureFullSnapshotForSession(e,s),this._captureSnapshotBuffered(r)):this._clearBuffer()}_safeTrackFullSnapshotCost(){try{this._trackFullSnapshotCost()}catch(e){this._snapshotCostErrorLogged||(this._snapshotCostErrorLogged=!0,hc.error("could not track full snapshot cost",e))}}_trackFullSnapshotCost(){var e,t;const i=null===(e=gc())||void 0===e||null===(t=e.getLastSnapshotCost)||void 0===t?void 0:t.call(e);i&&i!==this._lastSeenSnapshotCost&&(this._lastSeenSnapshotCost=i,this._slowestFullSnapshot&&this._slowestFullSnapshot.durationMs>=i.durationMs||(this._slowestFullSnapshot=i),500>i.durationMs||hc.warn("full snapshot was slow, the page may have been unresponsive while it ran",{durationMs:Math.round(i.durationMs),stylesheetMs:Math.round(i.stylesheetMs),nodeCount:i.nodeCount,cssRuleCount:i.cssRuleCount,nonDeferrableCssRuleCount:i.nonDeferrableCssRuleCount,deferredStylesheetCount:i.deferredStylesheetCount}))}_ensureFullSnapshotForSession(e,t){2!==e.type?3===e.type&&(It(this._lastFullSnapshotSessionId)||this._lastFullSnapshotSessionId===t||this._fullSnapshotHealAttemptedFor===t||(this._fullSnapshotHealAttemptedFor=t,hc.info("incremental snapshot for a session with no full snapshot - requesting one",{sessionId:t}),this._tryTakeFullSnapshot())):this._lastFullSnapshotSessionId=t}_finishQueuedCompressionEvent(e){e.counted&&e.generation===this._compressionQueueGeneration&&(this._queuedCompressionEvents=Math.max(0,this._queuedCompressionEvents-1)),e.counted=!1,this._pendingCompressionEvents=this._pendingCompressionEvents.filter(t=>t!==e)}_captureQueuedCompressionEvent(e,t,i){e.processed||e.generation!==this._compressionQueueGeneration||(e.processed=!0,this._captureProcessedEvent(e.event,t,i,e.targetSessionId,e.targetWindowId))}_processQueuedCompressionEventSync(e){try{let t=e.event,i=Bo(e.event);if(e.compressionEnabled)try{({event:t,size:i}=Fc(e.event))}catch(e){hc.error("could not process queued compression event - will use uncompressed event",e)}try{this._captureQueuedCompressionEvent(e,t,i)}catch(e){hc.error("could not capture queued compression event",e)}}finally{this._finishQueuedCompressionEvent(e)}}_drainCompressionQueueSync(){[...this._pendingCompressionEvents].forEach(e=>{this._processQueuedCompressionEventSync(e)})}_enqueueCompression(e,t,i,s){var n=this;const r={event:e,compressionEnabled:t,targetSessionId:i,targetWindowId:s,generation:this._compressionQueueGeneration,processed:!1,counted:!0};this._pendingCompressionEvents.push(r),this._queuedCompressionEvents+=1;const o=(a=rt(function*(){try{if(r.processed)return;let i,s;try{const n=t?Tc(e)?yield function(e){return Lc.apply(this,arguments)}(e):Fc(e):{event:e,size:Bo(e)};i=n.event,s=n.size}catch(t){hc.error("could not process queued compression event - will use uncompressed event",t),i=e,s=Bo(e)}n._captureQueuedCompressionEvent(r,i,s)}finally{n._finishQueuedCompressionEvent(r)}}),function(){return a.apply(this,arguments)});var a;this._compressionQueue=this._compressionQueue?this._compressionQueue.catch(()=>{}).then(o):o()}onRRwebEmit(t){var i,s,n,r,o,a,l,c,u,d,h,p,_;if(!this._instance.sessionManager)return;if(this._processQueuedEvents(),!t||!Et(t))return;if(4===t.type){const e=this._maskReplayUrl(t.data.href);if(this._lastHref=e,!e)return;t.data.href=e}else this._pageViewFallBack();if(null===(i=this._strategy)||void 0===i||i.checkUrlTriggers(this.sessionId,()=>this._pauseRecording(),()=>this._resumeRecording(),(e,t)=>this._activateTrigger(e,t)),this._urlTriggerMatching.urlBlocked&&!function(e){return 5===e.type&&"recording paused"===e.data.tag}(t))return;2===t.type&&((null===(d=gc())||void 0===d||null===(h=d.wasMaxDepthReached)||void 0===h?void 0:h.call(d))&&(this._maxDepthExceeded=!0),this._safeTrackFullSnapshotCost(),Promise.resolve().then(()=>this._safeTrackFullSnapshotCost()),this._scheduleFullSnapshot(),null===(p=this._mutationThrottler)||void 0===p||p.reset(),null===(_=this._instance.persistence)||void 0===_||_.register_once({$debug_first_full_snapshot_timestamp:t.timestamp},void 0));const g=2===t.type&&(null===(s=this._strategy)||void 0===s?void 0:s.hasPendingTriggers(this.sessionId));g&&this._clearBufferBeforeMostRecentMeta();const f=this._mutationThrottler?this._mutationThrottler.throttleMutations(t):t;if(!f)return void(!0===this._isIdle&&this._eventsDroppedWhileIdle++);const v=function(e){const t=e;if(t&&Et(t)&&6===t.type&&Et(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));const i=[];for(let e=0;t.data.payload.payload.length>e;e++)i.push(t.data.payload.payload[e]&&t.data.payload.payload[e].length>2e3?t.data.payload.payload[e].slice(0,2e3)+"...[truncated]":t.data.payload.payload[e]);return t.data.payload.payload=i,e}return e}(f),m=function(e){return Dc(e)?e.data.payload:null}(v),y=function(e){return $c(e)?e.data.payload:null}(v),b=function(e){return Oc(e)?e.data.payload:null}(v);m||y?(null==m?void 0:m.lastActivityTimestamp)&&(v.timestamp=m.lastActivityTimestamp):(null==b?void 0:b.sessionId)||this._updateWindowAndSessionIds(v),2===t.type&&(this._fullSnapshotTimestamps.push([this._sessionId,t.timestamp]),this._fullSnapshotTimestamps.length>6&&(this._fullSnapshotTimestamps=this._fullSnapshotTimestamps.slice(-6)));const S=null!==(n=null!==(r=null!==(o=null==m?void 0:m.currentSessionId)&&void 0!==o?o:null==y?void 0:y.nextSessionId)&&void 0!==r?r:null==b?void 0:b.sessionId)&&void 0!==n?n:this._sessionId,w=null!==(a=null!==(l=null!==(c=null==m?void 0:m.currentWindowId)&&void 0!==c?c:null==y?void 0:y.nextWindowId)&&void 0!==l?l:null==b?void 0:b.windowId)&&void 0!==a?a:this._windowId;if(!0===this._isIdle&&!function(e){return Oc(e)||Dc(e)||$c(e)}(v))return void(function(e){return 2===e.type||4===e.type||3===e.type&&9!==e.data.source}(v)&&this._eventsDroppedWhileIdle++);2===v.type&&(this._eventsDroppedWhileIdle=0),b&&(v.timestamp=b.lastActivityTimestamp+b.threshold);const k=this._jsonLdCaptureReady;this._jsonLdCaptureReady=!0,g?this._scheduleJsonLdScan(!0):k||this._scheduleJsonLdScan();const C=null===(u=this._instance.config.session_recording.compress_events)||void 0===u||u;if(5===v.type&&"$json_ld"===v.data.tag){let t;try{t=e?this._maskReplayUrl(e.location.href):void 0}catch(e){}v.data.href=t}if(this._queuedCompressionEvents>0||C&&Tc(v))return void this._enqueueCompression(v,C,S,w);const{event:E,size:x}=C?Fc(v):{event:v,size:Bo(v)};this._captureProcessedEvent(v,E,x,S,w)}get status(){return this._strategy?this._strategy.getStatus({instance:this._instance,sessionId:this.sessionId,isSampled:this._isSampled,rrwebError:this._rrwebError,urlTriggerMatching:this._urlTriggerMatching,eventTriggerMatching:this._eventTriggerMatching,linkedFlagMatching:this._linkedFlagMatching,remoteConfig:this._remoteConfig}):_o}log(e,t="log"){var i;null===(i=this._instance.sessionRecording)||void 0===i||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}overrideLinkedFlag(){this._linkedFlagMatching.linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this._instance.persistence)||void 0===e||e.register({$session_is_sampled:this.sessionId,$replay_sample_rate:null}),this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e),this._releaseHoldAndFlush()}_currentMaskedHostname(){try{var t;const i=null==e||null===(t=e.location)||void 0===t?void 0:t.href;if(!i)return;const s=this._maskReplayUrl(i);if(!s)return;return new URL(s).hostname||void 0}catch(e){return}}_clearFlushBufferTimer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0)}_scheduleFlushBuffer(){this._flushBufferTimer||(this._flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_wouldOpenRecordingWithMarkersOnly(){return this._lastFullSnapshotSessionId!==this._buffer.sessionId&&0!==this._buffer.data.length&&this._buffer.data.every(e=>5===(null==e?void 0:e.type)&&!Dc(e)&&!$c(e))}_describePendingTriggerConditions(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getPendingTriggerConditions(this.sessionId))&&void 0!==e?e:[]}_maybeLogBufferingReason(e){if("buffering"!==e)return It(this._lastLoggedBufferingReason)||this._instance.register_for_session({[He]:[]}),void(this._lastLoggedBufferingReason=void 0);const t=this._describePendingTriggerConditions();if(0===t.length)return It(this._lastLoggedBufferingReason)||this._instance.register_for_session({[He]:[]}),void(this._lastLoggedBufferingReason=void 0);const i=t.join(", "),s=`${this.sessionId}:${i}`;s!==this._lastLoggedBufferingReason&&(this._lastLoggedBufferingReason=s,this._instance.register_for_session({[He]:t}),hc.info(`buffering: ${i}`))}_canParkPendingBuffer(){var e;return"memory"!==this._instance.config.persistence&&!0!==(null===(e=this._instance.persistence)||void 0===e?void 0:e._disabled)&&Ja._is_supported()}_parkBufferForNextPage(){0!==this._buffer.data.length&&this._buffer.size!==this._lastParkedBufferSize&&943718.4>=this._buffer.size&&this._canParkPendingBuffer()&&(this._lastParkedBufferSize=this._buffer.size,Ja._set(this._pendingBufferStorageKey,this._buffer))}_restorePendingBuffer(){if(this._pendingBufferRestored||!this._canParkPendingBuffer())return;this._pendingBufferRestored=!0;const e=Ja._parse(this._pendingBufferStorageKey);Ja._remove(this._pendingBufferStorageKey),Et(e)&&kt(e.data)&&0!==e.data.length&&kt(e.sizes)&&e.sizes.length===e.data.length&&Ft(e.size)&&e.sessionId===this._sessionId&&e.windowId===this._windowId&&(this._buffer.data.length>0||(this._buffer=e))}_flushBuffer(e=!1){var t;if(this._clearFlushBufferTimer(),this._holdFlushUntilInteraction)return this._buffer;if(this._wouldOpenRecordingWithMarkersOnly())return this._buffer.size>943718.4?this._clearBuffer():(e&&this._parkBufferForNextPage(),this._buffer);const i=this._buffer;null===(t=this._strategy)||void 0===t||t.ensureSamplingDecision(this.sessionId);const s=this._isBelowMinimumDuration(),n=this.status;if(this._maybeLogBufferingReason(n),"buffering"===n||"paused"===n||"disabled"===n||s)return!e||"active"!==n&&"sampled"!==n||this._parkBufferForNextPage(),this._scheduleFlushBuffer(),this._buffer;if(this._buffer!==i)return this._buffer;if(i.data.length>0){var r;const e=this._currentMaskedHostname();Ho(i).forEach(t=>{try{var i;null===(i=this._flushedSizeTracker)||void 0===i||i.trackSize(t.sessionId,t.size),this._captureSnapshot({$snapshot_bytes:t.size,$snapshot_data:t.data,$session_id:t.sessionId,$window_id:t.windowId,$lib:Ya.LIB_NAME,$lib_version:Ya.LIB_VERSION,$snapshot_host:e})}catch(e){hc.warn("could not capture snapshot chunk - skipping it",e)}}),It(this._lastParkedBufferSize)||(Ja._remove(this._pendingBufferStorageKey),this._lastParkedBufferSize=void 0),null===(r=this._strategy)||void 0===r||r.onFlushComplete()}return this._clearBuffer()}_captureSnapshotBuffered(e){var t;const i=2+((null===(t=this._buffer)||void 0===t?void 0:t.data.length)||0),s=e.$session_id,n=this._buffer.sessionId!==s;if(n||!0!==this._isIdle&&!this._holdFlushUntilInteraction&&this._buffer.size+e.$snapshot_bytes+i>943718.4){const t=this._sessionId;if(this._buffer=this._flushBuffer(),this._sessionId!==t)return;n&&this._buffer.data.length>0&&(this._buffer=this._clearBuffer()),this._buffer.sessionId=s,this._buffer.windowId=e.$window_id}this._holdFlushUntilInteraction&&(this._heldBufferOverflowed||this._buffer.size+e.$snapshot_bytes+i>943718.4)?this._heldBufferOverflowed||(this._heldBufferOverflowed=!0,this._buffer=this._clearBuffer()):(this._buffer.size+=e.$snapshot_bytes,this._buffer.data.push(e.$snapshot_data),this._buffer.sizes.push(e.$snapshot_bytes),!0===this._isIdle||this._holdFlushUntilInteraction||this._scheduleFlushBuffer())}_captureSnapshot(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}get _sessionDuration(){var e,t;const i=null===(e=this._buffer)||void 0===e?void 0:e.data[(null===(t=this._buffer)||void 0===t?void 0:t.data.length)-1];return i?i.timestamp-this._sessionStartTimestamp:null}_clearBufferBeforeMostRecentMeta(){if(!this._buffer||0===this._buffer.data.length)return this._clearBuffer();let e=-1;for(let t=this._buffer.data.length-1;t>=0;t--)if(4===this._buffer.data[t].type){e=t;break}return 0>e?this._clearBuffer():(this._buffer.data=this._buffer.data.slice(e),this._buffer.sizes=this._buffer.sizes.slice(e),this._buffer.size=this._buffer.sizes.reduce((e,t)=>e+t,0),this._buffer)}_clearBuffer(){return this._buffer={size:0,data:[],sizes:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_reportStarted(e,t){this._instance.register_for_session({[Ge]:e}),hc.info(e.replace("_"," "),t),"session_id_changed"!==e&&this._tryAddCustomEvent("$recording_started",ct({reason:e},t))}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==pc.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){const t=this._isInteractiveEvent(e);t||!0===this._isIdle||e.timestamp-this._lastActivityTimestamp>this._sessionIdleThresholdMilliseconds&&(this._isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this._sessionIdleThresholdMilliseconds,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size,sessionId:this._sessionId,windowId:this._windowId}),this._flushBuffer());const{windowId:i,sessionId:s}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp);let n=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){const t="unknown"===this._isIdle;this._isIdle=!1,t||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),n=!0)}const r=this._sessionId!==s,o=this._windowId!==i;if(this._windowId=i,this._sessionId=s,r||o){const e=r&&!1!==this._isIdle;e&&(this._isIdle="unknown"),this._restartForSessionIdChange(e)}else if(t&&this._releaseHoldAndFlush(),n){var a;const e=["sampled","active"].includes(this.status)||(null===(a=this._strategy)||void 0===a?void 0:a.hasPendingTriggers(this.sessionId));this._eventsDroppedWhileIdle>0&&e&&this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot()}}_clearConditionalRecordingPersistence(){var e;null===(e=this._strategy)||void 0===e||e.clearConditionalRecordingPersistence()}get sdkDebugProperties(){var e,t,i,s,n,r,o,a,l,c,u,d;const h=null===(e=gc())||void 0===e||null===(t=e.getDeferredStylesheetStats)||void 0===t?void 0:t.call(e);return{$recording_status:this.status,$sdk_debug_replay_flush_hold_reason:this._flushHoldReason,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_current_session_duration:this._sessionDuration,$sdk_debug_session_start:this._sessionStartTimestamp,$sdk_debug_replay_flushed_size:null===(i=this._flushedSizeTracker)||void 0===i?void 0:i.currentTrackedSize(this.sessionId),$sdk_debug_replay_full_snapshots:this._fullSnapshotTimestamps,$snapshot_max_depth_exceeded:this._maxDepthExceeded,$sdk_debug_replay_slowest_full_snapshot_ms:uc(null===(s=this._slowestFullSnapshot)||void 0===s?void 0:s.durationMs),$sdk_debug_replay_slowest_full_snapshot_stylesheet_ms:uc(null===(n=this._slowestFullSnapshot)||void 0===n?void 0:n.stylesheetMs),$sdk_debug_replay_slowest_full_snapshot_nodes:null===(r=this._slowestFullSnapshot)||void 0===r?void 0:r.nodeCount,$sdk_debug_replay_slowest_full_snapshot_css_rules:null===(o=this._slowestFullSnapshot)||void 0===o?void 0:o.cssRuleCount,$sdk_debug_replay_slowest_full_snapshot_css_rules_non_deferrable:null===(a=this._slowestFullSnapshot)||void 0===a?void 0:a.nonDeferrableCssRuleCount,$sdk_debug_replay_deferred_stylesheets:null==h?void 0:h.deferredCount,$sdk_debug_replay_deferred_stylesheets_failed:null==h?void 0:h.failedCount,$sdk_debug_replay_deferred_stylesheets_abandoned:null==h?void 0:h.abandonedCount,$sdk_debug_replay_deferred_stylesheet_ms:uc(null==h?void 0:h.totalMs),$sdk_debug_replay_deferred_stylesheet_slowest_slice_ms:uc(null==h?void 0:h.slowestSliceMs),$sdk_debug_replay_slowest_mutation_batch_ms:uc(null===(l=gc())||void 0===l||null===(c=l.getMutationCost)||void 0===c||null===(c=c.call(l))||void 0===c?void 0:c.slowestBatchMs),$sdk_debug_replay_discarded_duration_samples:null===(u=gc())||void 0===u||null===(d=u.getDiscardedDurationSamples)||void 0===d?void 0:d.call(u),$sdk_debug_replay_throttled_mutations_dropped:this._throttledMutationsDropped,$sdk_debug_replay_oversized_mutations_dropped:this._oversizedMutationsDropped,$sdk_debug_replay_oversized_mutation_bytes_dropped:this._oversizedMutationBytesDropped,$sdk_debug_replay_rrweb_error:this._rrwebError,[je]:!!this._stopRrweb,[Ve]:this._rrwebStartAttempted}}_startRecorder(){var t;if(this._stopRrweb)return;this._rrwebStartAttempted=!0;const i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,maskAllElementAttributes:!1,maskAttributeFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,inlineStylesheetBudgetRules:1e4,recordCrossOriginIframes:!1,sampling:void 0,attributeFilter:void 0},n=this._instance.config.session_recording;for(const[e,t]of Object.entries(n||{}))if(e in i)if("maskInputOptions"===e)i.maskInputOptions=ct({password:!0},t);else if("sampling"===e){const e=null!=t?t:{},s={};It(e.mousemove)||(s.mousemove=e.mousemove),It(e.mouseInteraction)||(s.mouseInteraction=e.mouseInteraction),i.sampling=s}else i[e]=t;var r,o,a,l;!0===(null==n?void 0:n.captureJsonLd)&&!0!==i.slimDOMOptions&&"all"!==i.slimDOMOptions&&(i.slimDOMOptions=ct(ct({},i.slimDOMOptions),{},{script:!0})),this._canvasRecording&&this._canvasRecording.enabled&&(i.recordCanvas=!0,i.sampling=ct(ct({},i.sampling),{},{canvas:this._canvasRecording.fps}),i.dataURLOptions={type:"image/webp",quality:this._canvasRecording.quality},i.canvasResolutionScale=this._canvasResolutionScale,i.canvasMasking={configured:()=>{var e;return Ct(null===(e=this._instance.config.session_recording)||void 0===e||null===(e=e.canvasCapture)||void 0===e?void 0:e.maskRegionsFn)},regionsFn:e=>{var t;const i=null===(t=this._instance.config.session_recording)||void 0===t||null===(t=t.canvasCapture)||void 0===t?void 0:t.maskRegionsFn;if(Ct(i))try{var s;return null!==(s=i(e))&&void 0!==s?s:null}catch(e){return this._maskRegionsFnFailed||(this._maskRegionsFnFailed=!0,hc.warn("canvasCapture.maskRegionsFn threw, canvas frames will be skipped",e)),null}}}),this._masking&&(i.maskAllInputs=null===(r=this._masking.maskAllInputs)||void 0===r||r,i.maskTextSelector=null!==(o=this._masking.maskTextSelector)&&void 0!==o?o:void 0,i.blockSelector=null!==(a=this._masking.blockSelector)&&void 0!==a?a:void 0,i.maskAllElementAttributes=null!==(l=this._masking.maskAllElementAttributes)&&void 0!==l&&l),i.maskAllElementAttributes&&i.maskAttributeFn&&(i.maskAttributeFn=void 0,this._hasWarnedExclusiveAttributeMasking||(this._hasWarnedExclusiveAttributeMasking=!0,hc.warn('`maskAllElementAttributes` and `maskAttributeFn` are mutually exclusive, and `maskAttributeFn` is being ignored. Remove one of the two. Note that `maskAllElementAttributes` can also come from your project\'s "Privacy and masking" settings. See https://posthog.com/docs/session-replay/privacy'))),this._warnIfClientMaskingShadowsServer();const c=fc();if(!c)return void hc.error("_startRecorder was called but rrwebRecord is not available. This indicates something has gone wrong.");this._mutationThrottler=null!==(t=this._mutationThrottler)&&void 0!==t?t:new ka(c,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{const i=`Too many mutations on node '${e}'. Rate limiting. This could be due to SVG animations or something similar`;hc.info(i,{node:t}),this.log("[SessionRecording] "+i,"warn")},onDroppedAttributeMutations:e=>this._throttledMutationsDropped+=e,bytesRefillRate:this._instance.config.session_recording.__mutationBytesRefillRate,bytesBucketSize:this._instance.config.session_recording.__mutationBytesBucketSize,resyncIntervalMs:this._fullSnapshotIntervalMillis,onDroppedOversizedMutation:e=>{0===this._oversizedMutationsDropped&&this.log("[SessionRecording] Dropped an oversized DOM mutation to keep the recording playable. The recording will resync with a full snapshot.","warn"),this._oversizedMutationsDropped+=1,this._oversizedMutationBytesDropped+=e},requestFullSnapshot:()=>this._tryTakeFullSnapshot()});const u=this._gatherRRWebPlugins();if(this._stopRrweb=c(ct({emit:e=>{this.onRRwebEmit(e)},plugins:u,errorHandler:(e,t)=>"rrweb"===t&&(this._hasLoggedRecorderCallbackError||(this._hasLoggedRecorderCallbackError=!0,hc.error("rrweb internal error - recording will continue but may be incomplete",e)),!0)},i)),!this._stopRrweb)return this._rrwebError=!0,void hc.error("rrweb failed to start - Loss of recording data is possible. Check the browser console for rrweb errors.");this._rrwebError=!1,!0===(null==n?void 0:n.captureJsonLd)&&s&&(null==e?void 0:e.MutationObserver)&&!this._jsonLdCapture&&(this._jsonLdCapture=function(e,t,i){const s=new WeakMap,n=i.getCaptureState||(()=>!0);let r=ql;const o=function(e,t){const i=t.attributeFilter;return t.maskAllElementAttributes||t.maskAttributeFn||(null==i?void 0:i.length)&&!i.includes("id")?Wl:i=>{const s=e.getElementById(i);return!!s&&"SCRIPT"!==s.nodeName&&(!t.isRecordedElement||t.isRecordedElement(s))&&!lc(s,t.blockClass,t.blockSelector)}}(e,i),a=t=>{try{const a=n();if(!r||!1===a||!t.isConnected||t.ownerDocument!==e||function(e,t){return lc(e,t.blockClass,t.blockSelector)||lc(e,t.maskTextClass,t.maskTextSelector)}(t,i))return;const l=function(e,t=Wl,i){if(!e||e.length>ql)return null;try{const s=JSON.parse(e),n={maskUrl:i,remainingNodes:2048,exceeded:!1},r=kt(s)?s.map(e=>rc(e,t,n)):rc(s,t,n);if(n.exceeded||Rt(r)||kt(r)&&(!r.length||r.some(Rt)))return null;const o=JSON.stringify(r);return o.length>2e4?null:[r,o]}catch(e){return null}}(t.text,o,i.maskUrl);if(!l)return void s.delete(t);const[c,u]=l;if(Rt(a))return void s.set(t,u);if(s.get(t)!==u){if(u.length>r)return void(r=0);i.emit(c)&&(s.set(t,u),r-=u.length)}}catch(e){return}};try{const i=new t(e=>{try{if(!r||!1===n())return;const t=e=>{for(const t of cc(e))a(t)};for(const i of e)if("childList"===i.type)oc(i.target)&&a(i.target),i.addedNodes.forEach(t);else if("characterData"===i.type){const e=i.target.parentNode;e&&oc(e)&&a(e)}else"attributes"===i.type&&oc(i.target)&&a(i.target)}catch(e){return}});return i.observe(e,{attributes:!0,attributeFilter:["type"],characterData:!0,childList:!0,subtree:!0}),{scan(t=!1){r&&!1!==n()&&cc(e.documentElement).forEach(e=>{t&&s.delete(e),a(e)})},stop(){return i.disconnect()}}}catch(e){return{scan(){},stop(){}}}}(s,e.MutationObserver,{maskUrl:e=>this._maskReplayUrl(e),attributeFilter:i.attributeFilter,blockClass:i.blockClass,blockSelector:i.blockSelector,isRecordedElement:e=>c.mirror.getId(e)>0,maskAllElementAttributes:i.maskAllElementAttributes,maskAttributeFn:i.maskAttributeFn,maskTextClass:i.maskTextClass,maskTextSelector:i.maskTextSelector,getCaptureState:()=>{var e;return!0!==(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)||this._urlTriggerMatching.urlBlocked||this._urlTriggerMatching.isCurrentUrlBlocked()?null:this._canCaptureJsonLd()},emit:e=>this._tryAddJsonLdEvent(e)}),this._urlTriggerMatching.isCurrentUrlBlocked()&&this._jsonLdCapture.scan()),this._lastActivityTimestamp=Date.now(),this._isIdle=At(this._isIdle)?this._isIdle:"unknown",this.tryAddCustomEvent("$remote_config_received",this._remoteConfig),this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:u.map(e=>null==e?void 0:e.name)}),this._tryAddCustomEvent("$posthog_config",{config:this._instance.config})}tryAddCustomEvent(e,t){return this._tryAddCustomEvent(e,t)}};const Bc=["type"];var qc=function(e){return e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e}({}),Hc=function(e){return e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e}({}),Uc=function(e){return e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e}({}),Wc=function(e){return e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e}({}),zc=function(e){return e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e}({}),jc=function(e){return e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e}({}),Vc=function(e){return e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e}({});function Gc(e,t){return-1!==e.indexOf(t)}"Mobile".toLowerCase(),"Tablet".toLowerCase(),new RegExp("Xbox","i"),new RegExp("Nintendo","i"),new RegExp("PlayStation","i"),new RegExp("Windows","i"),Date,Date,"0".repeat(32),"0".repeat(16);var Qc={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot"],MutationObserver:[]},Kc={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:["querySelector","querySelectorAll"],MutationObserver:["constructor"]},Zc={};function Jc(e){if(Zc[e])return Zc[e];const t=function(e){var t,i;const s=null===(t=globalThis)||void 0===t||null===(t=t.Zone)||void 0===t||null===(i=t.__symbol__)||void 0===i?void 0:i.call(t,e);return s&&globalThis[s]?globalThis[s]:void 0}(e)||globalThis[e],i=t.prototype,s=e in Qc?Qc[e]:void 0,n=Boolean(s&&s.every(e=>{var t;return Boolean(null===(t=Object.getOwnPropertyDescriptor(i,e))||void 0===t||null===(t=t.get)||void 0===t?void 0:t.toString().includes("[native code]"))})),r=e in Kc?Kc[e]:void 0,o=Boolean(r&&r.every(e=>{var t;return"function"==typeof i[e]&&(null===(t=i[e])||void 0===t?void 0:t.toString().includes("[native code]"))}));if(n&&o)return Zc[e]=t.prototype,t.prototype;const a=document.createElement("iframe");a.style.display="none";let l=!1;try{document.body.appendChild(a);const s=a.contentWindow;if(!s)return t.prototype;const n=s[e].prototype;return n?(function(e){return Gc(e,"AppleWebKit")&&!Gc(e,"Chrome")}(navigator.userAgent)&&(a.classList.add("rr-block","ph-no-capture"),a.setAttribute("__rrwebUntaintedPrototype",e),l=!0),Zc[e]=n):i}catch(e){return i}finally{!l&&a.parentNode&&document.body.removeChild(a)}}var Yc=Object.create(null);function Xc(e,t,i){var s;const n=Yc[e],r=n[i];if(r)return r.call(t);const o=Jc(e),a=null===(s=Object.getOwnPropertyDescriptor(o,i))||void 0===s?void 0:s.get;return a?(n[i]=a,a.call(t)):t[i]}Yc.Node=Object.create(null),Yc.ShadowRoot=Object.create(null),Yc.MutationObserver=Object.create(null),Yc.Element=Object.create(null);var eu,tu={};function iu(e,t,i){const s=`${e}.${String(i)}`;if(tu[s])return tu[s].bind(t);const n=Jc(e)[i];return"function"!=typeof n?t[i]:(tu[s]=n,n.bind(t))}function su(){return Jc("MutationObserver").constructor}function nu(e,t,i){try{if(!(t in e))return()=>{};const s=e[t],n={next:s},r=i(function(...e){return n.next.apply(this,e)});return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:s},__rrweb_layer__:{enumerable:!1,value:n}})),e[t]=r,()=>{if(e[t]===r)return void(e[t]=n.next);const i=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let s=e[t],o=i(s);for(;o;){if(o.next===r)return void(o.next=n.next);s=o.next,o=i(s)}}}catch(e){return()=>{}}}var ru={childNodes:e=>Xc("Node",e,"childNodes"),parentNode:e=>Xc("Node",e,"parentNode"),parentElement:e=>Xc("Node",e,"parentElement"),textContent:e=>Xc("Node",e,"textContent"),isConnected(e){if(void 0===eu){var t;const e=null===(t=Object.getOwnPropertyDescriptor(Jc("Node"),"isConnected"))||void 0===t?void 0:t.get;eu=(null==e?void 0:e.toString().includes("[native code]"))?e:null}return null==eu?void 0:eu.call(e)},contains:(e,t)=>iu("Node",e,"contains")(t),getRootNode:e=>iu("Node",e,"getRootNode")(),host:e=>e&&"host"in e?Xc("ShadowRoot",e,"host"):null,styleSheets:e=>e.styleSheets,shadowRoot:e=>e&&"shadowRoot"in e?Xc("Element",e,"shadowRoot"):null,querySelector:(e,t)=>iu("Element",e,"querySelector")(t),querySelectorAll:(e,t)=>iu("Element",e,"querySelectorAll")(t),mutationObserver:su,patch:nu};function ou(){try{if("undefined"!=typeof performance&&performance.now)return performance.now()}catch(e){}return Date.now()}var au=0;function lu(){au+=1}function cu(){return au}function uu(e,t){return(t!==au||e>6e4)&&!0}var du=0,hu=0,pu=0,_u={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gu=null,fu=null,vu=[],mu=0,yu=0,bu={slowestBatchMs:0},Su={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0};function wu(e){(du+=1)>1||(_u={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},vu=[],mu=0,fu=(e=>e&&e>0?e:null)(e),hu=ou(),pu=au)}function ku(){return 0===du?gu||{durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0}:(du-=1)>0?_u:(_u.durationMs=ou()-hu,_u.deferredStylesheetCount=mu,Su.deferredCount+=mu,fu=null,uu(_u.durationMs,pu)?_u:gu=_u)}function Cu(e,t,i){let s=e.length;if(i>=32)return s;for(let n=0;e.length>n;n++){const r=e[n];try{const e=r.cssRules;if(e&&e.length)s+=Cu(e,t,i+1);else if(t&&r.styleSheet){const e=r.styleSheet;if(!t.has(e)){t.add(e);const n=e.rules||e.cssRules;n&&(s+=Cu(n,t,i+1))}}}catch(e){}}return s}function Eu(e){if(0===du)return;const t=Cu(e,null,0);_u.cssRuleCount+=t,yu>0&&(_u.nonDeferrableCssRuleCount+=t)}function xu(e){yu+=1;try{return e()}finally{yu-=1}}function Iu(e){du>0&&(_u.stylesheetMs+=e)}function Tu(e){if(0===du||null===fu)return!1;const t=_u.cssRuleCount-_u.nonDeferrableCssRuleCount;return t>=fu||t+function(e){try{const t=e&&(e.rules||e.cssRules);if(!t)return 0;const i=new WeakSet;return i.add(e),Cu(t,i,0)}catch(e){return 0}}(e)>fu}function Mu(){const e=vu;return vu=[],e}function Ru(){Su.failedCount+=1}function Pu(e){e>0&&(Su.abandonedCount+=e)}function Fu(e){return Fu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fu(e)}function Lu(e,t,i){return(t=function(e){var t=function(e){if("object"!=Fu(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=Fu(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Fu(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Au(e){return e.nodeType===e.ELEMENT_NODE}function Ou(e){const t=e&&"host"in e&&"mode"in e&&ru.host(e)||null;return Boolean(t&&"shadowRoot"in t&&ru.shadowRoot(t)===e)}function Du(e){return"[object ShadowRoot]"==={}.toString.call(e)}function $u(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function Nu(e){const{cssText:t}=e;if(3>t.split('"').length)return t;const i=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?i.push("layer"):e.layerName&&i.push(`layer(${e.layerName})`),e.supportsText&&i.push(`supports(${e.supportsText})`),e.media.length&&i.push(e.media.mediaText),i.join(" ")+";"}var Bu=0;function qu(e){const t=0===Bu,i=t?ou():0;Bu+=1;try{const t=e.rules||e.cssRules;if(!t)return null;Eu(t);let i=e.href;return!i&&e.ownerNode&&(i=e.ownerNode.baseURI),$u(Array.from(t,e=>Hu(e,i)).join(""))}catch(e){return null}finally{Bu-=1,t&&Iu(ou()-i)}}function Hu(e,t){if(Wu(e)){let t;try{t=qu(e.styleSheet)||Nu(e)}catch(i){t=e.cssText}try{var i;if(t&&(null===(i=e.styleSheet)||void 0===i?void 0:i.href))return rd(t,e.styleSheet.href)}catch(e){}return t}{let i=e.cssText;return zu(e)&&e.selectorText.includes(":")&&(i=Uu(i)),t?rd(i,t):i}}function Uu(e){return e.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")}function Wu(e){return"styleSheet"in e}function zu(e){return"selectorText"in e}var ju=/^-?[A-Za-z_][\w-]*$/,Vu=/^-?[A-Za-z_][\w-]*(\.-?[A-Za-z_][\w-]*)*$/;function Gu(e){const t=[];let i=!1,s=null;const n=new Map;function r(e){const n=t.pop();if("group"===n.kind){if(null===e){for(;t.length>0&&"group"===t[t.length-1].kind;)t.pop();return void r(null)}const i=t[t.length-1];return i.parts.push(e),void(i.index+=1)}if(!n.importRule)return i=!0,void(s=e);o(t[t.length-1],n.importRule,e)}function o(e,t,i){try{let n;try{n=i||Nu(t)}catch(e){n=t.cssText}try{var s;n&&(null===(s=t.styleSheet)||void 0===s?void 0:s.href)&&(n=rd(n,t.styleSheet.href))}catch(e){}n&&e.parts.push(n),e.index+=1}catch(e){r(null)}}function a(e){const i=e.rules[e.index];if("sheet"===e.kind&&Wu(i)){const s=n.get(i);return null===s?(e.parts.push(i.cssText),void(e.index+=1)):s?void t.push({kind:"sheet",sheet:s.sheet,rules:s.rules,sheetHref:s.sheetHref,index:0,parts:[],importRule:i}):void o(e,i,null)}if(function(e,i){try{const s=function(e){const t=e;if(!t.cssRules||0===t.cssRules.length)return null;if(t.media&&"string"==typeof t.media.mediaText)return`@media ${t.media.mediaText} {`;if(zu(e)){if("number"==typeof t.type&&1!==t.type)return null;const i=t.style?t.style.cssText:"";return`${e.selectorText} {${i?" "+i:""}`}if("containerName"in t)return"string"!=typeof t.containerQuery||t.containerName&&!ju.test(t.containerName)?null:`@container ${t.containerName?`${t.containerName} `:""}${t.containerQuery} {`;if("string"==typeof t.conditionText){let s="";try{var i;s=(null===(i=e.constructor)||void 0===i?void 0:i.name)||""}catch(e){return null}return""===s||"Object"===s||"CSSSupportsRule"===s?`@supports ${t.conditionText} {`:null}return"string"==typeof t.name?"keyText"in t.cssRules[0]?ju.test(t.name)?`@keyframes ${t.name} {`:null:""===t.name?"@layer {":Vu.test(t.name)?`@layer ${t.name} {`:null:null}(e);if(null===s)return!1;const n=i.sheetHref;return t.push({kind:"group",rules:Array.from(e.cssRules),sheetHref:n,index:0,parts:[],prelude:n?rd(s,n):s,fixColons:"sheet"===i.kind&&zu(e)&&e.selectorText.includes(":")}),!0}catch(e){return!1}}(i,e))return;let s=i.cssText;"sheet"===e.kind&&zu(i)&&i.selectorText.includes(":")&&(s=Uu(s)),e.parts.push(e.sheetHref?rd(s,e.sheetHref):s),e.index+=1}return function(e){try{const i=e.rules||e.cssRules;if(!i)return!1;Eu(i);let s=e.href;!s&&e.ownerNode&&(s=e.ownerNode.baseURI);const r=Array.from(i);return t.push({kind:"sheet",sheet:e,rules:r,sheetHref:s,index:0,parts:[],importRule:null}),function(e,t){const i=[{sheet:t,rules:e,index:0}];for(;i.length>0;){const e=i[i.length-1];if(e.index>=e.rules.length){i.pop();continue}const t=e.rules[e.index];if(e.index+=1,!Wu(t)||n.has(t))continue;let s=null;try{s=t.styleSheet}catch(e){n.set(t,null);continue}if(s&&!i.some(e=>e.sheet===s))try{const e=s.rules||s.cssRules;if(!e)continue;Eu(e);let r=s.href;!r&&s.ownerNode&&(r=s.ownerNode.baseURI);const o=Array.from(e);n.set(t,{sheet:s,rules:o,sheetHref:r}),i.push({sheet:s,rules:o,index:0})}catch(e){}}}(r,e),!0}catch(e){return!1}}(e)||(i=!0),{advance(e){if(i)return!0;const n=ou();let o=e>0?e:1;try{for(;!i&&o>0;){const e=t[t.length-1];if(e.index>=e.rules.length){let t=null;try{if("group"===e.kind){const i=e.prelude+e.parts.join("")+"}";t=e.fixColons?Uu(i):i}else t=$u(e.parts.join(""))}catch(e){}r(t);continue}o-=1;try{a(e)}catch(e){r(null)}}}catch(e){i=!0,s=null}finally{Iu(ou()-n)}return i},text:()=>i?s:null,remainingRules(){if(i)return 0;let e=0;for(const i of t)e+=i.rules.length-i.index;return e}}}var Qu=class{constructor(){Lu(this,"idNodeMap",new Map),Lu(this,"nodeMetaMap",new WeakMap)}getId(e){var t,i;return e&&null!==(t=null===(i=this.getMeta(e))||void 0===i?void 0:i.id)&&void 0!==t?t:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);if(this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e)),Au(e)){const t=ru.shadowRoot(e);t&&this.removeNodeFromMap(t),"IFRAME"===e.nodeName&&e.contentDocument&&this.removeNodeFromMap(e.contentDocument)}}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){this.idNodeMap.set(t.id,e),this.nodeMetaMap.set(e,t)}replace(e,t){const i=this.getNode(e);if(i){const e=this.nodeMetaMap.get(i);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function Ku({element:e,maskInputOptions:t,tagName:i,type:s,value:n,maskInputFn:r}){let o=n||"";const a=s&&Zu(s);return(t[i.toLowerCase()]||a&&t[a])&&(o=r?r(o,e):"*".repeat(o.length)),o}function Zu(e){return e.toLowerCase()}var Ju=new Set(["rr_width","rr_height","rr_left","rr_top","rr_position","rr_transform","rr_display","rr_scrollleft","rr_scrolltop","rr_mediastate","rr_open_mode"]);function Yu({element:e,name:t,value:i,maskAllElementAttributes:s,maskAttributeFn:n,isGenerated:r=!1}){return i?s?r&&Ju.has(Zu(t))?i:"*".repeat(i.length):n?n(t,i,e):i:i}var Xu="__rrweb_original__";function ed(e){try{const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Zu(t):null}catch(e){return null}}var td=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,id=/^(?:[a-z+]+:)?\/\//i,sd=/^www\..*/i,nd=/^(data:)([^,]*),(.*)/i;function rd(e,t){return(e||"").replace(td,(e,i,s,n,r,o)=>{const a=s||r||o,l=i||n||"";if(!a)return e;if(id.test(a)||sd.test(a))return`url(${l}${a}${l})`;if(nd.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),u=a.split("/");c.pop();for(const e of u)"."!==e&&(".."===e?c.pop():c.push(e));return`url(${l}${c.join("/")}${l})`})}var od,ad,ld=new Map,cd=1,ud=new RegExp("[^a-z0-9-_:]");function dd(){return cd++}var hd=/^[^ \t\n\r\u000c]+/,pd=/^[, \t\n\r\u000c]+/,_d=new WeakMap;function gd(e,t){return t&&""!==t.trim()?fd(e,t):t}function fd(e,t){let i=_d.get(e);if(i||(i=e.createElement("a"),_d.set(e,i)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return i.setAttribute("href",t),i.href}function vd(e,t){return(null==t?void 0:t.maxBase64ImageLength)?function(e,t){return t&&e.length>t?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==":e}(e,t.maxBase64ImageLength):e}function md(e,t,i,s,n,r){if(!s)return s;if("src"===i||"href"===i&&("use"!==t||"#"!==s[0])){if("link"===t&&n){var o;const e=null===(o=n.sheet)||void 0===o?void 0:o.href;if(e)return e}const i=gd(e,s);if(i.startsWith("data:")){if("img"===t&&n){let e=i;return((null==r?void 0:r.type)||void 0!==(null==r?void 0:r.quality))&&(e=function(e,t,i,s){if(1e5>t.length)return t;if(!e.complete||0===e.naturalWidth)return t;if(e.naturalWidth>4096||e.naturalHeight>4096)return t;const n=ld.get(t);if(n&&n.type===i&&n.quality===s)return n.result;try{const n=document.createElement("canvas");n.width=e.naturalWidth,n.height=e.naturalHeight;const r=n.getContext("2d");if(!r)return t;r.drawImage(e,0,0);const o=n.toDataURL(i||"image/webp",null!=s?s:.4),a=t.length>o.length?o:t;if(ld.size>=10){const e=ld.keys().next().value;void 0!==e&&ld.delete(e)}return ld.set(t,{type:i,quality:s,result:a}),a}catch(e){return t}}(n,i,r.type,r.quality)),vd(e,r)}if("image"===t)return vd(i,r)}return i}if("xlink:href"===i&&"#"!==s[0]){const i=gd(e,s);return"image"===t&&i.startsWith("data:")?vd(i,r):i}return"background"!==i||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===i?function(e,t){if(""===t.trim())return t;let i=0;function s(e){let s;const n=e.exec(t.substring(i));return n?(s=n[0],i+=s.length,s):""}const n=[];for(;s(pd),t.length>i;){let r=s(hd);if(","===r.slice(-1))r=gd(e,r.substring(0,r.length-1)),n.push(r);else{let s="";r=gd(e,r);let o=!1;for(;;){const e=t.charAt(i);if(""===e){n.push((r+s).trim());break}if(o)")"===e&&(o=!1);else{if(","===e){i+=1,n.push((r+s).trim());break}"("===e&&(o=!0)}s+=e,i+=1}}}return n.join(", ")}(e,s):"style"===i?rd(s,fd(e)):"object"===t&&"data"===i?gd(e,s):s:gd(e,s)}function yd(e,t,i){return("video"===e||"audio"===e)&&"autoplay"===Zu(t)}function bd(e,t,i){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!i&&bd(ru.parentNode(e),t,i);for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;return!!i&&bd(ru.parentNode(e),t,i)}function Sd(e,t,i,s){let n;if(Au(e)){if(n=e,!ru.childNodes(n).length)return!1}else{if(null===ru.parentElement(e))return!1;n=ru.parentElement(e)}try{if("string"==typeof t){if(s){if(n.closest(`.${t}`))return!0}else if(n.classList.contains(t))return!0}else if(bd(n,t,s))return!0;if(i)if(s){if(n.closest(i))return!0}else if(n.matches(i))return!0}catch(e){}return!1}function wd(e,t,i){const s=e.removeEventListener;"function"==typeof s&&s.call(e,t,i)}var kd=new Map;function Cd(e,t){return Array.from(e.styleSheets).find(e=>e.href===t)}function Ed(e){return null==e?"":e.toLowerCase()}var xd=!1,Id=!1;function Td(e,t){const{doc:i,mirror:s,blockClass:n,blockSelector:r,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p=!1,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f={},inlineImages:v=!1,recordCanvas:m=!1,canvasMaskingConfigured:y,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w=5e3,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E=5e3,keepIframeSrcFn:x=()=>!1,newlyAddedElement:I=!1,depth:T=0,maxDepth:M=50}=t;let{needsMask:R}=t,{preserveWhiteSpace:P=!0}=t;if(T>=M)return Id=!0,xd||(xd=!0,console.warn(`[rrweb-snapshot] DOM tree depth exceeded max depth of ${M}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`)),null;R||(R=Sd(e,o,a,void 0===R)),du>0&&(_u.nodeCount+=1);const F=function(e,t){const{doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:u,maskAllElementAttributes:d=!1,maskAttributeFn:h,dataURLOptions:p={},inlineImages:_,recordCanvas:g,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const i=t.getId(e);return 1===i?void 0:i}(i,s);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:Vc.Document,childNodes:[],compatMode:e.compatMode}:{type:Vc.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:Vc.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:i,blockClass:s,blockSelector:n,inlineStylesheet:r,maskInputOptions:o={},maskInputFn:a,maskAllElementAttributes:l=!1,maskAttributeFn:c,dataURLOptions:u={},inlineImages:d,recordCanvas:h,canvasMaskingConfigured:p,keepIframeSrcFn:_,newlyAddedElement:g=!1,rootId:f}=t,v=function(e,t,i){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;if(i)return e.matches(i)}catch(e){}return!1}(e,s,n),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=Zu(e.tagName);return ud.test(t)?"div":t}(e),y=new Set;let b={};const S=e.attributes.length;for(let t=0;S>t;t++){const s=e.attributes[t];yd(m,s.name)||(b[s.name]=md(i,m,Zu(s.name),s.value,e,u))}if("link"===m&&r&&!v){let t=e.sheet;if(!t){const s=function(e){return e.href}(e);s&&(t=Cd(i,s),!t&&s.includes(".css"))&&(t=Cd(i,window.location.origin+"/"+s.replace(window.location.href,"")))}let s=null;t&&(Tu(t)?du>0&&(vu.push(e),mu+=1):s=qu(t)),s&&(delete b.rel,delete b.href,b._cssText=s)}if("style"===m&&e.sheet&&!(e.innerText||ru.textContent(e)||"").trim().length){const t=xu(()=>qu(e.sheet));t&&(b._cssText=t)}if("input"===m||"textarea"===m||"select"===m){const t=e.value,i=e.checked;"radio"!==b.type&&"checkbox"!==b.type&&"submit"!==b.type&&"button"!==b.type&&t?b.value=Ku({element:e,type:ed(e),tagName:m,value:t,maskInputOptions:o,maskInputFn:a}):i&&(b.checked=i)}if("option"===m&&(e.selected&&!o.select?b.selected=!0:delete b.selected),"dialog"===m&&e.open){try{b.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"}catch(e){b.rr_open_mode="modal",b.ph_rr_could_not_detect_modal=!0}y.add("rr_open_mode")}if("canvas"===m&&h&&!(null==p?void 0:p()))if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let i=0;e.width>i;i+=50)for(let s=0;e.height>s;s+=50){const n=t.getImageData;if(new Uint32Array((Xu in n?n[Xu]:n).call(t,i,s,Math.min(50,e.width-i),Math.min(50,e.height-s)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(b.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){const t=e.toDataURL(u.type,u.quality),s=i.createElement("canvas");s.width=e.width,s.height=e.height,t!==s.toDataURL(u.type,u.quality)&&(b.rr_dataURL=t)}let w,k=!1;if("img"===m&&d){od||(od=i.createElement("canvas"),ad=od.getContext("2d"));const t=e,s=t.currentSrc||t.getAttribute("src")||"<unknown-src>",n=t.crossOrigin,r=(t,i)=>k?Yu({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c}):i,o=()=>{wd(t,"load",o);try{od.width=t.naturalWidth,od.height=t.naturalHeight,ad.drawImage(t,0,0);const e=od.toDataURL(u.type,u.quality);b.rr_dataURL=r("rr_dataURL",e)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o));console.warn(`Cannot inline img src=${s}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(n?b.crossOrigin=r("crossOrigin",n):t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if("audio"===m||"video"===m){const t=b;t.rr_mediaState=e.paused?"paused":"played",y.add("rr_mediaState"),t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}if(g||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),v){var C,E,x;const{width:t,height:s,left:n,top:r}=e.getBoundingClientRect(),o=null===(C=i.defaultView)||void 0===C?void 0:C.getComputedStyle(e);b={class:b.class,rr_width:`${t}px`,rr_height:`${s}px`,rr_left:`${Math.floor(n+((null===(E=i.defaultView)||void 0===E?void 0:E.scrollX)||0))}px`,rr_top:`${Math.floor(r+((null===(x=i.defaultView)||void 0===x?void 0:x.scrollY)||0))}px`},y.add("rr_width"),y.add("rr_height"),y.add("rr_left"),y.add("rr_top"),o&&(b.rr_position=o.position||"static",y.add("rr_position"),o.transform&&"none"!==o.transform&&(b.rr_transform=o.transform,y.add("rr_transform")),o.display&&o.display.startsWith("inline")&&(b.rr_display=o.display,y.add("rr_display")))}if("iframe"!==m||_(b.src)||(e.contentDocument||(b.rr_src=b.src),delete b.src),l||c)for(const[t,i]of Object.entries(b))"string"!=typeof i&&null!==i||(b[t]=Yu({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c,isGenerated:y.has(t)}));k=!0;try{customElements.get(m)&&(w=!0)}catch(e){}return{type:Vc.Element,tagName:m,attributes:b,childNodes:[],isSVG:(I=e,Boolean("svg"===I.tagName||I.ownerSVGElement)||void 0),needBlock:v,rootId:f,isCustom:w};var I}(e,{doc:i,blockClass:n,blockSelector:r,inlineStylesheet:a,maskInputOptions:l,maskInputFn:u,maskAllElementAttributes:d,maskAttributeFn:h,dataURLOptions:p,inlineImages:_,recordCanvas:g,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:i,maskTextFn:s,rootId:n}=t,r=ru.parentNode(e),o=r&&r.tagName;let a=ru.textContent(e);const l="STYLE"===o||void 0,c="SCRIPT"===o||void 0;if(l&&a){try{var u;if(e.nextSibling||e.previousSibling);else if(Tu(r.sheet));else if(null===(u=r.sheet)||void 0===u?void 0:u.cssRules){const e=qu(r.sheet);e&&!/(?:^|[\s;{}])-?[a-zA-Z][\w-]*\s*:\s*;/.test(e)&&(a=e)}}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}a=rd(a,fd(t.doc))}return c&&(a="SCRIPT_PLACEHOLDER"),!l&&!c&&a&&i&&(a=s?s(a,ru.parentElement(e)):a.replace(/[\S]/g,"*")),{type:Vc.Text,textContent:a||"",isStyle:l,rootId:n}}(e,{doc:i,needsMask:o,maskTextFn:c,rootId:y});case e.CDATA_SECTION_NODE:return{type:Vc.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:Vc.Comment,textContent:ru.textContent(e)||"",rootId:y};default:return!1}}(e,{doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:R,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,keepIframeSrcFn:x,newlyAddedElement:I});if(!F)return console.warn(e,"not serialized"),null;let L;L=s.hasNode(e)?s.getId(e):function(e,t){if(t.comment&&e.type===Vc.Comment)return!0;if(e.type===Vc.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===function(e){var t;let i;try{i=new URL(e,window.location.href)}catch(e){return null}const s=i.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:null}(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Ed(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Ed(e.attributes.name)||["icon","apple-touch-icon","shortcut icon"].includes(Ed(e.attributes.rel)))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Ed(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Ed(e.attributes.property).match(/^(og|twitter|fb):/)||Ed(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Ed(e.attributes.name)))return!0;if(t.headMetaRobots&&["robots","googlebot","bingbot"].includes(Ed(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&(["author","generator","framework","publisher","progid"].includes(Ed(e.attributes.name))||Ed(e.attributes.property).match(/^article:/)||Ed(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&["google-site-verification","yandex-verification","csrf-token","p:domain_verify","verify-v1","verification","shopify-checkout-api-token"].includes(Ed(e.attributes.name)))return!0}}return!1}(F,g)||!P&&F.type===Vc.Text&&!F.isStyle&&!F.textContent.replace(/^\s+|\s+$/gm,"").length?-2:dd();const A=Object.assign(F,{id:L});if(s.add(e,A),-2===L)return null;b&&b(e);let O=!l;if(A.type===Vc.Element){O=O&&!A.needBlock,delete A.needBlock;const t=ru.shadowRoot(e);t&&Du(t)&&(A.isShadowHost=!0)}if((A.type===Vc.Document||A.type===Vc.Element)&&O){g.headWhitespace&&A.type===Vc.Element&&"head"===A.tagName&&(P=!1);const t={doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:R,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:P,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:x,depth:T+1,maxDepth:M};if(A.type===Vc.Element&&"textarea"===A.tagName&&void 0!==A.attributes.value);else for(const i of Array.from(ru.childNodes(e))){const e=Td(i,t);e&&A.childNodes.push(e)}let I=null;if(Au(e)&&(I=ru.shadowRoot(e)))for(const e of Array.from(ru.childNodes(I))){const i=Td(e,t);i&&(Du(I)&&(i.isShadow=!0),A.childNodes.push(i))}}const D=ru.parentNode(e);if(D&&Ou(D)&&Du(D)&&(A.isShadow=!0),A.type===Vc.Element&&"iframe"===A.tagName){const t=function(e,t,i){const s=()=>{},n=e.contentWindow;if(!n)return s;let r;try{r=n.document.readyState}catch(e){return s}const o=()=>t();if("complete"!==r){let s=!1,n=null;const r=()=>{s||(s=!0,null!==n&&(clearTimeout(n),n=null),wd(e,"load",a),e.addEventListener("load",o),t())},a=()=>r();return n=setTimeout(r,i),e.addEventListener("load",a),()=>{null!==n&&(clearTimeout(n),n=null),s?wd(e,"load",o):(s=!0,wd(e,"load",a))}}const a="about:blank";let l;try{l=n.location.href}catch(e){return s}if(l!==a||e.src===a||""===e.src){const i=setTimeout(t,0);return e.addEventListener("load",o),()=>{clearTimeout(i),wd(e,"load",o)}}return e.addEventListener("load",o),()=>{wd(e,"load",o)}}(e,()=>{const t=e.contentDocument;if(t&&S){const i=Td(t,{doc:t,mirror:s,blockClass:n,blockSelector:r,needsMask:R,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:P,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:x,depth:T+1,maxDepth:M});i&&S(e,i)}},w);null==k||k(e,t)}return A.type===Vc.Element&&"link"===A.tagName&&"stylesheet"===A.attributes.rel&&function(t,l,k){if(kd.has(t))return;let I;try{I=t.sheet}catch(e){return}if(I)return;const F=new AbortController;let L=!1;const A=()=>{if(!L){L=!0;try{(()=>{if(C){const t=Td(e,{doc:i,mirror:s,blockClass:n,blockSelector:r,needsMask:R,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:_,slimDOMOptions:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:P,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:x,depth:T,maxDepth:M});t&&C(e,t)}})()}finally{kd.delete(t),F.abort()}}},O=setTimeout(A,k);F.signal.addEventListener("abort",()=>clearTimeout(O),{once:!0}),t.addEventListener("load",A,{signal:F.signal,once:!0}),kd.set(t,F)}(e,0,E),A}function Md(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:!1===e?{}:e}var Rd=class e{constructor(...e){Lu(this,"parentElement",null),Lu(this,"parentNode",null),Lu(this,"ownerDocument",void 0),Lu(this,"firstChild",null),Lu(this,"lastChild",null),Lu(this,"previousSibling",null),Lu(this,"nextSibling",null),Lu(this,"ELEMENT_NODE",1),Lu(this,"TEXT_NODE",3),Lu(this,"nodeType",void 0),Lu(this,"nodeName",void 0),Lu(this,"RRNodeType",void 0)}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};function Pd(e,t,i=document){const s={capture:!0,passive:!0};return i.addEventListener(e,t,s),()=>Fd(i,e,t,s)}function Fd(e,t,i,s){Ld(()=>{const n=e.removeEventListener;"function"==typeof n&&(void 0!==s?n.call(e,t,i,s):n.call(e,t,i))})}function Ld(e){try{e()}catch(e){if(!(e instanceof DOMException&&"SecurityError"===e.name))throw e}}function Ad(e){e.forEach(e=>{if("function"==typeof e)try{e()}catch(e){}})}var Od="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",Dd={map:{},getId(){return console.warn(Od),-1},getNode(){return console.warn(Od),null},removeNodeFromMap(){console.warn(Od)},has(){return console.warn(Od),!1},reset(){console.warn(Od)}};function $d(e,t,i={}){let s=null,n=0;return function(...r){const o=Date.now();n||!1!==i.leading||(n=o);const a=t-(o-n),l=this;0>=a||a>t?(s&&(clearTimeout(s),s=null),n=o,e.apply(l,r)):s||!1===i.trailing||(s=setTimeout(()=>{n=!1===i.leading?0:Date.now(),s=null,e.apply(l,r)},a))}}function Nd(e,t,i,s,n=window){const r=n.Object.getOwnPropertyDescriptor(e,t);return n.Object.defineProperty(e,t,s?i:{set(e){if(setTimeout(()=>{try{i.set.call(this,e)}catch(e){}},0),r&&r.set){if(r.get)try{r.get.call(this)}catch(e){return}r.set.call(this,e)}}}),()=>Nd(e,t,r||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Dd=new Proxy(Dd,{get(e,t,i){return"map"===t&&console.warn(Od),Reflect.get(e,t,i)}}));var Bd=Date.now;function qd(e){var t,i,s,n;const r=e.document;return{left:r.scrollingElement?r.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:r.documentElement.scrollLeft||(null==r?void 0:r.body)&&(null===(t=ru.parentElement(r.body))||void 0===t?void 0:t.scrollLeft)||(null==r||null===(i=r.body)||void 0===i?void 0:i.scrollLeft)||0,top:r.scrollingElement?r.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==r?void 0:r.documentElement.scrollTop)||(null==r?void 0:r.body)&&(null===(s=ru.parentElement(r.body))||void 0===s?void 0:s.scrollTop)||(null==r||null===(n=r.body)||void 0===n?void 0:n.scrollTop)||0}}function Hd(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ud(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Wd(e){return e?e.nodeType===e.ELEMENT_NODE?e:ru.parentElement(e):null}function zd(e,t,i,s){if(!e)return!1;const n=Wd(e);if(!n)return!1;try{if("string"==typeof t){if(n.classList.contains(t))return!0;if(s&&null!==n.closest("."+t))return!0}else if(bd(n,t,s))return!0}catch(e){}if(i){if(n.matches(i))return!0;if(s&&null!==n.closest(i))return!0}return!1}function jd(e,t,i){return!("TITLE"!==e.tagName||!i.headTitleMutations)||-2===t.getId(e)}function Vd(e,t){if(Ou(e))return!1;const i=t.getId(e);if(!t.has(i))return!0;const s=ru.parentNode(e);return(!s||s.nodeType!==e.DOCUMENT_NODE)&&(!s||Vd(s,t))}function Gd(e){return Boolean(e.changedTouches)}function Qd(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Kd(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Zd(e){return!!e&&(e instanceof Rd&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(ru.shadowRoot(e)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(Bd=()=>(new Date).getTime());var Jd=class{constructor(){Lu(this,"id",1),Lu(this,"styleIDMap",new WeakMap),Lu(this,"idStyleMap",new Map)}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let i;return i=void 0===t?this.id++:t,this.styleIDMap.set(e,i),this.idStyleMap.set(i,e),i}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function Yd(e){var t;let i=null;return"getRootNode"in e&&(null===(t=ru.getRootNode(e))||void 0===t?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&ru.host(ru.getRootNode(e))&&(i=ru.host(ru.getRootNode(e))),i}function Xd(e){const t=e.ownerDocument;if(!t)return!1;if(ru.contains(t,e))return!0;const i=ru.isConnected(e);return"boolean"==typeof i?i:function(e){const t=e.ownerDocument;if(!t)return!1;const i=function(e){let t,i=e;for(;t=Yd(i);)i=t;return i}(e);return ru.contains(t,i)}(e)}function eh(e){return"__ln"in e}var th,ih=class{constructor(){Lu(this,"length",0),Lu(this,"head",null),Lu(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let i=0;e>i;i++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&eh(e.previousSibling)){const i=e.previousSibling.__ln.next;t.next=i,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,i&&(i.previous=t)}else if(e.nextSibling&&eh(e.nextSibling)&&e.nextSibling.__ln.previous){const i=e.nextSibling.__ln.previous;t.previous=i,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,i&&(i.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},sh=(e,t)=>`${e}@${t}`,nh=class{constructor(){Lu(this,"frozen",!1),Lu(this,"locked",!1),Lu(this,"texts",[]),Lu(this,"attributes",[]),Lu(this,"attributeMap",new WeakMap),Lu(this,"generatedAttributes",new WeakMap),Lu(this,"removes",[]),Lu(this,"mapRemoves",new Set),Lu(this,"movedMap",{}),Lu(this,"addedSet",new Set),Lu(this,"movedSet",new Set),Lu(this,"droppedSet",new Set),Lu(this,"removesSubTreeCache",new Set),Lu(this,"mutationCb",void 0),Lu(this,"blockClass",void 0),Lu(this,"blockSelector",void 0),Lu(this,"maskTextClass",void 0),Lu(this,"maskTextSelector",void 0),Lu(this,"inlineStylesheet",void 0),Lu(this,"maskInputOptions",void 0),Lu(this,"maskTextFn",void 0),Lu(this,"maskInputFn",void 0),Lu(this,"maskAllElementAttributes",void 0),Lu(this,"maskAttributeFn",void 0),Lu(this,"keepIframeSrcFn",void 0),Lu(this,"recordCanvas",void 0),Lu(this,"canvasMaskingConfigured",void 0),Lu(this,"inlineImages",void 0),Lu(this,"slimDOMOptions",void 0),Lu(this,"dataURLOptions",void 0),Lu(this,"doc",void 0),Lu(this,"mirror",void 0),Lu(this,"iframeManager",void 0),Lu(this,"stylesheetManager",void 0),Lu(this,"shadowDomManager",void 0),Lu(this,"canvasManager",void 0),Lu(this,"processedNodeManager",void 0),Lu(this,"unattachedDoc",void 0),Lu(this,"canvasManagerReleased",!1),Lu(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),Lu(this,"emit",()=>{if(this.frozen||this.locked)return;const e=ou(),t=cu();try{this.processBufferedMutations()}finally{i=ou()-e,s=t,du>0||uu(i,null!=s?s:au)||i>bu.slowestBatchMs&&(bu.slowestBatchMs=i)}var i,s}),Lu(this,"processBufferedMutations",()=>{const e=[],t=new Set,i=new ih,s=e=>{let t=e,i=-2;for(;-2===i;)t=t&&t.nextSibling,i=t&&this.mirror.getId(t);return i};let n;const r=r=>{var o;const a=ru.parentNode(r);if(!a||!Xd(r)||"TEXTAREA"===a.tagName)return;if(this.isBlockedAtEmission(a))return;const l=Ou(a)?this.mirror.getId(Yd(r)):this.mirror.getId(a),c=s(r);if(-1===l||-1===c)return i.addNode(r);null!==(o=n)&&void 0!==o||(n={doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,canvasMaskingConfigured:this.canvasMaskingConfigured,inlineImages:this.inlineImages,onSerialize:e=>{Qd(e,this.mirror)&&this.iframeManager.addIframe(e),Kd(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Zd(e)&&!zd(e,this.blockClass,this.blockSelector,!0)&&this.shadowDomManager.addShadowRoot(ru.shadowRoot(e),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onIframeListenerRegistered:(e,t)=>{this.iframeManager.registerLoadListenerDisposer(e,t)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});const u=Td(r,n);u&&(e.push({parentId:l,nextId:c,node:u}),t.add(u.id))};for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e);for(const e of this.movedSet)oh(this.removesSubTreeCache,e)&&!this.movedSet.has(ru.parentNode(e))||r(e);for(const e of this.addedSet)ah(this.droppedSet,e)||oh(this.removesSubTreeCache,e)?ah(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let o=null;for(;i.length;){let e=null;if(o){const t=this.mirror.getId(ru.parentNode(o.value)),i=s(o.value);-1!==t&&-1!==i&&(e=o)}if(!e){let t=i.tail;for(;t;){const i=t;if(t=t.previous,i){const t=this.mirror.getId(ru.parentNode(i.value));if(-1===s(i.value))continue;if(-1!==t){e=i;break}{const t=ru.parentNode(i.value);if(t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const s=ru.host(t);if(-1!==this.mirror.getId(s)){e=i;break}}}}}}if(!e){for(;i.head;)i.removeNode(i.head.value);break}o=e.previous,i.removeNode(e.value),r(e.value)}const a={texts:this.texts.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const t=e.node,i=ru.parentNode(t);return i&&"TEXTAREA"===i.tagName&&this.genTextAreaValueMutation(i),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const{attributes:t}=e;if(!this.maskAllElementAttributes&&!this.maskAttributeFn&&"string"==typeof t.style){const i=JSON.stringify(e.styleDiff),s=JSON.stringify(e._unchangedStyles);t.style.length>i.length&&(i+s).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}if(this.maskAllElementAttributes||this.maskAttributeFn)for(const[s,n]of Object.entries(t))if("string"==typeof n||null===n){var i;t[s]=Yu({element:e.node,name:s,value:n,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,isGenerated:null===(i=this.generatedAttributes.get(e.node))||void 0===i?void 0:i.has(s)})}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.generatedAttributes=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},(a.texts.length||a.attributes.length||a.removes.length||a.adds.length)&&this.mutationCb(a)}),Lu(this,"bufferBelongsToIframe",e=>this.doc===e.contentDocument),Lu(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const i=Array.from(ru.childNodes(e),e=>ru.textContent(e)||"").join("");t.attributes.value=Ku({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:ed(e),value:i,maskInputFn:this.maskInputFn})}),Lu(this,"processMutation",e=>{if(!jd(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=ru.textContent(e.target);zd(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Sd(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Wd(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{var t;const s=e.target,n=Zu(s.tagName),r=e.attributeName,o=null!==(t=e.attributeNamespace)&&void 0!==t?t:null;let a=function(e,t,i){if(!i)return t;const s=e.getAttributeNodeNS(i,t);if(s)return s.name;if("http://www.w3.org/1999/xlink"===i)return`xlink:${t}`;if("http://www.w3.org/XML/1998/namespace"===i)return`xml:${t}`;if("http://www.w3.org/2000/xmlns/"===i)return"xmlns"===t?t:`xmlns:${t}`;const n=e.lookupPrefix(i);return n?`${n}:${t}`:t}(s,r,o),l=o?s.getAttributeNS(o,r):e.target.getAttribute(r);if("value"===a){const e=s,t=ed(e);l=Ku({element:e,maskInputOptions:this.maskInputOptions,tagName:s.tagName,type:t,value:l,maskInputFn:this.maskInputFn})}if(zd(e.target,this.blockClass,this.blockSelector,!1)||l===e.oldValue)return;let c=this.attributeMap.get(e.target);const u="iframe"===n&&"src"===a;if(u&&!this.keepIframeSrcFn(l)&&s.contentDocument)return;if("type"===a&&"input"===n&&"password"===(e.oldValue||"").toLowerCase()&&s.setAttribute("data-rr-is-password","true"),!yd(n,a)){var i;c||(c={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(c),this.attributeMap.set(e.target,c));const t=md(this.doc,n,Zu(a),l,s,this.dataURLOptions);if(u&&!this.keepIframeSrcFn(l)&&(a="rr_src"),c.attributes[a]=t,null===(i=this.generatedAttributes.get(e.target))||void 0===i||i.delete(a),"style"===a){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const t=this.unattachedDoc.createElement("span"),i=s.style;e.oldValue&&(t.style.cssText=e.oldValue);for(const e of Array.from(i)){const s=i.getPropertyValue(e),n=i.getPropertyPriority(e);s!==t.style.getPropertyValue(e)||n!==t.style.getPropertyPriority(e)?c.styleDiff[e]=""===n?s:[s,n]:c._unchangedStyles[e]=[s,n]}for(const e of Array.from(t.style))""===i.getPropertyValue(e)&&(c.styleDiff[e]=!1)}else if("open"===a&&"dialog"===n){c.attributes.rr_open_mode=s.matches("dialog:modal")?"modal":"non-modal";let t=this.generatedAttributes.get(e.target);t||(t=new Set,this.generatedAttributes.set(e.target,t)),t.add("rr_open_mode")}}break}case"childList":if(zd(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const i=this.mirror.getId(t),s=Ou(e.target)?this.mirror.getId(ru.host(e.target)):this.mirror.getId(e.target);zd(e.target,this.blockClass,this.blockSelector,!1)||jd(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(rh(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===i||Vd(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[sh(i,s)]?rh(this.movedSet,t):(this.removes.push({parentId:s,id:i,isShadow:!(!Ou(e.target)||!Du(e.target))||void 0}),function(e,t){const i=[e];for(;i.length;){const e=i.pop();t.has(e)||(t.add(e),ru.childNodes(e).forEach(e=>i.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.add(t))})}}),Lu(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)){if(this.addedSet.has(e))return this.addedSet.delete(e),void this.addedSet.add(e);if(!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(jd(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let i=null;t&&this.mirror.hasNode(t)&&(i=this.mirror.getId(t)),i&&-1!==i&&(this.movedMap[sh(this.mirror.getId(e),i)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);if(!zd(e,this.blockClass,this.blockSelector,!1)){if(e.nodeType===e.TEXT_NODE)return;const t=ru.childNodes(e);for(let e=0,i=t.length;i>e;e++){const i=t[e];i&&this.genAdds(i)}if(Zd(e)){const t=ru.childNodes(ru.shadowRoot(e));for(let i=0,s=t.length;s>i;i++){const s=t[i];s&&(this.processedNodeManager.add(s,this),this.genAdds(s,e))}}}}}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","maskAllElementAttributes","maskAttributeFn","keepIframeSrcFn","recordCanvas","canvasMaskingConfigured","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]}),this.canvasManager.acquire()}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.releaseCanvasManager()}releaseCanvasManager(){this.canvasManagerReleased||(this.canvasManagerReleased=!0,this.canvasManager.reset())}bufferDoc(){return this.doc}destroy(){for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e)}isBlockedAtEmission(e){const t=this.blockClass,i=t&&"string"!=typeof t&&(t.global||t.sticky)?new RegExp(t):null;for(;e;){if(i&&(i.lastIndex=0),zd(e,i||t,this.blockSelector,!0))return!0;const s="getRootNode"in e?ru.getRootNode(e):null;e=(null==s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE?ru.host(s):null}return!1}};function rh(e,t){const i=[t];for(;i.length;){const t=i.pop();if(e.delete(t),t.nodeType===t.TEXT_NODE)continue;const s=ru.childNodes(t);for(let e=0,t=s.length;t>e;e++){const t=s[e];t&&i.push(t)}}}function oh(e,t,i){return 0!==e.size&&function(e,t){const i=ru.parentNode(t);return!!i&&e.has(i)}(e,t)}function ah(e,t){if(0===e.size)return!1;let i=ru.parentNode(t);for(;i;){if(e.has(i))return!0;i=ru.parentNode(i)}return!1}function lh(e){th=e}function ch(){th=void 0}var uh=(e,t="rrweb")=>th?(...i)=>{try{return e(...i)}catch(e){if(th&&!0===th(e,t))return;throw e}}:e,dh=[];function hh(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function ph(e,t){const i=new nh;let s;i.init(e);try{s=new(su())(uh(i.processMutations.bind(i)));const n={attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};return e.attributeFilter&&e.attributeFilter.length>0&&(n.attributeFilter=e.attributeFilter),s.observe(t,n),dh.push(i),{observer:s,buffer:i}}catch(e){try{null==s||s.disconnect(),i.destroy(),i.reset()}catch(e){}throw e}}function _h({scrollCb:e,doc:t,mirror:i,blockClass:s,blockSelector:n,sampling:r}){const o=new Map,a=r=>{const a=hh(r);if(!a||zd(a,s,n,!0))return;const l=i.getId(a);let c,u;if(a===t&&t.defaultView){const e=qd(t.defaultView);c=e.left,u=e.top}else c=a.scrollLeft,u=a.scrollTop;const d=`${c},${u}`;o.get(l)!==d&&(o.set(l,d),e({id:l,x:c,y:u}))},l=[Pd("scroll",uh($d(uh(e=>a(e)),r.scroll||100)),t)];return"onscrollend"in t&&l.push(Pd("scrollend",uh(a),t)),()=>l.forEach(e=>e())}function gh(e,t){for(let i=dh.length-1;i>=0;i--){const s=dh[i];if(!s)continue;let n=s.bufferBelongsToIframe(e);!n&&t&&t.has(s.bufferDoc())&&(n=!0),n&&(s.reset(),dh.splice(i,1))}}var fh=["INPUT","TEXTAREA","SELECT"],vh=new WeakMap;function mh(e){return function e(t,i){if(wh("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||wh("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||wh("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||wh("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const s=Array.from(t.parentRule.cssRules).indexOf(t);return i.unshift(s),e(t.parentRule,i)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);i.unshift(e)}return i}(e,[])}function yh(e,t,i){let s,n;return e?(e.ownerNode?s=t.getId(e.ownerNode):n=i.getId(e),{styleId:n,id:s}):{}}function bh({mirror:e,stylesheetManager:t},i){var s,n;let r=null;r=e.getId("#document"===i.nodeName?i:ru.host(i));const o="#document"===i.nodeName?null===(s=i.defaultView)||void 0===s?void 0:s.Document:null===(n=i.ownerDocument)||void 0===n||null===(n=n.defaultView)||void 0===n?void 0:n.ShadowRoot,a=(null==o?void 0:o.prototype)?Object.getOwnPropertyDescriptor(null==o?void 0:o.prototype,"adoptedStyleSheets"):void 0;return null!==r&&-1!==r&&o&&a?(Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var e;return null===(e=a.get)||void 0===e?void 0:e.call(this)},set(e){let i;try{var s;i=null===(s=a.set)||void 0===s?void 0:s.call(this,e)}catch(e){if(e&&"object"==typeof e&&"NotAllowedError"===e.name)return;throw e}if(null!==r&&-1!==r)try{t.adoptStyleSheets(e,r)}catch(e){}return i}}),uh(()=>{Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})):()=>{}}function Sh(e,t={}){const i=e.doc.defaultView;if(!i)return()=>{};let s,n;!function(e,t){const{mutationCb:i,mousemoveCb:s,mouseInteractionCb:n,scrollCb:r,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p,customElementCb:_}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),i(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),s(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),n(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),r(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),_(...e)}}(e,t);const r=[],o=uh(()=>{try{if(n)try{n.destroy(),n.reset()}finally{const e=dh.indexOf(n);-1!==e&&dh.splice(e,1)}e.shadowDomManager.resetForDoc(e.doc),null==s||s.disconnect()}finally{Ad(r)}});try{if(e.recordDOM){const t=ph(e,e.doc);s=t.observer,n=t.buffer}if(r.push(function({mousemoveCb:e,sampling:t,doc:i,mirror:s}){if(!1===t.mousemove)return()=>{};const n="number"==typeof t.mousemove?t.mousemove:50,r="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let o,a=[];const l=$d(uh(t=>{const i=Date.now()-o;e(a.map(e=>(e.timeOffset-=i,e)),t),a=[],o=null}),r),c=uh($d(uh(e=>{const t=hh(e),{clientX:i,clientY:n}=Gd(e)?e.changedTouches[0]:e;o||(o=Bd()),a.push({x:i,y:n,id:s.getId(t),timeOffset:Bd()-o}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?Hc.Drag:e instanceof MouseEvent?Hc.MouseMove:Hc.TouchMove)}),n,{trailing:!1})),u=[Pd("mousemove",c,i),Pd("touchmove",c,i),Pd("drag",c,i)];return uh(()=>{u.forEach(e=>e())})}(e)),r.push(function({mouseInteractionCb:e,doc:t,mirror:i,blockClass:s,blockSelector:n,sampling:r}){if(!1===r.mouseInteraction)return()=>{};const o=!0===r.mouseInteraction||void 0===r.mouseInteraction?{}:r.mouseInteraction,a=[];let l=null;return Object.keys(Uc).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==o[e]).forEach(r=>{let o=Zu(r);const c=(t=>r=>{const o=hh(r);if(zd(o,s,n,!0))return;let a=null,c=t;if("pointerType"in r){switch(r.pointerType){case"mouse":a=Wc.Mouse;break;case"touch":a=Wc.Touch;break;case"pen":a=Wc.Pen}a===Wc.Touch&&(Uc[t]===Uc.MouseDown?c="TouchStart":Uc[t]===Uc.MouseUp&&(c="TouchEnd"))}else Gd(r)&&(a=Wc.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Wc.Touch||c.startsWith("Mouse")&&a===Wc.Mouse)&&(a=null)):Uc[t]===Uc.Click&&(a=l,l=null);const u=Gd(r)?r.changedTouches[0]:r;if(!u)return;const d=i.getId(o),{clientX:h,clientY:p}=u;uh(e)(ct({type:Uc[c],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(r);if(window.PointerEvent)switch(Uc[r]){case Uc.MouseDown:case Uc.MouseUp:o=o.replace("mouse","pointer");break;case Uc.TouchStart:case Uc.TouchEnd:return}a.push(Pd(o,c,t))}),uh(()=>{a.forEach(e=>e())})}(e)),r.push(_h(e)),r.push(function({viewportResizeCb:e},{win:t}){let i=-1,s=-1;return Pd("resize",uh($d(uh(()=>{const t=Hd(),n=Ud();i===t&&s===n||(e({width:Number(n),height:Number(t)}),i=t,s=n)}),200)),t)}(e,{win:i})),r.push(function({inputCb:e,doc:t,mirror:i,blockClass:s,blockSelector:n,ignoreClass:r,ignoreSelector:o,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:u}){function d(e){let i=hh(e);const c=e.isTrusted,d=t.defaultView;if(i&&d&&!(i instanceof d.HTMLElement))return;const p=i&&i.tagName;if(i&&"OPTION"===p&&(i=ru.parentElement(i)),!i||!p||0>fh.indexOf(p)||zd(i,s,n,!0))return;if(i.classList.contains(r)||o&&i.matches(o))return;let _=i.value,g=!1;const f=ed(i)||"";"radio"===f||"checkbox"===f?g=i.checked:(a[p.toLowerCase()]||a[f])&&(_=Ku({element:i,maskInputOptions:a,tagName:p,type:f,value:_,maskInputFn:l})),h(i,u?{text:_,isChecked:g,userTriggered:c}:{text:_,isChecked:g});const v=i.name;"radio"===f&&v&&g&&t.querySelectorAll(`input[type="radio"][name="${v}"]`).forEach(e=>{if(e!==i){const t=e.value;h(e,u?{text:t,isChecked:!g,userTriggered:!1}:{text:t,isChecked:!g})}})}function h(t,s){const n=vh.get(t);if(!n||n.text!==s.text||n.isChecked!==s.isChecked){vh.set(t,s);const n=i.getId(t);uh(e)(ct(ct({},s),{},{id:n}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>Pd(e,uh(d),t)),_=t.defaultView;if(!_)return()=>{p.forEach(e=>e())};const g=_.Object.getOwnPropertyDescriptor(_.HTMLInputElement.prototype,"value");return g&&g.set&&p.push(...[[_.HTMLInputElement.prototype,"value"],[_.HTMLInputElement.prototype,"checked"],[_.HTMLSelectElement.prototype,"value"],[_.HTMLTextAreaElement.prototype,"value"],[_.HTMLSelectElement.prototype,"selectedIndex"],[_.HTMLOptionElement.prototype,"selected"]].map(e=>Nd(e[0],e[1],{set(){uh(d)({target:this,isTrusted:!1})}},!1,_))),uh(()=>{Ad(p)})}(e)),r.push(function({mediaInteractionCb:e,blockClass:t,blockSelector:i,mirror:s,sampling:n,doc:r}){const o=uh(r=>$d(uh(n=>{const o=hh(n);if(!o||zd(o,t,i,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:u,loop:d}=o;e({type:r,id:s.getId(o),currentTime:a,volume:l,muted:c,playbackRate:u,loop:d})}),n.media||500)),a=[Pd("play",o(jc.Play),r),Pd("pause",o(jc.Pause),r),Pd("seeked",o(jc.Seeked),r),Pd("volumechange",o(jc.VolumeChange),r),Pd("ratechange",o(jc.RateChange),r)];return uh(()=>{a.forEach(e=>e())})}(e)),e.recordDOM){const t=function(e){const t=new Map,i=new Set;let s=!0;const n=e=>{if(s)try{e()}catch(e){}},r=e=>{var i;const s=t.get(e);if(s){for(;null===(i=s[0])||void 0===i?void 0:i.ready;){const e=s.shift();(null==e?void 0:e.emit)&&n(e.emit)}0===s.length&&t.delete(e)}};return{queueMutation(e,i){if(!e)return void n(i);const s=t.get(e);s?(s.push({emit:i,ready:!0}),r(e)):n(i)},queuePendingMutation(o,a,l){if(!s)return()=>{};let c=t.get(o);c||(c=[],t.set(o,c));const u={emit:a,ready:!1};c.push(u);let d,h=!1,p=!1;const _=()=>{h||p||(h=!0,void 0!==d&&i.delete(d),u.ready=!0,u.emit=void 0,r(o))};try{d=e.setTimeout(_,5e3),h||p?e.clearTimeout(d):i.add(d)}catch(e){_()}return t=>{!p&&s&&(p=!0,void 0!==d&&(e.clearTimeout(d),i.delete(d)),h?t&&n(l):(u.ready=!0,t||(u.emit=void 0),r(o)))}},reset(){s=!1,i.forEach(t=>e.clearTimeout(t)),i.clear(),t.clear()}}}(i);r.push(t.reset),r.push(function({styleSheetRuleCb:e,mirror:t,stylesheetManager:i},{win:s,mutationQueue:n}){if(!s.CSSStyleSheet||!s.CSSStyleSheet.prototype)return()=>{};const r=s.CSSStyleSheet.prototype.insertRule;s.CSSStyleSheet.prototype.insertRule=new Proxy(r,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=yh(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&n.queueMutation(r,()=>e({id:c,styleId:u,adds:[{rule:a,index:l}]})),l},"host")}),s.CSSStyleSheet.prototype.addRule=function(e,t,i=this.cssRules.length){return s.CSSStyleSheet.prototype.insertRule.apply(this,[`${e} { ${t} }`,i])};const o=s.CSSStyleSheet.prototype.deleteRule;let a,l;s.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=yh(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&n.queueMutation(r,()=>e({id:c,styleId:u,removes:[{index:a}]})),l},"host")}),s.CSSStyleSheet.prototype.removeRule=function(e){return s.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},s.CSSStyleSheet.prototype.replace&&(a=s.CSSStyleSheet.prototype.replace,s.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);try{const s=null==l?void 0:l.then;if(r.ownerNode||!l||"function"!=typeof s)return l;i.onCssomSheetMutation(r);const{id:o,styleId:c}=yh(r,t,i.styleMirror);if(!(o&&-1!==o||c&&-1!==c))return l;const u=n.queuePendingMutation(r,()=>e({id:o,styleId:c,replace:a}),()=>{const t=qu(r);null!==t&&e({id:o,styleId:c,replace:t})});try{s.call(l,()=>u(!0),()=>u(!1))}catch(e){u(!1)}}catch(e){}return l},"host")})),s.CSSStyleSheet.prototype.replaceSync&&(l=s.CSSStyleSheet.prototype.replaceSync,s.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=yh(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&n.queueMutation(r,()=>e({id:c,styleId:u,replaceSync:a})),l},"host")}));const c={};kh("CSSGroupingRule")?c.CSSGroupingRule=s.CSSGroupingRule:(kh("CSSMediaRule")&&(c.CSSMediaRule=s.CSSMediaRule),kh("CSSConditionRule")&&(c.CSSConditionRule=s.CSSConditionRule),kh("CSSSupportsRule")&&(c.CSSSupportsRule=s.CSSSupportsRule));const u={};return Object.entries(c).forEach(([s,r])=>{u[s]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=new Proxy(u[s].insertRule,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=yh(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...mh(r),l];n.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,adds:[{rule:a,index:t}]}))}return l},"host")}),r.prototype.deleteRule=new Proxy(u[s].deleteRule,{apply:uh((s,r,o)=>{const[a]=o,l=s.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=yh(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...mh(r),a];n.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,removes:[{index:t}]}))}return l},"host")})}),uh(()=>{s.CSSStyleSheet.prototype.insertRule=r,s.CSSStyleSheet.prototype.deleteRule=o,a&&(s.CSSStyleSheet.prototype.replace=a),l&&(s.CSSStyleSheet.prototype.replaceSync=l),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule})})}(e,{win:i,mutationQueue:t})),r.push(bh(e,e.doc)),r.push(function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:i,stylesheetManager:s},{win:n,mutationQueue:r}){const o=n.CSSStyleDeclaration.prototype.setProperty;n.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:uh((n,o,a)=>{var l;const[c,u,d]=a,h=n.apply(o,a);if(i.has(c))return h;const p=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;s.onCssomSheetMutation(p);const{id:_,styleId:g}=yh(p,t,s.styleMirror);if(_&&-1!==_||g&&-1!==g){const t=mh(o.parentRule);r.queueMutation(p,()=>e({id:_,styleId:g,set:{property:c,value:u,priority:d},index:t}))}return h},"host")});const a=n.CSSStyleDeclaration.prototype.removeProperty;return n.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:uh((n,o,a)=>{var l;const[c]=a,u=n.apply(o,a);if(i.has(c))return u;const d=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;s.onCssomSheetMutation(d);const{id:h,styleId:p}=yh(d,t,s.styleMirror);if(h&&-1!==h||p&&-1!==p){const t=mh(o.parentRule);r.queueMutation(d,()=>e({id:h,styleId:p,remove:{property:c},index:t}))}return u},"host")}),uh(()=>{n.CSSStyleDeclaration.prototype.setProperty=o,n.CSSStyleDeclaration.prototype.removeProperty=a})}(e,{win:i,mutationQueue:t})),e.collectFonts&&r.push(function({fontCb:e,doc:t}){const i=t.defaultView;if(!i)return()=>{};const s=[],n=new WeakMap,r=i.FontFace;i.FontFace=function(e,t,i){const s=new r(e,t,i);return n.set(s,{family:e,buffer:"string"!=typeof t,descriptors:i,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),s};const o=nu(t.fonts,"add",function(t){return function(i){return setTimeout(uh(()=>{const t=n.get(i);t&&(e(t),n.delete(i))}),0),t.apply(this,[i])}});return s.push(()=>{i.FontFace=r}),s.push(o),uh(()=>{s.forEach(e=>e())})}(e))}r.push(function(e){const{doc:t,mirror:i,blockClass:s,blockSelector:n,selectionCb:r}=e;let o=!0;const a=uh(()=>{const e=t.getSelection();if(!e||o&&(null==e?void 0:e.isCollapsed))return;o=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;l>t;t++){const{startContainer:r,startOffset:o,endContainer:l,endOffset:c}=e.getRangeAt(t);zd(r,s,n,!0)||zd(l,s,n,!0)||a.push({start:i.getId(r),startOffset:o,end:i.getId(l),endOffset:c})}r({ranges:a})});return a(),Pd("selectionchange",a)}(e)),r.push(function({doc:e,customElementCb:t}){const i=e.defaultView;return i&&i.customElements?nu(i.customElements,"define",function(e){return function(i,s,n){try{t({define:{name:i}})}catch(e){console.warn(`Custom element callback failed for ${i}`)}return e.apply(this,[i,s,n])}}):()=>{}}(e));for(const t of e.plugins)r.push(t.observer(t.callback,i,t.options))}catch(e){try{o()}catch(e){}throw e}return o}function wh(e){return void 0!==window[e]}function kh(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}var Ch=class{constructor(e){Lu(this,"generateIdFn",void 0),Lu(this,"iframeRemoteIdToLocalIdMap",new WeakMap),Lu(this,"iframeLocalIdToRemoteIdMap",new WeakMap),this.generateIdFn=e}getId(e,t,i,s){if(0>t)return t;const n=i||this.getRemoteIdToLocalIdMap(e),r=s||this.getLocalIdToRemoteIdMap(e);let o=n.get(t);return void 0===o&&(o=this.generateIdFn(),n.set(t,o),r.set(o,t)),o}getIds(e,t){const i=this.getRemoteIdToLocalIdMap(e),s=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getId(e,t,i,s))}getRemoteId(e,t,i){var s;return"number"!=typeof t||0>t?t:null!==(s=(i||this.getLocalIdToRemoteIdMap(e)).get(t))&&void 0!==s?s:-1}getRemoteIds(e,t){const i=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getRemoteId(e,t,i))}reset(e){if(!e)return this.iframeRemoteIdToLocalIdMap=new WeakMap,void(this.iframeLocalIdToRemoteIdMap=new WeakMap);this.iframeRemoteIdToLocalIdMap.delete(e),this.iframeLocalIdToRemoteIdMap.delete(e)}getRemoteIdToLocalIdMap(e){let t=this.iframeRemoteIdToLocalIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToLocalIdMap.set(e,t)),t}getLocalIdToRemoteIdMap(e){let t=this.iframeLocalIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeLocalIdToRemoteIdMap.set(e,t)),t}},Eh=class{constructor(e){Lu(this,"iframes",new WeakMap),Lu(this,"crossOriginIframeMap",new WeakMap),Lu(this,"crossOriginIframeMirror",new Ch(dd)),Lu(this,"crossOriginIframeStyleMirror",void 0),Lu(this,"crossOriginIframeRootIdMap",new WeakMap),Lu(this,"mirror",void 0),Lu(this,"mutationCb",void 0),Lu(this,"wrappedEmit",void 0),Lu(this,"loadListener",void 0),Lu(this,"pageHideListener",void 0),Lu(this,"stylesheetManager",void 0),Lu(this,"recordCrossOriginIframes",void 0),Lu(this,"messageHandler",void 0),Lu(this,"nestedIframeListeners",new Map),Lu(this,"attachedWindows",new WeakMap),Lu(this,"attachedDocuments",new WeakMap),Lu(this,"attachedIframes",new Map),Lu(this,"loadListenerDisposers",new WeakMap),Lu(this,"iframeElementsById",new Map),Lu(this,"pageHideHandlers",new WeakMap),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ch(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.messageHandler=this.handleMessage.bind(this),this.recordCrossOriginIframes&&window.addEventListener("message",this.messageHandler)}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}registerLoadListenerDisposer(e,t){let i=this.loadListenerDisposers.get(e);i||(i=new Set,this.loadListenerDisposers.set(e,i)),i.add(t);const s=this.mirror.getId(e);-1!==s&&this.iframeElementsById.set(s,e)}getIframeElementById(e){var t,i,s;return null!==(t=null!==(i=null===(s=this.attachedIframes.get(e))||void 0===s?void 0:s.element)&&void 0!==i?i:this.iframeElementsById.get(e))&&void 0!==t?t:null}forgetIframeId(e){this.attachedIframes.delete(e),this.iframeElementsById.delete(e)}disposeLoadListeners(e){const t=this.loadListenerDisposers.get(e);t&&(t.forEach(e=>Ld(e)),this.loadListenerDisposers.delete(e))}removePageHideListener(e){const t=this.pageHideHandlers.get(e);t&&(t.forEach(({win:e,handler:t})=>{Fd(e,"pagehide",t)}),this.pageHideHandlers.delete(e))}addLoadListener(e){this.loadListener=e}addPageHideListener(e){this.pageHideListener=e}removeLoadListener(){this.loadListener=void 0}trackIframeContent(e,t){const i=this.mirror.getId(e);return this.attachedIframes.set(i,{element:e,content:t}),i}attachIframe(e,t){var i;const s=this.trackIframeContent(e,t);if(e.contentDocument){let t=this.attachedDocuments.get(e);t||(t=new Set,this.attachedDocuments.set(e,t)),t.add(e.contentDocument)}this.mutationCb({adds:[{parentId:s,nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0});const n=e.contentWindow;if(this.recordCrossOriginIframes&&n&&!this.nestedIframeListeners.has(n)){const t=this.handleMessage.bind(this);Ld(()=>{n.addEventListener("message",t),this.nestedIframeListeners.set(n,t);let i=this.attachedWindows.get(e);i||(i=new Set,this.attachedWindows.set(e,i)),i.add(n)})}Ld(()=>{const t=e.contentWindow;if(!t)return;let i=this.pageHideHandlers.get(e);if(i)for(const e of i)if(e.win===t)return;const s=()=>{var t;null===(t=this.pageHideListener)||void 0===t||t.call(this,e),e.contentDocument&&this.mirror.removeNodeFromMap(e.contentDocument)};t.addEventListener("pagehide",s),i||(i=new Set,this.pageHideHandlers.set(e,i)),i.add({win:t,handler:s})}),null===(i=this.loadListener)||void 0===i||i.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const i=this.crossOriginIframeMap.get(e.source);if(!i)return;const s=this.transformCrossOriginEvent(i,t.data.event);s&&this.wrappedEmit(s,t.data.isCheckout)}transformCrossOriginEvent(e,t){switch(t.type){case qc.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const i=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,i),this.patchRootIdOnNode(t.data.node,i),this.trackIframeContent(e,t.data.node),{timestamp:t.timestamp,type:qc.IncrementalSnapshot,data:{source:Hc.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case qc.Meta:case qc.Load:case qc.DomContentLoaded:return!1;case qc.Plugin:return t;case qc.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case qc.IncrementalSnapshot:switch(t.data.source){case Hc.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const i=this.crossOriginIframeRootIdMap.get(e);i&&this.patchRootIdOnNode(t.node,i)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Hc.Drag:case Hc.TouchMove:case Hc.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Hc.ViewportResize:return!1;case Hc.MediaInteraction:case Hc.MouseInteraction:case Hc.Scroll:case Hc.CanvasMutation:case Hc.Input:return this.replaceIds(t.data,e,["id"]),t;case Hc.StyleSheetRule:case Hc.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Hc.Font:return t;case Hc.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case Hc.AdoptedStyleSheet:var i;return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(i=t.data.styles)||void 0===i||i.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,i,s){for(const n of s)(Array.isArray(t[n])||"number"==typeof t[n])&&(t[n]=Array.isArray(t[n])?e.getIds(i,t[n]):e.getId(i,t[n]));return t}replaceIds(e,t,i){return this.replace(this.crossOriginIframeMirror,e,t,i)}replaceStyleIds(e,t,i){return this.replace(this.crossOriginIframeStyleMirror,e,t,i)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===Vc.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}removeIframeById(e){const t=this.attachedIframes.get(e),i=(null==t?void 0:t.element)||this.iframeElementsById.get(e)||this.mirror.getNode(e);if(this.iframeElementsById.delete(e),i){const e=i.contentWindow,t=this.attachedWindows.get(i);t&&(t.forEach(e=>{const t=this.nestedIframeListeners.get(e);t&&(Fd(e,"message",t),this.nestedIframeListeners.delete(e)),this.crossOriginIframeMap.delete(e)}),this.attachedWindows.delete(i)),e&&this.nestedIframeListeners.has(e)&&(Fd(e,"message",this.nestedIframeListeners.get(e)),this.nestedIframeListeners.delete(e)),e&&this.crossOriginIframeMap.delete(e),this.iframes.delete(i),this.disposeLoadListeners(i),this.removePageHideListener(i);const s=this.attachedDocuments.get(i);s&&(s.forEach(e=>{Ld(()=>this.mirror.removeNodeFromMap(e))}),Ld(()=>gh(i,s)),this.attachedDocuments.delete(i))}t&&this.attachedIframes.delete(e)}cleanupDetachedIframes(){if(0===this.attachedIframes.size)return;const e=[];this.attachedIframes.forEach((t,i)=>{this.mirror.has(i)||e.push(i)}),e.forEach(e=>this.removeIframeById(e))}reattachIframes(){this.attachedIframes.forEach(({content:e},t)=>{this.mirror.has(t)?this.mutationCb({adds:[{parentId:t,nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}):this.attachedIframes.delete(t)})}destroy(){this.recordCrossOriginIframes&&Fd(window,"message",this.messageHandler),this.nestedIframeListeners.forEach((e,t)=>{Fd(t,"message",e)}),this.nestedIframeListeners.clear();const e=new Set;this.iframeElementsById.forEach(t=>e.add(t)),this.attachedIframes.forEach(({element:t})=>e.add(t)),e.forEach(e=>{this.disposeLoadListeners(e),this.removePageHideListener(e)}),this.crossOriginIframeMirror.reset(),this.crossOriginIframeStyleMirror.reset(),this.attachedIframes.clear(),this.crossOriginIframeMap=new WeakMap,this.iframes=new WeakMap,this.crossOriginIframeRootIdMap=new WeakMap,this.loadListenerDisposers=new WeakMap,this.pageHideHandlers=new WeakMap,this.attachedDocuments=new WeakMap,this.attachedWindows=new WeakMap,this.iframeElementsById=new Map}},xh=class{constructor(e){Lu(this,"shadowDoms",new WeakSet),Lu(this,"mutationCb",void 0),Lu(this,"scrollCb",void 0),Lu(this,"bypassOptions",void 0),Lu(this,"mirror",void 0),Lu(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){var i,s;if(!Du(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=null!==(i=null===(s=ru.host(e))||void 0===s?void 0:s.ownerDocument)&&void 0!==i?i:t,{observer:r,buffer:o}=ph(ct(ct({},this.bypassOptions),{},{doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push({doc:n,handler(){r.disconnect(),o.destroy(),o.releaseCanvasManager();const e=dh.indexOf(o);-1!==e&&dh.splice(e,1)}}),this.restoreHandlers.push({doc:n,handler:_h(ct(ct({},this.bypassOptions),{},{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))}),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(ru.host(e))),this.restoreHandlers.push({doc:n,handler:bh({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)})},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const i=this;this.restoreHandlers.push({doc:t,handler:nu(e.prototype,"attachShadow",function(e){return function(s){const n=e.call(this,s),r=ru.shadowRoot(this);return r&&Xd(this)&&i.addShadowRoot(r,t),n}})})}reset(){this.restoreHandlers.forEach(({handler:e})=>{try{e()}catch(e){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}resetForDoc(e){const t=[];for(const i of this.restoreHandlers)if(i.doc===e)try{i.handler()}catch(e){}else t.push(i);this.restoreHandlers=t}},Ih="skip-frame";function Th(e){if("object"!=typeof e||null===e)return!1;const{x:t,y:i,width:s,height:n}=e;return Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(s)&&Number.isFinite(n)&&s>=0&&n>=0}for(var Mh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rh="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ph=0;64>Ph;Ph++)Rh[Mh.charCodeAt(Ph)]=Ph;var Fh=function(e){var t,i=new Uint8Array(e),s=i.length,n="";for(t=0;s>t;t+=3)n+=Mh[i[t]>>2],n+=Mh[(3&i[t])<<4|i[t+1]>>4],n+=Mh[(15&i[t+1])<<2|i[t+2]>>6],n+=Mh[63&i[t+2]];return s%3==2?n=n.substring(0,n.length-1)+"=":s%3==1&&(n=n.substring(0,n.length-2)+"=="),n},Lh=new Map,Ah=(e,t,i)=>{if(!e||!$h(e,t)&&"object"!=typeof e)return;const s=function(e,t){let i=Lh.get(e);return i||(i=new Map,Lh.set(e,i)),i.has(t)||i.set(t,[]),i.get(t)}(i,e.constructor.name);let n=s.indexOf(e);return-1===n&&(n=s.length,s.push(e)),n};function Oh(e,t,i,s){if(e instanceof Array)return e.map(e=>Oh(e,t,i,s));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:Fh(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Oh(e.buffer,t,i,s),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:i}=e;return{rr_type:t,src:i}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL(s.type,s.quality)}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Oh(e.data,t,i,s),e.width,e.height]}:$h(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ah(e,t,i)}:e}var Dh=(e,t,i,s)=>e.map(e=>Oh(e,t,i,s)),$h=(e,t)=>{const i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(i.find(i=>e instanceof t[i]))},Nh=["webgl","webgl2"];function Bh(e){return"nodeType"in e}function qh(e,t,i,s){const n=[];try{if(s){const s=function(e,t,i){const s=e.GPUCanvasContext;if((null==s?void 0:s.prototype)&&"function"==typeof s.prototype.configure)return nu(s.prototype,"configure",function(s){return function(n){const r=function(e){const{canvas:t}=e;return t&&"object"==typeof t?t:null}(this);if(!r||Bh(r)&&zd(r,t,i,!0))return s.call(this,n);Bh(r)&&!("__context"in r)&&(r.__context="webgpu");const o=function(e){const t=e.GPUTextureUsage;return t?t.COPY_SRC|t.RENDER_ATTACHMENT:null}(e);return s.call(this,null!==o&&n?ct(ct({},n),{},{usage:"number"==typeof n.usage?n.usage|o:o}):n)}})}(e,t,i);s&&n.push(s)}const r=nu(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(n,...r){const o=function(e){return"experimental-webgl"===e?"webgl":e}(n);if(!zd(this,t,i,!0)&&("__context"in this||(this.__context=o),s&&Nh.includes(o)))if(r[0]&&"object"==typeof r[0]){const e=r[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else r.splice(0,1,{preserveDrawingBuffer:!0});return e.apply(this,[n,...r])}});n.push(r)}catch(e){console.warn("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(e=>e())}}function Hh(e,t,i,s,n,r,o){const a=[],l=Object.getOwnPropertyNames(e);for(const c of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const l=nu(e,c,function(e){return function(...a){const l=e.apply(this,a);if(Ah(l,r,this),this.canvas&&"tagName"in this.canvas&&!zd(this.canvas,s,n,!0)){const e=Dh(a,r,this,o);i(this.canvas,{type:t,property:c,args:e})}return l}});a.push(l)}catch(r){const o=Nd(e,c,{set(e){this.canvas&&"tagName"in this.canvas&&!zd(this.canvas,s,n,!0)&&i(this.canvas,{type:t,property:c,args:[e],setter:!0})}});a.push(o)}return a}var Uh='(function() {\n\t//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/base64-arraybuffer/1.0.2/f63fa6b5c318cf1c9f6bdd1d4292ad2f15f76f2ec78475025a2d44070e896fe9/node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js\n\tvar chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n\tvar lookup = typeof Uint8Array === "undefined" ? [] : /* @__PURE__ */ new Uint8Array(256);\n\tfor (var i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i;\n\tvar encode = function(arraybuffer) {\n\t\tvar bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";\n\t\tfor (i = 0; i < len; i += 3) {\n\t\t\tbase64 += chars[bytes[i] >> 2];\n\t\t\tbase64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n\t\t\tbase64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n\t\t\tbase64 += chars[bytes[i + 2] & 63];\n\t\t}\n\t\tif (len % 3 === 2) base64 = base64.substring(0, base64.length - 1) + "=";\n\t\telse if (len % 3 === 1) base64 = base64.substring(0, base64.length - 2) + "==";\n\t\treturn base64;\n\t};\n\t//#endregion\n\t//#region ../rrweb/src/record/workers/image-bitmap-data-url-worker.ts\n\tconst lastFingerprintMap = /* @__PURE__ */ new Map();\n\tconst transparentFingerprintMap = /* @__PURE__ */ new Map();\n\tconst lastSentAtMap = /* @__PURE__ */ new Map();\n\tconst PROVIDER_KEYFRAME_INTERVAL_MS = 3e4;\n\tfunction hashPixels(data) {\n\t\tconst view = new Uint32Array(data.buffer, data.byteOffset, data.byteLength >>> 2);\n\t\tlet primaryHash = 2166136261;\n\t\tlet secondaryHash = 2654435769;\n\t\tfor (let i = 0; i < view.length; i++) {\n\t\t\tprimaryHash ^= view[i];\n\t\t\tprimaryHash = Math.imul(primaryHash, 16777619);\n\t\t\tsecondaryHash ^= view[i];\n\t\t\tsecondaryHash = Math.imul(secondaryHash, 2246822507);\n\t\t}\n\t\treturn `${(primaryHash >>> 0).toString(16)}:${(secondaryHash >>> 0).toString(16)}`;\n\t}\n\tfunction frameFingerprint(width, height, data) {\n\t\treturn `${width}x${height}:${hashPixels(data)}`;\n\t}\n\tfunction transparentFingerprint(width, height) {\n\t\tconst pixelCount = width * height;\n\t\tlet hash = transparentFingerprintMap.get(pixelCount);\n\t\tif (hash === void 0) {\n\t\t\thash = hashPixels(new Uint8ClampedArray(pixelCount * 4));\n\t\t\ttransparentFingerprintMap.set(pixelCount, hash);\n\t\t}\n\t\treturn `${width}x${height}:${hash}`;\n\t}\n\tconst worker = self;\n\tlet reusableCanvas = null;\n\tlet reusableCtx = null;\n\tworker.onmessage = async function(e) {\n\t\tif ("resetFrameDedup" in e.data) {\n\t\t\tlastFingerprintMap.clear();\n\t\t\treturn;\n\t\t}\n\t\tif ("OffscreenCanvas" in globalThis) {\n\t\t\tconst { id, bitmap, width, height, displayWidth, displayHeight, dataURLOptions, maskRegions } = e.data;\n\t\t\ttry {\n\t\t\t\tif (!reusableCanvas || reusableCanvas.width !== width || reusableCanvas.height !== height) {\n\t\t\t\t\treusableCanvas = new OffscreenCanvas(width, height);\n\t\t\t\t\treusableCtx = reusableCanvas.getContext("2d", { willReadFrequently: true });\n\t\t\t\t}\n\t\t\t\tconst ctx = reusableCtx;\n\t\t\t\tctx.clearRect(0, 0, width, height);\n\t\t\t\tctx.drawImage(bitmap, 0, 0);\n\t\t\t\tbitmap.close();\n\t\t\t\tif (maskRegions) {\n\t\t\t\t\tctx.fillStyle = "black";\n\t\t\t\t\tfor (const region of maskRegions) ctx.fillRect(region.x, region.y, region.width, region.height);\n\t\t\t\t}\n\t\t\t\tconst fingerprint = frameFingerprint(width, height, ctx.getImageData(0, 0, width, height).data);\n\t\t\t\tif (fingerprint === (lastFingerprintMap.get(id) ?? transparentFingerprint(width, height))) {\n\t\t\t\t\tconst lastSentAt = lastSentAtMap.get(id);\n\t\t\t\t\tif (!(maskRegions !== void 0 && lastSentAt !== void 0 && Date.now() - lastSentAt >= PROVIDER_KEYFRAME_INTERVAL_MS)) return worker.postMessage({ id });\n\t\t\t\t}\n\t\t\t\tconst blob = await reusableCanvas.convertToBlob(dataURLOptions);\n\t\t\t\tconst arrayBuffer = await blob.arrayBuffer();\n\t\t\t\tworker.postMessage({\n\t\t\t\t\tid,\n\t\t\t\t\ttype: blob.type,\n\t\t\t\t\tbase64: encode(arrayBuffer),\n\t\t\t\t\tdisplayWidth,\n\t\t\t\t\tdisplayHeight\n\t\t\t\t});\n\t\t\t\tlastFingerprintMap.set(id, fingerprint);\n\t\t\t\tlastSentAtMap.set(id, Date.now());\n\t\t\t} catch {\n\t\t\t\tworker.postMessage({ id });\n\t\t\t}\n\t\t} else {\n\t\t\te.data.bitmap.close();\n\t\t\treturn worker.postMessage({ id: e.data.id });\n\t\t}\n\t};\n\t//#endregion\n})();\n',Wh="undefined"!=typeof self&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Uh],{type:"text/javascript;charset=utf-8"});function zh(e){let t;try{if(t=Wh&&(self.URL||self.webkitURL).createObjectURL(Wh),!t)throw"";const i=new Worker(t,{name:null==e?void 0:e.name});return i.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),i}catch(t){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Uh),{name:null==e?void 0:e.name})}}var jh,Vh,Gh,Qh=class{onFullSnapshot(){var e;null===(e=this.resetFrameDedup)||void 0===e||e.call(this)}acquire(){this.refCount+=1}reset(){this.refCount>0&&(this.refCount-=1),this.refCount>0||this.teardown()}teardown(){this.torndown||(this.torndown=!0,this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers(),null!==this.rafIdTimestamp&&(cancelAnimationFrame(this.rafIdTimestamp),this.rafIdTimestamp=null),null!==this.rafIdFlush&&(cancelAnimationFrame(this.rafIdFlush),this.rafIdFlush=null))}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){Lu(this,"pendingCanvasMutations",new Map),Lu(this,"rafStamps",{latestId:0,invokeId:null}),Lu(this,"mirror",void 0),Lu(this,"mutationCb",void 0),Lu(this,"resetObservers",void 0),Lu(this,"frozen",!1),Lu(this,"locked",!1),Lu(this,"rafIdTimestamp",null),Lu(this,"rafIdFlush",null),Lu(this,"refCount",0),Lu(this,"torndown",!1),Lu(this,"resetFrameDedup",null),Lu(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:i,blockClass:s,blockSelector:n,recordCanvas:r,dataURLOptions:o,resolutionScale:a,canvasMasking:l}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&"all"===t&&this.initCanvasMutationObserver(i,s,n,o),r&&"number"==typeof t&&this.initCanvasFPSObserver(t,i,s,n,{dataURLOptions:o,resolutionScale:a,canvasMasking:l})}initCanvasFPSObserver(e,t,i,s,n){var r=this;if(!("OffscreenCanvas"in t))return;const o="number"==typeof n.resolutionScale&&Number.isFinite(n.resolutionScale)?Math.min(1,Math.max(.1,n.resolutionScale)):1,a=qh(t,i,s,!0),l=new Map;let c;try{c=new zh}catch(e){return}let u=!1;c.onerror=()=>{var e;u=!0,cancelAnimationFrame(h),null===(e=c.terminate)||void 0===e||e.call(c),this.resetFrameDedup=null},this.resetFrameDedup=()=>{c.postMessage({resetFrameDedup:!0})},c.onmessage=e=>{const{id:t}=e.data;if(l.set(t,!1),!("base64"in e.data))return;const{base64:i,type:s,displayWidth:n,displayHeight:r}=e.data;this.mutationCb({id:t,type:zc["2D"],commands:[{property:"clearRect",args:[0,0,n,r]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:i}],type:s}]},0,0,n,r]}],displayWidth:n,displayHeight:r})};const d=1e3/e;let h,p=0;const _=e=>{var a;u||(p&&d>e-p||(p=e,(()=>{const e=[],n=t=>{try{t.querySelectorAll("canvas").forEach(t=>{zd(t,i,s,!0)||e.push(t)}),t.querySelectorAll("*").forEach(e=>{e.shadowRoot&&n(e.shadowRoot)})}catch(e){}};return n(t.document),e})().forEach((a=rt(function*(e){const t=r.mirror.getId(e);if(!l.get(t)&&0!==e.width&&0!==e.height){l.set(t,!0);try{if(["webgl","webgl2"].includes(e.__context)){var i,s;const n=e.getContext(e.__context);if(null==n||null===(i=n.isContextLost)||void 0===i?void 0:i.call(n))return void l.set(t,!1);!1===(null==n||null===(s=n.getContextAttributes())||void 0===s?void 0:s.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=e.clientWidth||e.width,a=e.clientHeight||e.height,u=Math.max(1,Math.round(r*o)),d=Math.max(1,Math.round(a*o)),h=function(e,t,i,s,n,r){if(!e||"function"!=typeof e.regionsFn)return;let o;try{o=e.regionsFn(t)}catch(e){return Ih}if(void 0===o)return;if(!Array.isArray(o)||!o.every(Th))return Ih;const a=i/n,l=s/r;return o.filter(e=>e.width>0&&e.height>0).map(e=>{const t=Math.floor(e.x*a),i=Math.floor(e.y*l);return{x:t,y:i,width:Math.ceil((e.x+e.width)*a)-t,height:Math.ceil((e.y+e.height)*l)-i}})}(n.canvasMasking,e,u,d,r,a);if("skip-frame"===h)return void l.set(t,!1);const p=yield createImageBitmap(e,1>o?{resizeWidth:u,resizeHeight:d,resizeQuality:"medium"}:{resizeWidth:u,resizeHeight:d});c.postMessage({id:t,bitmap:p,width:u,height:d,displayWidth:r,displayHeight:a,dataURLOptions:n.dataURLOptions,maskRegions:h},[p])}catch(e){l.set(t,!1)}}}),function(e){return a.apply(this,arguments)}))),h=requestAnimationFrame(_))};h=requestAnimationFrame(_),this.resetObservers=()=>{var e;a(),cancelAnimationFrame(h),null===(e=c.terminate)||void 0===e||e.call(c),this.resetFrameDedup=null}}initCanvasMutationObserver(e,t,i,s){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const n=qh(e,t,i,!1),r=function(e,t,i,s,n){const r=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const a of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[a])continue;const o=nu(t.CanvasRenderingContext2D.prototype,a,function(r){return function(...o){return zd(this.canvas,i,s,!0)||setTimeout(()=>{const i=Dh(o,t,this,n);e(this.canvas,{type:zc["2D"],property:a,args:i})},0),r.apply(this,o)}});r.push(o)}catch(n){const o=Nd(t.CanvasRenderingContext2D.prototype,a,{set(t){zd(this.canvas,i,s,!0)||e(this.canvas,{type:zc["2D"],property:a,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,s),o=function(e,t,i,s,n){const r=[];return void 0!==t.WebGLRenderingContext&&r.push(...Hh(t.WebGLRenderingContext.prototype,zc.WebGL,e,i,s,t,n)),void 0!==t.WebGL2RenderingContext&&r.push(...Hh(t.WebGL2RenderingContext.prototype,zc.WebGL2,e,i,s,t,n)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,s);this.resetObservers=()=>{n(),r(),o()}}startPendingCanvasMutationFlusher(){this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,this.rafIdTimestamp=requestAnimationFrame(e)};this.rafIdTimestamp=requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const i=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,i)}),this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const i=this.pendingCanvasMutations.get(e);if(!i||-1===t)return;const s=i.map(e=>mn(e,Bc)),{type:n}=i[0];this.mutationCb({id:t,type:n,commands:s}),this.pendingCanvasMutations.delete(e)}},Kh=class{constructor(e){var t;Lu(this,"trackedLinkElements",new WeakSet),Lu(this,"pendingDeferredSheets",new Set),Lu(this,"mutationCb",void 0),Lu(this,"adoptedStyleSheetCb",void 0),Lu(this,"maskAllElementAttributes",void 0),Lu(this,"maskAttributeFn",void 0),Lu(this,"styleMirror",new Jd),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb,this.maskAllElementAttributes=null!==(t=e.maskAllElementAttributes)&&void 0!==t&&t,this.maskAttributeFn=e.maskAttributeFn}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}beginDeferredLinkInlining(e,t){if(-1===t||!e.isConnected)return null;let i=null,s=null;try{s=e.sheet,s&&(i=Gu(s))}catch(e){}if(!i||!s)return Ru(),null;const n=i;let r=!1;const o={sheet:s,invalidate(){r=!0}};this.pendingDeferredSheets.add(o);let a=!1;return{advance:i=>{if(a)return!0;const l=ou(),c=cu();let u=!0;try{if(r)return a=!0,Ru(),!0;if(!n.advance(i))return u=!1,!1;a=!0;const o=n.text();if(!e.isConnected)return!0;let l=null;try{l=e.sheet}catch(e){}return l!==s?(Ru(),!0):o?(this.emitCssTextMutation(e,t,o),!0):(Ru(),!0)}finally{u&&this.pendingDeferredSheets.delete(o),uu(d=ou()-l,null!=(h=c)?h:au)||(Su.totalMs+=d,d>Su.slowestSliceMs&&(Su.slowestSliceMs=d))}var d,h},remainingRules:()=>n.remainingRules(),discard:()=>{this.pendingDeferredSheets.delete(o)}}}onCssomSheetMutation(e){if(e&&0!==this.pendingDeferredSheets.size)for(const t of this.pendingDeferredSheets)t.sheet===e&&(this.pendingDeferredSheets.delete(t),t.invalidate())}inlineDeferredLinkElement(e,t){var i;null===(i=this.beginDeferredLinkInlining(e,t))||void 0===i||i.advance(1/0)}emitCssTextMutation(e,t,i){this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t,attributes:{_cssText:Yu({element:e,name:"_cssText",value:i,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn})}}]})}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const i={id:t,styleIds:[]},s=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{const i=this.styleMirror.add(t);e=i;const n=ou();try{xu(()=>{try{const e=t.rules||t.cssRules;e&&Eu(e)}catch(e){}s.push({styleId:i,rules:Array.from(t.rules||CSSRule,(e,i)=>({rule:Hu(e,t.href),index:i}))})})}finally{Iu(ou()-n)}}i.styleIds.push(e)}s.length>0&&(i.styles=s),this.adoptedStyleSheetCb(i)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet,this.pendingDeferredSheets.clear(),kd.forEach(e=>e.abort()),kd.clear()}trackStylesheetInLinkElement(e){}},Zh=class{constructor(){Lu(this,"nodeMap",new WeakMap),Lu(this,"active",!1)}inOtherBuffer(e,t){const i=this.nodeMap.get(e);return i&&Array.from(i).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},Jh=!1;try{if(2!==Array.from([1],e=>2*e)[0]){var Yh;const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null===(Yh=e.contentWindow)||void 0===Yh?void 0:Yh.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}var Xh=new Qu,ep=new Set([Hc.Mutation,Hc.MediaInteraction,Hc.StyleSheetRule,Hc.CanvasMutation,Hc.Font,Hc.Log,Hc.StyleDeclaration,Hc.AdoptedStyleSheet]);function tp(e){const t=window;if("function"==typeof t.requestIdleCallback){const i=t.requestIdleCallback(e,{timeout:2e3});return{cancel(){var e;return null===(e=t.cancelIdleCallback)||void 0===e?void 0:e.call(t,i)}}}const i=setTimeout(e,250);return{cancel:()=>clearTimeout(i)}}function ip(e={}){let t;const{emit:i,checkoutEveryNms:s,checkoutEveryNth:n,blockClass:r="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:l=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:d=!0,inlineStylesheetBudgetRules:h,maskAllInputs:p,maskInputOptions:_,slimDOMOptions:g,maskInputFn:f,maskTextFn:v,maskAllElementAttributes:m=!1,maskAttributeFn:y,hooks:b,packFn:S,sampling:w={},dataURLOptions:k={},canvasResolutionScale:C,canvasMasking:E,mousemoveWait:x,recordDOM:I=!0,recordCanvas:T=!1,recordCrossOriginIframes:M=!1,recordAfter:R=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:P=!1,collectFonts:F=!1,inlineImages:L=!1,plugins:A,keepIframeSrcFn:O=()=>!1,ignoreCSSAttributes:D=new Set([]),attributeFilter:N,errorHandler:B}=e;lh(B);const q=ct({type:"image/webp",quality:.4,maxBase64ImageLength:1048576},k),H=!M||window.parent===window;let U=!1;if(!H)try{window.parent.document&&(U=!1)}catch(e){U=!0}if(H&&!i)throw new Error("emit function is required");if(!H&&!U)return()=>{};void 0!==x&&void 0===w.mousemove&&(w.mousemove=x),Xh.reset();const W=!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==_?_:{password:!0},z=Md(void 0!==g&&g);let j;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=[].forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=[].forEach)}();let V=0;const G=new Map;let Q,K;const Z=e=>{for(const t of A||[])t.eventProcessor&&(e=t.eventProcessor(e));return S&&!U&&(e=S(e)),e};jh=(e,t)=>{var r;const o=e;if(o.timestamp=Bd(),!(null===(r=dh[0])||void 0===r?void 0:r.isFrozen())||o.type===qc.FullSnapshot||o.type===qc.IncrementalSnapshot&&ep.has(o.data.source)||dh.forEach(e=>e.unfreeze()),H)null==i||i(Z(o),t);else if(U){const e={type:"rrweb",event:Z(o),origin:window.location.origin,isCheckout:t};window.parent.postMessage(e,"*")}if(o.type===qc.FullSnapshot)j=o,V=0;else if(o.type===qc.IncrementalSnapshot){if(o.data.source===Hc.Mutation&&o.data.isAttachIframe)return;V++,(n&&V>=n||s&&o.timestamp-j.timestamp>s)&&Vh(!0)}};const J=e=>{if(e.removes&&e.removes.length>0){const t=e.adds.length>0?new Set(e.adds.map(e=>e.node.id)):null,i=new Set;if(e.adds.length>0)for(const t of e.adds){const e=Xh.getNode(t.node.id);e&&"IFRAME"===e.nodeName&&i.add(e)}e.removes.forEach(({id:e})=>{if(t&&t.has(e))return;const s=te.getIframeElementById(e);s&&i.has(s)?te.forgetIframeId(e):(null==Q||Q(e),te.removeIframeById(e))}),null==K||K(),te.cleanupDetachedIframes()}jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Mutation},e)})},Y=e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Scroll},e)}),X=e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.CanvasMutation},e)}),ee=new Kh({mutationCb:J,adoptedStyleSheetCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.AdoptedStyleSheet},e)}),maskAllElementAttributes:m,maskAttributeFn:y}),te=new Eh({mirror:Xh,mutationCb:J,stylesheetManager:ee,recordCrossOriginIframes:M,wrappedEmit:jh});for(const e of A||[])e.getMirror&&e.getMirror({nodeMirror:Xh,crossOriginIframeMirror:te.crossOriginIframeMirror,crossOriginIframeStyleMirror:te.crossOriginIframeStyleMirror});const ie=new Zh,se=null==E?void 0:E.configured;Gh=new Qh({recordCanvas:T,mutationCb:X,win:window,blockClass:r,blockSelector:o,mirror:Xh,sampling:w.canvas,dataURLOptions:q,resolutionScale:C,canvasMasking:E});const ne=new xh({mutationCb:J,scrollCb:Y,bypassOptions:{blockClass:r,blockSelector:o,maskTextClass:c,maskTextSelector:u,inlineStylesheet:d,maskInputOptions:W,dataURLOptions:q,maskTextFn:v,maskInputFn:f,maskAllElementAttributes:m,maskAttributeFn:y,recordCanvas:T,canvasMaskingConfigured:se,inlineImages:L,sampling:w,slimDOMOptions:z,iframeManager:te,stylesheetManager:ee,canvasManager:Gh,keepIframeSrcFn:O,processedNodeManager:ie,attributeFilter:N},mirror:Xh});Vh=(e=!1)=>{if(I){wu(h);try{jh({type:qc.Meta,data:{href:window.location.href,width:Ud(),height:Hd()}},e),null==t||t.cancel(),t=void 0,ee.reset(),ne.init(),dh.forEach(e=>e.lock());let i=null,s=[];try{i=function(e,t){const{mirror:i=new Qu,blockClass:s="rr-block",blockSelector:n=null,maskTextClass:r="rr-mask",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,canvasMaskingConfigured:u,maskAllInputs:d=!1,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:_=!1,maskAttributeFn:g,slimDOM:f=!1,dataURLOptions:v,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E=()=>!1,maxDepth:x,inlineStylesheetBudgetRules:I}=t||{},T=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,M=Md(f);wu(I);try{return Td(e,{doc:e,mirror:i,blockClass:s,blockSelector:n,maskTextClass:r,maskTextSelector:o,skipChild:!1,inlineStylesheet:a,maskInputOptions:T,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:_,maskAttributeFn:g,slimDOMOptions:M,dataURLOptions:v,inlineImages:l,recordCanvas:c,canvasMaskingConfigured:u,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E,newlyAddedElement:!1,maxDepth:x})}finally{ku()}}(document,{mirror:Xh,blockClass:r,blockSelector:o,maskTextClass:c,maskTextSelector:u,inlineStylesheet:d,maskAllInputs:W,inlineStylesheetBudgetRules:h,maskTextFn:v,maskInputFn:f,maskAllElementAttributes:m,maskAttributeFn:y,slimDOM:z,dataURLOptions:q,recordCanvas:T,canvasMaskingConfigured:se,inlineImages:L,onSerialize(e){Qd(e,Xh)&&te.addIframe(e),Kd(e,Xh)&&ee.trackLinkElement(e),Zd(e)&&ne.addShadowRoot(ru.shadowRoot(e),document)},onIframeLoad(e,t){te.attachIframe(e,t),ne.observeAttachShadow(e)},onIframeListenerRegistered(e,t){te.registerLoadListenerDisposer(e,t)},onStylesheetLoad(e,t){ee.attachLinkElement(e,t)},keepIframeSrcFn:O})}finally{s=Mu()}if(!i)return console.warn("Failed to snapshot the document");if(jh({type:qc.FullSnapshot,data:{node:i,initialOffset:qd(window)}},e),dh.forEach(e=>e.unlock()),Gh.onFullSnapshot(),s.length){const e=function(e,t,i){let s=!1,n=null,r=0,o=null;const a=()=>null!==o||e.length>r,l=()=>{const i=e[r];e[r]=null,r+=1,i&&Ld(()=>{o=t.beginDeferredLinkInlining(i,Xh.getId(i))})},c=()=>{if(!o)return;const e=o;let t=!0;Ld(()=>{t=e.advance(200)}),t&&(o=null)},u=()=>{o||l(),c()},d=e=>{if(n=null,s)return;let t=0;do{try{u()}catch(e){null==o||o.discard(),o=null,Pu(1)}t+=1}while(!s&&a()&&(e?!e.didTimeout&&e.timeRemaining()>5:10>t));s||(a()?n=tp(d):i())};return n=tp(d),{cancel(){s=!0,null==o||o.discard(),o=null,null==n||n.cancel(),n=null},flush(){if(s)return;s=!0,null==n||n.cancel(),n=null;let t=0,u=0;for(;a()&&50>t;){o||l();const e=o;if(e)if(Math.floor(e.remainingRules()/200)+1>50-t)e.discard(),o=null,u+=1;else{try{c()}catch(e){null==o||o.discard(),o=null,u+=1}t+=1}}if(a()||u>0){let t=u+(null!==o?1:0);for(let i=r;e.length>i;i++)null!==e[i]&&(t+=1);Pu(t),null==o||o.discard(),o=null}i()}}}(s,ee,()=>{t===e&&(t=void 0)});t=e}M&&te.reattachIframes(),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ee.adoptStyleSheets(document.adoptedStyleSheets,Xh.getId(document))}finally{ku()}}};try{const e=[];e.push(Pd("pagehide",()=>{try{null==t||t.flush()}catch(e){}t=void 0},window));for(const t of["visibilitychange","freeze","resume"])e.push(Pd(t,lu,document));Q=t=>{const i=G.get(t);i&&(i.forEach(t=>{Ld(t);const i=e.indexOf(t);-1!==i&&e.splice(i,1)}),G.delete(t))},K=()=>{for(const[e]of G){const t=Xh.getNode(e);if(t)try{t.contentDocument&&t.contentDocument.defaultView||null==Q||Q(e)}catch(t){null==Q||Q(e)}else null==Q||Q(e)}};const i=e=>{var t;return uh(Sh)({mutationCb:J,mousemoveCb:(e,t)=>jh({type:qc.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.MouseInteraction},e)}),scrollCb:Y,viewportResizeCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.ViewportResize},e)}),inputCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Input},e)}),mediaInteractionCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.MediaInteraction},e)}),styleSheetRuleCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.StyleSheetRule},e)}),styleDeclarationCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.StyleDeclaration},e)}),canvasMutationCb:X,fontCb:e=>jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Font},e)}),selectionCb(e){jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.Selection},e)})},customElementCb(e){jh({type:qc.IncrementalSnapshot,data:ct({source:Hc.CustomElement},e)})},blockClass:r,ignoreClass:a,ignoreSelector:l,maskTextClass:c,maskTextSelector:u,maskInputOptions:W,inlineStylesheet:d,sampling:w,recordDOM:I,recordCanvas:T,canvasMaskingConfigured:se,inlineImages:L,userTriggeredOnInput:P,collectFonts:F,doc:e,maskInputFn:f,maskTextFn:v,maskAllElementAttributes:m,maskAttributeFn:y,keepIframeSrcFn:O,blockSelector:o,slimDOMOptions:z,dataURLOptions:q,mirror:Xh,iframeManager:te,stylesheetManager:ee,shadowDomManager:ne,processedNodeManager:ie,canvasManager:Gh,ignoreCSSAttributes:D,attributeFilter:N,plugins:(null==A||null===(t=A.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>jh({type:qc.Plugin,data:{plugin:e.name,payload:t}})})))||[]},b)};te.addLoadListener(t=>{try{const s=Xh.getId(t),n=i(t.contentDocument);if("function"==typeof n&&(e.push(n),-1!==s)){let e=G.get(s);e||(e=new Set,G.set(s,e)),e.add(n)}}catch(e){console.warn(e)}}),te.addPageHideListener(e=>{const t=Xh.getId(e);null==Q||Q(t),gh(e)});let s=-1;const n=e=>jh({type:qc.Custom,data:{tag:"rrweb/fullscreen",payload:e}}),h=()=>{var e,t,i,r;const o=document,a=null!==(e=null!==(t=null!==(i=null!==(r=o.fullscreenElement)&&void 0!==r?r:o.webkitFullscreenElement)&&void 0!==i?i:o.mozFullScreenElement)&&void 0!==t?t:o.msFullscreenElement)&&void 0!==e?e:null,l=a?Xh.getId(a):-1;l!==s&&(-1!==s&&n({id:s,enter:!1}),s=l,-1!==l&&n({id:l,enter:!0}))},p=()=>{Vh();const t=i(document);"function"==typeof t&&e.push(t),e.push(Pd("fullscreenchange",h)),e.push(Pd("webkitfullscreenchange",h)),e.push(Pd("mozfullscreenchange",h)),e.push(Pd("MSFullscreenChange",h)),Jh=!0};return["interactive","complete"].includes(document.readyState)?p():(e.push(Pd("DOMContentLoaded",()=>{jh({type:qc.DomContentLoaded,data:{}}),"DOMContentLoaded"===R&&p()})),e.push(Pd("load",()=>{jh({type:qc.Load,data:{}}),"load"===R&&p()},window))),()=>{try{null==t||t.flush()}catch(e){}t=void 0,Ad(e),ie.destroy(),te.removeLoadListener(),te.destroy(),G.clear(),ne.reset(),Xh.reset(),Jh=!1,ch()}}catch(e){console.warn(e)}}ip.addCustomEvent=(e,t)=>{if(!Jh)throw new Error("please add custom event after start recording");jh({type:qc.Custom,data:{tag:e,payload:t}})},ip.freezePage=()=>{dh.forEach(e=>e.freeze())},ip.takeFullSnapshot=e=>{if(!Jh)throw new Error("please take full snapshot after start recording");Vh(e)},ip.mirror=Xh,"Mobile".toLowerCase(),"Tablet".toLowerCase(),new RegExp("Xbox","i"),new RegExp("Nintendo","i"),new RegExp("PlayStation","i"),new RegExp("Windows","i"),Date,Date,"0".repeat(32),"0".repeat(16);var sp=Object.create(null);function np(e){return np="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},np(e)}function rp(e,t,i){return(t=function(e){var t=function(e){if("object"!=np(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=np(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==np(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}sp.Node=Object.create(null),sp.ShadowRoot=Object.create(null),sp.MutationObserver=Object.create(null),sp.Element=Object.create(null);var op=class{constructor(e){rp(this,"fileName",void 0),rp(this,"functionName",void 0),rp(this,"lineNumber",void 0),rp(this,"columnNumber",void 0),this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}toString(){const e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${e}:${t})`:`${this.fileName}:${e}:${t}`}},ap=/(^|@)\S+:\d+/,lp=/^\s*at .*(\S+:\d+|\(native\))/m,cp=/^(eval@)?(\[native code])?$/,up={parse(e){return e?void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(lp)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):[]:[]},extractLocation(e){if(-1===e.indexOf(":"))return[e];const t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error(`Cannot parse given url: ${e}`);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE(e){return e.stack.split("\n").filter(function(e){return!!e.match(lp)},this).map(function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let t=e.replace(/^\s+/,"").replace(/\(eval code/g,"(");const i=t.match(/ (\((.+):(\d+):(\d+)\)$)/);t=i?t.replace(i[0],""):t;const s=t.split(/\s+/).slice(1),n=this.extractLocation(i?i[1]:s.pop());return new op({functionName:s.join(" ")||void 0,fileName:["eval","<anonymous>"].indexOf(n[0])>-1?void 0:n[0],lineNumber:n[1],columnNumber:n[2]})},this)},parseFFOrSafari(e){return e.stack.split("\n").filter(function(e){return!e.match(cp)},this).map(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new op({functionName:e});{const t=/((.*".+"[^@]*)?[^@]*)(?:@)/,i=e.match(t),s=i&&i[1]?i[1]:void 0,n=this.extractLocation(e.replace(t,""));return new op({functionName:s,fileName:n[0],lineNumber:n[1],columnNumber:n[2]})}},this)},parseOpera(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9(e){const t=/Line (\d+).*script (?:in )?(\S+)/i,i=e.message.split("\n"),s=[];for(let e=2,n=i.length;n>e;e+=2){const n=t.exec(i[e]);n&&s.push(new op({fileName:n[2],lineNumber:parseFloat(n[1])}))}return s},parseOpera10(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=e.stacktrace.split("\n"),s=[];for(let e=0,n=i.length;n>e;e+=2){const n=t.exec(i[e]);n&&s.push(new op({functionName:n[3]||void 0,fileName:n[2],lineNumber:parseFloat(n[1])}))}return s},parseOpera11(e){return e.stack.split("\n").filter(function(e){return!!e.match(ap)&&!e.match(/^Error created at/)},this).map(function(e){const t=e.split("@"),i=this.extractLocation(t.pop());return new op({functionName:(t.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)}};function dp(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let i=e.localName;if(!i)break;i=i.toLowerCase();const s=e.parentElement,n=[];if(s.children&&s.children.length>0)for(let e=0;s.children.length>e;e++){const t=s.children[e];t.localName&&t.localName.toLowerCase&&t.localName.toLowerCase()===i&&n.push(t)}n.length>1&&(i+=`:eq(${n.indexOf(e)})`),t=i+(t?">"+t:""),e=s}return t}function hp(e){return Array.isArray(e)}function pp(e){return"object"==typeof e&&null!==e&&!hp(e)}function _p(e,t){if(0===t)return!0;const i=Object.keys(e);for(const s of i)if(pp(e[s])&&_p(e[s],t-1))return!0;return!1}function gp(e,t){const i={numOfKeysLimit:50,depthOfLimit:4};Object.assign(i,t);const s=[],n=[];return JSON.stringify(e,function(e,t){if(s.length>0){const i=s.indexOf(this);~i?s.splice(i+1):s.push(this),~i?n.splice(i,1/0,e):n.push(e),~s.indexOf(t)&&(t=s[0]===t?"[Circular ~]":"[Circular ~."+n.slice(0,s.indexOf(t)).join(".")+"]")}else s.push(t);if(null===t)return t;if(void 0===t)return"undefined";if(pp(r=t)&&Object.keys(r).length>i.numOfKeysLimit||"function"==typeof r||pp(r)&&_p(r,i.depthOfLimit))return function(e){let t=e.toString();return i.stringLengthLimit&&t.length>i.stringLengthLimit&&(t=`${t.slice(0,i.stringLengthLimit)}...`),t}(t);var r;if("bigint"==typeof t)return t.toString()+"n";if(t instanceof Event){const e={};for(const i in t){const s=t[i];e[i]=hp(s)?dp(s.length?s[0]:null):s}return e}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t})}var fp={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function vp(e,t,i){const s=i?Object.assign({},fp,i):fp,n=s.logger;if(!n)return()=>{};let r;r="string"==typeof n?t[n]:n;let o=0,a=!1,l=!0;const c=[];if(s.level.includes("error")){const i=t=>{const i=t.message;e({level:"error",trace:up.parse(t.error).map(e=>e.toString()),payload:[gp(i,s.stringifyOptions)]})};t.addEventListener("error",i),c.push(()=>{t.removeEventListener("error",i)});const n=t=>{let i,n;t.reason instanceof Error?(i=t.reason,n=[gp(`Uncaught (in promise) ${i.name}: ${i.message}`,s.stringifyOptions)]):(i=new Error,n=[gp("Uncaught (in promise)",s.stringifyOptions),gp(t.reason,s.stringifyOptions)]),e({level:"error",trace:up.parse(i).map(e=>e.toString()),payload:n})};t.addEventListener("unhandledrejection",n),c.push(()=>{t.removeEventListener("unhandledrejection",n)})}for(const e of s.level)c.push(u(r,e));return()=>{l=!1,c.forEach(e=>e())};function u(t,i){return t[i]?function(n,r){try{if(!(r in n))return()=>{};const c=n[r],u={next:c},d=(n=>(...r)=>{if(n.apply(t,r),l&&!("assert"===i&&r[0]||a)){a=!0;try{const t=up.parse(new Error).map(e=>e.toString()).splice(1),n=("assert"===i?r.slice(1):r).map(e=>gp(e,s.stringifyOptions));o++,s.lengthThreshold>o?e({level:i,trace:t,payload:n}):o===s.lengthThreshold&&e({level:"warn",trace:[],payload:[gp("The number of log records reached the threshold.")]})}catch(e){n.apply(t,["rrweb logger error:",e,...r])}finally{a=!1}}})(function(...e){return u.next.apply(this,e)});return"function"==typeof d&&(d.prototype=d.prototype||{},Object.defineProperties(d,{__rrweb_original__:{enumerable:!1,value:c},__rrweb_layer__:{enumerable:!1,value:u}})),n[r]=d,()=>{if(n[r]===d)return void(n[r]=u.next);const e=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let t=n[r],i=e(t);for(;i;){if(i.next===d)return void(i.next=u.next);t=i.next,i=e(t)}}}catch(e){return()=>{}}}(t,i):()=>{}}}var mp=e=>({name:"rrweb/console@1",observer:vp,options:e});const yp=()=>{},bp=e=>{var t;if(Ct(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Sp(e,t,i){try{if(!(t in e))return yp;const s={next:e[t]},n=i(function(...e){return s.next.apply(this,e)});return Ct(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=s.next);let i=e[t],r=bp(i);for(;r;){if(r.next===n)return void(r.next=s.next);i=r.next,r=bp(i)}}}catch(e){return yp}}function wp(e,t){var i;const s=function(e){try{return"string"==typeof e?new URL(e).hostname:"url"in e?new URL(e.url).hostname:e.hostname}catch(e){return null}}(e),n={hostname:s,isHostDenied:!1};if(!(null===(i=t.payloadHostDenyList)||void 0===i?void 0:i.length)||!(null==s?void 0:s.trim().length))return n;for(const e of t.payloadHostDenyList)if(s.endsWith(e))return{hostname:s,isHostDenied:!0};return n}const kp=Gn("[Recorder]"),Cp=e=>"navigation"===e.entryType,Ep=e=>"resource"===e.entryType;function xp(e,t){return!!t&&(At(t)||t[e])}function Ip(e){if("undefined"==typeof Request)return!1;if(e instanceof Request)return!0;try{return"[object Request]"==={}.toString.call(e)}catch(e){return!1}}const Tp=["image/","video/","audio/","font/","application/octet-stream","application/pdf","application/zip","application/wasm"];function Mp({type:e,recordBody:t,headers:i,url:s}){function n(e){const t=Object.keys(i).find(e=>"content-type"===e.toLowerCase()),s=t&&i[t];return e.some(e=>null==s?void 0:s.toLowerCase().includes(e))}if(!t)return!1;if(function e(t){try{return"string"==typeof t?t.startsWith("blob:"):t instanceof URL?"blob:"===t.protocol:!!Ip(t)&&e(t.url)}catch(e){return!1}}(s))return!1;if(n(Tp))return!1;if(At(t))return!0;if(kt(t))return n(t);const r=t[e];return At(r)?r:n(r)}function Rp(e,t,i,s,n){return Pp.apply(this,arguments)}function Pp(){return Pp=rt(function*(e,t,i,s,n,r=0){if(r>10)return kp.warn("Failed to get performance entry for request",{url:i,initiatorType:t}),null;const o=function(e,t){for(let i=e.length-1;i>=0;i-=1)if(t(e[i]))return e[i]}(e.performance.getEntriesByName(i),e=>Ep(e)&&e.initiatorType===t&&(It(s)||e.startTime>=s)&&(It(n)||n>=e.startTime));return o||(yield new Promise(e=>setTimeout(e,50*r)),Rp(e,t,i,s,n,r+1))}),Pp.apply(this,arguments)}function Fp({body:e,options:t,url:i}){if(Pt(e))return null;const{hostname:s,isHostDenied:n}=wp(i,t);if(n)return s+" is in deny list";if(Tt(e))return e;if((e=>"u">typeof Document&&e instanceof Document)(e))return e.textContent;if(Ot(e))return lr(e);if(Et(e))try{return JSON.stringify(e)}catch(e){return"[SessionReplay] Failed to stringify response object"}return"[SessionReplay] Cannot read body of type "+toString.call(e)}const Lp=e=>!Rt(e)&&("navigation"===e.entryType||"resource"===e.entryType);function Ap({entry:e,method:t,status:i,networkRequest:s,isInitial:n,start:r,end:o,url:a,initiatorType:l}){r=e?e.startTime:r,o=e?e.responseEnd:o;const c=Math.floor(Date.now()-performance.now()),u=Math.floor(c+(r||0)),d=[ct(ct({},e?e.toJSON():{name:a}),{},{startTime:It(r)?void 0:Math.round(r),endTime:It(o)?void 0:Math.round(o),timeOrigin:c,timestamp:u,method:t,initiatorType:l||(e?e.initiatorType:void 0),status:i,requestHeaders:s.requestHeaders,requestBody:s.requestBody,responseHeaders:s.responseHeaders,responseBody:s.responseBody,isInitial:n})];if(Lp(e))for(const t of e.serverTiming||[])d.push({timeOrigin:c,timestamp:u,startTime:Math.round(e.startTime),name:t.name,duration:t.duration,entryType:"serverTiming"});return d}const Op=["video/","audio/"];function Dp(e){return Et(e)&&Ct(e.getReader)&&Ct(e.tee)}const $p="[SessionReplay] Timeout while trying to read body",Np="[SessionReplay] Failed to read body";function Bp(e){return`${Np}: ${e}`}function qp(e){return`[SessionReplay] Body too large to record (> ${e} bytes)`}function Hp(e,t){if(!t.streamNetworkBody)return function(e){return new Promise(t=>{const i=setTimeout(()=>t($p),500);try{e.clone().text().then(e=>t(e),e=>t(Bp(e))).finally(()=>clearTimeout(i))}catch(e){clearTimeout(i),t(Np)}})}(e);const i=so(t);return function(e,t){try{var i,s;const n=null===(i=e.headers)||void 0===i||null===(s=i.get)||void 0===s?void 0:s.call(i,"content-length");if(!n)return!1;const r=parseInt(n,10);return Number.isFinite(r)&&r>t}catch(e){return!1}}(e,i)?Promise.resolve(qp(i)):function(e,t){return new Promise(i=>{let s,n=!1;function r(){try{null==s||s.cancel().catch(()=>{})}catch(e){}}function o(e){n||(n=!0,clearTimeout(a),r(),i(e))}const a=setTimeout(()=>o($p),500);let l;try{l=e.clone()}catch(e){return void o(Np)}const c=l.body;if(!Dp(c)||"undefined"==typeof TextDecoder){try{l.text().then(e=>o(e),e=>o(Bp(e)))}catch(e){o(Np)}return}try{s=c.getReader()}catch(e){return void o(Np)}const u=[];let d=0;!function e(){s.read().then(({done:i,value:s})=>{if(n)r();else if(i)o((new TextDecoder).decode(function(e,t){const i=new Uint8Array(t);let s=0;for(const t of e)i.set(t,s),s+=t.byteLength;return i}(u,d)));else{if(s){if(d+s.byteLength>t)return void o(qp(t));d+=s.byteLength,u.push(s)}e()}},e=>o(Bp(e)))}()})}(e,i)}function Up(){return Up=rt(function*({r:e,options:t,url:i}){const{hostname:s,isHostDenied:n}=wp(i,t);return n?Promise.resolve(s+" is in deny list"):Hp(e,t)}),Up.apply(this,arguments)}function Wp(){return Wp=rt(function*({r:e,options:t,url:i}){const s=function({r:e,options:t,url:i}){var s;if("chunked"===e.headers.get("Transfer-Encoding"))return"Chunked Transfer-Encoding is not supported";const n=null===(s=e.headers.get("Content-Type"))||void 0===s?void 0:s.toLowerCase(),r=Op.some(e=>null==n?void 0:n.startsWith(e));if(n&&r)return`Content-Type ${n} is not supported`;const{hostname:o,isHostDenied:a}=wp(i,t);return a?o+" is in deny list":null}({r:e,options:t,url:i});return Rt(s)?Hp(e,t):Promise.resolve(s)}),Wp.apply(this,arguments)}let zp=null;function jp(e,t,i){if(!("performance"in t))return()=>{};if(zp)return kp.warn("Network observer already initialised, doing nothing"),()=>{};const s=i?Object.assign({},no,i):no;let n=!0;const r=t=>{if(!n)return;const i=[];let r=!1;t.requests.forEach(e=>{const t="serverTiming"===e.entryType;if(t&&r)return;const n=s.maskRequestFn(e);t||(r=!n||(e=>!!e&&po.has(e))(n)),n&&i.push(n)}),i.length>0&&e(ct(ct({},t),{},{requests:i}))},o=function(e,t,i){i.recordInitialRequests&&e({requests:t.performance.getEntries().filter(e=>Cp(e)||Ep(e)&&i.initiatorTypes.includes(e.initiatorType)).flatMap(e=>Ap({entry:e,method:void 0,status:void 0,networkRequest:{},isInitial:!0})),isInitial:!0});const s=new t.PerformanceObserver(t=>{e({requests:t.getEntries().filter(e=>Cp(e)||Ep(e)&&i.initiatorTypes.includes(e.initiatorType)&&(e=>!i.recordBody&&!i.recordHeaders||"xmlhttprequest"!==e.initiatorType&&"fetch"!==e.initiatorType)(e)).flatMap(e=>Ap({entry:e,method:void 0,status:void 0,networkRequest:{}}))})}),n=PerformanceObserver.supportedEntryTypes.filter(e=>i.performanceEntryTypeToObserve.includes(e));return s.observe({entryTypes:n}),()=>{s.disconnect()}}(r,t,s);let a=()=>{},l=()=>{};return(s.recordHeaders||s.recordBody)&&(a=function(e,t,i){if(!i.initiatorTypes.includes("xmlhttprequest"))return()=>{};const s=xp("request",i.recordHeaders),n=xp("response",i.recordHeaders),r=Sp(t.XMLHttpRequest.prototype,"open",r=>function(o,a,l=!0,c,u){const d=this;try{const r=new Request(a),l={};let c,u;const h={},p=d.setRequestHeader.bind(d);d.setRequestHeader=(e,t)=>(h[e]=t,p(e,t)),s&&(l.requestHeaders=h);const _=d.send.bind(d);d.send=e=>(Mp({type:"request",headers:h,url:a,recordBody:i.recordBody})&&(l.requestBody=Fp({body:e,options:i,url:a})),c=t.performance.now(),_(e));const g=()=>{d.removeEventListener("readystatechange",f),d.removeEventListener("error",g),d.removeEventListener("abort",g),d.removeEventListener("timeout",g)},f=()=>{if(d.readyState!==d.DONE)return;g(),u=t.performance.now();const s={};d.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),i=t.shift(),n=t.join(": ");i&&(s[i]=n)}),n&&(l.responseHeaders=s),Mp({type:"response",headers:s,url:a,recordBody:i.recordBody})&&(l.responseBody=Fp({body:d.response,options:i,url:a})),Rp(t,"xmlhttprequest",r.url,c,u).then(t=>{e({requests:Ap({entry:t,method:o,status:null==d?void 0:d.status,networkRequest:l,start:c,end:u,url:a.toString(),initiatorType:"xmlhttprequest"})})}).catch(()=>{})};d.addEventListener("readystatechange",f),d.addEventListener("error",g),d.addEventListener("abort",g),d.addEventListener("timeout",g)}catch(e){kp.error("Failed to instrument XHR for network capture",e)}r.call(d,o,a.toString(),l,c,u)});return()=>{r()}}(r,t,s),l=function(e,t,i){if(!i.initiatorTypes.includes("fetch"))return()=>{};const s=xp("request",i.recordHeaders),n=xp("response",i.recordHeaders),r=Sp(t,"fetch",r=>function(){var o=rt(function*(o,a){let l,c;try{l=new Request(o,a)}catch(e){return kp.error("Failed to instrument fetch for network capture",e),r(o,a)}const u={};let d,h;try{try{const e={};l.headers.forEach((t,i)=>{e[i]=t}),s&&(u.requestHeaders=e),!Dp(null==a?void 0:a.body)&&Mp({type:"request",headers:e,url:o,recordBody:i.recordBody})&&(u.requestBody=yield function(e){return Up.apply(this,arguments)}({r:l,options:i,url:o}))}catch(e){kp.error("Failed to record fetch request for network capture",e)}d=t.performance.now(),c=Ip(o)?yield r(l):yield r(o,a),h=t.performance.now();try{const e={};c.headers.forEach((t,i)=>{e[i]=t}),n&&(u.responseHeaders=e),Mp({type:"response",headers:e,url:o,recordBody:i.recordBody})&&(u.responseBody=yield function(e){return Wp.apply(this,arguments)}({r:c,options:i,url:o}))}catch(e){kp.error("Failed to record fetch response for network capture",e)}return c}finally{Rp(t,"fetch",l.url,d,h).then(t=>{e({requests:Ap({entry:t,method:l.method,status:null==c?void 0:c.status,networkRequest:u,start:d,end:h,url:l.url,initiatorType:"fetch"})})}).catch(()=>{})}});return function(e,t){return o.apply(this,arguments)}}());return()=>{r()}}(r,t,s)),zp=()=>{n=!1,o(),a(),l(),zp=null},zp}const Vp=e=>({name:"rrweb/network@1",observer:jp,options:e});var Gp,Qp,Kp,Zp,Jp,Yp,Xp,e_,t_,i_,s_,n_,r_,o_,a_;h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.rrwebPlugins={getRecordConsolePlugin:mp,getRecordNetworkPlugin:Vp},h.__PosthogExtensions__.rrweb={record:ip,version:"v2",wasMaxDepthReached:()=>Id,resetMaxDepthState(){Id=!1,xd=!1},getLastSnapshotCost:()=>gu,getMutationCost:()=>ct({},bu),resetSnapshotCostState(){du=0,hu=0,pu=0,au=0,_u={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gu=null,fu=null,vu=[],mu=0,yu=0,bu={slowestBatchMs:0},Su={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0}}},h.rrweb={record:ip,version:"v2"},h.rrwebConsoleRecord={getRecordConsolePlugin:mp},h.getRecordNetworkPlugin=Vp,h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.initSessionRecording=(e,t)=>new Nc(e,t);var l_,c_,u_,d_,h_={},p_=[],__=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,g_=Array.isArray;function f_(e,t){for(var i in t)e[i]=t[i];return e}function v_(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function m_(e,t,i){var s,n,r,o={};for(r in t)"key"==r?s=t[r]:"ref"==r?n=t[r]:o[r]=t[r];if(arguments.length>2&&(o.children=arguments.length>3?Gp.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===o[r]&&(o[r]=e.defaultProps[r]);return y_(e,o,s,n,null)}function y_(e,t,i,s,n){var r={type:e,props:t,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==n?++Kp:n,__i:-1,__u:0};return null==n&&null!=Qp.vnode&&Qp.vnode(r),r}function b_(e){return e.children}function S_(e,t){this.props=e,this.context=t}function w_(e,t){if(null==t)return e.__?w_(e.__,e.__i+1):null;for(var i;e.__k.length>t;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?w_(e):null}function k_(e){if(e.__P&&e.__d){var t=e.__v,i=t.__e,s=[],n=[],r=f_({},t);r.__v=t.__v+1,Qp.vnode&&Qp.vnode(r),L_(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[i]:null,s,null==i?w_(t):i,!!(32&t.__u),n),r.__v=t.__v,r.__.__k[r.__i]=r,O_(s,r,n),t.__e=t.__=null,r.__e!=i&&C_(r)}}function C_(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),C_(e)}function E_(e){(!e.__d&&(e.__d=!0)&&Zp.push(e)&&!x_.__r++||Jp!=Qp.debounceRendering)&&((Jp=Qp.debounceRendering)||Yp)(x_)}function x_(){try{for(var e,t=1;Zp.length;)Zp.length>t&&Zp.sort(Xp),e=Zp.shift(),t=Zp.length,k_(e)}finally{Zp.length=x_.__r=0}}function I_(e,t,i,s,n,r,o,a,l,c,u){var d,h,p,_,g,f,v,m=s&&s.__k||p_,y=t.length;for(l=function(e,t,i,s,n){var r,o,a,l,c,u=i.length,d=u,h=0;for(e.__k=new Array(n),r=0;n>r;r++)null!=(o=t[r])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=e.__k[r]=y_(null,o,null,null,null):g_(o)?o=e.__k[r]=y_(b_,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=e.__k[r]=y_(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[r]=o,l=r+h,o.__=e,o.__b=e.__b+1,a=null,-1!=(c=o.__i=M_(o,i,l,d))&&(d--,(a=i[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(n>u?h--:u>n&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[r]=null;if(d)for(r=0;u>r;r++)null!=(a=i[r])&&!(2&a.__u)&&(a.__e==s&&(s=w_(a)),N_(a,a));return s}(i,t,m,l,y),d=0;y>d;d++)null!=(p=i.__k[d])&&(h=-1!=p.__i&&m[p.__i]||h_,p.__i=d,f=L_(e,p,h,n,r,o,a,l,c,u),_=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&$_(h.ref,null,p),u.push(p.ref,p.__c||_,p)),null==g&&null!=_&&(g=_),(v=!!(4&p.__u))||h.__k===p.__k?(l=T_(p,l,e,v),v&&h.__e&&(h.__e=null)):"function"==typeof p.type&&void 0!==f?l=f:_&&(l=_.nextSibling),p.__u&=-7);return i.__e=g,l}function T_(e,t,i,s){var n,r;if("function"==typeof e.type){for(n=e.__k,r=0;n&&n.length>r;r++)n[r]&&(n[r].__=e,t=T_(n[r],t,i,s));return t}e.__e!=t&&(s&&(t&&e.type&&!t.parentNode&&(t=w_(e)),i.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function M_(e,t,i,s){var n,r,o,a=e.key,l=e.type,c=t[i],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&l==c.type)return i;if(s>(u?1:0))for(n=i-1,r=i+1;n>=0||t.length>r;)if(null!=(c=t[o=0>n?r++:n--])&&!(2&c.__u)&&a==c.key&&l==c.type)return o;return-1}function R_(e,t,i){"-"==t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||__.test(t)?i:i+"px"}function P_(e,t,i,s,n){var r,o;e:if("style"==t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof s&&(e.style.cssText=s=""),s)for(t in s)i&&t in i||R_(e.style,t,"");if(i)for(t in i)s&&i[t]==s[t]||R_(e.style,t,i[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(s_,"$1")),o=t.toLowerCase(),t=o in e||"onFocusOut"==t||"onFocusIn"==t?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=i,i?s?i[i_]=s[i_]:(i[i_]=n_,e.addEventListener(t,r?o_:r_,r)):e.removeEventListener(t,r?o_:r_,r);else{if("http://www.w3.org/2000/svg"==n)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==i?"":i))}}function F_(e){return function(t){if(this.l){var i=this.l[t.type+e];if(null==t[t_])t[t_]=n_++;else if(i[i_]>t[t_])return;return i(Qp.event?Qp.event(t):t)}}}function L_(e,t,i,s,n,r,o,a,l,c){var u,d,h,p,_,g,f,v,m,y,$,b,S,w,k,C,E=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),r=[a=t.__e=i.__e]),(u=Qp.__b)&&u(t);e:if("function"==typeof E){d=o.length;try{if(m=t.props,y=E.prototype&&E.prototype.render,$=(u=E.contextType)&&s[u.__c],b=u?$?$.props.value:u.__:s,i.__c?v=(h=t.__c=i.__c).__=h.__E:(y?t.__c=h=new E(m,b):(t.__c=h=new S_(m,b),h.constructor=E,h.render=B_),$&&$.sub(h),h.state||(h.state={}),h.__n=s,p=h.__d=!0,h.__h=[],h._sb=[]),y&&null==h.__s&&(h.__s=h.state),y&&null!=E.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=f_({},h.__s)),f_(h.__s,E.getDerivedStateFromProps(m,h.__s))),_=h.props,g=h.state,h.__v=t,p)y&&null==E.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),y&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(y&&null==E.getDerivedStateFromProps&&m!==_&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,b),t.__v==i.__v||!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,b)){t.__v!=i.__v&&(h.props=m,h.state=h.__s,h.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(e){e&&(e.__=t)}),p_.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,b),y&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(_,g,f)})}if(h.context=b,h.props=m,h.__P=e,h.__e=!1,S=Qp.__r,w=0,y)h.state=h.__s,h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),p_.push.apply(h.__h,h._sb),h._sb=[];else do{h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&25>++w);h.state=h.__s,null!=h.getChildContext&&(s=f_(f_({},s),h.getChildContext())),y&&!p&&null!=h.getSnapshotBeforeUpdate&&(f=h.getSnapshotBeforeUpdate(_,g)),k=null!=u&&u.type===b_&&null==u.key?D_(u.props.children):u,a=I_(e,g_(k)?k:[k],t,i,s,n,r,o,a,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),v&&(h.__E=h.__=null)}catch(e){if(o.length=d,t.__v=null,l||null!=r)if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;null!=r&&(r[r.indexOf(a)]=null),t.__e=a}else{if(null!=r)for(C=r.length;C--;)v_(r[C]);A_(t)}else t.__e=i.__e,!t.__k&&i.__k&&(t.__k=i.__k),e.then||A_(t);Qp.__e(e,t,i)}}else null==r&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):a=t.__e=function(e,t,i,s,n,r,o,a,l){var c,u,d,h,p,_,g,f=i.props||h_,v=t.props,m=t.type;if("svg"==m?n="http://www.w3.org/2000/svg":"math"==m?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;r.length>c;c++)if((p=r[c])&&"setAttribute"in p==!!m&&(m?p.localName==m:3==p.nodeType)){e=p,r[c]=null;break}if(null==e){if(null==m)return document.createTextNode(v);e=document.createElementNS(n,m,v.is&&v),a&&(Qp.__m&&Qp.__m(t,r),a=!1),r=null}if(null==m)f===v||a&&e.data==v||(e.data=v);else{if(r="textarea"==m&&null!=v.defaultValue?null:r&&Gp.call(e.childNodes),!a&&null!=r)for(f={},c=0;e.attributes.length>c;c++)f[(p=e.attributes[c]).name]=p.value;for(c in f)p=f[c],"dangerouslySetInnerHTML"==c?d=p:"children"==c||c in v||"value"==c&&"defaultValue"in v||"checked"==c&&"defaultChecked"in v||P_(e,c,null,p,n);for(c in v)p=v[c],"children"==c?h=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?_=p:"checked"==c?g=p:a&&"function"!=typeof p||f[c]===p||P_(e,c,p,f[c],n);if(u)a||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),I_("template"==t.type?e.content:e,g_(h)?h:[h],t,i,s,"foreignObject"==m?"http://www.w3.org/1999/xhtml":n,r,o,r?r[0]:i.__k&&w_(i,0),a,l),null!=r)for(c=r.length;c--;)v_(r[c]);a&&"textarea"!=m||(c="value","progress"==m&&null==_?e.removeAttribute("value"):null!=_&&(_!==e[c]||"progress"==m&&!_||"option"==m&&_!=f[c])&&P_(e,c,_,f[c],n),c="checked",null!=g&&g!=e[c]&&P_(e,c,g,f[c],n))}return e}(i.__e,t,i,s,n,r,o,l,c);return(u=Qp.diffed)&&u(t),128&t.__u?void 0:a}function A_(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(A_))}function O_(e,t,i){for(var s=0;i.length>s;s++)$_(i[s],i[++s],i[++s]);Qp.__c&&Qp.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Qp.__e(e,t.__v)}})}function D_(e){return"object"!=typeof e||null==e||e.__b>0?e:g_(e)?e.map(D_):void 0!==e.constructor?null:f_({},e)}function $_(e,t,i){try{if("function"==typeof e){var s="function"==typeof e.__u;s&&e.__u(),s&&null==t||(e.__u=e(t))}else e.current=t}catch(e){Qp.__e(e,i)}}function N_(e,t,i){var s,n;if(Qp.unmount&&Qp.unmount(e),(s=e.ref)&&(s.current&&s.current!=e.__e||$_(s,null,t)),null!=(s=e.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(e){Qp.__e(e,t)}s.base=s.__P=s.__n=null}if(s=e.__k)for(n=0;s.length>n;n++)s[n]&&N_(s[n],t,i||"function"!=typeof e.type);i||v_(e.__e),e.__c=e.__=e.__e=void 0}function B_(e,t,i){return this.constructor(e,i)}function q_(e,t,i){var s,n,r,o;t==document&&(t=document.documentElement),Qp.__&&Qp.__(e,t),n=(s="function"==typeof i)?null:i&&i.__k||t.__k,r=[],o=[],L_(t,e=(!s&&i||t).__k=m_(b_,null,[e]),n||h_,h_,t.namespaceURI,!s&&i?[i]:n?null:t.firstChild?Gp.call(t.childNodes):null,r,!s&&i?i:n?n.__e:t.firstChild,s,o),O_(r,e,o),e.props.children=null}Gp=p_.slice,Qp={__e(e,t,i,s){for(var n,r,o;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e,s||{}),o=n.__d),o)return n.__E=n}catch(t){e=t}throw e}},Kp=0,S_.prototype.setState=function(e,t){var i=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=f_({},this.state);"function"==typeof e&&(e=e(f_({},i),this.props)),e&&f_(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),E_(this))},S_.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),E_(this))},S_.prototype.render=b_,Zp=[],Yp="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Xp=function(e,t){return e.__v.__b-t.__v.__b},x_.__r=0,e_=Math.random().toString(8),t_="__d"+e_,i_="__a"+e_,s_=/(PointerCapture)$|Capture$/i,n_=0,r_=F_(!1),o_=F_(!0),a_=0;var H_=0,U_=[],W_=Qp,z_=W_.__b,j_=W_.__r,V_=W_.diffed,G_=W_.__c,Q_=W_.unmount,K_=W_.__;function Z_(e,t){W_.__h&&W_.__h(c_,e,H_||t),H_=0;var i=c_.__H||(c_.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function J_(e){return H_=1,function(e,t){var i=Z_(l_++,2);if(i.t=e,!i.__c&&(i.__=[lg(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],s=i.t(t,e);t!==s&&(i.__N=[s,i.__[1]],i.__c.setState({}))}],i.__c=c_,!c_.__f)){var s=function(e,t,s){if(!i.__c.__H)return!0;var r=!1,o=i.__c.props!==e;if(i.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),n){var a=n.call(this,e,t,s);return r?a||o:a}return!r||o};c_.__f=!0;var n=c_.shouldComponentUpdate,r=c_.componentWillUpdate;c_.componentWillUpdate=function(e,t,i){if(this.__e){var o=n;n=void 0,s(e,t,i),n=o}r&&r.call(this,e,t,i)},c_.shouldComponentUpdate=s}return i.__N||i.__}(lg,e)}function Y_(e,t){var i=Z_(l_++,3);!W_.__s&&ag(i.__H,t)&&(i.__=e,i.u=t,c_.__H.__h.push(i))}function X_(e){return H_=5,eg(function(){return{current:e}},[])}function eg(e,t){var i=Z_(l_++,7);return ag(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function tg(e){var t=c_.context[e.__c],i=Z_(l_++,9);return i.c=e,t?(null==i.__&&(i.__=!0,t.sub(c_)),t.props.value):e.__}function ig(){for(var e;e=U_.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rg),t.__h.some(og),t.__h=[]}catch(i){t.__h=[],W_.__e(i,e.__v)}}}W_.__b=function(e){c_=null,z_&&z_(e)},W_.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),K_&&K_(e,t)},W_.__r=function(e){j_&&j_(e),l_=0;var t=(c_=e.__c).__H;t&&(u_===c_?(t.__h=[],c_.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.length&&ig(),l_=0)),u_=c_},W_.diffed=function(e){V_&&V_(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==U_.push(t)&&d_===W_.requestAnimationFrame||((d_=W_.requestAnimationFrame)||ng)(ig)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),u_=c_=null},W_.__c=function(e,t){t.some(function(e){try{e.__h.some(rg),e.__h=e.__h.filter(function(e){return!e.__||og(e)})}catch(i){t.some(function(e){e.__h&&(e.__h=[])}),t=[],W_.__e(i,e.__v)}}),G_&&G_(e,t)},W_.unmount=function(e){Q_&&Q_(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.some(function(e){try{rg(e)}catch(e){t=e}}),i.__H=void 0,t&&W_.__e(t,i.__v))};var sg="function"==typeof requestAnimationFrame;function ng(e){var t,i=function(){clearTimeout(s),sg&&cancelAnimationFrame(t),setTimeout(e)},s=setTimeout(i,35);sg&&(t=requestAnimationFrame(i))}function rg(e){var t=c_,i=e.__c;"function"==typeof i&&(e.__c=void 0,i()),c_=t}function og(e){var t=c_;e.__c=e.__(),c_=t}function ag(e,t){return!e||e.length!==t.length||t.some(function(t,i){return t!==e[i]})}function lg(e,t){return"function"==typeof t?t(e):t}const cg={GZipJS:"gzip-js",Base64:"base64"},ug={Activation:"events",Cancellation:"cancelEvents"},dg={Button:"button",Tab:"tab",Selector:"selector"},hg={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},pg={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},_g={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},gg={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},fg={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},vg={Once:"once",Recurring:"recurring",Always:"always"},mg={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},yg={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},bg={Popover:"popover",Inline:"inline"};function Sg(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&Ct(i.then)&&i.then(void 0,()=>{})}}}}const wg=Gn("[Surveys]"),kg="PostHog is not capturing, so a survey response cannot be recorded";function Cg(e){return Ct(e.is_capturing)?e.is_capturing():!e.has_opted_out_capturing()}function Eg(e){return!(!e.start_date||e.end_date)}function xg(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Ig=(e,t)=>`${e}${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`,Tg=e=>Ig("seenSurvey_",e),Mg=e=>{try{const t=Tg(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){wg.error("Failed to persist survey seen state",e)}},Rg=[_g.Popover,_g.Widget,_g.API],Pg={ignoreConditions:!1,ignoreDelay:!1,displayType:bg.Popover},Fg="logs",Lg=Gn("[Stylesheet Loader]"),Ag=e,Og=s,Dg="#020617",$g={fontFamily:"inherit",backgroundColor:"#eeeded",submitButtonColor:"black",submitButtonTextColor:"white",ratingButtonColor:"white",ratingButtonActiveColor:"black",borderColor:"#c9c6c6",whiteLabel:!1,displayThankYouMessage:!0,thankYouMessageHeader:"Thank you for your feedback!",position:hg.Right,widgetType:dg.Tab,widgetLabel:"Feedback",widgetColor:"black",zIndex:String(2147483645),disabledButtonOpacity:"0.6",maxWidth:"300px",textSubtleColor:"#939393",boxPadding:"20px 24px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",borderRadius:"10px",shuffleQuestions:!1,surveyPopupDelaySeconds:void 0,outlineColor:"rgba(59, 130, 246, 0.8)",inputBackground:"white",inputTextColor:Dg,scrollbarThumbColor:"var(--ph-survey-border-color)",scrollbarTrackColor:"var(--ph-survey-background-color)"},Ng=[hg.Center,hg.Left,hg.Right];function Bg(e){if(e.startsWith("#")){let t=e.replace(/^#/,"");return/^[0-9A-Fa-f]{3}$/.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),/^[0-9A-Fa-f]{6}$/.test(t)?`rgb(${parseInt(t.slice(0,2),16)},${parseInt(t.slice(2,4),16)},${parseInt(t.slice(4,6),16)})`:"rgb(255, 255, 255)"}return"rgb(255, 255, 255)"}function qg(e=$g.backgroundColor){let t;"#"===e[0]&&(t=Bg(e)),e.startsWith("rgb")&&(t=e);const i={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}[e.toLowerCase()];if(i&&(t=Bg(i)),!t)return Dg;const s=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(s){const e=parseInt(s[1]),t=parseInt(s[2]),i=parseInt(s[3]);return Math.sqrt(e*e*.299+t*t*.587+i*i*.114)>127.5?Dg:"white"}return Dg}const Hg=(e,t,i)=>{const s=af(e),n=Og.querySelector(`.${s}`);if(n&&n.shadowRoot)return{shadow:n.shadowRoot,isNewlyCreated:!1};const r=Og.createElement("div");((e,t,i)=>{const s=ct(ct({},$g),i),n=e.style,r=!Ng.includes(s.position)||t===_g.Widget&&(null==i?void 0:i.widgetType)===dg.Tab;n.setProperty("--ph-survey-font-family",function(e){if("inherit"===e)return"inherit";const t='BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';return e?`${e}, ${t}`:`-apple-system, ${t}`}(s.fontFamily)),n.setProperty("--ph-survey-box-padding",s.boxPadding),n.setProperty("--ph-survey-max-width",s.maxWidth),n.setProperty("--ph-survey-z-index",s.zIndex),n.setProperty("--ph-survey-border-color",s.borderColor),r?(n.setProperty("--ph-survey-border-radius",s.borderRadius),n.setProperty("--ph-survey-border-bottom","1.5px solid var(--ph-survey-border-color)")):(n.setProperty("--ph-survey-border-bottom","none"),n.setProperty("--ph-survey-border-radius",`${s.borderRadius} ${s.borderRadius} 0 0`)),n.setProperty("--ph-survey-background-color",s.backgroundColor),n.setProperty("--ph-survey-box-shadow",s.boxShadow),n.setProperty("--ph-survey-disabled-button-opacity",s.disabledButtonOpacity),n.setProperty("--ph-survey-submit-button-color",s.submitButtonColor),n.setProperty("--ph-survey-submit-button-text-color",(null==i?void 0:i.submitButtonTextColor)||qg(s.submitButtonColor)),n.setProperty("--ph-survey-rating-bg-color",s.ratingButtonColor),n.setProperty("--ph-survey-rating-active-bg-color",s.ratingButtonActiveColor),n.setProperty("--ph-survey-rating-active-text-color",qg(s.ratingButtonActiveColor)),n.setProperty("--ph-survey-text-primary-color",(null==i?void 0:i.textColor)||qg(s.backgroundColor)),n.setProperty("--ph-survey-text-subtle-color",s.textSubtleColor),n.setProperty("--ph-widget-color",s.widgetColor),n.setProperty("--ph-widget-text-color",qg(s.widgetColor)),n.setProperty("--ph-widget-z-index",s.zIndex);const o=(null==i?void 0:i.inputBackground)||(null==i?void 0:i.inputBackgroundColor);let a=o||s.inputBackground;o||"white"!==s.backgroundColor||(a="#f8f8f8"),n.setProperty("--ph-survey-input-background",a);const l=(null==i?void 0:i.inputTextColor)||qg(a);n.setProperty("--ph-survey-input-text-color",l),n.setProperty("--ph-survey-rating-text-color",l),n.setProperty("--ph-survey-scrollbar-thumb-color",s.scrollbarThumbColor),n.setProperty("--ph-survey-scrollbar-track-color",s.scrollbarTrackColor),n.setProperty("--ph-survey-outline-color",s.outlineColor)})(r,e.type,e.appearance),r.className=s;const o=r.attachShadow({mode:"open"}),a=function(e){const t=((e,t,i)=>{let s=e.createElement("style");s.innerText=t;const n=(e=>{var t;return Ct(e)?e:null==e||null===(t=e.config)||void 0===t?void 0:t.prepare_external_dependency_stylesheet})(i);return n&&(s=n(s)),s||(Lg.error("prepare_external_dependency_stylesheet returned null"),null)})(Og,':host{--ph-survey-font-family:-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--ph-survey-box-padding:20px 24px;--ph-survey-max-width:300px;--ph-survey-z-index:calc(2147480000 + 3645);--ph-survey-border-color:#dcdcdc;--ph-survey-border-bottom:1.5px solid var(--ph-survey-border-color);--ph-survey-border-radius:10px;--ph-survey-background-color:#eeeded;--ph-survey-box-shadow:0 4px 12px #00000026;--ph-survey-submit-button-color:black;--ph-survey-submit-button-text-color:white;--ph-survey-rating-bg-color:white;--ph-survey-rating-text-color:#020617;--ph-survey-rating-active-bg-color:black;--ph-survey-rating-active-text-color:white;--ph-survey-text-primary-color:#020617;--ph-survey-text-subtle-color:#939393;--ph-widget-color:#e0a045;--ph-widget-text-color:white;--ph-survey-scrollbar-thumb-color:var(--ph-survey-border-color);--ph-survey-scrollbar-track-color:var(--ph-survey-background-color);--ph-survey-outline-color:#3b82f6cc;--ph-survey-input-background:white;--ph-survey-input-text-color:#020617;--ph-survey-disabled-button-opacity:.6}.ph-survey{min-width:300px;width:var(--ph-survey-max-width);max-width:85%;z-index:var(--ph-survey-z-index);height:fit-content;margin:0;position:fixed;bottom:0}.ph-survey h3,.ph-survey p{margin:0}.ph-survey *{box-sizing:border-box;font-family:var(--ph-survey-font-family);color:var(--ph-survey-text-primary-color)}.ph-survey textarea,.ph-survey input[type=text],.ph-survey .multiple-choice-options label{color:var(--ph-survey-input-text-color);background:var(--ph-survey-input-background);border:1.5px solid var(--ph-survey-border-color);border-radius:4px;padding:10px;transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey textarea,.ph-survey input[type=text]{transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey input{margin:0}.ph-survey textarea:focus,.ph-survey textarea:focus-visible,.ph-survey input[type=text]:focus,.ph-survey input[type=text]:focus-visible,.ph-survey .form-submit:focus,.ph-survey .form-submit:focus-visible,.ph-survey input[type=checkbox]:focus,.ph-survey input[type=radio]:focus,.ph-survey input[type=checkbox]:focus-visible,.ph-survey input[type=radio]:focus-visible{outline:1.5px solid var(--ph-survey-outline-color);border-color:var(--ph-survey-rating-active-bg-color);outline-offset:2px}.ph-survey textarea:focus:not(:focus-visible),.ph-survey input[type=text]:focus:not(:focus-visible),.ph-survey button:focus:not(:focus-visible),.ph-survey input[type=checkbox]:focus:not(:focus-visible),.ph-survey input[type=radio]:focus:not(:focus-visible){outline:none}.ph-survey textarea:hover:not(:focus),.ph-survey input[type=text]:hover:not(:focus){border-color:var(--ph-survey-rating-active-bg-color)}@media (max-width:768px){.ph-survey textarea,.ph-survey input[type=text]{font-size:1rem}}.ph-survey .multiple-choice-options label,.ph-survey .rating-options-number,.ph-survey .form-cancel,.ph-survey input[type=checkbox],.ph-survey input[type=radio]{border:1.5px solid var(--ph-survey-border-color)}.ph-survey label,.ph-survey input[type=checkbox],.ph-survey input[type=radio],.ph-survey .ratings-emoji,.ph-survey .ratings-number,.ph-survey .footer-branding,.ph-survey .form-cancel,.ph-survey .form-submit{transition:all .2s ease-out}@media (prefers-reduced-motion:no-preference){.ph-survey button:active,.ph-survey input[type=checkbox]:active,.ph-survey input[type=radio]:active,.ph-survey label:active{transition-duration:.1s}}.ph-survey-widget-tab{background:var(--ph-widget-color);color:var(--ph-widget-text-color);text-align:center;cursor:pointer;z-index:var(--ph-survey-z-index);border:none;border-radius:3px 3px 0 0;padding:10px 12px;transition:padding .2s ease-out;position:fixed}.ph-survey-widget-tab:hover:not(.widget-tab-top){padding-bottom:16px}.ph-survey-widget-tab.widget-tab-top{border-radius:0 0 3px 3px}.ph-survey-widget-tab.widget-tab-top:hover{padding-top:16px}@keyframes ph-survey-fade-in{0%{opacity:0}to{opacity:1}}.survey-box{flex-direction:column;gap:16px;display:flex}.bottom-section{flex-direction:column;gap:8px;display:flex}.thank-you-message-header~.bottom-section,.intro-screen-header~.bottom-section{padding-top:16px}.question-container,.thank-you-message,.intro-screen{flex-direction:column;gap:8px;display:flex}.survey-question{font-size:14px;font-weight:500}.survey-question-description{opacity:.8;padding-top:4px;font-size:13px}.survey-question-description,.thank-you-message-body,.intro-screen-body{word-wrap:break-word;overflow-wrap:break-word}:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) img,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) video,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) iframe,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) embed,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) object,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) svg{max-width:100%;height:auto}.question-textarea-wrapper{flex-direction:column;display:flex}.survey-form{animation:.3s ease-out forwards ph-survey-fade-in}.survey-form,.thank-you-message,.intro-screen{text-align:left;width:100%;z-index:var(--ph-survey-z-index);border:1.5px solid var(--ph-survey-border-color);border-bottom:var(--ph-survey-border-bottom);background:var(--ph-survey-background-color);border-radius:var(--ph-survey-border-radius);box-shadow:var(--ph-survey-box-shadow);padding:var(--ph-survey-box-padding);margin:0;position:relative}.survey-form textarea,.survey-form input[type=text]{min-width:100%}.survey-form textarea:focus,.survey-form textarea:focus-visible{box-shadow:0 4px 12px #00000014}.survey-form textarea:focus:not(:focus-visible){box-shadow:none}.survey-box .question-header--empty~.multiple-choice-options,.survey-box .question-header--empty~textarea{margin-top:0}.multiple-choice-options{border:none;flex-direction:column;gap:8px;margin:0;padding:1px 0;font-size:14px;display:flex}.multiple-choice-options label,.multiple-choice-options .response-choice{color:inherit;align-items:center;gap:8px;display:flex}.multiple-choice-options label{cursor:pointer;font-size:13px}.multiple-choice-options label:hover:not(:has(input:checked)){border-color:var(--ph-survey-text-subtle-color);box-shadow:0 2px 8px #00000014}.multiple-choice-options label:has(input:checked){border-color:var(--ph-survey-rating-active-bg-color);box-shadow:0 1px 4px #0000000d}.multiple-choice-options label.choice-option-open{flex-wrap:wrap}.multiple-choice-options label span{color:inherit}.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--ph-survey-input-background);cursor:pointer;z-index:1;border-radius:3px;flex-shrink:0;width:1rem;height:1rem;transition:all .2s cubic-bezier(.4,0,.2,1),transform .15s ease-out;position:relative}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):focus{transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):hover{border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):active{transform:scale(.95)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked{background:var(--ph-survey-rating-active-bg-color);border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked:hover{transform:scale(1.05)}.multiple-choice-options input[type=checkbox]:checked:after{border:solid var(--ph-survey-rating-active-text-color);border-width:0 2px 2px 0;width:4px;height:8px;animation:.2s ease-out .1s forwards ph-survey-checkmark-reveal;left:4px;transform:rotate(45deg)scale(0)}.multiple-choice-options input[type=radio]:checked:after{background:var(--ph-survey-rating-active-text-color);border-radius:50%;width:6px;height:6px;animation:.15s ease-out 50ms forwards ph-survey-radio-reveal;top:5px;left:5px;transform:scale(0)}.multiple-choice-options input[type=checkbox]:checked:after,.multiple-choice-options input[type=radio]:checked:after{content:"";box-sizing:content-box;position:absolute}.multiple-choice-options input[type=radio]{border-radius:50%}.multiple-choice-options input[type=radio]:checked{border:none}:is(.multiple-choice-options input[type=checkbox]:checked,.multiple-choice-options input[type=radio]:checked)~*{font-weight:700}.multiple-choice-options .choice-option-open input[type=text]::placeholder{color:var(--ph-survey-text-subtle-color);font-weight:400}.rating-options-emoji{justify-content:space-between;display:flex}.rating-options-emoji-2{justify-content:space-around}.ratings-emoji{opacity:.5;background-color:#0000;border:none;padding:0;font-size:16px}.ratings-emoji:hover{cursor:pointer;opacity:1;transform:scale(1.15)}.ratings-emoji.rating-active{opacity:1}.ratings-emoji svg{fill:var(--ph-survey-text-primary-color);transition:fill .2s ease-out}.rating-options-number{border-radius:6px;grid-auto-columns:1fr;grid-auto-flow:column;display:grid;overflow:hidden}.rating-options-number .ratings-number{border-right:1px solid var(--ph-survey-border-color);text-align:center;cursor:pointer;color:var(--ph-survey-rating-text-color);border-top:none;border-bottom:none;border-left:none;font-weight:700}.rating-options-number .ratings-number:last-of-type{border-right:0}.rating-options-number .ratings-number.rating-active{background:var(--ph-survey-rating-active-bg-color);color:var(--ph-survey-rating-active-text-color)}.ratings-number{background-color:var(--ph-survey-rating-bg-color);border:none;padding:8px 0}.ratings-number .rating-active{background-color:var(--ph-survey-rating-active-bg-color)}.ratings-number{cursor:pointer}@media (hover:hover) and (pointer:fine){.ratings-number:hover:not(.rating-active){background-color:color-mix(in srgb, var(--ph-survey-rating-active-bg-color) 14%, var(--ph-survey-rating-bg-color))}}.rating-text{opacity:.7;flex-direction:row;justify-content:space-between;font-size:11px;display:flex}.form-buttons{flex-direction:row;gap:8px;width:100%;display:flex}.form-buttons-with-back>.form-submit{flex:auto;min-width:0}.form-submit{text-align:center;cursor:pointer;user-select:none;background:var(--ph-survey-submit-button-color);color:var(--ph-survey-submit-button-text-color);border:none;border-radius:6px;min-width:100%;padding:12px;font-weight:700;box-shadow:0 2px #0000000b}.form-submit:not([disabled]):hover{transform:scale(1.02);box-shadow:0 4px 8px #0000001a}.form-submit:not([disabled]):active{transform:scale(.98);box-shadow:0 1px 2px #0000000d}.form-submit[disabled]{opacity:var(--ph-survey-disabled-button-opacity);cursor:not-allowed}.form-back{text-align:center;cursor:pointer;user-select:none;color:var(--ph-survey-text-primary-color);border:1.5px solid var(--ph-survey-border-color);background:0 0;border-radius:6px;flex:none;padding:12px 16px;font-weight:600}.form-back:hover{transform:scale(1.02)}.form-back:active{transform:scale(.98)}.validation-hint{opacity:.7;margin-top:4px;font-size:12px}.form-cancel{cursor:pointer;background:#fff;border-radius:100%;padding:12px;line-height:0;position:absolute;top:0;right:0;transform:translate(50%,-50%)}.form-cancel:hover{opacity:.7;transform:translate(50%,-50%)scale(1.1)}.footer-branding{opacity:.6;justify-content:center;align-items:center;gap:4px;font-size:11px;font-weight:500;text-decoration:none;display:flex}.footer-branding:hover{opacity:1}.footer-branding a{text-decoration:none}.thank-you-message{text-align:center}.thank-you-message-header{margin:10px 0 0}.thank-you-message-body{opacity:.8;font-size:14px}.intro-screen{text-align:center;animation:.3s ease-out forwards ph-survey-fade-in}.intro-screen-header{margin:10px 0 0}.intro-screen-body{opacity:.8;font-size:14px}.limit-height{scrollbar-width:thin;scrollbar-color:var(--ph-survey-scrollbar-thumb-color) var(--ph-survey-scrollbar-track-color);max-height:256px;overflow:hidden auto}.limit-height::-webkit-scrollbar{width:8px}.limit-height::-webkit-scrollbar-track{background:var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb{background-color:var(--ph-survey-scrollbar-thumb-color);border:2px solid var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb:hover{background-color:var(--ph-survey-text-subtle-color)}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.ph-survey *{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes ph-survey-checkmark-reveal{0%{opacity:0;transform:rotate(45deg)scale(0)}50%{opacity:1;transform:rotate(45deg)scale(1.2)}to{opacity:1;transform:rotate(45deg)scale(1)}}@keyframes ph-survey-radio-reveal{0%{opacity:0;transform:scale(0)}50%{opacity:1;transform:scale(1.3)}to{opacity:1;transform:scale(1)}}',e);return null==t||t.setAttribute("data-ph-survey-style","true"),t}(t);if(a){const e=o.querySelector("style");e&&o.removeChild(e),o.appendChild(a)}return(i||Og.body).appendChild(r),{shadow:o,isNewlyCreated:!0}},Ug=({responses:e,survey:t,surveySubmissionId:i,posthog:s,isSurveyCompleted:n,properties:r,surveyLanguage:o,questionSnapshots:a})=>{var l;s?Cg(s)&&(Mg(t),s.capture(mg.SENT,ct(ct(ct(ct({[yg.SURVEY_NAME]:t.name,[yg.SURVEY_ID]:t.id,[yg.SURVEY_ITERATION]:t.current_iteration,[yg.SURVEY_ITERATION_START_DATE]:t.current_iteration_start_date,[yg.SURVEY_SUBMISSION_ID]:i,[yg.SURVEY_COMPLETED]:n},o&&{[yg.SURVEY_LANGUAGE]:o}),{},{sessionRecordingUrl:null===(l=s.get_session_replay_url)||void 0===l?void 0:l.call(s)},sl(e,t,a)),r),{},{$set:{[rl(t,"responded")]:!0}})),n&&(Ag.dispatchEvent(new CustomEvent("PHSurveySent",{detail:{surveyId:t.id}})),of(t),s.reloadFeatureFlags())):wg.error("[survey sent] event not captured, PostHog instance not found.")},Wg=(e,t,i)=>{var s;return ct(ct({[yg.SURVEY_NAME]:e.name,[yg.SURVEY_ID]:e.id,[yg.SURVEY_ITERATION]:e.current_iteration,[yg.SURVEY_ITERATION_START_DATE]:e.current_iteration_start_date,[yg.SURVEY_PARTIALLY_COMPLETED]:nl(null==t?void 0:t.responses)},(null==t?void 0:t.surveyLanguage)&&{[yg.SURVEY_LANGUAGE]:t.surveyLanguage}),{},{sessionRecordingUrl:null===(s=i.get_session_replay_url)||void 0===s?void 0:s.call(i),[yg.SURVEY_SUBMISSION_ID]:null==t?void 0:t.surveySubmissionId},sl(null==t?void 0:t.responses,e,null==t?void 0:t.questionSnapshots))},zg=(e,t,i,s)=>{if(!t)return void wg.error("[survey dismissed] event not captured, PostHog instance not found.");if(i)return;const n=nf(e),r=n?n.surveyLanguage:s;t.capture(mg.DISMISSED,ct(ct(ct({},Wg(e,n,t)),r&&{[yg.SURVEY_LANGUAGE]:r}),{},{$set:{[rl(e,"dismissed")]:!0}})),of(e),Mg(e),Ag.dispatchEvent(new CustomEvent("PHSurveyClosed",{detail:{surveyId:e.id}}))},jg=(e,t)=>{if(!t)return void wg.error("[survey abandoned] event not captured, PostHog instance not found.");const i=(e=>Ig("abandonedSurvey_",e))(e);try{if("true"===localStorage.getItem(i))return}catch(e){return}const s=nf(e);if(s){try{localStorage.setItem(i,"true")}catch(e){}t.capture(mg.ABANDONED,Wg(e,s,t),{transport:"sendBeacon"})}},Vg=e=>e.map(e=>({sort:Math.floor(10*Math.random()),value:e})).sort((e,t)=>e.sort-t.sort).map(e=>e.value),Gg=(e,t)=>e.length===t.length&&e.every((e,i)=>e===t[i])?t.reverse():t,Qg=e=>{const t=e.map(e=>e.id);return t.every(e=>!!e)?t:void 0},Kg=(e,t)=>{return(e=>e.questions.some(e=>{var t;return!!(null===(t=e.branching)||void 0===t?void 0:t.type)}))(e)?e.questions:t?null!==(i=((e,t)=>{if(!t||t.length!==e.questions.length)return null;const i=new Map(e.questions.map(e=>[e.id,e])),s=[];for(const e of t){const t=i.get(e);if(!t)return null;s.push(t)}return s})(e,t.questionOrder))&&void 0!==i?i:e.questions:e.appearance&&e.appearance.shuffleQuestions&&!e.enable_partial_responses?Gg(e.questions,Vg(e.questions)):e.questions;var i},Zg=e=>hl(e)||rf(e),Jg=function(e){function t(e){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&i.forEach(function(e){e.__e=!0,E_(e)})},this.sub=function(e){i.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i&&i.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+a_++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed(){},isPopup:!0,onPreviewSubmit(){},onPreviewBack(){},surveySubmissionId:"",properties:void 0,surveyLanguage:null}),Yg=()=>tg(Jg),Xg=({component:e,children:t,renderAsHtml:i,style:s})=>function(e,t,i){var s,n,r,o,a=f_({},e.props);for(r in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)"key"==r?s=t[r]:"ref"==r?n=t[r]:a[r]=void 0===t[r]&&null!=o?o[r]:t[r];return arguments.length>2&&(a.children=arguments.length>3?Gp.call(arguments,2):i),y_(e.type,a,s||e.key,n||e.ref,null)}(e,i?{dangerouslySetInnerHTML:{__html:t},style:s}:{children:t,style:s});function ef(e,t){var i,s;if(!(null===(i=e.conditions)||void 0===i?void 0:i.url))return!0;const n=gr(t);if(!n)return!1;const r=[e.conditions.url],o=function(e){return null!=e?e:"icontains"}(null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType);return gl[o](r,[n])}const tf=e=>Ig("inProgressSurvey_",e),sf=(e,t)=>{try{localStorage.setItem(tf(e),JSON.stringify(t))}catch(e){wg.error("Error setting in-progress survey state in localStorage",e)}},nf=e=>{try{const t=localStorage.getItem(tf(e));if(t)return JSON.parse(t)}catch(e){wg.error("Error getting in-progress survey state from localStorage",e)}return null},rf=e=>{const t=nf(e);return!Pt(null==t?void 0:t.surveySubmissionId)},of=e=>{try{localStorage.removeItem(tf(e))}catch(e){wg.error("Error clearing in-progress survey state from localStorage",e)}};function af(e,t=!1){const i=`PostHogSurvey-${e.id}`;return t?`.${i}`:i}function lf(e,t=hg.Right,i){if(e===_g.ExternalSurvey)return{};switch(t){case hg.TopLeft:return{top:"0",left:"0",transform:"translate(30px, 30px)"};case hg.TopRight:return{top:"0",right:"0",transform:"translate(-30px, 30px)"};case hg.TopCenter:return{top:"0",left:"50%",transform:"translate(-50%, 30px)"};case hg.MiddleLeft:return{top:"50%",left:"0",transform:"translate(30px, -50%)"};case hg.MiddleRight:return{top:"50%",right:"0",transform:"translate(-30px, -50%)"};case hg.MiddleCenter:return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case hg.Left:return{left:"30px"};case hg.Center:return{left:"50%",transform:"translateX(-50%)"};default:return{right:e===_g.Widget&&i===dg.Tab?"60px":"30px"}}}var cf=0;function uf(e,t,i,s,n,r){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?o=t[a]:l[a]=t[a];var c={type:e,props:l,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--cf,__i:-1,__u:0,__source:n,__self:r};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return Qp.vnode&&Qp.vnode(c),c}const df=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),hf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),pf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),_f=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z"})}),gf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:uf("path",{d:"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),ff=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:uf("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})}),vf=uf("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:uf("path",{d:"M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z"})}),mf=({fill:e="currentColor"}={})=>uf("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:e,xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"close-survey-title-adam",children:[uf("title",{id:"close-survey-title",className:"adam-testing",children:"Close survey"}),uf("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z",fill:e})]}),yf=uf("svg",{width:"77",height:"14",viewBox:"0 0 77 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[uf("g",{"clip-path":"url(#clip0_2415_6911)",children:[uf("mask",{id:"mask0_2415_6911",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"77",height:"14",children:uf("path",{d:"M0.5 0H76.5V14H0.5V0Z",fill:"white"})}),uf("g",{mask:"url(#mask0_2415_6911)",children:[uf("path",{d:"M5.77226 8.02931C5.59388 8.37329 5.08474 8.37329 4.90634 8.02931L4.4797 7.20672C4.41155 7.07535 4.41155 6.9207 4.4797 6.78933L4.90634 5.96669C5.08474 5.62276 5.59388 5.62276 5.77226 5.96669L6.19893 6.78933C6.26709 6.9207 6.26709 7.07535 6.19893 7.20672L5.77226 8.02931ZM5.77226 12.6946C5.59388 13.0386 5.08474 13.0386 4.90634 12.6946L4.4797 11.872C4.41155 11.7406 4.41155 11.586 4.4797 11.4546L4.90634 10.632C5.08474 10.288 5.59388 10.288 5.77226 10.632L6.19893 11.4546C6.26709 11.586 6.26709 11.7406 6.19893 11.872L5.77226 12.6946Z",fill:"#1D4AFF"}),uf("path",{d:"M0.5 10.9238C0.5 10.508 1.02142 10.2998 1.32637 10.5938L3.54508 12.7327C3.85003 13.0267 3.63405 13.5294 3.20279 13.5294H0.984076C0.716728 13.5294 0.5 13.3205 0.5 13.0627V10.9238ZM0.5 8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.19753 13.3927C5.28831 13.4802 5.41144 13.5294 5.53982 13.5294H8.0421C8.47337 13.5294 8.68936 13.0267 8.3844 12.7327L1.32637 5.92856C1.02142 5.63456 0.5 5.84278 0.5 6.25854V8.67083ZM0.5 4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L10.0368 13.3927C10.1276 13.4802 10.2508 13.5294 10.3791 13.5294H12.8814C13.3127 13.5294 13.5287 13.0267 13.2237 12.7327L1.32637 1.26329C1.02142 0.969312 0.5 1.17752 0.5 1.59327V4.00556ZM5.33931 4.00556C5.33931 4.12932 5.39033 4.24802 5.4811 4.33554L14.1916 12.7327C14.4965 13.0267 15.0179 12.8185 15.0179 12.4028V9.99047C15.0179 9.86671 14.9669 9.74799 14.8762 9.66049L6.16568 1.26329C5.86071 0.969307 5.33931 1.17752 5.33931 1.59327V4.00556ZM11.005 1.26329C10.7 0.969307 10.1786 1.17752 10.1786 1.59327V4.00556C10.1786 4.12932 10.2296 4.24802 10.3204 4.33554L14.1916 8.06748C14.4965 8.36148 15.0179 8.15325 15.0179 7.7375V5.3252C15.0179 5.20144 14.9669 5.08272 14.8762 4.99522L11.005 1.26329Z",fill:"#F9BD2B"}),uf("path",{d:"M21.0852 10.981L16.5288 6.58843C16.2238 6.29443 15.7024 6.50266 15.7024 6.91841V13.0627C15.7024 13.3205 15.9191 13.5294 16.1865 13.5294H23.2446C23.5119 13.5294 23.7287 13.3205 23.7287 13.0627V12.5032C23.7287 12.2455 23.511 12.0396 23.2459 12.0063C22.4323 11.9042 21.6713 11.546 21.0852 10.981ZM18.0252 12.0365C17.5978 12.0365 17.251 11.7021 17.251 11.2901C17.251 10.878 17.5978 10.5436 18.0252 10.5436C18.4527 10.5436 18.7996 10.878 18.7996 11.2901C18.7996 11.7021 18.4527 12.0365 18.0252 12.0365Z",fill:"currentColor"}),uf("path",{d:"M0.5 13.0627C0.5 13.3205 0.716728 13.5294 0.984076 13.5294H3.20279C3.63405 13.5294 3.85003 13.0267 3.54508 12.7327L1.32637 10.5938C1.02142 10.2998 0.5 10.508 0.5 10.9238V13.0627ZM5.33931 5.13191L1.32637 1.26329C1.02142 0.969306 0.5 1.17752 0.5 1.59327V4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L5.33931 8.86412V5.13191ZM1.32637 5.92855C1.02142 5.63455 0.5 5.84278 0.5 6.25853V8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.33931 13.5294V9.79717L1.32637 5.92855Z",fill:"#1D4AFF"}),uf("path",{d:"M10.1787 5.3252C10.1787 5.20144 10.1277 5.08272 10.0369 4.99522L6.16572 1.26329C5.8608 0.969306 5.33936 1.17752 5.33936 1.59327V4.00556C5.33936 4.12932 5.39037 4.24802 5.48114 4.33554L10.1787 8.86412V5.3252ZM5.33936 13.5294H8.04214C8.47341 13.5294 8.6894 13.0267 8.38443 12.7327L5.33936 9.79717V13.5294ZM5.33936 5.13191V8.67083C5.33936 8.79459 5.39037 8.91331 5.48114 9.00081L10.1787 13.5294V9.99047C10.1787 9.86671 10.1277 9.74803 10.0369 9.66049L5.33936 5.13191Z",fill:"#F54E00"}),uf("path",{d:"M29.375 11.6667H31.3636V8.48772H33.0249C34.8499 8.48772 36.0204 7.4443 36.0204 5.83052C36.0204 4.21681 34.8499 3.17334 33.0249 3.17334H29.375V11.6667ZM31.3636 6.84972V4.81136H32.8236C33.5787 4.81136 34.0318 5.19958 34.0318 5.83052C34.0318 6.4615 33.5787 6.84972 32.8236 6.84972H31.3636ZM39.618 11.7637C41.5563 11.7637 42.9659 10.429 42.9659 8.60905C42.9659 6.78905 41.5563 5.45438 39.618 5.45438C37.6546 5.45438 36.2701 6.78905 36.2701 8.60905C36.2701 10.429 37.6546 11.7637 39.618 11.7637ZM38.1077 8.60905C38.1077 7.63838 38.7118 6.97105 39.618 6.97105C40.5116 6.97105 41.1157 7.63838 41.1157 8.60905C41.1157 9.57972 40.5116 10.2471 39.618 10.2471C38.7118 10.2471 38.1077 9.57972 38.1077 8.60905ZM46.1482 11.7637C47.6333 11.7637 48.6402 10.8658 48.6402 9.81025C48.6402 7.33505 45.2294 8.13585 45.2294 7.16518C45.2294 6.8983 45.5189 6.72843 45.9342 6.72843C46.3622 6.72843 46.8782 6.98318 47.0418 7.54132L48.527 6.94678C48.2375 6.06105 47.1677 5.45438 45.8713 5.45438C44.4743 5.45438 43.6058 6.25518 43.6058 7.21372C43.6058 9.53118 46.9663 8.88812 46.9663 9.84665C46.9663 10.1864 46.6391 10.417 46.1482 10.417C45.4434 10.417 44.9525 9.94376 44.8015 9.3735L43.3164 9.93158C43.6436 10.8537 44.6001 11.7637 46.1482 11.7637ZM53.4241 11.606L53.2982 10.0651C53.0843 10.1743 52.8074 10.2106 52.5808 10.2106C52.1278 10.2106 51.8257 9.89523 51.8257 9.34918V7.03172H53.3612V5.55145H51.8257V3.78001H49.9755V5.55145H48.9687V7.03172H49.9755V9.57972C49.9755 11.06 51.0202 11.7637 52.3921 11.7637C52.7696 11.7637 53.122 11.7031 53.4241 11.606ZM59.8749 3.17334V6.47358H56.376V3.17334H54.3874V11.6667H56.376V8.11158H59.8749V11.6667H61.8761V3.17334H59.8749ZM66.2899 11.7637C68.2281 11.7637 69.6378 10.429 69.6378 8.60905C69.6378 6.78905 68.2281 5.45438 66.2899 5.45438C64.3265 5.45438 62.942 6.78905 62.942 8.60905C62.942 10.429 64.3265 11.7637 66.2899 11.7637ZM64.7796 8.60905C64.7796 7.63838 65.3837 6.97105 66.2899 6.97105C67.1835 6.97105 67.7876 7.63838 67.7876 8.60905C67.7876 9.57972 67.1835 10.2471 66.2899 10.2471C65.3837 10.2471 64.7796 9.57972 64.7796 8.60905ZM73.2088 11.4725C73.901 11.4725 74.5177 11.242 74.845 10.8416V11.424C74.845 12.1034 74.2786 12.5767 73.4102 12.5767C72.7935 12.5767 72.2523 12.2854 72.1642 11.788L70.4776 12.0428C70.7042 13.1955 71.925 13.972 73.4102 13.972C75.361 13.972 76.6574 12.8679 76.6574 11.2298V5.55145H74.8324V6.07318C74.4926 5.69705 73.9136 5.45438 73.171 5.45438C71.409 5.45438 70.3014 6.61918 70.3014 8.46345C70.3014 10.3077 71.409 11.4725 73.2088 11.4725ZM72.1012 8.46345C72.1012 7.55345 72.655 6.97105 73.5109 6.97105C74.3793 6.97105 74.9331 7.55345 74.9331 8.46345C74.9331 9.37345 74.3793 9.95585 73.5109 9.95585C72.655 9.95585 72.1012 9.37345 72.1012 8.46345Z",fill:"currentColor"})]})]}),uf("defs",{children:uf("clipPath",{id:"clip0_2415_6911",children:uf("rect",{width:"76",height:"14",fill:"white",transform:"translate(0.5)"})})})]});function bf({urlParams:e}){const t=e?Object.entries(e).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&"):"";return uf("a",{href:"https://posthog.com/surveys"+(t?`?${t}`:""),target:"_blank",rel:"noopener",className:"footer-branding",children:["Survey by ",yf]})}function Sf({text:t,submitDisabled:i,appearance:s,onSubmit:n,link:r,onPreviewSubmit:o,skipSubmitButton:a,canGoBack:l,onBack:c}){const{isPreviewMode:u}=tg(Jg),d=!!l&&!!c,h=!a&&uf("button",{className:"form-submit",disabled:i,"aria-label":"Submit survey",type:"button",onClick(){r&&(null==e||e.open(r)),u?null==o||o():n()},children:t});return uf("div",{className:"bottom-section",children:[d?uf("div",{className:"form-buttons form-buttons-with-back",children:[uf("button",{className:"form-back",type:"button","aria-label":"Go to previous question",onClick:c,children:s.backButtonText||"Back"}),h]}):h,!s.whiteLabel&&uf(bf,{urlParams:{utm_source:"survey-footer"}})]})}function wf({question:e,forceDisableHtml:t,htmlFor:i}){return uf("div",{class:e.question||e.description?"question-header":"question-header question-header--empty",children:[uf(e.type===gg.Open?"label":"h3",{className:"survey-question",htmlFor:i,children:e.question}),e.description&&Xg({component:m_("p",{className:"survey-question-description"}),children:e.description,renderAsHtml:!t&&"text"!==e.descriptionContentType})]})}function kf({onClick:e}){const{isPreviewMode:t}=tg(Jg);return uf("button",{className:"form-cancel",onClick:e,disabled:t,"aria-label":"Close survey",type:"button",children:mf({fill:"black"})})}const Cf=e;function Ef({header:e,description:t,contentType:i,forceDisableHtml:s,appearance:n,onClose:r}){const{isPopup:o}=tg(Jg);return Y_(()=>{const e=e=>{"Enter"!==e.key&&"Escape"!==e.key||(e.preventDefault(),r())};return sr(Cf,"keydown",e),()=>{Cf.removeEventListener("keydown",e)}},[r]),uf("div",{className:"thank-you-message",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==n.hideCancelButton&&uf(kf,{onClick:()=>r()}),uf("h3",{className:"thank-you-message-header",children:e}),t&&Xg({component:m_("p",{className:"thank-you-message-body"}),children:t,renderAsHtml:!s&&"text"!==i}),o&&uf(Sf,{text:n.thankYouMessageCloseButtonText||"Close",submitDisabled:!1,appearance:n,onSubmit:()=>r()})]})}function xf({header:e,description:t,contentType:i,forceDisableHtml:s,appearance:n,onStart:r}){const{isPopup:o,onPreviewSubmit:a,onPopupSurveyDismissed:l}=tg(Jg);return uf("div",{className:"intro-screen",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==n.hideCancelButton&&uf(kf,{onClick:()=>l()}),e&&uf("h3",{className:"intro-screen-header",children:e}),t&&Xg({component:m_("p",{className:"intro-screen-body"}),children:t,renderAsHtml:!s&&"text"!==i}),uf(Sf,{text:n.introScreenButtonText||"Get started",submitDisabled:!1,appearance:n,onSubmit:r,onPreviewSubmit:()=>a(null)})]})}const If=e=>kt(e)&&e.every(e=>Tt(e));function Tf({question:e,forceDisableHtml:t,appearance:i,onSubmit:s,onPreviewSubmit:n,displayQuestionIndex:r,initialValue:o,canGoBack:a,onBack:l}){const{isPreviewMode:c}=Yg(),u=X_(null),[d,h]=J_(()=>Tt(o)?o:""),p=null==i?void 0:i.disableAutofocus;Y_(()=>{p||setTimeout(()=>{var e;c||null===(e=u.current)||void 0===e||e.focus()},100)},[c,p]);const _=`surveyQuestion${r}`,g=eg(()=>function(e,t,i){const s=e.trim();if(!i&&""===s)return"This field is required";if(""===s)return!1;if(t&&t.length>0)for(const e of t)switch(e.type){case ht:var n;if(void 0!==e.value&&e.value>s.length)return null!==(n=e.errorMessage)&&void 0!==n?n:`Please enter at least ${e.value} characters`;break;case pt:var r;if(void 0!==e.value&&s.length>e.value)return null!==(r=e.errorMessage)&&void 0!==r?r:`Please enter no more than ${e.value} characters`}return!1}(d,e.validation,e.optional),[d,e.validation,e.optional]),f=Un(e.validation,ht),v=Un(e.validation,pt),m=eg(()=>function(e,t){const i=1===e?void 0:e;return i&&t?`Enter ${i}-${t} characters`:i?`Enter at least ${i} ${1===i?"character":"characters"}`:t?`Maximum ${t} ${1===t?"character":"characters"}`:void 0}(f,v),[f,v]),y=()=>{g||s(d.trim())},b=()=>{g||n(d.trim())};return uf(b_,{children:[uf("div",{className:"question-container",children:[uf(wf,{question:e,forceDisableHtml:t,htmlFor:_}),uf("textarea",{ref:u,id:_,rows:4,placeholder:null==i?void 0:i.placeholder,minLength:f,maxLength:v,onInput(e){h(e.currentTarget.value),e.stopPropagation()},onKeyDown(e){e.stopPropagation(),"Enter"!==e.key||!e.metaKey&&!e.ctrlKey||g||(e.preventDefault(),c?b():y())},value:d}),m&&uf("div",{className:"validation-hint",children:m})]}),uf(Sf,{text:e.buttonText||"Submit",submitDisabled:!!g,appearance:i,onSubmit:y,onPreviewSubmit:b,canGoBack:a,onBack:l})]})}function Mf({question:e,forceDisableHtml:t,appearance:i,onSubmit:s,onPreviewSubmit:n,canGoBack:r,onBack:o}){return uf(b_,{children:[uf("div",{className:"question-container",children:uf(wf,{question:e,forceDisableHtml:t})}),uf(Sf,{text:e.buttonText||"Submit",submitDisabled:!1,link:e.link,appearance:i,onSubmit:()=>s("link clicked"),onPreviewSubmit:()=>n("link clicked"),canGoBack:r,onBack:o})]})}function Rf({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:s,onSubmit:n,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){var c;const u=e.scale,d=10===e.scale?0:1,[h,p]=J_(()=>Ft(o)?o:kt(o)&&o.length>0&&Ft(parseInt(o[0]))?parseInt(o[0]):Tt(o)&&Ft(parseInt(o))?parseInt(o):null),_="emoji"===e.display&&2===e.scale,{isPreviewMode:g}=Yg(),f=e=>g?r(e):n(e);return uf(b_,{children:[uf("div",{className:"question-container",children:[uf(wf,{question:e,forceDisableHtml:t}),uf("div",{className:"rating-section",children:[uf("div",{className:"rating-options",children:["emoji"===e.display&&uf("div",{className:"rating-options-emoji"+(_?" rating-options-emoji-2":""),children:null===(c=Df[e.scale])||void 0===c?void 0:c.map((t,s)=>uf("button",{"aria-label":`Rate ${s+1}`,className:`ratings-emoji question-${i}-rating-${s} ${s+1===h?"rating-active":""}`,value:s+1,type:"button",onClick(){const t=s+1;p(t),e.skipSubmitButton&&f(t)},children:t},s))}),"number"===e.display&&uf("div",{className:"rating-options-number",style:{gridTemplateColumns:`repeat(${u-d+1}, minmax(0, 1fr))`},children:$f(e.scale).map((t,n)=>uf(Pf,{displayQuestionIndex:i,active:h===t,appearance:s,num:t,setActiveNumber(t){p(t),e.skipSubmitButton&&f(t)}},n))})]}),!_&&uf("div",{className:"rating-text",children:[uf("div",{children:e.lowerBoundLabel}),uf("div",{children:e.upperBoundLabel})]})]})]}),uf(Sf,{text:e.buttonText||(null==s?void 0:s.submitButtonText)||"Submit",submitDisabled:Rt(h)&&!e.optional,appearance:s,onSubmit:()=>n(h),onPreviewSubmit:()=>r(h),skipSubmitButton:e.skipSubmitButton,canGoBack:a,onBack:l})]})}function Pf({num:e,active:t,displayQuestionIndex:i,setActiveNumber:s}){return uf("button",{"aria-label":`Rate ${e}`,className:`ratings-number question-${i}-rating-${e} ${t?"rating-active":""}`,type:"button",onClick(){s(e)},children:e})}function Ff({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:s,onSubmit:n,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){const c=X_(null),u=eg(()=>(e=>{if(!e.shuffleOptions)return e.choices;const t=e.choices;let i="";e.hasOpenChoice&&(i=t.pop());const s=Gg(t,Vg(t));return e.hasOpenChoice&&(e.choices.push(i),s.push(i)),s})(e),[e]),[d,h]=J_(()=>((e,t)=>Tt(e)||If(e)?e:t===gg.SingleChoice?null:[])(o,e.type)),[p,_]=J_(()=>((e,t)=>{if(Tt(e)&&!t.includes(e))return{isSelected:!0,inputValue:e};if(If(e)){const i=e.find(e=>!t.includes(e));if(i)return{isSelected:!0,inputValue:i}}return{isSelected:!1,inputValue:""}})(o,u)),{isPreviewMode:g}=Yg(),f=e.type===gg.SingleChoice,v=e.type===gg.MultipleChoice,m=e.skipSubmitButton&&f&&!e.hasOpenChoice,y=(e,t)=>{if(t){const e=!p.isSelected;return _(t=>ct(ct({},t),{},{isSelected:e,inputValue:e?t.inputValue:""})),f&&h(""),void(e&&setTimeout(()=>{var e;return null===(e=c.current)||void 0===e?void 0:e.focus()},75))}if(f)return h(e),_(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),void(m&&(n(e),g&&r(e)));v&&kt(d)&&(d.includes(e)?h(d.filter(t=>t!==e)):h([...d,e]))},b=e=>{e.stopPropagation();const t=e.currentTarget.value;_(e=>ct(ct({},e),{},{inputValue:t})),f&&h(t)},S=e=>{e.stopPropagation(),"Enter"!==e.key||w()||(e.preventDefault(),k()),"Escape"===e.key&&(e.preventDefault(),_(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),f&&h(null))},w=()=>!(e.optional||!Rt(d)&&(!kt(d)||p.isSelected||0!==d.length)&&(!p.isSelected||""!==p.inputValue.trim())),k=()=>{p.isSelected&&v?kt(d)&&(g?r([...d,p.inputValue]):n([...d,p.inputValue])):g?r(d):n(d)};return uf(b_,{children:[uf("div",{className:"question-container",children:[uf(wf,{question:e,forceDisableHtml:t}),uf("fieldset",{className:"multiple-choice-options limit-height",children:[uf("legend",{className:"sr-only",children:v?" Select all that apply":" Select one"}),u.map((t,s)=>{const n=!!e.hasOpenChoice&&s===e.choices.length-1,r=`surveyQuestion${i}Choice${s}`,o=`${r}Open`,a=n?p.isSelected:f?d===t:kt(d)&&d.includes(t);return uf("label",{className:n?"choice-option-open":"",children:[uf("div",{className:"response-choice",children:[uf("input",{type:f?"radio":"checkbox",name:r,checked:a,onChange:()=>y(t,n),id:r,"aria-controls":o}),uf("span",{children:n?`${t}:`:t})]}),n&&uf("input",{type:"text",ref:c,id:o,name:`question${i}Open`,value:p.inputValue,onKeyDown:S,onInput:b,onClick(e){p.isSelected||y(t,!0),e.stopPropagation()},"aria-label":`${t} - please specify`})]},s)})]})]}),uf(Sf,{text:e.buttonText||"Submit",submitDisabled:w(),appearance:s,onSubmit:k,onPreviewSubmit:k,skipSubmitButton:m,canGoBack:a,onBack:l})]})}const Lf=[1,2,3,4,5],Af=[1,2,3,4,5,6,7],Of=[0,1,2,3,4,5,6,7,8,9,10],Df={2:[ff,vf],3:[pf,hf,df],5:[_f,pf,hf,df,gf]};function $f(e){switch(e){case 5:default:return Lf;case 7:return Af;case 10:return Of}}const Nf=Gn("[Surveys]");function Bf(e,t,i){var s;const n=e.questions[t],r=t+1;if(!(null===(s=n.branching)||void 0===s?void 0:s.type))return t===e.questions.length-1?fg.End:r;if(n.branching.type===fg.End)return fg.End;if(n.branching.type===fg.SpecificQuestion){if(Number.isInteger(n.branching.index))return n.branching.index}else if(n.branching.type===fg.ResponseBased){if(n.type===gg.SingleChoice){var o;let e=n.choices.indexOf(`${i}`);if(-1===e&&n.hasOpenChoice&&(e=n.choices.length-1),null===(o=n.branching)||void 0===o||null===(o=o.responseValues)||void 0===o?void 0:o.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fg.End?fg.End:r}}else if(n.type===gg.Rating){var a;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");const e=function(e,t){if(2===t){if(1>e||e>2)throw new Error("The response must be in range 1-2");return 1===e?"positive":"negative"}if(3===t){if(1>e||e>3)throw new Error("The response must be in range 1-3");return 1===e?"negative":2===e?"neutral":"positive"}if(5===t){if(1>e||e>5)throw new Error("The response must be in range 1-5");return e>2?3===e?"neutral":"positive":"negative"}if(7===t){if(1>e||e>7)throw new Error("The response must be in range 1-7");return e>3?4===e?"neutral":"positive":"negative"}if(10===t){if(0>e||e>10)throw new Error("The response must be in range 0-10");return e>6?e>8?"promoters":"passives":"detractors"}throw new Error("The scale must be one of: 2, 3, 5, 7, 10")}(i,n.scale);if(null===(a=n.branching)||void 0===a||null===(a=a.responseValues)||void 0===a?void 0:a.hasOwnProperty(e)){const t=n.branching.responseValues[e];return Number.isInteger(t)?t:t===fg.End?fg.End:r}}return r}return Nf.warn("Falling back to next question index due to unexpected branching type"),r}const qf=Gn("[SurveyTranslations]");function Hf(e,t){const i=function(e){return function({overrideLanguage:e,storedPersonProperties:t,locale:i},s){const n=ol(e);if(n)return null==s||s.info(`Using override display language: ${n}`),n;const r=function(e){return e&&"object"==typeof e&&"language"in e?ol(e.language):null}(t);if(r)return null==s||s.info(`Using person property language: ${r}`),r;const o=ol(i);return o?(null==s||s.info(`Using detected locale: ${o}`),o):(null==s||s.info("No user language detected"),null)}({overrideLanguage:e.config.override_display_language,storedPersonProperties:Ct(e.get_property)?e.get_property(ae):void 0,locale:Fl()},qf)}(t);if(!i)return qf.info("No user language detected"),{survey:e,language:null};const s=ul(e,i,qf);return{survey:s.survey,language:s.matchedKey}}const Uf=e,Wf=s,zf="ph:show_survey_widget",jf="PHWidgetSurveyClickListener";function Vf(e,t){try{const i=e.getBoundingClientRect(),s=Uf.innerHeight,n=Uf.innerWidth;let r=i.left+i.width/2-t/2;r+t>n-20&&(r=n-t-20),20>r&&(r=20);const o=s-i.bottom,a=250>o&&i.top>o;return{position:"fixed",top:a?"auto":`${i.bottom+12}px`,left:`${r}px`,right:"auto",bottom:a?s-i.top+12+"px":"auto",zIndex:$g.zIndex}}catch(e){return wg.warn("Failed to calculate trigger position:",e),null}}var Gf=class{constructor(e){this._surveyTimeouts=new Map,this._widgetSelectorListeners=new Map,this._renderedTabWidgets=new Map,this._renderedTargets=new Map,this._prefillHandledSurveys=new Set,this._currentLanguage=null,this._surveyIsRendered=!1,this._languageChangeListener=null,this._unsubscribeFeatureFlags=null,this._surveyPopupProps=null,this._loggedFeatureFlagsDisabledWarning=!1,this.handlePageUnload=()=>{const e=this._posthog.get_property(ue);if(e)for(const t of e)rf(t)&&jg(t,this._posthog)},this.handlePopoverSurvey=(e,t,{resumeDelayFromActivation:i=!1}={})=>{var s,n,r,o,a,l;if(!Cg(this._posthog))return;const{survey:c,language:u}=this._translateSurveyForRendering(e);this._currentLanguage=u,this._surveyPopupProps=null,this._displayOptions=t;const d=this._applyDisplayOverrides(c,t);this._clearSurveyTimeout(d.id);const{properties:h,initialResponses:p}=null!=t?t:{},_=!(!p||0>=Object.keys(p).length)&&this._handleInitialResponses(d,p,h,u);if(_&&!(null===(s=d.appearance)||void 0===s?void 0:s.displayThankYouMessage))return;this._addSurveyToFocus(d);let g={};if((null===(n=d.appearance)||void 0===n?void 0:n.position)===hg.NextToTrigger&&(null===(r=d.appearance)||void 0===r?void 0:r.widgetSelector)){const e=Wf.querySelector(d.appearance.widgetSelector);var f;e&&(g=Vf(e,parseInt((null===(f=d.appearance)||void 0===f?void 0:f.maxWidth)||$g.maxWidth))||{})}const v=(null===(o=d.appearance)||void 0===o?void 0:o.surveyPopupDelaySeconds)||0,{shadow:m}=Hg(d,this._posthog);this._renderedTargets.set(m,m.host);const y={posthog:this._posthog,survey:d,removeSurveyFromFocus:this._removeSurveyFromFocus,properties:h,style:g,isSurveyCompleted:_,skipShownEvent:null==t?void 0:t.skipShownEvent,surveyLanguage:u};if(this._surveyPopupProps=y,0>=v)return this._surveyIsRendered=!0,q_(uf(Yf,ct({},y)),m);const b=()=>{this._surveyIsRendered=!0;const{survey:i,language:s}=this._translateSurveyForRendering(e);this._currentLanguage=s;const n=this._applyDisplayOverrides(i,t),r=ct(ct({},y),{},{survey:n,surveyLanguage:s});this._surveyPopupProps=r,q_(uf(Yf,ct(ct({},r),{},{survey:ct(ct({},n),{},{appearance:ct(ct({},n.appearance),{},{surveyPopupDelaySeconds:0})})})),m)},S=()=>{if(!Cg(this._posthog)||!this._shouldDisplaySurvey(d))return wg.info(`Survey ${d.id} no longer eligible when its display delay elapsed; not displaying`),this._removeSurveyFromFocus(d);b()},w=i?null===(a=this._posthog.surveys)||void 0===a||null===(a=a._surveyEventReceiver)||void 0===a||null===(l=a.getActivationTimestamp)||void 0===l?void 0:l.call(a,d.id):void 0,k=Ft(w)?Math.max(0,Date.now()-w):0,C=Math.max(0,1e3*v-k);if(0>=C)return S();const E=Uf.setTimeout(()=>{this._surveyTimeouts.delete(d.id),S()},C);this._surveyTimeouts.set(d.id,E)},this._handleWidget=e=>{var t;const{survey:i,language:s}=this._translateSurveyForRendering(e),{shadow:n,isNewlyCreated:r}=Hg(i,this._posthog);this._renderedTargets.set(n,n.host),(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===dg.Tab&&this._renderedTabWidgets.set(e.id,e),r&&q_(uf(ev,{posthog:this._posthog,survey:i,surveyLanguage:s},e.id),n)},this._detachWidgetSelectorListener=e=>{const t=this._widgetSelectorListeners.get(e);t&&(t.element.removeEventListener("click",t.listener),t.element.removeAttribute(jf),this._widgetSelectorListeners.delete(e),wg.info(`Removed click listener for survey ${e}`))},this._removeWidgetSelectorListener=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._detachWidgetSelectorListener(e.id))},this._removeTabWidget=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._renderedTabWidgets.delete(e.id))},this._isWidgetSurveyOpen=e=>{try{var t;const i=Wf.querySelector(af(e,!0));return!!(null==i||null===(t=i.shadowRoot)||void 0===t?void 0:t.querySelector(".ph-survey"))}catch(e){return!1}},this._manageWidgetSelectorListener=(e,t)=>{const i=Wf.querySelector(t),s=this._widgetSelectorListeners.get(e.id);if(i){if(this._handleWidget(e),s){if(i===s.element)return;wg.info(`Selector element changed for survey ${e.id}. Re-attaching listener.`),this._detachWidgetSelectorListener(e.id)}if(!i.hasAttribute(jf)){const t=t=>{var i,s;t.stopPropagation();const n=(null===(i=e.appearance)||void 0===i?void 0:i.position)===hg.NextToTrigger?Vf(t.currentTarget,parseInt((null===(s=e.appearance)||void 0===s?void 0:s.maxWidth)||$g.maxWidth)):{};Uf.dispatchEvent(new CustomEvent(zf,{detail:{surveyId:e.id,position:n}}))};sr(i,"click",t),i.setAttribute(jf,"true"),this._widgetSelectorListeners.set(e.id,{element:i,listener:t,survey:e}),wg.info(`Attached click listener for feedback button survey ${e.id}`)}}else s&&this._removeWidgetSelectorListener(e)},this.renderPopover=e=>{if(!Cg(this._posthog))return;const{survey:t,language:i}=this._translateSurveyForRendering(e),{shadow:s}=Hg(t,this._posthog);this._renderedTargets.set(s,s.host),q_(uf(Yf,{posthog:this._posthog,survey:t,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:i}),s)},this.renderSurvey=(e,t,i)=>{var s;if(!Cg(this._posthog))return;const{survey:n,language:r}=this._translateSurveyForRendering(e);let o=!1;(null===(s=this._posthog.config)||void 0===s||null===(s=s.surveys)||void 0===s?void 0:s.prefillFromUrl)&&(o=this._handleUrlPrefill(n,r,i)),q_(uf(Yf,{posthog:this._posthog,survey:n,removeSurveyFromFocus:this._removeSurveyFromFocus,isPopup:!1,properties:i,isSurveyCompleted:o,surveyLanguage:r}),t)},this.getActiveMatchingSurveys=(e,t=!1)=>{var i;null===(i=this._posthog)||void 0===i||null===(i=i.surveys)||void 0===i||i.getSurveys(t=>{e(t.filter(e=>this._shouldDisplaySurvey(e)))},t)},this.callSurveysAndEvaluateDisplayLogic=(e=!1)=>{this.getActiveMatchingSurveys(e=>{const t=Cg(this._posthog),i=e.filter(e=>t&&(e.type===_g.Popover||e.type===_g.Widget)),s=new Set(i.map(e=>e.id));for(const e of Array.from(this._surveyTimeouts.keys()))s.has(e)||this.cancelSurvey(e);const n=this._sortSurveysByAppearanceDelay(i),r=new Set,o=new Set;n.forEach(e=>{if(e.type===_g.Widget){var t,i,s,n;if((null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===dg.Tab)return o.add(e.id),void this._handleWidget(e);(null===(i=e.appearance)||void 0===i?void 0:i.widgetType)===dg.Selector&&(null===(s=e.appearance)||void 0===s?void 0:s.widgetSelector)&&(r.add(e.id),this._manageWidgetSelectorListener(e,null===(n=e.appearance)||void 0===n?void 0:n.widgetSelector))}Rt(this._surveyInFocus)&&e.type===_g.Popover&&this.handlePopoverSurvey(e,void 0,{resumeDelayFromActivation:!0})}),this._widgetSelectorListeners.forEach(({survey:e})=>{r.has(e.id)||this._removeWidgetSelectorListener(e)}),this._renderedTabWidgets.forEach((e,t)=>{o.has(t)||this._removeTabWidget(e)})},e)},this._addSurveyToFocus=e=>{Rt(this._surveyInFocus)||wg.error(`Survey ${this._surveyInFocus} already in focus. Cannot add survey ${e.id}.`),this._surveyInFocus=e.id},this._removeSurveyFromFocus=e=>{this._surveyInFocus!==e.id&&wg.error(`Survey ${e.id} is not in focus. Cannot remove survey ${e.id}.`),this._clearSurveyTimeout(e.id),this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0,this._removeSurveyFromDom(e)},this._posthog=e,this._surveyInFocus=null,this._languageChangeListener=()=>this._onLanguageChange(),sr(Uf,"languagechange",this._languageChangeListener),this._unsubscribeFeatureFlags=e.onFeatureFlags(()=>this._onLanguageChange())}_onLanguageChange(){if(Rt(this._surveyInFocus))return;const e=this._posthog.get_property(ue),t=null==e?void 0:e.find(e=>e.id===this._surveyInFocus);if(!t)return;const{survey:i,language:s}=this._translateSurveyForRendering(t);if(s===this._currentLanguage)return;if(this._currentLanguage=s,!this._surveyIsRendered)return;const n=this._applyDisplayOverrides(i,this._displayOptions),{shadow:r}=Hg(n,this._posthog);q_(uf(Yf,ct(ct({},this._surveyPopupProps),{},{posthog:this._posthog,survey:n,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:s})),r)}get _featureFlags(){var e,t,i;return null!==(e=null===(t=(i=this._posthog).getExtension)||void 0===t?void 0:t.call(i,"featureFlags"))&&void 0!==e?e:this._posthog.featureFlags}_applyDisplayOverrides(e,t){return(null==t?void 0:t.position)||(null==t?void 0:t.selector)?ct(ct({},e),{},{appearance:ct(ct(ct({},e.appearance),t.position&&{position:t.position}),t.selector&&{widgetSelector:t.selector})}):e}_clearSurveyTimeout(e){const t=this._surveyTimeouts.get(e);t&&(clearTimeout(t),this._surveyTimeouts.delete(e))}cancelSurvey(e){this._surveyTimeouts.has(e)&&(wg.info(`Cancelled pending survey ${e}`),this._clearSurveyTimeout(e),this._surveyInFocus===e&&(this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0))}setAutomaticDisplayDispose(e){this._automaticDisplayDispose=e}dispose(){var e;null===(e=this._automaticDisplayDispose)||void 0===e||e.call(this),this._automaticDisplayDispose=void 0,this._languageChangeListener&&(Uf.removeEventListener("languagechange",this._languageChangeListener),this._languageChangeListener=null),this._unsubscribeFeatureFlags&&(this._unsubscribeFeatureFlags(),this._unsubscribeFeatureFlags=null),this._surveyTimeouts.forEach((e,t)=>this._clearSurveyTimeout(t)),this._widgetSelectorListeners.forEach((e,t)=>this._detachWidgetSelectorListener(t)),this._renderedTargets.forEach((e,t)=>{q_(null,t),null==e||e.remove()}),this._renderedTargets.clear(),this._renderedTabWidgets.clear(),this._surveyInFocus=null}_sortSurveysByAppearanceDelay(e){return e.sort((e,t)=>{var i,s;const n=rf(e),r=rf(t);if(n&&!r)return-1;if(!n&&r)return 1;const o=e.schedule===vg.Always,a=t.schedule===vg.Always;return o&&!a?1:!o&&a?-1:((null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)||0)-((null===(s=t.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds)||0)})}_translateSurveyForRendering(e){return Hf(e,this._posthog)}_handleUrlPrefill(e,t,i){if(this._prefillHandledSurveys.has(e.id))return!1;const{params:s}=function(){const e={};let t=!1;const i=Uf.location.search.replace(/^\?/,"");if(!i)return{params:e,autoSubmit:t};const s=i.split("&");for(const i of s){const[s,n]=i.split("=");if(!s||It(n))continue;const r=decodeURIComponent(s),o=decodeURIComponent(n);if("auto_submit"===r&&"true"===o){t=!0;continue}const a=r.match(/^q(\d+)$/);if(a){const t=parseInt(a[1],10);e[t]||(e[t]=[]),e[t].push(o)}}return{params:e,autoSubmit:t}}();if(0===Object.keys(s).length)return!1;wg.info("[Survey Prefill] Detected URL prefill parameters");const n=this._processPrefillData(e,s,t);return!!n&&(this._autoSubmitPrefilledResponses(e,n,i,t),this._prefillHandledSurveys.add(e.id),n.isSurveyCompleted)}_autoSubmitPrefilledResponses(e,t,i,s){const{responses:n,submissionId:r,isSurveyCompleted:o,skippedResponses:a}=t;(Object.keys(a).length>0&&e.enable_partial_responses||o)&&Ug({responses:o?n:a,survey:e,surveySubmissionId:r,posthog:this._posthog,isSurveyCompleted:o,properties:i,surveyLanguage:s})}_handleInitialResponses(e,t,i,s){const n={};for(const[e,i]of Object.entries(t))n[parseInt(e)]=kt(i)?i.map(String):[String(i)];wg.info("[Survey] Processing initial responses");const r=this._processPrefillData(e,n,s);return!!r&&(this._autoSubmitPrefilledResponses(e,r,i,s),r.isSurveyCompleted)}_processPrefillData(e,t,i){try{const s=function(e,t){const i={};return e.questions.forEach((e,s)=>{if(!t[s]||!e.id)return;const n=t[s],r=tl(e.id);try{switch(e.type){case gg.SingleChoice:{if(!e.choices||0===e.choices.length)return void Vn.warn(`[Survey Prefill] Question ${s} has no choices`);const t=parseInt(n[0],10);if(isNaN(t)||0>t||t>=e.choices.length)return void Vn.warn(`[Survey Prefill] Invalid choice index for q${s}: ${n[0]}`);i[r]=e.choices[t];break}case gg.MultipleChoice:{if(!e.choices||0===e.choices.length)return void Vn.warn(`[Survey Prefill] Question ${s} has no choices`);const t=n.map(e=>parseInt(e,10)).filter(t=>!isNaN(t)&&t>=0&&e.choices.length>t);if(0===t.length)return void Vn.warn(`[Survey Prefill] No valid choices for q${s}`);const o=[...new Set(t.map(t=>e.choices[t]))];t.length>o.length&&Vn.warn(`[Survey Prefill] Removed duplicate choices for q${s}`),i[r]=o;break}case gg.Rating:{const t=parseInt(n[0],10),o=e.scale||10;if(isNaN(t)||0>t||t>o)return void Vn.warn(`[Survey Prefill] Invalid rating for q${s}: ${n[0]} (scale: 0-${o})`);i[r]=t;break}default:Vn.info(`[Survey Prefill] Question type ${e.type} does not support prefill`)}}catch(e){Vn.error(`[Survey Prefill] Error converting q${s}:`,e)}}),i}(e,t);if(0===Object.keys(s).length)return wg.warn("[Survey Prefill] No valid responses after conversion"),null;const n=Ra(),{startQuestionIndex:r,skippedResponses:o,skippedIndices:a}=function(e,t,i){let s=0;const n={},r=[],o=e.questions.length+1;let a=0;for(;e.questions.length>s&&o>a&&(a++,t.includes(s));){const t=e.questions[s];if(!t||!("skipSubmitButton"in t)||!t.skipSubmitButton)break;if(t.id){const e=tl(t.id);It(i[e])||(n[e]=i[e])}r.push(s);const o=Bf(e,s,t.id?i[tl(t.id)]:null);if(o===fg.End)return{startQuestionIndex:e.questions.length,skippedResponses:n,skippedIndices:r};s=o}return{startQuestionIndex:s,skippedResponses:n,skippedIndices:r}}(e,Object.keys(t).map(e=>parseInt(e,10)),s),l=r>=e.questions.length;return sf(e,{surveySubmissionId:n,responses:s,lastQuestionIndex:r,questionOrder:Qg(e.questions),visitedIndices:a,surveyLanguage:i}),wg.info("[Survey Prefill] Stored prefilled responses in localStorage"),{responses:s,submissionId:n,startQuestionIndex:r,isSurveyCompleted:l,skippedResponses:o}}catch(e){return wg.error("[Survey Prefill] Error handling prefill:",e),null}}_isSurveyFeatureFlagEnabled(e,t=void 0){if(!e)return!0;const i=this._featureFlags,s=!!(null==i?void 0:i.isFeatureEnabled(e,{send_event:!e.startsWith("survey-targeting-")}));let n=!0;t&&(n=(null==i?void 0:i.getFeatureFlag(e,{send_event:!1}))===t||"any"===t);const r=s&&n;return r||this._warnIfFeatureFlagsDisabled(e),r}_warnIfFeatureFlagsDisabled(e){var t;!this._loggedFeatureFlagsDisabledWarning&&(null===(t=this._posthog.config)||void 0===t?void 0:t.advanced_disable_feature_flags)&&(this._loggedFeatureFlagsDisabledWarning=!0,wg.warn(`Survey feature flag "${e}" evaluated to false because advanced_disable_feature_flags is set. PostHog creates an internal targeting flag for almost every survey, so no survey can display while flags are disabled. To keep surveys working, replace advanced_disable_feature_flags with advanced_only_evaluate_survey_feature_flags, which evaluates survey flags only.`))}_isSurveyConditionMatched(t){return!t.conditions||ef(t,this._posthog)&&function(t){var s,n;return function(t,s){var n,r,o;if(!t||0===t.length)return!0;if(!c)return!1;const a=Zi(c,{userAgentDataPlatform:null==i||null===(n=i.userAgentData)||void 0===n?void 0:n.platform,maxTouchPoints:null==i?void 0:i.maxTouchPoints,screenWidth:null==e||null===(r=e.screen)||void 0===r?void 0:r.width,screenHeight:null==e||null===(o=e.screen)||void 0===o?void 0:o.height,devicePixelRatio:null==e?void 0:e.devicePixelRatio});return gl[null!=s?s:"icontains"](t,[a])}(null===(s=t.conditions)||void 0===s?void 0:s.deviceTypes,null===(n=t.conditions)||void 0===n?void 0:n.deviceTypesMatchType)}(t)&&function(e){var t;return!(null===(t=e.conditions)||void 0===t?void 0:t.selector)||!!(null==Og?void 0:Og.querySelector(e.conditions.selector))}(t)}_internalFlagCheckSatisfied(e){var t;return Zg(e)?{satisfied:!0}:e.internal_targeting_flag_key&&function(e){var t;return"recurring"===e.schedule||(null!==(t=e.current_iteration)&&void 0!==t?t:0)>0}(e)&&!(null===(t=this._featureFlags)||void 0===t?void 0:t.hasLoadedFlags)?(this._warnIfFeatureFlagsDisabled(e.internal_targeting_flag_key),{satisfied:!1,reason:"Feature flags have not loaded yet; deferring internal targeting flag check"}):{satisfied:this._isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key)}}checkSurveyEligibility(e){var t,i;const s={eligible:!0,reason:void 0};if(!Eg(e))return s.eligible=!1,s.reason=`Survey is not running. It was completed on ${e.end_date}`,s;if(!Rg.includes(e.type))return s.eligible=!1,s.reason=`Surveys of type ${e.type} are never eligible to be shown in the app`,s;const n=null===(t=e.conditions)||void 0===t?void 0:t.linkedFlagVariant;if(!this._isSurveyFeatureFlagEnabled(e.linked_flag_key,n))return s.eligible=!1,s.reason=n?`Survey linked feature flag is not enabled for variant ${n}`:"Survey linked feature flag is not enabled",s;if(!this._isSurveyFeatureFlagEnabled(e.targeting_flag_key))return s.eligible=!1,s.reason="Survey targeting feature flag is not enabled",s;const r=this._internalFlagCheckSatisfied(e);var o;return r.satisfied?function(e,t){if(!e||!t)return!0;const i="string"==typeof t?new Date(t):t,s=Math.abs((new Date).getTime()-i.getTime());return Math.ceil(s/864e5)>e}(null===(i=e.conditions)||void 0===i?void 0:i.seenSurveyWaitPeriodInDays,$a._get("lastSeenSurveyDate"))?(e=>!!$a._get(Tg(e))&&!Zg(e))(e)?(s.eligible=!1,s.reason="Survey has already been seen and it can't be activated again",s):s:(s.eligible=!1,s.reason="Survey wait period has not passed",s):(s.eligible=!1,s.reason=null!==(o=r.reason)&&void 0!==o?o:"Survey internal targeting flag is not enabled and survey cannot activate repeatedly and survey is not in progress",s)}checkSurveyCaptureEligibility(){return Cg(this._posthog)?{eligible:!0}:{eligible:!1,reason:kg}}checkSurveyDisplayEligibility(e){const t=this.checkSurveyCaptureEligibility();return t.eligible?this.checkSurveyEligibility(e):t}checkSurveyRenderability(e){const t=this.checkSurveyDisplayEligibility(e);return t.eligible&&!this._hasActionOrEventTriggeredSurvey(e)?{eligible:!1,reason:"Survey event/action trigger has not been fired yet"}:t}_hasActionOrEventTriggeredSurvey(e){var t;if(!dl(e)&&!xg(e))return!0;const i=null===(t=this._posthog.surveys)||void 0===t||null===(t=t._surveyEventReceiver)||void 0===t?void 0:t.getSurveys();return!!(null==i?void 0:i.includes(e.id))}_checkFlags(e){var t;return!(null===(t=e.feature_flag_keys)||void 0===t?void 0:t.length)||e.feature_flag_keys.every(({key:e,value:t})=>!e||!t||this._isSurveyFeatureFlagEnabled(t))}_shouldDisplaySurvey(e){return this.checkSurveyEligibility(e).eligible&&this._isSurveyConditionMatched(e)&&this._hasActionOrEventTriggeredSurvey(e)&&this._checkFlags(e)}_removeSurveyFromDom(e){try{const t=Wf.querySelector(af(e,!0));(null==t?void 0:t.shadowRoot)&&(q_(null,t.shadowRoot),this._renderedTargets.delete(t.shadowRoot)),null==t||t.remove()}catch(t){wg.warn(`Failed to remove survey ${e.id} from DOM:`,t)}}getTestAPI(){return{addSurveyToFocus:this._addSurveyToFocus,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyInFocus:this._surveyInFocus,surveyTimeouts:this._surveyTimeouts,handleWidget:this._handleWidget,handlePopoverSurvey:this.handlePopoverSurvey,manageWidgetSelectorListener:this._manageWidgetSelectorListener,sortSurveysByAppearanceDelay:this._sortSurveysByAppearanceDelay,checkFlags:this._checkFlags.bind(this),isSurveyFeatureFlagEnabled:this._isSurveyFeatureFlagEnabled.bind(this),onLanguageChange:this._onLanguageChange.bind(this),currentLanguage:this._currentLanguage,surveyIsRendered:this._surveyIsRendered}}};function Qf(e,t){if(!Wf||!Uf)return;const i=new Gf(e);if(e.config.disable_surveys_automatic_display)return wg.info("Surveys automatic display is disabled. Skipping call surveys and evaluate display logic."),i;if(!1===t)return wg.info("There are no surveys to load or Surveys is disabled in the project settings."),i;let s;i.callSurveysAndEvaluateDisplayLogic(!0);const n=()=>{It(s)&&(s=setInterval(()=>{i.callSurveysAndEvaluateDisplayLogic(!1)},1e3))},r=()=>{It(s)||(clearInterval(s),s=void 0)};n();const o=()=>{Wf.hidden?r():(i.callSurveysAndEvaluateDisplayLogic(!1),n())};return sr(Wf,"visibilitychange",o),i.setAutomaticDisplayDispose(()=>{r(),Wf.removeEventListener("visibilitychange",o)}),i}function Kf({survey:e,removeSurveyFromFocus:t=()=>{},setSurveyVisible:i,isPreviewMode:s=!1,posthog:n}){Y_(()=>{var r;if(s||!(null===(r=e.conditions)||void 0===r?void 0:r.url))return;const o=()=>{var s;const r=e.type===_g.Widget,o=ef(e,n),a=(null===(s=e.appearance)||void 0===s?void 0:s.widgetType)===dg.Tab&&r;if(!o)return wg.info(`Hiding survey ${e.id} because URL does not match`),i(!1),t(e);a&&(wg.info(`Showing survey ${e.id} because it is a feedback button tab and URL matches`),i(!0))};sr(Uf,"popstate",o),sr(Uf,"hashchange",o);const a=Uf.history.pushState,l=Uf.history.replaceState;return Uf.history.pushState=function(...e){a.apply(this,e),o()},Uf.history.replaceState=function(...e){l.apply(this,e),o()},()=>{Uf.removeEventListener("popstate",o),Uf.removeEventListener("hashchange",o),Uf.history.pushState=a,Uf.history.replaceState=l}},[s,e,t,i,n])}const Zf=200;function Jf(e=pg.Right){switch(e){case pg.Top:return{top:"0",left:"50%",transform:"translateX(-50%)"};case pg.Left:return{top:"50%",left:"0",transform:"rotate(90deg) translateY(-100%)",transformOrigin:"left top"};case pg.Bottom:return{bottom:"0",left:"50%",transform:"translateX(-50%)"};default:return{top:"50%",right:"0",transform:"rotate(-90deg) translateY(-100%)",transformOrigin:"right top"}}}function Yf({survey:e,forceDisableHtml:t,posthog:i,style:s={},previewPageIndex:n,removeSurveyFromFocus:r=()=>{},isPopup:o=!0,onPreviewSubmit:a=()=>{},onPreviewBack:l=()=>{},onPopupSurveyDismissed:c=()=>{},onCloseConfirmationMessage:u=()=>{},properties:d,isSurveyCompleted:h,skipShownEvent:p,surveyLanguage:_}){var g,f,v,m,y,b,S,w,k,C,E,x;const I=X_(null),T=Number.isInteger(n),{isPopupVisible:M,isSurveySent:R,hidePopupWithAnimation:P}=function(e,t,i,s,n,r,o,a,l){const[c,u]=J_(s||0===i||e.type===_g.ExternalSurvey),[d,h]=J_(!1),p=X_(!1),_=()=>{const t=()=>{r&&n(e),u(!1)};if(p.current)return;const i=null==o?void 0:o.current;i?(p.current=!0,i.style.transition=`opacity ${Zf}ms ease-out`,i.style.opacity="0",setTimeout(()=>{p.current=!1,t()},250)):t()},g=t=>{t.detail.surveyId===e.id&&_()};return Y_(()=>{if(!t)return void wg.error("usePopupVisibility hook called without a PostHog instance.");if(s)return;let n;const r=t=>{var i,s;if(t.detail.surveyId===e.id){if(!(null===(i=e.appearance)||void 0===i?void 0:i.displayThankYouMessage))return _();h(!0),(null===(s=e.appearance)||void 0===s?void 0:s.autoDisappear)&&(n&&clearTimeout(n),n=setTimeout(_,5e3))}},o=()=>{if(ef(e,t)){var i;u(!0),Uf.dispatchEvent(new Event("PHSurveyShown")),a||t.capture(mg.SHOWN,ct(ct({[yg.SURVEY_NAME]:e.name,[yg.SURVEY_ID]:e.id,[yg.SURVEY_ITERATION]:e.current_iteration,[yg.SURVEY_ITERATION_START_DATE]:e.current_iteration_start_date},l&&{[yg.SURVEY_LANGUAGE]:l}),{},{sessionRecordingUrl:null===(i=t.get_session_replay_url)||void 0===i?void 0:i.call(t)}));try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}};sr(Uf,"PHSurveyClosed",g),sr(Uf,"PHSurveySent",r);const c=i>0?setTimeout(o,i):void 0;return It(c)&&o(),()=>{It(c)||clearTimeout(c),It(n)||clearTimeout(n),Uf.removeEventListener("PHSurveyClosed",g),Uf.removeEventListener("PHSurveySent",r)}},[]),Kf({survey:e,removeSurveyFromFocus:n,setSurveyVisible:u,isPreviewMode:s,posthog:t}),{isPopupVisible:c,isSurveySent:d,setIsPopupVisible:u,hidePopupWithAnimation:_}}(e,i,(null===(g=e.appearance)||void 0===g?void 0:g.surveyPopupDelaySeconds)?1e3*e.appearance.surveyPopupDelaySeconds:0,T,r,o,I,p,_),F=R||n===e.questions.length||!0===h,[L,A]=J_(!1),O=eg(()=>!!nf(e),[e]),D=!(!(null===(f=e.appearance)||void 0===f?void 0:f.introScreenHeader)&&!(null===(v=e.appearance)||void 0===v?void 0:v.introScreenDescription)),N=T?-1===n:!!(null===(m=e.appearance)||void 0===m?void 0:m.displayIntroScreen)&&D&&!L&&!O,B=eg(()=>{const t=nf(e),s=(null==t?void 0:t.surveySubmissionId)||Ra();return{isPreviewMode:T,previewPageIndex:n,onPopupSurveyDismissed(){_?zg(e,i,T,_):zg(e,i,T),c()},isPopup:o||!1,surveySubmissionId:s,onPreviewSubmit:a,onPreviewBack:l,posthog:i,properties:d,surveyLanguage:_}},[T,n,o,i,e,c,a,l,d,_]);return M?uf(Jg.Provider,{value:B,children:uf("div",{className:"ph-survey",style:ct(ct({},lf(e.type,null===(y=e.appearance)||void 0===y?void 0:y.position,null===(b=e.appearance)||void 0===b?void 0:b.widgetType)),s),ref:I,children:F?uf(Ef,{header:(null===(S=e.appearance)||void 0===S?void 0:S.thankYouMessageHeader)||"Thank you!",description:(null===(w=e.appearance)||void 0===w?void 0:w.thankYouMessageDescription)||"",forceDisableHtml:!!t,contentType:null===(k=e.appearance)||void 0===k?void 0:k.thankYouMessageDescriptionContentType,appearance:e.appearance||$g,onClose(){P(),u()}}):N?uf(xf,{header:(null===(C=e.appearance)||void 0===C?void 0:C.introScreenHeader)||"",description:(null===(E=e.appearance)||void 0===E?void 0:E.introScreenDescription)||"",forceDisableHtml:!!t,contentType:null===(x=e.appearance)||void 0===x?void 0:x.introScreenDescriptionContentType,appearance:e.appearance||$g,onStart:()=>A(!0)}):uf(Xf,{survey:e,forceDisableHtml:!!t,posthog:i})})}):null}function Xf({survey:e,forceDisableHtml:t,posthog:i}){var s,n;const r=eg(()=>{const t=nf(e);if(!t)return null;const i=Ft(t.lastQuestionIndex);return!i||i&&t.lastQuestionIndex>=0&&e.questions.length>t.lastQuestionIndex?t:(of(e),null)},[e]),[o,a]=J_(()=>((null==r?void 0:r.responses)&&wg.info("Survey is already in progress, filling in initial responses"),(null==r?void 0:r.responses)||{})),[l,c]=J_(!1),{previewPageIndex:u,onPopupSurveyDismissed:d,isPopup:h,onPreviewSubmit:p,onPreviewBack:_,surveySubmissionId:g,isPreviewMode:f,properties:v,surveyLanguage:m}=tg(Jg),[y,b]=J_(()=>{const t=null==r?void 0:r.lastQuestionIndex,i=Ft(t)&&t>=0&&e.questions.length>t?t:0;return Ft(u)&&u>=0?u:i}),[S,w]=J_(()=>{var t;return(null!==(t=null==r?void 0:r.visitedIndices)&&void 0!==t?t:[]).filter(t=>t>=0&&e.questions.length>t)}),[k,C]=J_(()=>{var t;const i=nf(e);return null!==(t=null==i?void 0:i.questionSnapshots)&&void 0!==t?t:{}}),E=eg(()=>Qg(Kg(e,r)),[e.id,r]),x=eg(()=>{if(!E||new Set(E).size!==E.length)return Kg(e,r);const t=new Map(e.questions.map(e=>[e.id,e])),i=E.map(e=>t.get(e)).filter(e=>!!e);return i.length===E.length?i:e.questions},[E,e.questions,e,r]);Y_(()=>{!f||It(u)||0>u||b(u)},[u,f]);const I=!!(null===(s=e.appearance)||void 0===s?void 0:s.allowGoBack)&&(f?(null!=u?u:0)>0:S.length>0),T=x.at(y);return T?uf("form",{className:"survey-form",name:"surveyForm",children:[h&&!0!==(null===(n=e.appearance)||void 0===n?void 0:n.hideCancelButton)&&uf(kf,{onClick(){d()}}),uf("div",{className:"survey-box","data-question-index":y,children:[l&&uf("p",{role:"alert",children:"Your response could not be sent. Please try again later."}),tv({question:T,forceDisableHtml:t,displayQuestionIndex:y,appearance:e.appearance||$g,onSubmit:t=>(({res:t,displayQuestionIndex:s,questionId:n})=>{if(!i)return void wg.error("onNextButtonClick called without a PostHog instance.");if(!Cg(i))return void c(!0);if(c(!1),!n)return void wg.error("onNextButtonClick called without a questionId.");const r=tl(n),l=ct(ct({},o),{},{[r]:t});a(l);const u=x[s],d=(null==u?void 0:u.id)?ct(ct({},k),{},{[u.id]:u.question}):k;C(d);const h=Bf(e,s,t),p=h===fg.End,_=[...S,s];if(p||(w(_),b(h),sf(e,{surveySubmissionId:g,responses:l,lastQuestionIndex:h,questionOrder:Qg(x),visitedIndices:_,surveyLanguage:m,questionSnapshots:d})),e.enable_partial_responses||p){const t=new Set(_.map(e=>{var t;return null===(t=x[e])||void 0===t?void 0:t.id}).filter(e=>!!e).map(e=>tl(e))),s=Object.fromEntries(Object.entries(l).filter(([e])=>t.has(e)));Ug({responses:s,survey:e,surveySubmissionId:g,isSurveyCompleted:p,posthog:i,properties:v,surveyLanguage:m,questionSnapshots:d})}})({res:t,displayQuestionIndex:y,questionId:T.id}),onPreviewSubmit:p,initialValue:T.id?o[tl(T.id)]:void 0,canGoBack:I,onBack(){if(f)return void _();if(0===S.length)return;const t=S[S.length-1],i=S.slice(0,-1);w(i),b(t),sf(e,{surveySubmissionId:g,responses:o,lastQuestionIndex:t,questionOrder:Qg(x),visitedIndices:i,surveyLanguage:m,questionSnapshots:k})}})]})]}):null}function ev({survey:e,forceDisableHtml:t,posthog:i,readOnly:s,surveyLanguage:n}){var r,o,a,l,c,u,d;const[h,p]=J_(!0),[_,g]=J_(!1),[f,v]=J_({}),m=X_(void 0),y=()=>{(_||!i||s||Cg(i))&&g(!_)};if(Y_(()=>{var t;if(!i)return void wg.error("FeedbackWidget called without a PostHog instance.");if(s)return;"tab"===(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)&&v({top:"50%",bottom:"auto"});const n=t=>{var i;const s=t;(null===(i=s.detail)||void 0===i?void 0:i.surveyId)===e.id&&(wg.info(`Received show event for feedback button survey ${e.id}`),v(s.detail.position||{}),y())};return sr(Uf,zf,n),()=>{It(m.current)||(clearTimeout(m.current),m.current=void 0),Uf.removeEventListener(zf,n)}},[i,s,e.id,null===(r=e.appearance)||void 0===r?void 0:r.widgetType,null===(o=e.appearance)||void 0===o?void 0:o.widgetSelector,null===(a=e.appearance)||void 0===a?void 0:a.borderColor]),Kf({survey:e,setSurveyVisible:p,posthog:i}),!h)return null;const b=()=>{e.schedule!==vg.Always&&p(!1),It(m.current)||clearTimeout(m.current),m.current=setTimeout(()=>{m.current=void 0,g(!1)},200)};return uf(b_,{children:["tab"===(null===(l=e.appearance)||void 0===l?void 0:l.widgetType)&&uf("button",{className:"ph-survey-widget-tab "+((null===(c=e.appearance)||void 0===c?void 0:c.tabPosition)===pg.Top?"widget-tab-top":""),onClick:y,disabled:s,style:Jf(null===(u=e.appearance)||void 0===u?void 0:u.tabPosition),children:(null===(d=e.appearance)||void 0===d?void 0:d.widgetLabel)||""}),_&&uf(Yf,{posthog:i,survey:e,forceDisableHtml:t,style:f,onPopupSurveyDismissed:b,onCloseConfirmationMessage:b,surveyLanguage:n})]})}const tv=({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:s,onSubmit:n,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l})=>{const c={forceDisableHtml:t,appearance:s,onPreviewSubmit(e){r(e)},onSubmit(e){n(e)},initialValue:o,displayQuestionIndex:i,canGoBack:a,onBack:l};switch(e.type){case gg.Open:return m_(Tf,ct(ct({},c),{},{question:e,key:e.id}));case gg.Link:return m_(Mf,ct(ct({},c),{},{question:e,key:e.id}));case gg.Rating:return m_(Rf,ct(ct({},c),{},{question:e,key:e.id}));case gg.SingleChoice:case gg.MultipleChoice:return m_(Ff,ct(ct({},c),{},{question:e,key:e.id}));default:return wg.error(`Unsupported question type: ${e.type}`),null}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.generateSurveys=Qf,h.extendPostHogWithSurveys=Qf;const iv=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},sv=1e4,nv=(e,t,i)=>i.remaining>0?t.length>i.remaining?(e.push(t.slice(0,i.remaining)),i.remaining=0,i.truncated=!0,!1):(e.push(t),i.remaining-=t.length,!0):(i.truncated=!0,!1),rv=(e,t,i)=>{const s=JSON.stringify(e);if(i.remaining>=s.length)return nv(t,s,i);if(i.truncated=!0,2>i.remaining)return!1;let n=0,r=Math.min(e.length,i.remaining-2);for(;r>n;){const t=Math.ceil((n+r)/2);JSON.stringify(e.slice(0,t)).length>i.remaining?r=t-1:n=t}return nv(t,JSON.stringify(e.slice(0,n)),i)},ov=e=>void 0!==e&&"function"!=typeof e&&"symbol"!=typeof e&&"bigint"!=typeof e,av=(e,t,i)=>{if(!i.truncated){if(i.keysRemaining-=1,i.sizeRemaining-=String(t).length+e.length,0>=i.keysRemaining||0>=i.sizeRemaining)return i.truncated=!0,void(i.result.attributes_truncated=!0);i.result[e]=t}},lv=(e,t,i)=>{if(!i.truncated)if(Et(e)){if(i.seen.has(e))return void av(t||"circular","[Circular]",i);i.seen.add(e);try{for(const s in e)try{if(!{}.hasOwnProperty.call(e,s))continue;if(lv(e[s],t?`${t}.${s}`:s,i),i.truncated)return}catch(e){continue}}catch(e){}}else av(t,e,i)},cv=(e,t,i,s,n=!1,r)=>{if(!ov(e))return!n||nv(t,"null",i);if(Rt(e)||(e=>{try{return Ft(e)||At(e)}catch(e){return!1}})(e))return nv(t,JSON.stringify(e),i);if("string"==typeof e)return rv(e,t,i);if(!Et(e)&&!kt(e))return nv(t,JSON.stringify(e),i);if(s.has(e))return rv("[Circular]",t,i);s.add(e);try{const r=e.toJSON;if(Ct(r))return cv(r.call(e),t,i,s,n)}catch(e){}try{const s={}.toString.call(e);if("[object String]"===s)return rv(String(e.valueOf()),t,i);if("[object Number]"===s||"[object Boolean]"===s)return nv(t,JSON.stringify(e.valueOf()),i)}catch(e){}if(e instanceof Error){const o={};try{for(const t in e)({}).hasOwnProperty.call(e,t)&&(o[t]=e[t])}catch(e){}try{o.name=e.name}catch(e){}try{o.message=e.message}catch(e){}try{o.stack=e.stack}catch(e){}return cv(o,t,i,s,n,r)}if(kt(e)){if(!nv(t,"[",i))return!1;for(let n=0;e.length>n;n++){if(n>0&&!nv(t,",",i))return!1;let r;try{r=e[n]}catch(e){r=void 0}if(!cv(r,t,i,s,!0))return!1}return nv(t,"]",i)}if(!nv(t,"{",i))return!1;let o=!0;try{for(const n in e){if(!{}.hasOwnProperty.call(e,n))continue;if(0>=i.remaining)return i.truncated=!0,!1;let a;try{a=e[n]}catch(e){continue}if(r)try{lv(a,n,r)}catch(e){}if(!ov(a))continue;const l=`${o?"":","}${JSON.stringify(n)}:`;if(l.length>=i.remaining)return i.truncated=!0,!1;const c=t.length,u=i.remaining,d=i.truncated;if(!nv(t,l,i))return!1;const h=t.length,p=cv(a,t,i,s,!1),_=i.truncated;if(t.length!==h){if(o=!1,!p)return!1}else if(t.length=c,i.remaining=u,i.truncated=p?d:_,!p)return!1}}catch(e){}return nv(t,"}",i)},uv=(e,t)=>{const i=[],s={remaining:t,truncated:!1},n=Et(e[0])?{result:{},keysRemaining:50,sizeRemaining:sv,truncated:!1,seen:new WeakSet([e[0]])}:void 0;for(let t=0;e.length>t&&(0>=t||nv(i," ",s))&&cv(e[t],i,s,new WeakSet,!1,0===t?n:void 0);t++);return{body:i.join("")+(s.truncated?"...":""),truncated:s.truncated,attributes:(null==n?void 0:n.result)||{}}},dv={debug:"debug",log:"info",warn:"warn",error:"error",info:"info"},hv=e=>"canCapture"in e,pv=e=>hv(e)?e.canCapture?e.getExtension(Fg):void 0:e.is_capturing()?e.logs:void 0,_v=(e,t,i)=>{if(hv(e))return void t.captureConsoleLog(i);const s=(e=>{const t=/^1\.(\d+)\.(\d+)$/.exec(e);if(!t)return;const i=Number(t[1]),s=Number(t[2]);return 392>i||i>419?void 0:410===i?s>4?s>10?void 0:"de":"le":418===i?s>3?s>10?s>14?s>17?void 0:"vi":"ci":"ui":"he":419===i?s>2?void 0:"vi":410>i?"le":"he"})(e.version),n=s?t[s]:void 0;Ct(n)&&n.call(t,i)};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.logs={initializeLogs(e){let t=e;const i=[],s={host:h.location.host};let n=!1;for(const e of Object.keys(dv)){const r=i=>(...r)=>{let o=!1;try{const i=t;if(r.length>0&&!n&&i){const t=pv(i);if(t){n=!0,o=!0;const{body:a,truncated:l,attributes:c}=uv(r,sv),u=ct(ct({},s),l?{body_truncated:"true"}:{}),d={level:dv[e],body:a,attributes:ct(ct({"log.source":`console.${e}`},u),c)};_v(i,t,d)}}}catch(e){}finally{o&&(n=!1),i.apply(h.console,r)}},o=h.console[e];i.push(Sp(h.console,e,e=>{const t=r(e);return t.__rrweb_original__=iv(o),t}))}return()=>{t=void 0,i.forEach(e=>e())}},replayConsoleBuffer(e,t){const i=pv(e);if(i)for(const e of t)try{var s;const{body:t,truncated:n,attributes:r}=uv(e.args,sv);null===(s=i.captureBufferedConsoleLog)||void 0===s||s.call(i,{level:dv[e.level],body:t,attributes:ct(ct({"log.source":`console.${e.level}`,host:h.location.host},n?{body_truncated:"true"}:{}),r)},e.context,e.occurredAtMs)}catch(e){}}};const gv=e=>qt(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),fv=Gn("[Error tracking]"),vv="webkit-masked-url:",mv=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],yv=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",vv],bv=["__firefox__","__gCrWeb"];function Sv(){return new vs([new Ns,new Qs,new qs,new Bs,new Vs,new js,new Us,new Gs],function(e,...t){return(i,s=0)=>{const n=[],r=i.split("\n"),o=Math.min(r.length,s+1e3),a=[];for(let i=s;o>i;i++){const s=r[i];if(s.length>1024)continue;const o=Rs.test(s)?s.replace(Rs,"$1"):s;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){n.push(t);const e=Fs(n);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if(Ds(n,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=As(n,c);n.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Ls(n,e);return a.some(e=>0===e.start&&n.length===e.length)&&function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)$s(t,e,i)&&(i=e);e.push(...e.splice(0,i))}(n),function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return ct(ct({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(n)}}("web:javascript",xs,Ms))}const wv=Gn("[ExceptionAutocapture]"),kv=Sv(),Cv=(e,t)=>{try{return e()}catch(e){return t}},Ev=(e,t)=>Cv(()=>e(t()),void 0),xv=e=>Cv(()=>Ct(e)&&Ct(e.call),!1),Iv=(e,t)=>Cv(()=>{e[t].__POSTHOG_INSTRUMENTED__=!0},void 0),Tv=(e,t,i)=>{Cv(()=>{var i;null===(i=e[t])||void 0===i||delete i.__POSTHOG_INSTRUMENTED__},void 0),Cv(()=>{e[t]=i},void 0)},Mv=t=>{const i=e;i||wv.info("window not available, cannot wrap onerror");const s=Cv(()=>i.onerror,void 0);return i.onerror=function(...e){var i;return Ev(t,()=>kv.buildFromUnknown((([e,t,i,s,n])=>{if(null!=n)return n;if(Tt(e)&&Tt(t)&&t.length>0&&"undefined"!=typeof ErrorEvent)try{return new ErrorEvent("error",{message:e,filename:t,lineno:i,colno:s})}catch(t){return e}return e})(e),{mechanism:{handled:!1}})),!!xv(s)&&null!==(i=s(...e))&&void 0!==i&&i},Iv(i,"onerror"),()=>Tv(i,"onerror",s)},Rv=(t,i=!1)=>{const s=e;s||wv.info("window not available, cannot wrap onUnhandledRejection");const n=Cv(()=>s.onunhandledrejection,void 0);return s.onunhandledrejection=function(e){var s;return Ev(t,()=>kv.buildFromUnknown(e,{mechanism:{handled:!1}})),xv(n)?null!==(s=n(e))&&void 0!==s&&s:i},Iv(s,"onunhandledrejection"),()=>Tv(s,"onunhandledrejection",n)},Pv={wrapOnError:Mv,wrapUnhandledRejection:Rv,wrapConsoleError(e){const t=console;t||wv.info("console not available, cannot wrap console.error");const i=Cv(()=>t.error,void 0);return t.error=function(...t){Cv(()=>t.length>1&&Tt(t[0])&&(/^\[PostHog\.js\](?: |$)/.test(t[0])||"rrweb logger error:"===t[0]),!1)||Ev(e,()=>{let e;e=1==t.length?t[0]:t.join(" ");const i=t.find(e=>e instanceof Error);return kv.buildFromUnknown(i||e,{mechanism:{handled:!0,type:"onconsole"},syntheticException:new Error("PostHog syntheticException"),skipFirstLines:2})}),xv(i)&&i(...t)},Iv(t,"error"),()=>Tv(t,"error",i)}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.errorWrappingFunctions=Pv,h.posthogErrorWrappingFunctions=Pv;const Fv=(e,t)=>{if(!Ct(null==e?void 0:e.capture))return;const i=null==t?void 0:t.autocaptureExceptions,s=!Rt(i)&&"object"==typeof i&&kt(i.errors_to_ignore)?i.errors_to_ignore.reduce((e,t)=>{try{e.push(new RegExp(t))}catch(e){wv.error("Ignoring invalid legacy exception exclusion rule",t,e)}return e},[]):[],n=t=>{try{var i;null===(i=e.capture)||void 0===i||i.call(e,"$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",_noHeatmaps:!0})}catch(e){wv.error("Failed to capture exception for a legacy client",e)}};Mv(e=>{s.some(t=>e.$exception_list.some(e=>t.test(e.value||"")))||n(e)}),Rv(n,!0)};h.extendPostHogWithExceptionAutoCapture=Fv,h.extendPostHogWithExceptionAutocapture=Fv;const Lv="X-POSTHOG-SESSION-ID",Av="X-POSTHOG-WINDOW-ID",Ov="X-POSTHOG-DISTINCT-ID",Dv=[Lv,Av,Ov],$v=["attributionReporting","body","browsingTopics","cache","credentials","dispatcher","duplex","integrity","keepalive","method","mode","priority","redirect","referrer","referrerPolicy","signal","window"],Nv=(e,t)=>({}.hasOwnProperty.call(e,t)),Bv=e=>"object"==typeof e&&!Rt(e)||Ct(e),qv=e=>"undefined"!=typeof Request&&(e instanceof Request||"[object Request]"==={}.toString.call(e)),Hv=t=>{try{var i;return qv(t)?t.url:new URL(t instanceof URL?t.toString():String(t),null==e||null===(i=e.location)||void 0===i?void 0:i.href).toString()}catch(e){return}},Uv=(e,t,i,s,n)=>{let r;try{r=new URL(s).hostname}catch(e){return!1}if(!e)return!1;if(kt(e)&&!e.includes(r))return!1;let o=!1;if(i){const{sessionId:e,windowId:t}=i.checkAndGetSessionAndWindowId(!0);n.set(Lv,e),n.set(Av,t),o=!0}const a=(e=>Ct(e)?e():e)(t);return a&&"$posthog_cookieless"!==a&&(n.set(Ov,a),o=!0),o};h.__PosthogExtensions__=h.__PosthogExtensions__||{};const Wv={_patchFetch:(t,i,s)=>Sp(e,"fetch",e=>function(n,r){const o=arguments.length>1?[n,r]:[n];let a=o;try{const e=Hv(n);if(e)if(qv(n)){const e=new Request(n,r);Uv(t,i,s,e.url,e.headers),a=[e]}else{const o=new Headers(Bv(r)?r.headers:void 0);if(Uv(t,i,s,e,o)){const e=((e,t)=>{if(It(e)||Rt(e))return{headers:t};if(!Bv(e))return;const i=e;if("undefined"==typeof Proxy||"undefined"==typeof Reflect){const e=Object.create(i);return Object.defineProperty(e,"headers",{configurable:!0,enumerable:!0,value:t,writable:!0}),e}return new Proxy({headers:t},{get:(e,t)=>Nv(e,t)?Reflect.get(e,t):Reflect.get(i,t,i),has:(e,t)=>Nv(e,t)||t in i,ownKeys(e){const t=new Set(Reflect.ownKeys(e));return Reflect.ownKeys(i).forEach(e=>t.add(e)),$v.forEach(e=>{e in i&&t.add(e)}),Array.from(t)},getOwnPropertyDescriptor(e,t){const s=Reflect.getOwnPropertyDescriptor(e,t);if(s)return s;if("string"==typeof t&&$v.includes(t)&&t in i)return{configurable:!0,enumerable:!0,get(){return Reflect.get(i,t,i)}};const n=Reflect.getOwnPropertyDescriptor(i,t);return n?ct(ct({},n),{},{configurable:!0}):void 0},getPrototypeOf:()=>Object.getPrototypeOf(i)})})(r,o);e&&(a=[n,e])}}}catch(e){a=o}return e.apply(this,a)}),_patchXHR:(t,i,s)=>Sp(e.XMLHttpRequest.prototype,"open",e=>function(n,r,o=!0,a,l){const c=this,u=new Headers,d=Hv(r);d&&Uv(t,i,s,d,u);const h=e.call(c,n,r,o,a,l);return Dv.forEach(e=>{const t=u.get(e);if(t)try{c.setRequestHeader(e,t)}catch(e){}}),h})};h.__PosthogExtensions__.tracingHeadersPatchFns=Wv,h.postHogTracingHeadersPatchFns=Wv,"function"!=typeof[].at&&Object.defineProperty(Array.prototype,"at",{value(e){const t=this.length;let i=Math.trunc(e)||0;return 0>i&&(i+=t),0>i||i>=t?void 0:this[i]},writable:!0,enumerable:!1,configurable:!0}),"function"!=typeof[].findLast&&Object.defineProperty(Array.prototype,"findLast",{value(e,t){for(let i=this.length-1;i>=0;i--){const s=this[i];if(e.call(t,s,i,this))return s}},writable:!0,enumerable:!1,configurable:!0});var zv=class{constructor(){this.t=void 0,this.o=0,this.i=[]}l(e){var t;if(e.hadRecentInput)return;const i=this.i[0],s=this.i.at(-1);this.o&&i&&s&&1e3>e.startTime-s.startTime&&5e3>e.startTime-i.startTime?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const jv=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Vv=e=>{if("loading"===document.readyState)return"loading";const t=jv();if(t){if(t.domInteractive>e)return"loading";if(0===t.domContentLoadedEventStart||t.domContentLoadedEventStart>e)return"dom-interactive";if(0===t.domComplete||t.domComplete>e)return"dom-content-loaded"}return"complete"},Gv=e=>{const t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},Qv=e=>{let t="";try{for(;9!==(null==e?void 0:e.nodeType);){var i;const s=e,n=s.id?"#"+s.id:[Gv(s),...Array.from(null!==(i=s.classList)&&void 0!==i?i:[]).sort()].join(".");if(t.length+n.length>99)return t||n;if(t=t?n+">"+t:n,s.id)break;e=s.parentNode}}catch(e){}return t},Kv=new WeakMap;function Zv(e,t){let i=Kv.get(t);return i||(i=new WeakMap,Kv.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}let Jv=-1;const Yv=()=>Jv,Xv=e=>{addEventListener("pageshow",t=>{t.persisted&&(Jv=t.timeStamp,e(t))},!0)},em=(e,t,i,s)=>{let n,r;return o=>{var a;t.value>=0&&(o||s)&&(r=t.value-(null!==(a=n)&&void 0!==a?a:0),(r||void 0===n)&&(n=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},tm=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},im=()=>{var e,t;return null!==(e=null===(t=jv())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let sm=-1;const nm=new Set,rm=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,om=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of nm)e();isFinite(sm)||(sm="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",om,!0))}},am=(e=!1)=>{if(e&&(sm=1/0),0>sm){var t;const e=im(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;sm=null!=i?i:rm(),addEventListener("visibilitychange",om,!0),addEventListener("prerenderingchange",om,!0),Xv(()=>{setTimeout(()=>{sm=rm()})})}return{get firstHiddenTime(){return sm},onHidden(e){nm.add(e)}}},lm=(e,t=-1,i,s=0,n,r,o)=>{const a=jv(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>Yv()?a&&(document.prerendering||im()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:s||l,navigationInteractionId:n,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},cm=(e,t,i={})=>{try{const s=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(s.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();s.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of s)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},um=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},dm=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},hm=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var pm=class{constructor(){this.u=void 0}};const _m=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},gm=[1800,3e3],fm=(e,t={})=>{const i=um(t);_m(()=>{const s=Zv(t,pm),n=am();let r,o=lm("FCP");const a=cm(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),n.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-im(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=em(e,o,gm,t.reportAllChanges),Xv(i=>{o=lm("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Yv()),r=em(e,o,gm,t.reportAllChanges),tm(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&cm(["soft-navigation"],i=>{i.forEach(i=>{s.u&&i.navigationId&&dm(s.u,i);const n=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=lm("FCP",n,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=em(e,o,gm,t.reportAllChanges),r(!0)})},t)})},vm=[.1,.25],mm=e=>e.find(e=>{var t;return 1===(null===(t=e.node)||void 0===t?void 0:t.nodeType)})||e[0],ym=(e,t={})=>{const i=Zv(t=Object.assign({},t),zv),s=new WeakMap;i.t=e=>{var i;if(null==e||null===(i=e.sources)||void 0===i?void 0:i.length){const i=mm(e.sources),o=null==i?void 0:i.node;if(o){var n,r;const e=null!==(n=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,o))&&void 0!==n?n:Qv(o);s.set(i,e)}}},((e,t={})=>{const i=am();fm(hm(()=>{let s,n=lm("CLS",0);const r=Zv(t,zv),o=(i,o,a,l,c)=>{n=lm("CLS",0,i,o,a,l,c),r.o=0,s=em(e,n,vm,t.reportAllChanges)},a=(e=!1)=>{r.o>n.value&&(n.value=r.o,n.entries=r.i),s(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.l(t):l(t);a()},u=["layout-shift"];um(t)&&u.push("soft-navigation");const d=cm(u,c);d&&(s=em(e,n,vm,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),s(!0)}),Xv(()=>{o("back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,Yv()),tm(s)}),setTimeout(s))}))})(t=>{e((e=>{let t={};if(e.entries.length){var i;const n=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(null==n||null===(i=n.sources)||void 0===i?void 0:i.length){const e=mm(n.sources);e&&(t={largestShiftTarget:s.get(e),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:Vv(n.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},bm=(e,t={})=>{const i=Zv(t=Object.assign({},t),pm);um(t)&&(i.u=new Map),fm(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:Vv(Yv())};if("soft-navigation"!==e.navigationType){if(e.entries.length){const i=jv(),s=e.entries.at(-1);if(i){const n=Math.max(0,i.responseStart-(i.activationStart||0));t={timeToFirstByte:n,firstByteToFCP:e.value-n,loadState:Vv(e.entries[0].startTime),navigationEntry:i,fcpEntry:s}}}}else{var s;const n=null===(s=i.u)||void 0===s?void 0:s.get(e.navigationId);n&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:"complete",navigationEntry:n})}return Object.assign(e,{attribution:t})})(t))},t)};let Sm=0,wm=1/0,km=0;const Cm=e=>{for(const t of e)t.interactionId&&(wm=Math.min(wm,t.interactionId),km=Math.max(km,t.interactionId),Sm=km?(km-wm)/7+1:0)};let Em;const xm=()=>{var e;return Em?Sm:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var Im=class{constructor(){this.h=0,this.v=[],this.p=new Map,this.m=void 0,this.M=void 0}T(){return xm()-this.h}D(){this.h=xm(),this.v.length=0,this.p.clear()}S(e){const t=this.T(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{k:8,id:-1,entries:[]}}l(e){var t;if(null===(t=this.m)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let s=this.p.get(e.interactionId);if(s||10>this.v.length||e.duration>i.k){var n;if(s?e.duration>s.k?(s.entries=[e],s.k=e.duration):e.duration===s.k&&e.startTime===s.entries[0].startTime&&s.entries.push(e):(s={id:e.interactionId,entries:[e],k:e.duration},this.p.set(s.id,s),this.v.push(s)),this.v.sort((e,t)=>t.k-e.k),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.p.delete(t.id)}null===(n=this.M)||void 0===n||n.call(this,s)}}};const Tm=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,s=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const n=hm(e);let r=-1;const o=()=>{s(r),n()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),n()},{timeout:t})}},Mm=[200,500],Rm=(e,t={})=>{const i=Zv(t=Object.assign({},t),Im);let s=[],n=[],r=0;const o=new WeakMap,a=new WeakMap;let l=!1;const c=()=>{l||(Tm(u),l=!0)},u=()=>{const e=new Set(i.v.map(e=>o.get(e.entries[0]))),t=n.length-10;n=n.filter((i,s)=>s>=t||e.has(i));const a=new Set;for(const e of n){const t=d(e.startTime,e.processingEnd);for(const e of t)a.add(e)}s=s.filter(e=>e.startTime>r||a.has(e)),l=!1};i.m=e=>{const i=e.startTime+e.duration;let s;r=Math.max(r,e.processingEnd);for(let r=n.length-1;r>=0;r--){const o=n[r];if(8>=Math.abs(i-o.renderTime)){s=o,s.startTime=Math.min(e.startTime,s.startTime),s.processingStart=Math.min(e.processingStart,s.processingStart),s.processingEnd=Math.max(e.processingEnd,s.processingEnd),t.includeProcessedEventEntries&&s.entries.push(e);break}}s||(s={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:i,entries:t.includeProcessedEventEntries?[e]:[]},n.push(s)),e.interactionId&&o.set(e,s),c()},i.M=e=>{if(!a.get(e)){var i;const o=null===(i=e.entries.find(e=>e.target))||void 0===i?void 0:i.target;if(o){var s,n;const i=null!==(s=null===(n=t.generateTarget)||void 0===n?void 0:n.call(t,o))&&void 0!==s?s:Qv(o);a.set(e,i)}else{var r;const t=null===(r=e.entries.find(e=>e.targetSelector))||void 0===r?void 0:r.targetSelector;t&&a.set(e,t)}}};const d=(e,t)=>{const i=[];for(const n of s)if(n.startTime+n.duration>=e){if(n.startTime>t)break;i.push(n)}return i};cm(["long-animation-frame"],e=>{s=s.concat(e),c()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=am();_m(()=>{var s;"interactionCount"in performance||Em||(Em=cm(["event"],Cm,{durationThreshold:0}));let n,r=lm("INP");const o=Zv(t,Im),a=(i,s,a,l,c)=>{o.D(),r=lm("INP",-1,i,s,a,l,c),n=em(e,r,Mm,t.reportAllChanges)},l=()=>{const e=o.S(r.navigationType);e&&e.k!==r.value&&(r.value=e.k,r.entries=e.entries,n())},c=e=>{l(),n(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{Tm(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.l(t):c(t);l(),t&&n(!0)})},d=["event","first-input"];um(t)&&d.push("soft-navigation");const h=cm(d,u,ct(ct({},t),{},{durationThreshold:null!==(s=t.durationThreshold)&&void 0!==s?s:40}));n=em(e,r,Mm,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),Xv(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,Yv())}))})})(t=>{e((e=>{if(0===e.entries.length){const t={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:Vv(e.navigationStartTime||0)};return Object.assign(e,{attribution:t})}const t=e.entries[0],s=o.get(t),n=Math.max(s.processingStart,t.startTime),r=Math.max(t.startTime+t.duration,n),l=Math.min(s.processingEnd,r),c=s.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,l),h=i.p.get(t.interactionId),p={interactionTarget:a.get(h),interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:r,processedEventEntries:c,longAnimationFrameEntries:u,inputDelay:n-t.startTime,processingDuration:l-n,presentationDelay:r-l,loadState:Vv(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;const i=e.interactionTime,s=e.nextPaintTime;if(!(null===(t=e.longAnimationFrameEntries)||void 0===t?void 0:t.length)||!i||!s)return;const n=e.inputDelay,r=e.processingDuration;let o,a,l=0,c=0,u=0,d=0;for(const t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(const e of t.scripts){const t=e.startTime+e.duration;if(i>t)continue;const s=t-Math.max(i,e.startTime),u=e.duration?s/e.duration*e.forcedStyleAndLayoutDuration:0;l+=s-u,c+=u,s>d&&(a=i+n>e.startTime?"input-delay":i+n+r>e.startTime?"processing-duration":"presentation-delay",o=e,d=s)}}const h=e.longAnimationFrameEntries.at(-1),p=h?h.startTime+h.duration:0;p>=i+n+r&&(u=s-p),o&&a&&(e.longestScript={entry:o,subpart:a,intersectingDuration:d}),e.totalScriptDuration=l,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=u,e.totalUnattributedDuration=s-i-l-c-u})(p),Object.assign(e,{attribution:p})})(t))},t)};var Pm=class{constructor(){this.m=void 0,this.u=void 0}l(e){var t;null===(t=this.m)||void 0===t||t.call(this,e)}};const $=[2500,4e3];let Fm=50;const Lm=[];cm(["resource"],e=>{for(const t of e)Lm.push(t),Lm.length>Fm&&Lm.shift()});const Am=(e,t={})=>{null!=(t=Object.assign({},t)).resourceBufferSize&&(Fm=t.resourceBufferSize);const i=Zv(t,Pm),s=new WeakMap;um(t)&&(i.u=new Map),i.m=e=>{const i=e.element;if(i){var n,r;const o=null!==(n=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,i))&&void 0!==n?n:Qv(i);s.set(e,o)}else e.id&&s.set(e,`#${e.id}`)},((e,t={})=>{let i=!1;const s=um(t);_m(()=>{let n,r=am(),o=lm("LCP");const a=Zv(t,Pm),l=(s,a,l,c,u)=>{o=lm("LCP",-1,s,a,l,c,u),n=em(e,o,$,t.reportAllChanges),i=!1,"soft-navigation"===s&&(r=am(!0))},c=e=>{var t;a.u&&e.navigationId&&dm(a.u,e),i||n(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const s=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);s&&u([s])},u=e=>{t.reportAllChanges||s||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,s=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-im(),0),a.l(t),s=[t];else if("interaction-contentful-paint"===t.entryType){var i;const n=t;if(!o.navigationId)continue;if("interactionId"in n&&n.interactionId!=o.navigationInteractionId)continue;l=(null===(i=n.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),n.largestContentfulPaint&&(a.l(n.largestContentfulPaint),s=[n.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=s,n())}},d=["largest-contentful-paint"];s&&d.push("interaction-contentful-paint","soft-navigation");const h=cm(d,u);if(h){n=em(e,o,$,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;Tm(()=>{if(!i){if(!s){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,n(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});Xv(s=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Yv()),n=em(e,o,$,t.reportAllChanges),tm(()=>{o.value=performance.now()-s.timeStamp,i=!0,n(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){var n,r,o;const a=e.entries.at(-1),l=a.url&&(Lm.findLast(e=>e.name===a.url)||performance.getEntriesByType("resource").findLast(e=>e.name===a.url));let c;t.target=s.get(a),t.lcpEntry=a,a.url&&(t.url=a.url),l&&(t.lcpResourceEntry=l);let u=0,d=0;if("soft-navigation"!==e.navigationType?(c=jv(),u=null!==(n=null==c?void 0:c.activationStart)&&void 0!==n?n:0,d=null!==(r=null==c?void 0:c.responseStart)&&void 0!==r?r:0):(u=e.navigationStartTime||0,c=null===(o=i.u)||void 0===o?void 0:o.get(e.navigationId)),c){const i=Math.max(0,d-u),s=Math.max(i,l?(l.requestStart||l.startTime)-u:0),n=Math.min(e.value,Math.max(s,l?l.responseEnd-u:0));t=ct(ct({},t),{},{timeToFirstByte:i,resourceLoadDelay:s-i,resourceLoadDuration:n-s,elementRenderDelay:e.value-n,navigationEntry:c})}}return Object.assign(e,{attribution:t})})(t))},t)};let Om=-1;const Dm=()=>Om,$m=e=>{addEventListener("pageshow",t=>{t.persisted&&(Om=t.timeStamp,e(t))},!0)},Nm=(e,t,i,s)=>{let n,r;return o=>{var a;t.value>=0&&(o||s)&&(r=t.value-(null!==(a=n)&&void 0!==a?a:0),(r||void 0===n)&&(n=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},Bm=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},qm=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Hm=()=>{var e,t;return null!==(e=null===(t=qm())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let Um=-1;const Wm=new Set,zm=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,jm=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of Wm)e();isFinite(Um)||(Um="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",jm,!0))}},Vm=(e=!1)=>{if(e&&(Um=1/0),0>Um){var t;const e=Hm(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;Um=null!=i?i:zm(),addEventListener("visibilitychange",jm,!0),addEventListener("prerenderingchange",jm,!0),$m(()=>{setTimeout(()=>{Um=zm()})})}return{get firstHiddenTime(){return Um},onHidden(e){Wm.add(e)}}},Gm=(e,t=-1,i,s=0,n,r,o)=>{const a=qm(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>Dm()?a&&(document.prerendering||Hm()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:s||l,navigationInteractionId:n,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},Qm=new WeakMap;function Km(e,t){let i=Qm.get(t);return i||(i=new WeakMap,Qm.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}var Zm=class{constructor(){this.t=void 0,this.i=0,this.o=[]}h(e){var t;if(e.hadRecentInput)return;const i=this.o[0],s=this.o.at(-1);this.i&&i&&s&&1e3>e.startTime-s.startTime&&5e3>e.startTime-i.startTime?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const Jm=(e,t,i={})=>{try{const s=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(s.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();s.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of s)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},Ym=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},Xm=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},ey=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var ty=class{constructor(){this.l=void 0}};const iy=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},sy=[1800,3e3],ny=(e,t={})=>{const i=Ym(t);iy(()=>{const s=Km(t,ty),n=Vm();let r,o=Gm("FCP");const a=Jm(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),n.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-Hm(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=Nm(e,o,sy,t.reportAllChanges),$m(i=>{o=Gm("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Dm()),r=Nm(e,o,sy,t.reportAllChanges),Bm(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&Jm(["soft-navigation"],i=>{i.forEach(i=>{s.l&&i.navigationId&&Xm(s.l,i);const n=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=Gm("FCP",n,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=Nm(e,o,sy,t.reportAllChanges),r(!0)})},t)})},ry=[.1,.25],oy=(e,t={})=>{const i=Vm();ny(ey(()=>{let s,n=Gm("CLS",0);const r=Km(t,Zm),o=(i,o,a,l,c)=>{n=Gm("CLS",0,i,o,a,l,c),r.i=0,s=Nm(e,n,ry,t.reportAllChanges)},a=(e=!1)=>{r.i>n.value&&(n.value=r.i,n.entries=r.o),s(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.h(t):l(t);a()},u=["layout-shift"];Ym(t)&&u.push("soft-navigation");const d=Jm(u,c);d&&(s=Nm(e,n,ry,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),s(!0)}),$m(()=>{o("back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,Dm()),Bm(s)}),setTimeout(s))}))};let ay=0,ly=1/0,cy=0;const uy=e=>{for(const t of e)t.interactionId&&(ly=Math.min(ly,t.interactionId),cy=Math.max(cy,t.interactionId),ay=cy?(cy-ly)/7+1:0)};let dy;const hy=()=>{var e;return dy?ay:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var py=class{constructor(){this.u=0,this.v=[],this.m=new Map,this.p=void 0,this.T=void 0}_(){return hy()-this.u}M(){this.u=hy(),this.v.length=0,this.m.clear()}L(e){const t=this._(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{P:8,id:-1,entries:[]}}h(e){var t;if(null===(t=this.p)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let s=this.m.get(e.interactionId);if(s||10>this.v.length||e.duration>i.P){var n;if(s?e.duration>s.P?(s.entries=[e],s.P=e.duration):e.duration===s.P&&e.startTime===s.entries[0].startTime&&s.entries.push(e):(s={id:e.interactionId,entries:[e],P:e.duration},this.m.set(s.id,s),this.v.push(s)),this.v.sort((e,t)=>t.P-e.P),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.m.delete(t.id)}null===(n=this.T)||void 0===n||n.call(this,s)}}};const _y=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,s=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const n=ey(e);let r=-1;const o=()=>{s(r),n()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),n()},{timeout:t})}},gy=[200,500],fy=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=Vm();iy(()=>{var s;"interactionCount"in performance||dy||(dy=Jm(["event"],uy,{durationThreshold:0}));let n,r=Gm("INP");const o=Km(t,py),a=(i,s,a,l,c)=>{o.M(),r=Gm("INP",-1,i,s,a,l,c),n=Nm(e,r,gy,t.reportAllChanges)},l=()=>{const e=o.L(r.navigationType);e&&e.P!==r.value&&(r.value=e.P,r.entries=e.entries,n())},c=e=>{l(),n(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{_y(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.h(t):c(t);l(),t&&n(!0)})},d=["event","first-input"];Ym(t)&&d.push("soft-navigation");const h=Jm(d,u,ct(ct({},t),{},{durationThreshold:null!==(s=t.durationThreshold)&&void 0!==s?s:40}));n=Nm(e,r,gy,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),$m(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,Dm())}))})};var vy=class{constructor(){this.p=void 0,this.l=void 0}h(e){var t;null===(t=this.p)||void 0===t||t.call(this,e)}};const my=[2500,4e3],yy=(e,t={})=>{let i=!1;const s=Ym(t);iy(()=>{let n,r=Vm(),o=Gm("LCP");const a=Km(t,vy),l=(s,a,l,c,u)=>{o=Gm("LCP",-1,s,a,l,c,u),n=Nm(e,o,my,t.reportAllChanges),i=!1,"soft-navigation"===s&&(r=Vm(!0))},c=e=>{var t;a.l&&e.navigationId&&Xm(a.l,e),i||n(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const s=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);s&&u([s])},u=e=>{t.reportAllChanges||s||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,s=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-Hm(),0),a.h(t),s=[t];else if("interaction-contentful-paint"===t.entryType){var i;const n=t;if(!o.navigationId)continue;if("interactionId"in n&&n.interactionId!=o.navigationInteractionId)continue;l=(null===(i=n.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),n.largestContentfulPaint&&(a.h(n.largestContentfulPaint),s=[n.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=s,n())}},d=["largest-contentful-paint"];s&&d.push("interaction-contentful-paint","soft-navigation");const h=Jm(d,u);if(h){n=Nm(e,o,my,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;_y(()=>{if(!i){if(!s){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,n(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});$m(s=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,Dm()),n=Nm(e,o,my,t.reportAllChanges),Bm(()=>{o.value=performance.now()-s.timeStamp,i=!0,n(!0)})})}})},by={onLCP:Am,onCLS:ym,onFCP:bm,onINP:Rm,withoutAttribution:{onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution-soft-navs"]=by,h.__PosthogExtensions__.postHogWebVitalsCallbacks=by,h.postHogWebVitalsCallbacks=by;const Sy={onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-soft-navs"]=Sy,h.__PosthogExtensions__.postHogWebVitalsCallbacks=Sy,h.postHogWebVitalsCallbacks=Sy,h.__PosthogExtensions__.loadWebVitalsCallbacks=()=>Sy;const wy={onLCP:Am,onCLS:ym,onFCP:bm,onINP:Rm,withoutAttribution:{onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution"]=wy,h.__PosthogExtensions__.postHogWebVitalsCallbacks=wy,h.postHogWebVitalsCallbacks=wy;const ky={onLCP:yy,onCLS:oy,onFCP:ny,onINP:fy};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},h.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals"]=ky,h.__PosthogExtensions__.postHogWebVitalsCallbacks=ky,h.postHogWebVitalsCallbacks=ky,h.__PosthogExtensions__.loadWebVitalsCallbacks=()=>ky;var Cy=class{constructor(e){this.disabled=!1===e;const t=Et(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;const 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}};const Ey="$copy_autocapture",xy=Gn("[AutoCapture]");function Iy(e,t){return t.length>e?t.slice(0,e)+"...":t}function Ty(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!vr(t));return t}function My(t,{e:i,maskAllElementAttributes:s,maskAllText:n,elementAttributeIgnoreList:r,elementsChainAsString:o,disableCaptureUrlHashes:a}){var l,c;if(!vr(t))return{props:{}};const u=[t],d=new Set([t]);let h=t;for(;h.parentNode&&!mr(h,"body")&&1e3>u.length;){if(br(h.parentNode)){const e=h.parentNode.host;if(d.has(e))break;d.add(e),u.push(e),h=e;continue}if(!vr(h.parentNode))break;if(d.has(h.parentNode))break;d.add(h.parentNode),u.push(h.parentNode),h=h.parentNode}const p="click"===i.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?u.findIndex(e=>mr(e,"button")||mr(e,"a")):-1;p>0&&(n=n||u.slice(0,p+1).some(e=>!Ur(e)||Wr(e)));const _=[],g={};let f,v=!1,m=!1;if(Kn(u,e=>{const t=Ur(e);if(mr(e,"a")&&!s&&!(null==r?void 0:r.includes("href"))){const i=e.getAttribute("href");v=!!(t&&i&&Jr(i))&&(a?ls(i):i)}ft(kr(e),"ph-no-capture")&&(m=!0),_.push(function(e,t,i,s,n=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};Ir.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?Iy(1024,Yr(e)):Iy(1024,Er(e)));const a=kr(e);t||(null==s?void 0:s.includes("class"))||0>=a.length||(o.classes=a.filter(function(e){return""!==e})),Kn(e.attributes,function(i){var r;if((!Wr(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==s?void 0:s.includes(i.name))&&!t&&Jr(i.value)&&(!Tt(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=Sr(e).join(" ")),o["attr__"+i.name]=Iy(1024,"href"===i.name&&n?ls(e):e)}});let l=1,c=1,u=e;for(;u=Ty(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}(e,s,n,r,a)),Kn(function(e){if(!Ur(e))return{};const t={};return Kn(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Jr(s)&&(t[i]=s)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(g,t)||(g[t]=e)})}),m)return{props:{},explicitNoCapture:m};if(p>0&&(t=u[p],_.splice(0,p)),n||(_[0].$el_text=mr(t,"a")||mr(t,"button")?Yr(t):Er(t)),v){var y,b;_[0].attr__href=v;const t=null===(y=ar(v))||void 0===y?void 0:y.host,i=null==e||null===(b=e.location)||void 0===b?void 0:b.host;t&&i&&t!==i&&(f=v)}return{props:Zn((w=i.type,{$event_type:w,$ce_version:1}),o?{}:{$elements:_},{$elements_chain:(S=_,kt(S)?function(e){return e.map(e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n=ct(ct(ct(ct({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return Jn(n).sort(([e],[t])=>function(e,t){return t>e?-1:e>t?1:0}(e,t)).forEach(([e,t])=>r[eo(e.toString())]=eo(t.toString())),s+=":",s+=Jn(r).map(([e,t])=>`${e}="${t}"`).join(""),s}).join(";")}(function(e){return e.map(e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:to(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Jn(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>s.attributes[e]=t),s})}(S)):"")},(null===(l=_[0])||void 0===l?void 0:l.$el_text)?{$el_text:null===(c=_[0])||void 0===c?void 0:c.$el_text}:{},f&&"click"===i.type?{$external_click_url:f}:{},g),target:t};var S,w}var Ry=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!Ur(e))return!0;const i=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:Pr,s=new Set;let n=e;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const e=n,t=kr(e);if(ft(t,"ph-no-capture")||ft(t,"ph-sensitive")||Wr(e)||i.some(t=>Tr(e,t)))return!0;const r=n.parentNode;n=br(r)?r.host:r&&vr(r)?r:null}return!1}_trackPointer(e){if(!this.isEnabled||"pointercancel"===e.type)return void this._clearPointer();if("pointerdown"===e.type){this._clearPointer();const i=xr(e);var t;return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&vr(i)&&(this._pointerDown={target:i,excluded:this._isExcludedPointerTarget(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this._client)||void 0===t?void 0:t.distinctId}))}const i=this._pointerDown;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this._clearPointer():"pointerup"===e.type&&(i.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){var t;const i=this._pointerDown;this._clearPointer();const n=xr(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this._client)||void 0===t?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)&&n&&(mr(n,"html")||mr(n,"body"))){var r;if(i.excluded)return null;const e=null!==(r=this._refreshConfig().css_selector_ignorelist)&&void 0!==r?r:Pr;return[n,null==s?void 0:s.documentElement,null==s?void 0:s.body].some(t=>{if(!t)return!1;const i=kr(t);return ft(i,"ph-no-capture")||ft(i,"ph-sensitive")||!Ur(t)||Wr(t)||e.some(e=>Tr(t,e))})?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 Cy(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;const 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)||void 0===e||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?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null===(t=this._config.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){if(!this.isBrowserSupported())return void xy.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!s)return;const t=this._domEventHandler=t=>{t=t||(null==e?void 0:e.event);try{if("blur"===t.type)return void this._clearPointer();if(0===t.type.indexOf("pointer"))return void this._trackPointer(t);const e="click"===t.type?this._recoverClickTarget(t):void 0;if(Rt(e))return;this._captureEvent(t,"$autocapture",e)}catch(e){xy.error("Failed to capture event",e)}};if(sr(e,"blur",t),sr(s,"submit",t,{capture:!0}),sr(s,"change",t,{capture:!0}),sr(s,"click",t,{capture:!0}),Kn(["pointerdown","pointermove","pointerup","pointercancel"],e=>{sr(s,e,t,{capture:!0})}),this._refreshConfig().capture_copied_text){const t=this._copiedTextHandler=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t,Ey)}catch(e){xy.error("Failed to capture clipboard event",e)}};sr(s,"copy",t,{capture:!0}),sr(s,"cut",t,{capture:!0}),sr(s,"paste",t,{capture:!0})}}_removeDomEventHandlers(){this._clearPointer(),this._domEventHandler&&(null==e||e.removeEventListener("blur",this._domEventHandler),Kn(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==s||s.removeEventListener(e,this._domEventHandler,!0)}),null==s||s.removeEventListener("submit",this._domEventHandler,!0),null==s||s.removeEventListener("change",this._domEventHandler,!0),null==s||s.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==s||s.removeEventListener("copy",this._copiedTextHandler,!0),null==s||s.removeEventListener("cut",this._copiedTextHandler,!0),null==s||s.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)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);const i=t.autocapture_opt_out;var s;At(i)&&(null===(s=this._client)||void 0===s||s.kv.set("$autocapture_disabled_server_side",i),this._isDisabledServerSide=i),this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e,t){var i;const n=[];return null===(i=this._elementSelectors)||void 0===i||i.forEach(i=>{const r=null==s?void 0:s.querySelectorAll(i);null==r||r.forEach(s=>{e!==s&&t!==s||ft(n,i)||n.push(i)})}),n}get isEnabled(){var e,t;if(this._disposed)return!1;const i=null===(e=this._client)||void 0===e?void 0:e.kv.get(C),s=this._isDisabledServerSide,n=this._refreshConfig();if(!n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;const r=n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(Rt(s)&&!At(i)&&!r)return!1;const o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!n.enabled&&!o}_captureEvent(t,i="$autocapture",s){if(!this.isEnabled)return void this._clearPointer();let n=s||xr(t);yr(n)&&(n=n.parentNode||null);const r=this._compileUrlPatterns();var o;"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&r.rageclick&&(null===(o=this.rageclicks)||void 0===o?void 0:o.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime()))&&Br(n,r.rageclick)&&this._captureEvent(t,"$rageclick",s);const a=i===Ey,l=a?ct(ct({},r),{},{dom_event_allowlist:void 0}):r;if(n&&function(t,i,s,n,r,o){var a;if(!e||qr(t))return!1;if((null==s?void 0:s.url_allowlist)&&!wr(s.url_allowlist,o))return!1;if((null==s?void 0:s.url_ignorelist)&&wr(s.url_ignorelist,o))return!1;if(null==s?void 0:s.dom_event_allowlist){const e=s.dom_event_allowlist;if(e&&!e.some(e=>i.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=Hr(t,n);if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(It(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,s))return!1;if(!Mr(c,null==s?void 0:s.css_selector_allowlist))return!1;if(Mr(c,null!==(a=null==s?void 0:s.css_selector_ignorelist)&&void 0!==a?a:Pr))return!1;try{const s=e.getComputedStyle(t);if(s&&"pointer"===s.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(e){}const u=t.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(r||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(i.type)>=0;default:return l?(r||["click"]).indexOf(i.type)>=0:(r||["click"]).indexOf(i.type)>=0&&(Ir.indexOf(u)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,l,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var c;const{props:s,explicitNoCapture:o,target:a}=My(n,{e:t,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(o)return!1;const l=this.getElementSelectors(n,a);if(l&&l.length>0&&(s.$element_selectors=l),i===Ey){const i=t.type||"clipboard";if("paste"!==i){var u,d;const t=null==e||null===(u=e.getSelection())||void 0===u?void 0:u.toString(),i=Cr(t);if(!i)return!1;s.$selected_content=i,s.$clipboard_text_length=null!==(d=null==t?void 0:t.length)&&void 0!==d?d:0}s.$copy_type=i}return null===(c=this._client)||void 0===c||c.capture(i,s).catch(e=>xy.error("Failed to capture event",e)),!0}}isBrowserSupported(){return Ct(null==s?void 0:s.querySelectorAll)}};const Py={};function Fy(e,t){const i=xr(e);return i?ct({node:i,originalEvent:e,timestamp:Date.now()},t):null}function Ly(e,t){return Math.abs(e)<Math.abs(t)?0>t?"up":"down":0>e?"left":"right"}function Ay(e){return"swipe"===e.type?"$dead_swipe":"$dead_click"}const Oy="canvas,video,audio,embed,object";function Dy(e,t){return Ft(e)&&e>=t}function $y(e,t=1e3){return e>=0&&t>e?e:void 0}function Ny(e,t,i=1e3){return Ft(t)?$y(e-t,i):void 0}var By=class{_asRequiredConfig(e){var t,i,s,n,r,o,a,l;const c=this._defaultConfig((null==e?void 0:e.__onCapture)||this._captureDeadClick.bind(this));return{element_attribute_ignorelist:null!==(t=null==e?void 0:e.element_attribute_ignorelist)&&void 0!==t?t:c.element_attribute_ignorelist,scroll_threshold_ms:null!==(i=null==e?void 0:e.scroll_threshold_ms)&&void 0!==i?i:c.scroll_threshold_ms,selection_change_threshold_ms:null!==(s=null==e?void 0:e.selection_change_threshold_ms)&&void 0!==s?s:c.selection_change_threshold_ms,mutation_threshold_ms:null!==(n=null==e?void 0:e.mutation_threshold_ms)&&void 0!==n?n:c.mutation_threshold_ms,capture_clicks_with_modifier_keys:null!==(r=null==e?void 0:e.capture_clicks_with_modifier_keys)&&void 0!==r?r:c.capture_clicks_with_modifier_keys,capture_dead_swipes:null!==(o=null==e?void 0:e.capture_dead_swipes)&&void 0!==o?o:c.capture_dead_swipes,swipe_threshold_px:null!==(a=null==e?void 0:e.swipe_threshold_px)&&void 0!==a?a:c.swipe_threshold_px,max_dead_swipes_per_page_load:null!==(l=null==e?void 0:e.max_dead_swipes_per_page_load)&&void 0!==l?l:c.max_dead_swipes_per_page_load,css_selector_ignorelist:null==e?void 0:e.css_selector_ignorelist,__onCapture:c.__onCapture}}constructor(e,t){this.instance=e,this._hadSelection=!1,this._clicks=[],this._deadSwipesCaptured=0,this._defaultConfig=e=>({element_attribute_ignorelist:[],scroll_threshold_ms:100,selection_change_threshold_ms:100,mutation_threshold_ms:2500,capture_clicks_with_modifier_keys:!1,capture_dead_swipes:!0,swipe_threshold_px:30,max_dead_swipes_per_page_load:10,__onCapture:e}),this._clearMouseSelection=()=>{clearTimeout(this._mouseSelectionTimer),this._mouseSelectionTimer=void 0,this._mouseSelection=void 0},this._onMouseDown=e=>{if(this._clearMouseSelection(),0===e.button){const t={path:e.composedPath(),trusted:e.isTrusted,selectionChanged:!1,selectionInitiallyRelated:!1},i=null==s?void 0:s.getSelection();t.selectionInitiallyRelated="Range"===(null==i?void 0:i.type)&&this._selectionTouchesGesture(i,t),this._mouseSelection=t}},this._onMouseOut=e=>{Rt(e.relatedTarget)&&this._clearMouseSelection()},this._onMouseUp=e=>{const t=this._mouseSelection,i=e;if(!t||0!==i.button||e.isTrusted!==t.trusted)return;const s=e.composedPath();for(const e of t.path)if(vr(e)&&-1!==s.indexOf(e)){t.clickTarget=e;break}t.clickDetail=i.detail,this._mouseSelectionTimer=h.setTimeout(this._clearMouseSelection,0)},this._onClick=e=>{const t=e,i=Fy(t,{type:"click"}),s=this._mouseSelection;i&&s&&0===t.button&&t.detail>0&&t.detail===s.clickDetail&&e.isTrusted===s.trusted&&i.node===s.clickTarget&&(i.selectionChangedDuringGesture=s.selectionChanged&&this._config.selection_change_threshold_ms>0,this._clearMouseSelection()),Rt(i)||this._ignore(i)||this._queueCandidate(i),this._scheduleCheck()},this._onScroll=()=>{const e=Date.now();this._lastScroll=e,e%50==0&&this._clicks.forEach(t=>{It(t.scrollDelayMs)&&(t.scrollDelayMs=e-t.timestamp)})},this._onSelectionChange=e=>{var t,i;const n=null==s?void 0:s.getSelection(),r=this._hadSelection;this._hadSelection="Range"===(null==n?void 0:n.type);const o=null==n?void 0:n.focusNode,a=o&&(vr(o)?o:o.parentElement),l=null==s?void 0:s.activeElement;let c=l;for(;null==c||null===(t=c.shadowRoot)||void 0===t?void 0:t.activeElement;)c=c.shadowRoot.activeElement;const u=Nr(xr(e))||Nr(null!=a?a:null)||Nr(null!==(i=c)&&void 0!==i?i:null),d="Caret"===(null==n?void 0:n.type)&&c&&!c.shadowRoot&&o&&o!==l&&o.contains(null!=l?l:null);if(!(r||this._hadSelection||u||d))return;const h=Date.now();this._lastSelectionChanged=h;const p=this._mouseSelection;if(p&&(r||this._hadSelection||u)){const t=xr(e);let i;if(Nr(t))i=t;else if("Caret"===(null==n?void 0:n.type)){var _;Nr(null!==(_=c)&&void 0!==_?_:null)||d?i=c:u&&(i=a)}const s=i?this._selectionIsInGesture(i,p):n&&(o||n.anchorNode)?this._selectionTouchesGesture(n,p):r&&!this._hadSelection&&p.selectionInitiallyRelated;p.selectionChanged=p.selectionChanged||s}this._clicks.forEach(e=>{const t=h-e.timestamp;0>t||!It(e.selectionChangedDelayMs)&&t>=e.selectionChangedDelayMs||(e.selectionChangedDelayMs=t)})},this._onVisibilityChange=()=>{"hidden"===(null==s?void 0:s.visibilityState)&&this._clearMouseSelection();const e=Date.now();this._lastVisibilityChange=e,this._recordLivenessSignal("visibilityChangedDelayMs",e)},this._onFocusChange=()=>{const e=Date.now();this._lastFocusChange=e,this._recordLivenessSignal("focusChangedDelayMs",e)},this._onTouchStart=e=>{const t=e.touches,i=1===(null==t?void 0:t.length)?t[0]:void 0;this._touchStart=i?{x:i.clientX,y:i.clientY,timestamp:Date.now()}:void 0},this._onTouchCancel=()=>{this._touchStart=void 0},this._onTouchEnd=e=>{var t;const i=this._touchStart;if(this._touchStart=void 0,It(i)||this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)return;const n=e,r=null===(t=n.changedTouches)||void 0===t?void 0:t[0];if(!r)return;const o=r.clientX-i.x,a=r.clientY-i.y,l=o*o+a*a,c=this._config.swipe_threshold_px;if(c*c>l)return;if([this._lastScroll,this._lastMutation,this._lastSelectionChanged].some(e=>Ft(e)&&e>=i.timestamp))return;var u,d;if(this._pageHasUnobservableSurfaces()&&(null!==(u=null==s||null===(d=s.elementsFromPoint)||void 0===d?void 0:d.call(s,i.x,i.y))&&void 0!==u?u:[]).some(e=>{var t;return null===(t=e.matches)||void 0===t?void 0:t.call(e,Oy)}))return;const h=Fy(n,{type:"swipe",swipeDirection:Ly(o,a),swipeDistancePx:Math.round(Math.sqrt(l))});Rt(h)||this._ignore(h)||this._queueCandidate(h),this._scheduleCheck()},this._config=this._asRequiredConfig(t),this._onCapture=this._config.__onCapture}start(e){this._startClickObserver(),this._startScrollObserver(),this._startSelectionChangedObserver(),this._startVisibilityChangeObserver(),this._startFocusChangeObserver(),this._startMutationObserver(e),this._config.capture_dead_swipes&&this._startSwipeObserver()}_startMutationObserver(t){if(!this._mutationObserver){const i=function(t){return function(t,i){const s=Py[t];if(s)return s;let n=i[t];if((e=>Ct(e)&&-1!==e.toString().indexOf("[native code]"))(n)&&!(null==e?void 0:e.Zone))return Py[t]=n.bind(i);const r=i.document;if(r&&Ct(r.createElement)){let e,s=!1;try{e=r.createElement("iframe"),e.hidden=!0,r.head.appendChild(e);const l=e.contentWindow;var o,a;l&&l[t]&&(n=l[t],"MutationObserver"===t&&function(e){return ft(e,"AppleWebKit")&&!ft(e,"Chrome")}(null!==(o=null===(a=i.navigator)||void 0===a?void 0:a.userAgent)&&void 0!==o?o:"")&&(e.classList.add("rr-block","ph-no-capture"),s=!0))}catch(e){Vn.warn(`Could not create sandbox iframe for ${t} check, bailing to assignableWindow.${t}: `,e)}finally{!s&&(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}}return n&&Ct(n)?Py[t]=n.bind(i):n}("MutationObserver",t)}(h);this._mutationObserver=new i(e=>{this._onMutation(e)}),this._mutationObserver.observe(t,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}}stop(){var e;null===(e=this._mutationObserver)||void 0===e||e.disconnect(),this._mutationObserver=void 0,h.removeEventListener("click",this._onClick,{capture:!0}),h.removeEventListener("mousedown",this._onMouseDown,{capture:!0}),h.removeEventListener("mouseup",this._onMouseUp,{capture:!0}),h.removeEventListener("mouseout",this._onMouseOut,{capture:!0}),h.removeEventListener("dragstart",this._clearMouseSelection,{capture:!0}),h.removeEventListener("pointercancel",this._clearMouseSelection,{capture:!0}),h.removeEventListener("blur",this._clearMouseSelection),this._clearMouseSelection(),h.removeEventListener("scroll",this._onScroll,{capture:!0}),null==s||s.removeEventListener("selectionchange",this._onSelectionChange),h.removeEventListener("touchstart",this._onTouchStart,{capture:!0}),h.removeEventListener("touchend",this._onTouchEnd,{capture:!0}),h.removeEventListener("touchcancel",this._onTouchCancel,{capture:!0}),null==s||s.removeEventListener("visibilitychange",this._onVisibilityChange),h.removeEventListener("blur",this._onFocusChange),h.removeEventListener("focus",this._onFocusChange),this._touchStart=void 0}_onMutation(e){this._lastMutation=Date.now()}_startClickObserver(){sr(h,"click",this._onClick,{capture:!0}),sr(h,"mousedown",this._onMouseDown,{capture:!0}),sr(h,"mouseup",this._onMouseUp,{capture:!0}),sr(h,"mouseout",this._onMouseOut,{capture:!0}),sr(h,"dragstart",this._clearMouseSelection,{capture:!0}),sr(h,"pointercancel",this._clearMouseSelection,{capture:!0}),sr(h,"blur",this._clearMouseSelection)}_queueCandidate(e){e.selectionChangedDelayMs=Ny(e.timestamp,this._lastSelectionChanged,this._config.selection_change_threshold_ms),e.visibilityChangedDelayMs=Ny(e.timestamp,this._lastVisibilityChange),e.focusChangedDelayMs=Ny(e.timestamp,this._lastFocusChange),this._clicks.push(e)}_scheduleCheck(){this._clicks.length&&It(this._checkClickTimer)&&(this._checkClickTimer=h.setTimeout(()=>{this._checkClicks()},1e3))}_startScrollObserver(){sr(h,"scroll",this._onScroll,{capture:!0})}_startSelectionChangedObserver(){var e;this._hadSelection="Range"===(null==s||null===(e=s.getSelection())||void 0===e?void 0:e.type),sr(s,"selectionchange",this._onSelectionChange)}_selectionIsInGesture(e,t){const i=t.path[0];for(;e;){if(-1!==t.path.indexOf(e)||vr(i)&&i.contains(e))return!0;e=e.getRootNode().host}return!1}_selectionTouchesGesture(e,t){const i=t.path[0],s=e.rangeCount>0?e.getRangeAt(0):void 0;if(s&&vr(i)&&s.startContainer.getRootNode()===i.getRootNode()){var n;if(!s.collapsed)return s.intersectsNode(i);const e=vr(s.startContainer)&&null!==(n=s.startContainer.childNodes[s.startOffset])&&void 0!==n?n:s.startContainer;return this._selectionIsInGesture(e,t)}return this._selectionIsInGesture(e.focusNode,t)||this._selectionIsInGesture(e.anchorNode,t)}_startVisibilityChangeObserver(){sr(s,"visibilitychange",this._onVisibilityChange)}_startFocusChangeObserver(){sr(h,"blur",this._onFocusChange),sr(h,"focus",this._onFocusChange)}_recordLivenessSignal(e,t){this._clicks.forEach(i=>{const s=$y(t-i.timestamp);Ft(s)&&(It(i[e])||i[e]>s)&&(i[e]=s)})}_startSwipeObserver(){sr(h,"touchstart",this._onTouchStart,{capture:!0,passive:!0}),sr(h,"touchend",this._onTouchEnd,{capture:!0,passive:!0}),sr(h,"touchcancel",this._onTouchCancel,{capture:!0,passive:!0})}_pageHasUnobservableSurfaces(){const e=It(this._surfacesCheckedAt)||Ft(this._lastMutation)&&this._lastMutation>this._surfacesCheckedAt;return(It(this._hasUnobservableSurfaces)||e)&&(this._surfacesCheckedAt=Date.now(),this._hasUnobservableSurfaces=!!(null==s?void 0:s.querySelector(Oy))),!!this._hasUnobservableSurfaces}_ignore(e){return!e||("swipe"===e.type?this._ignoreCommon(e):this._ignoreClick(e))}_ignoreCommon(t){return!(!fr(t.node)&&!this._clicks.some(e=>e.type===t.type&&e.node===t.node&&1e3>Math.abs(e.timestamp-t.timestamp))&&!mr(t.node,"html")&&vr(t.node)&&function(t,i){var s;if(!e||qr(t))return!1;const n=At(i)?Or:null!==(s=null==i?void 0:i.css_selector_ignorelist)&&void 0!==s?s:Or,{targetElementList:r}=Hr(t,!1);return!Mr(r,n)}(t.node,{css_selector_ignorelist:this._config.css_selector_ignorelist}))}_ignoreClick(t){return!(this._config.capture_clicks_with_modifier_keys||(i=t.originalEvent,!(i.ctrlKey||i.metaKey||i.altKey||i.shiftKey)))||!!this._ignoreCommon(t)||function(t){if(!e||qr(t))return!1;const{targetElementList:i}=Hr(t,!1);return i.some(e=>mr(e,"a"))}(t.node);var i}_checkClicks(){if(!this._clicks.length)return;clearTimeout(this._checkClickTimer),this._checkClickTimer=void 0;const e=this._clicks;this._clicks=[];for(const i of e){var t;i.mutationDelayMs=null!==(t=i.mutationDelayMs)&&void 0!==t?t:this._lastMutation&&this._lastMutation>=i.timestamp?this._lastMutation-i.timestamp:void 0,i.absoluteDelayMs=Date.now()-i.timestamp;const e=Dy(i.scrollDelayMs,this._config.scroll_threshold_ms),s=Dy(i.selectionChangedDelayMs,this._config.selection_change_threshold_ms),n=Dy(i.mutationDelayMs,this._config.mutation_threshold_ms),r=Dy(i.absoluteDelayMs,1.1*this._config.mutation_threshold_ms),o=Ft(i.scrollDelayMs)&&this._config.scroll_threshold_ms>i.scrollDelayMs,a=Ft(i.mutationDelayMs)&&this._config.mutation_threshold_ms>i.mutationDelayMs,l=i.selectionChangedDuringGesture||Ft(i.selectionChangedDelayMs)&&this._config.selection_change_threshold_ms>i.selectionChangedDelayMs,c=Ft(i.visibilityChangedDelayMs),u=Ft(i.focusChangedDelayMs);if(!(o||a||l||c||u))if(e||n||r||s){const t=Ay(i);if("$dead_swipe"===t){if(this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)continue;this._deadSwipesCaptured++}this._onCapture(i,{[`${t}_last_mutation_timestamp`]:this._lastMutation,[`${t}_event_timestamp`]:i.timestamp,[`${t}_scroll_timeout`]:e,[`${t}_mutation_timeout`]:n,[`${t}_absolute_timeout`]:r,[`${t}_selection_changed_timeout`]:s,[`${t}_visibility_changed_timeout`]:!1})}else this._config.mutation_threshold_ms>i.absoluteDelayMs&&this._clicks.push(i)}this._scheduleCheck()}_captureDeadClick(e,t){const i=Ay(e);this.instance.capture(i,ct(ct(ct({},t),My(e.node,{e:e.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:!1,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}).props),{},{[`${i}_scroll_delay_ms`]:e.scrollDelayMs,[`${i}_mutation_delay_ms`]:e.mutationDelayMs,[`${i}_absolute_delay_ms`]:e.absoluteDelayMs,[`${i}_selection_changed_delay_ms`]:e.selectionChangedDelayMs,[`${i}_visibility_changed_delay_ms`]:e.visibilityChangedDelayMs,[`${i}_focus_changed_delay_ms`]:e.focusChangedDelayMs,$dead_swipe_direction:e.swipeDirection,$dead_swipe_distance_px:e.swipeDistancePx}),{timestamp:new Date(e.timestamp)})}};h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.initDeadClicksAutocapture=(e,t)=>new By(e,t);var qy=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(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){const e=this._storage._get(this._storageKey);return zt(e)?1:ft(jt,e)?0:-1}get _storage(){const e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?$a:Oa,i=t._is_supported()?t:Ka;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;const t="localStorage"===e?Oa:$a;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(zt(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,h.doNotTrack,null==i?void 0:i.globalPrivacyControl].some(e=>zt(e))}};const Hy=Gn("[Dead Clicks]"),Uy=()=>!0,Wy=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property(R)),s=e.instance.config.capture_dead_clicks;return At(s)?s:!!Et(s)||i};var zy=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)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[R]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",t=>{t?Hy.error("failed to load script",t):e()})}_start(){var e;if(s){if(!this._lazyLoadedDeadClicksAutocapture&&(null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=Et(this.instance.config.capture_dead_clicks)?ct({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=h.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(s),Hy.info("starting...")}}else Hy.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Hy.info("stopping..."))}};const jy=Gn("[SegmentIntegration]");function Vy(e,t,i=!0){const s=e.config.segment;if(!s)return t();const{analytics:n,filterProperties:r}=(e=>Ct(e.register))(o=s)?{analytics:o}:o;var o;!function(e,t,i,s){const n=t=>{const n=()=>t.anonymousId()||Ra();e.config.get_device_id=n,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:n()}),e.persistence.set_property(xe,Ze)),i(s?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&Ct(r.then)?r.then(n):n(r)}(e,n,i=>{n.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||jy.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!t&&s.event.anonymousId===t&&!s.event.userId;r||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(jy.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(jy.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));let o=e.calculateEventProperties(n,s.event.properties);if(!Pt(i)){const e=s.event.properties||{},t={};for(const i of Object.keys(o))St.call(e,i)||(t[i]=o[i]);const n=((e,t)=>{const i=kt(e)?e:[e];let s=ct({},t);for(const e of i)try{if(s=e(s),Pt(s))return null}catch(e){return jy.error("Error in Segment filterProperties:",e),null}return s})(i,t);if(Pt(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return s(e,e.event.event)},page(e){return s(e,et)},identify(e){return s(e,it)},screen(e){return s(e,"$screen")}}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{jy.error("Failed to register the Segment integration",e),t()})},i)}const Gy="posthog-js";function Qy(e,{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==n&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],_=p.map(e=>ct(ct({},e),{},{stacktrace:e.stacktrace?ct(ct({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>ct(ct({},e),{},{platform:"web:javascript"}))}):void 0})),g={$exception_message:(null===(l=p[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=p[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:_,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=p[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=p[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var f;return t&&i&&(g.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(f=e.exceptions)||void 0===f||f.sendExceptionEvent(g)),o}}var Ky=class{constructor(e,t,i,s,n,r){this.name=Gy,this.setupOnce=function(o){o(Qy(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},Zy=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Vn.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?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null===(e=this._unsubscribeSessionId)||void 0===e||e.call(this),this._unsubscribeSessionId=void 0}doPageView(t,i){var s;const n=this._previousPageViewProperties(t,i);return this._currentPageview={pathname:null!==(s=null==e?void 0:e.location.pathname)&&void 0!==s?s:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),n}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){const i=this._currentPageview;if(!i)return{$pageview_id:t};let s={$pageview_id:t,$prev_pageview_id:i.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=n;if(!(It(e)||It(t)||It(i)||It(r)||It(o)||It(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const n=e>1?Qt(t/e,0,1,Vn):1,l=e>1?Qt(i/e,0,1,Vn):1,c=r>1?Qt(o/r,0,1,Vn):1,u=r>1?Qt(a/r,0,1,Vn):1;s=Zn(s,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}};const Jy=["flags","surveys"],Yy={[p]:{exposure:"hidden"},[v]:{exposure:"hidden"},[m]:{exposure:"hidden"},[k]:{exposure:"hidden"},[b]:{exposure:"hidden"},[w]:{exposure:"hidden"},[C]:{exposure:"event"},[E]:{exposure:"hidden"},[F]:{exposure:"hidden"},[x]:{exposure:"event"},[I]:{exposure:"hidden"},[T]:{exposure:"event"},[M]:{exposure:"event"},[R]:{exposure:"event"},[P]:{exposure:"hidden"},[L]:{exposure:"event"},[A]:{exposure:"hidden"},[O]:{exposure:"hidden"},[U]:{exposure:"hidden"},[W]:{exposure:"event"},[D]:{exposure:"event",shouldSkipFromEventProperties:e=>Rt(e)},[z]:{exposure:"event"},[j]:{exposure:"event"},[V]:{exposure:"event"},[Z]:{exposure:"event"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden",storageGroup:"flags"},[X]:{exposure:"hidden",storageGroup:"flags"},[ee]:{exposure:"hidden"},[te]:{exposure:"hidden",storageGroup:"flags"},[ie]:{exposure:"hidden",storageGroup:"flags"},[se]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ne]:{exposure:"hidden",storageGroup:"flags"},[re]:{exposure:"hidden"},[oe]:{exposure:"hidden"},[ae]:{exposure:"hidden"},[le]:{exposure:"hidden"},[ue]:{exposure:"hidden",storageGroup:"surveys"},[de]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[he]:{exposure:"event"},[pe]:{exposure:"hidden"},[_e]:{exposure:"hidden"},[ge]:{exposure:"hidden"},[fe]:{exposure:"hidden"},[ve]:{exposure:"hidden"},[me]:{exposure:"event"},[ye]:{exposure:"event"},[be]:{exposure:"event"},[Se]:{exposure:"event"},[we]:{exposure:"hidden"},[ke]:{exposure:"hidden"},[ce]:{exposure:"event"},[Ce]:{exposure:"hidden"},[Ee]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[xe]:{exposure:"hidden"},[Ie]:{exposure:"hidden"},[Te]:{exposure:"hidden"},[Me]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[Fe]:{exposure:"hidden"},[N]:{exposure:"event"},[B]:{exposure:"event"},[q]:{exposure:"event"},[H]:{exposure:"event"},[Oe]:{exposure:"event"},[De]:{exposure:"event"},[$e]:{exposure:"event"},[Ne]:{exposure:"event"},[Be]:{exposure:"event"},[qe]:{exposure:"event"},[He]:{exposure:"event"},[Ue]:{exposure:"event"},[We]:{exposure:"event"},[ze]:{exposure:"event"},[Ge]:{exposure:"event"}},Xy=[[G,{exposure:"hidden"}],[Q,{exposure:"hidden"}],[K,{exposure:"hidden"}]],eb=e=>{const t=Yy[e];if(t)return t;for(const[t,i]of Xy)if(0===e.indexOf(t))return i},tb={flags:Ee,surveys:de},ib=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],sb=e=>`${e}_cookie_identity_change_pending`,nb=e=>{let t="",i=0;for(const s of e){const e=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+e>1e3)break;t+=s,i+=e}return t},rb="main",ob=[Y,X,te,ie,se,Ee,ne,ae],ab=e=>-1!==ob.indexOf(e),lb=[b,w],cb=e=>-1!==lb.indexOf(e),ub=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},db=e=>{if(!e)return{};const t=JSON.parse(e);return Et(t)?t:{}},hb=(e,t)=>{Kn(e,(i,s)=>{const n=eb(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})};var pb=class{constructor(t,i,s=!0){if(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._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=t,this._ownsSplitStorage=s,this.props={},this._campaign_params_url=void 0,this._name=(e=>{let t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(t),this._storage=this._buildStorage(t),this._splitStorage=this._resolveSplitStorage(t),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),t.debug&&Vn.info("Persistence loaded",t.persistence,ct({},this.props)),this.update_config(t,t,i),this.save(),e){const t=()=>this.flush();sr(e,"beforeunload",t,{capture:!1}),sr(e,"pagehide",t,{capture:!1}),this._onStorage=t=>{if(this._splitStorageEligible&&(!t.storageArea||t.storageArea===(null==e?void 0:e.localStorage))&&t.key)if(t.key!==this._name){if(this._splitStorage){const e=Jy.find(e=>t.key===this._groupEntryName(e));e&&this._syncCrossTabFeatureFlagProperties(t.key,e)}}else this._syncCrossTabFeatureFlagProperties(t.key,rb)},sr(e,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!ab(e)||!0===i)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(i||[]);t.forEach(e=>s.add(e)),s.size&&this._setCrossTabFeatureFlagChangesPending(e,s)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&e&&(e.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i=!0){if(this._disabled)return!1;let s,n;try{if(n=$a._get(e),Rt(n)){const e=this._slotWriteState(t);return e.storageValue=null,t!==rb&&(e.persisted=!1),!1}s=db(n)}catch(e){return!1}const r=t===rb?s:$a._parse(this._name);if(r&&this._hasCrossTabFeatureFlagIdentityMismatch(r))return!1;const o=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===rb&&this._splitStorage&&!ub(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,n),o}_hasCrossTabFeatureFlagIdentityMismatch(e){const t=this.props[_],i=e[_];return!It(t)&&!It(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){const n=this._slotWriteState(t);n.storageValue=s,t!==rb&&(n.persisted=i);try{n.fingerprint=this._entryFingerprint(e,t)}catch(e){n.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){let s=!1;return ob.forEach(i=>{var n;const r=null===(n=eb(i))||void 0===n?void 0:n.storageGroup;if(t===rb&&this._splitStorage&&r||t!==rb&&r!==t)return;const 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&&ub(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;const e=$a._get(this._name),t=this._slotWriteState(rb);let i,s=!1,n=!1;if(e!==t.storageValue)if(Rt(e))t.storageValue=null;else{if(i=db(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(i),this._crossTabFeatureFlagIdentityMismatch)return!1;n=this._mergeCrossTabFeatureFlagProperties(i,rb,!1),!this._splitStorage||ub(this._partitionProps().main,i)?this._rememberCrossTabStorageFingerprint(i,rb,!0,e):t.storageValue=e,s=!0}return this._splitStorage&&Jy.forEach(e=>{const t=$a._get(this._groupEntryName(e)),r=this._slotWriteState(e),o=i||{},a=s&&ob.some(t=>{var i;return(null===(i=eb(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(Rt(t))return r.storageValue=null,r.persisted=!1,void(a&&(n=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||n));const l=db(t);n=this._mergeCrossTabFeatureFlagProperties(l,e,!1)||n,this._rememberCrossTabStorageFingerprint(l,e,!0,t)}),n}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);const i=eb(e);(null==i?void 0:i.volatile)||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||rb).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){ob.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{const e=$a._get(this._name),t=db(e);this._slotWriteState(rb).storageValue=e,ob.forEach(e=>{var i;const s=this._splitStorage?null===(i=eb(e))||void 0===i?void 0:i.storageGroup:void 0,n=s?$a._get(this._groupEntryName(s)):null;if(s){const e=this._slotWriteState(s);e.storageValue=n,e.persisted=!Rt(n)}const r=s&&!Rt(n)?db(n):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,r[e],this.props[e]):e in r&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const s=new Set(kt(t)?t:[]),n=new Set(kt(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?s.add(e):s.delete(e)),Array.from(s)}const s=Et(t)?ct({},t):{},n=Et(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in n?s[e]=n[e]:delete s[e]}),s}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(!ab(e))return;const s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===s)return;let n=t;if(this._splitStorageEligible)try{var r;const t=this._splitStorage?null===(r=eb(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this._groupEntryName(t):this._name;n=db($a._get(i))[e]}catch(e){}const o=new Set(s||[]);if("$active_feature_flags"===e){if(!It(t)&&!kt(t)||!It(n)&&!kt(n)||!kt(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(t||[]),r=new Set(n||[]),a=new Set(i);new Set([...s,...a]).forEach(e=>{s.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!Et(i))return void(ub(n,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!It(t)&&!Et(t)||It(t)&&xt(i)&&It(n))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=Et(t)?t:{},r=Et(n)?n:{};new Set([...Object.keys(s),...Object.keys(i)]).forEach(e=>{e in s==e in i&&ub(s[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&ub(r[e],i[e])&&o.delete(e)})}}o.size?this._setCrossTabFeatureFlagChangesPending(e,o):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){var e;const t=null===(e=this._config)||void 0===e?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{const t=Wa(e,this._config.cookie_persisted_properties||[]),i=ja(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),n=Oa._get(this._name)||void 0;n&&Ga(this._name,n)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=n)}catch(e){}else try{const e=Oa._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?Ga(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=Oa._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;const s=Ga(this._name,i);let n;try{n=Ua(JSON.parse(i))}catch(e){return!1}if((Oa._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=i;const r=Va(this._name,i),o=[...Ba,...r.properties],a={};if(Object.keys(n).forEach(e=>{const t=n[e];(It(t)||Rt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete n[e])}),xt(n))return!1;const l="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,c=this.props,u=c[_],d=c[xe],h=Zn({},c);[...Ba,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in n)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){const t=h[e];(r.isValid||-1===Ba.indexOf(e)||!1!==t&&0!==t)&&delete h[e]}}),this.props=Zn(h,n),ob.forEach(e=>{const t=e in this.props;e in c===t&&ub(c[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,c[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this._setProp(xe,Ke);const p=this.props[_],g=this.props[xe];return!l||p===u&&g===d||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Ja._set(sb(this._name),!0),this._deleteProp(ae),this._deleteProp(X),this._deleteProp(Y),this._deleteProp(te),this._deleteProp(ie),this._deleteProp(se),this._deleteProp(Ee),this._deleteProp(Ce),this._deleteProp(we),"anonymous"!==g||"identified"!==d&&"anonymous"!==n.$user_state&&(It(u)||p===u)||(hb(this.props,n),this._deleteProp(le)),"identified"===g?this.props.$user_id=p:delete this.props.$user_id,this._deleteProp(v)),!0}consumeCookieIdentityChange(){const e=sb(this._name),t=this._cookieIdentityChangePending||!!Ja._get(e);return this._cookieIdentityChangePending=!1,t&&Ja._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[rb],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(t){-1===ib.indexOf(t.persistence.toLowerCase())&&(Vn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");const i=((t=[],i=!1)=>{const s=[...Ba,...t];return ct(ct({},$a),{},{_parse(e){try{let n,r={};try{n=Oa._get(e)||void 0,r=n?Ua(JSON.parse(n)):{}}catch(e){}const o=JSON.parse($a._get(e)||"{}");let a;if(i){const i=Va(e,n),l=[...Ba,...i.properties],c={};Object.keys(r).forEach(e=>{const t=r[e];Rt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var t;const e=o[_],n=null!==(t=o.$user_state)&&void 0!==t?t:Ke;s.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const t=o[e];(i.isValid||-1===Ba.indexOf(e)||!1!==t&&0!==t)&&delete o[e]}}),!u||"$user_state"in r||"$user_state"in o||(o[xe]=Ke),!u||("distinct_id"in c?c[_]:o[_])===e&&("$user_state"in c?c[xe]:o[xe])===n||(Na.forEach(e=>delete o[e]),"identified"===c.$user_state&&"distinct_id"in c?o.$user_id=c[_]:delete o.$user_id,"identified"!==c.$user_state&&(delete o[ce],delete o[le]),delete o.__alias)}a=Zn(o,c)}else a=Zn(r,o);return $a._set(e,a),a}catch(e){}return null},_set(e,s,n,r,o,a){const l=$a._set(e,s,void 0,void 0,a);try{const c=Wa(s,t);if(Object.keys(c).length){if(i){const i=qa(e),u=ja(c,t);if(Oa._set(i,u,n,r,o,a),Oa._get(i)!==JSON.stringify(u)){Oa._remove(i,r);const t=Wa(s);return Oa._set(e,t,n,r,o,a),l}}Oa._set(e,c,n,r,o,a)}}catch(e){$a._error(e)}return l},_remove(t,i){try{null==e||e.localStorage.removeItem(t),Oa._remove(t,i),Oa._remove(qa(t),i)}catch(e){$a._error(e)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict);let s,n=!1,r=!1;const o=t.persistence.toLowerCase();return"localstorage"===o&&$a._is_supported()?(s=$a,r=!0):"localstorage+cookie"===o&&i._is_supported()?(s=i,r=!0,n=!0):"sessionstorage"===o&&Ja._is_supported()?s=Ja:"memory"===o?s=Ka:"cookie"===o&&Oa._is_supported()?(s=Oa,n=!0):i._is_supported()?(s=i,r=!0,n=!0):Oa._is_supported()?(s=Oa,n=!0):s=Ka,this._splitStorageEligible=r,this._storesIdentityInCookie=n,s}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){const e={};return Kn(this.props,(t,i)=>{const s=eb(i);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,t))return;e[i]=t}}),e}load(e=!1){if(this._disabled&&!e)return;const t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?$a._parse(this._name):null;let s={};if(t)try{s=Ua(Oa._parse(this._name)),Kn(s,(e,t)=>{(It(e)||Rt(e)||""===e)&&delete s[t]})}catch(e){}const n=this._storage._parse(this._name);if(n&&(this.props=Zn({},n)),this._splitStorage&&this._loadGroupEntries(),t&&n){var r,o;const e=null==i?void 0:i[_],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Ke,a=n[_],l=null!==(o=n.$user_state)&&void 0!==o?o:Ke;if(a!==e||l!==t){this._cookieIdentityChangePending=!0,Ja._set(sb(this._name),!0);const i=Zn({},this.props);Na.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==s.$user_state&&(It(e)||a===e)||(hb(i,s),delete i[le]),this.props=i;const n=new Set;Na.forEach(e=>{var t;const i=null===(t=eb(e))||void 0===t?void 0:t.storageGroup;i&&n.add(i)}),n.forEach(e=>{const t={};Kn(this.props,(i,s)=>{var n;(null===(n=eb(s))||void 0===n?void 0:n.storageGroup)===e&&(t[s]=i)}),xt(t)?($a._remove(this._groupEntryName(e)),this._slotState[e]={}):$a._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Ja._get(sb(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(const e of Jy){const t=$a._parse(this._groupEntryName(e));if(t&&!xt(t)){const i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Zn(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=eb(t))||void 0===i?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){const i=tb[e];if(!i)return!1;const s=t[i],n=this.props[i];return Ft(s)&&Ft(n)&&n>s}refreshKey(e){var t;if(this._disabled)return;if(this._metaIdentifierChangePending.has(e))return;const i=this._splitStorage?null===(t=eb(e))||void 0===t?void 0:t.storageGroup:void 0,s=i?$a._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){const t=this._storage._parse(this._name);if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}}save(){if(this._disabled)return;const e=this._saveDebounceMs();e>0?It(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||lb.forEach(e=>this.refreshKey(e)));const t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);const i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&Vn.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));const s=this._writeEntry(this._storage,this._name,this.props,rb);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){const{main:e,groups:t}=this._partitionProps(),i=this._writeEntry(this._storage,this._name,e,rb);"written"===i&&this._rememberCurrentCookieProperties(e),"failed"!==i&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),ob.forEach(e=>{var t;(null===(t=eb(e))||void 0===t?void 0:t.storageGroup)||this._pendingCrossTabFeatureFlagChanges.delete(e)}));for(const e of Jy){var s;const i=t[e];if(xt(i)&&!(null===(s=this._slotState[e])||void 0===s?void 0:s.persisted)){ob.forEach(t=>{var i;(null===(i=eb(t))||void 0===i?void 0:i.storageGroup)===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}const n=this._writeEntry($a,this._groupEntryName(e),i,e);"failed"!==n&&ob.forEach(t=>{const i=eb(t);(null==i?void 0:i.storageGroup)!==e||"written"!==n&&i.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){const e={},t={flags:{},surveys:{}};return Kn(this.props,(i,s)=>{var n;const r=null===(n=eb(s))||void 0===n?void 0:n.storageGroup;r?t[r][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===rb)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;const i={};return Kn(e,(e,t)=>{var s;i[t]=(null===(s=eb(t))||void 0===s?void 0:s.volatile)?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){const n=this._slotWriteState(s);if(s!==rb&&!n.dirty&&!It(n.fingerprint))return"skipped";let r;try{if(r=this._entryFingerprint(i,s),r===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!==rb&&(n.persisted=!0),It(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=$a._get(t)),"written"):(this._config.debug&&Vn.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),It(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(const e of Jy)$a._remove(this._groupEntryName(e));e?delete this._slotState[rb]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Et(e)){this.syncCookieProperties(),It(t)&&(t="None"),this._expire_days=It(i)?this._default_expiry:i;let s=!1;if(Kn(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(Et(e)){this.syncCookieProperties(),this._expire_days=It(t)?this._default_expiry:t;let i=!1;if(Kn(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||Et(t)||kt(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this._deleteProp(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==s?void 0:s.URL;if(e===this._campaign_params_url)return;const t=Ml(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!xt(Xn(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}update_search_keyword(){this.register(function(){const e=null==s?void 0:s.referrer;return e?Pl(e):{}}())}update_referrer_info(){var e;this.register_once({$referrer:Ol(),$referring_domain:(null==s?void 0:s.referrer)&&(null===(e=ar(s.referrer))||void 0===e?void 0:e.host)||Al},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Dl(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Pe]:this._storesIdentityInCookie?{r:nb(e.r),u:e.u?nb(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Kn([Re,Me],t=>{const i=this.props[t];i&&Kn(i,function(t,i){e["$initial_"+mt(i)]=t})});const t=this.props[Pe];if(t){const i=function(e,t=!1){const i=$l(e,t),s={};return Kn(i,function(e,t){s[`$initial_${mt(t)}`]=e}),s}(t,this._config.disable_capture_url_hashes);Zn(e,i)}return e}safe_merge(e){return Kn(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const s=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=s||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this._disabled&&!a;a||this._syncCookieProperties(t,l),this._config=e,!a&&(s||n||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(ct(ct({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();const u=this._resolveSplitStorage(e),d=r||u!==this._splitStorage,h=!a&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(l);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this._storage=c,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=c,a||(delete this._slotState[rb],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){const e=this.props[Pe];if(!this._storesIdentityInCookie||!Et(e)||"string"!=typeof e.r)return;const t=nb(e.r),i="string"==typeof e.u?nb(e.u):e.u;t===e.r&&i===e.u||this._setProp(Pe,ct(ct({},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){const i=this.props.__timers||{};i[e]=t,this._setProp(k,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return It(i)||(delete t[e],this._setProp(k,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=!0){var s;const n=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||n===t||(this._localIdentityChangePending=!0),cb(e)&&!ub(n,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,n,t),(null===(s=eb(e))||void 0===s?void 0:s.volatile)||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(ab(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),cb(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t;const i=null===(t=eb(e))||void 0===t?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}};const _b={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},gb={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},fb={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},vb=Gn("[RateLimiter]");var mb=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{vb.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void vb.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?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,i,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),a=null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*r,a.last=o,a.tokens>n&&(a.tokens=n);const l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){const e=(Ft(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this._captureWarning(e)&&(a.dropped=0)}return this.lastEventRateLimited=l,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){const t=this.instance.config.property_denylist;return!kt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&(null==n?void 0:n.pathname))return`${null!==(e=n.origin)&&void 0!==e?e:""}${n.pathname}`}_captureWarning(e){var t,i;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const yb=Gn("[RemoteConfig]");var bb=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=h._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}_loadRemoteConfigJs(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,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 yb.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void yb.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return yb.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){yb.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||yb.warn("Failed to fetch remote config from PostHog."):yb.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){yb.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)||void 0===i||i.ensureFlagsLoaded()}catch(e){yb.error("Error loading feature flags",e)}}};const Sb=["fatal","error","warning","log","info","debug"],wb=!!o||!!r,kb=new WeakMap,Cb="text/plain";let Eb=0,xb=!1;const Ib=(e,t)=>{const[i,s]=e.split("#"),[n,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},Tb=(e,t,i=!0)=>{var s;const[n,r]=e.split("?"),o=ct({},t),a=null!==(s=null==r?void 0:r.split("&").map(e=>{var t;const[s,n]=e.split("="),r=i&&null!==(t=o[s])&&void 0!==t?t:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],l=lr(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},Mb=e=>{if(e._encodedBody)return e._encodedBody;const{data:t,compression:i}=e;if(!t)return;if(i===cg.GZipJS){const e=ba(Sa(or(t)),{mtime:0});return{contentType:Cb,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===cg.Base64){const e=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(or(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:or(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=or(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},Rb=e=>{const t=()=>"sendBeacon"===e.transport?{url:Tb(e.url,{compression:cg.Base64}),encodedBody:Mb(ct(ct({},e),{},{compression:cg.Base64,_encodedBody:void 0}))}:{url:Ib(e.url,"compression"),encodedBody:Mb(ct(ct({},e),{},{compression:void 0,_encodedBody:void 0}))};let i;try{i=Mb(e)}catch(i){if(cn(e.compression,cr(e.url,"compression")))return Vn.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&cn(e.compression,cr(e.url,"compression"))&&!((s=i.body)instanceof ArrayBuffer?ln(new Uint8Array(s)):ArrayBuffer.isView(s)&&ln(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(xb=!0,t()):{url:e.url,encodedBody:i};var s},Pb=e=>{try{return Rb(e)}catch(i){var t;return Vn.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},Fb=function(){var e=rt(function*(e){const t=yield fn(or(e.data),Ya.DEBUG,{rethrow:!0});if(!t)return e;const i=yield t.arrayBuffer();return ct(ct({},e),{},{_encodedBody:{contentType:Cb,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),Lb=/Failed to fetch|NetworkError|Load failed/i,Ab=e=>"TypeError"===(null==e?void 0:e.name)&&Lb.test((null==e?void 0:e.message)||""),Ob=e=>{try{const t=function(e,t=Date.now()){if("string"!=typeof e||!e)return;const i=e.trim(),s=/^\d+\s*,/.test(i)?i.slice(0,i.indexOf(",")).trim():i;if(/^\d+$/.test(s)){const e=1e3*Math.min(Number(s),300);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,r=Date.parse(n)-t;return Number.isFinite(r)&&r>0?Math.min(r,ss):void 0}(e());return It(t)?void 0:Math.min(t,3e4)}catch(e){return}},Db=e=>{const t=Pb(e);if(!t)return;const i=new o;kb.set(i,!0);const{url:s,encodedBody:n}=t;i.open(e.method||"GET",s,!0);const{contentType:r,body:a}=null!=n?n:{};Kn(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t;const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s,Ob(()=>i.getResponseHeader("Retry-After")))}},i.send(a)},$b=e=>{const t=Pb(e);if(!t)return;const{url:i,encodedBody:s}=t,{contentType:n,body:o,estimatedSize:l}=null!=s?s:{},c=new Headers;Kn(e.headers,function(e,t){c.append(t,e)}),n&&c.append("Content-Type",n);let u=null,d=!1;if(a){const t=new a;u={signal:t.signal,timeout:setTimeout(()=>{var i;d=!0,t.abort(as("AbortError","PostHog request timed out"+((i=e.timeout)?` after ${i}ms`:"")))},e.timeout)}}const h=t=>{var i;d&&"AbortError"===(null==t?void 0:t.name)||Ab(t)?Vn.warn(t):Vn.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t})};let p=0;const _=()=>{Eb-=p,p=0,u&&clearTimeout(u.timeout)};try{const t=ct({method:(null==e?void 0:e.method)||"GET",headers:c,referrerPolicy:"strict-origin",body:o,signal:null==u?void 0:u.signal},e.fetchOptions),s=null!=l?l:It(o)?0:void 0;t.keepalive="POST"===t.method&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===o&&!It(s)&&s>=0&&52428.8>Eb+s,t.keepalive&&(p=s,Eb+=p),r(i,t).then(t=>t.text().then(i=>{var s;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){Vn.error(e)}_(),null===(s=e.callback)||void 0===s||s.call(e,n,Ob(()=>t.headers.get("Retry-After")))})).catch(e=>{_(),h(e)}).finally(_)}catch(e){_(),h(e)}},Nb=e=>{try{var t;const{url:s,encodedBody:n}=Rb(e),{contentType:o,body:a,estimatedSize:l}=null!=n?n:{};if(!a)return;const c=a instanceof Blob?a:new Blob([a],{type:o});if(i.sendBeacon(s,c))return;const u=kt(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(kt(u)&&u.length>1&&(null!=l?l:0)>16384){const t=Math.ceil(u.length/2),i=t=>kt(e.data)?t:ct(ct({},e.data),{},{batch:t});return Nb(ct(ct({},e),{},{data:i(u.slice(0,t))})),void Nb(ct(ct({},e),{},{data:i(u.slice(t))}))}Vn.warn(`Beacon of ~${null!=l?l:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?$b(ct(ct({},e),{},{_keepaliveDisabled:!0})):Db(e)}catch(e){Vn.warn("Beacon send failed",e)}},Bb=(e,t,i,s)=>{const n="query"===s?"POST"===t?"sent_at":"_":void 0;return Tb(i===cg.GZipJS?Ib(e,"compression"):e,ct(ct({},n?{[n]:Date.now().toString()}:{}),i===cg.GZipJS?{}:{compression:i}))},qb=(()=>{const e=[];return r&&e.push({transport:"fetch",method:$b}),o&&e.push({transport:"XHR",method:Db}),(null==i?void 0:i.sendBeacon)&&e.push({transport:"sendBeacon",method:Nb}),e})();let Hb=!wb&&-1===(null==c?void 0:c.indexOf("MSIE"))&&-1===(null==c?void 0:c.indexOf("Mozilla"));function Ub(e,t,i){var s,n,r;i&&(t=ct(ct({},t),{},{callback:e=>i(e)})),e.__loaded?Hb?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(n=t.callback)||void 0===n||n.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=ct(ct({},e.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(s=e.compression)&&void 0!==s?s:t.compressionFallback:t.compression,(It(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{var i,s,n;const r=ct(ct({},e),{},{callback:null!=t?t:t=>{var i;return null===(i=e.callback)||void 0===i?void 0:i.call(e,t)}});r.timeout=r.timeout||6e4;const o=null!==(i=r.transport)&&void 0!==i?i:"fetch";"sendBeacon"===o&&It(r.compression)&&r.data&&(r.compression=cg.Base64),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(e=>{var t,i;const s=(kt(e)?e:[e]).map(e=>ct(ct({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(t=null==n||null===(i=n.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((e,t=(new Date).toISOString())=>kt(e)?e.map(e=>ct(ct({},e),{},{sent_at:t})):ct(ct({},e),{},{sent_at:t}))(r.data))),r.url=Bb(r.url,r.method,r.compression,r.timestampMode);const a=qb.filter(e=>!r.disableTransport||!e.transport||!r.disableTransport.includes(e.transport)),c=null!==(s=null===(n=function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]}(a,e=>e.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:a[0].method;if(!c)throw new Error("No available transport method");const u=e=>{try{c(e)}catch(e){var t;Ab(e)?Vn.warn(e):Vn.error(e),null===(t=r.callback)||void 0===t||t.call(r,{statusCode:0,error:e})}};"sendBeacon"!==o&&r.data&&r.compression===cg.GZipJS&&l&&"undefined"!=typeof Promise&&!xb?Fb(r).then(e=>{u(e)}).catch(t=>{if(un(t))return xb=!0,void u(ct(ct({},r),{},{compression:void 0,url:Bb(e.url,e.method,void 0,e.timestampMode)}));dn(t)&&(xb=!0),u(r)}):c(r)})(t,(s,n)=>{var r,o,a;e.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=e.config).on_request_error)||void 0===r||r.call(o,s),i?i(s,n):null===(a=t.callback)||void 0===a||a.call(t,s)})):t.fireCallbackOnDrop&&(null===(r=t.callback)||void 0===r||r.call(t,{statusCode:0}))}var Wb=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Qt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Vn.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();const e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(e,"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){const e=this._formatQueue();for(const t in e)this._sendRequestSafely(e[t])}},this._flushTimeoutMs))}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Vn.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){const e={};return Kn(this._queue,t=>{var i;const s=t,n=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");It(e[n])&&(e[n]=ct(ct({},s),{},{data:[]})),null===(i=e[n].data)||void 0===i||i.push(s.data)}),this._queue=[],e}};const zb=["retriesPerformedSoFar"];var jb=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!It(e)&&"onLine"in e.navigator){if(this._areWeOnline=e.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},sr(e,"online",this._onlineListener),sr(e,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,s=mn(e,zb);Lt(i)&&(s.url=Tb(s.url,{retry_count:i})),Ub(this._instance,t?ct(ct({},s),{},{transport:t}):s,(e,t)=>{var n;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=i?i:0))return void this._enqueue(ct({retriesPerformedSoFar:i},s),t);0===e.statusCode&&Vn.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!=i?i:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,e)})}_enqueue(e,t){const i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;const s=Math.max(function(e){const t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)}(i),null!=t?t:0),n=Date.now()+s;this._queue.push({retryAt:n,requestOptions:e});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),Vn.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(){const e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,It(e)||(this._onlineListener&&(e.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(e.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0));for(const{requestOptions:e}of this._queue)try{this._instance._send_request(ct(ct({},e),{},{transport:"sendBeacon"}))}catch(e){Vn.error(e)}this._queue=[]}},Vb=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this._context.lastScrollY=Math.ceil(r),this._context.maxScrollY=Math.max(r,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){const e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){sr(e,"scroll",this._updateScrollData,{capture:!0}),sr(e,"scrollend",this._updateScrollData,{capture:!0}),sr(e,"resize",this._updateScrollData)}scrollElement(){if(this._scrollRoot){const i=kt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(const s of i){var t;const i=null==e||null===(t=e.document)||void 0===t?void 0:t.querySelector(s);if(i)return i}return}var i;return null==e||null===(i=e.document)||void 0===i?void 0:i.documentElement}_scrollPosition(t){var i,s;const n="y"===t?"scrollTop":"scrollLeft";if(this._scrollRoot){const e=this.scrollElement();return e&&e[n]||0}return e?"y"===t?e.scrollY||e.pageYOffset||(null===(i=e.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollTop)||0:e.scrollX||e.pageXOffset||(null===(s=e.document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}};const Gb=e=>Dl(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);var Qb=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{const t=this._getStored();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[Ie]:i})},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Gb,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Ie]}getSetOnceProps(){var e;const t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?$l(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(){const e={};return Kn(Xn(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${mt(i)}`]=t}),e}},Kb=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(const i of this._events[e]||[])i(t);for(const i of this._events["*"]||[])i(e,t)}constructor(){this._events={}}};const Zb=Gn("[SessionId]"),Jb=864e5;var Yb=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 Kb,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Lt(e)||!Lt(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||Ra,this._windowIdGenerator=i||Ra;const n=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Qt(this._config.session_idle_timeout_seconds||1800,60,36e3,Zb.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){const e=Ja._parse(this._window_id_storage_key),t=Ja._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:Ja._remove(this._window_id_storage_key),Ja._set(this._primary_window_exists_storage_key,!0)}(null===(s=this._config.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return It(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&&Ja._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Ja._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Ja._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){const t=this._lastPersistedActivityTimestamp;return!Rt(t)&&!Rt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){const s=t!==this._sessionActivityTimestamp,n=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,n&&!s||n&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[U]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return Lt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(U):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(Rt(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();const[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[U]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){const[e]=this._getSessionId(),t=Lt(e)?e:0,i=Lt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){const e=this._persistence.props[U];return kt(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=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Zb.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Zb.error("Invalid sessionID in bootstrap",e)}})(e);return!It(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&&e&&(e.removeEventListener(Xe,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Ja._remove(this._primary_window_exists_storage_key)},sr(e,Xe,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=t||(new Date).getTime(),n=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(Rt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var r,o;null===(r=(o=this._persistence).syncCookieProperties)||void 0===r||r.call(o),this._lastCookieSyncTimestamp=s}let[,a,l]=this._getSessionId();const c=!It(n)&&a!==n,u=this._freshestActivityTimestamp();let d=this._getWindowId();const h=this._pendingBootstrapSession,p=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Jb),_=h?p:Lt(l)&&Math.abs(s-l)>Jb;let g=!1,f=c;const v=!a||!!h,m=a;let y=!v&&!e&&this._sessionHasBeenIdleTooLong(s,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(s),y||Zb.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this._getSessionId()),v||y||_){f=!1;const e=h&&!p;a=e?h.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),Zb.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:v,activityTimeout:y,sessionPastMaximumLength:_}}),l=e?h.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,g=!0}else d||(d=this._windowIdGenerator(),g=!0),f=f||a!==m,f&&(Zb.info("adopted cross-tab session id",{sessionId:a,windowId:d}),g=!0);const b=Lt(u)&&e&&!_?u:s,S=Lt(l)?l:(new Date).getTime();this._setWindowId(d),this._setSessionId(a,b,S),e||this._resetIdleTimer();const w={noSessionId:v,activityTimeout:y,sessionPastMaximumLength:_,crossTabAdoption:f};return g&&this._sessionIdChangedHandlers.forEach(e=>e(a,d,w)),{sessionId:a,windowId:d,sessionStartTimestamp:S,changeReason:g?w:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){const e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};const Xb=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Gt(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>Gt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function eS(){return eS=rt(function*(){const e=null==i?void 0:i.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return Tt(i)&&i.length>0?i:void 0}catch(e){return void Vn.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}),eS.apply(this,arguments)}const tS="custom",iS="i.posthog.com",sS=/^\/static\//,nS=["/s/","/e/","/i/"];var rS=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${iS}`,".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":tS),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!sS.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}_urlKey(e){const t=ar(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;let s=i;const n=this.instance.config.rewriteRequestPath;if(n){var r;const e=(null===(r=ar(i))||void 0===r?void 0:r.href)||i;s=n(new URL(e)).toString()}if(n&&"api"===e&&nS.some(e=>0===t.indexOf(e))){const e=this._urlKey(s);if(e){const t=this.apiHost;let i=this._ingestionEndpoints;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===n||(i={apiHost:t,rewriteRequestPath:n,urls:new Set},this._ingestionEndpoints=i),i.urls.add(e)}}return s}isIngestionEndpoint(e){const 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(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){const i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,`${i}${t}`)}if(this.region===tS)return this._prepareEndpoint(e,t,this.apiHost+t);const i=iS+t;switch(e){case"assets":return this._prepareEndpoint(e,t,`https://${this.region}-assets.${i}`);case"api":return this._prepareEndpoint(e,t,`https://${this.region}.${i}`)}}};const oS=Gn("[PostHog ExternalIntegrations]"),aS={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var lS=class{constructor(e){this._instance=e}_loadScript(e,t){var i,s;null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,e,e=>{if(e)return oS.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[n,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,s;r&&!(null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[n])&&this._loadScript(aS[n],()=>{var e;null===(e=h.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[n])||void 0===e||e.start(this._instance)}),!r&&(null===(i=h.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&(null===(s=h.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},cS=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return rt(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{const i=e.setup(t._client);i&&(yield i)}catch(i){const 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)return;this._disposed=!0;const e=Array.from(this._extensions.values()).reverse();this._extensions.clear();for(const t of e)this._disposeExtension(t)}_disposeExtension(e){try{var t;const i=null===(t=e.dispose)||void 0===t?void 0:t.call(e);i&&Ct(i.then)&&i.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)}}},uS=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const s of e){const e=null==t?void 0:t.get_property(s);It(e)||(i[s]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}};const dS="extensionsRemoteConfig";var hS=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=Vn,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new uS(e),this.onEvent=e=>Sg(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 Sg(()=>{});const t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(dS,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),Sg(i)},this._runtime=new cS(Vn.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(){const e=this.instance.get_property(g);return"string"==typeof e?e:void 0}get library(){return{name:Ya.LIB_NAME,version:Ya.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s;const n=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==n?void 0:n.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==n?void 0:n.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.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 rt(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 Sg(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(dS,e))}sendRequest(e){var t=this;return rt(function*(e,i={}){var s;const n=t.instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),r={method:i.method,url:i.query?Tb(n,i.query):n,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?dt.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(t.instance._send_request(r),{statusCode:202}):new Promise(e=>{r.callback=e,t.instance._send_request(r)})}).apply(this,arguments)}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}};const pS={};let _S=0;const gS=()=>{},fS='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',vS="Surveys module not available",mS="sanitize_properties is deprecated. Use before_send instead",yS="Invalid value for property_denylist config: ",bS=/^[A-Za-z0-9_-]{1,400}$/,SS=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,wS=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,kS=["token","distinct_id",Ae],CS="posthog",ES=e=>{const 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},xS=t=>{var i;return ct({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ir(null==s?void 0:s.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:gS,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:n&&Tt(null==n?void 0:n.search)&&-1!==n.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==e||null===(i=e.location)||void 0===i?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){Vn.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:Je,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:gS},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Lr,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:ES(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)}))(t))},IS=[["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"]],TS=e=>{const t={};for(const[i,s]of IS)It(e[i])||(t[s]=e[i]);const i=Zn({},t,e),s=e.__preview_external_dependency_versioned_paths;return It(s)||(It(e.strict_script_versioning)&&(i.strict_script_versioning=!!s),Tt(s)&&It(e.asset_host)&&(i.asset_host=s)),kt(e.property_blacklist)&&(It(e.property_denylist)?i.property_denylist=e.property_blacklist:kt(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Vn.error(yS+e.property_denylist)),i};var MS=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Vn.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},RS=class t{_removeExtension(e){if(!e)return;const t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}_replaceExtension(e,t){var i;return this._removeExtension(e),this._extensions.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this._inCookielessMode())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this._hasStableInitialDistinctId)return;let t,i,s;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}_healCookielessSentinelDistinctId(){if(this._inCookielessMode()||"$posthog_cookieless"!==this.get_distinct_id())return;const e=this.persistence;if(!e)return;this._is_persistence_disabled()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(Ra());this.register({distinct_id:t,$device_id:t}),e.set_property(xe,Ke)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new MS,this._personProcessingSetOncePropertiesSent=!1,this.version=Ya.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Kb,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=xS(),this.SentryIntegration=Ky,this.sentryIntegration=e=>function(e,t){const i=Qy(e,t);return{name:Gy,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 Vb(this),this.pageViewManager=new Zy(this),this.rateLimiter=new mb(this),this.requestRouter=new rS(this),this.consent=new qy(this),this.externalIntegrations=new lS(this);const i=null!==(e=t.__defaultExtensionClasses)&&void 0!==e?e:{};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)=>{const s=Tt(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=Tt(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>Vn.info(`send "${null==e?void 0:e.event}"`,e))}init(e,i,s){if(s&&s!==CS){var n;const r=null!==(n=pS[s])&&void 0!==n?n:new t;return r._init(e,i,s),pS[s]=r,pS[CS][s]=r,r}return this._init(e,i,s)}_init(t,i={},s){var n,r,o;const a=Tt(t)?t.trim():"";if(!a)return Vn.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=xS(i.defaults),i.debug=this._checkLocalStorageForDebug(i.debug),this._originalUserConfig=i,this._triggered_notifs=[],i.person_profiles?this._initialPersonProfilesConfig=i.person_profiles:i.process_person&&(this._initialPersonProfilesConfig=i.process_person);const c=xS(i.defaults),u=TS(i),d=Zn({},c,u,{name:s,token:a});Et(c.rageclick)&&Et(u.rageclick)&&(d.rageclick=Zn({},c.rageclick,u.rageclick)),Et(c.session_recording)&&Et(u.session_recording)&&(d.session_recording=Zn({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Vn.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:cg.GZipJS;const h=this._is_persistence_disabled();if(this.persistence=new pb(this.config,h),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new pb(ct(ct({},this.config),{},{persistence:"sessionStorage"}),h,!1),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&Ja._is_supported()){const e=Ja._parse(this._sessionRegisteredPropertiesStorageKey);kt(e)&&e.forEach(e=>{Tt(e)&&this._sessionRegisteredPropKeys.add(e)})}else Ja._remove(this._sessionRegisteredPropertiesStorageKey);const p=ct({},this.persistence.props),_=ct({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Wb((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new jb(this),this.__request_queue=[];const g=this._inCookielessMode();g||(this.sessionManager=new Yb(this),this.sessionPropsManager=new Qb(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Vn.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._initExtensions(g)},0)):(Vn.info("Initializing extensions synchronously"),this._initExtensions(g)),Ya.DEBUG=Ya.DEBUG||this.config.debug,Ya.DEBUG&&Vn.info("Starting in debug mode",{this:this,config:i,thisC:ct({},this.config),p:p,s:_}),this.config.identity_distinct_id&&!(null===(n=i.bootstrap)||void 0===n?void 0:n.distinctID)&&(i.bootstrap=ct(ct({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const v=null===(r=i.bootstrap)||void 0===r?void 0:r.distinctID;if(this._hasStableInitialDistinctId=!!v&&!Mt(v),null===(o=i.bootstrap)||void 0===o?void 0:o.distinctID){const e=i.bootstrap.distinctID,t=this.get_distinct_id(),s=this.persistence.get_property(xe);if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"anonymous"===s)this.identify(e);else if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"identified"===s)Vn.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const t=this.config.get_device_id(Ra()),s=i.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(xe,i.bootstrap.isIdentifiedID?Ze:Ke),this.register({distinct_id:e,$device_id:s})}}if(g)this.register_once({distinct_id:Le,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(Ra());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(xe,Ke)}return sr(e,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),sr(e,"pageshow",()=>{var e;this._isPageUnloading=!1,this._isShutdown||null===(e=this._retryQueue)||void 0===e||e.resume()}),i.segment?Vy(this,()=>this._loaded()):this._loaded(),Ct(this.config._onCapture)&&this.config._onCapture!==gS&&(Vn.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Vn.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 eS.apply(this,arguments)}().then(e=>{e&&this.register({[f]:e})}).catch(gS),this}_isSharedExtension(e){const t=e;return Tt(t.name)&&Ct(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>{var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}).catch(t=>{Vn.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this._extensions.push(e)}_enrollFeatureFlags(){var e,i,s;const n=null!==(e=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==e?e:null===(s=t.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,a;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this._featureFlagsReloadingUnsubscribe)||void 0===r||r.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new n(this)),Ct(this.featureFlags.onReloading)&&Ct(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):null===(o=(a=this.featureFlags).initialize)||void 0===o||o.call(a))}_initExtensions(e){const i=performance.now(),s=ct(ct({},t.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,d;s.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this._extensions.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this._extensions.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this._extensions.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this._enrollExtension(this.autocapture=new s.autocapture(this),n),s.surveys&&this._enrollExtension(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this._enrollExtension(this.logs=null!==(a=this.logs)&&void 0!==a?a:new s.logs(this),n),s.metrics&&this._extensions.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new s.metrics(this)),s.conversations&&this._extensions.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new s.conversations(this)),s.productTours&&this._extensions.push(this.productTours=new s.productTours(this)),s.heatmaps&&this._extensions.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this._extensions.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,Wy)),s.toolbar&&this._extensions.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this._extensions.forEach(e=>{e.initialize&&n.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),n.push(()=>{if(this._pendingRemoteConfig){const e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this._processInitTaskQueue(n,i)}_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);const i=e.shift();if(i)try{i()}catch(e){Vn.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[Oe]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[De]:i}),this.config.__preview_deferred_init_extensions&&Vn.info(`PostHog extensions initialized (${i}ms)`)}_onRemoteConfig(e){var t;if(!s||!s.body)return Vn.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;const t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=ft(t.supportedCompression,cg.GZipJS)?cg.GZipJS:ft(t.supportedCompression,cg.Base64)?cg.Base64:void 0),(null===(i=t.analytics)||void 0===i?void 0:i.endpoint)&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Je}),null===(t=this._browserClientAdapter)||void 0===t||t.handleRemoteConfig(e),this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}_loaded(){try{this.config.loaded(this)}catch(e){Vn.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&(null==n?void 0:n.hostname)){const e=n.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 bb(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&Qn(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,n,r;this._isPageUnloading=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(tt),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this._requestQueue)||void 0===n||n.unload(),null===(r=this._retryQueue)||void 0===r||r.unload()):this._shouldCapturePageleave()&&this.capture(tt,null,{transport:"sendBeacon"})}_send_request(e){Ub(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?ct(ct({},e),{},{transport:t}):e)}_execute_array(e){_S++;try{let t;const i=[],s=[],n=[];Qn(e,e=>{if(e)if(t=e[0],kt(t))n.push(e);else if(Ct(e))try{e.call(this)}catch(t){Vn.error("Error executing queued PostHog call",e,t)}else kt(e)&&"alias"===t?i.push(e):kt(e)&&-1!==t.indexOf("capture")&&Ct(this[t])?n.push(e):s.push(e)});const r=function(e,t){Qn(e,function(e){try{if(kt(e[0])){let i=t;Kn(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Vn.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(s,this),r(n,this)}finally{_S--}}push(e){if(_S>0&&kt(e)&&Tt(e[0])){const i=t.prototype[e[0]];return void(Ct(i)&&i.apply(this,e.slice(1)))}this._execute_array([e])}get _facebookClickIdChannel(){return{property:y,persistenceKey:b,cookieName:"_fbc",pattern:SS,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[b]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(b)}}}get _facebookBrowserIdChannel(){return{property:S,persistenceKey:w,cookieName:"_fbp",pattern:wS,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[w]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(w)}}}_getPersistedMetaIdentifier(e){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(e.persistenceKey);return Tt(i)&&e.pattern.test(i)?{value:i,delivered:!1}:Et(i)&&Tt(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;const t=Ca(e.cookieName);return Tt(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,i,s){if(!this.persistence)return;const n=this._facebookClickIdChannel;this.persistence.refreshKey(n.persistenceKey);const r=this._getPersistedMetaIdentifier(n);if(s)return void n.unregister();if(i)return Tt(t)&&SS.test(t)?this._storeMetaIdentifier(n,t,r):void n.unregister();const o=Tt(e)&&bS.test(e)?e:void 0,a=this._readMetaCookie(n);return a&&((e,t,i)=>{const s=e.split(".");if(t)return s[3]===t;if(!i)return!0;const n=i.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(a,o,r)?this._storeMetaIdentifier(n,a,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this._storeMetaIdentifier(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}_updateFacebookBrowserId(e,t,i){if(!this.persistence)return;const s=this._facebookBrowserIdChannel;this.persistence.refreshKey(s.persistenceKey);const n=this._getPersistedMetaIdentifier(s);if(i)return void s.unregister();if(t)return Tt(e)&&wS.test(e)?this._storeMetaIdentifier(s,e,n):void s.unregister();const r=this._readMetaCookie(s);return r?this._storeMetaIdentifier(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);const i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}capture(e,t,i){var s,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void Vn.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(It(e)||!Tt(e))return void Vn.error("No event name provided to posthog.capture");this._healCookielessSentinelDistinctId();const r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;const o=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==o?void 0:o.isRateLimited)return void Vn.critical("This capture call is ignored due to client rate limiting.");let a;(null==t?void 0:t.$current_url)&&!Tt(null==t?void 0:t.$current_url)&&(Vn.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?void 0:i._originatedFromCaptureException)||Vn.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&&(a=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const l=new Date,c=(null==i?void 0:i.timestamp)||l,u=os(null==i?void 0:i.uuid,Ra);let d={uuid:u,event:e,properties:this.calculateEventProperties(e,t||{},c,u)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&r&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),o&&(d.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens);const h="$feature_flag_called"===e&&!1===d.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!h&&(d.$set=null==i?void 0:i.$set);const p=Et(null==t?void 0:t.$set)?t.$set:void 0,_=kt(null==t?void 0:t.$unset)?t.$unset:[],g=(null==i?void 0:i.$unset)||[],f=e=>{var t;const s=!!(null==i?void 0:i.$set)&&e in i.$set;return{hasProvided:s||!!p&&e in p,provided:s?null==i||null===(t=i.$set)||void 0===t?void 0:t[e]:null==p?void 0:p[e],unset:-1!==_.indexOf(e)||-1!==g.indexOf(e)}},v=f(y),m=f(S),b=[{channel:this._facebookClickIdChannel,hasProvided:v.hasProvided,update:this._updateFacebookClickId(null==a?void 0:a.fbclid,v.provided,v.hasProvided,v.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:m.hasProvided,update:this._updateFacebookBrowserId(m.provided,m.hasProvided,m.unset)}];for(const{channel:e,hasProvided:t,update:i}of b)i&&!0===d.properties.$process_person_profile&&i.pending&&!t&&!h&&(d.$set=ct({[e.property]:i.value},d.$set));const w=null==i?void 0:i.$unset;w&&(d.$unset=w);const k=h?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==st,e===it);if(k&&(d.$set_once=k),(null==i?void 0:i._noTruncate)||(C=this.config.properties_string_max_length,d=function(e,t){const i=new Set;return function e(s,n){if(s!==Object(s))return t?t(s):s;if(i.has(s))return;let r;if(i.add(s),kt(s))r=[],Qn(s,t=>{r.push(e(t))});else{const t={};Kn(qt(s)?er(s):s,(s,n)=>{i.has(s)||(t[n]=e(s,n))}),r=t}return r}(e)}(d,e=>Tt(e)?e.slice(0,C):e)),d.timestamp=c,It(null==i?void 0:i.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=l),h&&(d.properties=((e,t=[])=>{const i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return on.forEach(s),t.forEach(s),i})(d.properties,kS)),e===mg.DISMISSED||e===mg.SENT){const i=null==t?void 0:t[yg.SURVEY_ID],s=null==t?void 0:t[yg.SURVEY_ITERATION];Mg({id:i,current_iteration:s}),d.$set=ct(ct({},d.$set),{},{[rl({id:i,current_iteration:s},e===mg.SENT?"responded":"dismissed")]:!0})}else e===mg.SHOWN&&(d.$set=ct(ct({},d.$set),{},{[yg.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var C;if(e===gb.SHOWN){const e=null==t?void 0:t[fb.TOUR_TYPE];e&&(d.$set=ct(ct({},d.$set),{},{[`${fb.TOUR_LAST_SEEN_DATE}/${e}`]:(new Date).toISOString()}))}const E=ct(ct({},d.properties.$set),d.$set);if(xt(E)||this.setPersonPropertiesForFlags(E),!Pt(this.config.before_send)){const e=this._runBeforeSend(d);if(!e)return;d=e,d.uuid=os(d.uuid,Ra)}const x=b.filter(({channel:e,update:t})=>{var i,s,n;const r=null!==(i=null===(s=d.$set)||void 0===s?void 0:s[e.property])&&void 0!==i?i:Et(null===(n=d.properties)||void 0===n?void 0:n.$set)?d.properties.$set[e.property]:void 0;return(null==t?void 0:t.pending)&&r===t.value});this._internalEventEmitter.emit("eventCaptured",d);const I=null!==(s=null==i?void 0:i._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),T="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(I),M=ct(ct(ct({method:"POST",url:I,data:d,compression:"best-available",timestampMode:T?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},T&&(null===(n=d.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),x.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(const{channel:e,update:t}of x)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)||x.length){var R;let e;!M.transport&&!M.callback&&xt(null!==(R=this.config.request_headers)&&void 0!==R?R:{})&&this._isPageUnloading&&(e="sendBeacon"),this._send_retriable_request(M,e)}else this._requestQueue.enqueue(M);return d}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this._browserClientAdapter)||void 0===t?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new hS(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}_processCookieIdentityChange(e=!0){var t,i,s;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this._cachedPersonProperties=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,i,r,o,a){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this._processCookieIdentityChange();const l=a?void 0:this.persistence.remove_event_timer(t);let u=ct({},i);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this._inCookielessMode()&&(u[Ae]=!0),"$snapshot"===t){const e=ct(ct({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=e.distinct_id,(!Tt(u.distinct_id)&&!Ft(u.distinct_id)||Mt(u.distinct_id))&&Vn.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}const d=function(t,i,s,r=!1){var o,a,l,u;if(!c)return{};const d=t?[...El,...i||[]]:[],[h,p]=Qi(c),[_,g]=function(e){for(let t=0;Yi.length>t;t++){const[i,s,n]=Yi[t],r=e.match(i);if(r){const t=n&&e.match(n)||r;return[s,(null==t?void 0:t[1])||""]}}return["",""]}(c),f=function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}}(),v={};It(s)||(v.detectGoogleSearchApp=s);const m={},y=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,b=null===(a=navigator)||void 0===a?void 0:a.maxTouchPoints,S=null==e||null===(l=e.screen)||void 0===l?void 0:l.width,w=null==e||null===(u=e.screen)||void 0===u?void 0:u.height,k=null==e?void 0:e.devicePixelRatio;It(y)||(m.userAgentDataPlatform=y),It(b)||(m.maxTouchPoints=b),It(S)||(m.screenWidth=S),It(w)||(m.screenHeight=w),It(k)||(m.devicePixelRatio=k);const C=Zn(Xn({$os:h,$os_version:p,$browser:zi(c,navigator.vendor,f,v),$webview_app:_,$webview_app_version:g,$device:Ki(c),$device_type:Zi(c,m),$timezone:Nl(),$timezone_offset:Bl()}),{$current_url:ur(r?ls(null==n?void 0:n.href):null==n?void 0:n.href,d,Il),$host:null==n?void 0:n.host,$pathname:null==n?void 0:n.pathname,$raw_user_agent:c.length>1e3?c.substring(0,997)+"...":c,$browser_version:Vi(c,navigator.vendor,f,v),$browser_language:Fl(),$browser_language_prefix:Ll(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:zn.LIB_NAME,$lib_version:zn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return zn.SDK_DIST_CHANNEL&&(C.$sdk_dist_channel=zn.SDK_DIST_CHANNEL),C}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(a,r.getTime(),!0);u.$session_id=e,u.$window_id=t}this.sessionPropsManager&&Zn(u,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&Zn(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=null===(h=this._retryQueue)||void 0===h?void 0:h.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}let p;if(this.requestRouter.region===tS&&(u.$lib_custom_api_host=this.config.api_host),p="$pageview"!==t||a?"$pageleave"!==t||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),u=Zn(u,p),"$pageview"===t&&s&&(u.title=s.title),!It(l)){const e=r.getTime()-l;u.$duration=parseFloat((e/1e3).toFixed(3))}c&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser");const _=this.persistence.properties(),g=this.sessionPersistence.properties(),f=u.$groups,v=_.$groups;Et(f)&&!xt(f)&&(u.$groups=ct(ct({},Et(v)?v:{}),f)),Kn(["$referrer","$referring_domain"],e=>{e in _&&delete g[e]});const m={};if(this._extensionEventPropertyProducers.length>0)for(const e of this._extensionEventPropertyProducers.slice())try{Zn(m,e())}catch(e){Vn.error("Failed to produce browser extension event properties",e)}u=Zn({},d,_,g,ct(ct({},m),u)),u.$is_identified=this._isIdentified(),kt(this.config.property_denylist)?Kn(this.config.property_denylist,function(e){delete u[e]}):Vn.error(yS+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(Vn.error(mS),u=y(u,t));const b=this._hasPersonProcessing();return u.$process_person_profile=b,b&&!a&&this._requirePersonProcessing("_calculate_event_properties"),u}_calculate_set_once_properties(e,t=!0,i=!1){var s;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Zn({},n,r||{},e||{});const a=this.config.sanitize_properties;return a&&(Vn.error(mS),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),xt(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this._processCookieIdentityChange(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),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)||void 0===t||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(!this._sessionRegisteredPropertiesStorageKey)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e._disabled)||!Ja._is_supported())return void Ja._remove(this._sessionRegisteredPropertiesStorageKey);const t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Ja._set(this._sessionRegisteredPropertiesStorageKey,t):Ja._remove(this._sessionRegisteredPropertiesStorageKey)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var s;return null===(s=this.featureFlags)||void 0===s?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:vS}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:vS})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:vS})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=Pg){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:vS}}canRenderSurveyAsync(e,t=!1){var i,s;return null!==(i=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:vS})}_validateIdentifyId(e){return!e||Mt(e)?(Vn.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Vn.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())||(Vn.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 Vn.uninitializedWarning("posthog.identify");if(Ft(e)&&(e=e.toString(),Vn.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))return;if(!this._requirePersonProcessing("posthog.identify"))return;this._healCookielessSentinelDistinctId();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property("__alias")&&(this.unregister(v),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Ke,c=e!==s,u=!c&&o;if(c&&o){var l;const n=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:s};this.persistence.set_property(xe,Ze),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",n,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=vl(e,t,i)),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(u){this.persistence.set_property(xe,Ze);const s=t||{},n=i||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:s,$set_once:n})&&(this._cachedPersonProperties=vl(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);c||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(we)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this._requirePersonProcessing("posthog.setPersonProperties"))return;const i=vl(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)):Vn.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(kt(e)?e:[e]).filter(e=>Tt(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var s;if(!e||!t)return void Vn.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this._processCookieIdentityChange();const n=this.getGroups(),r=n[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ct(ct({},n),{},{[e]:t})}),(r||i)&&this._hasPersonProcessing()){const s={$group_type:e,$group_key:t};i&&(s.$group_set=i),this.capture(st,s)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=At(e)?e:null==e?void 0:e.resetDeviceID,i=At(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t=!1,i){var s,n,r,o,a,l;if(Vn.info("reset"),!this.__loaded)return Vn.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(s=this._originalUserConfig)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this._shouldDisableFlags());const u=this.get_property(g),d=this.get_property(f),h=this.get_property(A);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const 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.");const _=null===(a=this.persistence)||void 0===a||null===(l=a._beginCookieSyncSuppression)||void 0===l?void 0:l.call(a);let v=!1;try{var m,y,b,S,w,k,C,E,x,I,T,M,R;if(null===(m=this.persistence)||void 0===m||m.clear(),null===(y=this.sessionPersistence)||void 0===y||y.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),It(h)||null===(I=this.persistence)||void 0===I||I.register({$session_recording_remote_config:h}),null===(b=this.surveys)||void 0===b||b.reset(),null===(S=this.featureFlags)||void 0===S||S.reset(),null===(w=this.conversations)||void 0===w||w.reset(),null===(k=this.logs)||void 0===k||k.reset(),null===(C=this.metrics)||void 0===C||C.reset(),null===(E=this.persistence)||void 0===E||E.set_property("$user_state","anonymous"),null===(x=this.sessionManager)||void 0===x||x.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Le,$device_id:null},"");else{const t=this.config.get_device_id(Ra());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||It(d)||this.register({[f]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(i.distinctID&&!this._inCookielessMode()&&(null===(R=this.persistence)||void 0===R||R.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(T=this.featureFlags)||void 0===T||T.initialize(),!Pt(c)&&!(null===(M=this.sessionManager)||void 0===M?void 0:M.setBootstrapSessionId(c,!0))){const e=ct({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,v=!0}finally{var P,F;_&&(null===(P=this.persistence)||void 0===P||null===(F=P._endCookieSyncSuppression)||void 0===F||F.call(P,v))}this.reloadFeatureFlags()}shutdown(e){var t=this;return rt(function*(){var e,i,s,n,r,o,a,l;if(t.__loaded){t._isShutdown=!0,t._getBrowserClientAdapter().dispose(),null===(e=t.sessionRecording)||void 0===e||e.dispose(),null===(i=t.logs)||void 0===i||i.flushLogs("sendBeacon"),null===(s=t.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=t.metrics)||void 0===n||n.dispose(),null===(r=t._requestQueue)||void 0===r||r.unload(),null===(o=t._retryQueue)||void 0===o||o.unload();try{var c;null===(c=t.featureFlags)||void 0===c||c.destroy()}catch(e){Vn.error("Error while destroying feature flags",e)}null===(a=t.persistence)||void 0===a||a.destroy(),null===(l=t.sessionPersistence)||void 0===l||l.destroy()}else Vn.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)||void 0===i||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)||void 0===e||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?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(Vn.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(It(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(v,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Vn.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=ct({},this.config);if(Et(e)){var i,s,n,r,o,a,l,c,u,d,h,p,_,g;Zn(this.config,TS(e));const v=this._is_persistence_disabled();null===(i=this.persistence)||void 0===i||i.update_config(this.config,t,v),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new pb(ct(ct({},this.config),{},{persistence:"sessionStorage"}),v,!1);const m=this._checkLocalStorageForDebug(this.config.debug);var f;At(m)&&(this.config.debug=m),At(this.config.debug)&&(this.config.debug?(Ya.DEBUG=!0,$a._is_supported()&&$a._set("ph_debug",!0),Vn.info("set_config",{config:e,oldConfig:t,newConfig:ct({},this.config)})):(Ya.DEBUG=!1,$a._is_supported()&&$a._remove("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this._shouldDisableFlags()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(c=this.tracingHeaders)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(f=this.historyAutocapture)||void 0===f||f.startIfEnabledOrStop()),null===(h=this.exceptionObserver)||void 0===h||h.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(_=this.surveys)||void 0===_||_.loadIfEnabled(),this._sync_opt_out_with_persistence(),null===(g=this.externalIntegrations)||void 0===g||g.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&Vy(this,gS,!1)}}_overrideSDKInfo(e,t){Ya.LIB_NAME=e,Ya.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var s,n,r,o,a;Object.values(i).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!!(null===(e=this.sessionRecording)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(ct(ct({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var e,i;return null!==(e=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==e?e:t._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?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:CS;return t!==CS&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?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()&&xt(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0: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?(Vn.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(Fe,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;const 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;const i=this._is_persistence_disabled();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s._onOptOut(),(null===(e=this.persistence)||void 0===e?void 0:e._disabled)!==i&&(null===(n=this.persistence)||void 0===n||n.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t._disabled)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),i&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),i}opt_in_capturing(e){var i;if("always"!==this.config.cookieless_mode){if(this._inCookielessMode()){var s,n,r,o,a,l;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Yb(this),this.pageViewManager=new Zy(this),this.persistence&&(this.sessionPropsManager=new Qb(this,this.sessionManager,this.persistence));const e=null!==(o=null===(a=this.config.__extensionClasses)||void 0===a?void 0:a.sessionRecording)&&void 0!==o?o:null===(l=t.__defaultExtensionClasses)||void 0===l?void 0:l.sessionRecording;var c,u;e&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new e(this)),this._lastRemoteConfig&&(null===(c=this.sessionRecording)||void 0===c||null===(u=c.onRemoteConfig)||void 0===u||u.call(c,this._lastRemoteConfig)))}var d,h;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(It(null==e?void 0:e.captureEventName)||(null==e?void 0:e.captureEventName))&&this.capture(null!==(h=null==e?void 0:e.captureEventName)&&void 0!==h?h:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else Vn.warn(fS)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void Vn.warn(fS);const e="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var t,i;null==e||e.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:Le,$device_id:null}),this._removeExtension(e),this.sessionRecording=void 0,null===(t=this.sessionManager)||void 0===t||t.destroy(),null===(i=this.pageViewManager)||void 0===i||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const 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 i?Xb(i,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){s&&("visible"===s.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(et,{title:s.title},{send_instantly:!0}),this._visibilityStateListener&&(s.removeEventListener(Ye,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),sr(s,Ye,this._visibilityStateListener)))}debug(t){!1===t?(null==e||e.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==e||e.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){const 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?(Vn.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,n){const r=t in e&&!Pt(e[t]),o=i in e&&!Pt(e[i]);return r?e[t]:!!o&&(n&&n.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,Vn)}_runBeforeSend(e){var t;if(Pt(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter($t),s=kt(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=e;for(const t of s)try{if(n=t(n),Pt(n)){const t=`Event '${e.event}' was rejected in beforeSend function`;return Dt(e.event)?Vn.warn(`${t}. This can cause unexpected behavior.`):Vn.info(t),null}n.properties&&!xt(n.properties)||Vn.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Vn.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(n.properties&&Pt(n.properties[t]))return Vn.warn(`Event '${e.event}' had its '${t}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var e;return null===(e=this.pageViewManager._currentPageview)||void 0===e?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){const t=At(e)&&!e,i=$a._is_supported()&&"true"===$a._get("ph_debug");return!t&&(!!i||e)}};RS.__defaultExtensionClasses={},RS._noopLogger=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Yn(e.prototype[t[i]])}(RS,["identify"]);var PS=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,i=Et(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}};const FS=Gn("[ExceptionAutocapture]"),LS=Gn("[TracingHeaders]"),AS=Gn("[Web Vitals]"),OS=9e5,DS=["CLS","FCP","INP","LCP"],$S=["INP","LCP"],NS=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],BS=Gn("[SessionRecording]"),qS=Gn("[Heatmaps]");function HS(e){return Et(e)&&"clientX"in e&&"clientY"in e&&Ft(e.clientX)&&Ft(e.clientY)}const US=Gn("[Product Tours]"),WS=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(P))},zS=["$set_once","$set"],jS=Gn("[SiteApps]"),VS="Error while initializing PostHog app with config id ",GS=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),QS="SDK is not enabled or survey functionality is not yet loaded",KS="Disabled. Not loading surveys.";var ZS=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)return;if(this._config.disableSurveys)return;if(!e.ok)return wg.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(Pt(t))return wg.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=At(t)?t:t.length>0,wg.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()}}setup(e){if(!this._disposed)return this._initializingClient=e,GS(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(s=i.dispose)||void 0===s||s.call(i),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)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let e=0;e<localStorage.length;e++){const i=localStorage.key(e);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&t.push(i)}t.forEach(e=>localStorage.removeItem(e))}catch(e){}}loadIfEnabled(){if(this._disposed||!this._client)return;const e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void wg.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void wg.info(KS);if(e.cookielessMode&&this._configSource.isOptedOut())return void wg.info("Not loading surveys in cookieless mode without consent.");const t=this._configSource.getExtensions();if(!t)return void wg.error("PostHog Extensions not found.");if(It(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;const i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0;try{const e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,i),void(this._isInitializingSurveys=!1);const s=t.loadExternalDependency;if(!s)return this._handleSurveyLoadError(Qe),void(this._isInitializingSurveys=!1);s(e=>{try{if(this._disposed)return;const t=this._configSource.getExtensions();e||!(null==t?void 0: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}}_completeSurveyInitialization(e,t){this._disposed||(this._surveyManager=e(t),this._surveyEventReceiver=this._configSource.createEventReceiver(),wg.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0}))}_handleSurveyLoadError(e,t){wg.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=!1){var i;const s=null!==(i=this._client)&&void 0!==i?i:this._initialClientState;if(!s||this._disposed)return;if(this._config.disableSurveys)return wg.info(KS),e([]);const n=s.kv.get(ue);if(n&&!t)return e(n,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:i})=>{this._disposed||e(t,i)}).catch(e=>wg.error("Error in survey callback",e));const r=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 wg.error("Error processing surveys response",e),this._handleSurveyResponse(s,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(s,{statusCode:0,error:e}));this._getSurveysInFlightPromise=r;const o=()=>{this._getSurveysInFlightPromise===r&&(this._getSurveysInFlightPromise=null)};r.then(t=>{o(),this._disposed||e(t.surveys,t.context)},o).catch(e=>wg.error("Error in survey callback",e))}_sendSurveysRequest(e,t){const i=this._client;return i?i.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:new Error(QS)}))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:QS}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?wg.error(e):t.error||wg.warn(e),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;const s=t.json.surveys||[],n=s.filter(e=>Eg(e)&&(dl(e)||xg(e)));var r;return n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n)),e.kv.set({[ue]:s,[de]:Date.now()}),{surveys:s,context:{isLoaded:!0}}}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e,t;const i=null===(e=null!==(t=this._client)&&void 0!==t?t:this._initialClientState)||void 0===e?void 0:e.kv.get(de);return Ft(i)&&Date.now()-i>3e5}_isSurveyRefreshBackingOff(){return Ft(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;const s={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Mg(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}_notifySurveyCallbacks(e){for(const t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){wg.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t=!1){if(!Pt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);wg.warn("init was not called")}_getSurveyById(e){let 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:QS};const t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){if(!this._configSource.isCapturing())return{eligible:!1,reason:kg};if(Pt(this._surveyManager))return{eligible:!1,reason:QS};const 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 wg.warn("init was not called"),{visible:!1,disabledReason:QS};const t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Pt(this._surveyManager)?(wg.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:QS})):new Promise(i=>{this.getSurveys(t=>{var s;const n=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(n){const e=this._checkSurveyRenderability(n);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var n;if(!this._configSource.isCapturing())return;if(Pt(this._surveyManager))return void wg.warn("init was not called");const r="string"==typeof e?this._getSurveyById(e):e;if(!(null==r?void 0:r.id))return void wg.warn("Survey not found");if(!Rg.includes(r.type))return void wg.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const o=null==s?void 0:s.querySelector(t);if(o){if(null===(n=r.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds){wg.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,s;this._renderTimeouts.delete(e),!this._disposed&&this._configSource.isCapturing()&&(wg.info(`Rendering survey ${r.id} with delay of ${null===(t=r.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(r,o,i),wg.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this._renderTimeouts.add(e)}this._surveyManager.renderSurvey(r,o,i)}else wg.warn("Survey element not found")}displaySurvey(e,t){var i;if(!this._configSource.isCapturing())return;if(Pt(this._surveyManager))return void wg.warn("init was not called");const s=this._getSurveyById(e);if(!s)return void wg.warn("Survey not found");let n=s;if((null===(i=s.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)&&t.ignoreDelay&&(n=ct(ct({},s),{},{appearance:ct(ct({},s.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==bg.Popover&&t.initialResponses&&wg.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this._checkSurveyEligibility(s);if(!e.eligible)return void wg.warn("Survey is not eligible to be displayed: ",e.reason)}t.displayType!==bg.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}cancelPendingSurvey(e){Pt(this._surveyManager)?wg.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}};function JS(e,t,i){if(Pt(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var YS=class{constructor(e){this._instance=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Kb,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?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;It(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this._captureHookUnsubscribe=null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;null===(e=this._captureHookUnsubscribe)||void 0===e||e.call(this),this._captureHookUnsubscribe=void 0,this._debugEventEmitter=new Kb}register(e){var t,i;if(!It(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null===(i=this._instance)||void 0===i?void 0:i.autocapture)){const e=new Set;this._actionRegistry.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._instance.autocapture.setElementSelectors(e)}}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(const 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?void 0:t.url){var i;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!JS(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?void 0:t.href))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>JS(e.href,t.href,t.href_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&JS(function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""}(n),t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(!(null==t?void 0:t.text))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>JS(e.text,t.text,t.text_matching||"exact")||JS(e.$el_text,t.text,t.text_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&(r=function(e){const t=[],i=/(?::|")text="(.*?)"/g;let s;for(;!Pt(s=i.exec(e));)t.includes(s[1])||t.push(s[1]);return t}(n),o=t.text,a=t.text_matching||"exact",r.some(e=>JS(e,o,a)));var r,o,a}_checkStepSelector(e,t){var i,s;if(!(null==t?void 0:t.selector))return!0;const n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==n?void 0:n.includes(t.selector))return!0;const r=(null==e||null===(s=e.properties)||void 0===s?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?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||fl(t.properties.reduce((e,t)=>{const i=kt(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)}},XS=class{constructor(e){var t,i;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,this._sessionIdUnsubscribe=null===(t=this._instance)||void 0===t||null===(i=t.onSessionId)||void 0===i?void 0:i.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&fl(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){const i=new Map;return e.forEach(e=>{var s;null===(s=e.conditions)||void 0===s||null===(s=s[t])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(t=>{if(null==t?void 0:t.name){const s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}_getMatchingItems(e,t,i){const s=(i===ug.Activation?this._eventToItems:this._cancelEventToItems).get(e);let n=[];return this._getItems(e=>{n=e.filter(e=>null==s?void 0:s.includes(e.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[i])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(t=>t.name===e);return this._doesEventMatchFilter(r,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){var i;It(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var s;if(t&&this._actionToItems.clear(),0===i.length)return void(t&&(null===(s=this._actionMatcher)||void 0===s||s.replace([])));this._actionMatcher||(this._actionMatcher=new YS(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));const n=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(n.push(t),t.name){var i;const s=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];s.includes(e.id)||s.push(e.id),this._actionToItems.set(t.name,s)}})}),t?this._actionMatcher.replace(n):this._actionMatcher.register(n)}_mergeItemMaps(e,t){t.forEach((t,i)=>{var s;const n=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{n.includes(e)||n.push(e)}),e.set(i,n)})}_setupEventBasedItems(e,t){var i,s;const n=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=this._buildEventToItemMap(e,ug.Activation),a=this._buildEventToItemMap(e,ug.Cancellation);t?(this._eventToItems=o,this._cancelEventToItems=a):(this._mergeItemMaps(this._eventToItems,o),this._mergeItemMaps(this._cancelEventToItems,a)),(0!==n.length||0!==r.length)&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s;const n=this._getLogger(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(s=t.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const t=this._activationOutcome(e,r);if("consume"===t)return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._deactivateItems([r]);if("persist"===t)return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this._persistActivation(r),void this._clearActivationTimestamps([r])}if(this._cancelEventToItems.has(e)){const i=this._getMatchingItems(e,t,ug.Cancellation);i.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._deactivateItems(i.map(e=>e.id)),i.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});const o=this._getMatchingItems(e,t,ug.Activation);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){var t,i;if(0===e.length)return;const s=!!(null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t)),n=[];for(const t of e)s&&this._shouldPersistArmedActivation(t)?this._persistActivation(t)&&this._recordActivationTimestamp(t):n.push(t);n.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...n])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()})}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);const t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){const t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));const 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;const t=this._getActivationTimestampsKey();if(!t)return{};const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[t];return i&&"object"==typeof i?i:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps();this._writeActivationTimestamps(ct(ct({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps(),i={};let s=!1;for(const[n,r]of Object.entries(t))e.includes(n)?s=!0:i[n]=r;s&&(xt(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;const t=this._getRawActivationTimestamps()[e];return Ft(t)?t:void 0}_getRawPersistedActivatedIds(){var e;const t=this._getActivatedKey();return(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,i;const s=this._getRawPersistedActivatedIds();if(0===s.length)return[];const n=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[this._getActivatedSessionKey()],r=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);return r&&n===r?s:[]}_stampActivationSession(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(t=e.get_session_id)||void 0===t?void 0:t.call(e);i&&this._setActivatedSession(i)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this._getActivatedSessionKey()];if(i&&i!==e){const e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>Ft(t[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)||void 0===e||e.call(this),this._sessionIdUnsubscribe=void 0,null===(t=this._captureHookUnsubscribe)||void 0===t||t.call(this),this._captureHookUnsubscribe=void 0,null===(i=this._actionMatcher)||void 0===i||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}},ew=class extends XS{constructor(e){super(e)}_getActivatedKey(){return he}_getActivatedSessionKey(){return pe}_getActivationTimestampsKey(){return _e}_writeActivationTimestamps(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated_timestamps:e})}_clearActivationTimestampsStore(){var e;null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.unregister("$surveys_activated_timestamps")}_shouldPersistArmedActivation(e){var t;let i;this._getItems(t=>{i=t.find(t=>t.id===e)});const s=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return Ft(s)&&s>0}_getShownEventName(){return mg.SHOWN}_getItems(e){var t;null===(t=this._instance)||void 0===t||t.getSurveys(e)}_cancelPendingItem(e){var t;null===(t=this._instance)||void 0===t||t.cancelPendingSurvey(e)}_getLogger(){return wg}_setActivatedItems(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated:e})}_setActivatedSession(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated_session:e})}_clearActivatedSession(){var e;null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.unregister("$surveys_activated_session")}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){let i;return this._getItems(e=>{i=e.find(e=>e.id===t)}),!i||hl(i)?e===mg.SHOWN?"consume":"ignore":e===mg.SHOWN?"persist":e===mg.DISMISSED||e===mg.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},tw=class{constructor(e){this._instance=e}initialize(){}get(e){if("string"==typeof e)return this._instance.get_property(e);const t={};for(const i of e){const e=this._instance.get_property(i);It(e)||(t[i]=e)}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)}},iw=class{constructor(e){this._instance=e}get(){const 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()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=null==h?void 0:h.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:i}=e;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:i?e=>i(this._instance,"surveys",e):void 0}}createEventReceiver(){return new ew(this._instance)}};const sw=(null==e?void 0:e.location)?dr(e.location.hash,"__posthog")||dr(location.hash,"state"):null,nw="_postHogToolbarParams",rw=Gn("[Toolbar]"),ow=Gn("[FeatureFlags]");var aw=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,s,n,r,o,a,l;return{bootstrap:{featureFlags:null!==(i=null===(s=e.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},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!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:It(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(l=e.evaluation_contexts)&&void 0!==l?l:e.evaluation_environments)&&void 0!==a?a:[],flagKeys:kt(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(ow.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),It(e.flag_keys)||kt(e.flag_keys)||ow.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}};const lw=Gn("[FeatureFlags]"),cw=Gn("[FeatureFlags]",{debugEnabled:!0}),uw="\" failed. Feature flags didn't load in time.",dw=["click","keydown","wheel","touchstart","pointerdown"],hw="connection_error",pw=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},_w=e=>{const t={};for(const[i,s]of Jn(e||{}))s&&(t[i]=s);return t},gw="Refusing to render web experiment since the viewer is a likely bot",fw={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>pl(t,e),not_regex:(e,t)=>!pl(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},vw=Gn("[Conversations]"),mw="Conversations not available yet.";function yw(e,t){var s,n,r,o,a,l,c;const u=null!==(s=null==e?void 0:e.flushIntervalMs)&&void 0!==s?s:3e3,d=null!==(n=null==e?void 0:e.maxBufferSize)&&void 0!==n?n:100,h=(null==t?void 0:t.consoleCapture)?void 0:null!==(r=null==e?void 0:e.maxLogsPerInterval)&&void 0!==r?r:1e3,p=It(h)?Math.max(d,2048):Math.max(d,h),_=ct(ct({},function(){let e="",t="";try{const s=null==i?void 0:i.userAgent;s&&([e,t]=Qi(s))}catch(e){}return function(e,t){const i=function(e){if(e)return{}.hasOwnProperty.call(In,e)?In[e]:e}(e);return ct(ct({},i?{"os.name":i}:{}),t?{"os.version":t}:{})}(e,t)}()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(o=null!==(a=null==_?void 0:_["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==_?void 0:_["service.version"])&&void 0!==l?l:null==e?void 0:e.serviceVersion,environment:null!==(c=null==_?void 0:_["deployment.environment"])&&void 0!==c?c:null==e?void 0:e.environment,resourceAttributes:_,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:d,maxQueueSize:p,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const bw=["debug","log","warn","error","info"],Sw="console",ww="__posthogHandledLogsRequestError",kw=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[ww]=!0,i},Cw=e=>!!e&&"object"==typeof e&&!0===e[ww],Ew=Gn("[NetworkMetrics]"),xw=()=>{var t;return(null==e||null===(t=e.performance)||void 0===t?void 0:t.now)?e.performance.now():Date.now()},Iw=e=>e?`${Math.floor(e/100)}xx`:"missing",Tw=(e,t)=>{var i;const s=String(t);return{method:String(e).toUpperCase(),url:(null===(i=ar(s))||void 0===i?void 0:i.href)||s}},Mw=(e,t,i,s,n)=>{try{var r,o,a;const c=n();if(!c)return;const u=i||void 0,d=xw()-s,h=ar(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const p={url:(null==h?void 0:h.href)||t.url,method:t.method},_=Ct(c.name)?c.name(p):Tt(c.name)?c.name:"http.client.request.duration";if(!_)return;const g=ct({method:p.method,host:null!==(r=null==h?void 0:h.hostname)&&void 0!==r?r:"",path:h?(l=h.pathname,l.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/")):"",status_class:Iw(u)},null===(o=c.attributes)||void 0===o?void 0:o.call(c,p,{status:u,durationMs:d}));null===(a=e.metrics)||void 0===a||a.histogram(_,d,{unit:"ms",attributes:g})}catch(e){Ew.error("Failed to record network metric",e)}var l},Rw=()=>{},Pw=(t,i)=>Ct(null==e?void 0:e.fetch)?Sp(e,"fetch",e=>function(...s){const n=xw(),r=e.apply(this,s);if(!i())return r;try{var o,a,l;const[e,c]=s,u=Tw(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==e?void 0:e.method)&&void 0!==o?o:"GET",null!==(l=null==e?void 0:e.url)&&void 0!==l?l:e);return r.then(e=>(Mw(t,u,null==e?void 0:e.status,n,i),e),e=>{throw Mw(t,u,void 0,n,i),e})}catch(e){return Ew.error("Failed to observe fetch",e),r}}):Rw,Fw=(t,i)=>{var s;const n=null==e||null===(s=e.XMLHttpRequest)||void 0===s?void 0:s.prototype;if(!n)return Rw;const r=new WeakMap,o=Sp(n,"open",e=>function(...t){try{(()=>kb.has(this))()||r.set(this,Tw(t[0],t[1]))}catch(e){Ew.error("Failed to observe XHR open",e)}return e.apply(this,t)}),a=Sp(n,"send",e=>function(...s){let n;try{const e=r.get(this);if(e&&i()){const s=xw();n=()=>{this.removeEventListener("loadend",n),Mw(t,e,this.status,s,i)},sr(this,"loadend",n)}}catch(e){Ew.error("Failed to observe XHR send",e)}try{return e.apply(this,s)}catch(e){throw n&&this.removeEventListener("loadend",n),e}});return()=>{o(),a()}},Lw={featureFlags:class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=lw,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._hadUserInteraction=!1,this._onOnline=()=>{const e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t;const i=this._refreshIntervalMs,n=null!==(e=this._dueRefreshIntervalMs)&&void 0!==e?e:i;It(i)||It(n)||this._config.remoteRequestsDisabled||!s||"hidden"===s.visibilityState||Date.now()-(null!==(t=this._lastRefreshAt)&&void 0!==t?t:0)<n||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?i:Math.min(2*n,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{"visible"===(null==s?void 0:s.visibilityState)&&this._resumeConfiguredInterval()},"get"in e?this._configSource=e:(this._instance=e,this._mutableConfigSource=new aw(e.config,e._shouldDisableFlags()),this._configSource=this._mutableConfigSource)}updateConfig(e,t){var i;null===(i=this._mutableConfigSource)||void 0===i||i.update(e,t),this._client&&this._syncAutomaticRefresh()}setup(e){return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),GS(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(t){var i;if(this._client===t)return e&&sr(e,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=t.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){const e=this._config.refreshIntervalMs,t=!this._config.remoteRequestsDisabled&&s&&!It(e)&&e>0?e:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=t),t!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),It(t)||(this._refreshIntervalMs=t,this._dueRefreshIntervalMs=t,this._scheduleNextRefresh(),(null==s?void 0:s.addEventListener)&&(sr(s,Ye,this._onVisibilityChange),Qn(dw,e=>{sr(s,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){It(this._refreshIntervalMs)||(It(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e;It(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null==s||null===(e=s.removeEventListener)||void 0===e||e.call(s,"visibilitychange",this._onVisibilityChange),Qn(dw,e=>{var t;null==s||null===(t=s.removeEventListener)||void 0===t||t.call(s,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var t,i;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._client&&(this._clearDebouncer(),null===(t=this._dynamicProperties)||void 0===t||t.dispose(),this._dynamicProperties=void 0,null===(i=this._crossTabPersistenceUnsubscribe)||void 0===i||i.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null==e||e.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?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!It(null===(e=this._client)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!e.$enabled_feature_flags)return;const n=this._prop("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,c=l?a:i&&!kt(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),u=this._prop("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},h=l||i?c:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),p=!l&&!i,_=!!p||c,g=!!p||h,f={[X]:_,[Y]:_,[ie]:g};e.$feature_flag_details&&(f[te]=_);for(const t of[se,Ee,ne])It(e[t])||(f[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(f)}_remove(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){const e={};for(const t of[X,ie,se,re]){const i=this._prop(t);It(i)||(e[t]=i)}this._baseEventProperties=e;const t=ct({},e),i=this._prop(Y);if(i)for(const[e,s]of Object.entries(i))t[`$feature/${e}`]=s;this._eventPropertiesWithFlagValues=t}_isCacheStale(){const e=this._config.cacheTtlMs;if(!e||0>=e)return!1;const t=this._prop(Ee);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(){const e=this._config.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const 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(){const e=this._config.flagKeys;if(!It(e))return e.filter(e=>{const 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;const i=this._config,s=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var n,r;const e=null!==(n=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},t=Object.keys(s).filter(e=>!It(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this._receivedFeatureFlags({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var s,n;const r=(null==i?void 0:i.merge)&&null!==(s=this._prop("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==i?void 0:i.merge)&&null!==(n=this._prop("$feature_flag_payloads"))&&void 0!==n?n:{},a=ct(ct({},r),e),l=ct(ct({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:nn(t),variant:rn(t),reason:void 0,metadata:It(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this._prop(te),t=this._prop(re),i=this._prop(oe);if(!i&&!t)return e||{};const s=Zn({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of n){var r;const n=s[e],a=null==t?void 0:t[e],l=It(a)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!a,c=It(a)?null==n?void 0:n.variant:"string"==typeof a?a:void 0,u=null==i?void 0:i[e],d=ct(ct({},n),{},{enabled:l,variant:l?null!=c?c:null==n?void 0:n.variant:void 0});var o;l!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),c!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=ct(ct({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[e]=d}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this._override_warning=!0),s}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const s=e[i];return{key:i,enabled:nn(s),variant:rn(s),payload:sn(t[i])}})}getFlagVariants(){const e=this._prop(Y),t=this._prop(re);if(!t)return e||{};const i=Zn({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){const e=this._prop(ie),t=this._prop(oe);if(!t)return e||{};const i=Zn({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];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(we)}_callFlagsEndpoint(e){this._clearDebouncer();const t=this._client;if(!t||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return;if(this._requestInFlight)return void(this._additionalReloadRequested=!0);const i={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:ct(ct(ct({},t.initialPersonProperties),this._prop("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this._prop(le),timezone:Nl()};It(t.deviceId)||(i.$device_id=t.deviceId),((null==e?void 0:e.disableFlags)||this._config.featureFlagsDisabled)&&(i.disable_flags=!0);const s=this._getValidEvaluationEnvironments();s.length&&(i.evaluation_contexts=s);const n=this._getValidFlagKeys();It(n)||(i.flag_keys=n);const r=this._config.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),a=this._requestGeneration;this._requestInFlight=!0;const l=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},c=e=>{var t,s;const n=null!==(t=e.json)&&void 0!==t?t:{},o=200!==e.statusCode;if(this._requestInFlight=!1,a!==this._requestGeneration)return void l();if(this._trackStatusZeroReachability(e.statusCode),o||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),i.disable_flags&&!this._additionalReloadRequested)return;this._flagsLoadedFromRemote=!o;const c=[];e.error?c.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?hw:"unknown_error"):200!==e.statusCode&&c.push(`api_error_${e.statusCode}`),n.errorsWhileComputingFlags&&c.push("errors_while_computing_flags");const u=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));u&&c.push("quota_limited"),this._set({[Ce]:c}),u?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(n,o,{partialResponse:r}),l()},u=e=>{this._requestInFlight=!1,a===this._requestGeneration?(this._set({[Ce]:[hw]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),l()):l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:i,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(c).catch(u)}catch(e){u(e)}}_hasStatusZeroCircuitBreakerTripped(){return hr(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=pr(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(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlag for key "'+e+uw);if(this._checkAndTriggerStaleRefresh())return;const s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlagResult for key "'+e+uw);if(this._checkAndTriggerStaleRefresh())return;const i=this.getFlagVariants(),s=e in i,n=i[e],r=this.getFlagPayloads()[e],o=String(n),a=this._prop("$feature_flag_request_id")||void 0,l=this._prop("$feature_flag_evaluated_at")||void 0;let c,u=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var d;const e=null===(d=this._client)||void 0===d?void 0:d.session.sessionId,t=this._prop(ke);e&&e!==t&&(u={},c=e)}if(t.send_event||!("send_event"in t))if(e in u&&u[e].includes(o))c&&this._set({[we]:u,[ke]:c});else{var h,p,_,g,f,v,m,y,b,S,w,k;kt(u[e])?u[e].push(o):u[e]=[o],this._set(ct({[we]:u},c?{[ke]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(h=this._prop("$feature_flag_errors"))&&void 0!==h?h:[]];It(n)&&i.push("flag_missing");const s={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(p=null===(_=this._config.bootstrap)||void 0===_||null===(_=_.featureFlags)||void 0===_?void 0:_[e])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(g=null===(f=this._config.bootstrap)||void 0===f||null===(f=f.featureFlagPayloads)||void 0===f?void 0:f[e])&&void 0!==g?g:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};It(null==t||null===(v=t.metadata)||void 0===v?void 0:v.has_experiment)||(s.$feature_flag_has_experiment=t.metadata.has_experiment),It(null==t||null===(m=t.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=t.metadata.version);const d=null!==(y=null==t||null===(b=t.reason)||void 0===b?void 0:b.description)&&void 0!==y?y:null==t||null===(S=t.reason)||void 0===S?void 0:S.code;var C;d&&(s.$feature_flag_reason=d),(null==t||null===(w=t.metadata)||void 0===w?void 0:w.id)&&(s.$feature_flag_id=t.metadata.id),It(null==t?void 0:t.original_variant)&&It(null==t?void 0:t.original_enabled)||(s.$feature_flag_original_response=It(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(k=t.metadata)||void 0===k?void 0:k.original_payload)&&(s.$feature_flag_original_payload=null==t||null===(C=t.metadata)||void 0===C?void 0:C.original_payload),i.length&&(s.$feature_flag_error=i.join(",")),this._captureFeatureFlagCalled(s)}else c&&this._set({[we]:u,[ke]:c});return s?{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:sn(r)}:void 0}_captureFeatureFlagCalled(e){try{var t;null===(t=this._client)||void 0===t||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 rt(function*(){const s=i._client;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=i._getValidEvaluationEnvironments();r.length&&(n.evaluation_contexts=r);const o=i._getValidFlagKeys();let a;It(o)||(n.flag_keys=o);try{var l;const t=null===(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+uw),t.defaultValue;const i=this.getFeatureFlag(e,t);return It(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)return;this._hasLoadedFlags=!0;const s=((e,t={},i={},s={},n,r=lw)=>{const o=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),s=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!It(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return ct(ct({},e),{},{featureFlags:t,featureFlagPayloads:s})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,r),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(!l)return;const u=e.requestId,d=e.evaluatedAt;if(kt(l)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(l)for(let t=0;l.length>t;t++)e[l[t]]=!0;return{[X]:l,[Y]:e,[ne]:!1}}let h=l,p=c,_=a;if(null==n?void 0:n.partialResponse){const e=Object.keys(h),n=p||{};h=ct(ct({},t),h),p=ct(ct({},i),n),e.forEach(e=>{e in n||null==p||delete p[e]}),_=ct(ct({},s),_)}else if(e.errorsWhileComputingFlags)if(a){const e=new Set(Object.keys(a).filter(e=>{var t;return!(null===(t=a[e])||void 0===t?void 0:t.failed)}));h=ct(ct({},t),Object.fromEntries(Object.entries(h).filter(([t])=>e.has(t))));const n=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=ct(ct({},i),n),e.forEach(e=>{e in n||null==p||delete p[e]}),_=ct(ct({},s),Object.fromEntries(Object.entries(_||{}).filter(([t])=>e.has(t))))}else h=ct(ct({},t),h),p=ct(ct({},i),p),_=ct(ct({},s),_);return ct(ct({[X]:Object.keys(_w(h)),[Y]:h||{},[ie]:p||{},[te]:_||{},[ne]:!0===e.minimalFlagCalledEvents},u?{[se]:u}:{}),d?{[Ee]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(s)if(!1===(null==i?void 0:i.persist)){const e=!It(this._client.kv.get(Y));this._bootstrapState=s,e||this._set(s)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(s,e,!!(null==i?void 0:i.partialResponse)),this._set(s);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,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([re,oe]),this._fireFeatureFlagsCallbacks(),void cw.info("All overrides cleared");if(kt(e))return this._set({[re]:pw(e)}),this._fireFeatureFlagsCallbacks(),void cw.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const s={},n=i.flags,r=i.payloads;return n&&(s[re]=kt(n)?pw(n):n),r&&(s[oe]=r),Object.keys(s).length&&this._set(s),!1===n&&!1===r?this._remove([re,oe]):!1===n?this._remove(re):!1===r&&this._remove(oe),this._fireFeatureFlagsCallbacks(),!1===n?cw.info("Flag overrides cleared"):n&&cw.info("Flag overrides set",{flags:n}),void(!1===r?cw.info("Payload overrides cleared"):r&&cw.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this._set({[re]:e}),this._fireFeatureFlagsCallbacks(),void cw.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){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;const n=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i);const a=ct(ct({},this.getFlagVariants()),{},{[e]:t});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this._set({[X]:Object.keys(_w(a)),[Y]:a,[ae]:ct(ct({},this._prop("$stored_person_properties")||{}),r)}),this._fireFeatureFlagsCallbacks();try{var l;null===(l=this._client)||void 0===l||l.capture("$feature_enrollment_update",o).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=!1,i){const s=this._prop(ee);!s||t?this._getEarlyAccessFeatures(e,i):e(s)}_getEarlyAccessFeatures(e,t){var i=this;return rt(function*(){const s=i._client;if(!s)return;const n=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let r;try{const e=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;r=e.json.earlyAccessFeatures,i._set({[ee]: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(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(s=>{try{s(t,i,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}})}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){const i=this._prop("$stored_person_properties")||{},s=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),n=null==e?void 0:e.$set_once,r={};if(n)for(const e in n)({}).hasOwnProperty.call(n,e)&&(e in i||(r[e]=n[e]));this._set({[ae]:ct(ct(ct({},i),r),s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=ct({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[ae]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(ae),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this._prop("$stored_group_properties")||{},s=ct({},i);for(const t of Object.keys(e))s[t]=ct(ct({},i[t]),e[t]);this._set({[le]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this._prop("$stored_group_properties")||{};this._set({[le]:ct(ct({},t),{},{[e]:{}})})}else this._remove(le)}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}}},Aw={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!!(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0: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?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=_o,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var t,i;if(!(null==s?void 0:s.visibilityState)||"visible"===s.visibilityState)return!0;const n=null==e||null===(t=e.performance)||void 0===t||null===(i=t.getEntriesByType)||void 0===i?void 0:i.call(t,"visibility-state");return!(null==n?void 0:n.length)||n.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e,t;"visible"===(null==s?void 0:s.visibilityState)&&(this._documentWasEverVisible=!0,null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw BS.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==s?void 0:s.addEventListener)&&sr(s,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,null==s||null===(t=s.removeEventListener)||void 0===t||t.call(s,"visibilitychange",this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var t;const i=!!(null===(t=this._instance.get_property("$session_recording_remote_config"))||void 0===t?void 0:t.enabled),s=!this._config.disable_session_recording,n=this._config.disable_session_recording||this._instance.consent.isOptedOut();return e&&i&&s&&!n}startIfEnabledOrStop(e){var t;if(this._sessionRecordingDisposed)return;if(this._isRecordingEnabled&&(null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.isStarted))return;const i=!It(Object.assign)&&!It(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),BS.info("starting")):(this._recordingStatus=_o,this.stopRecording())}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=yo),(null==h||null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=h.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this._onScriptLoaded(e);else{var s,n;const t=this._instance.sessionManager;null===(s=h.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this._scriptName,i=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),BS.error("could not load recorder",i)):void this._onScriptLoaded(e);this._recordingStatus="disabled"})}}stopRecording(){var e,t;null===(e=this._persistFlagsOnSessionListener)||void 0===e||e.call(this),this._persistFlagsOnSessionListener=void 0,null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.stop()}_discardRecording(e=!1){var t,i;null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=void 0,null===(i=this._lazyLoadedSessionRecording)||void 0===i||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null===(e=this._persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._persistence)||void 0===t||t.unregister("$replay_sample_rate")}_validateSampleRate(e,t){if(Pt(e))return null;const i=Ft(e)?e:parseFloat(e);return"number"!=typeof(s=i)||!Number.isFinite(s)||0>s||s>1?(BS.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var s}_persistRemoteConfig(e){if(this._persistence){var t,i;const s=this._persistence,n=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null===(t=this._config.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=n?n:r;Pt(o)&&this._resetSampling();const a=null==i?void 0:i.minimumDurationMilliseconds;s.register({[A]:ct(ct({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:ct({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:o,minimumDurationMilliseconds:It(a)?null:a,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)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(n)}}onRemoteConfig(e){const 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",BS.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.log)?this._lazyLoadedSessionRecording.log(e,t):BS.warn("log called before recorder was ready")}get _scriptName(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(A);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){const e=this._instance.get_property(A);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return BS.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!Pt(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,i,s;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return BS.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[$e]:!0});var n;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null===(n=h.__PosthogExtensions__)||void 0===n?void 0:n.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",BS.info("persisted remote config is stale, requesting fresh config before starting"),void new bb(this._instance).load()}this._recordingStatus=yo,null===(i=(s=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||void 0===i||i.call(s,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=_o}onRRwebEmit(e){var t,i;null===(t=this._lazyLoadedSessionRecording)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null===(i=this._persistence)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!!(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},Ow={autocapture:class extends Ry{constructor(e){super(new PS(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(Vn.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,Vn.info("History API monitoring stopped")}monitorHistoryChanges(){e&&e.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(t){var i;if(!e||(null===(i=e.history[t])||void 0===i?void 0:i.__posthog_wrapped__))return;const s=this;Sp(e.history,t,e=>function(i,n,r){e.call(this,i,n,r),s._capturePageview(t)})}_getCurrentLocation(){const t=null==e?void 0:e.location;if(null==t?void 0:t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}_getCaptureOptions(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:Et(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){const 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{const t=this._getCurrentLocation();if(!t)return;this._hasLocationChanged(t)&&this._instance.capture(et,{navigation_type:e}),this._lastLocation=t}catch(t){Vn.error(`Error capturing ${e} pageview`,t)}}_setupPopstateListener(){if(this._popstateListener)return;const t=()=>{this._capturePageview("popstate")};sr(e,"popstate",t),this._popstateListener=()=>{e&&e.removeEventListener("popstate",t)}}_setupHashchangeListener(){if(this._hashchangeListener)return;const t=()=>{this._capturePageview("hashchange")};sr(e,"hashchange",t),this._hashchangeListener=()=>{e&&e.removeEventListener("hashchange",t)}}},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)||void 0===t?void 0:t.props[E]),this.rageclicks=new Cy(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return Et(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;qS.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)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[E]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){const e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){HS(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval="visible"===(null==s?void 0:s.visibilityState)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){e&&s&&(this._flushHandler=this._flush.bind(this),sr(e,Xe,this._flushHandler),this._onClickHandler=t=>this._onClick(t||(null==e?void 0:e.event)),sr(s,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=t=>this._onMouseMove(t||(null==e?void 0:e.event)),sr(s,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new zy(this.instance,Uy,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),sr(s,Ye,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var t;e&&s&&(this._flushHandler&&e.removeEventListener(Xe,this._flushHandler),this._onClickHandler&&s.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&s.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&s.removeEventListener(Ye,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null===(t=this._deadClicksCapture)||void 0===t||t.stop(),this._initialized=!1)}_getProperties(t,i){const s=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(t,i,s){let n=t;for(;n&&vr(n)&&!mr(n,"body");){if(n===s)return!1;let t;try{var r,o,a;t=null===(r=null!==(o=null===(a=n.ownerDocument)||void 0===a?void 0:a.defaultView)&&void 0!==o?o:e)||void 0===r?void 0:r.getComputedStyle(n).position}catch(e){return!1}if(ft(i,t))return!0;n=Rr(n)}return!1}(xr(t),["fixed","sticky"],r);return{x:t.clientX+(o?0:n),y:t.clientY+(o?0:s),target_fixed:o,type:i}}_onClick(e,t="click"){var i;if(fr(e.target)||!HS(e))return;const s=this._getProperties(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&Br(xr(e),this.instance.config.rageclick)&&this._capture(ct(ct({},s),{},{type:"rageclick"})),this._capture(s)}_onMouseMove(e){!fr(e.target)&&HS(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(t){if(!e)return;const i=this._config.disable_capture_url_hashes?ls(e.location.href):e.location.href,s=this._config.custom_personal_data_properties,n=this._config.mask_personal_data_properties?[...El,...s||[]]:[],r=ur(i,n,Il);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(t)}_flush(){this._buffer&&!xt(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:zy,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",ct({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>ct(ct({},e),{},{[`$web_vitals_${t.name}_event`]:ct({},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))return void AS.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this._maskedURL(i);if(It(s))return;const n=Ft(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${s}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void AS.error("Ignoring metric with value >= "+this._maxAllowedValue,e);this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),It(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=s),this._buffer.firstMetricTimestamp=It(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=ct(ct(ct({},e),i?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,Et(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of NS){const s="url"===i&&"string"==typeof e.attribution[i]?this._maskedURL(e.attribution[i]):e.attribution[i];It(s)||(t[i]=s)}o.attribution=t}else delete o.attribution;It(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this._buffer.metrics.push(o),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let e,t,i,s,n=!1;const r=h.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&It(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!It(a)){const r=a.withoutAttribution,o=this.attributionMetrics;n=!It(r),e=o.indexOf("LCP")>-1?a.onLCP:(null==r?void 0:r.onLCP)||a.onLCP,t=o.indexOf("CLS")>-1?a.onCLS:(null==r?void 0:r.onCLS)||a.onCLS,i=o.indexOf("FCP")>-1?a.onFCP:(null==r?void 0:r.onFCP)||a.onFCP,s=o.indexOf("INP")>-1?a.onINP:(null==r?void 0:r.onINP)||a.onINP}if(!(e&&t&&i&&s))return void AS.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},c=n&&this.attributionMetrics.indexOf("INP")>-1?ct(ct({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this),c),this._initialized=!0},this._enabledServerSide=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[M]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=Et(this._perfConfig)?null===(e=this._perfConfig)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return Pt(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||DS:i}get flushToCaptureTimeoutMs(){return(Et(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=Et(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return At(e)?e?DS:[]:kt(e)?e:$S}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=Et(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){const e=Et(this._perfConfig)&&Ft(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:OS;return e>0&&6e4>=e?OS:e}get isEnabled(){const e=null==n?void 0:n.protocol;if("http:"!==e&&"https:"!==e)return AS.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=Et(this._perfConfig)?this._perfConfig.web_vitals:At(this._perfConfig)?this._perfConfig:void 0;return At(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(AS.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=Et(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=Et(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[M]:i}),this._instance.persistence.register({[L]: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;const i=h.__PosthogExtensions__,s=this._callbackFlavor,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&It(n)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,s,t=>{t?AS.error("failed to load script",t):e()})}_maskedURL(t){const i=t||(null==e?void 0:e.location.href);if(!i)return void AS.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?ls(i):i,n=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...El,...n||[]]:[];return ur(s,r,Il)}}},Dw={exceptionObserver:class{constructor(t){var i;this._startCapturing=()=>{var t;if(!e||!this.isEnabled||!(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions))return;const i=h.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=h.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=h.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=i(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=s(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=n(this.captureException.bind(this)))}catch(e){FS.error("failed to start",e),this._stopCapturing()}},this._instance=t,this._remoteEnabled=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[x]),this._rateLimiter=new Kt(ct(ct({},function(e={}){var t,i,s,n;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(n=e.exceptionRateLimiterBucketSize)&&void 0!==n?n:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:FS})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Et(e)?t=ct(ct({},t),e):(It(e)?this._remoteEnabled:e)&&(t=ct(ct({},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?(FS.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"exception-autocapture",t=>{if(t)return FS.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null===(e=this._unwrapOnError)||void 0===e||e.call(this),this._unwrapOnError=void 0,null===(t=this._unwrapUnhandledRejection)||void 0===t||t.call(this),this._unwrapUnhandledRejection=void 0,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[x]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,s;const n=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(n))return void FS.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=Sv(),this._instance=e,this._suppressionRules=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=Xs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new en(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Xs(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if(!e.ok)return;const n=e.config;if(!("errorTracking"in n))return;const r=null!==(t=null===(i=n.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[I]:this._suppressionRules,[T]:o})}get _captureExtensionExceptions(){var e;const t=!!this._instance.get_property(T),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!Tt(e)||0===e.trim().length)return void fv.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:s}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>Js.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));s.length>0&&fv.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this._exceptionStepsBuffer.add(ct({[Ks]:e,[Zs]:(new Date).toISOString()},i))}catch(e){fv.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void fv.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 fv.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 fv.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 fv.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this._exceptionStepsConfig.enabled&&Pt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,s=function(){const e=globalThis._posthogReleaseId;return"string"==typeof e&&e.length>0?e:void 0}();s&&(i.$release_id=s);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){return gv(e)||fv.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void(gv(e)||fv.error("Failed to process exception event. Ignoring this exception.",e))}}_addBufferedExceptionSteps(e){try{const t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:ct(ct({},e),{},{$exception_steps:t})}catch(t){return fv.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Ks]:e,[Zs]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Et(e)?ct({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(Tt(t)&&t.length>0&&e.$exception_types.push(t),Tt(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{const i=e.values.map(e=>{const i=gl[e.operator],s=t[e.key];if(!i||!s)return!1;const n=kt(e.value)?e.value:[e.value];return n.length>0&&i(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return fv.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&yv.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(vv))||e.some(({type:e,value:t})=>"NoResponse"===e||Tt(t)&&mv.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(vv))))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>Tt(e)&&bv.some(t=>e.includes(t)))}_isPostHogException(e){if(e.length>0){var t,i,s,n;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!Pt(e)&&kt(e)}}},$w=ct({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)return;const t=e.config;if("productTours"in t){var i,s;if(this._persistence&&this._persistence.register({[P]:!!t.productTours}),!WS(this._instance))return!this._productTourManager&&Pt(null===(i=this._persistence)||void 0===i?void 0:i.props.ph_product_tours)||US.info("product tours disabled; stopping and clearing cached tours"),null===(s=this._productTourManager)||void 0===s||s.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&WS(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"product-tours",t=>{t?US.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&(null===(e=h.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this._productTourManager=h.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(kt(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});const i=this._persistence;if(i){const s=i.props[ge];if(kt(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(!WS(this._instance))return void e([],{isLoaded:!0});const s=t.statusCode;if(200!==s||!t.json){const i=`Product Tours API could not be loaded, status: ${s}`;return 0===s?t.error||US.warn(i):US.error(i),void e([],{isLoaded:!1,error:i})}const n=kt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[ge]:n}),e(n,{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)||void 0===t||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null===(t=this._productTourManager)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this._productTourManager)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this._productTourManager)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this._productTourManager)||void 0===e||e.previousStep()}clearCache(){var e;this._cachedTours=null,null===(e=this._persistence)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this._productTourManager)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.cancelPendingTour(e)}}},Lw),Nw={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)return;const 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=h._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,i,s,n,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:ct(ct({},mn(e,zS)),{},{properties:ct(ct(ct({},e.properties),h?{$set:ct(ct({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:ct(ct({},null!==(s=null===(n=e.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_prepareElementForSiteApp(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();if("style"===i&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(e)||(jS.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===i&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(e)||(jS.error("prepare_external_dependency_script returned null"),null)}return e}_patchSiteAppElementInsertionMethods(){var e,t,i,n,r,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const c=null==s?void 0:s.defaultView,u=null==c||null===(e=c.Node)||void 0===e?void 0:e.prototype;if(!c||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();const d=[],h=this,p=new WeakSet,_=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const s=e[t];e[t]=i(s),d.push(()=>{e[t]=s})},g=e=>{if(p.has(e))return e;const t=h._prepareElementForSiteApp(e);return t&&p.add(t),t},f=e=>e.map(e=>"string"==typeof e?e:g(e)).filter(e=>!Rt(e));return _(u,"appendChild",e=>function(t){const i=g(t);return i?e.call(this,i):t}),_(u,"insertBefore",e=>function(t,i){const s=g(t);return s?e.call(this,s,i):t}),_(u,"replaceChild",e=>function(t,i){const s=g(t);return s?e.call(this,s,i):i}),[null===(t=c.Element)||void 0===t?void 0:t.prototype,null===(i=c.Document)||void 0===i?void 0:i.prototype,null===(n=c.DocumentFragment)||void 0===n?void 0:n.prototype].forEach(e=>{_(e,"append",e=>function(...t){return e.apply(this,f(t))}),_(e,"prepend",e=>function(...t){return e.apply(this,f(t))})}),[null===(r=c.Element)||void 0===r?void 0:r.prototype,null===(o=c.CharacterData)||void 0===o?void 0:o.prototype,null===(a=c.DocumentType)||void 0===a?void 0:a.prototype].forEach(e=>{_(e,"before",e=>function(...t){return e.apply(this,f(t))}),_(e,"after",e=>function(...t){return e.apply(this,f(t))}),_(e,"replaceWith",e=>function(...t){const i=f(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),_(null===(l=c.Element)||void 0===l?void 0:l.prototype,"insertAdjacentElement",e=>function(t,i){const s=g(i);return s?e.call(this,t,s):null}),this._restoreSiteAppElementPatches=()=>{d.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null===(t=this._restoreSiteAppElementPatches)||void 0===t||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){const i=this._patchSiteAppElementInsertionMethods();try{const s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(jS.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this._stopBuffering)||void 0===i||i.call(this))};let s=!1;const n=n=>{t.errored=!n,t.loaded=!0,jS.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),s&&i()};try{const{processEvent:i}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),n(e)}}),!1);i&&(t.processEvent=i),s=!0}catch(t){jS.error(VS+e.id,t),n(!1)}if(s&&t.loaded)try{i()}catch(i){jS.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}_setupSiteApps(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}_onCapturedEvent(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){jS.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,s;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void jS.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this._stopBuffering)||void 0===i||i.call(this),!e.ok)return;const n=e.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:e,url:t}of n.siteApps){var r,o;h[`__$$ph_site_app_${e}`]=this._instance,null===(r=h.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return jS.error(VS+e,t)})}else jS.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Bw={tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{const e=this._syncHostnamesForPatch();var t,i;e?(It(this._restoreXHRPatch)&&(this._restoreXHRPatch=null===(t=h.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),It(this._restoreFetchPatch)&&(this._restoreFetchPatch=null===(i=h.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i,s;(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=h.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"tracing-headers",t=>{if(t)return LS.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(){const e=this._getConfiguredHostnames();return kt(e)?(kt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(kt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},qw=ct({surveys:class extends ZS{constructor(e){var t;super(new iw(e),(t=e,{get projectToken(){return t.config.token},kv:new tw(t)})),this._instance=e}_sendSurveysRequest(e,t){const i=t.query?Tb(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})})}}},Lw),Hw={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){h.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=h.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,i=void 0,n=void 0){var r,o;if(nr(this.instance.config))return!1;if(!e||!s)return!1;t=null!==(r=t)&&void 0!==r?r:e.location,n=null!==(o=n)&&void 0!==o?o:e.history;try{if(!i){try{e.localStorage.setItem("test","test"),e.localStorage.removeItem("test")}catch(e){return!1}i=null==e?void 0:e.localStorage}const s=sw||dr(t.hash,"__posthog")||dr(t.hash,"state");let r;const o=s?cs(()=>JSON.parse(atob(decodeURIComponent(s))))||cs(()=>JSON.parse(decodeURIComponent(s))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?t.hash=o.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):(r=JSON.parse(i.getItem(nw)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){const t=h.ph_load_toolbar||h.ph_load_editor;!Pt(t)&&Ct(t)?t(e,this.instance):rw.warn("No toolbar load function found")}loadToolbar(t){const i=!!(null==s?void 0:s.getElementById("__POSTHOG_TOOLBAR__"));if(!e||i)return!1;const n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=ct(ct({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(e.localStorage.setItem(nw,JSON.stringify(ct(ct({},r),{},{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var o,a;this._setToolbarState(1),null===(o=h.__PosthogExtensions__)||void 0===o||null===(a=o.loadExternalDependency)||void 0===a||a.call(o,this.instance,"toolbar",e=>{if(e)return rw.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),sr(e,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},Uw=ct({experiments:class t{get _config(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(e=!1)=>{this.getWebExperiments(e=>{t._logInfo("retrieved web experiments from the server"),this._flagToExperiments=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;this._flagToExperiments&&(t._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=this._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e));const s=this._instance.getFeatureFlag(e.feature_flag_key);Tt(s)&&e.variants[s]&&this._applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(const i in e.variants){const s=e.variants[i];t._matchesTestVariant(s,this._instance)&&this._applyTransforms(e.name,i,s.transforms)}})},e)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t._logInfo(gw);else if(!this._config.disable_web_experiments){if(Pt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t._logInfo("applying feature flags",e),e.forEach(e=>{var t;if(this._flagToExperiments&&(null===(t=this._flagToExperiments)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),s=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&(null==s?void 0:s.variants[t])&&this._applyTransforms(s.name,t,s.variants[t].transforms)}})}}previewWebExperiment(){const e=t.getWindowLocation();if(null==e?void 0:e.search){const i=cr(null==e?void 0:e.search,"__experiment_id"),s=cr(null==e?void 0:e.search,"__experiment_variant");i&&s&&(t._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([]);const s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this._config.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,i,s){const n=s.filter(t=>t.id===e);n&&n.length>0&&(t._logInfo(`Previewing web experiment [${n[0].name}] with variant [${i}]`),this._applyTransforms(n[0].name,i,n[0].variants[i].transforms))}static _matchesTestVariant(e,i){return!Pt(e.conditions)&&t._matchUrlConditions(e,i)&&t._matchUTMConditions(e)}static _matchUrlConditions(e,i){var s;if(Pt(e.conditions)||Pt(null===(s=e.conditions)||void 0===s?void 0:s.url))return!0;const n=t.getWindowLocation();if(n){var r,o,a;const t=_r(i,n.href);return!(null===(r=e.conditions)||void 0===r?void 0:r.url)||fw[null!==(o=null===(a=e.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](e.conditions.url,t)}return!1}static getWindowLocation(){return null==e?void 0:e.location}static _matchUTMConditions(e){var t;if(Pt(e.conditions)||Pt(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=Ml();if(i.utm_source){var s,n,r,o,a,l,c,u;const t=!(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,p=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&p&&d}return!1}static _logInfo(e,...t){Vn.info(`[WebExperiments] ${e}`,t)}_applyTransforms(e,i,s){this._is_bot()?t._logInfo(gw):"control"!==i?s.forEach(s=>{if(s.selector){var n;t._logInfo(`applying transform of variant ${i} for experiment ${e} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(e=>{const t=e;s.html&&(t.innerHTML=s.html),s.css&&t.setAttribute("style",s.css)})}}):t._logInfo("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?Xb(i,this._config.custom_blocked_useragents):void 0}}},Lw),Ww={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)return;if(this._remoteConfigSuccessful=e.ok,!e.ok)return;const t=e.config.conversations;Pt(t)||(At(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this._isInitializing)return;if(this._instance.config.disable_conversations)return;if(nr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==h?void 0:h.__PosthogExtensions__;if(e&&!It(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{const t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);const i=e.loadExternalDependency;if(!i)return void this._handleLoadError(Qe);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 vw.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,vw.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else vw.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){vw.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():vw.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!Rt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":nr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":It(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?Pt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":(null==h?void 0:h.__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?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return rt(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(vw.warn(mw),null)})()}getMessages(e,t){var i=this;return rt(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(vw.warn(mw),null)})()}markAsRead(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(vw.warn(mw),null)})()}getTickets(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(vw.warn(mw),null)})()}requestRestoreLink(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(vw.warn(mw),null)})()}restoreFromToken(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(vw.warn(mw),null)})()}restoreFromUrlToken(){var e=this;return rt(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(vw.warn(mw),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}_onIdentityCleared(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},zw={logs:class{constructor(t){var i;this._instance=t,this.name=Fg,this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=Gn("[logs]"),this._coreLogger=ct(ct({},this._logger),{},{error:(...e)=>{e.some(Cw)||this._logger.error(...e)}}),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)||void 0===e||e.onReconnect(),null===(t=this._consoleCore)||void 0===t||t.onReconnect())},this._instance&&(null===(i=this._instance.config.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this._isLogsEnabled=!0),e&&sr(e,"online",this._onReconnect)}_buildCore(e,t,i,s){var n;const r=yw(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,i);return[new $n(this._createHost(e,t),r,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,s),r]}_getCore(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs;var i;return this._consoleCore&&this._consoleResolvedFrom===t||(null===(i=this._consoleCore)||void 0===i||i.reset(),this._consoleResolvedFrom=t,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Sw)),this._consoleCore}setup(e){var t;if(this._disposed)return;this._client=e,(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t||null===(t=t.logs)||void 0===t?void 0:t.captureConsoleLogs)&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._remoteConfigWillArrive()&&this._persistedCaptureHint())&&this._startConsoleRecorder();let i=!1;const s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?s.dispose():(this._remoteConfigSubscription=s,i||this.loadIfEnabled())}dispose(){var t,i,s,n;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null===(t=this._remoteConfigSubscription)||void 0===t||t.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null==e||e.removeEventListener("online",this._onReconnect),null===(i=this._consoleLogsDispose)||void 0===i||i.call(this),this._consoleLogsDispose=void 0,null===(s=this._core)||void 0===s||s.reset(),null===(n=this._consoleCore)||void 0===n||n.reset())}onRemoteConfig(e){var t,i;if(this._disposed)return;const s=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;Pt(s)?this._stopRecorderStartedByPersistedHint():(null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$logs_capture_enabled_server_side:!!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)||void 0===e||e.clearQueue(),this._queue=[],null===(t=this._core)||void 0===t||t.reset(),null===(i=this._consoleCore)||void 0===i||i.clearQueue(),this._consoleQueue=[],null===(s=this._consoleCore)||void 0===s||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)||void 0===e||null===(e=e.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e[F])}_remoteConfigWillArrive(){var e,t,i;return!(null===(e=this._instance)||void 0===e||null===(t=e._shouldDisableFlags)||void 0===t?void 0:t.call(e))||!!(null===(i=h._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[this._instance.config.token])||void 0===i?void 0:i.config)}_onOptOut(){var e;this._stopConsoleRecorder(),null===(e=this._consoleCore)||void 0===e||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!(null==h?void 0:h.console))return;const t=yw(null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs).maxBufferSize;let i=!0;this._consoleRecorderUnpatchers.push(()=>{i=!1});for(const e of bw){let s;try{s=iv(h.console[e])}catch(e){continue}s&&this._consoleRecorderUnpatchers.push(Sp(h.console,e,n=>{const r=(...s)=>{try{i&&this._recordConsoleEntry(e,s,t)}catch(e){}return n.apply(h.console,s)};return r.__rrweb_original__=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)||void 0===s?void 0: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){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0);for(const e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){const 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){Cw(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;const e=null==h?void 0:h.__PosthogExtensions__;if(!e)return this._logger.error("PostHog Extensions not found."),void this._stopConsoleRecorder();const t=e.loadExternalDependency;if(!t)return this._logger.error(Qe),void this._stopConsoleRecorder();this._isLoading=!0;try{t(this._instance,"logs",t=>{if(this._isLoading=!1,this._disposed||!this._isLogsEnabled)return;const i=e.logs;if(t||!(null==i?void 0:i.initializeLogs))this._logger.error("Could not load logs script",t),this._stopConsoleRecorder();else{var s;const e=this._takeConsoleBuffer();var n,r;this._consoleLogsDispose=i.initializeLogs(null!==(s=this._client)&&void 0!==s?s:this._instance),this._isLoaded=!0,e.length>0&&(null===(n=i.replayConsoleBuffer)||void 0===n||n.call(i,null!==(r=this._client)&&void 0!==r?r:this._instance,e))}})}catch(e){throw this._isLoading=!1,e}}_createHost(e,t){const i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===ut.LogsQueue?e():void 0,setPersistedProperty(e,i){var s;e===ut.LogsQueue&&t(null!==(s=i)&&void 0!==s?s:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>Ya.LIB_NAME,getLibraryVersion:()=>Ya.LIB_VERSION}}_sendLogsBatch(e){return new Promise(t=>{if(hr(this._consecutiveStatusZeroFailures,3))return void t({kind:"fatal",error:kw(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const s=e=>{i||(i=!0,clearTimeout(n),t(e))},n=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:kw(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=>{const 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:kw(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=pr(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,Ya.LIB_NAME,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,Sw,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,s,n){if(0===t.length)return;const r=t.map(e=>e.record);n([]);const o=Ln(r,Fn(i,Ya.LIB_NAME,Ya.LIB_VERSION),s,Ya.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;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:e,windowId:i,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=e,t.windowId=i,Pt(s)||(t.sessionStartTimestamp=s),Pt(n)||(t.lastActivityTimestamp=n)}if((null==h||null===(e=h.location)||void 0===e?void 0:e.href)&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ls(h.location.href):h.location.href),this._instance.featureFlags){const e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},jw={metrics:class{constructor(e){this._instance=e,this._logger=Gn("[metrics]"),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this._disposed)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,s=Pw(e,i),n=Fw(e,i);return()=>{t=!1,s(),n()}})(this._instance):!t&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,this._core=new Hn(this._createHost(),function(e){var t,i,s,n,r;const 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!==(n=null==e?void 0:e.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(t),this._logger)),this._core}count(e,t=1,i){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){const 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)||void 0===e||e.reset()}dispose(){var e,t;this._disposed=!0,null===(e=this._stopNetworkMetrics)||void 0===e||e.call(this),this._stopNetworkMetrics=void 0,null===(t=this._core)||void 0===t||t.reset()}_createHost(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>Ya.LIB_NAME,getLibraryVersion:()=>Ya.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{let s=!1;const n=e=>{s||(s=!0,clearTimeout(r),i(e))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(ct(ct({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};RS.__defaultExtensionClasses=ct({},ct(ct(ct(ct(ct(ct(ct(ct(ct(ct(ct(ct(ct({},Lw),Aw),Ow),Dw),$w),Nw),qw),Bw),Hw),Uw),Ww),zw),jw));const Vw=function(){Ya.SDK_DIST_CHANNEL="npm";const t=pS[CS]=new RS;return function(){function t(){t.done||(t.done=!0,Hb=!1,Kn(pS,function(e){e._dom_loaded()}))}(null==s?void 0:s.addEventListener)?"complete"===s.readyState?t():sr(s,"DOMContentLoaded",t,{capture:!1}):e&&Vn.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();var Gw=Vw;export{cg as Compression,_b as DEFAULT_PRODUCT_TOUR_APPEARANCE,bg as DisplaySurveyType,RS as PostHog,gb as ProductTourEventName,fb as ProductTourEventProperties,mg as SurveyEventName,yg as SurveyEventProperties,ug as SurveyEventType,hg as SurveyPosition,fg as SurveyQuestionBranchingType,gg as SurveyQuestionType,vg as SurveySchedule,pg as SurveyTabPosition,_g as SurveyType,dg as SurveyWidgetType,Gw as default,Vw as posthog,Sb as severityLevels};
2
2
  //# sourceMappingURL=module.full.no-external.js.map