tokentracker-cli 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dashboard/dist/.well-known/submitby-ai/6e2fa70e-9eb2-4c97-a9a9-fed567a3d4a9.txt +1 -0
  4. package/dashboard/dist/assets/AchievementBadge-B5kmt0VD.js +1 -0
  5. package/dashboard/dist/assets/{AchievementsPage-9_MxdI7O.js → AchievementsPage-C0FlkOo0.js} +2 -2
  6. package/dashboard/dist/assets/{AchievementsSection-CKDQGcJh.js → AchievementsSection-CRcp80Pp.js} +1 -1
  7. package/dashboard/dist/assets/{BadgeDetailModal-DdrXPVRL.js → BadgeDetailModal-DAFjGbKW.js} +1 -1
  8. package/dashboard/dist/assets/{BotAnimated-DsJDdDid.js → BotAnimated-CO0bbimB.js} +1 -1
  9. package/dashboard/dist/assets/{Card-Bz-sWY1C.js → Card-Xhr5exz8.js} +1 -1
  10. package/dashboard/dist/assets/{CloudCheckoutPage-DRjZcE0W.js → CloudCheckoutPage-DsQ7FmsI.js} +1 -1
  11. package/dashboard/dist/assets/{CloudPage-BNDyyX9r.js → CloudPage-DkSexu5V.js} +2 -2
  12. package/dashboard/dist/assets/{CommandPalette-LbE6Icc0.js → CommandPalette-Bm0huQdj.js} +1 -1
  13. package/dashboard/dist/assets/{CommunityStatsModal-DuEcAOB9.js → CommunityStatsModal-BsL8GN8Q.js} +1 -1
  14. package/dashboard/dist/assets/{ConfirmModal-B5V7ONKv.js → ConfirmModal-_WPp292g.js} +1 -1
  15. package/dashboard/dist/assets/{Controls-ZfN0QwwD.js → Controls-ktzn68KM.js} +1 -1
  16. package/dashboard/dist/assets/{DashboardPage-DqZPFmlv.js → DashboardPage-CdNXi3Im.js} +1 -1
  17. package/dashboard/dist/assets/{DateRangePopover-CbkBeaEI.js → DateRangePopover-DWr4zIzF.js} +1 -1
  18. package/dashboard/dist/assets/{DevicePage-DrHjmpPH.js → DevicePage-CBa8Mk47.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-DHaAwV1u.js → DialogClose-CZ5jzgtb.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-kCZ4gN09.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-CBhd4oLc.js → DialogTitle-Dr0N6q15.js} +1 -1
  22. package/dashboard/dist/assets/{ElectricLogo-CSWd3b2H.js → ElectricLogo-sYqgrO6-.js} +1 -1
  23. package/dashboard/dist/assets/{FadeIn-D5p6nDla.js → FadeIn-Qq-hcrZW.js} +1 -1
  24. package/dashboard/dist/assets/{HeaderGithubStar-BKVSzY27.js → HeaderGithubStar-B77zSv7i.js} +1 -1
  25. package/dashboard/dist/assets/{HoverTooltip-CvkAyCDm.js → HoverTooltip-lRDaUmoW.js} +1 -1
  26. package/dashboard/dist/assets/{IpCheckPage-BEMJGKtl.js → IpCheckPage-B6AvHZjA.js} +1 -1
  27. package/dashboard/dist/assets/{LandingPage-iRp33enQ.js → LandingPage-DgzOjf3x.js} +2 -2
  28. package/dashboard/dist/assets/{LeaderboardPage-DVMPrN4z.js → LeaderboardPage-BtjjtDMC.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProBadge-DwnaJoje.js → LeaderboardProBadge-B2wNTUTU.js} +1 -1
  30. package/dashboard/dist/assets/{LeaderboardProfileModal-DnzVweLM.js → LeaderboardProfileModal-DJJckwHh.js} +3 -3
  31. package/dashboard/dist/assets/{LeaderboardProfilePage-BHNuPuW7.js → LeaderboardProfilePage-DJdxByl2.js} +1 -1
  32. package/dashboard/dist/assets/LimitsPage-gSBHSBi_.js +6 -0
  33. package/dashboard/dist/assets/{LocalOnlyNotice-DStlbPET.js → LocalOnlyNotice-B2lVqf_H.js} +1 -1
  34. package/dashboard/dist/assets/{LoginCard-I47ukXU5.js → LoginCard-i0gg1yby.js} +1 -1
  35. package/dashboard/dist/assets/{LoginModal-C4iotNjY.js → LoginModal-B-loLNZM.js} +1 -1
  36. package/dashboard/dist/assets/{LoginPage-46QSEnG0.js → LoginPage-D_swI75j.js} +1 -1
  37. package/dashboard/dist/assets/{PetPage-SvgDUR8o.js → PetPage-DDpKvpjG.js} +2 -2
  38. package/dashboard/dist/assets/{PopoverPopup-k2ejLK1I.js → PopoverPopup-Gja4MyEK.js} +1 -1
  39. package/dashboard/dist/assets/{ProviderIcon-Bx1XKzin.js → ProviderIcon-DOPj7tAZ.js} +1 -1
  40. package/dashboard/dist/assets/{ResetPasswordPage-CcKIDknp.js → ResetPasswordPage-BVADLk89.js} +1 -1
  41. package/dashboard/dist/assets/{Select-D0hLQyU8.js → Select-D-38tN-E.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-DJGBJhDK.js → SelectItemText-jN61ukxk.js} +1 -1
  43. package/dashboard/dist/assets/{SelfHostPage-CeIFGRep.js → SelfHostPage-k7AkGpl1.js} +1 -1
  44. package/dashboard/dist/assets/ServiceStatusPage-D_Fa_pYz.js +1 -0
  45. package/dashboard/dist/assets/{SessionsPage-D6h5vSZn.js → SessionsPage-BymccEEz.js} +1 -1
  46. package/dashboard/dist/assets/{SettingsPage-BZgpB5SB.js → SettingsPage-DfnMCAuA.js} +3 -3
  47. package/dashboard/dist/assets/{SkillsPage-CtFuZ1ob.js → SkillsPage-YyIHIaHN.js} +1 -1
  48. package/dashboard/dist/assets/{TokenGalaxy-DC-no047.js → TokenGalaxy-BLcvZuQ9.js} +1 -1
  49. package/dashboard/dist/assets/{TooltipPopup-ZM0Ie2_C.js → TooltipPopup-3E8kyVzz.js} +1 -1
  50. package/dashboard/dist/assets/{TrendMonitor-fpLaqJ-o.js → TrendMonitor-ByKAdXSF.js} +1 -1
  51. package/dashboard/dist/assets/{WidgetsPage-DIoHY6ZJ.js → WidgetsPage-BgEVIIzL.js} +1 -1
  52. package/dashboard/dist/assets/{WrappedPage-D1-7o8Z1.js → WrappedPage-HjbX8QaA.js} +1 -1
  53. package/dashboard/dist/assets/__vite-browser-external-D_cMeuqI.js +45 -0
  54. package/dashboard/dist/assets/{agent-logos-YBC1iAbE.js → agent-logos-BVF2siPQ.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-left-BIe3z7iW.js → arrow-left-CYO24PGP.js} +1 -1
  56. package/dashboard/dist/assets/{arrow-right-CJmRcvYZ.js → arrow-right-Xg9PZYhw.js} +1 -1
  57. package/dashboard/dist/assets/{arrow-up-right-IgkBHoCl.js → arrow-up-right-B7ah6Qv-.js} +1 -1
  58. package/dashboard/dist/assets/{calendar-days-DTuIv3ts.js → calendar-days-BV_iG938.js} +1 -1
  59. package/dashboard/dist/assets/{check-DrXhhj46.js → check--EZH8RTp.js} +1 -1
  60. package/dashboard/dist/assets/{chevron-down-DHaFKHMK.js → chevron-down-BzGTlk0-.js} +1 -1
  61. package/dashboard/dist/assets/{cloud-checkout-BffVMyzI.js → cloud-checkout-BgyxPHEh.js} +1 -1
  62. package/dashboard/dist/assets/{composite-M_CP_KSx.js → composite-C0KrmLEK.js} +1 -1
  63. package/dashboard/dist/assets/{copy-D5xoS-Q8.js → copy-BtucSK2U.js} +1 -1
  64. package/dashboard/dist/assets/{download-CqomMv4-.js → download-CWHq03Y2.js} +1 -1
  65. package/dashboard/dist/assets/{external-link--q3pCw6b.js → external-link-DCTXF5VZ.js} +1 -1
  66. package/dashboard/dist/assets/{flame-CUGlDV__.js → flame-BE5TsqVF.js} +1 -1
  67. package/dashboard/dist/assets/{format-tokens-BZ6TX9Km.js → format-tokens-ThNIMWnZ.js} +1 -1
  68. package/dashboard/dist/assets/{gift-BBgOeC20.js → gift-DgaN9s4-.js} +1 -1
  69. package/dashboard/dist/assets/{icons-BELeB4ms.js → icons-B4r5EiDC.js} +1 -1
  70. package/dashboard/dist/assets/{index-B1B6oAbl.js → index-CKhcCLNC.js} +1 -1
  71. package/dashboard/dist/assets/{index-CsdgnKGf.js → index-DFF9xo6f.js} +1 -1
  72. package/dashboard/dist/assets/{index-CoRqgJ71.js → index-DqCtgU0G.js} +1 -1
  73. package/dashboard/dist/assets/{index-DkBvk4Qg.js → index-fNKH4U7j.js} +33 -33
  74. package/dashboard/dist/assets/{info-BG1vQZ1r.js → info-B4YzRR4y.js} +1 -1
  75. package/dashboard/dist/assets/{link-2-oi5TrXqi.js → link-2-DzbUbaBw.js} +1 -1
  76. package/dashboard/dist/assets/{loader-circle-BQQ_Xbby.js → loader-circle-B9c7D-7v.js} +1 -1
  77. package/dashboard/dist/assets/{local-usage-transfer-Dwz-clJ-.js → local-usage-transfer-btuk_b0Y.js} +1 -1
  78. package/dashboard/dist/assets/{modifiers.esm-C7a817l7.js → modifiers.esm-BjrU-Xz7.js} +1 -1
  79. package/dashboard/dist/assets/module-ZyVsxBG_.js +3 -0
  80. package/dashboard/dist/assets/{monitor-smartphone-Bnbo7uRg.js → monitor-smartphone-Bwn4tb4q.js} +1 -1
  81. package/dashboard/dist/assets/{play-C_xI_JM_.js → play-DIFOwGIQ.js} +1 -1
  82. package/dashboard/dist/assets/{plus-xF6PK5As.js → plus-BpBqnwVg.js} +1 -1
  83. package/dashboard/dist/assets/{provider-display-DxquW3js.js → provider-display-DSrs4u7T.js} +1 -1
  84. package/dashboard/dist/assets/{react-CGK0_x3G.js → react-BgG7_MY0.js} +1 -1
  85. package/dashboard/dist/assets/{safePolygon-CCoDMR4f.js → safePolygon-BUGWIDOM.js} +1 -1
  86. package/dashboard/dist/assets/{search-EZAGpmfJ.js → search-aHrmBmtZ.js} +1 -1
  87. package/dashboard/dist/assets/{server-2qbrx2G0.js → server-DOEvwlEU.js} +1 -1
  88. package/dashboard/dist/assets/{shield-check-D8kUejpE.js → shield-check-BPTnLhsT.js} +1 -1
  89. package/dashboard/dist/assets/{skills-api-DYPf1Vxh.js → skills-api-C052Mwez.js} +1 -1
  90. package/dashboard/dist/assets/{sortable.esm-D9gC08dQ.js → sortable.esm-DaZKhjhu.js} +1 -1
  91. package/dashboard/dist/assets/{store-BWUCbK6Y.js → store-Cq30Pofw.js} +1 -1
  92. package/dashboard/dist/assets/{terminal-B16b7r6H.js → terminal-CoSDSkE7.js} +1 -1
  93. package/dashboard/dist/assets/{trash-BIEoE13C.js → trash-BAmt-kPj.js} +1 -1
  94. package/dashboard/dist/assets/use-community-stats-Bxq0kBhm.js +1 -0
  95. package/dashboard/dist/assets/{use-latest-request-guard-CYKu-VOB.js → use-latest-request-guard-DmIQDlvk.js} +1 -1
  96. package/dashboard/dist/assets/use-limits-display-prefs-CyAn1fme.js +1 -0
  97. package/dashboard/dist/assets/{use-native-settings-vTg4j5Ln.js → use-native-settings-s_CIC8Bb.js} +1 -1
  98. package/dashboard/dist/assets/{use-ordered-list-CtXedlqH.js → use-ordered-list-BHhykAbt.js} +1 -1
  99. package/dashboard/dist/assets/use-reduced-motion-BmFyFE3S.js +1 -0
  100. package/dashboard/dist/assets/{use-transform-CdeW5xhz.js → use-transform-CVeMFlS6.js} +1 -1
  101. package/dashboard/dist/assets/use-usage-limits-DRZMI20u.js +1 -0
  102. package/dashboard/dist/assets/{useCurrency-bqycM681.js → useCurrency-DilqL2Iv.js} +1 -1
  103. package/dashboard/dist/assets/{usePositioner-DEXS10fY.js → usePositioner-BcnySw8a.js} +1 -1
  104. package/dashboard/dist/assets/{useTokenFormat-YF6hY8_m.js → useTokenFormat-CvKW46WP.js} +1 -1
  105. package/dashboard/dist/assets/{zap-Dg-ij-lq.js → zap-D7VRNTwk.js} +1 -1
  106. package/dashboard/dist/index.html +24 -1
  107. package/dashboard/dist/indexnow-key.txt +1 -0
  108. package/dashboard/dist/ip-check.html +1 -1
  109. package/dashboard/dist/leaderboard.html +1 -1
  110. package/dashboard/dist/share.html +1 -1
  111. package/dashboard/dist/tt6a1c9e2f4b8d.txt +1 -0
  112. package/package.json +3 -3
  113. package/src/lib/codex-rollout-parser.js +43 -6
  114. package/src/lib/codex-usage-record.js +21 -0
  115. package/src/lib/pricing/curated-overrides.json +94 -0
  116. package/src/lib/pricing/seed-snapshot.json +1 -1
  117. package/src/lib/qoder-limits.js +252 -55
  118. package/src/lib/rollout.js +68 -14
  119. package/src/lib/session-analytics.js +10 -3
  120. package/src/lib/usage-limits.js +6 -4
  121. package/src/lib/workbuddy-limits.js +101 -9
  122. package/src/lib/zcode-limits.js +350 -43
  123. package/dashboard/dist/assets/AchievementBadge-Dn39pyx9.js +0 -1
  124. package/dashboard/dist/assets/DialogDescription-CEY6jbs9.js +0 -1
  125. package/dashboard/dist/assets/LimitsPage-9LitacBf.js +0 -6
  126. package/dashboard/dist/assets/ServiceStatusPage-DMtw0YDh.js +0 -1
  127. package/dashboard/dist/assets/__vite-browser-external-DZF5L1pt.js +0 -45
  128. package/dashboard/dist/assets/module-C2SOSUuR.js +0 -3
  129. package/dashboard/dist/assets/use-community-stats-DWS7YKbM.js +0 -1
  130. package/dashboard/dist/assets/use-limits-display-prefs-CEAjVxFr.js +0 -1
  131. package/dashboard/dist/assets/use-reduced-motion-DVLsAhSA.js +0 -1
  132. package/dashboard/dist/assets/use-usage-limits-DmDa5Py8.js +0 -1
@@ -1,3 +0,0 @@
1
- var $u={};const b="u">typeof window?window:void 0,ve="u">typeof globalThis?globalThis:b,he=ve?.navigator,$=ve?.document,Q=ve?.location,vs=ve?.fetch,Ir=ve?.XMLHttpRequest&&"withCredentials"in new ve.XMLHttpRequest?ve.XMLHttpRequest:void 0,nn=ve?.AbortController,Eu=ve?.CompressionStream,ye=he?.userAgent,Wt=typeof globalThis<"u"?globalThis:b;Wt&&typeof self>"u"&&(Wt.self=Wt),Wt&&typeof File>"u"&&(Wt.File=function(){});const T=b??{},Su="0.9.5",Ge={DEBUG:!1,LIB_VERSION:Su,LIB_NAME:"browser-common"};var je=(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.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),Yi=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const Pu=["$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"],Mu=["token"];function A(e,t){return e.indexOf(t)!==-1}const Lt=function(e){return e.trim()},Xi=function(e){return e.replace(/^\$/,"")};function Bo(e){var t;const s=[];return(t=JSON.stringify(e,function(i,r){if(typeof r=="bigint")return r.toString();if(typeof r!="function"&&typeof r!="symbol"){if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r&&typeof r=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(r))return"[Circular]";s.push(r)}return r}}))!==null&&t!==void 0?t:"null"}const zo=Object.prototype,Or=zo.hasOwnProperty,ri=zo.toString,F=Array.isArray||function(e){return ri.call(e)==="[object Array]"},oe=e=>typeof e=="function",L=e=>e===Object(e)&&!F(e),$e=e=>{if(L(e)){for(const t in e)if(Or.call(e,t))return!1;return!0}return!1},x=e=>e===void 0,D=e=>ri.call(e)=="[object String]",rs=e=>D(e)&&e.trim().length===0,se=e=>e===null,R=e=>x(e)||se(e),ne=e=>ri.call(e)=="[object Number]"&&e==e,ze=e=>ne(e)&&e>0,we=e=>ri.call(e)==="[object Boolean]",Iu=e=>A(Pu,e),Ou=e=>A(Mu,e);function Vo(e){return e===null||typeof e!="object"}function Ns(e,t){return{}.toString.call(e)===`[object ${t}]`}function Vt(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 Wo(e,Error)}}function Fr(e){return"u">typeof Event&&Wo(e,Event)}function Wo(e,t){try{return e instanceof t}catch{return!1}}const Fu=[!0,"true",1,"1","yes"],ci=e=>A(Fu,e),Cu=[!1,"false",0,"0","no"];function on(e,t,s,i,r,n,o){try{var a=e[n](o),l=a.value}catch(u){return void s(u)}a.done?t(l):Promise.resolve(l).then(i,r)}function X(e){return function(){var t=this,s=arguments;return new Promise(function(i,r){var n=e.apply(t,s);function o(l){on(n,i,r,o,a,"next",l)}function a(l){on(n,i,r,o,a,"throw",l)}o(void 0)})}}const Au=["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"],$s=new Map,an=function(e,t=[]){if(!e)return!1;const s=(function(o,a){let l="";for(let u=0;a.length>u;u++){const c=a[u];l+=c.length+":"+c}return o.length+":"+o+"|"+a.length+":"+l})(e,t),i=$s.get(s);if(i!==void 0)return i;const r=e.toLowerCase(),n=Au.concat(t).some(o=>r.indexOf(o.toLowerCase())!==-1);return 256>$s.size||$s.clear(),$s.set(s,n),n};function qe(e,t,s,i,r){return t>s&&(i.warn("min cannot be greater than max."),t=s),ne(e)?e>s?(i.warn(" cannot be greater than max: "+s+". Using max value instead."),s):t>e?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+r),qe(r??s,t,s,i))}var Tu=class{constructor(e){this.C={},this.I=e.I,this.R=qe(e.bucketSize,0,100,e.A),this.$=qe(e.refillRate,0,this.R,e.A),this.O=qe(e.refillInterval,0,864e5,e.A)}F(e,t){const s=Math.floor((t-e.lastAccess)/this.O);s>0&&(e.tokens=Math.min(e.tokens+s*this.$,this.R),e.lastAccess=e.lastAccess+s*this.O)}consumeRateLimit(e){var t;const s=Date.now(),i=String(e);let r=this.C[i];return r?this.F(r,s):(r={tokens:this.R,lastAccess:s},this.C[i]=r),r.tokens===0||(r.tokens--,r.tokens===0&&((t=this.I)===null||t===void 0||t.call(this,e)),r.tokens===0)}stop(){this.C={}}};const Dt="Mobile",gs="Android",js="Tablet",Uo="Android Tablet",Go="iPad",Jo="Apple Watch",Fs="Safari",ni="BlackBerry",Ko="Samsung Internet",Cs="Chrome",Qo="Chrome iOS",Yo="Internet Explorer",Xo="Internet Explorer Mobile",Zo="Opera",ea="Microsoft Edge",As="Firefox",ta="Firefox iOS",qs="Nintendo",Hs="PlayStation",oi="Xbox",sa="Android Mobile",ia="Mobile Safari",di="Windows",ra="Windows Phone",ln="Nokia",Zi="Ouya",Ru="Generic "+Dt.toLowerCase(),na="Generic "+js.toLowerCase(),er="Konqueror",oa="Oculus Browser",aa="Vivaldi",la="Yandex",ua="Whale",ca="DuckDuckGo",da="Pale Moon",ha="Waterfox",tr="Brave",pa="Claude",fa="Codex",va="ChatGPT",ga="Google Search App",hi=new RegExp("Version/(\\d+(\\.\\d+)?)"),pi=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Lu=new RegExp(oi,"i"),Du=new RegExp("PlayStation \\w+","i"),Nu=new RegExp("Nintendo \\w+","i"),Cr=new RegExp("BlackBerry|PlayBook|BB10","i"),ju={"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"},_a=function(e,t,s,i){return t=t||"",(function(n){return n?.brave?tr:null})(s)||(i?.detectGoogleSearchApp&&A(e,"GSA/")?ga:A(e," OPR/")&&A(e,"Mini")?"Opera Mini":A(e," OPR/")?Zo:Cr.test(e)?ni:A(e,"IEMobile")||A(e,"WPDesktop")?Xo:A(e,"OculusBrowser")?oa:A(e,"SamsungBrowser")?Ko:A(e,"Edge")||A(e,"Edg/")?ea:A(e,"Vivaldi/")?aa:A(e,"YaBrowser/")?la:A(e,"Whale/")?ua:A(e,"DuckDuckGo/")||A(e,"Ddg/")?ca:A(e,"Claude/")?pa:A(e,"Codex/")?fa:A(e,"ChatGPT/")?va:A(e,"FBIOS")?"Facebook Mobile":A(e,"UCWEB")||A(e,"UCBrowser")?"UC Browser":A(e,"CriOS")?Qo:A(e,"CrMo")||A(e,Cs)?Cs:A(e,gs)&&A(e,Fs)?sa:A(e,"FxiOS")?ta:A(e.toLowerCase(),er.toLowerCase())?er:A(e,"Brave/")?tr:((n,o)=>o&&A(o,"Apple")||(function(a){return A(a,Fs)&&!A(a,Cs)&&!A(a,gs)})(n))(e,t)?A(e,Dt)?ia:Fs:A(e,"PaleMoon/")?da:A(e,"Waterfox/")?ha:A(e,As)?As:A(e,"MSIE")||A(e,"Trident/")?Yo:A(e,"Gecko")?As:"")},qu={[Xo]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ea]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Cs]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Qo]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Fs]:[hi],[ia]:[hi],[Zo]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[As]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ta]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[er]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[ni]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),hi],[sa]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Ko]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[oa]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[aa]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[la]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ua]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[tr]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[pa]:[pi],[fa]:[pi],[va]:[pi],[ca]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[da]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[ha]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[ga]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Yo]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Hu=function(e,t,s,i){const r=_a(e,t,s,i),n=qu[r];if(x(n))return null;for(let o=0;n.length>o;o++){const a=e.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},un=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[oi,e&&e[1]||""]],[new RegExp(qs,"i"),[qs,""]],[new RegExp(Hs,"i"),[Hs,""]],[Cr,[ni,""]],[new RegExp(di,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ra,""];if(new RegExp(Dt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const s=/Windows NT ([0-9.]+)/i.exec(t);if(s&&s[1]){let i=ju[s[1]]||"";return/arm/i.test(t)&&(i="RT"),[di,i]}return[di,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=x(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[gs,[e[2],e[3],e[4]||"0"].join(".")]:[gs,""]],[/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",""]]],ma=function(e){for(let t=0;un.length>t;t++){const[s,i]=un[t],r=s.exec(e),n=r&&(oe(i)?i(r,e):i);if(n)return n}return["",""]},ya=function(e){return Nu.test(e)?qs:Du.test(e)?Hs:Lu.test(e)?oi:new RegExp(Zi,"i").test(e)?Zi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?ra:/iPad/.test(e)?Go:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Jo:Cr.test(e)?ni:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(ln,"i").test(e)?ln:/(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(Dt).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)?gs:Uo:new RegExp("(pda|Mobile)","i").test(e)?Ru:new RegExp(js,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?na:""},Bu=function(e,t){var s;const i=ya(e);return i===Go||i===Uo||i==="Kobo"||i==="Kindle Fire"||i===na?js:i===qs||i===oi||i===Hs||i===Zi?"Console":i===Jo?"Wearable":i?Dt:t?.userAgentDataPlatform==="Android"&&((s=t?.maxTouchPoints)!==null&&s!==void 0?s:0)>0?600>Math.min((r=t?.screenWidth)!==null&&r!==void 0?r:0,(n=t?.screenHeight)!==null&&n!==void 0?n:0)/((o=t?.devicePixelRatio)!==null&&o!==void 0?o:1)?Dt:js:"Desktop";var r,n,o},fi=/\bFBAV\/(\d+(?:\.\d+)*)/i,cn=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",fi],[/\bFBAN\/EMA\b/i,"Facebook Lite",fi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",fi],[/\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"]],sr="[Truncated]",xs="[Unserializable]";function At(e){let t="";for(let s=0;e.length>s;s++){const i=e.charCodeAt(s);if(55296>i||i>56319)t+=56320>i||i>57343?e[s]:"�";else{const r=e.charCodeAt(s+1);56320>r||r>57343?t+="�":(t+=e[s]+e[s+1],s++)}}return t}function ba(e,t){if(!t)return e;let s=[];try{s=Object.keys(t)}catch{s=[]}for(const i of s){let r;try{r=t[i]}catch{r=xs}Object.defineProperty(e,i,{value:r,enumerable:!0,writable:!0,configurable:!0})}return e}const Ts=3e5;var wa=class{record(e){if(e.kind==="too-large")return;if(e.kind!=="retry-later")return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),s=Date.now(),i=Math.min(e.retryAfterMs,Ts);if(!t)return this.ts=s,void(this.es=s+i);this.es=Math.max(this.es,Math.min(s+i,this.ts+Ts))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(Ts,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const zu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function dn(e,t){return typeof(s=e)=="string"&&zu.test(s)?e:t();var s}function xa(e,t){const s=new Error(t);try{Object.defineProperty(s,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function ot(e){return e&&e.split("#")[0]}function hn(e){try{return e()}catch{return}}function ka(e,t){const s=setTimeout(e,t);return s!=null&&s.unref&&s?.unref(),s}function pn(e,t,s){return $a.apply(this,arguments)}function $a(){return($a=X(function*(e,t,s){let i;try{return yield Promise.race([e,new Promise((r,n)=>{i=ka(()=>{try{s?.(),r()}catch(o){n(o)}},t)})])}finally{clearTimeout(i)}})).apply(this,arguments)}function ns(e){return ns=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ns(e)}function Vu(e,t,s){return(t=(function(i){var r=(function(n){if(ns(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var a=o.call(n,"string");if(ns(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)})(i);return ns(r)=="symbol"?r:r+""})(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function fn(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),s.push.apply(s,i)}return s}function f(e){for(var t=1;arguments.length>t;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?fn(Object(s),!0).forEach(function(i){Vu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):fn(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}let Ut,vn,gn,bt;function Wu(e){var t;const s=globalThis._posthogChunkIds,i=globalThis._debugIds;if(!s&&!i)return;const r=s?Object.keys(s):[],n=i?Object.keys(i):[];if(bt&&_n(s,r,vn)&&_n(i,n,gn))return bt;vn=s?f({},s):void 0,gn=i?f({},i):void 0,bt={},(t=Ut)!==null&&t!==void 0||(Ut={});const o=(a,l)=>{for(const c of a){const h=l[c];if(!h)continue;const d=Ut?.[c];if(d){bt[d]=h;continue}const p=e(c);for(let v=p.length-1;v>=0;v--){var u;const _=(u=p[v])===null||u===void 0?void 0:u.filename;if(_){bt[_]=h,Ut[c]=_;break}}}};return i&&o(n,i),s&&o(r,s),bt}function _n(e,t,s){return e&&s?t.length===Object.keys(s).length&&t.every(i=>e[i]===s[i]):e===s}var Uu=class{constructor(e,t,s=[]){this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t={}){const s=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,t,0).apply(e),r=this.buildParsingContext(t),n=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(n,s),$exception_level:"error"}}modifyFrames(e){var t=this;return X(function*(){for(const s of e)s.stacktrace&&s.stacktrace.frames&&F(s.stacktrace.frames)&&(s.stacktrace.frames=yield t.applyModifiers(s.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)===null||t===void 0?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s;let i,r;if(e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null)try{r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return f(f({},e),{},{cause:i,stack:r,errors:(s=e.errors)===null||s===void 0?void 0:s.map(n=>this.parseStacktrace(n,t))})}applyChunkIds(e,t){return e.map(s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s))}applyCoercers(e,t){for(const s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return X(function*(){let s=e;for(const i of t.modifiers)s=yield i(s);return s})()}convertToExceptionList(e,t){const s=[],i=(r,n,o)=>{var a;const l=s.length,u=n===void 0?f(f({type:typeof t.type=="string"&&t.type.length>0?t.type:"generic"},typeof t.handled=="boolean"?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic=="boolean"?t.synthetic:r.synthetic,exception_id:l}):{type:"chained",source:o,synthetic:r.synthetic,exception_id:l,parent_id:n},c={type:r.type,value:r.value,mechanism:u};r.stack&&(c.stacktrace={type:"raw",frames:r.stack}),s.push(c),r.cause&&i(r.cause,l,"cause");for(const h of(a=r.errors)!==null&&a!==void 0?a:[])i(h,l,"member")};return i(e),s}buildParsingContext(e){var t;return{chunkIdMap:Wu(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(Vt(e)){let s=Object.getPrototypeOf(e);for(let i=0;s&&100>i;i++){var t;const r=(t=Object.getOwnPropertyDescriptor(s,"constructor"))===null||t===void 0?void 0:t.value;if(typeof r=="function"&&r.name==="AggregateError"){const n=e.errors;return F(n)?n:void 0}s=Object.getPrototypeOf(s)}}}catch{}}buildCoercingContext(e,t,s=0){let i=0,r=0,n=!1;const o=new Set,a=[],l={},u=(d,p,v=0)=>{const _=c(p,v),g=_.apply;if(_.apply=P=>{a.push(d);try{return g(P)}finally{a.pop()}},v>4||v>0&&a.indexOf(d)!==-1)return this.coerceFallback(_);const y=typeof d=="object"&&d!==null||typeof d=="function";if(v===0&&i>=50||y&&o.has(d))return;y&&o.add(d),v===0&&i++;const m=this.getAggregateErrors(d);let w,E;n||(n=!!m);try{if(w=this.applyCoercers(d,_),!w)throw l}catch(P){if(P===l)return void(v===0&&i--);if(!n)throw P;w=this.coerceFallback(_)}if(!m||i>=50)return w;try{E=m.length}catch{return w}if(!Number.isInteger(E)||0>E||E>4294967295)return w;const k=[];for(let P=0;50>i&&1e3>r&&E>P;P++){let I;r++;try{I=_.next(m[P])}catch{i++,I=this.coerceFallback(c(p+1))}I&&k.push(I)}return f(f({},w),{},{errors:k})},c=(d,p=0)=>f(f({},t),{},{syntheticException:d==0?t.syntheticException:void 0,mechanism:d==0?e:{},apply(v){const _=u(v,d,p+1);if(!_)throw l;return _},next:v=>u(v,d+1)}),h=c(s);return f(f({},h),{},{apply:d=>{var p;return(p=u(d,s))!==null&&p!==void 0?p:this.coerceFallback(h)}})}};const Gu=/^([a-z][a-z0-9.+-]+):/i,Ju=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function Ku(e){if(!e||e==="<anonymous>")return!1;const t=Gu.exec(e);return!t||Ju.includes(t[1].toLowerCase())}function ir(e,t,s,i,r){const n={platform:e,filename:t,function:s==="<anonymous>"?"?":s,in_app:Ku(t)};return x(i)||(n.lineno=i),x(r)||(n.colno=r),n}const Ea=(e,t)=>{const s=e.indexOf("safari-extension")!==-1,i=e.indexOf("safari-web-extension")!==-1;return s||i?[e.indexOf("@")!==-1?e.split("@")[0]:"?",s?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Qu=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Yu=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Xu=/\((\S*)(?::(\d+))(?::(\d+))\)/,Zu=(e,t)=>{const s=Qu.exec(e);if(s){const[,r,n,o]=s;return ir(t,r,"?",+n,+o)}const i=Yu.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){const o=Xu.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}const[r,n]=Ea(i[1]||"?",i[2]);return ir(t,n,r,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},ec=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,tc=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,sc=(e,t)=>{const s=ec.exec(e);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){const n=tc.exec(s[3]);n&&(s[1]=s[1]||"eval",s[3]=n[1],s[4]=n[2],s[5]="")}let i=s[3],r=s[1]||"?";return[r,i]=Ea(r,i),ir(t,i,r,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},mn=/\(error: (.*)\)/;function Ar(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function ic(e){for(let t=1;10>=t;t++){const s=e.length-2*t;if(0>s)break;let i=!0;for(let r=0;t>r;r++)if(!Ar(e[s+r],e[s+t+r])){i=!1;break}if(i){for(let r=0;t>r;r++)e[s+r]=e[s+t+r];return e.length=s+t,{start:s,length:t}}}}function rc(e,t){const s=t.start+t.length,i=Pa(e,t);i&&e.splice(s+i===e.length?s:t.start,i)}function Sa(e,t){let s=t.start;for(;s>0&&Ar(e[s-1],e[s-1+t.length]);)s--;return t.start-s}function Pa(e,t){const s=t.start+t.length;let i=s;for(;e.length>i&&Ar(e[i],e[i-t.length]);)i++;return i-s}function nc(e,t){const s=t[0];let i=e.length-(s?Sa(e,s):0);for(const r of t)i-=Pa(e,r);return i}function oc(e,t,s){for(let i=0;e.length>i;i++){const r=e[(t+i)%e.length],n=e[(s+i)%e.length];if(r!==n)return n>r}return!1}var ac=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const s=D(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?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 Ns(e,"DOMException")}isDOMError(e){return Ns(e,"DOMError")}},lc=class{match(e){return Vt(e)}coerce(e,t){var s;const i=this.getStack(e),r=i===void 0?(s=t.syntheticException)===null||s===void 0?void 0:s.stack:void 0,n=!!r;return{type:this.getType(e),value:this.getMessage(e,t),stack:i??r,cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){try{const t=e.stacktrace;if(typeof t=="string"&&t.length>0)return t;const s=e.stack;return typeof s=="string"&&s.length>0?s:void 0}catch{return}}},uc=class{match(e){return!!Ns(e,"ErrorEvent")&&(e.error!=null||this.ar(e))}coerce(e,t){var s;if(e.error!=null)return t.apply(e.error);const i=t.apply(e.message);return f(f({},i),{},{stack:(s=this.lr(e))!==null&&s!==void 0?s:i.stack,synthetic:!0})}ar(e){return D(e.message)&&e.message.length>0}lr(e){var t,s;const i=e,r=(t=i.lineno)!==null&&t!==void 0?t:0,n=(s=i.colno)!==null&&s!==void 0?s:0;if(D(i.filename)&&i.filename.length!==0&&r!==0)return`Error
2
- at ${i.filename}:${r}:${n}`}};const cc=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var dc=class{match(e){return typeof e=="string"}coerce(e,t){var s;const[i,r]=this.getInfos(e);return{type:i??"Error",value:r??e,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}getInfos(e){let t="Error",s=e;const i=e.match(cc);return i&&(t=i[1],s=i[2]),[t,s]}};const hc=["fatal","error","warning","log","info","debug"];function Ma(e,t=40){const s=Object.keys(e);if(s.sort(),!s.length)return"[object has no keys]";for(let i=s.length;i>0;i--){const r=s.slice(0,i).join(", ");if(t>=r.length)return i===s.length?r:r.length>t?`${r.slice(0,t)}...`:r}return""}var pc=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,i;const r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=this.getStack(e))!==null&&s!==void 0?s:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Fr(e))return e.constructor.name;const t="name"in e?e.name:void 0;return D(t)&&!rs(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let s=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(s+=` with message: '${e.message}'`),s}if("message"in e&&typeof e.message=="string")return e.message;const t=this.getObjectClassName(e);return`${t&&t!=="Object"?`'${t}'`:"Object"} captured as exception with keys: ${Ma(e)}`}isSeverityLevel(e){return D(e)&&!rs(e)&&hc.indexOf(e)>=0}getStack(e){try{return D(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:D(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const s=e[t];if(Vt(s))return s}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},fc=class{match(e){return Fr(e)}coerce(e,t){var s;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${Ma(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},vc=class{match(e){return Vo(e)}coerce(e,t){var s;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},gc=class{match(e){return Ns(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Fr(e))return!1;try{const t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var s;const i=this.getUnhandledRejectionReason(e);return Vo(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}:t.apply(i)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}};const Bs="$message",zs="$timestamp",_c=new Set([Bs,zs]),vi={enabled:!0,max_bytes:32768};function Vs(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:vi.enabled,max_bytes:yc(e.max_bytes,vi.max_bytes)}:f({},vi)}var mc=class{constructor(e){this.ns=[],this.ss=0,this.Mr=Vs(e)}setConfig(e){this.Mr=Vs(e),this.rs()}add(e){const t=(function(i){let r;try{r=Bo(i)}catch{return}try{const n=JSON.parse(r);if(!L(n))return;const o=n,a=o[Bs],l=o[zs];return!D(a)||a.trim().length===0||!D(l)&&!ne(l)?void 0:{step:o,json:r}}catch{return}})(e);if(!t)return;const s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;const r=encodeURIComponent(i);let n=0;for(let o=0;r.length>o;o++)r[o]==="%"?(n+=1,o+=2):n+=1;return n})(t.json);s>this.Mr.max_bytes||(this.ns.push({step:t.step,bytes:s}),this.ss+=s,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function yc(e,t){if(!ne(e)||e===1/0||e===-1/0)return t;const s=Math.floor(e);return 0>s?t:s}const yn=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function bn(e){return typeof e=="string"||e}function wn(e){return typeof e=="string"?e:void 0}const bc=["$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","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Ia="NativeGzipValidationError",rr=e=>e.length>=2&&e[0]===31&&e[1]===139,xn=(e,t)=>e===Yi.GZipJS||t===Yi.GZipJS||t==="gzip",kn=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let Gt;const Es=e=>{throw xa(Ia,`Native gzip produced invalid output: ${e}`)},wc=($n=X(function*(e,t){18>e.size&&Es("too-short");const s=new Uint8Array(yield e.slice(0,10).arrayBuffer());rr(s)&&s[2]===8||Es("invalid-header");const i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(n=>{const o=(()=>{if(Gt)return Gt;Gt=[];for(let l=0;256>l;l++){let u=l;for(let c=0;8>c;c++)u=1&u?3988292384^u>>>1:u>>>1;Gt[l]=u>>>0}return Gt})();let a=4294967295;for(let l=0;n.length>l;l++)a=o[255&(a^n[l])]^a>>>8;return(4294967295^a)>>>0})(t)&&Es("invalid-crc");const r=t.length>>>0;i.getUint32(4,!0)!==r&&Es("invalid-size")}),function(e,t){return $n.apply(this,arguments)});var $n;function nr(){return nr=X(function*(e,t=!0,s){try{const r=new TextEncoder().encode(e),n=new globalThis.CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(r).then(()=>o.close()).catch((i=X(function*(c){try{yield o.abort(c)}catch{}throw c}),function(c){return i.apply(this,arguments)})),l=new Response(n.readable).blob(),[u]=yield Promise.all([l,a]);return yield wc(u,r),u}catch(r){if(s?.rethrow)throw r;return t&&console.error("Failed to gzip compress data",r),null}var i}),nr.apply(this,arguments)}function Oa(e,t){if(e==null)return{};var s,i,r=(function(o,a){if(o==null)return{};var l={};for(var u in o)if({}.hasOwnProperty.call(o,u)){if(a.includes(u))continue;l[u]=o[u]}return l})(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;n.length>i;i++)t.includes(s=n[i])||{}.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}const fe="[redacted]",xc=/^[A-Za-z0-9+/\n\r]+=*$/,kc=/^[A-Za-z0-9_-]+={0,2}$/,$c=/[-_]/,Ec=/^data:[^,\s]*;base64,/i,Sc=/^[A-Za-z0-9+/_-]+={0,2}$/,Pc=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Mc=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Fa=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Ic=/[\s<>"]/,Ca=new RegExp(Fa.source,"i"),Aa=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Oc=new RegExp(`^${Aa.source}`,"i"),Fc=new RegExp(Aa.source,"gi"),Cc=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,Ac=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,Tc=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,Rc=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Lc=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,Dc=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,Nc=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,jc=/\b\d(?:[ ./-]?\d){12,}\b/g,En=/\d+/g,qc=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Hc=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function or(e){return(function(t){return Mc.test(t)})(e)||Cc.test(e)||Ac.test(e)}function gi(e){return e.split("&",129).length>128}function Bc(e,t,s){return or(e)||t.includes(";")&&(function(i){return i.split(";").some(r=>or(r.split("=",1)[0]))})(t)?fe:Ca.test(t)?s?Tr(t,{allowNestedUrls:!1,stripPunctuation:!0}):fe:t}function Ta(e,t){const s=new URLSearchParams;let i=!1,r=!1;for(const[n,o]of new URLSearchParams(e)){const a=Ws(n),l=Ws(o);i||(i=a!==n||l!==o);const u=Bc(a,l,t);i||(i=u!==l),r=or(a)||u!==l,s.append(a,u)}return{changed:i,lastFieldSensitive:r,serialized:s.toString()}}function Sn(e,t){if(!e.includes("="))return{value:zc(e,t),lastFieldSensitive:!1};const s=Ta(e,t);return{value:s.changed?s.serialized:e,lastFieldSensitive:s.lastFieldSensitive}}function zc(e,t){return t?Tr(e,{allowNestedUrls:!1,stripPunctuation:!0}):Ca.test(e)?fe:e}function Vc(e,t,s){return e==="#"?!t.fragment&&(t.fragment=!0):e==="?"&&(t.fragment?s!=="="&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function _i(e,t){var s;if(e.length>8192&&Oc.test(e))return fe;const{address:i,suffix:r}=t.stripPunctuation?(function(g){let y=g.length;for(;y>0&&".,;:!?)]}'".includes(g[y-1]);)y--;return{address:g.slice(0,y),suffix:g.slice(y)}})(e):{address:e,suffix:""};let n;try{n=new URL(i)}catch{return fe+r}const o=n.search.slice(1),a=n.hash!=="",l=(function(g){const y=g.slice(1),m=y.indexOf("?");return 0>m?{head:y,tail:null}:{head:y.slice(0,m),tail:y.slice(m+1)}})(n.hash);if(gi(o)||gi(l.head)||gi((s=l.tail)!==null&&s!==void 0?s:""))return fe+r;let u=!1;(n.username||n.password)&&(n.username=fe,n.password="",u=!0);const c=Ta(o,t.allowNestedUrls);c.changed&&(n.search=c.serialized,u=!0);const h=Sn(l.head,t.allowNestedUrls),d=l.tail===null?null:(p=l.tail,h.lastFieldSensitive?{value:p===""?"":fe,lastFieldSensitive:!0}:Sn(p,t.allowNestedUrls));var p;const v=d===null?h.value:`${h.value}?${d.value}`;v!==n.hash.slice(1)&&(n.hash=v,u=!0);const _=a?d??h:c;return(u?Ws(n.toString()):i)+(_.lastFieldSensitive?"":r)}function Tr(e,t){return e.replace(Fa,s=>(function(i,r){const n=(function(l){if(!l.includes("://"))return[];const u=[...l.matchAll(Fc)].map(_=>_.index),c=[],h={query:!1,fragment:!1,fragmentQuery:!1};let d=0,p=!1,v="";for(let _=0;l.length>_&&u.length>d;_++){u[d]===_&&(_>0&&v!=="="&&c.push(_),d++);const g=l[_];Vc(g,h,v)?(v=g,p=!0):p&&"=&".includes(g)&&(v=g)}return c})(i);if(n.length===0)return _i(i,r);let o="",a=0;for(const l of n)o+=_i(i.slice(a,l),f(f({},r),{},{stripPunctuation:!1})),a=l;return o+_i(i.slice(a),r)})(s,f(f({},t),{},{stripPunctuation:t.stripPunctuation&&s.length!==e.length})))}function Ws(e){return e.replace(Pc,fe)}function Ra(e,t){return(function(s){return s.length>=10240&&(xc.test(s)||(function(i){const r=Ec.exec(i);if(!r)return!1;let n;try{n=decodeURIComponent(i.slice(r[0].length))}catch{return!1}return Sc.test(n.replace(/[\r\n]/g,""))})(s)||$c.test(s)&&kc.test(s))})(e)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(s,i,r){const n=4*r.maxStringLength;if(s.length>n){const o=i(s.slice(0,(function(a,l){let u=l;for(;u>0&&!Ic.test(a[u-1]);)u--;return u})(s,n)));if(o.length>=2*r.maxStringLength)return o+r.truncationSuffix}return i(s)})(e,s=>(function(i){return Tr(i,{allowNestedUrls:!0,stripPunctuation:!0})})((function(i){let r=i.replace(Tc," ");return r=r.replace(Rc,fe),r=r.replace(Lc,fe),r=r.replace(Dc,`$1${fe}`),r=r.replace(jc,Uc),r=r.replace(Nc,fe),r=r.replace(qc,`$1${fe}`),r=r.replace(Hc,`$1${fe}`),r})(Ws(s))),t)}function Wc(e){let t=0,s=!1;for(let i=e.length-1;i>=0;i--){let r=e.charCodeAt(i)-48;if(0>r||r>9)return!1;s&&(r*=2,r>9&&(r-=9)),t+=r,s=!s}return t%10==0}function Uc(e){const t=[];for(let n=En.exec(e);n!==null;n=En.exec(e))t.push({digits:n[0],start:n.index,end:n.index+n[0].length});let s="",i=0,r=0;for(;t.length>r;){let n="",o=-1;for(let a=r;t.length>a&&(n+=t[a].digits,19>=n.length);a++)n.length>=13&&Wc(n)&&(o=a);0>o?r++:(s+=e.slice(i,t[r].start)+fe,i=t[o].end,r=o+1)}return s+e.slice(i)}const Gc={}.propertyIsEnumerable;function Us(e,t){try{return La(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Rr(e,t,s,i){if(0>=s.remainingNodes)return{stringValue:sr};if(s.remainingNodes--,we(e))return{boolValue:e};if(typeof e=="bigint")return(function(r,n){const o=r.toString(),a=BigInt("9223372036854775808");return r>=a||-a>r?(n?.debug(`Attribute ${o} is outside the int64 range; encoding it as a string`),{stringValue:o}):{intValue:o}})(e,t);if(typeof e=="number"){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 r=BigInt(e).toString();return e>=9223372036854776e3||-9223372036854776e3>e?(t?.debug(`Attribute ${r} is outside the int64 range; encoding it as a string`),{stringValue:r}):{intValue:r}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:At(e)};if(typeof e=="function")return{stringValue:"[Function]"};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(s.ancestors.has(e))return{stringValue:"[Circular]"};if(i>=20)return{stringValue:sr};if(e instanceof Date){const r=e.getTime(),n=Number.isFinite(r)?e.toISOString():String(e);return{stringValue:typeof n=="string"?At(n):String(n)}}s.ancestors.add(e);try{try{const r=e.toJSON;if(typeof r=="function")return Rr(r.call(e),t,s,i+1)}catch{}return F(e)?{arrayValue:{values:Jc(e,t,s,i+1)}}:{kvlistValue:{values:La(e,t,s,i+1)}}}finally{s.ancestors.delete(e)}}return{stringValue:At(String(e))}}function Jc(e,t,s,i){const r=[],n=Math.min(e.length,1e3);let o=0;for(;n>o&&s.remainingNodes>0;o++)try{const a=o in e?e[o]:void 0;if(R(a))continue;r.push(Rr(a,t,s,i))}catch{r.push({stringValue:xs})}return e.length>o&&r.push({stringValue:sr}),r}function La(e,t,s,i){const r=[];for(const n in e)if(Gc.call(e,n)){if(!n){t?.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=s.remainingNodes){t?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[n];if(se(o)||x(o))continue;r.push({key:At(n),value:Rr(o,t,s,i)})}catch{r.push({key:At(n),value:{stringValue:xs}})}}return r}function Da(e,t,s){return f(f(f(f({},ba({},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":s})}const Kc=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Na(e,t){const s=ba({},e),i={};for(const r of Kc)({}).hasOwnProperty.call(s,r)&&(i[r]=s[r],delete s[r]);return[...Us(s,t),...Us(i,t)]}const Pn={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"},ja={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}},Qc=ja.info;function Yc(e){try{return At(String(e))}catch{return xs}}function Xc(e,t,s,i){const r=e.level||"info",{text:n,number:o}=ja[r]||Qc,a=(function(d=Date.now()){return String(d)+"000000"})(ne(i)?i:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),R(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),R(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 u=f({},l),c=e.attributes;if(c){let d=[];try{d=Object.keys(c)}catch{d=[]}for(const p of d){let v;try{v=c[p]}catch{v=xs}Object.defineProperty(u,p,{value:v,enumerable:!0,writable:!0,configurable:!0})}}const h={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:n,body:{stringValue:Yc(e.body)},attributes:Us(u,s)};return e.trace_id&&(h.traceId=e.trace_id),e.span_id&&(h.spanId=e.span_id),x(e.trace_flags)||(h.flags=e.trace_flags),h}function qa(e,t,s){return Da(e,t,s)}function Ha(e,t,s,i){return{resourceLogs:[{resource:{attributes:Na(t)},scopeLogs:[{scope:{name:s,version:i},logRecords:e}]}]}}var Ba=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.cs}arm(e){this.clear(),this.us=Date.now()+e,this.cs=ka(()=>{this.cs=void 0,this.ls()},e)}armNoEarlierThan(e){this.cs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function za(){return .75+.5*Math.random()}function Va(e,t,s,i){const r=Math.min(Math.max(0,t-1),6),n=e*Math.pow(2,r);return Math.round(Math.min(n,Math.max(i,e))*s)}var Zc=class{constructor(e,t,s,i,r,n=()=>Promise.resolve(),o){var a;this._instance=e,this.Mr=t,this.A=s,this.hs=i,this.ds=r,this.vs=n,this.fs=o,this.ps=new Ba(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new wa,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=t.maxBufferSize,this.Is=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(je.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){var s;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Os(e);if(i===null)return;if(!i.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const r={record:Xc(i,(s=t?.context)!==null&&s!==void 0?s:this.hs(),this.A,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const s=F(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;i=n}catch(n){return this.A.error("Error in beforeSend function for log:",n),null}return i}Ds(){if(this.Rs===void 0)return!0;const e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var e=this;return X(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return X(function*(){var t;e.ps.clear();let s=(t=e._instance.getPersistedProperty(je.LogsQueue))!==null&&t!==void 0?t:[];if(s.length===0)return;const i=s.length;let r=0;for(;s.length>0&&i>r;){var n,o;const a=e._s;e.bs=0;const l=Math.min(s.length,e.Es),u=s.slice(0,l),c=Ha(u.map(d=>d.record),e.qs(),(n=e.fs)!==null&&n!==void 0?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),h=yield e._instance.js(c);if(e._s!==a)return;if(h.kind==="too-large"&&u.length>1)e.Es=Math.max(1,Math.floor(u.length/2)),e.A.warn(`Logs batch of size ${u.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(h),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),h.kind==="retry-later"||(h.kind==="too-large"?e.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):h.kind==="ok"&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(u.length),s=(o=e._instance.getPersistedProperty(je.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,h.kind==="fatal"))throw h.error}})()}Bs(e){var t=this;return X(function*(){var s;const i=Math.max(0,e-t.bs),r=(s=t._instance.getPersistedProperty(je.LogsQueue))!==null&&s!==void 0?s:[];t._instance.setPersistedProperty(je.LogsQueue,r.slice(i)),yield t.vs()})()}qs(){return qa(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const s=(t=this._instance.getPersistedProperty(je.LogsQueue))!==null&&t!==void 0?t:[];this.Is>s.length||(s.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),s.push(e),this._instance.setPersistedProperty(je.LogsQueue,s),this.Ts>s.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Va(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(je.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return X(function*(){t.ps.clear();const s=t.flush().catch(()=>{});e!==void 0?yield pn(s,e):yield s})()}flushWithTimeout(e){var t=this;return X(function*(){const s=t.flush();yield pn(s,e,()=>{s.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=za(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}};const ed=/^[0-9a-f]+$/;function Mn(e,t,s){return typeof e=="string"&&e.length===t&&e!==s&&ed.test(e)}const td=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/,sd="00",mi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ar(e){return String(e)+"000000"}function In(e,t,s,i){let r="";return i&&(r=Object.keys(i).sort().map(n=>`${JSON.stringify(n)}:${JSON.stringify(i[n])}`).join(",")),`${e}\0${t}\0${s??""}\0${r}`}var id=class{constructor(e,t,s){this._instance=e,this.Mr=t,this.A=s,this.Hs=new Map,this.ps=new Ba(()=>this.flush().catch(i=>{this.A.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new wa,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,s){this.Qs({name:e,type:"count",value:t,unit:s?.unit,attributes:s?.attributes})}gauge(e,t,s){this.Qs({name:e,type:"gauge",value:t,unit:s?.unit,attributes:s?.attributes})}histogram(e,t,s){this.Qs({name:e,type:"histogram",value:t,unit:s?.unit,attributes:s?.attributes})}flush(){var e=this;const t=this.ys,s=(function(){var i=X(function*(){t&&(yield t.catch(()=>{})),yield e.Zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===s&&(this.ys=null)});return this.ys=s,s}drainWindow(){if(this.Hs.size===0)return null;const e=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.A.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.A.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=t.attributes?f({},t.attributes):void 0,i=In(t.type,t.name,t.unit,s)}catch(a){return void this.A.warn(`Dropping metric '${t.name}': attributes could not be serialized`,a)}let r=this.Hs.get(i);if(!r){if(!this.Ks())return;r={name:t.name,type:t.type,unit:t.unit,attributes:s,windowStartMs:Date.now()},this.Hs.set(i,r)}const n=this.Ws.get(t.name);n===void 0?this.Ws.set(t.name,t.type):n===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.A.warn(`Metric name '${t.name}' is already used as a ${n}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(r,t.value);const o=this.Ys();o&&(r.exemplar=f(f({},o),{},{value:t.value,timeMs:Date.now()})),this.Fs()}Ys(){try{var e,t;const s=(function(i){const r=(function(o){if(typeof o!="string")return;const a=td.exec(o.trim());if(!a)return;const[,l,u,c,h,d]=a;return l==="ff"||l==="00"&&d||!(function(p){return Mn(p,32,"00000000000000000000000000000000")})(u)||!(function(p){return Mn(p,16,"0000000000000000")})(c)?void 0:{version:l,traceId:u,spanId:c,flags:h}})(i);return r&&{traceId:r.traceId,spanId:r.spanId,flags:(n=r.flags,1&parseInt(n,16)?"01":sd)};var n})((e=(t=this._instance).getActiveSpan)===null||e===void 0||(e=e.call(t))===null||e===void 0?void 0:e.traceparent());if(s&&s.flags==="01")return{traceId:s.traceId,spanId:s.spanId}}catch{}}Ks(){return this.Mr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case"count":var s;e.total=((s=e.total)!==null&&s!==void 0?s: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(mi.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(r,n){for(let o=0;n.length>o;o++)if(n[o]>=r)return o;return n.length})(t,mi)]+=1;break}}}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const s=F(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;i=n}catch(n){return this.A.error("Error in beforeSend function for metric:",n),null}return i}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Va(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var e=this;return X(function*(){if(e.ps.clear(),e.Hs.size===0)return;const t=e.Hs;e.Hs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const s=e.Gs,i=yield e._instance.co(e.Js(t));if(s===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=za()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.zs()),i.kind){case"ok":return;case"retry-later":return e.ho(t),void e.ps.armNoEarlierThan(e.zs());case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",i.error)}})()}Js(e){return t=this.do(e),s=(function(n,o,a){return Da(n,o,a)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Na(s)},scopeMetrics:[{scope:{name:i,version:r},metrics:t}]}]};var t,s,i,r}do(e){const t=ar(Date.now()),s=new Map;for(const o of e.values()){var i;const a=In(o.type,o.name,o.unit,void 0);let l=s.get(a);l||(l=f({name:o.name},o.unit&&{unit:o.unit}),o.type==="count"?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:o.type==="gauge"?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},s.set(a,l));const u=Us((i=o.attributes)!==null&&i!==void 0?i:{},this.A),c=ar(o.windowStartMs),h=rd(o.exemplar);if(o.type==="count"){var r;const d=f({attributes:u,startTimeUnixNano:c,timeUnixNano:t,asDouble:(r=o.total)!==null&&r!==void 0?r:0},h);l.sum.dataPoints.push(d)}else if(o.type==="gauge"){var n;const d=f({attributes:u,timeUnixNano:t,asDouble:(n=o.last)!==null&&n!==void 0?n:0},h);l.gauge.dataPoints.push(d)}else if(o.hist){const d=f({attributes:u,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:mi},h);l.histogram.dataPoints.push(d)}}return Array.from(s.values())}ho(e){for(const[r,n]of e){var t;const o=this.Hs.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.exemplar=(t=o.exemplar)!==null&&t!==void 0?t:n.exemplar,o.type){case"count":var s,i;o.total=((s=o.total)!==null&&s!==void 0?s:0)+((i=n.total)!==null&&i!==void 0?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(let a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ks()&&this.Hs.set(r,n)}}};function rd(e){return e?{exemplars:[{filteredAttributes:[],timeUnixNano:ar(e.timeMs),asDouble:e.value,traceId:e.traceId,spanId:e.spanId}]}:{}}const Wa=(e,{debugEnabled:t}={})=>{const s={N(i,...r){let n;try{n=typeof window>"u"?void 0:window}catch{return}n&&(Ge.DEBUG||n.POSTHOG_DEBUG||t)&&!x(n.console)&&n.console&&("__rrweb_original__"in n.console[i]?n.console[i].__rrweb_original__:n.console[i])(e,...r)},debug(...i){s.N("debug",...i)},info(...i){s.N("log",...i)},warn(...i){s.N("warn",...i)},error(...i){s.N("error",...i)},critical(...i){console.error(e,...i)},uninitializedWarning(i){s.error(`You must initialize PostHog before calling ${i}`)},createLogger:(i,r)=>Wa(`${e} ${i}`,r)};return s},S=Wa("[PostHog.js]"),ee=S.createLogger,nd=ee("[ExternalScriptsLoader]"),Gs=e=>{const t=$?.querySelectorAll("script");if(t){for(let s=0;t.length>s;s++)if(t[s].src===e||t[s].getAttribute("src")===e)return t[s]}},ht=(e,t,s)=>{if(e.config.disable_external_dependency_loading)return nd.warn(`${t} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");const i=Gs(t);if(i){if(i.__posthog_loading_callback_fired)return s();const n=i.__posthog_loading_error;return n?s(n):(i.addEventListener("load",o=>{i.__posthog_loading_callback_fired=!0,s(void 0,o)}),void i.addEventListener("error",o=>{i.__posthog_loading_error=o,s(o)}))}const r=()=>{if(!$)return s("document not found");if(Gs(t))return ht(e,t,s);let n=$.createElement("script");if(n.type="text/javascript",n.crossOrigin="anonymous",n.src=t,n.onload=a=>{n.__posthog_loading_callback_fired=!0,s(void 0,a)},n.onerror=a=>{n.__posthog_loading_error=a,s(a)},e.config.prepare_external_dependency_script&&(n=e.config.prepare_external_dependency_script(n)),!n)return s("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")$.head.appendChild(n);else{const a=$.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(n,a[0]):$.body.appendChild(n)}};$?.body?r():$?.addEventListener("DOMContentLoaded",r)},yi={},On=(e,t)=>{let s=`/static/${t}.js?v=${e.version}`;return t==="toolbar"&&(s=`${s}&t=${Math.floor(Date.now()/3e5)*3e5}`),e.requestRouter.endpointFor("assets",s)};T.__PosthogExtensions__=T.__PosthogExtensions__||{},T.__PosthogExtensions__.loadExternalDependency=(e,t,s)=>{if(t==="remote-config"){const r=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void ht(e,r,s)}const i=e.config.strict_script_versioning;if(i){const r=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),n=yi[r];if(i==="fallback"&&n){if(Gs(n))return void ht(e,n,s);delete yi[r]}return void ht(e,r,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;const u=On(e,t);yi[r]=u;const c=Gs(r);c==null||(l=c.parentNode)===null||l===void 0||l.removeChild(c),ht(e,u,s)}else s(void 0,a)}:s)}ht(e,On(e,t),s)},T.__PosthogExtensions__.loadSiteApp=(e,t,s)=>{const i=e.requestRouter.endpointFor("api",t);ht(e,i,s)},Ge.DEBUG=!1,Ge.LIB_VERSION="1.438.12",Ge.LIB_NAME="web";var ke=Ge;const lr="$early_access_features",We="$active_feature_flags",vt="$feature_flag_details",_s="$feature_flag_errors",nt="$feature_flag_evaluated_at",gt="$feature_flag_request_id",os="$minimal_flag_called_events",Ae="$enabled_feature_flags",tt="$stored_group_properties",st="$stored_person_properties",it="$flag_call_reported",ts="$flag_call_reported_session_id",rt="$feature_flag_payloads",Ne="$override_feature_flags",pt="$override_feature_flag_payloads",ms="visibilitychange",od="$people_distinct_id",Ce="distinct_id",Lr="$device_id",bi="$device_model",Js="__alias",ad="__cmpns",Fn="$fbc",Tt="$fbc_persistence",Cn="$fbp",as="$fbp_persistence",ur="__timers",Ua="$autocapture_disabled_server_side",cr="$heatmaps_enabled_server_side",dr="$exception_capture_enabled_server_side",Ga="$error_tracking_suppression_rules",hr="$error_tracking_capture_extension_exceptions",pr="$web_vitals_enabled_server_side",Dr="$dead_clicks_enabled_server_side",Nr="$product_tours_enabled_server_side",Ja="$logs_capture_enabled_server_side",Ka="$web_vitals_allowed_metrics",ls="$session_recording_remote_config",ld="$session_recording_enabled_server_side",ud="$replay_sample_rate",cd="$replay_override_sampling",dd="$replay_override_linked_flag",hd="$replay_override_url_trigger",pd="$replay_override_event_trigger",It="$sesid",Qa="$session_is_sampled",fd="$session_past_minimum_duration",vd="$session_recording_url_trigger_activated_session",gd="$session_recording_event_trigger_activated_session",_d="$debug_first_full_snapshot_timestamp",md="$sess_rec_flush_size",Ya="$groups",ss="$surveys",Ks="$surveys_loaded_at",Xa="$surveys_activated",Za="$surveys_activated_session",el="$surveys_activated_timestamps",fr="ph_product_tours",yd="$product_tours_activated",bd="$product_tours_activated_session",wd="$conversations_widget_session_id",xd="$conversations_ticket_id",kd="$conversations_widget_state",$d="$conversations_user_traits",be="$user_state",vr="$client_session_props",Ed="$capture_rate_limit",tl="$initial_campaign_params",sl="$initial_referrer_info",Ot="$initial_person_info",jr="$epp",wi="$posthog_cookieless",il="$cookieless_mode",rl="$sdk_debug_extensions_init_method",nl="$sdk_debug_extensions_init_time_ms",qr="$sdk_debug_recording_script_not_loaded",Hr="$sdk_debug_replay_stale_config",ol="$sdk_debug_replay_event_trigger_status",al="$sdk_debug_replay_linked_flag_trigger_status",ll="$sdk_debug_replay_matched_recording_trigger_groups",ul="$sdk_debug_replay_pending_trigger_conditions",cl="$sdk_debug_replay_remote_trigger_matching_config",dl="$sdk_debug_replay_trigger_groups_count",hl="$sdk_debug_replay_url_trigger_status",Sd="$session_recording_start_reason",Br="PostHog loadExternalDependency extension not found.",Ue="anonymous",Rs="identified",pl="identified_only",Qs="beforeunload",zr="$pageview",An="$pageleave",fl="$identify",Tn="$groupidentify";function Ft(e,t){F(e)&&e.forEach(t)}function J(e,t){if(!R(e))if(F(e))e.forEach(t);else if((s=>s instanceof FormData)(e))e.forEach((s,i)=>t(s,i));else for(const s in e)Or.call(e,s)&&t(e[s],s)}const Z=function(e,...t){for(const s of t)for(const i in s)s[i]!==void 0&&(e[i]=s[i]);return e};function Ls(e){const t=Object.keys(e);let s=t.length;const i=new Array(s);for(;s--;)i[s]=[t[s],e[t[s]]];return i}const Pd=function(e){return function(...t){try{return e.apply(this,t)}catch(s){S.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),S.critical(s)}}},Vr=function(e){const t={};return J(e,function(s,i){(D(s)&&s.length>0||ne(s))&&(t[i]=s)}),t};function vl(e){const t=f({},e);for(const s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch{}return t}const Md=["herokuapp.com","vercel.app","netlify.app"];function Id(e){const t=e?.hostname;if(!D(t))return!1;const s=t.split(".").slice(-2).join(".");for(const i of Md)if(s===i)return!1;return!0}function W(e,t,s,i){const{capture:r=!1,passive:n=!0}=i??{};e?.addEventListener(t,s,{capture:r,passive:n})}function gr(e){return e.name==="ph_toolbar_internal"}const us=e=>{if($){try{const t=e+"=",s=$.cookie.split(";").filter(i=>i.length);for(let i=0;s.length>i;i++){let r=s[i];for(;r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return ne(e)&&isFinite(e)&&Math.floor(e)===e});var Od=class _r{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,s,i,r){if(!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>s||0>i||0>r||t>0xffffffffffff||s>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");const n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|s>>>8,n[7]=s,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new _r(n)}toString(){let t="";for(let s=0;this.bytes.length>s;s++)t=t+(this.bytes[s]>>>4).toString(16)+(15&this.bytes[s]).toString(16),s!==3&&s!==5&&s!==7&&s!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new _r(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let s=0;16>s;s++){const i=this.bytes[s]-t.bytes[s];if(i!==0)return Math.sign(i)}return 0}},Fd=class{generate(){const e=this.generateOrAbort();if(!x(e))return e;{this.Ct=0;const t=this.generateOrAbort();if(x(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const e=(()=>{const t=Date.now();return ne(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.It();else{if(this.Ct>=e+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Od.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Cd}};let gl=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};b&&!x(b.crypto)&&crypto.getRandomValues&&(gl=e=>crypto.getRandomValues(e));var Cd=class{nextUint32(){return this.Rt.length>this.Et||(gl(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let Rn;const Te=()=>Ad().toString(),Ad=()=>(Rn||(Rn=new Fd)).generate();let Jt="";const Td=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let wt=null;const te={At(){if(!se(wt))return wt;if(wt=!1,$)try{const e=`__ph_cookie_support_${Te()}`;te.$t(e,"xyz"),wt=us(e)==='"xyz"',te.Pt(e)}catch{wt=!1}return wt},Lt(e){S.error("cookieStore error: "+e)},Ot:us,Dt(e){let t;try{t=JSON.parse(te.Ot(e))||{}}catch{}return t},$t(e,t,s,i,r){if(!$)return!1;try{let n="",o="";const a=(function(u,c){if(c){let h=(function(d,p=$){if(Jt)return Jt;if(!p||["localhost","127.0.0.1"].includes(d))return"";const v=d.split(".");let _=Math.min(v.length,8);const g="dmn_chk_"+Te();for(;!Jt&&_--;){const y=v.slice(_).join("."),m=g+"=1;domain=."+y+";path=/";p.cookie=m+";max-age=3",p.cookie.includes(g)&&(p.cookie=m+";max-age=0",Jt=y)}return Jt})(u);if(!h){const d=(p=>{const v=p.match(Td);return v?v[0]:""})(u);d!==h&&S.info("Warning: cookie subdomain discovery mismatch",d,h),h=d}return h?"; domain=."+h:""}return""})($.location.hostname,i);if(s){const u=new Date;u.setTime(u.getTime()+864e5*s),n="; expires="+u.toUTCString()}r&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&S.warn("cookieStore warning: large cookie, len="+l.length),$.cookie=l,!0}catch{return!1}},Pt(e,t){if($?.cookie&&(!t||!se(us(e))))try{te.$t(e,"",-1,t)}catch{return}}};let xi=null;const H={At(){if(!se(xi))return xi;let e=!0;if(x(b))e=!1;else try{const t="__mplssupport__";H.$t(t,"xyz"),H.Ot(t)!=='"xyz"'&&(e=!1),H.Pt(t)}catch{e=!1}return e||S.error("localStorage unsupported; falling back to cookie store"),xi=e,e},Lt(e){S.error("localStorage error: "+e)},Ot(e){try{return b?.localStorage.getItem(e)}catch(t){H.Lt(t)}return null},Dt(e){try{return JSON.parse(H.Ot(e))||{}}catch{}return null},$t(e,t){try{return b?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(s){H.Lt(s)}return!1},Pt(e){try{b?.localStorage.removeItem(e)}catch(t){H.Lt(t)}}},ki=[st,We,Ae,vt,rt,gt,nt,_s,it],ft=[Lr,Ce,It,Qa,jr,Ot,Tt,be],Ys=e=>e+"_cpm",Rd=["__proto__","constructor","prototype"],$i=e=>{if(!L(e))return{};const t={};return Object.keys(e).forEach(s=>{Rd.indexOf(s)===-1&&(t[s]=e[s])}),t},Ei=(e,t=[])=>{const s={};return[...ft,...t].forEach(i=>{const r=e[i];x(r)||se(r)||r===""||(s[i]=r)}),s},_l=e=>{let t=5381,s=2166136261;for(let i=0;e.length>i;i++){const r=e.charCodeAt(i);t=33*t^r,s=Math.imul(s^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(s>>>0).toString(36)},Ln=(e,t)=>({p:t,f:_l(JSON.stringify(e))}),Dn=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const s=te.Dt(Ys(e)),i=s?.f===_l(t)&&F(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},Si=(e,t)=>t+"|"+(te.Ot(Ys(e))||""),xt={},mr={At:()=>!0,Lt(e){S.error("memoryStorage error: "+e)},Ot:e=>e in xt?xt[e]:null,Dt:e=>e in xt?xt[e]:null,$t:(e,t)=>(xt[e]=t,!0),Pt(e){delete xt[e]}};let lt=null;const Y={At(){if(!se(lt))return lt;if(lt=!0,x(b))lt=!1;else try{const e="__support__";Y.$t(e,"xyz"),Y.Ot(e)!=='"xyz"'&&(lt=!1),Y.Pt(e)}catch{lt=!1}return lt},Lt(e){S.error("sessionStorage error: ",e)},Ot(e){try{return b?.sessionStorage.getItem(e)}catch(t){Y.Lt(t)}return null},Dt(e){try{return JSON.parse(Y.Ot(e))||null}catch{}return null},$t(e,t){try{return b?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(s){Y.Lt(s)}return!1},Pt(e){try{b?.sessionStorage.removeItem(e)}catch(t){Y.Lt(t)}}};var Ld=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Lo()?0:this.No}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.qo.$t(this.jo,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.qo.Pt(this.jo,this.Mr.cross_subdomain_cookie)}get jo(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:s}=this._instance.config;return s||(t?t+e:"__ph_opt_in_out_"+e)}get No(){const e=this.qo.Ot(this.jo);return ci(e)?1:A(Cu,e)?0:-1}get qo(){const e=this.Mr.opt_out_capturing_persistence_type,t=e==="localStorage"?H:te,s=t.At()?t:mr;if(!this.Bo||this.Bo!==s){this.Bo=s;const i=e==="localStorage"?te:H;i.Ot(this.jo)&&(this.Bo.Ot(this.jo)||this.optInOut(ci(i.Ot(this.jo))),i.Pt(this.jo,this.Mr.cross_subdomain_cookie))}return this.Bo}Lo(){return!!this.Mr.respect_dnt&&[he?.doNotTrack,he?.msDoNotTrack,T.doNotTrack,he?.globalPrivacyControl].some(e=>ci(e))}};function ml(e,t){var s;const i=e==null||(s=e.config)===null||s===void 0?void 0:s.get_current_url;if(!oe(i))return t;try{const r=i(t);return D(r)&&r?r:t}catch(r){return S.error("Error in get_current_url, falling back to window.location.href",r),t}}function Nn(e){var t;return e instanceof Element&&(e.id==="__POSTHOG_TOOLBAR__"||!!(!((t=e.closest)===null||t===void 0)&&t.call(e,".toolbar-global-fade-container")))}function Re(e){return!!e&&e.nodeType===1}function pe(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function yl(e){return!!e&&e.nodeType===3}function Wr(e){return!!e&&e.nodeType===11&&Re(e.host)}function Ur(e){return e?Lt(e).split(/\s+/):[]}function jn(e,t){const s=(function(i){var r;const n=b==null||(r=b.location)===null||r===void 0?void 0:r.href;return x(n)?void 0:ml(i,n)})(t);return!!(s&&e&&e.some(i=>s.match(i)))}function Nt(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 Ur(t)}function bl(e){return R(e)?null:Lt(e).split(/(\s+)/).filter(t=>Rt(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ys(e){let t="";return _t(e)&&!jt(e)&&e.childNodes&&e.childNodes.length&&J(e.childNodes,function(s){var i;yl(s)&&s.textContent&&(t+=(i=bl(s.textContent))!==null&&i!==void 0?i:"")}),Lt(t)}function cs(e){var t;return x(e.target)?e.srcElement||null:!((t=e.target)===null||t===void 0)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}const Gr=["a","button","form","input","select","textarea","label"];function yr(e,t){const s=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!s&&s.call(e,t)}catch{return!1}}function br(e,t){if(x(t))return!0;for(const s of e)if(t.some(i=>yr(s,i)))return!0;return!1}function wl(e){const t=e.parentNode;return!(!t||!Re(t))&&t}const Pi=[".ph-no-autocapture","[data-ph-no-autocapture]"],xl=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Jr=[...xl,"+","-","−","–"],qn=Jr.length+10,Dd=["button","a","input","select","textarea","label"],Nd=["button","link","tab","menuitem","option"],Hn=(e,t)=>/[a-z0-9]/i.test(t)?A(Jr,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,jd=e=>A(Dd,e.tagName.toLowerCase())||A(Nd,(e.getAttribute("role")||"").toLowerCase());function Mi(e){let t="",s="";const i=o=>{Re(o)&&_t(o)&&!jt(o)&&(t+=` ${ys(o)}`,s=s||o.getAttribute("aria-label")||"",J(o.childNodes,i))};i(e),t=Lt(t.replace(/\s+/g," "));const r=(Rt(t)?t:"").toLowerCase(),n=e.getAttribute("aria-label")||(r?"":s);return{safeText:r,ariaLabel:Lt(n).toLowerCase()}}const Bn=[".ph-no-rageclick",".ph-no-capture"],qd=["","text","search","email","password","url","tel","number"];function kl(e,t){if(!b||Kr(e))return!1;let s,i,r;var n,o;if(we(t)?(s=!!t&&Bn,i=void 0,r=!1):(s=(n=t?.css_selector_ignorelist)!==null&&n!==void 0?n:Bn,i=t?.content_ignorelist,r=(o=t?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||r&&(function(l){return!(!l||!Re(l))&&(!!pe(l,"textarea")||(pe(l,"input")?A(qd,(l.getAttribute("type")||"").toLowerCase()):(function(u){var c;if(u.isContentEditable)return!0;const h=(c=u.getAttribute)===null||c===void 0?void 0:c.call(u,"contenteditable");return h==="true"||h===""})(l)))})(e))return!1;const{targetElementList:a}=$l(e,!1);return!(i&&(function(l,{safeText:u,ariaLabel:c}){let h;if(l===!0)h=xl;else{if(!F(l))return!1;if(l.length>qn)return S.error(`[PostHog] content_ignorelist array cannot exceed ${qn} items. Use css_selector_ignorelist for more complex matching.`),!1;h=l.map(d=>d.toLowerCase())}return h.some(d=>Hn(u,d)||Hn(c,d))})(i,(function(l,u){for(const c of u)if(jd(c))return Mi(c);for(const c of u){try{if(b?.getComputedStyle(c).getPropertyValue("cursor")!=="pointer")break}catch{break}const h=Mi(c);if(h.safeText||h.ariaLabel)return h}return Mi(l)})(e,a))||br(a,s))}const Kr=e=>!e||pe(e,"html")||!Re(e),$l=(e,t)=>{if(!b||Kr(e))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const i=[e];let r=e;for(;r.parentNode&&!pe(r,"body");){if(Wr(r.parentNode)){i.push(r.parentNode.host),r=r.parentNode.host;continue}const n=wl(r);if(!n)break;if(t||Gr.indexOf(n.tagName.toLowerCase())>-1)s=!0;else try{const o=b.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(n),r=n}return{parentIsUsefulElement:s,targetElementList:i}};function _t(e){const t=new Set;let s=0;for(let n=e;n.parentNode&&!pe(n,"body");n=n.parentNode){if(s++>=1e3||t.has(n))return!1;t.add(n);const o=Nt(n);if(A(o,"ph-sensitive")||A(o,"ph-no-capture"))return!1}if(A(Nt(e),"ph-include"))return!0;const i=e.type||"";if(D(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}const r=e.name||e.id||"";return!D(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function jt(e){return!!(pe(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||pe(e,"select")||pe(e,"textarea")||e.getAttribute("contenteditable")==="true")}const zn=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}))$"),Vn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Hd=[16,15,14,13],Bd=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Wn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Un=/[0-9A-Za-z_]/;function zd(e){let t=0,s=!1;for(let i=e.length-1;i>=0;i--){let r=e.charCodeAt(i)-48;s&&(r*=2,r>9&&(r-=9)),t+=r,s=!s}return t%10==0}function Rt(e,t=!0){return!(R(e)||D(e)&&(e=Lt(e),(t?zn.test((e||"").replace(/[- ]/g,"")):(function(s){let i;for(Vn.lastIndex=0;i=Vn.exec(s);){const r=i[2];if(!r)continue;const n=r.replace(/[- ]/g,"");for(let o=0;n.length>o;o++)for(const a of Hd){const l=o+a;if(n.length>=l){const u=n.slice(o,l);if(zn.test(u)&&zd(u))return!0}}}return!1})(e))||(t?Bd.test(e):(function(s){let i;for(Wn.lastIndex=0;i=Wn.exec(s);){const r=i[1],n=i[3];if(!(r&&n&&Un.test(r)&&Un.test(n)))return!0}return!1})(e))))}function Gn(e){let t=ys(e);return t=`${t} ${El(e)}`.trim(),Rt(t)?t:""}function El(e){let t="";return e&&e.childNodes&&e.childNodes.length&&J(e.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{const r=ys(s);t=`${t} ${r}`.trim(),s.childNodes&&s.childNodes.length&&(t=`${t} ${El(s)}`.trim())}catch(r){S.error("[AutoCapture]",r)}}),t}function Jn(e){return e.replace(/"|\\"/g,'\\"')}function Vd(e){const t=e.attr__class;if(t)return F(t)?t:Ur(t)}const Ss=ee("[Dead Clicks]"),Wd=()=>!0,Ud=e=>{var t;const s=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(Dr)),i=e.instance.config.capture_dead_clicks;return we(i)?i:!!L(i)||s};var Kn=class{get lazyLoadedDeadClicksAutocapture(){return this.zo}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Dr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ho(()=>{this.Uo()}):this.stop()}Ho(e){var t,s,i;!((t=T.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(s=T.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",r=>{r?Ss.error("failed to load script",r):e()})}Uo(){var e;if($){if(!this.zo&&(!((e=T.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=L(this.instance.config.capture_dead_clicks)?f({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.zo=T.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.zo.start($),Ss.info("starting...")}}else Ss.error("`document` not found. Cannot start.")}stop(){this.zo&&(this.zo.stop(),this.zo=void 0,Ss.info("stopping..."))}};const Kt=ee("[SegmentIntegration]");function Qn(e,t,s=!0){const i=e.config.segment;if(!i)return t();const{analytics:r,filterProperties:n}=(a=>oe(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,u,c){const h=p=>{const v=()=>p.anonymousId()||Te();a.config.get_device_id=v,c&&p.id()&&(a.register({distinct_id:p.id(),$device_id:v()}),a.persistence.set_property(be,Rs)),u(c?void 0:p.anonymousId()||void 0)},d=l.user();"then"in d&&oe(d.then)?d.then(h):h(d)})(e,r,a=>{r.register(((l,u,{filterProperties:c}={})=>{typeof Promise<"u"&&Promise.resolve||Kt.warn("This browser does not have Promise support, and can not use the segment integration");const h=(d,p)=>{if(!p)return d;const v=!!u&&d.event.anonymousId===u&&!d.event.userId;v||d.event.userId||d.event.anonymousId===l.get_distinct_id()||(Kt.info("No userId set, resetting PostHog"),l.reset()),v||(u=void 0),d.event.userId&&d.event.userId!==l.get_distinct_id()&&(Kt.info("UserId set, identifying with PostHog"),l.identify(d.event.userId));let _=l.calculateEventProperties(p,d.event.properties);if(!R(c)){const g=d.event.properties||{},y={};for(const w of Object.keys(_))Or.call(g,w)||(y[w]=_[w]);const m=((w,E)=>{const k=F(w)?w:[w];let P=f({},E);for(const I of k)try{if(P=I(P),R(P))return null}catch(M){return Kt.error("Error in Segment filterProperties:",M),null}return P})(c,y);if(R(m))return d;_=m}return d.event.properties=Object.assign({},_,d.event.properties),d};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(d){return h(d,d.event.event)},page(d){return h(d,zr)},identify(d){return h(d,fl)},screen(d){return h(d,"$screen")}}})(e,a,{filterProperties:n})).then(()=>{t()},l=>{Kt.error("Failed to register the Segment integration",l),t()})},s)}const Sl="posthog-js";function Pl(e,{organization:t,projectId:s,prefix:i,severityAllowList:r=["error"],sendExceptionsToPostHog:n=!0}={}){return o=>{var a,l,u,c,h;if(r!=="*"&&!r.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const d=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=((a=o.exception)===null||a===void 0?void 0:a.values)||[],v=p.map(y=>f(f({},y),{},{stacktrace:y.stacktrace?f(f({},y.stacktrace),{},{type:"raw",frames:(y.stacktrace.frames||[]).map(m=>f(f({},m),{},{platform:"web:javascript"}))}):void 0})),_={$exception_message:((l=p[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(u=p[0])===null||u===void 0?void 0:u.type,$exception_level:o.level,$exception_list:v,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((c=p[0])===null||c===void 0?void 0:c.value)||o.message,$sentry_exception_type:(h=p[0])===null||h===void 0?void 0:h.type,$sentry_tags:o.tags};var g;return t&&s&&(_.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+o.event_id),n&&((g=e.exceptions)===null||g===void 0||g.sendExceptionEvent(_)),o}}var Gd=class{constructor(e,t,s,i,r,n){this.name=Sl,this.setupOnce=function(o){o(Pl(e,{organization:t,projectId:s,prefix:i,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},Yn=class{constructor(e){this.Wo=(t,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(S.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Vo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Go()}Go(){var e;this.Qo=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Wo)}destroy(){var e;(e=this.Qo)===null||e===void 0||e.call(this),this.Qo=void 0}doPageView(e,t){var s;const i=this.Zo(e,t);return this.Vo={pathname:(s=b?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Zo(e,(t=this.Vo)===null||t===void 0?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Vo)===null||e===void 0?void 0:e.pageViewId}}Zo(e,t){const s=this.Vo;if(!s)return{$pageview_id:t};let i={$pageview_id:t,$prev_pageview_id:s.pageViewId};const r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=r;if(!(x(n)||x(o)||x(a)||x(l)||x(u)||x(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);const h=n>1?qe(o/n,0,1,S):1,d=n>1?qe(a/n,0,1,S):1,p=l>1?qe(u/l,0,1,S):1,v=l>1?qe(c/l,0,1,S):1;i=Z(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:v})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),i}};const Qt=["flags","surveys"],Jd={[od]:{exposure:"hidden"},[Js]:{exposure:"hidden"},[ad]:{exposure:"hidden"},[ur]:{exposure:"hidden"},[Tt]:{exposure:"hidden"},[as]:{exposure:"hidden"},[Ua]:{exposure:"event"},[cr]:{exposure:"hidden"},[Ja]:{exposure:"hidden"},[dr]:{exposure:"event"},[Ga]:{exposure:"hidden"},[hr]:{exposure:"event"},[pr]:{exposure:"event"},[Dr]:{exposure:"event"},[Nr]:{exposure:"hidden"},[Ka]:{exposure:"event"},[ls]:{exposure:"hidden"},[ld]:{exposure:"hidden"},[It]:{exposure:"hidden"},[Qa]:{exposure:"event"},[ud]:{exposure:"event",shouldSkipFromEventProperties:e=>se(e)},[fd]:{exposure:"event"},[vd]:{exposure:"event"},[gd]:{exposure:"event"},[_d]:{exposure:"event"},[md]:{exposure:"hidden"},[Ae]:{exposure:"hidden",storageGroup:"flags"},[We]:{exposure:"hidden",storageGroup:"flags"},[lr]:{exposure:"hidden"},[vt]:{exposure:"hidden",storageGroup:"flags"},[rt]:{exposure:"hidden",storageGroup:"flags"},[gt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[os]:{exposure:"hidden",storageGroup:"flags"},[Ne]:{exposure:"hidden"},[pt]:{exposure:"hidden"},[st]:{exposure:"hidden"},[tt]:{exposure:"hidden"},[ss]:{exposure:"hidden",storageGroup:"surveys"},[Ks]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Xa]:{exposure:"event"},[Za]:{exposure:"hidden"},[el]:{exposure:"hidden"},[fr]:{exposure:"hidden"},[yd]:{exposure:"hidden"},[bd]:{exposure:"hidden"},[wd]:{exposure:"event"},[xd]:{exposure:"event"},[kd]:{exposure:"event"},[$d]:{exposure:"event"},[it]:{exposure:"hidden"},[ts]:{exposure:"hidden"},[Ya]:{exposure:"event"},[_s]:{exposure:"hidden"},[nt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[be]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[Ed]:{exposure:"hidden"},[tl]:{exposure:"hidden"},[sl]:{exposure:"hidden"},[Ot]:{exposure:"hidden"},[jr]:{exposure:"hidden"},[cd]:{exposure:"event"},[dd]:{exposure:"event"},[hd]:{exposure:"event"},[pd]:{exposure:"event"},[rl]:{exposure:"event"},[nl]:{exposure:"event"},[qr]:{exposure:"hidden"},[Hr]:{exposure:"hidden"},[ol]:{exposure:"hidden"},[al]:{exposure:"hidden"},[ll]:{exposure:"hidden"},[ul]:{exposure:"hidden"},[cl]:{exposure:"hidden"},[dl]:{exposure:"hidden"},[hl]:{exposure:"hidden"},[Sd]:{exposure:"event"}},Kd=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],ce=e=>{const t=Jd[e];if(t)return t;for(const[s,i]of Kd)if(e.indexOf(s)===0)return i};function Ml(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}const Il=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},Ol=(e,t)=>e>=t&&Il(),Fl=(e,t,s,i)=>{if(e===0){if(Il()){const r=t+1;return r===s&&i(),r}return t}return 0},Ct=(e,t)=>{try{let s;return JSON.stringify(e,(i,r)=>{var n;return Vt(r)?((n=s)!==null&&n!==void 0||(s=new WeakMap),s.has(r)||s.set(r,vl(r)),s.get(r)):typeof r=="bigint"?r.toString():r},t)}catch{return Bo(e)}},Je=e=>{const t=$?.createElement("a");return x(t)?null:(t.href=e,t)},qt=function(e,t){const s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let i;for(let r=0;s.length>r;r++){const n=s[r].split("=");if(n[0]===t){i=n;break}}if(!F(i)||2>i.length)return"";{let r=i[1];try{r=decodeURIComponent(r)}catch{S.error("Skipping decoding for malformed query param: "+r)}return r.replace(/\+/g," ")}},bs=function(e,t,s){if(!e||!t||!t.length)return e;const i=e.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[];for(let h=0;l.length>h;h++){const d=l[h].split("=");F(d)&&(t.includes(d[0])?u.push(d[0]+"="+s):u.push(l[h]))}let c=a;return o!=null&&(c+="?"+u.join("&")),r!=null&&(c+="#"+r),c},Xs=function(e,t){const s=e.match(new RegExp(t+"=([^&]*)"));return s?s[1]:null},Ht=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Qd=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ht],ws="<masked>",Yd=["li_fat_id"];function Cl(e,t,s){if(!$)return{};const i=t?[...Ht,...s||[]]:[],r=Al(bs($.URL,i,ws),e),n=(function(){const o={};return J(Yd,function(a){const l=us(a);o[a]=l||null}),o})();return Z(n,r)}function Al(e,t){const s=Qd.concat(t||[]),i={};return J(s,function(r){const n=qt(e,r);i[r]=n||null}),i}function Tl(e){const t=(function(r){return r?r.search("https?://(.*)google.([^/?]*)")===0?"google":r.search("https?://(.*)bing.com")===0?"bing":r.search("https?://(.*)yahoo.com")===0?"yahoo":r.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(e),s=t!="yahoo"?"q":"p",i={};if(!se(t)){i.$search_engine=t;const r=$?qt($.referrer,s):"";r.length&&(i.ph_keyword=r)}return i}function Rl(){return navigator.language||navigator.userLanguage}function Xd(){const e=Rl();return typeof e=="string"?e.split("-")[0]:void 0}const Zs="$direct";function Ll(){return $?.referrer||Zs}function Dl(e,t,s=!1){const i=e?[...Ht,...t||[]]:[],r=s?ot(Q?.href):Q?.href,n=r?.substring(0,1e3);return{r:Ll().substring(0,1e3),u:n?bs(n,i,ws):void 0}}function Nl(e,t=!1){var s;const{r:i,u:r}=e,n=t?ot(r):r,o={$referrer:i,$referring_domain:i==null?void 0:i==Zs?Zs:(s=Je(i))===null||s===void 0?void 0:s.host};if(n){o.$current_url=n;const a=Je(n);o.$host=a?.host,o.$pathname=a?.pathname;const l=Al(n);Z(o,l)}if(i){const a=Tl(i);Z(o,a)}return o}function Zd(){try{return new Date().getTimezoneOffset()}catch{return}}const eh={flags:nt,surveys:Ks},th=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ps=e=>`${e}_cookie_identity_change_pending`,Ms=e=>{let t="",s=0;for(const i of e){const r=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+r>1e3)break;t+=i,s+=r}return t},le="main",Ve=[Ae,We,vt,rt,gt,nt,os,st],Ii=e=>Ve.indexOf(e)!==-1,jl=[Tt,as],Xn=e=>jl.indexOf(e)!==-1,Xe=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},kt=e=>{if(!e)return{};const t=JSON.parse(e);return L(t)?t:{}},Zn=(e,t)=>{J(e,(s,i)=>{const r=ce(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(t,i)||delete e[i]})};var Oi=class{constructor(e,t,s=!0,i=!e.cookieless_mode){if(this.Jo={},this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=!1,this.ia=new Map,this.na=!1,this.sa=!1,this.ra=!1,this.oa=new Set,this.aa=new Set,this.Mr=e,this.la=s,this.props={},this.ua=void 0,this.ca=(r=>{let n="";return r.token&&(n=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+n+"_posthog"})(e),this.hi=e.disable_persistence||!!t,this.qo=this.ha(e),this.Yo=this.da(e),this.load(i),this.va(),e.debug&&S.info("Persistence loaded",e.persistence,f({},this.props)),this.update_config(e,e,t),this.save(),b){const r=()=>this.flush();W(b,"beforeunload",r,{capture:!1}),W(b,"pagehide",r,{capture:!1}),this.fa=n=>{if(this.Ko&&(!n.storageArea||n.storageArea===b?.localStorage)&&n.key)if(n.key!==this.ca){if(this.Yo){const o=Qt.find(a=>n.key===this.pa(a));o&&this.ga(n.key,o)}}else this.ga(n.key,le)},W(b,"storage",this.fa)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,s])=>{const i=this.ia.get(t);if(!Ii(t)||i===!0)return;if(s===!0)return void this.ma(t,!0);const r=new Set(i||[]);s.forEach(n=>r.add(n)),r.size&&this.ma(t,r)})}onCrossTabFeatureFlagChange(e){return this.aa.add(e),()=>this.aa.delete(e)}destroy(){this.fa&&b&&(b.removeEventListener("storage",this.fa),this.fa=void 0),this.aa.clear()}ga(e,t,s=!0){if(this.hi)return!1;let i,r;try{if(r=H.Ot(e),se(r)){const a=this.ya(t);return a.storageValue=null,t!==le&&(a.persisted=!1),!1}i=kt(r)}catch{return!1}const n=t===le?i:H.Dt(this.ca);if(n&&this.ba(n))return!1;const o=this._a(i,t,s);return t===le&&this.Yo&&!Xe(this.wa().main,i)||this.ka(i,t,!0,r),o}ba(e){const t=this.props[Ce],s=e[Ce];return!x(t)&&!x(s)&&t!==s}ka(e,t,s,i){const r=this.ya(t);r.storageValue=i,t!==le&&(r.persisted=s);try{r.fingerprint=this.Sa(e,t)}catch{r.fingerprint=void 0}}_a(e,t,s){let i=!1;return Ve.forEach(r=>{var n;const o=(n=ce(r))===null||n===void 0?void 0:n.storageGroup;if(t===le&&this.Yo&&o||t!==le&&o!==t)return;const a=r in e,l=this.xa(r,a?e[r]:void 0),u=this.ia.has(r)?r in this.props:a;u===r in this.props&&Xe(l,this.props[r])||(u?this.$a(r,l,!1):this.Ca(r,!1),i=!0)}),i&&s&&this.aa.forEach(r=>r()),i}Ta(){if(!this.Ko)return!1;try{this.ra=!1;const e=H.Ot(this.ca),t=this.ya(le);let s,i=!1,r=!1;if(e!==t.storageValue)if(se(e))t.storageValue=null;else{if(s=kt(e),this.ra=!this.sa&&this.ba(s),this.ra)return!1;r=this._a(s,le,!1),!this.Yo||Xe(this.wa().main,s)?this.ka(s,le,!0,e):t.storageValue=e,i=!0}return this.Yo&&Qt.forEach(n=>{const o=H.Ot(this.pa(n)),a=this.ya(n),l=s||{},u=i&&Ve.some(h=>{var d;return((d=ce(h))===null||d===void 0?void 0:d.storageGroup)===n&&h in l});if(o===a.storageValue&&!u)return;if(se(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this._a(l,n,!1)||r));const c=kt(o);r=this._a(c,n,!1)||r,this.ka(c,n,!0,o)}),r}catch{return!1}}ma(e,t){this.ia.set(e,t);const s=ce(e);s?.volatile||(this.ya((this.Yo?s?.storageGroup:void 0)||le).fingerprint=void 0,this.Ia(e))}Ma(){Ve.forEach(e=>this.ia.set(e,!0))}va(){if(this.Ko)try{const e=H.Ot(this.ca),t=kt(e);this.ya(le).storageValue=e,Ve.forEach(s=>{var i;const r=this.Yo?(i=ce(s))===null||i===void 0?void 0:i.storageGroup:void 0,n=r?H.Ot(this.pa(r)):null;if(r){const a=this.ya(r);a.storageValue=n,a.persisted=!se(n)}const o=r&&!se(n)?kt(n):t;s in this.props?this.Ea(s,o[s],this.props[s]):s in o&&this.ma(s,!0)})}catch{}}xa(e,t){const s=this.ia.get(e);if(!s)return t;if(s===!0)return this.props[e];if(e==="$active_feature_flags"){const n=new Set(F(t)?t:[]),o=new Set(F(this.props[e])?this.props[e]:[]);return s.forEach(a=>o.has(a)?n.add(a):n.delete(a)),Array.from(n)}const i=L(t)?f({},t):{},r=L(this.props[e])?this.props[e]:{};return s.forEach(n=>{n in r?i[n]=r[n]:delete i[n]}),i}Ea(e,t,s){if(!Ii(e))return;const i=this.ia.get(e);if(i===!0)return;let r=t;if(this.Ko)try{var n;const a=this.Yo?(n=ce(e))===null||n===void 0?void 0:n.storageGroup:void 0,l=a?this.pa(a):this.ca;r=kt(H.Ot(l))[e]}catch{}const o=new Set(i||[]);if(e==="$active_feature_flags"){if(!x(t)&&!F(t)||!x(r)&&!F(r)||!F(s))return void this.ma(e,!0);const a=new Set(t||[]),l=new Set(r||[]),u=new Set(s);new Set([...a,...u]).forEach(c=>{a.has(c)!==u.has(c)&&o.add(c)}),o.forEach(c=>{l.has(c)===u.has(c)&&o.delete(c)})}else{if(!L(s))return void(Xe(r,s)?this.ia.delete(e):this.ma(e,!0));{if(!x(t)&&!L(t)||x(t)&&$e(s)&&x(r))return void this.ma(e,!0);const a=L(t)?t:{},l=L(r)?r:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(u=>{u in a==u in s&&Xe(a[u],s[u])||o.add(u)}),o.forEach(u=>{u in l==u in s&&Xe(l[u],s[u])&&o.delete(u)})}}o.size?this.ma(e,o):this.ia.delete(e)}Pa(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return ne(t)&&t>0?t:0}Ra(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=Ei(e,this.Mr.cookie_persisted_properties||[]),s=Ln(t,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(t)+"|"+JSON.stringify(s),r=te.Ot(this.ca)||void 0;r&&Si(this.ca,r)===i&&(this.Aa=i,this.Fa=r)}catch{}else try{const t=te.Ot(this.ca)||void 0;this.Aa=t?Si(this.ca,t):void 0,this.Fa=t}catch{}}syncCookieProperties(){return this.Oa(this.Mr)}Oa(e,t=!1){if(this.hi&&!t||this.ea||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=te.Ot(this.ca)||void 0}catch{}if(!s||s===this.Fa)return!1;const i=Si(this.ca,s);let r;try{r=$i(JSON.parse(s))}catch{return!1}if((te.Ot(this.ca)||void 0)!==s)return!1;this.Aa=i,this.Fa=s;const n=Dn(this.ca,s),o=[...ft,...n.properties],a={};if(Object.keys(r).forEach(_=>{const g=r[_];(x(g)||se(g)||g===""||_==="$user_state"&&g!=="anonymous"&&g!=="identified")&&(a[_]=!0,delete r[_])}),$e(r))return!1;const l="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",u=this.props,c=u[Ce],h=u[be],d=Z({},u);[...ft,...e.cookie_persisted_properties||[]].forEach(_=>{if(o.indexOf(_)!==-1&&!(_ in r)&&!a[_]&&(l||_!=="distinct_id"&&_!=="$user_state")){const g=d[_];(n.isValid||ft.indexOf(_)===-1||g!==!1&&g!==0)&&delete d[_]}}),this.props=Z(d,r),Ve.forEach(_=>{const g=_ in this.props;_ in u===g&&Xe(u[_],this.props[_])||(g?this.Ea(_,u[_],this.props[_]):this.ma(_,!0))}),!l||"$user_state"in r||"$user_state"in this.props||this.$a(be,Ue);const p=this.props[Ce],v=this.props[be];return!l||p===c&&v===h||(this.sa=!0,this.ta=!0,Y.$t(Ps(this.ca),!0),this.Ca(st),this.Ca(We),this.Ca(Ae),this.Ca(vt),this.Ca(rt),this.Ca(gt),this.Ca(nt),this.Ca(_s),this.Ca(it),v!=="anonymous"||h!=="identified"&&r.$user_state!=="anonymous"&&(x(c)||p===c)||(Zn(this.props,r),this.Ca(tt)),v==="identified"?this.props.$user_id=p:delete this.props.$user_id,this.Ca(Js)),!0}consumeCookieIdentityChange(){const e=Ps(this.ca),t=this.ta||!!Y.Ot(e);return this.ta=!1,t&&Y.Pt(e),t}Da(e=!1){return!(this.ea||this.hi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ea=!0,0))}La(){this.ea&&(x(this.Na)||(clearTimeout(this.Na),this.Na=void 0),delete this.Jo[le],this.qa(!0))}ja(e=!0){if(this.ea)try{e?this.La():x(this.Na)||(clearTimeout(this.Na),this.Na=void 0)}finally{this.ea=!1}}isDisabled(){return!!this.hi}ha(e){th.indexOf(e.persistence.toLowerCase())===-1&&(S.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((o=[],a=!1,l=()=>!1)=>{const u=[...ft,...o];return f(f({},H),{},{Dt(c){try{let d,p={};try{d=te.Ot(c)||void 0,p=d?$i(JSON.parse(d)):{}}catch{}const v=JSON.parse(H.Ot(c)||"{}");let _;if(a){const g=Dn(c,d),y=[...ft,...g.properties],m={};Object.keys(p).forEach(E=>{const k=p[E];se(k)||k===""||E==="$user_state"&&k!=="anonymous"&&k!=="identified"||(m[E]=k)});const w="distinct_id"in m||m.$user_state==="anonymous"||m.$user_state==="identified";if(Object.keys(m).length>0){var h;const E=v[Ce],k=(h=v.$user_state)!==null&&h!==void 0?h:Ue;u.forEach(P=>{if(y.indexOf(P)!==-1&&!(P in p)&&(w||P!=="distinct_id"&&P!=="$user_state")){const I=v[P];(g.isValid||ft.indexOf(P)===-1||I!==!1&&I!==0)&&delete v[P]}}),!w||"$user_state"in p||"$user_state"in v||(v[be]=Ue),!w||("distinct_id"in m?m[Ce]:v[Ce])===E&&("$user_state"in m?m[be]:v[be])===k||(ki.forEach(P=>delete v[P]),m.$user_state==="identified"&&"distinct_id"in m?v.$user_id=m[Ce]:delete v.$user_id,m.$user_state!=="identified"&&(delete v[Ya],delete v[tt]),delete v.__alias)}_=Z(v,m)}else _=Z(p,v);return l()||H.$t(c,_),_}catch{}return null},$t(c,h,d,p,v,_){const g=H.$t(c,h,void 0,void 0,_);try{const y=Ei(h,o);if(Object.keys(y).length){if(a){const m=Ys(c),w=Ln(y,o);if(te.$t(m,w,d,p,v,_),te.Ot(m)!==JSON.stringify(w)){te.Pt(m,p);const E=Ei(h);return te.$t(c,E,d,p,v,_),g}}te.$t(c,y,d,p,v,_)}}catch(y){H.Lt(y)}return g},Pt(c,h){try{b?.localStorage.removeItem(c),te.Pt(c,h),te.Pt(Ys(c),h)}catch(d){H.Lt(d)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let s,i=!1,r=!1;const n=e.persistence.toLowerCase();return n==="localstorage"&&H.At()?(s=H,r=!0):n==="localstorage+cookie"&&t.At()?(s=t,r=!0,i=!0):n==="sessionstorage"&&Y.At()?s=Y:n==="memory"?s=mr:n==="cookie"&&te.At()?(s=te,i=!0):t.At()?(s=t,r=!0,i=!0):te.At()?(s=te,i=!0):s=mr,this.Ko=r,this.Xo=i,s}pa(e){return`${this.ca}__${e}`}da(e){return this.Ko&&!!e.split_storage}properties(){const e={};return J(this.props,(t,s)=>{const i=ce(s);if(!i||i.exposure==="event"){var r;if(!(i==null||(r=i.shouldSkipFromEventProperties)===null||r===void 0)&&r.call(i,t))return;e[s]=t}}),e}load(e=!1){if(this.hi&&!e)return;const t=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",s=t?H.Dt(this.ca):null;let i={};if(t)try{i=$i(te.Dt(this.ca)),J(i,(a,l)=>{(x(a)||se(a)||a==="")&&delete i[l]})}catch{}const r=this.qo.Dt(this.ca);if(r&&(this.props=Z({},r)),this.Yo&&this.Ba(),t&&r){var n,o;const a=s?.[Ce],l=(n=s?.$user_state)!==null&&n!==void 0?n:Ue,u=r[Ce],c=(o=r.$user_state)!==null&&o!==void 0?o:Ue;if(u!==a||c!==l){this.ta=!0,this.hi||Y.$t(Ps(this.ca),!0);const h=Z({},this.props);ki.forEach(p=>delete h[p]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(x(a)||u===a)||(Zn(h,i),delete h[tt]),this.props=h;const d=new Set;ki.forEach(p=>{var v;const _=(v=ce(p))===null||v===void 0?void 0:v.storageGroup;_&&d.add(_)}),d.forEach(p=>{if(this.hi)return;const v={};J(this.props,(_,g)=>{var y;((y=ce(g))===null||y===void 0?void 0:y.storageGroup)===p&&(v[g]=_)}),$e(v)?(H.Pt(this.pa(p)),this.Jo[p]={}):H.$t(this.pa(p),v)&&(this.Jo[p]={persisted:!0,fingerprint:this.Sa(v,p)})})}}Y.Ot(Ps(this.ca))&&(this.ta=!0)}Ba(){for(const e of Qt){const t=H.Dt(this.pa(e));if(t&&!$e(t)){const s=this.ya(e);s.persisted=!0,this.za(e)||(s.fingerprint=this.Sa(t,e)),this.Ha(e,t)||Z(this.props,t)}}}za(e){return Object.keys(this.props).some(t=>{var s;return((s=ce(t))===null||s===void 0?void 0:s.storageGroup)===e})}Ha(e,t){const s=eh[e];if(!s)return!1;const i=t[s],r=this.props[s];return ne(i)&&ne(r)&&r>i}refreshKey(e){var t;if(this.hi||this.oa.has(e))return;const s=this.Yo?(t=ce(e))===null||t===void 0?void 0:t.storageGroup:void 0,i=s?H.Dt(this.pa(s)):this.qo.Dt(this.ca);if(i&&e in i)this.$a(e,i[e],!1);else{if(s){const r=this.qo.Dt(this.ca);if(r&&e in r)return void this.$a(e,r[e],!1)}this.Ca(e,!1)}}save(){if(this.hi)return;const e=this.Pa();e>0?x(this.Na)&&(this.Na=setTimeout(()=>{this.Na=void 0,this.qa()},e)):this.qa()}flush(){x(this.Na)||(clearTimeout(this.Na),this.Na=void 0,this.qa())}qa(e=!1){if(this.hi||this.ea&&!e)return;e||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||jl.forEach(r=>this.refreshKey(r)));const t=!e&&!this.na;t||(this.ra=!1);const s=!!t&&this.Ta();if(this.ra)return void(this.Mr.debug&&S.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Yo)return this.Ua(),void(s&&this.aa.forEach(r=>r()));const i=this.Wa(this.qo,this.ca,this.props,le);i==="written"&&this.Ra(this.props),i!=="failed"&&(this.ia.clear(),this.sa=!1,this.oa.clear()),s&&this.aa.forEach(r=>r())}Ua(){const{main:e,groups:t}=this.wa(),s=this.Wa(this.qo,this.ca,e,le);s==="written"&&this.Ra(e),s!=="failed"&&(this.sa=!1,this.oa.clear(),Ve.forEach(r=>{var n;!((n=ce(r))===null||n===void 0)&&n.storageGroup||this.ia.delete(r)}));for(const r of Qt){var i;const n=t[r];if($e(n)&&!(!((i=this.Jo[r])===null||i===void 0)&&i.persisted)){Ve.forEach(a=>{var l;((l=ce(a))===null||l===void 0?void 0:l.storageGroup)===r&&this.ia.delete(a)});continue}const o=this.Wa(H,this.pa(r),n,r);o!=="failed"&&Ve.forEach(a=>{const l=ce(a);l?.storageGroup!==r||o!=="written"&&l.volatile||this.ia.delete(a)})}}wa(){const e={},t={flags:{},surveys:{}};return J(this.props,(s,i)=>{var r;const n=(r=ce(i))===null||r===void 0?void 0:r.storageGroup;n?t[n][i]=s:e[i]=s}),{main:e,groups:t}}Sa(e,t){if(t===le)return JSON.stringify(e)+"|"+this.Va+"|"+this.Ga+"|"+this.Qa;const s={};return J(e,(i,r)=>{var n;s[r]=!((n=ce(r))===null||n===void 0)&&n.volatile?"__volatile__":i}),JSON.stringify(s)}Wa(e,t,s,i){const r=this.ya(i);if(i!==le&&!r.dirty&&!x(r.fingerprint))return"skipped";let n;try{if(n=this.Sa(s,i),n===r.fingerprint)return r.dirty=!1,"skipped"}catch{n=void 0}return e.$t(t,s,this.Va,this.Ga,this.Qa,this.Mr.debug)?(r.dirty=!1,i!==le&&(r.persisted=!0),x(n)||(r.fingerprint=n),this.Ko&&(r.storageValue=H.Ot(t)),"written"):(this.Mr.debug&&S.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ma(),x(this.Na)||(clearTimeout(this.Na),this.Na=void 0),this.qo.Pt(this.ca,!1),this.qo.Pt(this.ca,!0),!e&&this.la)for(const t of Qt)H.Pt(this.pa(t));e?delete this.Jo[le]:this.Jo={},this.Aa=void 0,this.Fa=void 0}clear(){this.remove(),this.props={}}register_once(e,t,s){if(L(e)){this.syncCookieProperties(),x(t)&&(t="None"),this.Va=x(s)?this.Za:s;let i=!1;if(J(e,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.$a(n,r),i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(L(e)){this.syncCookieProperties(),this.Va=x(t)?this.Za:t;let s=!1;if(J(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||L(i)||F(i))&&(this.$a(r,i),s=!0)}),s)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t=typeof e=="string"?[e]:e;let s=!1;for(const i of t)i in this.props&&(this.Ca(i),s=!0);s&&this.save()}update_campaign_params(){const e=$?.URL;if(e===this.ua)return;const t=Cl(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),s=!$e(Vr(t));return s&&this.register(t),this.ua=e,s?t:void 0}update_search_keyword(){this.register((function(){const e=$?.referrer;return e?Tl(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:Ll(),$referring_domain:$?.referrer&&((e=Je($.referrer))===null||e===void 0?void 0:e.host)||Zs},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Dl(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[Ot]:this.Xo?{r:Ms(e.r),u:e.u?Ms(e.u):void 0}:e},void 0)}get_initial_props(){const e={};J([sl,tl],s=>{const i=this.props[s];i&&J(i,function(r,n){e["$initial_"+Xi(n)]=r})});const t=this.props[Ot];if(t){const s=(function(i,r=!1){const n=Nl(i,r),o={};return J(n,function(a,l){o[`$initial_${Xi(l)}`]=a}),o})(t,this.Mr.disable_capture_url_hashes);Z(e,s)}return e}safe_merge(e){return J(this.props,function(t,s){s in e||(e[s]=t)}),e}update_config(e,t,s){const i=e.persistence!==t.persistence,r=!((p,v)=>{if(p.length!==v.length)return!1;const _=[...p].sort(),g=[...v].sort();return _.every((y,m)=>y===g[m])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),n=i||r,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!s,l=!!this.hi&&!a;a||this.Oa(t,l),this.Mr=e,!a&&(i||r||o)&&(this.Aa=void 0,this.Fa=void 0,this.Oa(f(f({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const u=n||o?this.ha(e):this.qo;this.Ja();const c=this.da(e),h=n||c!==this.Yo,d=!a&&(h||e.cross_subdomain_cookie!==this.Ga||e.secure_cookie!==this.Qa)&&this.Da(l);this.na=h;try{if(this.Za=this.Va=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),h){const p=this.props;this.clear(),this.qo=u,this.Yo=c,this.props=p,this.save()}else o&&(this.qo=u,a||(delete this.Jo[le],this.qa()))}finally{this.na=!1,d&&this.ja()}}Ja(){const e=this.props[Ot];if(!this.Xo||!L(e)||typeof e.r!="string")return;const t=Ms(e.r),s=typeof e.u=="string"?Ms(e.u):e.u;t===e.r&&s===e.u||this.$a(Ot,f(f({},e),{},{r:t,u:s}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ga&&(this.Ga=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Qa&&(this.Qa=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const s=this.props.__timers||{};s[e]=t,this.$a(ur,s),this.save()}remove_event_timer(e){const t=this.props.__timers||{},s=t[e];return x(s)||(delete t[e],this.$a(ur,t),this.save()),s}get_property(e){return this.props[e]}set_property(e,t){this.$a(e,t),this.save()}$a(e,t,s=!0){var i;const r=this.props[e];this.props[e]=t,s&&(e!=="distinct_id"&&e!=="$user_state"||r===t||(this.sa=!0),Xn(e)&&!Xe(r,t)&&this.oa.add(e),this.Ea(e,r,t),!((i=ce(e))===null||i===void 0)&&i.volatile||this.Ia(e))}Ca(e,t=!0){delete this.props[e],t&&(Ii(e)&&this.ma(e,!0),Xn(e)&&this.oa.add(e),this.Ia(e))}Ia(e){var t;const s=(t=ce(e))===null||t===void 0?void 0:t.storageGroup;s&&(this.ya(s).dirty=!0)}ya(e){return this.Jo[e]||(this.Jo[e]={})}};const Pe={GZipJS:"gzip-js",Base64:"base64"},Yt={Activation:"events",Cancellation:"cancelEvents"},Fi={Popover:"popover",API:"api",Widget:"widget"},Se={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Ci={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},wr={Popover:"popover",Inline:"inline"};function Ai(e){let t=!0;return{dispose(){if(t){t=!1;const s=e();s&&oe(s.then)&&s.then(void 0,()=>{})}}}}const sh={SHOWN:"product tour shown"},eo={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},to=ee("[RateLimiter]");var ih=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{to.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void to.warn(`could not rate limit - continuing. Error: "${i?.message}"`,{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,s,i;const{captureEventsBurstLimit:r,captureEventsPerSecond:n}=this,o=new Date().getTime(),a=(t=(s=this.instance.persistence)===null||s===void 0?void 0:s.get_property("$capture_rate_limit"))!==null&&t!==void 0?t:{tokens:r,last:o};a.tokens+=Math.max(0,o-a.last)/1e3*n,a.last=Math.max(a.last,o),a.tokens>r&&(a.tokens=r);const l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){const u=(ne(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Ka(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}Xa(e){const t=this.instance.config.property_denylist;return!F(t)||!t.includes(e)}Ya(){var e;if(this.Xa("$current_url")&&this.Xa("$pathname")&&Q?.pathname)return`${(e=Q.origin)!==null&&e!==void 0?e:""}${Q.pathname}`}Ka(e){var t,s;const{captureEventsBurstLimit:i,captureEventsPerSecond:r}=this,n=this.Ya(),o=this.Xa("$session_id")?(t=(s=this.instance).get_session_id)===null||t===void 0?void 0:t.call(s):void 0,a=[`${e} event(s) dropped since the last warning`,n?`triggered on ${n}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${r} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}};const Ze=ee("[RemoteConfig]");var ql=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=T._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}tl(e){var t,s,i;!((t=T.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(s=T.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}el(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 Ze.info("Using preloaded remote config",this.remoteConfig),void this.il(this.remoteConfig);if(this._instance.nl())return void Ze.warn("Remote config is disabled. Falling back to local config.");this.tl(e=>{if(!e)return Ze.info("No config found after loading remote JS config. Falling back to JSON."),void this.el(t=>{this.il(t.json,t)});this.il(e)})}catch(e){Ze.error("Error loading remote config",e),this.il()}}il(e,t){!e&&t&&(t.statusCode===0?t.error||Ze.warn("Failed to fetch remote config from PostHog."):Ze.error("Failed to fetch remote config from PostHog."));try{this._instance.il(e?{ok:!0,config:e}:{ok:!1})}catch(i){Ze.error("Error applying remote config",i)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)===null||s===void 0||s.ensureFlagsLoaded()}catch(i){Ze.error("Error loading feature flags",i)}}},Oe=Uint8Array,Ee=Uint16Array,Bt=Uint32Array,Qr=new Oe([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]),Yr=new Oe([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]),so=new Oe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hl=function(e,t){for(var s=new Ee(31),i=0;31>i;++i)s[i]=t+=1<<e[i-1];var r=new Bt(s[30]);for(i=1;30>i;++i)for(var n=s[i];s[i+1]>n;++n)r[n]=n-s[i]<<5|i;return[s,r]},Bl=Hl(Qr,2),xr=Bl[1];Bl[0][28]=258,xr[258]=28;for(var io=Hl(Yr,0)[1],zl=new Ee(32768),ie=0;32768>ie;++ie){var $t=(43690&ie)>>>1|(21845&ie)<<1;zl[ie]=((65280&($t=(61680&($t=(52428&$t)>>>2|(13107&$t)<<2))>>>4|(3855&$t)<<4))>>>8|(255&$t)<<8)>>>1}var ds=function(e,t,s){for(var i=e.length,r=0,n=new Ee(t);i>r;++r)++n[e[r]-1];var o,a=new Ee(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;for(o=new Ee(i),r=0;i>r;++r)o[r]=zl[a[e[r]-1]++]>>>15-e[r];return o},mt=new Oe(288);for(ie=0;144>ie;++ie)mt[ie]=8;for(ie=144;256>ie;++ie)mt[ie]=9;for(ie=256;280>ie;++ie)mt[ie]=7;for(ie=280;288>ie;++ie)mt[ie]=8;var ei=new Oe(32);for(ie=0;32>ie;++ie)ei[ie]=5;var rh=ds(mt,9),nh=ds(ei,5),Vl=function(e){return(e/8|0)+(7&e&&1)},Wl=function(e,t,s){(s==null||s>e.length)&&(s=e.length);var i=new(e instanceof Ee?Ee:e instanceof Bt?Bt:Oe)(s-t);return i.set(e.subarray(t,s)),i},He=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8},Xt=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8,e[i+2]|=s>>>16},Ti=function(e,t){for(var s=[],i=0;e.length>i;++i)e[i]&&s.push({s:i,f:e[i]});var r=s.length,n=s.slice();if(!r)return[new Oe(0),0];if(r==1){var o=new Oe(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function(k,P){return k.f-P.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],u=0,c=1,h=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=s[s[h].f>s[u].f?u++:h++],l=s[u!=c&&s[h].f>s[u].f?u++:h++],s[c++]={s:-1,f:a.f+l.f,l:a,r:l};var d=n[0].s;for(i=1;r>i;++i)n[i].s>d&&(d=n[i].s);var p=new Ee(d+1),v=kr(s[c-1],p,0);if(v>t){i=0;var _=0,g=v-t,y=1<<g;for(n.sort(function(k,P){return p[P.s]-p[k.s]||k.f-P.f});r>i;++i){var m=n[i].s;if(t>=p[m])break;_+=y-(1<<v-p[m]),p[m]=t}for(_>>>=g;_>0;){var w=n[i].s;t>p[w]?_-=1<<t-p[w]++-1:++i}for(;i>=0&&_;--i){var E=n[i].s;p[E]==t&&(--p[E],++_)}v=t}return[new Oe(p),v]},kr=function(e,t,s){return e.s==-1?Math.max(kr(e.l,t,s+1),kr(e.r,t,s+1)):t[e.s]=s},ro=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new Ee(++t),i=0,r=e[0],n=1,o=function(l){s[i++]=l},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[s.subarray(0,i),t]},Zt=function(e,t){for(var s=0,i=0;t.length>i;++i)s+=e[i]*t[i];return s},$r=function(e,t,s){var i=s.length,r=Vl(t+2);e[r]=255&i,e[r+1]=i>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;i>n;++n)e[r+n+4]=s[n];return 8*(r+4+i)},no=function(e,t,s,i,r,n,o,a,l,u,c){He(t,c++,s),++r[256];for(var h=Ti(r,15),d=h[0],p=h[1],v=Ti(n,15),_=v[0],g=v[1],y=ro(d),m=y[0],w=y[1],E=ro(_),k=E[0],P=E[1],I=new Ee(19),M=0;m.length>M;++M)I[31&m[M]]++;for(M=0;k.length>M;++M)I[31&k[M]]++;for(var O=Ti(I,7),q=O[0],B=O[1],z=19;z>4&&!q[so[z-1]];--z);var K,C,j,N,U=u+5<<3,V=Zt(r,mt)+Zt(n,ei)+o,re=Zt(r,d)+Zt(n,_)+o+14+3*z+Zt(I,q)+(2*I[16]+3*I[17]+7*I[18]);if(V>=U&&re>=U)return $r(t,c,e.subarray(l,l+u));if(He(t,c,1+(V>re)),c+=2,V>re){K=ds(d,p),C=d,j=ds(_,g),N=_;var ue=ds(q,B);for(He(t,c,w-257),He(t,c+5,P-1),He(t,c+10,z-4),c+=14,M=0;z>M;++M)He(t,c+3*M,q[so[M]]);c+=3*z;for(var ae=[m,k],Me=0;2>Me;++Me){var ge=ae[Me];for(M=0;ge.length>M;++M)He(t,c,ue[de=31&ge[M]]),c+=q[de],de>15&&(He(t,c,ge[M]>>>5&127),c+=ge[M]>>>12)}}else K=rh,C=mt,j=nh,N=ei;for(M=0;a>M;++M)if(i[M]>255){var de;Xt(t,c,K[257+(de=i[M]>>>18&31)]),c+=C[de+257],de>7&&(He(t,c,i[M]>>>23&31),c+=Qr[de]);var _e=31&i[M];Xt(t,c,j[_e]),c+=N[_e],_e>3&&(Xt(t,c,i[M]>>>5&8191),c+=Yr[_e])}else Xt(t,c,K[i[M]]),c+=C[i[M]];return Xt(t,c,K[256]),c+C[256]},oh=new Bt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ah=(function(){for(var e=new Bt(256),t=0;256>t;++t){for(var s=t,i=9;--i;)s=(1&s&&3988292384)^s>>>1;e[t]=s}return e})(),Ri=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function lh(e,t){t===void 0&&(t={});var s=(function(){var h=4294967295;return{p(d){for(var p=h,v=0;d.length>v;++v)p=ah[255&p^d[v]]^p>>>8;h=p},d(){return 4294967295^h}}})(),i=e.length;s.p(e);var r,n,o,a,l,u=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,(function(h,d,p,v,_,g){var y=h.length,m=new Oe(v+y+5*(1+Math.floor(y/7e3))+_),w=m.subarray(v,m.length-_),E=0;if(!d||8>y)for(var k=0;y>=k;k+=65535){var P=k+65535;y>P?E=$r(w,E,h.subarray(k,P)):(w[k]=g,E=$r(w,E,h.subarray(k,y)))}else{for(var I=oh[d-1],M=I>>>13,O=8191&I,q=(1<<p)-1,B=new Ee(32768),z=new Ee(q+1),K=Math.ceil(p/3),C=2*K,j=function(ui){return(h[ui]^h[ui+1]<<K^h[ui+2]<<C)&q},N=new Bt(25e3),U=new Ee(288),V=new Ee(32),re=0,ue=0,ae=(k=0,0),Me=0,ge=0;y>k;++k){var de=j(k),_e=32767&k,Ke=z[de];if(B[_e]=Ke,z[de]=_e,k>=Me){var yt=y-k;if((re>7e3||ae>24576)&&yt>423){E=no(h,w,0,N,U,V,ue,ae,ge,k-ge,E),ae=re=ue=0,ge=k;for(var xe=0;286>xe;++xe)U[xe]=0;for(xe=0;30>xe;++xe)V[xe]=0}var Le=2,at=0,yu=O,Qe=_e-Ke&32767;if(yt>2&&de==j(k-Qe))for(var bu=Math.min(M,yt)-1,wu=Math.min(32767,k),xu=Math.min(258,yt);wu>=Qe&&--yu&&_e!=Ke;){if(h[k+Le]==h[k+Le-Qe]){for(var Ye=0;xu>Ye&&h[k+Ye]==h[k+Ye-Qe];++Ye);if(Ye>Le){if(Le=Ye,at=Qe,Ye>bu)break;var ku=Math.min(Qe,Ye-2),en=0;for(xe=0;ku>xe;++xe){var li=k-Qe+xe+32768&32767,tn=li-B[li]+32768&32767;tn>en&&(en=tn,Ke=li)}}}Qe+=(_e=Ke)-(Ke=B[_e])+32768&32767}if(at){N[ae++]=268435456|xr[Le]<<18|io[at];var sn=31&xr[Le],rn=31&io[at];ue+=Qr[sn]+Yr[rn],++U[257+sn],++V[rn],Me=k+Le,++re}else N[ae++]=h[k],++U[h[k]]}}E=no(h,w,g,N,U,V,ue,ae,ge,k-ge,E)}return Wl(m,0,v+Vl(E)+_)})(n=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!0)),c=u.length;return(function(h,d){var p=d.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>d.level?4:d.level==9?2:0,h[9]=3,d.mtime!=0&&Ri(h,4,Math.floor(new Date(d.mtime||Date.now())/1e3)),p){h[3]=8;for(var v=0;p.length>=v;++v)h[v+10]=p.charCodeAt(v)}})(u,t),Ri(u,c-8,s.d()),Ri(u,c-4,i),u}const uh=!!Ir||!!vs,Ul=new WeakMap,Gl="text/plain";let Li=0,Ds=!1;const Jl=(e,t)=>{const[s,i]=e.split("#"),[r,n]=s.split("?");if(!n)return e;const o=n.split("&").filter(a=>a.split("=")[0]!==t).join("&");return`${r}${o?`?${o}`:""}${i?`#${i}`:""}`},ks=(e,t,s=!0)=>{var i;const[r,n]=e.split("?"),o=f({},t),a=(i=n?.split("&").map(u=>{var c;const[h,d]=u.split("="),p=s&&(c=o[h])!==null&&c!==void 0?c:d;return delete o[h],`${h}=${p}`}))!==null&&i!==void 0?i:[],l=(function(u,c="&"){let h,d;const p=[];return J(u,function(v,_){x(v)||x(_)||_==="undefined"||(h=encodeURIComponent((g=>g instanceof File)(v)?v.name:v.toString()),d=encodeURIComponent(_),p[p.length]=d+"="+h)}),p.join(c)})(o);return l&&a.push(l),a.length>0?`${r}?${a.join("&")}`:r},Di=e=>{if(e.sl)return e.sl;const{data:t,compression:s}=e;if(!t)return;if(s===Pe.GZipJS){const r=lh((function(n){var o=n.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(n);for(var a=new Oe(n.length+(n.length>>>1)),l=0,u=function(p){a[l++]=p},c=0;o>c;++c){if(l+5>a.length){var h=new Oe(l+8+(o-c<<1));h.set(a),a=h}var d=n.charCodeAt(c);128>d?u(d):2048>d?(u(192|d>>>6),u(128|63&d)):d>55295&&57344>d?(u(240|(d=65536+(1047552&d)|1023&n.charCodeAt(++c))>>>18),u(128|d>>>12&63),u(128|d>>>6&63),u(128|63&d)):(u(224|d>>>12),u(128|d>>>6&63),u(128|63&d))}return Wl(a,0,l)})(Ct(t)),{mtime:0});return{contentType:Gl,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(s===Pe.Base64){const r=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Ct(t)),n=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Ct(o)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}const i=Ct(t);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},Kl=e=>{const t=()=>e.transport==="sendBeacon"?{url:ks(e.url,{compression:Pe.Base64}),encodedBody:Di(f(f({},e),{},{compression:Pe.Base64,sl:void 0}))}:{url:Jl(e.url,"compression"),encodedBody:Di(f(f({},e),{},{compression:void 0,sl:void 0}))};let s;try{s=Di(e)}catch(r){if(xn(e.compression,qt(e.url,"compression")))return S.error("Failed to gzip request body, sending uncompressed payload",r),t();throw r}return s&&xn(e.compression,qt(e.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?rr(new Uint8Array(i)):ArrayBuffer.isView(i)&&rr(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Ds=!0,t()):{url:e.url,encodedBody:s};var i},Ql=e=>{try{return Kl(e)}catch(s){var t;return S.error(s),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:s}))}},ch=(function(){var e=X(function*(t){const s=yield(function(r){return nr.apply(this,arguments)})(Ct(t.data),ke.DEBUG,{rethrow:!0});if(!s)return t;const i=yield s.arrayBuffer();return f(f({},t),{},{sl:{contentType:Gl,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}})(),dh=/Failed to fetch|NetworkError|Load failed/i,Yl=e=>e?.name==="TypeError"&&dh.test(e?.message||""),Xl=e=>{try{const t=(function(s,i=Date.now()){if(typeof s!="string"||!s)return;const r=s.trim(),n=/^\d+\s*,/.test(r)?r.slice(0,r.indexOf(",")).trim():r;if(/^\d+$/.test(n)){const l=1e3*Math.min(Number(n),300);return l>0?l:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(n))return;const o=/^\w{3} \w{3} /.test(n)?n+" GMT":n,a=Date.parse(o)-i;return Number.isFinite(a)&&a>0?Math.min(a,Ts):void 0})(e());return x(t)?void 0:Math.min(t,3e4)}catch{return}},Zl=e=>{const t=Ql(e);if(!t)return;const s=new Ir;Ul.set(s,!0);const{url:i,encodedBody:r}=t;s.open(e.method||"GET",i,!0);const{contentType:n,body:o}=r??{};J(e.headers,function(a,l){s.setRequestHeader(l,a)}),n&&s.setRequestHeader("Content-Type",n),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a;const l={statusCode:s.status,text:s.responseText};if(s.status===200)try{l.json=JSON.parse(s.responseText)}catch{}(a=e.callback)===null||a===void 0||a.call(e,l,Xl(()=>s.getResponseHeader("Retry-After")))}},s.send(o)},eu=e=>{const t=Ql(e);if(!t)return;const{url:s,encodedBody:i}=t,{contentType:r,body:n,estimatedSize:o}=i??{},a=new Headers;J(e.headers,function(v,_){a.append(_,v)}),r&&a.append("Content-Type",r);let l=null,u=!1;if(nn){const v=new nn;l={signal:v.signal,timeout:setTimeout(()=>{u=!0;try{v.abort(xa("AbortError","PostHog request timed out"+((_=e.timeout)?` after ${_}ms`:"")))}catch(g){h(g)}var _},e.timeout)}}let c=!1;const h=v=>{var _;c||(c=!0,u&&v?.name==="AbortError"||Yl(v)?S.warn(v):S.error(v),(_=e.callback)===null||_===void 0||_.call(e,{statusCode:0,error:v}))};let d=0;const p=()=>{Li-=d,d=0,l&&clearTimeout(l.timeout)};try{const v=f({method:e?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:n,signal:l?.signal},e.fetchOptions),_=o??(x(n)?0:void 0);v.keepalive=v.method==="POST"&&!e.rl&&v.keepalive!==!1&&v.body===n&&!x(_)&&_>=0&&52428.8>Li+_,v.keepalive&&(d=_,Li+=d),vs(s,v).then(g=>g.text().then(y=>{var m;if(c)return;const w={statusCode:g.status,text:y};if(g.status===200)try{w.json=JSON.parse(y)}catch(E){S.error(E)}c=!0,p(),(m=e.callback)===null||m===void 0||m.call(e,w,Xl(()=>g.headers.get("Retry-After")))})).catch(g=>{p(),h(g)}).finally(p)}catch(v){p(),h(v)}},Er=e=>{try{var t;const{url:s,encodedBody:i}=Kl(e),{contentType:r,body:n,estimatedSize:o}=i??{};if(!n)return;const a=n instanceof Blob?n:new Blob([n],{type:r});if(he.sendBeacon(s,a))return;const l=F(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(F(l)&&l.length>1&&(o??0)>16384){const u=Math.ceil(l.length/2),c=h=>F(e.data)?h:f(f({},e.data),{},{batch:h});return Er(f(f({},e),{},{data:c(l.slice(0,u))})),void Er(f(f({},e),{},{data:c(l.slice(u))}))}S.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${vs?"fetch":"XHR"}`),vs?eu(f(f({},e),{},{rl:!0})):Zl(e)}catch(s){S.warn("Beacon send failed",s)}},oo=(e,t,s,i)=>{const r=i==="query"?t==="POST"?"sent_at":"_":void 0;return ks(s===Pe.GZipJS?Jl(e,"compression"):e,f(f({},r?{[r]:Date.now().toString()}:{}),s===Pe.GZipJS?{}:{compression:s}))},hh=(()=>{const e=[];return vs&&e.push({transport:"fetch",method:eu}),Ir&&e.push({transport:"XHR",method:Zl}),he?.sendBeacon&&e.push({transport:"sendBeacon",method:Er}),e})();let tu=!uh&&ye?.indexOf("MSIE")===-1&&ye?.indexOf("Mozilla")===-1;function su(e,t,s){var i,r,n;s&&(t=f(f({},t),{},{callback:o=>s(o)})),e.__loaded?tu?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((r=t.callback)===null||r===void 0||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=f(f({},e.config.request_headers),t.headers),t.compression=t.compression==="best-available"?(i=e.compression)!==null&&i!==void 0?i:t.compressionFallback:t.compression,(x(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((o,a)=>{var l,u,c;const h=f(f({},o),{},{callback:a??(g=>{var y;return(y=o.callback)===null||y===void 0?void 0:y.call(o,g)})});h.timeout=h.timeout||6e4;const d=(l=h.transport)!==null&&l!==void 0?l:"fetch";d==="sendBeacon"&&x(h.compression)&&h.data&&(h.compression=Pe.Base64),h.method==="POST"&&h.data&&(h.timestampMode==="capture-body"?h.data=(g=>{var y,m;const w=(F(g)?g:[g]).map(k=>f(f({},k),k.timestamp instanceof Date&&!isNaN(k.timestamp.getTime())?{timestamp:k.timestamp.toISOString()}:{})),E=w[0];return{api_key:(y=E==null||(m=E.properties)===null||m===void 0?void 0:m.token)!==null&&y!==void 0?y:E?.token,batch:w,sent_at:new Date().toISOString()}})(h.data):h.timestampMode==="body"&&(h.data=((g,y=new Date().toISOString())=>F(g)?g.map(m=>f(f({},m),{},{sent_at:y})):f(f({},g),{},{sent_at:y}))(h.data))),h.url=oo(h.url,h.method,h.compression,h.timestampMode);const p=hh.filter(g=>!h.disableTransport||!g.transport||!h.disableTransport.includes(g.transport)),v=(u=(c=(function(g,y){for(let m=0;g.length>m;m++)if(y(g[m]))return g[m]})(p,g=>g.transport===d))===null||c===void 0?void 0:c.method)!==null&&u!==void 0?u:p[0].method;if(!v)throw new Error("No available transport method");const _=g=>{try{v(g)}catch(m){var y;Yl(m)?S.warn(m):S.error(m),(y=h.callback)===null||y===void 0||y.call(h,{statusCode:0,error:m})}};d!=="sendBeacon"&&!h.preferSyncCompression&&h.data&&h.compression===Pe.GZipJS&&Eu&&typeof Promise<"u"&&!Ds?ch(h).then(g=>{_(g)}).catch(g=>{if(kn(g))return Ds=!0,void _(f(f({},h),{},{compression:void 0,url:oo(o.url,o.method,void 0,o.timestampMode)}));(y=>{if(!y||typeof y!="object")return!1;const m="name"in y?String(y.name):"";return kn(y)||m===Ia})(g)&&(Ds=!0),_(h)}):_(h)})(t,(o,a)=>{var l,u,c;e.rateLimiter.checkForLimiting(o),400>o.statusCode||(l=(u=e.config).on_request_error)===null||l===void 0||l.call(u,o),s?s(o,a):(c=t.callback)===null||c===void 0||c.call(t,o)})):t.fireCallbackOnDrop&&((n=t.callback)===null||n===void 0||n.call(t,{statusCode:0}))}var ph=class{constructor(e,t){this.ol=!0,this.al=[],this.ll=qe(t?.flush_interval_ms||3e3,250,5e3,S.createLogger("flush interval"),3e3),this.ul=e}enqueue(e){this.al.push(e),this.cl||this.hl()}unload(){this.dl();const e=this.al.length>0?this.vl():{},t=Object.values(e);[...t.filter(s=>s.url.indexOf("/e")===0),...t.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.fl(f(f({},s),{},{callback:void 0}),"sendBeacon")})}enable(){this.ol=!1,this.hl()}hl(){this.ol||(this.cl=setTimeout(()=>{this.dl(),this.pl()},this.ll))}pl(){if(this.al.length>0){const e=this.vl();for(const t in e)this.fl(e[t])}}fl(e,t){try{this.ul(e,t)}catch(s){S.error(s)}}dl(){clearTimeout(this.cl),this.cl=void 0}vl(){const e={},t={};J(this.al,s=>{var i;const r=s,n=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:"");x(e[n])&&(e[n]=f(f({},r),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[n]=[]),(i=e[n].data)===null||i===void 0||i.push(r.data),r.callback&&t[n].push(r.callback)});for(const s in t){const i=t[s];i.length&&(e[s].callback=r=>{for(const n of i)n(r)})}return this.al=[],e}};const fh=["retriesPerformedSoFar"];var vh=class{constructor(e){this._instance=e,this.gl=!1,this.ml=3e3,this.al=[],this.al=[],this.yl=!0,this.resume()}resume(){if(!x(b)&&"onLine"in b.navigator){if(this.yl=b.navigator.onLine,this.bl)return;this.bl=()=>{this.yl=!0,this.pl()},this._l=()=>{this.yl=!1},W(b,"online",this.bl),W(b,"offline",this._l)}}get length(){return this.al.length}retriableRequest(e,t){let{retriesPerformedSoFar:s}=e,i=Oa(e,fh);ze(s)&&(i.url=ks(i.url,{retry_count:s})),su(this._instance,t?f(f({},i),{},{transport:t}):i,(r,n)=>{var o;if(r.statusCode!==200&&(400>r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(s??0))return void this.Ls(f({retriesPerformedSoFar:s},i),n);r.statusCode===0&&S.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${s??0} retries.`)}(o=i.callback)===null||o===void 0||o.call(i,r)})}Ls(e,t){const s=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=s+1;const i=Math.max((function(o){const a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)})(s),t??0),r=Date.now()+i;this.al.push({retryAt:r,requestOptions:e});let n=`Enqueued failed request for retry in ${i}`;navigator.onLine||(n+=" (Browser is offline)"),S.warn(n),this.gl||(this.gl=!0,this.wl())}wl(){if(this.kl&&clearTimeout(this.kl),this.al.length===0)return this.gl=!1,void(this.kl=void 0);this.kl=setTimeout(()=>{this.yl&&this.al.length>0&&this.pl(),this.wl()},this.ml)}pl(){const e=Date.now(),t=[],s=this.al.filter(i=>e>i.retryAt||(t.push(i),!1));if(this.al=t,s.length>0)for(const{requestOptions:i}of s)this.retriableRequest(i)}unload(){this.kl&&(clearTimeout(this.kl),this.kl=void 0),this.gl=!1,x(b)||(this.bl&&(b.removeEventListener("online",this.bl),this.bl=void 0),this._l&&(b.removeEventListener("offline",this._l),this._l=void 0));for(const{requestOptions:e}of this.al)try{this._instance._send_request(f(f({},e),{},{callback:F(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(t){S.error(t)}this.al=[]}},gh=class{constructor(e){this._instance=e,this.Sl=()=>{var t,s,i,r;this.xl||(this.xl={});const n=this.scrollElement(),o=this.scrollY(),a=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=o+(n?.clientHeight||0),u=n?.scrollHeight||0;this.xl.lastScrollY=Math.ceil(o),this.xl.maxScrollY=Math.max(o,(t=this.xl.maxScrollY)!==null&&t!==void 0?t:0),this.xl.maxScrollHeight=Math.max(a,(s=this.xl.maxScrollHeight)!==null&&s!==void 0?s:0),this.xl.lastContentY=l,this.xl.maxContentY=Math.max(l,(i=this.xl.maxContentY)!==null&&i!==void 0?i:0),this.xl.maxContentHeight=Math.max(u,(r=this.xl.maxContentHeight)!==null&&r!==void 0?r:0)}}get $l(){return this._instance.config.scroll_root_selector}getContext(){return this.xl}resetContext(){const e=this.xl;return this.xl=void 0,setTimeout(this.Sl,0),e}startMeasuringScrollPosition(){W(b,"scroll",this.Sl,{capture:!0}),W(b,"scrollend",this.Sl,{capture:!0}),W(b,"resize",this.Sl)}scrollElement(){if(this.$l){const s=F(this.$l)?this.$l:[this.$l];for(const i of s){var e;const r=b==null||(e=b.document)===null||e===void 0?void 0:e.querySelector(i);if(r)return r}return}var t;return b==null||(t=b.document)===null||t===void 0?void 0:t.documentElement}Cl(e){var t,s;const i=e==="y"?"scrollTop":"scrollLeft";if(this.$l){const r=this.scrollElement();return r&&r[i]||0}return b?e==="y"?b.scrollY||b.pageYOffset||((t=b.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:b.scrollX||b.pageXOffset||((s=b.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.Cl("y")}scrollX(){return this.Cl("x")}};const _h=e=>Dl(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes);var ao=class{constructor(e,t,s,i){this.qe=r=>{const n=this.Tl();if(n&&n.sessionId===r)return;const o={sessionId:r,props:this.Il(this._instance)};this.Ml.register({[vr]:o})},this._instance=e,this.El=t,this.Ml=s,this.Il=i||_h,this.El.onSessionId(this.qe)}Tl(){return this.Ml.props[vr]}getSetOnceProps(){var e;const t=(e=this.Tl())===null||e===void 0?void 0:e.props;return t?"r"in t?Nl(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 J(Vr(this.getSetOnceProps()),(t,s)=>{s==="$current_url"&&(s="url"),e[`$session_entry_${Xi(s)}`]=t}),e}},ti=class{on(e,t){return this.Pl[e]||(this.Pl[e]=[]),this.Pl[e].push(t),()=>{this.Pl[e]=this.Pl[e].filter(s=>s!==t)}}emit(e,t){for(const s of this.Pl[e]||[])s(t);for(const s of this.Pl["*"]||[])s(e,t)}constructor(){this.Pl={}}};const Et=ee("[SessionId]"),lo=864e5;var uo=class{on(e,t){return this.Rl.on(e,t)}constructor(e,t,s){var i;if(this.Al=null,this.Fl=null,this.Ol=[],this.Dl=void 0,this.Ll=!1,this.Rl=new ti,this.Nl=(n,o)=>!(!ze(n)||!ze(o))&&Math.abs(n-o)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=e.config,this.Ml=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.ql=void 0,this._sessionActivityTimestamp=null,this.jl=t||Te,this.Bl=s||Te;const r=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*qe(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Et.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.zl(),this.Hl="ph_"+r+"_window_id",this.Ul="ph_"+r+"_primary_window_exists",this.Wl()){const n=Y.Dt(this.Hl),o=Y.Dt(this.Ul);n&&!o?this.je=n:Y.Pt(this.Hl),Y.$t(this.Ul,!0)}!((i=this.Mr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Vl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return x(this.Ol)&&(this.Ol=[]),this.Ol.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.Ol=this.Ol.filter(t=>t!==e)}}Wl(){return this.Mr.persistence!=="memory"&&!this.Ml.hi&&Y.At()}Gl(e){e!==this.je&&(this.je=e,this.Wl()&&Y.$t(this.Hl,e))}Ql(){return this.je?this.je:this.Wl()?Y.Dt(this.Hl):null}Zl(e){const t=this.Al;return!se(t)&&!se(e)&&5e3>Math.abs(e-t)}Jl(e,t,s){const i=t!==this._sessionActivityTimestamp,r=!(e!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this.Xt=e,r&&!i||r&&this.Zl(t)||(this.Al=t,this.Ml.register({[It]:[t,e,s]}))}Kl(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return ze(t)&&t>0}Xl(){this.Kl()?this.Ml.refreshKey(It):(this.Ml.flush(),this.Ml.load())}Yl(){var e;if(se(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Al)return;this.Xl();const[,t,s]=this.tu();t===this.Xt&&s===this._sessionStartTimestamp&&(this.Al=this._sessionActivityTimestamp,this.Ml.register({[It]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Ml.flush())}eu(){const[e]=this.tu(),t=ze(e)?e:0,s=ze(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,s)}iu(e){return this.Xl(),this.Nl(e,this.eu())}tu(){const e=this.Ml.props[It];return F(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Al=null,this.ql=void 0,clearTimeout(this.nu),this.nu=void 0,this.Jl(null,null,null)}setBootstrapSessionId(e,t=!1){const s=((i,r=new Date().getTime())=>{try{const n=(o=>{const a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(i);return n>r+6e4?void Et.error("Bootstrap sessionID cannot be in the future"):n}catch(n){return void Et.error("Invalid sessionID in bootstrap",n)}})(e);return!x(s)&&(t?this.ql={sessionId:e,sessionStartTimestamp:s}:this.Jl(e,new Date().getTime(),s),!0)}destroy(){this.Ll=!0,this.Yl(),clearTimeout(this.nu),this.nu=void 0,this.Dl&&b&&(b.removeEventListener(Qs,this.Dl,{capture:!1}),this.Dl=void 0),this.Ol=[]}Vl(){this.Dl=()=>{this.Yl(),this.Wl()&&Y.Pt(this.Ul)},W(b,Qs,this.Dl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,s=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const i=t||new Date().getTime(),r=this.Xt;if(s)this.Fl=i;else if(se(this.Fl)||this.Fl>i||i-this.Fl>=1e3){var n,o;(n=(o=this.Ml).syncCookieProperties)===null||n===void 0||n.call(o),this.Fl=i}let[,a,l]=this.tu();const u=!x(r)&&a!==r,c=this.eu();let h=this.Ql();const d=this.ql,p=!!d&&(d.sessionStartTimestamp>i+6e4||i-d.sessionStartTimestamp>lo),v=d?p:ze(l)&&Math.abs(i-l)>lo;let _=!1,g=u,y=!a||!!d;const m=a;let w=!y&&!e&&this.Nl(i,c);if(w&&(w=this.iu(i),w||Et.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.tu(),w||(y=!a||!!d)),y||w||v){g=!1;const I=d&&!p;a=I?d.sessionId:this.jl(),h=this.Bl(),Et.info("new session ID assigned",{sessionId:a,windowId:h,bootstrapped:!!I,changeReason:{noSessionId:y,activityTimeout:w,sessionPastMaximumLength:v}}),l=I?d.sessionStartTimestamp:i,this.ql=void 0,_=!0}else h||(h=this.Bl(),_=!0),g=g||a!==m,g&&(Et.info("adopted cross-tab session id",{sessionId:a,windowId:h}),_=!0);const E=ze(c)&&e&&!v?c:i,k=ze(l)?l:new Date().getTime();this.Gl(h),this.Jl(a,E,k),e||this.zl();const P={noSessionId:y,activityTimeout:w,sessionPastMaximumLength:v,crossTabAdoption:g};return _&&this.Ol.forEach(I=>I(a,h,P)),{sessionId:a,windowId:h,sessionStartTimestamp:k,changeReason:_?P:void 0,lastActivityTimestamp:c}}zl(){this.Ll||(clearTimeout(this.nu),this.nu=setTimeout(()=>{if(!this.Ll)if(this.iu(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.Rl.emit("forcedIdleReset",{idleSessionId:e})}else this.zl()},1.1*this.sessionTimeoutMs))}};const iu=function(e,t){if(!e)return!1;const s=e.userAgent;if(s&&an(s,t))return!0;try{const i=e?.userAgentData;if(i?.brands&&i.brands.some(r=>an(r?.brand,t)))return!0}catch{}return!!e.webdriver};function ru(){return(ru=X(function*(){const e=he?.userAgentData;if(e?.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),s=t?.model;return D(s)&&s.length>0?s:void 0}catch(t){return void S.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function mh(e,t){let s=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(s=`$survey_${t}/${e.id}/${e.current_iteration}`),s}function nu(e){var t;return!!(!((t=e.conditions)===null||t===void 0||(t=t.events)===null||t===void 0||(t=t.values)===null||t===void 0)&&t.length)}const si=(e,t)=>{if(!(s=>{try{new RegExp(s)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Is=e=>e.toLowerCase(),ou={exact:(e,t)=>t.some(s=>e.some(i=>s===i)),is_not:(e,t)=>t.every(s=>e.every(i=>s!==i)),regex:(e,t)=>t.some(s=>e.some(i=>si(s,i))),not_regex:(e,t)=>t.every(s=>e.every(i=>!si(s,i))),icontains:(e,t)=>t.map(Is).some(s=>e.map(Is).some(i=>s.includes(i))),not_icontains:(e,t)=>t.map(Is).every(s=>e.map(Is).every(i=>!s.includes(i))),gt:(e,t)=>t.some(s=>{const i=parseFloat(s);return!isNaN(i)&&e.some(r=>i>parseFloat(r))}),lt:(e,t)=>t.some(s=>{const i=parseFloat(s);return!isNaN(i)&&e.some(r=>i<parseFloat(r))})};function au(e,t){return!e||Object.entries(e).every(([s,i])=>{const r=t?.[s];if(r==null)return!1;const n=ou[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}function Ni(e,t,s){return Ct({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:s})}const Sr="custom",co="i.posthog.com",yh=/^\/static\//,bh=["/s/","/e/","/i/"];var wh=class{constructor(e){this.su={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"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=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${co}`,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.su[this.apiHost]||(this.su[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":Sr),this.su[this.apiHost]}ru(e){if(!yh.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}ou(e){const t=Je(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}au(e,t,s){if(e==="ui")return s;let i=s;const r=this.instance.config.rewriteRequestPath;if(r){var n;const o=((n=Je(s))===null||n===void 0?void 0:n.href)||s;i=r(new URL(o)).toString()}if(r&&e==="api"&&bh.some(o=>t.indexOf(o)===0)){const o=this.ou(i);if(o){const a=this.apiHost;let l=this.lu;l?.apiHost===a&&l.rewriteRequestPath===r||(l={apiHost:a,rewriteRequestPath:r,urls:new Set},this.lu=l),l.urls.add(o)}}return i}isIngestionEndpoint(e){const t=this.lu,s=this.ou(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&t.urls.has(s)}endpointFor(e,t=""){if(t&&(t=t[0]==="/"?t:`/${t}`),e==="ui")return this.au(e,t,this.uiHost+t);if(e==="flags")return this.au(e,t,this.flagsApiHost+t);if(e==="assets"){const i=this.ru(t);if(i)return this.au(e,t,`${i}${t}`)}if(this.region===Sr)return this.au(e,t,this.apiHost+t);const s=co+t;switch(e){case"assets":return this.au(e,t,`https://${this.region}-assets.${s}`);case"api":return this.au(e,t,`https://${this.region}.${s}`)}}};const G=ee("[Surveys]"),lu=e=>{try{const t=(s=>((i,r)=>`seenSurvey_${(function(n){return n.current_iteration&&n.current_iteration>0?`${n.id}_${n.current_iteration}`:n.id})(r)}`)(0,s))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(t){G.error("Failed to persist survey seen state",t)}},xh=[Fi.Popover,Fi.Widget,Fi.API],kh={ignoreConditions:!1,ignoreDelay:!1,displayType:wr.Popover},$h=ee("[PostHog ExternalIntegrations]"),Eh={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Sh=class{constructor(e){this._instance=e}Ho(e,t){var s,i;(s=T.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,e,r=>{if(r)return $h.error("failed to load script",r);t()})}startIfEnabledOrStop(){var e;for(const[r,n]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var t,s,i;n&&!(!((t=T.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[r])&&this.Ho(Eh[r],()=>{var o;(o=T.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[r])===null||o===void 0||o.start(this._instance)}),!n&&(!((s=T.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[r])&&((i=T.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[r])===null||i===void 0||i.stop())}}};const uu="autocapture",cu="featureFlags",du="logs",hu="surveys";var Ph=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if(typeof e=="string")return t?.get_property(e);const s={};for(const i of e){const r=t?.get_property(i);x(r)||(s[i]=r)}return s}set(e,t){var s;(s=this._instance.persistence)===null||s===void 0||s.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)===null||t===void 0||t.unregister(e)}},Mh=class{constructor(e){this.instance=e,this.A=S,this.kv=new Ph(e),this.onEvent=t=>Ai(this.instance._addCaptureHook((s,i)=>{if(i)try{t({event:s,properties:i.properties})}catch(r){this.A.error("Browser extension event listener failed",r)}})),this.onRemoteConfig=t=>{const s=r=>{try{t(r)}catch(n){this.A.error("Browser extension remote config listener failed",n)}},i=this.instance.uu.on("extensionsRemoteConfig",s);return this.instance.cu&&s(this.instance.cu),Ai(i)}}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){const e=this.instance.get_property(Lr);return typeof e=="string"?e:void 0}get library(){return{name:ke.LIB_NAME,version:ke.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)===null||t===void 0?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,s,i,r;const n=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=n?.sessionId)!==null&&t!==void 0?t:"",windowId:(s=n?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=n?.sessionStartTimestamp)!==null&&i!==void 0?i:0,lastActivityTimestamp:(r=n?.lastActivityTimestamp)!==null&&r!==void 0?r:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return oe(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case cu:case"featureFlagsCommon":t=this.instance.featureFlags;break;case du:t=this.instance.logs;break;case hu:t=this.instance.surveys;break;case uu:t=this.instance.autocapture}return t}capture(e,t,s){s?this.instance.capture(e,t,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):this.instance.capture(e,t)}registerDynamicEventProperties(e){return Ai(this.instance.hu(e))}sendRequest(e){var t=this;return X(function*(s,i={}){var r;const n=(r=i.target)!==null&&r!==void 0?r:"api",o=t.instance.requestRouter.endpointFor(n,s),a=n==="api"&&s==="/i/v1/logs",l={method:i.method,url:i.query?ks(o,i.query):o,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?Yi.Base64:void 0,timestampMode:i.sentAt};return a&&(l.batchKey="logs"),i.transport==="sendBeacon"?(t.instance._send_request(l),{statusCode:202}):new Promise(u=>{l.callback=u,t.instance._send_request(l)})}).apply(this,arguments)}};const hs={};let ji=0;const ps=()=>{},ho='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',St="Surveys module not available",po="sanitize_properties is deprecated. Use before_send instead",pu="Invalid value for property_denylist config: ",Ih=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],Oh=["$feature_flag_called","$$heatmap","$snapshot"],fo=e=>e.charAt(0)==="$"&&!A(Oh,e),Fh=/^[A-Za-z0-9_-]{1,400}$/,vo=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,go=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Ch=["token","distinct_id",il],is="posthog",Ah=e=>{const t={};return e&&e!=="unset"&&("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},qi=e=>{var t;return f({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Id($?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:ps,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Q&&D(Q?.search)&&Q.search.indexOf("__posthog_debug=true")!==-1||!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:(b==null||(t=b.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(s){S.error("Bad HTTP status: "+s.statusCode+" "+s.text)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:pl,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:ps},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:Jr,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:Ah(s),external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:s&&s>="2026-05-30"?250:0,split_storage:!(!s||"2026-05-30">s),detect_google_search_app:!(!s||"2026-05-30">s),disable_capture_url_hashes:!(!s||"2026-06-25">s),cookieWinsOnConflict:!(!s||s==="unset"||"2026-08-29">s)}))(e))},Th=[["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"]],_o=e=>{const t={};for(const[r,n]of Th)x(e[r])||(t[n]=e[r]);const s=Z({},t,e),i=e.__preview_external_dependency_versioned_paths;return x(i)||(x(e.strict_script_versioning)&&(s.strict_script_versioning=!!i),D(i)&&x(e.asset_host)&&(s.asset_host=i)),F(e.property_blacklist)&&(x(e.property_denylist)?s.property_denylist=e.property_blacklist:F(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:S.error(pu+e.property_denylist)),s};var Rh=class{constructor(){this.__forceAllowLocalhost=!1}get du(){return this.__forceAllowLocalhost}set du(e){S.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},fs=class et{vu(t){if(!t)return;const s=this.fu.indexOf(t);s!==-1&&this.fu.splice(s,1)}pu(t,s){var i;return this.vu(t),this.fu.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}gu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}mu(){if(this.yu||this.config.reuseAnonymousId||this.config.segment||this.gu())return;const t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this.bu)return;let s,i,r;t?(s=`persistence is set to '${this.config.persistence}'`,i=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",r="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(s="persistence is disabled (disable_persistence is true)",i="on every page load",r="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.yu=!0,console.warn("[PostHog.js]",`${s} 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. ${r}`)}_u(){const t=this.persistence;if(!t||this.wu)return;if(this.gu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.ku(),this.Su()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.xu()||t.load(!0);const s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){const i=this.config.get_device_id(Te());this.register({distinct_id:i,$device_id:i}),t.set_property(be,Ue)}this.ku()}get decideEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.$u=!1,this.Cu=!1,this.webPerformance=new Rh,this.Tu=!1,this.version=ke.LIB_VERSION,this.Iu=new Set,this.Mu="",this.uu=new ti,this.fu=[],this.Eu=[],this.Pu=!1,this.bu=!1,this.yu=!1,this.wu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=qi(),this.SentryIntegration=Gd,this.sentryIntegration=i=>(function(r,n){const o=Pl(r,n);return{name:Sl,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ru=!1,this.Au=null,this.Fu=null,this.Ou=null,this.scrollManager=new gh(this),this.pageViewManager=new Yn(this),this.rateLimiter=new ih(this),this.requestRouter=new wh(this),this.consent=new Ld(this),this.externalIntegrations=new Sh(this);const s=(t=et.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(i,r,n)=>{const o=D(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{const o=D(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",i=>S.info(`send "${i?.event}"`,i))}init(t,s,i){if(i&&i!==is){var r;const n=(r=hs[i])!==null&&r!==void 0?r:new et;return n._init(t,s,i),hs[i]=n,hs[is][i]=n,n}return this._init(t,s,i)}_init(t,s={},i){var r,n,o;const a=D(t)?t.trim():"";if(!a)return S.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!==((l=this.config)===null||l===void 0?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=qi(s.defaults),s.debug=this.Du(s.debug),this.Lu=s,this.Nu=[],s.person_profiles?this.Fu=s.person_profiles:s.process_person&&(this.Fu=s.process_person);const u=qi(s.defaults),c=_o(s),h=Z({},u,c,{name:i,token:a});L(u.rageclick)&&L(c.rageclick)&&(h.rageclick=Z({},u.rageclick,c.rageclick)),L(u.session_recording)&&L(c.session_recording)&&(h.session_recording=Z({},u.session_recording,c.session_recording)),this.set_config(h),this.config.on_xhr_error&&S.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Pe.GZipJS;const d=this.xu(),p=!this.gu();if(this.persistence=new Oi(this.config,d,!0,p),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Oi(f(f({},this.config),{},{persistence:"sessionStorage"}),d,!1,p),this.Mu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&Y.At()){const m=Y.Dt(this.Mu);F(m)&&m.forEach(w=>{D(w)&&this.Iu.add(w)})}else Y.Pt(this.Mu);const v=f({},this.persistence.props),_=f({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.qu=new ph((m,w)=>this.ju(m,w),this.config.request_queue_config),this.Bu=new vh(this),this.__request_queue=[];const g=this.gu();g||(this.sessionManager=new uo(this),this.sessionPropsManager=new ao(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((m,w,E)=>{(E?.activityTimeout||E?.sessionPastMaximumLength||E?.crossTabAdoption)&&this.zu()})),this.Hu(),this.config.__preview_deferred_init_extensions?(S.info("Deferring extension initialization to improve startup performance"),this.Uu=setTimeout(()=>{this.Uu=void 0,this.Wu(g)},0)):(S.info("Initializing extensions synchronously"),this.Wu(g)),ke.DEBUG=ke.DEBUG||this.config.debug,ke.DEBUG&&S.info("Starting in debug mode",{this:this,config:s,thisC:f({},this.config),p:v,s:_}),this.config.identity_distinct_id&&!(!((r=s.bootstrap)===null||r===void 0)&&r.distinctID)&&(s.bootstrap=f(f({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const y=(n=s.bootstrap)===null||n===void 0?void 0:n.distinctID;if(this.bu=!!y&&!rs(y),(o=s.bootstrap)===null||o===void 0?void 0:o.distinctID){const m=s.bootstrap.distinctID,w=this.get_distinct_id(),E=this.persistence.get_property(be);if(s.bootstrap.isIdentifiedID&&w!=null&&w!==m&&E==="anonymous")this.identify(m);else if(s.bootstrap.isIdentifiedID&&w!=null&&w!==m&&E==="identified")S.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 k=this.config.get_device_id(Te()),P=s.bootstrap.isIdentifiedID?k:m;this.persistence.set_property(be,s.bootstrap.isIdentifiedID?Rs:Ue),this.register({distinct_id:m,$device_id:P})}}if(g)this.register_once({distinct_id:wi,$device_id:null},"");else if(!this.get_distinct_id()){const m=this.config.get_device_id(Te());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(be,Ue)}return W(b,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),W(b,"pageshow",()=>{var m;this.$u=!1,this.Cu||(m=this.Bu)===null||m===void 0||m.resume()}),s.segment?Qn(this,()=>this.Vu()):this.Vu(),oe(this.config._onCapture)&&this.config._onCapture!==ps&&(S.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",m=>this.config._onCapture(m.event,m))),this.config.ip&&S.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 ru.apply(this,arguments)})().then(m=>{m&&this.register({[bi]:m})}).catch(ps),this}Gu(t){const s=t;return D(s.name)&&oe(s.setup)}Qu(t,s){var i=this;this.Gu(t)?s.push(X(function*(){try{yield t.setup(i.Zu())}catch(n){S.error(`Failed to set up extension "${t.name}"`,n);try{var r;yield(r=t.dispose)===null||r===void 0?void 0:r.call(t)}catch(o){S.error(`Failed to dispose extension "${t.name}"`,o)}}})):this.fu.push(t)}Hu(){var t,s,i,r=this;const n=(t=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&t!==void 0?t:(i=et.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var o,a,l;if(n)if(this.featureFlags&&this.featureFlags instanceof n||((o=this.Ju)===null||o===void 0||o.call(this),this.Ju=void 0,this.featureFlags=new n(this)),oe(this.featureFlags.onReloading)&&oe(this.featureFlags.setup)){if(!this.Ju){this.Ju=this.featureFlags.onReloading(()=>{this.uu.emit("featureFlagsReloading",!0)});const u=this.featureFlags;X(function*(){try{yield u.setup(r.Zu())}catch(c){S.error("Failed to set up feature flags",c);const h=r.Ju;r.Ju=void 0;try{h?.()}catch(d){S.error("Failed to unsubscribe feature flag reloading",d)}try{yield u.dispose()}catch(d){S.error("Failed to dispose feature flags",d)}}})()}}else(a=(l=this.featureFlags).initialize)===null||a===void 0||a.call(l)}Wu(t){const s=performance.now(),i=f(f({},et.__defaultExtensionClasses),this.config.__extensionClasses),r=[];var n,o,a,l,u,c,h,d;i.exceptions&&this.fu.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new i.exceptions(this)),i.historyAutocapture&&this.fu.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.fu.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.fu.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!t&&this.fu.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.Qu(this.autocapture=new i.autocapture(this),r),i.surveys&&this.Qu(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),r),i.logs&&this.Qu(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),r),i.metrics&&this.fu.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.fu.push(this.conversations=(u=this.conversations)!==null&&u!==void 0?u:new i.conversations(this)),i.productTours&&this.fu.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.fu.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.fu.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.fu.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.fu.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,Ud)),i.toolbar&&this.fu.push(this.toolbar=(c=this.toolbar)!==null&&c!==void 0?c:new i.toolbar(this)),i.experiments&&this.fu.push(this.experiments=(h=this.experiments)!==null&&h!==void 0?h:new i.experiments(this)),i.webMCP&&this.fu.push(this.webMCP=(d=this.webMCP)!==null&&d!==void 0?d:new i.webMCP(this)),this.fu.forEach(p=>{p.initialize&&r.push(()=>{var v;(v=p.initialize)===null||v===void 0||v.call(p)})}),r.push(()=>{if(this.Ku){const p=this.Ku;this.Ku=void 0,this.fu.forEach(v=>{var _;return(_=v.onRemoteConfig)===null||_===void 0?void 0:_.call(v,p)})}}),this.Xu(r,s)}Xu(t,s){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&t.length>0)return void(this.Uu=setTimeout(()=>{this.Uu=void 0,this.Xu(t,s)},0));const r=t.shift();if(r)try{r()}catch(n){S.error("Error initializing extension:",n)}}const i=Math.round(performance.now()-s);this.register_for_session({[rl]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[nl]:i}),this.config.__preview_deferred_init_extensions&&S.info(`PostHog extensions initialized (${i}ms)`)}il(t){if(!$||!$.body)return S.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.il(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ku=t),this.cu=t,this.compression=void 0,t.ok){var s;const i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=A(i.supportedCompression,Pe.GZipJS)?Pe.GZipJS:A(i.supportedCompression,Pe.Base64)?Pe.Base64:void 0),!((s=i.analytics)===null||s===void 0)&&s.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Fu?this.Fu:pl}),this.uu.emit("extensionsRemoteConfig",t),this.fu.forEach(i=>{var r;return(r=i.onRemoteConfig)===null||r===void 0?void 0:r.call(i,t)})}Vu(){try{this.config.loaded(this)}catch(t){S.critical("`loaded` function failed",t)}if(this.Yu(),this.config.internal_or_test_user_hostname&&Q?.hostname){const t=Q.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?t===s:s.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.gu())&&this.tc()},1),this.ec=new ql(this),this.ec.load()}Yu(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.qu)===null||t===void 0||t.enable())}_dom_loaded(){this.is_capturing()&&Ft(this.__request_queue,t=>this.ju(t)),this.__request_queue=[],this.Yu()}_handle_unload(){var t,s,i,r,n,o;this.$u=!0,(t=this.surveys)===null||t===void 0||(s=t.handlePageUnload)===null||s===void 0||s.call(t),(i=this.metrics)===null||i===void 0||i.flush("sendBeacon"),this.config.request_batching?(this.nc()&&this.capture(An),(r=this.logs)===null||r===void 0||r.flushLogs("sendBeacon"),(n=this.qu)===null||n===void 0||n.unload(),(o=this.Bu)===null||o===void 0||o.unload()):this.nc()&&this.capture(An,null,{transport:"sendBeacon"})}_send_request(t){su(this,t)}ju(t,s){this.Bu?this.Bu.retriableRequest(t,s):this._send_request(s?f(f({},t),{},{transport:s}):t)}_execute_array(t){ji++;try{let s;const i=[],r=[],n=[];Ft(t,a=>{if(a)if(s=a[0],F(s))n.push(a);else if(oe(a))try{a.call(this)}catch(l){S.error("Error executing queued PostHog call",a,l)}else F(a)&&s==="alias"?i.push(a):F(a)&&s.indexOf("capture")!==-1&&oe(this[s])?n.push(a):r.push(a)});const o=function(a,l){Ft(a,function(u){try{if(F(u[0])){let c=l;J(u,function(h){c=c[h[0]].apply(c,h.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(c){S.error("Error executing queued PostHog call",u,c)}})};o(i,this),o(r,this),o(n,this)}finally{ji--}}push(t){if(ji>0&&F(t)&&D(t[0])){const s=et.prototype[t[0]];return void(oe(s)&&s.apply(this,t.slice(1)))}this._execute_array([t])}get sc(){return{property:Fn,persistenceKey:Tt,cookieName:"_fbc",pattern:vo,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[Tt]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Tt)}}}get rc(){return{property:Cn,persistenceKey:as,cookieName:"_fbp",pattern:go,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[as]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(as)}}}oc(t){var s;const i=(s=this.persistence)===null||s===void 0?void 0:s.get_property(t.persistenceKey);return D(i)&&t.pattern.test(i)?{value:i,delivered:!1}:L(i)&&D(i.value)&&t.pattern.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}ac(t,s,i){return s===i?.value?{value:s,pending:!i.delivered}:(t.register(s,!1),{value:s,pending:!0})}lc(t){if(!this.config.save_campaign_params||this.gu())return;const s=us(t.cookieName);return D(s)&&t.pattern.test(s)?s:void 0}uc(t,s,i,r){if(!this.persistence)return;const n=this.sc;this.persistence.refreshKey(n.persistenceKey);const o=this.oc(n);if(r)return void n.unregister();if(i)return D(s)&&vo.test(s)?this.ac(n,s,o):void n.unregister();const a=D(t)&&Fh.test(t)?t:void 0,l=this.lc(n);return l&&((u,c,h)=>{const d=u.split(".");if(c)return d[3]===c;if(!h)return!0;const p=h.value.split(".");return d[3]===p[3]||Number(d[2])>Number(p[2])})(l,a,o)?this.ac(n,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.ac(n,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}cc(t,s,i){if(!this.persistence)return;const r=this.rc;this.persistence.refreshKey(r.persistenceKey);const n=this.oc(r);if(i)return void r.unregister();if(s)return D(t)&&go.test(t)?this.ac(r,t,n):void r.unregister();const o=this.lc(r);return o?this.ac(r,o,n):n?{value:n.value,pending:!n.delivered}:void 0}hc(t,s){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const i=this.oc(t);i?.value!==s||i.delivered||t.register(s,!0)}capture(t,s,i){var r,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.qu))return void S.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(x(t)||!D(t))return void S.error("No event name provided to posthog.capture");if(this._u(),t==="$snapshot"&&this.gu())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return;const a=i?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void S.critical("This capture call is ignored due to client rate limiting.");let l;s?.$current_url&&!D(s?.$current_url)&&(S.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),t!=="$exception"||i?.dc||S.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const u=new Date,c=i?.timestamp||u,h=dn(i?.uuid,Te);let d={uuid:h,event:t,properties:this.calculateEventProperties(t,s||{},c,h)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),a&&(d.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const p=t==="$feature_flag_called"&&d.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i?.$set&&!p&&(d.$set=i?.$set);const v=L(s?.$set)?s.$set:void 0,_=F(s?.$unset)?s.$unset:[],g=i?.$unset||[],y=C=>{var j;const N=!!i?.$set&&C in i.$set;return{hasProvided:N||!!v&&C in v,provided:N?i==null||(j=i.$set)===null||j===void 0?void 0:j[C]:v?.[C],unset:_.indexOf(C)!==-1||g.indexOf(C)!==-1}},m=y(Fn),w=y(Cn),E=[{channel:this.sc,hasProvided:m.hasProvided,update:this.uc(l?.fbclid,m.provided,m.hasProvided,m.unset)},{channel:this.rc,hasProvided:w.hasProvided,update:this.cc(w.provided,w.hasProvided,w.unset)}];for(const{channel:C,hasProvided:j,update:N}of E)N&&d.properties.$process_person_profile===!0&&N.pending&&!j&&!p&&(d.$set=f({[C.property]:N.value},d.$set));const k=i?.$unset;k&&(d.$unset=k);const P=p?void 0:this.vc(i?.$set_once,t!==Tn,t===fl);if(P&&(d.$set_once=P),i?._noTruncate||(I=this.config.properties_string_max_length,d=(function(C,j){const N=new Set;return(function U(V,re){if(V!==Object(V))return j?j(V):V;if(N.has(V))return;let ue;if(N.add(V),F(V))ue=[],Ft(V,ae=>{ue.push(U(ae))});else{const ae={};J(Vt(V)?vl(V):V,(Me,ge)=>{N.has(Me)||(ae[ge]=U(Me))}),ue=ae}return ue})(C)})(d,C=>D(C)?C.slice(0,I):C)),d.timestamp=c,x(i?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=u),p&&(d.properties=((C,j=[])=>{const N={},U=V=>{C[V]!==void 0&&(N[V]=C[V])};return bc.forEach(U),j.forEach(U),N})(d.properties,Ch)),t===Se.DISMISSED||t===Se.SENT){const C=s?.[Ci.SURVEY_ID],j=s?.[Ci.SURVEY_ITERATION];lu({id:C,current_iteration:j}),d.$set=f(f({},d.$set),{},{[mh({id:C,current_iteration:j},t===Se.SENT?"responded":"dismissed")]:!0})}else t===Se.SHOWN&&(d.$set=f(f({},d.$set),{},{[Ci.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var I;if(t===sh.SHOWN){const C=s?.[eo.TOUR_TYPE];C&&(d.$set=f(f({},d.$set),{},{[`${eo.TOUR_LAST_SEEN_DATE}/${C}`]:new Date().toISOString()}))}const M=f(f({},d.properties.$set),d.$set);if($e(M)||this.setPersonPropertiesForFlags(M),!R(this.config.before_send)){const C=this.Os(d);if(!C)return;d=C,d.uuid=dn(d.uuid,Te)}this.sessionRecording&&!this.Pu&&fo(t)&&(this.Pu=!0,setTimeout(()=>this.Pu=!1,3e4));const O=E.filter(({channel:C,update:j})=>{var N,U,V;const re=(N=(U=d.$set)===null||U===void 0?void 0:U[C.property])!==null&&N!==void 0?N:L((V=d.properties)===null||V===void 0?void 0:V.$set)?d.properties.$set[C.property]:void 0;return j?.pending&&re===j.value});this.uu.emit("eventCaptured",d);const q=(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),B=i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(q),z=f(f(f({method:"POST",url:q,data:d,compression:"best-available",preferSyncCompression:i?.send_instantly,timestampMode:B?"body":"capture-body",batchKey:i?._batchKey},B&&(!((n=d.properties)===null||n===void 0)&&n.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),i?.transport?{transport:i.transport}:{}),O.length?{fireCallbackOnDrop:!0,callback:C=>{if(C.statusCode>=200&&300>C.statusCode)for(const{channel:j,update:N}of O)this.hc(j,N.value)}}:{});if(!this.config.request_batching||i&&!i?._batchKey||i?.send_instantly){var K;let C;!z.transport&&!z.callback&&$e((K=this.config.request_headers)!==null&&K!==void 0?K:{})&&this.$u&&(C="sendBeacon"),this.ju(z,C)}else this.qu.enqueue(z);return d}_addCaptureHook(t){return this.on("eventCaptured",s=>t(s.event,s))}getExtension(t){var s;return(s=this.fc)===null||s===void 0?void 0:s.getExtension(t)}Zu(){var t;return(t=this.fc)!==null&&t!==void 0?t:this.fc=new Mh(this)}hu(t){this.Eu.push(t);let s=!0;return()=>{if(!s)return;s=!1;const i=this.Eu.indexOf(t);i!==-1&&this.Eu.splice(i,1)}}gc(t=!0){var s,i,r;return!!(!((s=this.persistence)===null||s===void 0)&&s.consumeCookieIdentityChange())&&(this.Ou=null,this.persistence.get_property("$user_state")==="anonymous"&&((r=this.sessionPersistence)===null||r===void 0||r.clear(),this.Iu.clear(),this.mc()),(i=this.featureFlags)===null||i===void 0||i.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,s,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this._u(),this.persistence.syncCookieProperties(),this.gc();const o=n?void 0:this.persistence.remove_event_timer(t);let a=f({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.gu()&&(a[il]=!0),t==="$snapshot"){const m=f(f({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=m.distinct_id,(!D(a.distinct_id)&&!ne(a.distinct_id)||rs(a.distinct_id))&&S.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=(function(m,w,E,k=!1){var P,I,M,O;if(!ye)return{};const q=m?[...Ht,...w||[]]:[],[B,z]=ma(ye),[K,C]=(function(de){for(let _e=0;cn.length>_e;_e++){const[Ke,yt,xe]=cn[_e],Le=de.match(Ke);if(Le){const at=xe&&de.match(xe)||Le;return[yt,at?.[1]||""]}}return["",""]})(ye),j=(function(){const de="u">typeof navigator?navigator:void 0;return de?.brave?{brave:!0}:{}})(),N={};x(E)||(N.detectGoogleSearchApp=E);const U={},V=(P=navigator)===null||P===void 0||(P=P.userAgentData)===null||P===void 0?void 0:P.platform,re=(I=navigator)===null||I===void 0?void 0:I.maxTouchPoints,ue=b==null||(M=b.screen)===null||M===void 0?void 0:M.width,ae=b==null||(O=b.screen)===null||O===void 0?void 0:O.height,Me=b?.devicePixelRatio;x(V)||(U.userAgentDataPlatform=V),x(re)||(U.maxTouchPoints=re),x(ue)||(U.screenWidth=ue),x(ae)||(U.screenHeight=ae),x(Me)||(U.devicePixelRatio=Me);const ge=Z(Vr({$os:B,$os_version:z,$browser:_a(ye,navigator.vendor,j,N),$webview_app:K,$webview_app_version:C,$device:ya(ye),$device_type:Bu(ye,U),$timezone:Ml(),$timezone_offset:Zd()}),{$current_url:bs(k?ot(Q?.href):Q?.href,q,ws),$host:Q?.host,$pathname:Q?.pathname,$raw_user_agent:ye.length>1e3?ye.substring(0,997)+"...":ye,$browser_version:Hu(ye,navigator.vendor,j,N),$browser_language:Rl(),$browser_language_prefix:Xd(),$screen_height:b?.screen.height,$screen_width:b?.screen.width,$viewport_height:b?.innerHeight,$viewport_width:b?.innerWidth,$lib:Ge.LIB_NAME,$lib_version:Ge.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ge.SDK_DIST_CHANNEL&&(ge.$sdk_dist_channel=Ge.SDK_DIST_CHANNEL),ge})(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:m,windowId:w}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0);a.$session_id=m,a.$window_id=w}this.sessionPropsManager&&Z(a,this.sessionPropsManager.getSessionProps());try{var u;if(this.sessionRecording){const m=this.sessionRecording.sdkDebugProperties,w=!this.Pu&&fo(t);for(const E in m)(w||A(Ih,E))&&(a[E]=m[E])}a.$sdk_debug_retry_queue_size=(u=this.Bu)===null||u===void 0?void 0:u.length}catch(m){a.$sdk_debug_error_capturing_properties=String(m)}let c;if(this.requestRouter.region===Sr&&(a.$lib_custom_api_host=this.config.api_host),c=t!=="$pageview"||n?t!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=Z(a,c),t==="$pageview"&&$&&(a.title=$.title),!x(o)){const m=i.getTime()-o;a.$duration=parseFloat((m/1e3).toFixed(3))}ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const h=this.persistence.properties(),d=this.sessionPersistence.properties(),p=a.$groups,v=h.$groups;L(p)&&!$e(p)&&(a.$groups=f(f({},L(v)?v:{}),p)),J(["$referrer","$referring_domain"],m=>{m in h&&delete d[m]});const _={};if(this.Eu.length>0)for(const m of this.Eu.slice())try{Z(_,m())}catch(w){S.error("Failed to produce browser extension event properties",w)}a=Z({},l,h,d,f(f({},_),a)),a.$is_identified=this._isIdentified(),F(this.config.property_denylist)?J(this.config.property_denylist,function(m){delete a[m]}):S.error(pu+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const g=this.config.sanitize_properties;g&&(S.error(po),a=g(a,t));const y=this.yc();return a.$process_person_profile=y,y&&!n&&this.bc("_calculate_event_properties"),a}vc(t,s=!0,i=!1){var r;if(!this.persistence||!this.yc()||this.Tu&&!i)return t;const n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)===null||r===void 0?void 0:r.getSetOnceProps();let a=Z({},n,o||{},t||{});const l=this.config.sanitize_properties;return l&&(S.error(po),a=l(a,"$set_once")),s&&(this.Tu=!0),$e(a)?void 0:a}register(t,s){var i;(i=this.persistence)===null||i===void 0||i.register(t,s)}register_once(t,s,i){var r;(r=this.persistence)===null||r===void 0||r.register_once(t,s,i)}register_for_session(t){var s,i;(s=this.persistence)===null||s===void 0||s.syncCookieProperties(),this.gc(),(i=this.sessionPersistence)===null||i===void 0||i.register(t),Object.keys(t).forEach(r=>this.Iu.add(r)),this.mc()}unregister(t){var s;(s=this.persistence)===null||s===void 0||s.unregister(t)}unregister_for_session(t){var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t),this.Iu.delete(t),this.mc()}_c(t,s){this.register({[t]:s})}zu(){this.Iu.forEach(t=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t)}),this.Iu.clear(),this.mc()}mc(){var t;if(!this.Mu)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.hi||!Y.At())return void Y.Pt(this.Mu);const s=[];this.Iu.forEach(i=>s.push(i)),s.length>0?Y.$t(this.Mu,s):Y.Pt(this.Mu)}getFeatureFlag(t,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlag(t,s)}getFeatureFlagPayload(t){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlagPayload(t)}getFeatureFlagResult(t,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlagResult(t,s)}getAllFeatureFlags(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,s){var i,r;return(i=(r=this.featureFlags)===null||r===void 0?void 0:r.isFeatureEnabled(t,s))!==null&&i!==void 0?i:s?.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)===null||t===void 0||t.reloadFeatureFlags()}updateFlags(t,s,i){var r;(r=this.featureFlags)===null||r===void 0||r.updateFlags(t,s,i)}updateEarlyAccessFeatureEnrollment(t,s,i){var r;(r=this.featureFlags)===null||r===void 0||r.updateEarlyAccessFeatureEnrollment(t,s,i)}getEarlyAccessFeatures(t,s=!1,i){var r;return(r=this.featureFlags)===null||r===void 0?void 0:r.getEarlyAccessFeatures(t,s,i)}on(t,s){return this.uu.on(t,s)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:St}),()=>{})}onSessionId(t){var s,i;return(s=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(t))!==null&&s!==void 0?s:()=>{}}getSurveys(t,s=!1){this.surveys?this.surveys.getSurveys(t,s):t([],{isLoaded:!1,error:St})}getActiveMatchingSurveys(t,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,s):t([],{isLoaded:!1,error:St})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:St}),()=>{})}renderSurvey(t,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(t,s)}displaySurvey(t,s=kh){var i;(i=this.surveys)===null||i===void 0||i.displaySurvey(t,s)}cancelPendingSurvey(t){var s;(s=this.surveys)===null||s===void 0||s.cancelPendingSurvey(t)}canRenderSurvey(t){var s,i;return(s=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurvey(t))!==null&&s!==void 0?s:{visible:!1,disabledReason:St}}canRenderSurveyAsync(t,s=!1){var i,r;return(i=(r=this.surveys)===null||r===void 0?void 0:r.canRenderSurveyAsync(t,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:St})}wc(t){return!t||rs(t)?(S.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(S.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(S.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,s,i){if(!this.__loaded||!this.persistence)return S.uninitializedWarning("posthog.identify");if(ne(t)&&(t=t.toString(),S.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.wc(t)||!this.bc("posthog.identify"))return;this._u();const r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.gc(!1),a=this.persistence.Da();let l=!1;try{const c=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:c},""),t!==c&&t!==this.get_property("__alias")&&(this.unregister(Js),this.register({distinct_id:t}));const h=(this.persistence.get_property("$user_state")||"anonymous")===Ue,d=t!==c,p=!d&&h;if(d&&h){var u;const v=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:c};this.persistence.set_property(be,Rs),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.La(),this.capture("$identify",v,{$set:s||{},$set_once:i||{}})&&(this.Ou=Ni(t,s,i)),(u=this.featureFlags)===null||u===void 0||u.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:c)}else if(p){this.persistence.set_property(be,Rs);const v=s||{},_=i||{};this.setPersonPropertiesForFlags({$set:v,$set_once:_},!1),this.config.cookieWinsOnConflict&&this.persistence.La(),this.capture("$set",{$set:v,$set_once:_})&&(this.Ou=Ni(t,s,i))}else(s||i)&&this.setPersonProperties(s,i);d||n||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(it)):p&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.ja(l)}}setPersonProperties(t,s){if(!t&&!s||!this.bc("posthog.setPersonProperties"))return;const i=Ni(this.get_distinct_id(),t,s);this.Ou!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:s||{}},!0),this.capture("$set",{$set:t||{},$set_once:s||{}})&&(this.Ou=i)):S.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var s;const i=(F(t)?t:[t]).filter(r=>D(r)&&r.length>0);i.length!==0&&this.bc("posthog.unsetPersonProperties")&&((s=this.featureFlags)===null||s===void 0||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Ou=null)}group(t,s,i){var r;if(!t||!s)return void S.error("posthog.group requires a group type and group key");(r=this.persistence)===null||r===void 0||r.syncCookieProperties(),this.gc();const n=this.getGroups(),o=n[t]!==s;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:f(f({},n),{},{[t]:s})}),(o||i)&&this.yc()){const a={$group_type:t,$group_key:s};i&&(a.$group_set=i),this.capture(Tn,a)}i&&this.setGroupPropertiesForFlags({[t]:i}),o&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,s=!0){var i;(i=this.featureFlags)===null||i===void 0||i.setPersonPropertiesForFlags(t,s)}resetPersonPropertiesForFlags(t=!0){var s;(s=this.featureFlags)===null||s===void 0||s.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,s=!0){var i;this.bc("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)===null||i===void 0||i.setGroupPropertiesForFlags(t,s))}resetGroupPropertiesForFlags(t){var s;(s=this.featureFlags)===null||s===void 0||s.resetGroupPropertiesForFlags(t)}reset(t){const s=we(t)?t:t?.resetDeviceID,i=we(t)||t==null?void 0:t.bootstrap;this.kc(s,!1,i)}kc(t,s=!1,i){var r,n,o,a,l,u;if(S.info("reset"),!this.__loaded)return S.uninitializedWarning("posthog.reset");const c=i?.sessionID;this.config.bootstrap=i||((r=this.Lu)===null||r===void 0?void 0:r.bootstrap)||{},(n=this.featureFlags)===null||n===void 0||(o=n.updateConfig)===null||o===void 0||o.call(n,this.config,this.nl());const h=this.get_property(Lr),d=this.get_property(bi),p=this.get_property(ls);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const v=this.is_capturing();s||this.consent.reset(),s||!v||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 _=(l=this.persistence)===null||l===void 0||(u=l.Da)===null||u===void 0?void 0:u.call(l),g=this.wu;this.wu=g||s;let y=!1;try{var m,w,E,k,P,I,M,O,q,B,z,K,C;if((m=this.persistence)===null||m===void 0||m.clear(),(w=this.sessionPersistence)===null||w===void 0||w.clear(),this.Iu.clear(),this.mc(),x(p)||(B=this.persistence)===null||B===void 0||B.register({$session_recording_remote_config:p}),(E=this.surveys)===null||E===void 0||E.reset(),(k=this.featureFlags)===null||k===void 0||k.reset(),(P=this.conversations)===null||P===void 0||P.reset(),(I=this.logs)===null||I===void 0||I.reset(),(M=this.metrics)===null||M===void 0||M.reset(),(O=this.persistence)===null||O===void 0||O.set_property("$user_state","anonymous"),(q=this.sessionManager)===null||q===void 0||q.resetSessionId(),this.Ou=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:wi,$device_id:null},"");else{const U=this.config.get_device_id(Te());this.register_once({distinct_id:U,$device_id:t?U:h},""),t||x(d)||this.register({[bi]:d})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID&&!this.gu()&&((C=this.persistence)===null||C===void 0||C.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(z=this.featureFlags)===null||z===void 0||z.initialize(),!R(c)&&!(!((K=this.sessionManager)===null||K===void 0)&&K.setBootstrapSessionId(c,!0)))){const U=f({},i);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,y=!0}finally{var j,N;this.wu=g,_&&((j=this.persistence)===null||j===void 0||(N=j.ja)===null||N===void 0||N.call(j,y))}this.reloadFeatureFlags()}shutdown(t){var s=this;return X(function*(){if(!s.__loaded)return void S.uninitializedWarning("posthog.shutdown");s.Cu=!0,clearTimeout(s.Uu),s.Uu=void 0;const i=s.Ju;s.Ju=void 0;for(const r of[()=>{var n;return(n=s.sessionRecording)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.logs)===null||n===void 0?void 0:n.flushLogs("sendBeacon")},()=>{var n;return(n=s.metrics)===null||n===void 0?void 0:n.flush("sendBeacon")},()=>{var n;return(n=s.metrics)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.logs)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.surveys)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.autocapture)===null||n===void 0?void 0:n.dispose()},()=>i?.(),()=>{var n;return(n=s.qu)===null||n===void 0?void 0:n.unload()},()=>{var n;return(n=s.Bu)===null||n===void 0?void 0:n.unload()},()=>{var n;return(n=s.featureFlags)===null||n===void 0?void 0:n.destroy()},()=>{var n;return(n=s.persistence)===null||n===void 0?void 0:n.destroy()},()=>{var n;return(n=s.sessionPersistence)===null||n===void 0?void 0:n.destroy()}])try{const n=r();n&&oe(n.then)&&n.then(void 0,o=>{S.error("Error during shutdown",o)})}catch(n){S.error("Error during shutdown",n)}})()}setIdentity(t,s){var i;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=s,this.alias(t),(i=this.conversations)===null||i===void 0||i.Sc()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(t=this.conversations)===null||t===void 0||t.xc()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,s;return(t=(s=this.sessionManager)===null||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:s,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let r=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${s}`);if(t?.withTimestamp&&i){var n;const o=(n=t.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;r+=`?t=${Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}`}return r}alias(t,s){return t===this.get_property("$people_distinct_id")?(S.critical("Attempting to create alias for existing People user - aborting."),-2):this.bc("posthog.alias")?(x(s)&&(s=this.get_distinct_id()),t!==s?(this._c(Js,t),this.capture("$create_alias",{alias:t,distinct_id:s})):(S.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const s=f({},this.config);if(L(t)){var i,r,n,o,a,l,u,c,h,d,p,v,_,g;Z(this.config,_o(t));const k=this.xu();if(this.persistence){const I=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var y,m;if(I&&this.sessionPersistence!==this.persistence&&((y=this.sessionPersistence)===null||y===void 0||y.remove(),(m=this.sessionPersistence)===null||m===void 0||m.destroy()),this.persistence.update_config(this.config,s,k),I)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new Oi(f(f({},this.config),{},{persistence:"sessionStorage"}),k,!1);else{var w;(w=this.sessionPersistence)===null||w===void 0||w.update_config(f(f({},this.config),{},{persistence:"sessionStorage"}),f(f({},s),{},{persistence:"sessionStorage"}),k)}}const P=this.Du(this.config.debug);var E;we(P)&&(this.config.debug=P),we(this.config.debug)&&(this.config.debug?(ke.DEBUG=!0,H.At()&&H.$t("ph_debug",!0),S.info("set_config",{config:t,oldConfig:s,newConfig:f({},this.config)})):(ke.DEBUG=!1,H.At()&&H.Pt("ph_debug"))),(i=this.featureFlags)===null||i===void 0||(r=i.updateConfig)===null||r===void 0||r.call(i,this.config,this.nl()),(n=this.exceptionObserver)===null||n===void 0||n.onConfigChange(),(o=this.exceptions)===null||o===void 0||o.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(l=this.webMCP)===null||l===void 0||l.startIfEnabled(),(u=this.sessionRecording)===null||u===void 0||u.startIfEnabledOrStop(),(c=this.tracingHeaders)===null||c===void 0||c.startIfEnabledOrStop(),(h=this.autocapture)===null||h===void 0||h.startIfEnabled(),(d=this.heatmaps)===null||d===void 0||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((E=this.historyAutocapture)===null||E===void 0||E.startIfEnabledOrStop()),(p=this.exceptionObserver)===null||p===void 0||p.startIfEnabledOrStop(),(v=this.deadClicksAutocapture)===null||v===void 0||v.startIfEnabledOrStop(),(_=this.surveys)===null||_===void 0||_.loadIfEnabled(),this.ku(),(g=this.externalIntegrations)===null||g===void 0||g.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&Qn(this,ps,!1)}}_overrideSDKInfo(t,s){ke.LIB_NAME=t,ke.LIB_VERSION=s}startSessionRecording(t){const s=t===!0,i={sampling:s||!!t?.sampling,linked_flag:s||!!t?.linked_flag,url_trigger:s||!!t?.url_trigger,event_trigger:s||!!t?.event_trigger};var r,n,o,a,l;Object.values(i).some(Boolean)&&((r=this.sessionManager)===null||r===void 0||r.checkAndGetSessionAndWindowId(),i.sampling&&((n=this.sessionRecording)===null||n===void 0||n.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)===null||o===void 0||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(!((t=this.sessionRecording)===null||t===void 0)&&t.started)}captureException(t,s){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(f(f({},i),s))}catch{return}}addExceptionStep(t,s){var i;(i=this.exceptions)===null||i===void 0||i.addExceptionStep(t,s)}captureLog(t){var s;(s=this.logs)===null||s===void 0||s.captureLog(t)}get logger(){var t,s;return(t=(s=this.logs)===null||s===void 0?void 0:s.logger)!==null&&t!==void 0?t:et.$c}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var s,i;return(s=(i=this.toolbar)===null||i===void 0?void 0:i.loadToolbar(t))!==null&&s!==void 0&&s}get_property(t){var s;return(s=this.persistence)===null||s===void 0?void 0:s.props[t]}getSessionProperty(t){var s;return(s=this.sessionPersistence)===null||s===void 0?void 0:s.props[t]}toString(){var t;let s=(t=this.config.name)!==null&&t!==void 0?t:is;return s!==is&&(s="posthog."+s),s}_isIdentified(){var t,s;return((t=this.persistence)===null||t===void 0?void 0:t.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)===null||s===void 0?void 0:s.get_property("$user_state"))==="identified"}yc(){var t,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&$e(this.getGroups())&&!(!((t=this.persistence)===null||t===void 0||(t=t.props)===null||t===void 0)&&t.__alias)&&!(!((s=this.persistence)===null||s===void 0||(s=s.props)===null||s===void 0)&&s.$epp))}nc(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.yc()||this.bc("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bc("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}bc(t){return this.config.person_profiles==="never"?(S.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.mu(),this._c(jr,!0),!0)}xu(){if(this.config.cookieless_mode==="always")return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}ku(){var t,s;const i=this.xu();var r,n,o;return this.is_capturing()||(r=this.logs)===null||r===void 0||r.Cc(),((t=this.persistence)===null||t===void 0?void 0:t.hi)!==i&&((n=this.persistence)===null||n===void 0||n.set_disabled(i)),((s=this.sessionPersistence)===null||s===void 0?void 0:s.hi)!==i&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(i)),this.mc(),i}opt_in_capturing(t){var s;if(this.config.cookieless_mode!=="always"){if(this.gu()){var i,r,n,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.kc(!0,!0),(r=this.sessionManager)===null||r===void 0||r.destroy(),(n=this.pageViewManager)===null||n===void 0||n.destroy(),this.sessionManager=new uo(this),this.pageViewManager=new Yn(this),this.persistence&&(this.sessionPropsManager=new ao(this,this.sessionManager,this.persistence));const p=(o=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&o!==void 0?o:(l=et.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var u,c;p&&(this.sessionRecording=this.pu(this.sessionRecording,new p(this)),this.cu&&((u=this.sessionRecording)===null||u===void 0||(c=u.onRemoteConfig)===null||c===void 0||c.call(u,this.cu)))}var h,d;this.consent.optInOut(!0),this.ku(),this.Yu(),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((h=this.surveys)===null||h===void 0||h.loadIfEnabled()),(x(t?.captureEventName)||t?.captureEventName)&&this.capture((d=t?.captureEventName)!==null&&d!==void 0?d:"$opt_in",t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.tc()}else S.warn(ho)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.ku(),this.config.cookieless_mode==="on_reject"&&this.Su()):S.warn(ho)}Su(){var t,s;const i=this.sessionRecording;i?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.kc(!0,!0),this.register({distinct_id:wi,$device_id:null}),this.vu(i),this.sessionRecording=void 0,(t=this.sessionManager)===null||t===void 0||t.destroy(),(s=this.pageViewManager)===null||s===void 0||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.tc(),this.Yu()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return!this.wu&&(this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.ku()}_is_bot(){return he?iu(he,this.config.custom_blocked_useragents):void 0}tc(){$&&($.visibilityState==="visible"?this.Ru||(this.Ru=!0,this.capture(zr,{title:$.title},{send_instantly:!0}),this.Au&&($.removeEventListener(ms,this.Au),this.Au=null)):this.Au||(this.Au=this.tc.bind(this),W($,ms,this.Au)))}debug(t){t===!1?(b?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(b?.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}))}nl(){const t=this.Lu||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(S.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(s,i,r,n,o){const a=i in s&&!R(s[i]),l=r in s&&!R(s[r]);return a?s[i]:!!l&&(o&&o.warn(`Config field '${r}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),s[r])})(t,"advanced_disable_flags","advanced_disable_decide",0,S)}Os(t){var s;if(R(this.config.before_send))return t;const i=Object.keys((s=t.properties)!==null&&s!==void 0?s:{}).filter(Ou),r=F(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const o of r)try{if(n=o(n),R(n)){const a=`Event '${t.event}' was rejected in beforeSend function`;return Iu(t.event)?S.warn(`${a}. This can cause unexpected behavior.`):S.info(a),null}n.properties&&!$e(n.properties)||S.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return S.error(`Error in beforeSend function for event '${t.event}':`,a),null}for(const o of i)if(n.properties&&R(n.properties[o]))return S.warn(`Event '${t.event}' had its '${o}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return(t=this.pageViewManager.Vo)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,s){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:s})}captureTraceMetric(t,s,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:s,$ai_metric_value:String(i)})}Du(t){const s=we(t)&&!t,i=H.At()&&H.Ot("ph_debug")==="true";return!s&&(!!i||t)}};fs.__defaultExtensionClasses={},fs.$c=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(let s=0;t.length>s;s++)e.prototype[t[s]]=Pd(e.prototype[t[s]])})(fs,["identify"]);var fu=class{constructor(e){this.disabled=e===!1;const t=L(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,s){if(this.disabled)return!1;const i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&this.timeoutMs>s-i.timestamp){if(this.clicks.push({x:e,y:t,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:s}];return!1}};const Hi="$copy_autocapture",Bi=ee("[AutoCapture]");function zi(e,t){return t.length>e?t.slice(0,e)+"...":t}function Lh(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Re(t));return t}function Dh(e,{e:t,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:r,elementsChainAsString:n,disableCaptureUrlHashes:o}){var a,l;if(!Re(e))return{props:{}};const u=[e],c=new Set([e]);let h=e;for(;h.parentNode&&!pe(h,"body")&&1e3>u.length;){if(Wr(h.parentNode)){const P=h.parentNode.host;if(c.has(P))break;c.add(P),u.push(P),h=P;continue}if(!Re(h.parentNode)||c.has(h.parentNode))break;c.add(h.parentNode),u.push(h.parentNode),h=h.parentNode}const d=t.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?u.findIndex(P=>pe(P,"button")||pe(P,"a")):-1;d>0&&(i=i||u.slice(0,d+1).some(P=>!_t(P)||jt(P)));const p=[],v={};let _,g=!1,y=!1;if(J(u,P=>{const I=_t(P);if(pe(P,"a")&&!s&&!r?.includes("href")){const M=P.getAttribute("href");g=!!(I&&M&&Rt(M))&&(o?ot(M):M)}A(Nt(P),"ph-no-capture")&&(y=!0),p.push((function(M,O,q,B,z=!1){const K=M.tagName.toLowerCase(),C={tag_name:K};Gr.indexOf(K)>-1&&!q&&(C.$el_text=K.toLowerCase()==="a"||K.toLowerCase()==="button"?zi(1024,Gn(M)):zi(1024,ys(M)));const j=Nt(M);O||B?.includes("class")||0>=j.length||(C.classes=j.filter(function(re){return re!==""})),J(M.attributes,function(re){var ue;if((!jt(M)||["name","id","class","aria-label"].indexOf(re.name)!==-1)&&!B?.includes(re.name)&&!O&&Rt(re.value)&&(!D(ue=re.name)||ue.substring(0,10)!=="_ngcontent"&&ue.substring(0,7)!=="_nghost")){let ae=re.value;re.name==="class"&&(ae=Ur(ae).join(" ")),C["attr__"+re.name]=zi(1024,re.name==="href"&&z?ot(ae):ae)}});let N=1,U=1,V=M;for(;V=Lh(V);)N++,V.tagName===M.tagName&&U++;return C.nth_child=N,C.nth_of_type=U,C})(P,s,i,r,o)),J((function(M){if(!_t(M))return{};const O={};return J(M.attributes,function(q){if(q.name&&q.name.indexOf("data-ph-capture-attribute")===0){const B=q.name.replace("data-ph-capture-attribute-",""),z=q.value;B&&z&&Rt(z)&&(O[B]=z)}}),O})(P),(M,O)=>{({}).hasOwnProperty.call(v,O)||(v[O]=M)})}),y)return{props:{},explicitNoCapture:y};if(d>0&&(e=u[d],p.splice(0,d)),i||(p[0].$el_text=pe(e,"a")||pe(e,"button")?Gn(e):ys(e)),g){var m,w;p[0].attr__href=g;const P=(m=Je(g))===null||m===void 0?void 0:m.host,I=b==null||(w=b.location)===null||w===void 0?void 0:w.host;P&&I&&P!==I&&(_=g)}return{props:Z((k=t.type,{$event_type:k,$ce_version:1}),n?{}:{$elements:p},{$elements_chain:(E=p,F(E)?(function(P){return P.map(I=>{var M,O;let q="";if(I.tag_name&&(q+=I.tag_name),I.attr_class){I.attr_class.sort();for(const K of I.attr_class)q+=`.${K.replace(/"/g,"")}`}const B=f(f(f(f({},I.text?{text:I.text}:{}),{},{"nth-child":(M=I.nth_child)!==null&&M!==void 0?M:0,"nth-of-type":(O=I.nth_of_type)!==null&&O!==void 0?O:0},I.href?{href:I.href}:{}),I.attr_id?{attr_id:I.attr_id}:{}),I.attributes),z={};return Ls(B).sort(([K],[C])=>(function(j,N){return N>j?-1:j>N?1:0})(K,C)).forEach(([K,C])=>z[Jn(K.toString())]=Jn(C.toString())),q+=":",q+=Ls(z).map(([K,C])=>`${K}="${C}"`).join(""),q}).join(";")})((function(P){return P.map(I=>{var M,O;const q={text:(M=I.$el_text)===null||M===void 0?void 0:M.slice(0,400),tag_name:I.tag_name,href:(O=I.attr__href)===null||O===void 0?void 0:O.slice(0,2048),attr_class:Vd(I),attr_id:I.attr__id,nth_child:I.nth_child,nth_of_type:I.nth_of_type,attributes:{}};return Ls(I).filter(([B])=>B.indexOf("attr__")===0).forEach(([B,z])=>q.attributes[B]=z),q})})(E)):"")},!((a=p[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=p[0])===null||l===void 0?void 0:l.$el_text}:{},_&&t.type==="click"?{$external_click_url:_}:{},v),target:e};var E,k}var Nh=class{vo(){this.fo=void 0,clearTimeout(this.po),this.po=void 0}mo(e){var t;if(!_t(e))return!0;const s=(t=this.yo().css_selector_ignorelist)!==null&&t!==void 0?t:Pi,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const n=r,o=Nt(n);if(A(o,"ph-no-capture")||A(o,"ph-sensitive")||jt(n)||s.some(l=>yr(n,l)))return!0;const a=r.parentNode;r=Wr(a)?a.host:a&&Re(a)?a:null}return!1}bo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.vo();if(e.type==="pointerdown"){this.vo();const i=cs(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&Re(i)&&(this.fo={target:i,excluded:this.mo(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this._o)===null||t===void 0?void 0:t.distinctId}))}const s=this.fo;s&&(e.pointerId!==s.id||Math.abs(e.clientX-s.x)>5||Math.abs(e.clientY-s.y)>5?this.vo():e.type==="pointerup"&&(s.released=!0,this.po=setTimeout(()=>this.vo(),0)))}wo(e){var t;const s=this.fo;this.vo();const i=cs(e);if(s?.released&&s.target.isConnected&&s.distinctId===((t=this._o)===null||t===void 0?void 0:t.distinctId)&&e.pointerId===s.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-s.x)&&5>=Math.abs(e.clientY-s.y)&&i&&(pe(i,"html")||pe(i,"body"))){var r;if(s.excluded)return null;const n=(r=this.yo().css_selector_ignorelist)!==null&&r!==void 0?r:Pi;return[i,$?.documentElement,$?.body].some(o=>{if(!o)return!1;const a=Nt(o);return A(a,"ph-no-capture")||A(a,"ph-sensitive")||!_t(o)||jt(o)||n.some(l=>yr(o,l))})?null:s.target}}constructor(e){this.ko=e,this.name=uu,this.So=!1,this.xo=null,this.$o=!1,this.Co=new Map,this.To=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Io=!1,this.ko.refresh(this.Mr),this.rageclicks=new fu(this.Mr.rageclick),this.Mo=null}setup(e){this.Eo(),this._o=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.Io?t.dispose():(this.Po=t,this.startIfEnabled())}dispose(){var e;this.Io||(this.Io=!0,this._o=void 0,(e=this.Po)===null||e===void 0||e.dispose(),this.Po=void 0,this.Co.clear(),this.Mo=null,this.Ro())}yo(){return this.ko.refresh(this.Mr),this.Mr}Eo(){var e,t;return this.yo(),this.Mr.url_allowlist=(e=this.Mr.url_allowlist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Mr.url_ignorelist=(t=this.Mr.url_ignorelist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Mr}Ao(){if(!this.isBrowserSupported())return void Bi.info("Disabling Automatic Event Collection because this browser is not supported");if(!b||!$)return;const e=this.Fo=t=>{t=t||b?.event;try{if(t.type==="blur")return void this.vo();if(t.type.indexOf("pointer")===0)return void this.bo(t);const s=t.type==="click"?this.wo(t):void 0;if(se(s))return;this.Oo(t,"$autocapture",s)}catch(s){Bi.error("Failed to capture event",s)}};if(W(b,"blur",e),W($,"submit",e,{capture:!0}),W($,"change",e,{capture:!0}),W($,"click",e,{capture:!0}),J(["pointerdown","pointermove","pointerup","pointercancel"],t=>{W($,t,e,{capture:!0})}),this.yo().capture_copied_text){const t=this.Do=s=>{s=s||b?.event;try{this.Oo(s,Hi)}catch(i){Bi.error("Failed to capture clipboard event",i)}};W($,"copy",t,{capture:!0}),W($,"cut",t,{capture:!0}),W($,"paste",t,{capture:!0})}}Ro(){this.vo(),this.Fo&&(b?.removeEventListener("blur",this.Fo),J(["pointerdown","pointermove","pointerup","pointercancel"],e=>{$?.removeEventListener(e,this.Fo,!0)}),$?.removeEventListener("submit",this.Fo,!0),$?.removeEventListener("change",this.Fo,!0),$?.removeEventListener("click",this.Fo,!0),this.Fo=void 0),this.Do&&($?.removeEventListener("copy",this.Do,!0),$?.removeEventListener("cut",this.Do,!0),$?.removeEventListener("paste",this.Do,!0),this.Do=void 0),this.So=!1}startIfEnabled(){this.isEnabled||this.vo(),!this.Io&&this._o&&this.isEnabled&&!this.So&&(this.Ao(),this.So=!0)}onRemoteConfig(e){if(this.Io)return;if(this.$o=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this.To=t.elementsChainAsString);const s=t.autocapture_opt_out;var i;we(s)&&((i=this._o)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.xo=s),this.startIfEnabled()}setElementSelectors(e,t=this){if(this.Io)return;e.size?this.Co.set(t,new Set(e)):this.Co.delete(t);const s=new Set;this.Co.forEach(i=>{i.forEach(r=>s.add(r))}),this.Mo=s}getElementSelectors(e,t){var s;const i=[];return(s=this.Mo)===null||s===void 0||s.forEach(r=>{const n=$?.querySelectorAll(r);n?.forEach(o=>{e!==o&&t!==o||A(i,r)||i.push(r)})}),i}get isEnabled(){var e,t;if(this.Io)return!1;const s=(e=this._o)===null||e===void 0?void 0:e.kv.get(Ua),i=this.xo,r=this.yo();if(!r.remoteRequestsDisabled&&!this.$o)return!1;const n=r.remoteRequestsDisabled&&!this.$o;if(se(i)&&!we(s)&&!n)return!1;const o=(t=this.xo)!==null&&t!==void 0?t:!!s;return!!r.enabled&&!o}Oo(e,t="$autocapture",s){if(!this.isEnabled)return void this.vo();let i=s||cs(e);yl(i)&&(i=i.parentNode||null);const r=this.Eo();var n;t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&r.rageclick&&(!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime()))&&kl(i,r.rageclick)&&this.Oo(e,"$rageclick",s);const o=t===Hi,a=o?f(f({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(h,d,p,v,_,g){var y;if(!b||Kr(h)||p?.url_allowlist&&!jn(p.url_allowlist,g)||p?.url_ignorelist&&jn(p.url_ignorelist,g))return!1;if(p?.dom_event_allowlist){const k=p.dom_event_allowlist;if(k&&!k.some(P=>d.type===P))return!1}const{parentIsUsefulElement:m,targetElementList:w}=$l(h,v);if(!(function(k,P){const I=P?.element_allowlist;if(x(I))return!0;for(const M of k)if(I.some(O=>M.tagName.toLowerCase()===O))return!0;return!1})(w,p)||!br(w,p?.css_selector_allowlist)||br(w,(y=p?.css_selector_ignorelist)!==null&&y!==void 0?y:Pi))return!1;try{const k=b.getComputedStyle(h);if(k&&k.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0}catch{}const E=h.tagName.toLowerCase();switch(E){case"html":return!1;case"form":return(_||["submit"]).indexOf(d.type)>=0;case"input":case"select":case"textarea":return(_||["change","click"]).indexOf(d.type)>=0;default:return m?(_||["click"]).indexOf(d.type)>=0:(_||["click"]).indexOf(d.type)>=0&&(Gr.indexOf(E)>-1||h.getAttribute("contenteditable")==="true")}})(i,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var l;const{props:h,explicitNoCapture:d,target:p}=Dh(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.To,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(d)return!1;const v=this.getElementSelectors(i,p);if(v&&v.length>0&&(h.$element_selectors=v),t===Hi){const _=e.type||"clipboard";if(_!=="paste"){var u,c;const g=b==null||(u=b.getSelection())===null||u===void 0?void 0:u.toString(),y=bl(g);if(!y)return!1;h.$selected_content=y,h.$clipboard_text_length=(c=g?.length)!==null&&c!==void 0?c:0}h.$copy_type=_}return(l=this._o)===null||l===void 0||l.capture(t,h),!0}}isBrowserSupported(){return oe($?.querySelectorAll)}},jh=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,s=L(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.nl(),e.url_allowlist=s?.url_allowlist,e.url_ignorelist=s?.url_ignorelist,e.dom_event_allowlist=s?.dom_event_allowlist,e.element_allowlist=s?.element_allowlist,e.css_selector_allowlist=s?.css_selector_allowlist,e.css_selector_ignorelist=s?.css_selector_ignorelist,e.element_attribute_ignorelist=s?.element_attribute_ignorelist,e.capture_copied_text=s?.capture_copied_text}};const es=ee("[ExceptionAutocapture]"),mo=()=>{},yo=e=>{var t;if(oe(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function zt(e,t,s){try{if(!(t in e))return mo;const i={next:e[t]},r=s(function(...n){return i.next.apply(this,n)});return oe(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),e[t]=r,()=>{if(e[t]===r)return void(e[t]=i.next);let n=e[t],o=yo(n);for(;o;){if(o.next===r)return void(o.next=i.next);n=o.next,o=yo(n)}}}catch{return mo}}const qh=ee("[TracingHeaders]"),ut=ee("[Web Vitals]"),bo=9e5,wo=["CLS","FCP","INP","LCP"],Hh=["INP","LCP"],Bh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Vi="disabled",xo="lazy_loading",Be=ee("[SessionRecording]"),zh=[qr,Hr,ol,al,ll,ul,cl,dl,hl],Vh=ee("[Heatmaps]");function Wi(e){return L(e)&&"clientX"in e&&"clientY"in e&&ne(e.clientX)&&ne(e.clientY)}const Os=ee("[Product Tours]"),Ui=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(Nr))},Wh=["$set_once","$set"],De=ee("[SiteApps]"),ko="Error while initializing PostHog app with config id ",Xr=(e,t)=>e?.then?e.then(t):t(e),Pt="SDK is not enabled or survey functionality is not yet loaded",$o="Disabled. Not loading surveys.";var Uh=class{constructor(e,t){this.ko=e,this.Tc=t,this.name=hu,this._surveyEventReceiver=null,this._surveyManager=null,this.Ic=!1,this.Mc=!1,this.Ec=[],this.Pc=[],this.Rc=null,this.Ac=null,this.Io=!1,this.Fc=new Set,this.onRemoteConfig=s=>{if(this.Io||this.Mr.disableSurveys)return;if(!s.ok)return this.Mc=!0,this.Oc({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),G.warn("Remote config unavailable. Not loading surveys.");const i=s.config.surveys;if(R(i))return G.warn("Flags not loaded yet. Not loading surveys.");this.Dc=we(i)?i:i.length>0,G.info(`flags response received, isSurveysEnabled: ${this.Dc}`),this.loadIfEnabled()},this.Oc=s=>{this.Pc.slice().forEach(i=>this.Lc(i,s))}}setup(e){if(!this.Io)return this.Nc=e,Xr(e.kv.initialize(),()=>{if(this.Nc!==e||this.Io)return;this.Nc=void 0,this._o=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.Io?t.dispose():(this.Po=t,this.loadIfEnabled())})}dispose(){var e,t,s,i,r;this.Io||(this.Io=!0,this.Nc=void 0,this._o=void 0,(e=this.Po)===null||e===void 0||e.dispose(),this.Po=void 0,(t=this._surveyEventReceiver)===null||t===void 0||t.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)===null||s===void 0||(i=s.dispose)===null||i===void 0||i.call(s),this._surveyManager=null,this.Ec=[],this.Pc.forEach(n=>{n.active=!1}),this.Pc=[],(r=this.qc)===null||r===void 0||r.call(this),this.qc=void 0,this.Rc=null,this.Fc.forEach(n=>clearTimeout(n)),this.Fc.clear())}get Mr(){return this.ko.get()}initialize(){this.loadIfEnabled()}reset(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.clearInMemoryInProgressSurveyState)===null||t===void 0||t.call(e);try{var s;(s=this._surveyEventReceiver)===null||s===void 0||s.reset(),localStorage.removeItem("lastSeenSurveyDate");const i=[];for(let r=0;r<localStorage.length;r++){const n=localStorage.key(r);(n?.startsWith("seenSurvey_")||n?.startsWith("inProgressSurvey_"))&&i.push(n)}i.forEach(r=>localStorage.removeItem(r))}catch{}this.Oc()}loadIfEnabled(){if(this.Io||!this._o)return;const e=this.Mr;if(this._surveyManager)return;if(this.Ic)return void G.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void G.info($o);if(e.cookielessMode&&this.ko.isOptedOut())return void G.info("Not loading surveys in cookieless mode without consent.");const t=this.ko.getExtensions();if(!t)return void this.jc("PostHog Extensions not found.");if(x(this.Dc)&&!e.advancedEnableSurveys)return;const s=this.Dc||e.advancedEnableSurveys;this.Ic=!0,this.Mc=!1;try{const i=t.generateSurveys;if(i)return this.Bc(i,s),void(this.Ic=!1);const r=t.loadExternalDependency;if(!r)return this.jc(Br),void(this.Ic=!1);r(n=>{try{if(this.Io)return;const o=this.ko.getExtensions();n||!o?.generateSurveys?this.jc("Could not load surveys script",n):this.Bc(o.generateSurveys,s)}finally{this.Ic=!1}})}catch(i){throw this.Ic=!1,this.jc("Error initializing surveys",i),i}}Bc(e,t){var s,i;if(this.Io)return;this._surveyManager=e(t),this._surveyEventReceiver=this.ko.createEventReceiver(this.Oc);const r=(s=(i=this._o)!==null&&i!==void 0?i:this.Tc)===null||s===void 0?void 0:s.kv.get(ss);r&&this.zc(r),G.info("Surveys loaded successfully"),this.Hc(),this.Oc(),this.Uc({isLoaded:!0})}jc(e,t){this.Mc=!0,G.error(e,t),this.Oc({isLoaded:!1,error:e}),this.Uc({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Ec.push(e),this._surveyManager&&this.Uc({isLoaded:!0}),()=>{this.Ec=this.Ec.filter(t=>t!==e)}}getSurveys(e,t=!1){var s;const i=(s=this._o)!==null&&s!==void 0?s:this.Tc;if(!i||this.Io)return;if(this.Mr.disableSurveys)return G.info($o),e([]);const r=i.kv.get(ss);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Wc()&&this.getSurveys(()=>{},!0));if(this.Rc)return void this.Rc.then(({surveys:a,context:l})=>{this.Io||e(a,l)}).catch(a=>G.error("Error in survey callback",a));const n=this.Vc("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(a=>{try{return this.Gc(i,a)}catch(l){return G.error("Error processing surveys response",l),this.Gc(i,{statusCode:0,error:l})}},a=>this.Gc(i,{statusCode:0,error:a}));this.Rc=n;const o=()=>{this.Rc===n&&(this.Rc=null)};n.then(a=>{o(),this.Io||(this.Oc(a.context),e(a.surveys,a.context))},o).catch(a=>G.error("Error in survey callback",a))}Vc(e,t){const s=this._o;return s?s.sendRequest(e,t):new Promise(i=>i({statusCode:0,error:new Error(Pt)}))}Gc(e,t){if(this.Io)return{surveys:[],context:{isLoaded:!1,error:Pt}};const s=t.statusCode;if(s!==200||!t.json){const r=`Surveys API could not be loaded, status: ${s}`;return s!==0?G.error(r):t.error||G.warn(r),this.Ac=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ac=null;const i=t.json.surveys||[];return e.kv.set({[ss]:i,[Ks]:Date.now()}),this.zc(i),{surveys:i,context:{isLoaded:!0}}}zc(e){var t;const s=e.filter(i=>(function(r){return!(!r.start_date||r.end_date)})(i)&&(nu(i)||(function(r){var n;return!!(!((n=r.conditions)===null||n===void 0||(n=n.actions)===null||n===void 0||(n=n.values)===null||n===void 0)&&n.length)})(i)));(t=this._surveyEventReceiver)===null||t===void 0||t.replace(s)}Wc(){return this.Qc()&&!this.Rc&&!this.Zc()}Qc(){var e,t;const s=(e=(t=this._o)!==null&&t!==void 0?t:this.Tc)===null||e===void 0?void 0:e.kv.get(Ks);return ne(s)&&Date.now()-s>3e5}Zc(){return ne(this.Ac)&&3e5>Date.now()-this.Ac}markSurveyAsSeen(e,t){var s;const i={id:e,current_iteration:(s=t?.iteration)!==null&&s!==void 0?s:null};lu(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Oc()}Uc(e){for(const t of this.Ec)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(s){G.error("Error in survey callback",s)}}getActiveMatchingSurveys(e,t=!1){if(!R(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);G.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t,s;if(this.Io)return()=>{};const i={callback:e,active:!0,revision:0};this.Pc.push(i),this.Hc();const r=(t=(s=this._o)!==null&&s!==void 0?s:this.Tc)===null||t===void 0?void 0:t.kv.get(ss);return this.Mr.disableSurveys||!this._surveyManager&&this.Mc&&!this.Ic||!r&&!R(this.Ac)&&!this.Rc?this.Lc(i,{isLoaded:!1}):this._surveyManager&&this.Lc(i),()=>{var n;i.active=!1,this.Pc=this.Pc.filter(o=>o!==i),this.Pc.length===0&&((n=this.qc)===null||n===void 0||n.call(this),this.qc=void 0)}}Hc(){var e,t,s;this._surveyManager&&this.Pc.length>0&&((e=this.qc)!==null&&e!==void 0||(this.qc=(t=(s=this.ko).onMatchingConditionsChanged)===null||t===void 0?void 0:t.call(s,this.Oc)))}Lc(e,t){if(this.Io||!e.active)return;const s=++e.revision,i=r=>{if(!this.Io&&e.active&&s===e.revision)try{const n=t??{isLoaded:!0},o=JSON.stringify([r,n]);if(o===e.lastResult)return;e.lastResult=o,e.callback(r,n)}catch(n){G.error("Error in active matching surveys callback",n)}};try{t&&!t.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(r){G.error("Error in active matching surveys callback",r)}}Jc(e){let t=null;return this.getSurveys(s=>{var i;t=(i=s.find(r=>r.id===e))!==null&&i!==void 0?i:null}),t}Kc(e){if(R(this._surveyManager))return{eligible:!1,reason:Pt};const t=typeof e=="string"?this.Jc(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Xc(e){if(!this.ko.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(R(this._surveyManager))return{eligible:!1,reason:Pt};const t=typeof e=="string"?this.Jc(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(R(this._surveyManager))return G.warn("init was not called"),{visible:!1,disabledReason:Pt};const t=this.Xc(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return R(this._surveyManager)?(G.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Pt})):new Promise(s=>{this.getSurveys(i=>{var r;const n=(r=i.find(o=>o.id===e))!==null&&r!==void 0?r:null;if(n){const o=this.Xc(n);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,s){var i;if(!this.ko.isCapturing())return;if(R(this._surveyManager))return void G.warn("init was not called");const r=typeof e=="string"?this.Jc(e):e;if(!r?.id)return void G.warn("Survey not found");if(!xh.includes(r.type))return void G.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const n=$?.querySelector(t);if(n){if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){G.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const o=setTimeout(()=>{var a,l;this.Fc.delete(o),!this.Io&&this.ko.isCapturing()&&(G.info(`Rendering survey ${r.id} with delay of ${(a=r.appearance)===null||a===void 0?void 0:a.surveyPopupDelaySeconds} seconds`),(l=this._surveyManager)===null||l===void 0||l.renderSurvey(r,n,s),G.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Fc.add(o)}this._surveyManager.renderSurvey(r,n,s)}else G.warn("Survey element not found")}displaySurvey(e,t){var s;if(!this.ko.isCapturing())return;if(R(this._surveyManager))return void G.warn("init was not called");const i=this.Jc(e);if(!i)return void G.warn("Survey not found");let r=i;if(!((s=i.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=f(f({},i),{},{appearance:f(f({},i.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==wr.Popover&&t.initialResponses&&G.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){const n=this.Kc(i);if(!n.eligible)return void G.warn("Survey is not eligible to be displayed: ",n.reason)}t.displayType!==wr.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){R(this._surveyManager)?G.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.handlePageUnload)===null||t===void 0||t.call(e)}};function Mt(e,t,s){if(R(e))return!1;switch(s){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{return!1}default:return!1}}var Gh=class{constructor(e){this._instance=e,this.Yc=new Set,this.th=new Set,this.eh=new ti,this.ih=(t,s)=>this.nh(t,s)&&this.sh(t,s)&&this.rh(t,s)&&this.oh(t,s),this.nh=(t,s)=>!s?.event||t?.event===s?.event}init(){var e,t;x((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.ah=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var e,t;(e=this.ah)===null||e===void 0||e.call(this),this.ah=void 0,(t=this._instance)===null||t===void 0||(t=t.autocapture)===null||t===void 0||t.setElementSelectors(new Set,this),this.eh=new ti}register(e){var t,s;if(!x((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(i=>{var r;this.Yc.add(i),(r=i.steps)===null||r===void 0||r.forEach(n=>{this.th.add(n?.event||"")})}),(s=this._instance)===null||s===void 0?void 0:s.autocapture)){const i=new Set;this.Yc.forEach(r=>{var n;(n=r.steps)===null||n===void 0||n.forEach(o=>{o?.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i,this)}}replace(e){this.Yc.clear(),this.th.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.th.has(e)||this.th.has(t.event))&&this.Yc.forEach(s=>{this.uh(t,s)&&this.eh.emit("actionCaptured",s.name)})}hh(e){this.onAction("actionCaptured",t=>e(t))}uh(e,t){if(t?.steps==null)return!1;for(const s of t.steps)if(this.ih(e,s))return!0;return!1}onAction(e,t){return this.eh.on(e,t)}sh(e,t){if(t?.url){var s;const i=e==null||(s=e.properties)===null||s===void 0?void 0:s.$current_url;if(!i||typeof i!="string"||!Mt(i,t.url,t.url_matching||"contains"))return!1}return!0}rh(e,t){return!!this.dh(e,t)&&!!this.fh(e,t)&&!!this.ph(e,t)}dh(e,t){var s;if(!t?.href)return!0;const i=this.gh(e);if(i.length>0)return i.some(n=>Mt(n.href,t.href,t.href_matching||"exact"));const r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!r&&Mt((function(n){const o=n.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(r),t.href,t.href_matching||"exact")}fh(e,t){var s;if(!t?.text)return!0;const i=this.gh(e);if(i.length>0)return i.some(l=>Mt(l.text,t.text,t.text_matching||"exact")||Mt(l.$el_text,t.text,t.text_matching||"exact"));const r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!r&&(n=(function(l){const u=[],c=/(?::|")text="(.*?)"/g;let h;for(;!R(h=c.exec(l));)u.includes(h[1])||u.push(h[1]);return u})(r),o=t.text,a=t.text_matching||"exact",n.some(l=>Mt(l,o,a)));var n,o,a}ph(e,t){var s,i;if(!t?.selector)return!0;const r=e==null||(s=e.properties)===null||s===void 0?void 0:s.$element_selectors;if(r?.includes(t.selector))return!0;const n=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch{return!1}return!1}gh(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e?.properties.$elements}oh(e,t){return!t?.properties||t.properties.length===0||au(t.properties.reduce((s,i)=>{const r=F(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:r,operator:i.operator||"exact"},s},{}),e?.properties)}},Jh=class{constructor(e,t){var s,i;this.mh=[],this._instance=e,this.yh=t,this.bh=new Map,this._h=new Map,this.wh=new Map,this.kh=(s=this._instance)===null||s===void 0||(i=s.onSessionId)===null||i===void 0?void 0:i.call(s,r=>this.Sh(r))}xh(e){return!1}$h(){return null}Ch(e){}Th(){}Ih(e,t){return!!e&&au(e.propertyFilters,t?.properties)}Mh(e,t){const s=new Map;return e.forEach(i=>{var r;(r=i.conditions)===null||r===void 0||(r=r[t])===null||r===void 0||(r=r.values)===null||r===void 0||r.forEach(n=>{if(n?.name){const o=s.get(n.name)||[];o.push(i.id),s.set(n.name,o)}})}),s}Eh(e,t,s){const i=(s===Yt.Activation?this.bh:this._h).get(e);let r=[];return this.Ph(n=>{r=n.filter(o=>i?.includes(o.id))}),r.filter(n=>{var o;const a=(o=n.conditions)===null||o===void 0||(o=o[s])===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.find(l=>l.name===e);return this.Ih(a,t)})}register(e){this.Rh(e,!1)}replace(e){this.Rh(e,!0)}Rh(e,t){var s;x((s=this._instance)===null||s===void 0?void 0:s._addCaptureHook)||(this.Ah(e,t),this.Fh(e,t))}Fh(e,t){const s=e.filter(n=>{var o;return(o=n.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.length});var i;if(t&&this.wh.clear(),s.length===0)return void(t&&((i=this.Oh)===null||i===void 0||i.replace([])));this.Oh||(this.Oh=new Gh(this._instance),this.Oh.init(),this.Oh.hh(n=>this.onAction(n)));const r=[];s.forEach(n=>{var o;(o=n.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||o.values.forEach(a=>{if(r.push(a),a.name){var l;const u=(l=this.wh.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.wh.set(a.name,u)}})}),t?this.Oh.replace(r):this.Oh.register(r)}Dh(e,t){t.forEach((s,i)=>{var r;const n=(r=e.get(i))!==null&&r!==void 0?r:[];s.forEach(o=>{n.includes(o)||n.push(o)}),e.set(i,n)})}Ah(e,t){var s,i;const r=e.filter(l=>{var u,c;return((u=l.conditions)===null||u===void 0?void 0:u.events)&&((c=l.conditions)===null||c===void 0||(c=c.events)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length)>0}),n=e.filter(l=>{var u,c;return((u=l.conditions)===null||u===void 0?void 0:u.cancelEvents)&&((c=l.conditions)===null||c===void 0||(c=c.cancelEvents)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length)>0}),o=this.Mh(e,Yt.Activation),a=this.Mh(e,Yt.Cancellation);t?(this.bh=o,this._h=a):(this.Dh(this.bh,o),this.Dh(this._h,a)),(r.length!==0||n.length!==0||e.some(l=>{var u;return(u=l.conditions)===null||u===void 0||(u=u.actions)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length}))&&((s=this.ah)!==null&&s!==void 0||(this.ah=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((l,u)=>{this.onEvent(l,u)})))}onEvent(e,t){var s,i;const r=this.Lh(),n=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$survey_id)||(t==null||(i=t.properties)===null||i===void 0?void 0:i.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){const a=this.Nh(e,n,t);if(a==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this.qh([n]);if(a==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this.jh(n),void this.Bh([n])}if(this._h.has(e)){const a=this.Eh(e,t,Yt.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(l=>l.id)}),this.qh(a.map(l=>l.id)),a.forEach(l=>this.zh(l.id)))}if(!this.bh.has(e))return;r.info("event name matched",{event:e,eventPayload:t,items:this.bh.get(e)});const o=this.Eh(e,t,Yt.Activation);this.Hh(o.map(a=>a.id))}onAction(e){this.wh.has(e)&&this.Hh(this.wh.get(e)||[])}Hh(e){var t,s;if(e.length===0)return;const i=!!(!((t=this._instance)===null||t===void 0||(s=t.get_session_id)===null||s===void 0)&&s.call(t)),r=[];for(const n of e)i&&this.xh(n)?this.jh(n)&&this.Uh(n):r.push(n);r.length>0&&(this.mh=[...new Set([...this.mh,...r])]),this.Lh().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Wh()}jh(e){this.mh=this.mh.filter(s=>s!==e);const t=this.Vh();return!t.includes(e)&&(this.Gh([...t,e]),this.Qh(),!0)}qh(e){const t=new Set(e);this.mh=this.mh.filter(r=>!t.has(r));const s=this.Zh(),i=s.filter(r=>!t.has(r));i.length!==s.length&&(this.Gh(i),i.length===0&&this.Jh()),this.Bh(e),this.Wh()}Wh(){try{var e;(e=this.yh)===null||e===void 0||e.call(this)}catch(t){this.Lh().error("Error while handling activated items change",t)}}Kh(){var e;const t=this.$h();if(!t)return{};const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t];return s&&typeof s=="object"?s:{}}Uh(e){if(!this.$h())return;const t=this.Kh();this.Ch(f(f({},t),{},{[e]:Date.now()}))}Bh(e){if(!this.$h())return;const t=this.Kh(),s={};let i=!1;for(const[r,n]of Object.entries(t))e.includes(r)?i=!0:s[r]=n;i&&($e(s)?this.Th():this.Ch(s))}Xh(){this.$h()&&this.Th()}getActivationTimestamp(e){if(!this.Vh().includes(e))return;const t=this.Kh()[e];return ne(t)?t:void 0}Zh(){var e;const t=this.Yh();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t])||[]}Vh(){var e,t,s;const i=this.Zh();if(i.length===0)return[];const r=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.td()],n=(t=this._instance)===null||t===void 0||(s=t.get_session_id)===null||s===void 0?void 0:s.call(t);return n&&r===n?i:[]}Qh(){var e,t;const s=(e=this._instance)===null||e===void 0||(t=e.get_session_id)===null||t===void 0?void 0:t.call(e);s&&this.ed(s)}Jh(){this.nd()}Sh(e){var t;const s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.td()];if(s&&s!==e){const i=this.Zh(),r=this.Kh();i.length>0&&(this.Gh([]),i.filter(n=>ne(r[n])).forEach(n=>this.zh(n))),this.Jh(),this.Xh(),i.length>0&&this.Wh()}}getActivatedIds(){return[...new Set([...this.Vh(),...this.mh])].filter(e=>!this.sd(e))}dispose(){var e,t,s;(e=this.kh)===null||e===void 0||e.call(this),this.kh=void 0,(t=this.ah)===null||t===void 0||t.call(this),this.ah=void 0,(s=this.Oh)===null||s===void 0||s.dispose(),this.Oh=void 0}reset(){this.mh=[],this.Zh().length>0&&this.Gh([]),this.Jh(),this.Xh(),this.Wh()}getEventToItemsMap(){return this.bh}rd(){return this.Oh}},Kh=class extends Jh{constructor(e,t){super(e,t)}Yh(){return Xa}td(){return Za}$h(){return el}Ch(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_timestamps:e})}Th(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}xh(e){var t;let s;this.Ph(r=>{s=r.find(n=>n.id===e)});const i=s==null||(t=s.appearance)===null||t===void 0?void 0:t.surveyPopupDelaySeconds;return ne(i)&&i>0}od(){return Se.SHOWN}Ph(e){var t;(t=this._instance)===null||t===void 0||t.getSurveys(e)}zh(e){var t;(t=this._instance)===null||t===void 0||t.cancelPendingSurvey(e)}Lh(){return G}Gh(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated:e})}ed(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_session:e})}nd(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}sd(){return!1}Nh(e,t,s){var i;if(e===Se.SENT&&(s==null||(i=s.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let r;return this.Ph(n=>{r=n.find(o=>o.id===t)}),!r||(function(n){var o;return nu(n)&&!!(!((o=n.conditions)===null||o===void 0||(o=o.events)===null||o===void 0)&&o.repeatedActivation)||n.schedule==="always"})(r)?e===Se.SHOWN?"consume":"ignore":e===Se.SHOWN?"persist":e===Se.DISMISSED||e===Se.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Qh=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);const t={};for(const s of e){const i=this._instance.get_property(s);x(i)||(t[s]=i)}return t}set(e,t){this._instance.register(typeof e=="string"?{[e]:t}:e)}remove(e){typeof e!="string"?e.forEach(t=>this._instance.unregister(t)):this._instance.unregister(e)}},Yh=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=T?.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:s}=e;return{generateSurveys:t?i=>t(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}createEventReceiver(e){return new Kh(this._instance,e)}onMatchingConditionsChanged(e){const t=this._instance._addCaptureHook(n=>{n!=="$pageview"&&n!==Se.SHOWN&&n!==Se.DISMISSED&&n!==Se.SENT||e()}),s=()=>e();W(b,"PHSurveyShown",s);let i=!1;const r=this._instance.onFeatureFlags(()=>{i&&e()});return i=!0,()=>{i=!1,t(),r(),b?.removeEventListener("PHSurveyShown",s)}}};const Xh=b?.location?Xs(b.location.hash,"__posthog")||Xs(location.hash,"state"):null,Eo="_postHogToolbarParams",So=ee("[Toolbar]"),Po=ee("[FeatureFlags]"),ct=ee("[FeatureFlags]",{debugEnabled:!0}),Gi=`" failed. Feature flags didn't load in time.`,Zh=[502,504],Mo=["click","keydown","wheel","touchstart","pointerdown"],Io="connection_error",Oo=e=>{const t={};for(let s=0;e.length>s;s++)t[e[s]]=!0;return t},Fo=e=>{const t={};for(const[s,i]of Ls(e||{}))i&&(t[s]=i);return t};var ep=class{constructor(e){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.A=Po,this.ld={},this.ud={},this.hd=[],this.dd=new Set,this.vd=new Set,this.fd=!1,this.pd=!1,this.gd=0,this.md=!1,this.yd=!1,this.bd=!1,this._d=!1,this.wd=0,this.kd=!1,this.rn=()=>{const t=this.Sd();this.wd=0,t&&this.reloadFeatureFlags()},this.xd=()=>{var t,s;const i=this.$d,r=(t=this.Cd)!==null&&t!==void 0?t:i;x(i)||x(r)||this.Mr.remoteRequestsDisabled||!this.Td||this.Td.visibilityState==="hidden"||Date.now()-((s=this.Id)!==null&&s!==void 0?s:0)<r||(this.Cd=this.kd||!this.Mr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.kd=!1,this.reloadFeatureFlags(),this.Md())},this.Ed=()=>{this.kd&&this.Cd===this.$d||this.Pd()},this.sn=()=>{var t;((t=this.Td)===null||t===void 0?void 0:t.visibilityState)==="visible"&&this.Pd()},this.ko=e}get Rd(){}Ad(){this._o&&this.Fd()}setup(e){try{this.Od=typeof window>"u"?void 0:window,this.Td=typeof document>"u"?void 0:document}catch{this.Od=void 0,this.Td=void 0}return this.Nc=e,this.A=e.logger.createLogger("[FeatureFlags]"),Xr(e.kv.initialize(),()=>{this.Nc===e&&(this.Nc=void 0,this._o=e,this.Dd(e))})}Dd(e){var t;if(this._o===e)return this.Od&&W(this.Od,"online",this.rn),this.Fd(),this.Ld=e.registerDynamicEventProperties(()=>this.Nd()?this.ld:this.ud),this.qd=(t=this.Rd)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.jd(),this.Bd(),this.zd()}),this.Bd(),this.initialize()}Pd(){this.kd=!0,this.Cd=this.$d,this.xd()}Fd(){var e;const t=this.Mr.refreshIntervalMs,s=!this.Mr.remoteRequestsDisabled&&this.Td&&!x(t)&&t>0?t:void 0;this.Mr.idleRefreshBackoff||(this.Cd=s),s!==this.$d&&(this.Hd(),x(s)||(this.$d=s,this.Cd=s,this.Md(),!((e=this.Td)===null||e===void 0)&&e.addEventListener&&(W(this.Td,ms,this.sn),Ft(Mo,i=>{W(this.Td,i,this.Ed,{capture:!0})}))))}Md(){x(this.$d)||(x(this.Ud)||clearInterval(this.Ud),this.Id=Date.now(),this.Ud=setInterval(this.xd,this.$d))}Hd(){var e,t;x(this.Ud)||(clearInterval(this.Ud),this.Ud=void 0,(e=this.Td)===null||e===void 0||(t=e.removeEventListener)===null||t===void 0||t.call(e,"visibilitychange",this.sn),Ft(Mo,s=>{var i,r;(i=this.Td)===null||i===void 0||(r=i.removeEventListener)===null||r===void 0||r.call(i,s,this.Ed,{capture:!0})})),this.$d=void 0,this.Cd=void 0,this.kd=!1,this.Id=void 0}destroy(){this.Wd()}dispose(){this.Wd()}Wd(){var e,t,s;this.Hd(),this.gd++,this.yd=!1,this.Nc=void 0,this.Vd(this.dd,"cancelled"),this.Vd(this.vd,"cancelled"),this._o&&(this.Gd(),(e=this.Ld)===null||e===void 0||e.dispose(),this.Ld=void 0,(t=this.qd)===null||t===void 0||t.call(this),this.qd=void 0,this.hd=[],(s=this.Od)===null||s===void 0||s.removeEventListener("online",this.rn),this._o=void 0)}get Mr(){return this.ko.get()}Qd(e){var t;return this.Zd&&e in this.Zd?this.Zd[e]:(t=this._o)===null||t===void 0?void 0:t.kv.get(e)}jd(){return!!this.Zd&&(this.Zd=void 0,!0)}Jd(){var e;return!x((e=this._o)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.jd()}$t(e){this.Kd(()=>{var t;return(t=this._o)===null||t===void 0?void 0:t.kv.set(e)})}Xd(e,t,s){if(!this.Rd||!e.$enabled_feature_flags)return;const i=this.Qd("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},n=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,g])=>!g?.failed).map(([g])=>g):[],a=!!t.errorsWhileComputingFlags&&!!t.flags,l=a?o:s&&!F(n)?Object.keys(n||{}):Array.from(new Set([...Object.keys(i),...Object.keys(r)])),u=this.Qd("$feature_flag_payloads")||{},c=e.$feature_flag_payloads||{},h=a||s?l:Array.from(new Set([...Object.keys(u),...Object.keys(c)])),d=!a&&!s,p=!!d||l,v=!!d||h,_={[We]:p,[Ae]:p,[rt]:v};e.$feature_flag_details&&(_[vt]=p);for(const g of[gt,nt,os])x(e[g])||(_[g]=!0);this.Rd.markCrossTabFeatureFlagChanges(_)}Pt(e){this.Kd(()=>{var t;return(t=this._o)===null||t===void 0?void 0:t.kv.remove(e)})}Kd(e){try{e()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Bd(){const e={};for(const i of[We,rt,gt,Ne]){const r=this.Qd(i);x(r)||(e[i]=r)}this.ld=e;const t=f({},e),s=this.Qd(Ae);if(s)for(const[i,r]of Object.entries(s))t[`$feature/${i}`]=r;this.ud=t}Nd(){const e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;const t=this.Qd(nt);return typeof t!="number"||Date.now()-t>e}Yd(){return!!this.Nd()&&(this._d||this.pd||(this._d=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}tv(){const e=this.Mr.evaluationContexts;return e?.length?e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),s}):[]}ev(){const e=this.Mr.flagKeys;if(!x(e))return e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),s})}initialize(){var e,t;const s=this.Mr,i=(e=(t=s.bootstrap)===null||t===void 0?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var r,n;const o=(r=(n=s.bootstrap)===null||n===void 0?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter(u=>!x(i[u])).reduce((u,c)=>(u[c]=i[c],u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this.iv({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,s){var i,r;const n=s?.merge&&(i=this.Qd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s?.merge&&(r=this.Qd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=f(f({},n),e),l=f(f({},o),t),u={};for(const[c,h]of Object.entries(a))u[c]={key:c,enabled:bn(h),variant:wn(h),reason:void 0,metadata:x(l?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}};this.iv({flags:u})}get hasLoadedFlags(){return this.fd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Qd(vt),t=this.Qd(Ne),s=this.Qd(pt);if(!s&&!t)return e||{};const i=Z({},e||{}),r=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(const a of r){var n,o;const l=i[a],u=t?.[a],c=x(u)?(n=l?.enabled)!==null&&n!==void 0&&n:!!u,h=x(u)?l?.variant:typeof u=="string"?u:void 0,d=s?.[a],p=f(f({},l),{},{enabled:c,variant:c?h??l?.variant:void 0});c!==l?.enabled&&(p.original_enabled=l?.enabled),h!==l?.variant&&(p.original_variant=l?.variant),d&&(p.metadata=f(f({},l?.metadata),{},{payload:d,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=p}return this.ad||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:i}),this.ad=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(s=>{const i=e[s];return{key:s,enabled:bn(i),variant:wn(i),payload:yn(t[s])}})}getFlagVariants(){const e=this.Qd(Ae),t=this.Qd(Ne);if(!t)return e||{};const s=Z({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.ad||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:s}),this.ad=!0),s}getFlagPayloads(){const e=this.Qd(rt),t=this.Qd(pt);if(!t)return e||{};const s=Z({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.ad||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:s}),this.ad=!0),s}reloadFeatureFlags(){this.md||this.Mr.featureFlagsDisabled||this.Sd()||(this.pd&&(this.yd=!0),this.nv||(this.hd.slice().forEach(e=>{try{e()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.nv=setTimeout(()=>{this.sv()},5)))}reloadFeatureFlagsAsync(){return!this._o||this.md||this.Mr.featureFlagsDisabled||this.Mr.remoteRequestsDisabled||this.Sd()?Promise.resolve({status:"skipped"}):new Promise(e=>{this.dd.add(e),this.reloadFeatureFlags()})}Vd(e,t){e.forEach(s=>s({status:t})),e.clear()}Gd(){clearTimeout(this.nv),this.nv=void 0}onReloading(e){return this.hd.push(e),()=>{this.hd=this.hd.filter(t=>t!==e)}}ensureFlagsLoaded(){this.fd||this.pd||this.nv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.md=e}resetFlagCallReported(){this.Pt(it)}sv(e){var t;this.Gd();const s=this._o;if(!s||this.Mr.remoteRequestsDisabled||this.Sd())return void this.Vd(this.dd,"skipped");if(this.pd)return void(this.yd=!0);const i={token:s.projectToken,distinct_id:s.distinctId,groups:s.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:f(f(f({},s.initialPersonProperties),this.Qd("$stored_person_properties")||{}),{},{$lib:s.library.name,$lib_version:s.library.version}),group_properties:this.Qd(tt),timezone:Ml()};x(s.deviceId)||(i.$device_id=s.deviceId),(e?.disableFlags||this.Mr.featureFlagsDisabled)&&(i.disable_flags=!0);const r=this.tv();r.length&&(i.evaluation_contexts=r);const n=this.ev();x(n)||(i.flag_keys=n);const o=this.Mr.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.gd,u=this.dd;this.dd=new Set,this.vd=u,this.pd=!0;const c=()=>{this.yd&&(this.yd=!1,this.sv())},h=g=>{var y,m;const w=(y=g.json)!==null&&y!==void 0?y:{},E=g.statusCode!==200;if(this.pd=!1,l!==this.gd)return void c();if(this.rv(g.statusCode),E||this.yd||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.yd)return void this.Vd(u,"skipped");this.bd=!E;const k=[];g.error?k.push(g.error instanceof Error&&g.error.name==="AbortError"?"timeout":g.error instanceof Error?Io:"unknown_error"):g.statusCode!==200&&k.push(`api_error_${g.statusCode}`),w.errorsWhileComputingFlags&&k.push("errors_while_computing_flags");const P=!!(!((m=w.quotaLimited)===null||m===void 0)&&m.includes("feature_flags"));P&&k.push("quota_limited"),this.$t({[_s]:k}),P?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):i.disable_flags||this.iv(w,E,{partialResponse:o}),this.Vd(u,i.disable_flags?"skipped":k.length||!w.flags&&!w.featureFlags?"error":"loaded"),c()},d=g=>{this.pd=!1,l===this.gd&&(this.$t({[_s]:[Io]}),this.A.error("Feature flag request failed",g),this.Jd()&&this.zd(!0),this.Vd(u,"error")),c()};let p=(t=this.Mr.requestMaxRetries)!==null&&t!==void 0?t:1;const v=()=>p>0&&l===this.gd,_=()=>{if(l!==this.gd||!this._o||this.Mr.remoteRequestsDisabled)return this.pd=!1,this.Vd(u,"skipped"),void c();try{s.sendRequest(a,{target:"flags",method:"POST",body:i,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(g=>{if((y=>Zh.includes(y.statusCode)||(m=>m.statusCode===0&&m.error instanceof Error&&m.error.name==="AbortError")(y))(g)&&v())return p--,void setTimeout(_,500);h(g)}).catch(d)}catch(g){d(g)}};_()}Sd(){return Ol(this.wd,3)}rv(e){this.wd=Fl(e,this.wd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var s;if(t.fresh&&!this.bd)return;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+e+Gi);if(this.Yd())return;const i=this.getFeatureFlagResult(e,t);return(s=i?.variant)!==null&&s!==void 0?s:i?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.bd)return;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+e+Gi);if(this.Yd())return;const s=this.getFlagVariants(),i=e in s,r=s[e],n=this.getFlagPayloads()[e],o=String(r),a=this.Qd("$feature_flag_request_id")||void 0,l=this.Qd("$feature_flag_evaluated_at")||void 0;let u,c=this.Qd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var h;const O=(h=this._o)===null||h===void 0||(h=h.session)===null||h===void 0?void 0:h.sessionId,q=this.Qd(ts);O&&O!==q&&(c={},u=O)}if(!t.send_event&&"send_event"in t)u&&this.$t({[it]:c,[ts]:u});else if(e in c&&c[e].includes(o))u&&this.$t({[it]:c,[ts]:u});else{var d,p,v,_,g,y,m,w,E,k,P,I,M;F(c[e])?c[e].push(o):c[e]=[o],this.$t(f({[it]:c},u?{[ts]:u}:{}));const O=this.getFeatureFlagDetails(e),q=[...(d=this.Qd("$feature_flag_errors"))!==null&&d!==void 0?d:[]];x(r)&&q.push("flag_missing");const B={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:n??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(p=(v=this.Mr.bootstrap)===null||v===void 0||(v=v.featureFlags)===null||v===void 0?void 0:v[e])!==null&&p!==void 0?p:null,$feature_flag_bootstrapped_payload:(_=(g=this.Mr.bootstrap)===null||g===void 0||(g=g.featureFlagPayloads)===null||g===void 0?void 0:g[e])!==null&&_!==void 0?_:null,$used_bootstrap_value:!this.bd};x(O==null||(y=O.metadata)===null||y===void 0?void 0:y.has_experiment)||(B.$feature_flag_has_experiment=O.metadata.has_experiment),x(O==null||(m=O.metadata)===null||m===void 0?void 0:m.version)||(B.$feature_flag_version=O.metadata.version);const z=(w=O==null||(E=O.reason)===null||E===void 0?void 0:E.description)!==null&&w!==void 0?w:O==null||(k=O.reason)===null||k===void 0?void 0:k.code;z&&(B.$feature_flag_reason=z),!(O==null||(P=O.metadata)===null||P===void 0)&&P.id&&(B.$feature_flag_id=O.metadata.id),x(O?.original_variant)&&x(O?.original_enabled)||(B.$feature_flag_original_response=x(O.original_variant)?O.original_enabled:O.original_variant),!(O==null||(I=O.metadata)===null||I===void 0)&&I.original_payload&&(B.$feature_flag_original_payload=O==null||(M=O.metadata)===null||M===void 0?void 0:M.original_payload),q.length&&(B.$feature_flag_error=q.join(",")),this.ov(B)}return i?{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:yn(n)}:void 0}ov(e){try{var t;(t=this._o)===null||t===void 0||t.capture("$feature_flag_called",e)}catch(s){this.A.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(e,t){this.av(e,t)}av(e,t){var s=this;return X(function*(){const i=s._o;if(!i)return;const r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=s.tv();n.length&&(r.evaluation_contexts=n);const o=s.ev();let a;x(o)||(r.flag_keys=o);try{var l;const u=(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:s.Mr.compression,sentAt:"body",timeoutMs:s.Mr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=u?.[e]||void 0}catch(u){return void s.A.error("Remote config feature flag request failed",u)}try{t(a)}catch(u){s.A.error("Remote config feature flag callback failed",u)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.bd)return t.defaultValue;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+e+Gi),t.defaultValue;const s=this.getFeatureFlag(e,t);return x(s)?t.defaultValue:!!s}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,s){this.iv(e,t,s)}iv(e,t,s){if(!this._o)return;this.fd=!0;const i=((r,n={},o={},a={},l,u=Po)=>{const c=((w,E)=>{const k=w.flags;if(k){const P=Object.fromEntries(Object.keys(k).map(M=>{var O;return[M,(O=k[M].variant)!==null&&O!==void 0?O:k[M].enabled]})),I=Object.fromEntries(Object.keys(k).filter(M=>k[M].enabled).filter(M=>{var O;return!x((O=k[M].metadata)===null||O===void 0?void 0:O.payload)}).map(M=>{var O;return[M,(O=k[M].metadata)===null||O===void 0?void 0:O.payload]}));return f(f({},w),{},{featureFlags:P,featureFlagPayloads:I})}return w.featureFlags&&E.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),w})(r,u),h=c.flags,d=c.featureFlags,p=c.featureFlagPayloads;if(!d)return;const v=r.requestId,_=r.evaluatedAt;if(F(d)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const w={};if(d)for(let E=0;d.length>E;E++)w[d[E]]=!0;return{[We]:d,[Ae]:w,[os]:!1}}let g=d,y=p,m=h;if(l?.partialResponse){const w=Object.keys(g),E=y||{};g=f(f({},n),g),y=f(f({},o),E),w.forEach(k=>{k in E||y==null||delete y[k]}),m=f(f({},a),m)}else if(r.errorsWhileComputingFlags)if(h){const w=new Set(Object.keys(h).filter(k=>{var P;return!(!((P=h[k])===null||P===void 0)&&P.failed)}));g=f(f({},n),Object.fromEntries(Object.entries(g).filter(([k])=>w.has(k))));const E=Object.fromEntries(Object.entries(y||{}).filter(([k])=>w.has(k)));y=f(f({},o),E),w.forEach(k=>{k in E||y==null||delete y[k]}),m=f(f({},a),Object.fromEntries(Object.entries(m||{}).filter(([k])=>w.has(k))))}else g=f(f({},n),g),y=f(f({},o),y),m=f(f({},a),m);return f(f({[We]:Object.keys(Fo(g)),[Ae]:g||{},[rt]:y||{},[vt]:m||{},[os]:r.minimalFlagCalledEvents===!0},v?{[gt]:v}:{}),_?{[nt]:_}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.A);if(i)if(s?.persist===!1){const r=!x(this._o.kv.get(Ae));this.Zd=i,r||this.$t(i)}else this.jd(),this.Xd(i,e,!!s?.partialResponse),this.$t(i);else t&&this.Jd();t||(this._d=!1),this.zd(t)}override(e,t=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.lv(e)}lv(e){if(this._o){if(e===!1)return this.Pt([Ne,pt]),this.zd(),void ct.info("All overrides cleared");if(F(e))return this.$t({[Ne]:Oo(e)}),this.zd(),void ct.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;const s=e;this.ad=!!((t=s.suppressWarning)!==null&&t!==void 0&&t);const i={},r=s.flags,n=s.payloads;return r&&(i[Ne]=F(r)?Oo(r):r),n&&(i[pt]=n),Object.keys(i).length&&this.$t(i),r===!1&&n===!1?this.Pt([Ne,pt]):r===!1?this.Pt(Ne):n===!1&&this.Pt(pt),this.zd(),r===!1?ct.info("Flag overrides cleared"):r&&ct.info("Flag overrides set",{flags:r}),void(n===!1?ct.info("Payload overrides cleared"):n&&ct.info("Payload overrides set",{payloads:n}))}if(e&&typeof e=="object")return this.$t({[Ne]:e}),this.zd(),void ct.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.fd){const{flags:t,flagVariants:s}=this.uv();try{e(t,s)}catch(i){this.A.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var i;const r=(this.Qd("$early_access_features")||[]).find(u=>u.flagKey===e),n={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:n};r&&(o.$early_access_feature_name=r.name),s&&(o.$feature_enrollment_stage=s);const a=f(f({},this.getFlagVariants()),{},{[e]:t});(i=this.Rd)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(n)}),this.$t({[We]:Object.keys(Fo(a)),[Ae]:a,[st]:f(f({},this.Qd("$stored_person_properties")||{}),n)}),this.zd();try{var l;(l=this._o)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(u){this.A.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(e,t=!1,s){const i=this.Qd(lr);!i||t?this.hv(e,s):e(i)}hv(e,t){var s=this;return X(function*(){const i=s._o;if(!i)return;const r=t?`&${t.map(o=>`stage=${o}`).join("&")}`:"";let n;try{const o=yield i.sendRequest(`/api/early_access_features/?token=${i.projectToken}${r}`,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;n=o.json.earlyAccessFeatures,s.$t({[lr]:n})}catch(o){return void s.A.error("Early access feature request failed",o)}try{e(n)}catch(o){s.A.error("Early access feature callback failed",o)}})()}uv(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(s=>t[s]),flagVariants:Object.keys(t).filter(s=>t[s]).reduce((s,i)=>(s[i]=t[i],s),{})}}zd(e){this.Bd();const{flags:t,flagVariants:s}=this.uv();this.featureFlagEventHandlers.forEach(i=>{try{i(t,s,{errorsLoading:e})}catch(r){this.A.error("Error while running feature flags callback",r)}})}setPersonPropertiesForFlags(e,t=!0){this.dv(e,t)}dv(e,t=!0){const s=this.Qd("$stored_person_properties")||{},i=e?.$set||(e?.$set_once?{}:e),r=e?.$set_once,n={};if(r)for(const o in r)({}).hasOwnProperty.call(r,o)&&(o in s||(n[o]=r[o]));this.$t({[st]:f(f(f({},s),n),i)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const s=f({},this.Qd("$stored_person_properties")||{});e.forEach(i=>{delete s[i]}),this.$t({[st]:s}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Pt(st),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const s=this.Qd("$stored_group_properties")||{},i=f({},s);for(const r of Object.keys(e))i[r]=f(f({},s[r]),e[r]);this.$t({[tt]:i}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.Qd("$stored_group_properties")||{};this.$t({[tt]:f(f({},t),{},{[e]:{}})})}else this.Pt(tt)}reset(){this.gd++,this.Vd(this.dd,"cancelled"),this.Vd(this.vd,"cancelled"),this.yd=!1,this.ld={},this.ud={},this.Zd=void 0,this.fd=!1,this.md=!1,this.bd=!1,this.$anon_distinct_id=void 0,this.Gd(),this.ad=!1,this.wd=0}};const Co=ee("[FeatureFlags]");var tp=class{constructor(e,t=!1){this.vv=!1,this.update(e,t)}update(e,t){this.fv=((s,i)=>{var r,n,o,a,l,u,c,h;return{bootstrap:{featureFlags:(r=(n=s.bootstrap)===null||n===void 0?void 0:n.featureFlags)!==null&&r!==void 0?r:void 0,featureFlagPayloads:(o=(a=s.bootstrap)===null||a===void 0?void 0:a.featureFlagPayloads)!==null&&o!==void 0?o:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!s.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!s.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!s.advanced_feature_flags_dedup_per_session,cacheTtlMs:s.feature_flag_cache_ttl_ms,refreshIntervalMs:(l=s.remote_config_refresh_interval_ms)!==null&&l!==void 0?l:3e5,idleRefreshBackoff:x(s.remote_config_refresh_interval_ms),requestTimeoutMs:s.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(u=s.feature_flag_request_max_retries)!==null&&u!==void 0?u:1),compression:s.disable_compression?void 0:"best-available",evaluationContexts:(c=(h=s.evaluation_contexts)!==null&&h!==void 0?h:s.evaluation_environments)!==null&&c!==void 0?c:[],flagKeys:F(s.flag_keys)?s.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.vv||(Co.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.vv=!0),x(e.flag_keys)||F(e.flag_keys)||Co.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.fv}};const Ao=e=>Vt(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Fe=ee("[Error tracking]"),Pr="webkit-masked-url:",sp=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],ip=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Pr],rp=["__firefox__","__gCrWeb"],To="Refusing to render web experiment since the viewer is a likely bot",np={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>si(t,e),not_regex:(e,t)=>!si(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Ie=ee("[Conversations]"),dt="Conversations not available yet.";function Ro(e,t){var s,i,r,n,o,a,l;const u=(s=e?.flushIntervalMs)!==null&&s!==void 0?s:3e3,c=(i=e?.maxBufferSize)!==null&&i!==void 0?i:100,h=t?.consoleCapture?void 0:(r=e?.maxLogsPerInterval)!==null&&r!==void 0?r:1e3,d=x(h)?Math.max(c,2048):Math.max(c,h),p=f(f({},(function(){let v="",_="";try{var g;const y="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,m=y==null||(g=y.navigator)===null||g===void 0?void 0:g.userAgent;m&&([v,_]=ma(m))}catch{}return(function(y,m){const w=(function(E){if(E)return{}.hasOwnProperty.call(Pn,E)?Pn[E]:E})(y);return f(f({},w?{"os.name":w}:{}),m?{"os.version":m}:{})})(v,_)})()),e?.resourceAttributes);return{serviceName:(n=(o=p?.["service.name"])!==null&&o!==void 0?o:e?.serviceName)!==null&&n!==void 0?n:t?.serviceNameDefault,serviceVersion:(a=p?.["service.version"])!==null&&a!==void 0?a:e?.serviceVersion,environment:(l=p?.["deployment.environment"])!==null&&l!==void 0?l:e?.environment,resourceAttributes:p,beforeSend:e?.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const op=["debug","log","warn","error","info"],ap=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},Lo="console",vu="__posthogHandledLogsRequestError",Ji=(e,t)=>{const s=e instanceof Error?e:new Error(t);return s[vu]=!0,s},Do=e=>!!e&&typeof e=="object"&&e[vu]===!0;var lp=class{get pv(){return f(f({},this.A),{},{error:(...e)=>{e.some(Do)||this.A.error(...e)}})}constructor(e,t){var s;this.ko=e,this.gv=t,this.name="logs",this.mv=!1,this.yv=!1,this.bv=!1,this.A=ee("[logs]"),this.al=[],this._v=[],this.wd=0,this.wv=!1,this.Io=!1,this.Sv=[],this.xv=[],this.$v=!1,this.Cv=!1,this.Tv=!1,this.Iv=()=>{var i,r;this.Io||(this.wd=0,(i=this.Mv)===null||i===void 0||i.onReconnect(),(r=this.Ev)===null||r===void 0||r.onReconnect())},this.mv=!!(!((s=e.get())===null||s===void 0)&&s.captureConsoleLogs)}get Pv(){return!0}Rv(){}Av(){if(!this.Tv){try{this.Od=typeof window>"u"?void 0:window}catch{this.Od=void 0}this.Od&&(W(this.Od,"online",this.Iv),this.Tv=!0)}}Fv(e,t,s,i){this.Av();const r=Ro(this.ko.get(),s);return[new Zc(this.Ov(e,t),r,this.pv,()=>this.gv(),n=>n(),void 0,i),r]}Dv(){const e=this.ko.get();var t;return this.Mv&&this.Lv===e||((t=this.Mv)===null||t===void 0||t.reset(),this.Lv=e,[this.Mv,this.Nv]=this.Fv(()=>this.al,s=>{this.al=s})),this.Mv}qv(){const e=this.ko.get();var t;return this.Ev&&this.jv===e||((t=this.Ev)===null||t===void 0||t.reset(),this.jv=e,[this.Ev,this.Bv]=this.Fv(()=>this._v,s=>{this._v=s},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Lo)),this.Ev}setup(e){if(!this.Io&&!this.wv)return this.wv=!0,this._o=e,this.A=e.logger.createLogger("[logs]"),Xr(e.kv.initialize(),()=>{this.Io||this.Dd(e)})}Dd(e){var t;this.Av(),!((t=this.ko.get())===null||t===void 0)&&t.captureConsoleLogs&&(this.mv=!0),(this.mv||this.ko.remoteConfigWillArrive&&e.kv.get(this.ko.captureHintKey))&&this.zv();let s=!1;const i=e.onRemoteConfig(r=>{var n;s=r.ok&&((n=r.config.logs)===null||n===void 0?void 0:n.captureConsoleLogs)===!0,this.onRemoteConfig(r)});this.Io?i.dispose():(this.Po=i,s||this.loadIfEnabled())}dispose(){var e,t,s,i,r,n,o;this.Io||(this.Io=!0,this.Hv(),(e=this.Po)===null||e===void 0||e.dispose(),this.Po=void 0,this._o=void 0,this.bv=!1,(t=this.Od)===null||t===void 0||t.removeEventListener("online",this.Iv),(s=this.Uv)===null||s===void 0||s.call(this),this.Uv=void 0,(i=this.Mv)===null||i===void 0||i.clearQueue(),(r=this.Ev)===null||r===void 0||r.clearQueue(),(n=this.Mv)===null||n===void 0||n.reset(),(o=this.Ev)===null||o===void 0||o.reset())}onRemoteConfig(e){var t,s;if(this.Io)return;const i=e.ok?(t=e.config.logs)===null||t===void 0?void 0:t.captureConsoleLogs:void 0;R(i)?this.Wv():((s=this._o)===null||s===void 0||s.kv.set(this.ko.captureHintKey,!!i),i?(this.mv=!0,this.yv||this.zv(),this.loadIfEnabled()):this.Wv())}reset(){var e,t,s,i;this.Hv(),(e=this.Mv)===null||e===void 0||e.clearQueue(),this.al=[],(t=this.Mv)===null||t===void 0||t.reset(),(s=this.Ev)===null||s===void 0||s.clearQueue(),this._v=[],(i=this.Ev)===null||i===void 0||i.reset(),this.wd=0}captureLog(e){!this.Io&&this._o&&this.Dv().captureLog(e)}captureConsoleLog(e){!this.Io&&this._o&&this.qv().captureLog(e)}captureBufferedConsoleLog(e,t,s){!this.Io&&this._o&&this.qv().captureLog(e,{context:t,occurredAtMs:s})}Cc(){var e;this.Hv(),(e=this.Ev)===null||e===void 0||e.clearQueue(),this._v=[]}Wv(){this.mv||this.Hv()}zv(){var e;if(this.$v||!(!((e=this.Od)===null||e===void 0)&&e.console))return;const t=Ro(this.ko.get()).maxBufferSize;let s=!0;this.xv.push(()=>{s=!1});for(const i of op){let r;try{r=ap(this.Od.console[i])}catch{continue}r&&this.xv.push(zt(this.Od.console,i,n=>{const o=(...a)=>{try{s&&this.Vv(i,a,t)}catch{}return n.apply(this.Od.console,a)};return o.__rrweb_original__=r,o}))}this.$v=!0,this.Gv=setTimeout(()=>{this.Hv()},3e4)}Vv(e,t,s){var i;if(this.$v&&!this.Cv&&t.length!==0)if(!((i=this._o)===null||i===void 0)&&i.canCapture){if(s>this.Sv.length){this.Cv=!0;try{this.Sv.push({level:e,args:t,occurredAtMs:Date.now(),context:this.gv()})}finally{this.Cv=!1}}}else this.Hv()}Hv(){if(this.Sv=[],this.$v){this.$v=!1,this.Gv&&(clearTimeout(this.Gv),this.Gv=void 0);for(const e of this.xv)e();this.xv=[]}}Qv(){const e=this.Sv;return this.Hv(),e}get logger(){return this.Zv||(this.Zv={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.Zv}flushLogs(e){this._o&&(e?this.Jv(e):(this.Mv&&this.Mv.flush().catch(t=>this.Kv(t)),this.Ev&&this.Ev.flush().catch(t=>this.Kv(t))))}flush(){var e=this;return X(function*(){var t,s;const i=(t=e.Mv)===null||t===void 0?void 0:t.flush().catch(n=>e.Kv(n)),r=(s=e.Ev)===null||s===void 0?void 0:s.flush().catch(n=>e.Kv(n));yield i,yield r})()}Kv(e){Do(e)||this.A.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.Io||!this.mv||this.yv||this.bv)return;const e=this.Rv();if(e){this.bv=!0;try{e((t,s)=>{if(this.bv=!1,!this.Io&&this.mv)if(t||!s)this.A.error("Could not load logs script",t),this.Hv();else{const i=this.Qv();this.Uv=s.initialize(this._o),this.yv=!0,i.length>0&&s.replay(this._o,i)}})}catch(t){throw this.bv=!1,t}}else this.Hv()}Ov(e,t){const s=this._o;return{get isDisabled(){return!1},get optedOut(){return!s.canCapture},getPersistedProperty:i=>i===je.LogsQueue?e():void 0,setPersistedProperty(i,r){i===je.LogsQueue&&t(r??[])},js:i=>this.js(i),getLibraryId:()=>s.library.name,getLibraryVersion:()=>s.library.version}}js(e){return new Promise(t=>{if(Ol(this.wd,3))return void t({kind:"fatal",error:Ji(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1;const i=o=>{s||(s=!0,clearTimeout(r),t(o))},r=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:Ji(void 0,"logs request timed out")})},9e4),n=this.Pv;this._o.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._o.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(o=>{var a;const l=o.statusCode;this.Xv(l,n),l>=200&&300>l?i({kind:"ok"}):l===413?i({kind:"too-large"}):l!==0&&l!==408&&l!==429&&500>l?i({kind:"fatal",error:new Error(`logs request failed with status ${l}`)}):l===0?(o.error||this.A.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:Ji(o.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${l}`)})},o=>{i({kind:"retry-later",error:o})})})}Xv(e,t){(e!==0||t)&&(this.wd=Fl(e,this.wd,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Jv(e){this.al.length>0&&this.Yv(e,this.al,this.Nv,this._o.library.name,t=>{this.al=t}),this._v.length>0&&this.Yv(e,this._v,this.Bv,Lo,t=>{this._v=t})}Yv(e,t,s,i,r){if(t.length===0)return;const n=t.map(a=>a.record);r([]);const o=Ha(n,qa(s,this._o.library.name,this._o.library.version),i,this._o.library.version);this._o.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._o.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(a=>this.Kv(a))}};const ii=ee("[NetworkMetrics]"),Zr=()=>{var e;return!(b==null||(e=b.performance)===null||e===void 0)&&e.now?b.performance.now():Date.now()},up={"http:":80,"https:":443},cp=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),gu=(e,t)=>{var s;const i=String(t);return{method:String(e).toUpperCase(),url:((s=Je(i))===null||s===void 0?void 0:s.href)||i}},Mr=(e,t,s,i,r,n,o=!1)=>{try{var a,l;const u=r();if(!u)return;const c=s||void 0,h=Zr()-i,d=Je(t.url);if(d&&d.protocol!=="http:"&&d.protocol!=="https:")return;const p={url:d?.href||t.url,method:t.method},v=oe(u.name)?u.name(p):D(u.name)?u.name:"http.client.request.duration";if(!v)return;const _=o&&!c?void 0:((y,m)=>y?400>y?void 0:String(y):m?.name||"_OTHER")(c,n),g=f(f(f(f(f({},(y=>{const m=cp.has(y)?y:"_OTHER";return f({"http.request.method":m},m==="_OTHER"&&y!==m?{"http.request.method_original":y}:{})})(p.method)),d?(y=>{return{"server.address":y.hostname.startsWith("[")&&y.hostname.endsWith("]")?y.hostname.slice(1,-1):y.hostname,"server.port":Number(y.port)||up[y.protocol],"url.scheme":y.protocol.slice(0,-1),"url.template":(m=y.pathname,m.split("/").map(w=>(E=>/^\d+$/.test(E)||E.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(E))(w)?":id":w).join("/"))};var m})(d):{}),c?{"http.response.status_code":c}:{}),_?{"error.type":_}:{}),(a=u.attributes)===null||a===void 0?void 0:a.call(u,p,{status:c,durationMs:h}));(l=e.metrics)===null||l===void 0||l.histogram(v,h,{unit:"ms",attributes:g})}catch(u){ii.error("Failed to record network metric",u)}},_u=()=>{},dp=(e,t)=>oe(b?.fetch)?zt(b,"fetch",s=>function(...i){const r=Zr(),n=s.apply(this,i);if(!t())return n;try{var o,a,l;const[u,c]=i,h=gu((o=(a=c?.method)!==null&&a!==void 0?a:u?.method)!==null&&o!==void 0?o:"GET",(l=u?.url)!==null&&l!==void 0?l:u);return n.then(d=>(Mr(e,h,d?.status,r,t,void 0,!0),d),d=>{throw Mr(e,h,void 0,r,t,d),d})}catch(u){return ii.error("Failed to observe fetch",u),n}}):_u,hp=(e,t)=>{var s;const i=b==null||(s=b.XMLHttpRequest)===null||s===void 0?void 0:s.prototype;if(!i)return _u;const r=new WeakMap,n=zt(i,"open",a=>function(...l){try{Ul.has(this)||r.set(this,gu(l[0],l[1]))}catch(u){ii.error("Failed to observe XHR open",u)}return a.apply(this,l)}),o=zt(i,"send",a=>function(...l){let u;try{const c=r.get(this);if(c&&t()){const h=Zr();u=()=>{this.removeEventListener("loadend",u),Mr(e,c,this.status,h,t)},W(this,"loadend",u)}}catch(c){ii.error("Failed to observe XHR send",c)}try{return a.apply(this,l)}catch(c){throw u&&this.removeEventListener("loadend",u),c}});return()=>{n(),o()}},No=new WeakMap,pp=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),fp={maxStringLength:2048,truncationSuffix:"..."},vp={maxStringLength:2048,truncationSuffix:"..."};function jo(e){if(e)return e===!0?{intent:!0,model:!0}:{intent:e.intent!==!1,model:e.model!==!1}}function Ki(e,t){return{}.hasOwnProperty.call(e,t)}function Qi(e,t){const s=Object.create(e);return t&&Object.defineProperty(s,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),s}function qo(e,t,s=!1){if(!D(e))return;const i=e.trim();return i?(s?Ra(i,fp):i).slice(0,t):void 0}function Ho(e){try{return L(e)&&e.isError===!0}catch{return!1}}function mu(e){return Ra(e||"Unknown error",vp).slice(0,2048)}function gp(e,t){try{return mu(t?(function(s){try{return!L(s)||!F(s.content)?void 0:s.content.filter(i=>L(i)&&i.type==="text"&&D(i.text)).map(i=>i.text).join(" ").trim()||void 0}catch{return}})(e):L(e)&&D(e.message)?e.message:D(e)?e:String(e))}catch{return"Unknown error"}}function _p(e,t,s){return t.errorResult?[{type:"Error",value:s,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:e.buildProperties(t.error,{handled:!0}).$exception_list.map(i=>f(f({},i),{},{value:mu(i.value)}))}function mp(e,t){if(t)return"Error";try{if(!L(e))return"Error";let s=D(e.name)?e.name.trim():"";const i=e.constructor;return s&&s!=="Error"||!oe(i)||i.name==="Error"||(s=i.name),(s||"Error").slice(0,256)}catch{return"Error"}}function yp(e,t){return{message:gp(e,t),type:mp(e,t)}}const ai={featureFlags:class extends ep{constructor(e){const t=new tp(e.config,e.nl());super(t),this.name=cu,this._instance=e,this.tf=t}get Rd(){return this._instance.persistence}updateConfig(e,t){this.tf.update(e,t),this.Ad()}}},bp={sessionRecording:class{get Mr(){return this._instance.config}get Ml(){return this._instance.persistence}get started(){var e;return!!(!((e=this.ef)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.if==="awaiting_config"||this.if==="missing_config"?this.if:(e=(t=this.ef)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.if}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.if=Vi,this.nf=void 0,this.sf=!1,this.Je=(()=>{var t,s;if(!$?.visibilityState||$.visibilityState==="visible")return!0;const i=b==null||(t=b.performance)===null||t===void 0||(s=t.getEntriesByType)===null||s===void 0?void 0:s.call(t,"visibility-state");return!i?.length||i.some(r=>r.name==="visible")})(),this.sn=()=>{var t,s;$?.visibilityState==="visible"&&(this.Je=!0,(t=this.ef)===null||t===void 0||(s=t.setDocumentWasEverVisible)===null||s===void 0||s.call(t,!0))},!this._instance.sessionManager)throw Be.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');$?.addEventListener&&W($,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.sf=!0,$==null||(t=$.removeEventListener)===null||t===void 0||t.call($,"visibilitychange",this.sn),e?this.rf(!0):this.stopRecording()}get af(){var e;const t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),s=!this.Mr.disable_session_recording,i=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return b&&t&&s&&!i}startIfEnabledOrStop(e){var t;if(this.sf||this.af&&(!((t=this.ef)===null||t===void 0)&&t.isStarted))return;const s=!x(Object.assign)&&!x(Array.from);this.af&&s?(this.lf(e),Be.info("starting")):(this.if=Vi,this.stopRecording())}lf(e){var t,s;if(this.af)if(this.if!=="awaiting_config"&&this.if!=="missing_config"&&(this.if=xo),(T==null||(t=T.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((s=T.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this.uf(e);else{var i,r;const n=this._instance.sessionManager;(i=T.__PosthogExtensions__)===null||i===void 0||(r=i.loadExternalDependency)===null||r===void 0||r.call(i,this._instance,this.cf,o=>{if(!this.sf&&this.af&&this._instance.sessionManager===n)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Be.error("could not load recorder",o)):void this.uf(e);this.if="disabled"})}}stopRecording(){var e,t;(e=this.nf)===null||e===void 0||e.call(this),this.nf=void 0,(t=this.ef)===null||t===void 0||t.stop()}rf(e=!1){var t,s;(t=this.nf)===null||t===void 0||t.call(this),this.nf=void 0,(s=this.ef)===null||s===void 0||s.discard({discardProducerEvents:e})}hf(){var e,t;(e=this.Ml)===null||e===void 0||e.unregister("$session_is_sampled"),(t=this.Ml)===null||t===void 0||t.unregister("$replay_sample_rate")}df(e,t){if(R(e))return null;const s=ne(e)?e:parseFloat(e);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Be.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):s;var i}vf(e){if(this.Ml){var t,s;const i=this.Ml,r=()=>{var n;const o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.df((n=this.Mr.session_recording)===null||n===void 0?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.df(o?.sampleRate,"remote config sampleRate"),u=a??l;R(u)&&this.hf();const c=o?.minimumDurationMilliseconds;i.register({[ls]:f(f({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:f({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:x(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(t=this.nf)===null||t===void 0||t.call(this),this.nf=(s=this._instance.sessionManager)===null||s===void 0?void 0:s.onSessionId(r)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.vf(t),void this.rf()):(this.vf(t),void this.startIfEnabledOrStop()):(this.if==="awaiting_config"&&(this.if="missing_config",this._instance.register_for_session({[Hr]:!0}),Be.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var s;!((s=this.ef)===null||s===void 0)&&s.log?this.ef.log(e,t):Be.warn("log called before recorder was ready")}get cf(){var e,t;const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(ls);return(s==null||(t=s.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}ff(){const e=this._instance.get_property(ls);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return Be.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!R(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}uf(e){var t,s,i;if(!this.sf&&this.af&&this._instance.sessionManager){if(!(!((t=T.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return Be.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[qr]:!0});var r;if(this.ef||(this.ef=(r=T.__PosthogExtensions__)===null||r===void 0?void 0:r.initSessionRecording(this._instance,this.Je),this.ef._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ff())return this.if==="missing_config"||this.if==="awaiting_config"?void 0:(this.if="awaiting_config",Be.info("persisted remote config is stale, requesting fresh config before starting"),void new ql(this._instance).load());this.if=xo,(s=(i=this.ef).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Je),this.ef.start(e)}else this.if=Vi}onRRwebEmit(e){var t,s;(t=this.ef)===null||t===void 0||(s=t.onRRwebEmit)===null||s===void 0||s.call(t,e)}overrideLinkedFlag(){var e,t;this.ef||(t=this.Ml)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.ef)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.ef||(t=this.Ml)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.ef)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,s;this.ef||(s=this.Ml)===null||s===void 0||s.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.ef)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const i of zh){var s;const r=(s=this._instance.sessionPersistence)===null||s===void 0?void 0:s.get_property(i);x(r)||(t[i]=r)}return f(f({},t),((e=this.ef)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var s;return!!(!((s=this.ef)===null||s===void 0)&&s.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.ef)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},wp={autocapture:class extends Nh{constructor(e){super(new jh(e)),this.instance=e}},historyAutocapture:class{constructor(e){this.pf=!1,this._instance=e,this.gf=this.mf()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.yf();return!!(e.path||e.search||this.bf(e))}startIfEnabled(){this.isEnabled&&(S.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.gf=this.mf(),this.startIfEnabled()}stop(){this._f&&this._f(),this._f=void 0,this.wf&&this.wf(),this.wf=void 0,S.info("History API monitoring stopped")}monitorHistoryChanges(){b&&b.history&&(this.kf("pushState"),this.kf("replaceState"),this.Sf(),this.bf()&&this.xf())}kf(e){var t;if(!b||!((t=b.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const s=this;zt(b.history,e,i=>function(r,n,o){var a;s.$f(o)&&s.Cf(),i.call(this,r,n,o),s.Tf(e,!s.pf&&(b==null||(a=b.event)===null||a===void 0?void 0:a.type)!=="popstate")})}mf(){const e=b?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}yf(){const e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:L(e)?e:{}}bf(e=this.yf()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}If(e){const t=this.yf(),s=this.gf;return!(!s||!(t.path&&e.pathname!==s.pathname||t.search&&e.search!==s.search||this.bf(t)&&e.hash!==s.hash))}Tf(e,t=!1){try{t||this.Cf();const s=this.mf();if(!s)return;if(this.If(s)){const i=()=>this._instance.capture(zr,{navigation_type:e});t?(this.Mf=i,Promise.resolve().then(()=>this.Cf())):i()}this.gf=s}catch(s){S.error(`Error capturing ${e} pageview`,s)}}$f(e){var t,s;return!(R(e)||!b)&&((t=Je(String(e)))===null||t===void 0?void 0:t.href)!==((s=b.location)===null||s===void 0?void 0:s.href)}Cf(){const e=this.Mf;if(e){this.Mf=void 0,this.pf=!0;try{e()}catch(t){S.error("Error capturing deferred pageview",t)}finally{this.pf=!1}this.gf=this.mf()}}Sf(){if(this._f)return;const e=()=>{this.Tf("popstate")};W(b,"popstate",e),this._f=()=>{b&&b.removeEventListener("popstate",e)}}xf(){if(this.wf)return;const e=()=>{this.Tf("hashchange")};W(b,"hashchange",e),this.wf=()=>{b&&b.removeEventListener("hashchange",e)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(e){var t;this.Ef=!1,this.So=!1,this.Pf=null,this.instance=e,this.Ef=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[cr]),this.rageclicks=new fu(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return L(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return R(this.Mr.capture_heatmaps)?R(this.Mr.enable_heatmaps)?this.Ef:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.So)return;Vh.info("starting..."),this.Rf(),this.sn()}else{var e;clearInterval((e=this.Pf)!==null&&e!==void 0?e:void 0),this.Af(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const s=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[cr]:s}),this.Ef=s,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}Ff(e){Wi(e.originalEvent)&&this.Ir(e.originalEvent,"deadclick")}sn(){this.Pf&&clearInterval(this.Pf),this.Pf=$?.visibilityState==="visible"?setInterval(this.pl.bind(this),this.flushIntervalMilliseconds):null}Rf(){b&&$&&(this.Of=this.pl.bind(this),W(b,Qs,this.Of),this.Df=e=>this.Ir(e||b?.event),W($,"click",this.Df,{capture:!0}),this.Lf=e=>this.Nf(e||b?.event),W($,"mousemove",this.Lf,{capture:!0}),this.qf=new Kn(this.instance,Wd,this.Ff.bind(this)),this.qf.startIfEnabledOrStop(),this.jf=this.sn.bind(this),W($,ms,this.jf),this.So=!0)}Af(){var e;b&&$&&(this.Of&&b.removeEventListener(Qs,this.Of),this.Df&&$.removeEventListener("click",this.Df,{capture:!0}),this.Lf&&$.removeEventListener("mousemove",this.Lf,{capture:!0}),this.jf&&$.removeEventListener(ms,this.jf),clearTimeout(this.Bf),(e=this.qf)===null||e===void 0||e.stop(),this.So=!1)}zf(e,t){const s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){let u=o;for(;u&&Re(u)&&!pe(u,"body");){if(u===l)return!1;let p;try{var c,h,d;p=(c=(h=(d=u.ownerDocument)===null||d===void 0?void 0:d.defaultView)!==null&&h!==void 0?h:b)===null||c===void 0?void 0:c.getComputedStyle(u).position}catch{return!1}if(A(a,p))return!0;u=wl(u)}return!1})(cs(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:i),y:e.clientY+(n?0:s),target_fixed:n,type:t}}Ir(e,t="click"){var s;if(Nn(e.target)||!Wi(e))return;const i=this.zf(e,t);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,new Date().getTime())&&kl(cs(e),this.instance.config.rageclick)&&this.Qs(f(f({},i),{},{type:"rageclick"})),this.Qs(i)}Nf(e){!Nn(e.target)&&Wi(e)&&(clearTimeout(this.Bf),this.Bf=setTimeout(()=>{this.Qs(this.zf(e,"mousemove"))},500))}Qs(e){if(!b)return;const t=this.Mr.disable_capture_url_hashes?ot(b.location.href):b.location.href,s=this.Mr.custom_personal_data_properties,i=this.Mr.mask_personal_data_properties?[...Ht,...s||[]]:[],r=bs(t,i,ws);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(e)}pl(){this.Rt&&!$e(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Kn,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.Ef=!1,this.So=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Hf=()=>{clearTimeout(this.Uf),this.Uf=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",f({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>f(f({},s),{},{[`$web_vitals_${i.name}_event`]:f({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Wf=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},R(s?.name)||R(s?.value))return void ut.error("Invalid metric received",s);const r=typeof s.navigationURL=="string"?s.navigationURL:void 0,n=this.Vf(r);if(x(n))return;const o=ne(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${n}`;if(this.Gf&&s.value>=this.Gf)return void ut.error("Ignoring metric with value >= "+this.Gf,s);this.Rt.navigationKey!==o&&(this.Hf(),this.Uf=setTimeout(this.Hf,this.flushToCaptureTimeoutMs)),x(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=n),this.Rt.firstMetricTimestamp=x(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const a=(i=this._instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0),l=f(f(f({},s),r?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,L(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){const u={};for(const c of Bh){const h=c==="url"&&typeof s.attribution[c]=="string"?this.Vf(s.attribution[c]):s.attribution[c];x(h)||(u[c]=h)}l.attribution=u}else delete l.attribution;x(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.Hf()},this.Qf=()=>{if(this.So)return;let s,i,r,n,o=!1;const a=T.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.Zf]||(this.Zf==="web-vitals"&&x(l)?a?.postHogWebVitalsCallbacks:void 0);if(!x(u)){const d=u.withoutAttribution,p=this.attributionMetrics;o=!x(d),s=p.indexOf("LCP")>-1?u.onLCP:d?.onLCP||u.onLCP,i=p.indexOf("CLS")>-1?u.onCLS:d?.onCLS||u.onCLS,r=p.indexOf("FCP")>-1?u.onFCP:d?.onFCP||u.onFCP,n=p.indexOf("INP")>-1?u.onINP:d?.onINP||u.onINP}if(!(s&&i&&r&&n))return void ut.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},h=o&&this.attributionMetrics.indexOf("INP")>-1?f(f({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&s(this.Wf.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Wf.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Wf.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Wf.bind(this),h),this.So=!0},this.Ef=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[pr]),this.startIfEnabled()}get Jf(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const s=L(this.Jf)?(e=this.Jf)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return R(s)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||wo:s}get flushToCaptureTimeoutMs(){return(L(this.Jf)?this.Jf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=L(this.Jf)?this.Jf.web_vitals_attribution:void 0;return we(e)?e?wo:[]:F(e)?e:Hh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=L(this.Jf)?this.Jf.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Gf(){const e=L(this.Jf)&&ne(this.Jf.__web_vitals_max_value)?this.Jf.__web_vitals_max_value:bo;return e>0&&6e4>=e?bo:e}get isEnabled(){const e=Q?.protocol;if(e!=="http:"&&e!=="https:")return ut.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=L(this.Jf)?this.Jf.web_vitals:we(this.Jf)?this.Jf:void 0;return we(t)?t:this.Ef}startIfEnabled(){this.isEnabled&&!this.So&&(ut.info("enabled, starting..."),this.Ho(this.Qf))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const s=L(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=L(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[pr]:s}),this._instance.persistence.register({[Ka]:i})),this.Ef=s,this.startIfEnabled()}get Zf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ho(e){var t;const s=T.__PosthogExtensions__,i=this.Zf,r=s?.postHogWebVitalsCallbacksByFlavor;r?.[i]||i==="web-vitals"&&x(r)&&s?.postHogWebVitalsCallbacks?e():s==null||(t=s.loadExternalDependency)===null||t===void 0||t.call(s,this._instance,i,n=>{n?ut.error("failed to load script",n):e()})}Vf(e){const t=e||b?.location.href;if(!t)return void ut.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?ot(t):t,i=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Ht,...i||[]]:[];return bs(s,r,ws)}}},xp={exceptionObserver:class{constructor(e){var t;this.Qf=()=>{var s;if(!b||!this.isEnabled||!(!((s=T.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;const i=T.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=T.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=T.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Kf&&this.Mr.capture_unhandled_errors&&(this.Kf=i(this.captureException.bind(this))),!this.Xf&&this.Mr.capture_unhandled_rejections&&(this.Xf=r(this.captureException.bind(this))),!this.Yf&&this.Mr.capture_console_errors&&(this.Yf=n(this.captureException.bind(this)))}catch(o){es.error("failed to start",o),this.tp()}},this._instance=e,this.ep=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[dr]),this.wt=new Tu(f(f({},(function(s={}){var i,r,n,o;return{refillRate:(i=(r=s.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(n=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:es})),this.Mr=this.np(),this.startIfEnabledOrStop()}np(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return L(e)?t=f(f({},t),e):(x(e)?this.ep:e)&&(t=f(f({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(es.info("enabled"),this.tp(),this.Ho(this.Qf)):this.tp()}Ho(e){var t,s,i;!((t=T.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(s=T.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",r=>{if(r)return es.error("failed to load script",r);e()})}tp(){var e,t,s;(e=this.Kf)===null||e===void 0||e.call(this),this.Kf=void 0,(t=this.Xf)===null||t===void 0||t.call(this),this.Xf=void 0,(s=this.Yf)===null||s===void 0||s.call(this),this.Yf=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.ep=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[dr]:this.ep}),this.Mr=this.np(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.np()}captureException(e){try{var t,s,i;const r=(t=e==null||(s=e.$exception_list)===null||s===void 0||(s=s[0])===null||s===void 0?void 0:s.type)!==null&&t!==void 0?t:"Exception";if(this.wt.consumeRateLimit(r))return void es.info("Skipping exception capture because of client rate limiting.",{exception:r});(i=this._instance.exceptions)===null||i===void 0||i.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){var t,s;this.sp=[],this.rp=new Uu([new ac,new gc,new uc,new lc,new fc,new pc,new dc,new vc],(function(i,...r){return(n,o=0)=>{const a=[],l=n.split(`
3
- `),u=Math.min(l.length,o+1e3),c=[];for(let p=o;u>p;p++){const v=l[p];if(v.length>1024)continue;const _=mn.test(v)?v.replace(mn,"$1"):v;if(!_.match(/\S*Error: /)){for(const g of r){const y=g(_,i);if(y){a.push(y);const m=ic(a);if(m){for(let w=c.length-1;w>=0;w--){const E=c[w];if(m.start>=E.start+E.length)break;c.pop()}c.push(m)}break}}if(nc(a,c)>=50)break}}const h=[...c].sort((p,v)=>v.start-p.start),d=h[h.length-1];if(d){const p=Sa(a,d);a.splice(d.start-p,p);for(const v of h)v.start-=p}for(const p of h)rc(a,p);return c.some(p=>p.start===0&&a.length===p.length)&&(function(p){const v=p.map(g=>`${g.function}|${g.filename}|${g.lineno}|${g.colno}|${g.module}`);let _=0;for(let g=1;v.length>g;g++)oc(v,g,_)&&(_=g);p.push(...p.splice(0,_))})(a),(function(p){if(!p.length)return[];const v=Array.from(p);return v.reverse(),v.slice(0,50).map(_=>{return f(f({},_),{},{filename:_.filename||(g=v,g[g.length-1]||{}).filename,function:_.function||"?"});var g})})(a)}})("web:javascript",Zu,sc)),this._instance=e,this.sp=(t=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.op=Vs(this.ap()),this.lp=new mc(this.op)}onConfigChange(){this.op=Vs(this.ap()),this.lp.setConfig(this.op)}onRemoteConfig(e){var t,s,i;if(!e.ok)return;const r=e.config;if(!("errorTracking"in r))return;const n=(t=(s=r.errorTracking)===null||s===void 0?void 0:s.suppressionRules)!==null&&t!==void 0?t:[],o=(i=r.errorTracking)===null||i===void 0?void 0:i.captureExtensionExceptions;this.sp=n,this._instance.persistence&&this._instance.persistence.register({[Ga]:this.sp,[hr]:o})}get up(){var e;const t=!!this._instance.get_property(hr),s=this._instance.config.error_tracking.captureExtensionExceptions;return(e=s??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.rp.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.op.enabled)try{if(!D(e)||e.trim().length===0)return void Fe.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:s,droppedKeys:i}=(function(r){if(!r)return{sanitizedProperties:{},droppedKeys:[]};const n=[];return{sanitizedProperties:Object.keys(r).reduce((o,a)=>_c.has(a)?(n.push(a),o):(o[a]=r[a],o),{}),droppedKeys:n}})(this.cp(t));i.length>0&&Fe.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.lp.add(f({[Bs]:e,[zs]:new Date().toISOString()},s))}catch(s){Fe.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this.hp(t)){if(this.dp(t))return this.vp("Exception dropped: matched a suppression rule"),void Fe.info("Skipping exception capture because a suppression rule matched");if(!this.up&&this.fp(t))return this.vp("Exception dropped: thrown by a browser extension"),void Fe.info("Skipping exception capture because it was thrown by an extension");if(!this.up&&this.pp(t))return this.vp("Exception dropped: thrown by an injected browser script"),void Fe.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.gp(t))return this.vp("Exception dropped: thrown by the PostHog SDK"),void Fe.info("Skipping exception capture because it was thrown by the PostHog SDK")}const s=this.op.enabled&&R(e.$exception_steps)?this.mp(e):e,i=(function(){if("u">typeof process){var r;const o=(r=$u.POSTHOG_RELEASE_ID)===null||r===void 0?void 0:r.trim();if(o)return o}const n=globalThis._posthogReleaseId;return typeof n=="string"&&n.length>0?n:void 0})();i&&(s.$release_id=i);try{const r=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",dc:!0});return r&&this.lp.clear(),r}catch(r){return Ao(r)||Fe.error("Failed to capture exception event. Dropping this exception.",r),void this.lp.clear()}}catch(t){return void(Ao(t)||Fe.error("Failed to process exception event. Ignoring this exception.",t))}}mp(e){try{const t=this.lp.getAttachable();return t.length===0?e:f(f({},e),{},{$exception_steps:t})}catch(t){return Fe.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}vp(e){this.op.enabled&&this.lp.add({[Bs]:e,[zs]:new Date().toISOString()})}cp(e){return L(e)?f({},e):{}}ap(){var e,t;return(e=(t=this._instance.config.error_tracking)===null||t===void 0?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}dp(e){if(e.length===0)return!1;try{const t=e.reduce((s,{type:i,value:r})=>(D(i)&&i.length>0&&s.$exception_types.push(i),D(r)&&r.length>0&&s.$exception_values.push(r),s),{$exception_types:[],$exception_values:[]});return this.sp.some(s=>{const i=s.values.map(r=>{const n=ou[r.operator],o=t[r.key];if(!n||!o)return!1;const a=F(r.value)?r.value:[r.value];return a.length>0&&n(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(t){return Fe.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}fp(e){const t=e.flatMap(i=>{var r,n;return(r=(n=i.stacktrace)===null||n===void 0?void 0:n.frames)!==null&&r!==void 0?r:[]}),s=t.filter(({filename:i})=>!!i&&ip.some(r=>i.startsWith(r)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(Pr))||e.some(({type:i,value:r})=>i==="NoResponse"||D(r)&&sp.some(({value:n,exact:o})=>o?r===n:r.includes(n)))&&!t.some(({in_app:i,filename:r})=>i&&!r?.startsWith(Pr)))}pp(e){return e.some(({value:t})=>D(t)&&rp.some(s=>t.includes(s)))}gp(e){if(e.length>0){var t,s,i,r;const n=(t=(s=e[0].stacktrace)===null||s===void 0?void 0:s.frames)!==null&&t!==void 0?t:[],o=n[n.length-1];return(i=o==null||(r=o.filename)===null||r===void 0?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}hp(e){return!R(e)&&F(e)}}},kp=f({productTours:class{get Ml(){return this._instance.persistence}constructor(e){this.yp=null,this.bp=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var s,i;if(this.Ml&&this.Ml.register({[Nr]:!!t.productTours}),!Ui(this._instance))return!this.yp&&R((s=this.Ml)===null||s===void 0?void 0:s.props.ph_product_tours)||Os.info("product tours disabled; stopping and clearing cached tours"),(i=this.yp)===null||i===void 0||i.stop(),this.yp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.yp&&Ui(this._instance)&&this.Ho(()=>this._p())}Ho(e){var t,s,i;!((t=T.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(s=T.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",r=>{r?Os.error("Could not load product tours script",r):e()})}_p(){var e;!this.yp&&(!((e=T.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.yp=T.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(F(this.bp)&&!t)return void e(this.bp,{isLoaded:!0});const s=this.Ml;if(s){const i=s.props[fr];if(F(i)&&!t)return this.bp=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!Ui(this._instance))return void e([],{isLoaded:!0});const r=i.statusCode;if(r!==200||!i.json){const o=`Product Tours API could not be loaded, status: ${r}`;return r===0?i.error||Os.warn(o):Os.error(o),void e([],{isLoaded:!1,error:o})}const n=F(i.json.product_tours)?i.json.product_tours:[];this.bp=n,s&&s.register({[fr]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){R(this.yp)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.yp.getActiveProductTours(e)}showProductTour(e){var t;(t=this.yp)===null||t===void 0||t.showTourById(e)}previewTour(e){this.yp?this.yp.previewTour(e):this.Ho(()=>{var t;this._p(),(t=this.yp)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.yp)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.yp)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.yp)===null||e===void 0||e.previousStep()}clearCache(){var e;this.bp=null,(e=this.Ml)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.yp)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.yp)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.yp)===null||t===void 0||t.cancelPendingTour(e)}}},ai),$p={siteApps:class{constructor(e){this._instance=e,this.wp=0,this.kp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Sp(e,t){if(!t)return;const s=this.globalsForEvent(t);this.kp.push(s),this.kp.length>1e3&&(this.kp=this.kp.slice(10))}get siteAppLoaders(){var e;return(e=T._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this.Sp.bind(this));this.xp=()=>{e(),this.kp=[],this.xp=void 0}}}globalsForEvent(e){var t,s,i,r,n,o,a;if(!e)throw new Error("Event payload is required");const l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(const[p,v]of Object.entries(c))l[p]={id:u[p],type:p,properties:v};const{$set_once:h,$set:d}=e;return{event:f(f({},Oa(e,Wh)),{},{properties:f(f(f({},e.properties),d?{$set:f(f({},(t=(s=e.properties)===null||s===void 0?void 0:s.$set)!==null&&t!==void 0?t:{}),d)}:{}),h?{$set_once:f(f({},(i=(r=e.properties)===null||r===void 0?void 0:r.$set_once)!==null&&i!==void 0?i:{}),h)}:{}),elements_chain:(n=(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=e.properties)===null||a===void 0?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}$p(e){var t;const s=(t=e.tagName)===null||t===void 0?void 0:t.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(De.error("prepare_external_dependency_stylesheet returned null"),null):s==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(De.error("prepare_external_dependency_script returned null"),null):e}Cp(){var e,t,s,i,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=$?.defaultView,u=l==null||(e=l.Node)===null||e===void 0?void 0:e.prototype;if(!l||!u)return()=>{};if(this.wp++,this.Tp)return this.Ip();const c=[],h=this,d=new WeakSet,p=(g,y,m)=>{if(!g?.[y])return;const w=g[y];g[y]=m(w),c.push(()=>{g[y]=w})},v=g=>{if(d.has(g))return g;const y=h.$p(g);return y&&d.add(y),y},_=g=>g.map(y=>typeof y=="string"?y:v(y)).filter(y=>!se(y));return p(u,"appendChild",g=>function(y){const m=v(y);return m?g.call(this,m):y}),p(u,"insertBefore",g=>function(y,m){const w=v(y);return w?g.call(this,w,m):y}),p(u,"replaceChild",g=>function(y,m){const w=v(y);return w?g.call(this,w,m):m}),[(t=l.Element)===null||t===void 0?void 0:t.prototype,(s=l.Document)===null||s===void 0?void 0:s.prototype,(i=l.DocumentFragment)===null||i===void 0?void 0:i.prototype].forEach(g=>{p(g,"append",y=>function(...m){return y.apply(this,_(m))}),p(g,"prepend",y=>function(...m){return y.apply(this,_(m))})}),[(r=l.Element)===null||r===void 0?void 0:r.prototype,(n=l.CharacterData)===null||n===void 0?void 0:n.prototype,(o=l.DocumentType)===null||o===void 0?void 0:o.prototype].forEach(g=>{p(g,"before",y=>function(...m){return y.apply(this,_(m))}),p(g,"after",y=>function(...m){return y.apply(this,_(m))}),p(g,"replaceWith",y=>function(...m){const w=_(m);return m.length&&!w.length?void 0:y.apply(this,w)})}),p((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",g=>function(y,m){const w=v(m);return w?g.call(this,y,w):null}),this.Tp=()=>{c.forEach(g=>g()),this.Tp=void 0},this.Ip()}Ip(){let e=!1;return()=>{var t;e||(e=!0,this.wp--,this.wp===0&&((t=this.Tp)===null||t===void 0||t.call(this)))}}Mp(e,t=!0){const s=this.Cp();try{const i=e(s);return t&&s(),i}catch(i){throw s(),i}}setupSiteApp(e){const t=this.apps[e.id],s=()=>{var n;!t.errored&&this.kp.length&&(De.info(`Processing ${this.kp.length} events for site app with id ${e.id}`),this.kp.forEach(o=>this.Mp(()=>{var a;return(a=t.processEvent)===null||a===void 0?void 0:a.call(t,o)})),t.processedBuffer=!0),Object.values(this.apps).every(o=>o.processedBuffer||o.errored)&&((n=this.xp)===null||n===void 0||n.call(this))};let i=!1;const r=n=>{t.errored=!n,t.loaded=!0,De.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),i&&s()};try{const{processEvent:n}=this.Mp(o=>e.init({posthog:this._instance,callback(a){o(),r(a)}}),!1);n&&(t.processEvent=n),i=!0}catch(n){De.error(ko+e.id,n),r(!1)}if(i&&t.loaded)try{s()}catch(n){De.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}Ep(){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)}Pp(e){if(Object.keys(this.apps).length===0)return;const t=this.globalsForEvent(e);for(const s of Object.values(this.apps))try{this.Mp(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,t)})}catch(i){De.error(`Error while processing event ${e.event} for site app ${s.id}`,i)}}onRemoteConfig(e){var t,s,i;if(!((t=this.siteAppLoaders)===null||t===void 0)&&t.length)return this.isEnabled?(this.Ep(),void this._instance.on("eventCaptured",a=>this.Pp(a))):void De.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.xp)===null||s===void 0||s.call(this),!e.ok)return;const r=e.config;if(!((i=r.siteApps)===null||i===void 0)&&i.length)if(this.isEnabled)for(const{id:a,url:l}of r.siteApps){var n,o;T[`__$$ph_site_app_${a}`]=this._instance,(n=T.__PosthogExtensions__)===null||n===void 0||(o=n.loadSiteApp)===null||o===void 0||o.call(n,this._instance,l,u=>{if(u)return De.error(ko+a,u)})}else De.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Ep={tracingHeaders:class{constructor(e){this._instance=e,this.Rp=void 0,this.Ap=void 0,this.Fp=void 0,this.Qf=()=>{const t=this.Op();var s,i;t?(x(this.Rp)&&(this.Rp=(s=T.__PosthogExtensions__)===null||s===void 0||(s=s.tracingHeadersPatchFns)===null||s===void 0?void 0:s._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),x(this.Ap)&&(this.Ap=(i=T.__PosthogExtensions__)===null||i===void 0||(i=i.tracingHeadersPatchFns)===null||i===void 0?void 0:i._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.tp()}}initialize(){this.startIfEnabledOrStop()}Ho(e){var t,s,i;!((t=T.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(s=T.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",r=>{if(r)return qh.error("failed to load script",r);e()})}Dp(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}Op(){const e=this.Dp();return F(e)?(F(this.Fp)?this.Fp.splice(0,this.Fp.length,...e):this.Fp=[...e],e.length>0?this.Fp:void 0):(F(this.Fp)&&this.Fp.splice(0),this.Fp=e||void 0,this.Fp)}tp(){var e,t;(e=this.Rp)===null||e===void 0||e.call(this),(t=this.Ap)===null||t===void 0||t.call(this),this.Rp=void 0,this.Ap=void 0}startIfEnabledOrStop(){this.Op()?this.Ho(this.Qf):this.tp()}}},Sp=f({surveys:class extends Uh{constructor(e){var t;super(new Yh(e),(t=e,{get projectToken(){return t.config.token},kv:new Qh(t)})),this._instance=e}Vc(e,t){const s=t.query?ks(e,t.query):e;return new Promise(i=>{var r;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((r=t.target)!==null&&r!==void 0?r:"api",s),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:i})})}}},ai),Pp={toolbar:class{constructor(e){this.instance=e}Lp(e){T.ph_toolbar_state=e}Np(){var e;return(e=T.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,s=void 0){var i,r;if(gr(this.instance.config)||!b||!$)return!1;e=(i=e)!==null&&i!==void 0?i:b.location,s=(r=s)!==null&&r!==void 0?r:b.history;try{if(!t){try{b.localStorage.setItem("test","test"),b.localStorage.removeItem("test")}catch{return!1}t=b?.localStorage}const n=Xh||Xs(e.hash,"__posthog")||Xs(e.hash,"state");let o;const a=n?hn(()=>JSON.parse(atob(decodeURIComponent(n))))||hn(()=>JSON.parse(decodeURIComponent(n))):null;return a&&a.action==="ph_authorize"?(o=a,o.source="url",o&&Object.keys(o).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):(o=JSON.parse(t.getItem(Eo)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}qp(e){const t=T.ph_load_toolbar||T.ph_load_editor;!R(t)&&oe(t)?t(e,this.instance):So.warn("No toolbar load function found")}loadToolbar(e){const t=!!$?.getElementById("__POSTHOG_TOOLBAR__");if(!b||t)return!1;const s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=f(f({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(b.localStorage.setItem(Eo,JSON.stringify(f(f({},i),{},{source:void 0}))),this.Np()===2)this.qp(i);else if(this.Np()===0){var r,n;this.Lp(1),(r=T.__PosthogExtensions__)===null||r===void 0||(n=r.loadExternalDependency)===null||n===void 0||n.call(r,this.instance,"toolbar",o=>{if(o)return So.error("[Toolbar] Failed to load",o),void this.Lp(0);this.Lp(2),this.qp(i)}),W(b,"turbolinks:load",()=>{this.Lp(0),this.loadToolbar(i)})}return!0}jp(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,s=void 0){return this.maybeLoadToolbar(e,t,s)}}},Mp=f({experiments:class me{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{me.Bp("retrieved web experiments from the server"),this.zp=new Map,i.forEach(r=>{if(r.feature_flag_key){var n;this.zp&&(me.Bp("setting flag key ",r.feature_flag_key," to web experiment ",r),(n=this.zp)===null||n===void 0||n.set(r.feature_flag_key,r));const o=this._instance.getFeatureFlag(r.feature_flag_key);D(o)&&r.variants[o]&&this.Hp(r.name,o,r.variants[o].transforms)}else if(r.variants)for(const o in r.variants){const a=r.variants[o];me.Up(a,this._instance)&&this.Hp(r.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(t){if(this._is_bot())me.Bp(To);else if(!this.Mr.disable_web_experiments){if(R(this.zp))return this.zp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();me.Bp("applying feature flags",t),t.forEach(s=>{var i;if(this.zp&&(!((i=this.zp)===null||i===void 0)&&i.has(s))){var r;const n=this._instance.getFeatureFlag(s),o=(r=this.zp)===null||r===void 0?void 0:r.get(s);n&&o?.variants[n]&&this.Hp(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){const t=me.getWindowLocation();if(t?.search){const s=qt(t?.search,"__experiment_id"),i=qt(t?.search,"__experiment_variant");s&&i&&(me.Bp(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(r=>{this.Wp(parseInt(s),i,r)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,s,i){if(this.Mr.disable_web_experiments&&!i)return t([]);const r=this._instance.get_property("$web_experiments");if(r&&!s)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:n=>t(n.statusCode===200&&n.json&&n.json.experiments||[])})}Wp(t,s,i){const r=i.filter(n=>n.id===t);r&&r.length>0&&(me.Bp(`Previewing web experiment [${r[0].name}] with variant [${s}]`),this.Hp(r[0].name,s,r[0].variants[s].transforms))}static Up(t,s){return!R(t.conditions)&&me.Vp(t,s)&&me.Gp(t)}static Vp(t,s){var i;if(R(t.conditions)||R((i=t.conditions)===null||i===void 0?void 0:i.url))return!0;const r=me.getWindowLocation();if(r){var n,o,a;const l=ml(s,r.href);return!(!((n=t.conditions)===null||n===void 0)&&n.url)||np[(o=(a=t.conditions)===null||a===void 0?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return b?.location}static Gp(t){var s;if(R(t.conditions)||R((s=t.conditions)===null||s===void 0?void 0:s.utm))return!0;const i=Cl();if(i.utm_source){var r,n,o,a,l,u,c,h;const d=!(!((r=t.conditions)===null||r===void 0||(r=r.utm)===null||r===void 0)&&r.utm_campaign)||((n=t.conditions)===null||n===void 0||(n=n.utm)===null||n===void 0?void 0:n.utm_campaign)==i.utm_campaign,p=!(!((o=t.conditions)===null||o===void 0||(o=o.utm)===null||o===void 0)&&o.utm_source)||((a=t.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_source)==i.utm_source,v=!(!((l=t.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((u=t.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0?void 0:u.utm_medium)==i.utm_medium,_=!(!((c=t.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0)&&c.utm_term)||((h=t.conditions)===null||h===void 0||(h=h.utm)===null||h===void 0?void 0:h.utm_term)==i.utm_term;return d&&v&&_&&p}return!1}static Bp(t,...s){S.info(`[WebExperiments] ${t}`,s)}Hp(t,s,i){this._is_bot()?me.Bp(To):s!=="control"?i.forEach(r=>{if(r.selector){var n;me.Bp(`applying transform of variant ${s} for experiment ${t} `,r);const o=(n=document)===null||n===void 0?void 0:n.querySelectorAll(r.selector);o?.forEach(a=>{const l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)})}}):me.Bp("Control variants leave the page unmodified.")}_is_bot(){return he&&this._instance?iu(he,this.Mr.custom_blocked_useragents):void 0}}},ai),Ip={conversations:class{constructor(e){this._instance=e,this.Qp=void 0,this._conversationsManager=null,this.Zp=!1,this.ne=null,this.Jp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Kp=e.ok,!e.ok))return;const t=e.config.conversations;R(t)||(we(t)?this.Qp=t:(this.Qp=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this.Qp=void 0,this.ne=null,this.Kp=void 0,this.Jp=!1}loadIfEnabled(){if(this._conversationsManager||this.Zp||this._instance.config.disable_conversations||gr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=T?.__PosthogExtensions__;if(e&&!x(this.Qp)&&this.Qp)if(this.ne&&this.ne.token){this.Zp=!0;try{const t=e.initConversations;if(t)return this.Xp(t),void(this.Zp=!1);const s=e.loadExternalDependency;if(!s)return void this.Yp(Br);s(this._instance,"conversations",i=>{i||!e.initConversations?this.Yp("Could not load conversations script",i):this.Xp(e.initConversations),this.Zp=!1})}catch(t){this.Yp("Error initializing conversations",t),this.Zp=!1}}else Ie.error("Conversations enabled but missing token in remote config.")}Xp(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.Jp=!1,Ie.info("Conversations loaded successfully")}catch(t){this.Yp("Error completing conversations initialization",t)}else Ie.error("Cannot complete initialization: remote config is null")}Yp(e,t){Ie.error(e,t),this._conversationsManager=null,this.Zp=!1,this.Jp=!0}show(){this._conversationsManager?this._conversationsManager.show():Ie.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Qp===!0&&!se(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":gr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Kp===!1?"remote_config_failed":x(this.Qp)?this.Kp?"disabled_in_project":"remote_config_pending":this.Qp?R(this.ne)||!this.ne.token?"missing_token":T?.__PosthogExtensions__?this.Zp?"initializing":this.Jp?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,s){var i=this;return X(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,s):(Ie.warn(dt),null)})()}getMessages(e,t){var s=this;return X(function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,t):(Ie.warn(dt),null)})()}markAsRead(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Ie.warn(dt),null)})()}getTickets(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Ie.warn(dt),null)})()}requestRestoreLink(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Ie.warn(dt),null)})()}restoreFromToken(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Ie.warn(dt),null)})()}restoreFromUrlToken(){var e=this;return X(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Ie.warn(dt),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}Sc(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}xc(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},Op={logs:class extends lp{constructor(e){super({get(){var t;return e==null||(t=e.config)===null||t===void 0?void 0:t.logs},captureHintKey:Ja,get remoteConfigWillArrive(){var t,s;return!(!((t=e.nl)===null||t===void 0)&&t.call(e))||!!(!((s=T._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[e.config.token])===null||s===void 0)&&s.config)}},()=>(function(t){var s;const i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){const{sessionId:r,windowId:n,sessionStartTimestamp:o,lastActivityTimestamp:a}=t.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=r,i.windowId=n,R(o)||(i.sessionStartTimestamp=o),R(a)||(i.lastActivityTimestamp=a)}if(!(T==null||(s=T.location)===null||s===void 0)&&s.href&&(i.currentUrl=t.config.disable_capture_url_hashes?ot(T.location.href):T.location.href),t.featureFlags){const r=t.featureFlags.getFlags();r&&r.length>0&&(i.activeFeatureFlags=r)}return i})(e)),this._instance=e,this.name=du,this.Av()}get Pv(){return this._instance.__loaded}Rv(){const e=ee("[logs]"),t=T?.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");const s=t.loadExternalDependency;if(s)return i=>{s(this._instance,"logs",r=>{const n=t.logs;i(r,n?.initializeLogs?{initialize:o=>n.initializeLogs(o),replay(o,a){var l;return(l=n.replayConsoleBuffer)===null||l===void 0?void 0:l.call(n,o,a)}}:void 0)})};e.error(Br)}}},Fp={metrics:class{constructor(e){this._instance=e,this.A=ee("[metrics]"),this.Io=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this.Io)return;const t=!!(!((e=this._instance.config.metrics)===null||e===void 0)&&e.network);t&&!this.tg?this.tg=(s=>{let i=!0;const r=()=>i?(a=>{var l;const u=(l=a.config.metrics)===null||l===void 0?void 0:l.network;return u===!0?{}:u||void 0})(s):void 0,n=dp(s,r),o=hp(s,r);return()=>{i=!1,n(),o()}})(this._instance):!t&&this.tg&&(this.tg(),this.tg=void 0)}Dv(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.metrics;var s;return this.Mv&&this.Lv===t||((s=this.Mv)===null||s===void 0||s.reset(),this.Lv=t,this.Mv=new id(this.Ov(),(function(i){var r,n,o,a,l;const u=i?.resourceAttributes;return{serviceName:(r=u?.["service.name"])!==null&&r!==void 0?r:i?.serviceName,serviceVersion:(n=u?.["service.version"])!==null&&n!==void 0?n:i?.serviceVersion,environment:(o=u?.["deployment.environment"])!==null&&o!==void 0?o:i?.environment,resourceAttributes:u,beforeSend:i?.beforeSend,flushIntervalMs:(a=i?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(t),this.A)),this.Mv}count(e,t=1,s){this.Dv().count(e,t,s)}gauge(e,t,s){this.Dv().gauge(e,t,s)}histogram(e,t,s){this.Dv().histogram(e,t,s)}flush(e){if(!this.Mv)return Promise.resolve();if(e){const t=this.Mv.drainWindow();return t&&this.co(t,e),Promise.resolve()}return this.Mv.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this.Mv)===null||e===void 0||e.reset()}dispose(){var e,t;this.Io=!0,(e=this.tg)===null||e===void 0||e.call(this),this.tg=void 0,(t=this.Mv)===null||t===void 0||t.reset()}Ov(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},co:s=>t.co(s),getLibraryId:()=>ke.LIB_NAME,getLibraryVersion:()=>ke.LIB_VERSION}}co(e,t){return new Promise(s=>{let i=!1;const r=o=>{i||(i=!0,clearTimeout(n),s(o))},n=setTimeout(()=>r({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(f(f({method:"POST",url:this.eg(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(o){const a=o.statusCode;if(a>=200&&300>a)r({kind:"ok"});else if(a===413)r({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)r({kind:"fatal",error:new Error(`metrics request failed with status ${a}`)});else{var l;r({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error(`metrics request failed with status ${a}`)})}}}))})}eg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Cp={webMCP:class{constructor(e){this._instance=e,this.ig=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.ig)return;const e=$?.modelContext;if(!e||!oe(e.registerTool))return;const t=No.get(e);if(t)return t.instances.add(this._instance),void(this.ig=!0);const s={instances:new Set([this._instance])},i=e.registerTool,r=this;zt(e,"registerTool",n=>{const o=n;return function(a,...l){let u=a;try{u=r.ng(a,s)}catch{return o.call(this,a,...l)}return o.call(this,u,...l)}}),e.registerTool!==i&&(No.set(e,s),this.ig=!0)}ng(e,t){if(!e||!oe(e.execute))return e;const s=e.execute,i=this,{tool:r,injected:n}=(function(o,a){const l={intent:!1,model:!1},u=o.inputSchema;if(!(function(v){return!!x(v)||L(v)&&Object.keys(v).every(_=>pp.has(_)||_.startsWith("x-"))&&v.additionalProperties!==!0&&!L(v.additionalProperties)&&(!v.type||v.type==="object")&&(!v.properties||L(v.properties))&&(!v.required||F(v.required))})(u))return{tool:Qi(o),injected:l};const c=u?.properties||{},h=v=>Ki(c,v)||F(u?.required)&&u.required.includes(v);if(l.intent=a.intent&&!h("context"),l.model=a.model&&!h("llm_model"),!l.intent&&!l.model)return{tool:Qi(o),injected:l};const d=f({},c),p=F(u?.required)?[...u.required]:[];return l.intent&&(d.context={type:"string",description:`Explain why this tool is called and how it supports the user's goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".`},p.includes("context")||p.push("context")),l.model&&(d.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},p.includes("llm_model")||p.push("llm_model")),{tool:Qi(o,f(f({},u),{},{type:u?.type||"object",properties:d,required:p})),injected:l}})(e,(function(o){const a={intent:!1,model:!1};for(const l of o.instances){const u=jo(l.config.capture_webmcp);a.intent||(a.intent=u?.intent===!0),a.model||(a.model=u?.model===!0)}return a})(t));return Object.defineProperty(r,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const a=new Date,l=(function(p,v){if(!L(p))return{};try{const _=v.intent?qo(p.context,2048,!0):void 0,g=v.model?qo(p.llm_model,256):void 0;return f(f({},_&&_!=="{}"?{intent:_}:{}),g&&g.toLowerCase()!=="unknown"?{model:g}:{})}catch{return{}}})(o[0],n),u=(function(p,v){const _=p[0];if(!L(_))return p;try{const g=v.intent&&Ki(_,"context"),y=v.model&&Ki(_,"llm_model");if(!g&&!y)return p;const m=f({},_);return g&&delete m.context,y&&delete m.llm_model,[m,...p.slice(1)]}catch{return p}})(o,n);let c;try{c=s.apply(this===r?e:this,u)}catch(p){throw i.sg(t,r,a,{error:p,errorResult:!1},l),p}if((h=c)&&typeof h.then=="function")return Promise.resolve(c).then(p=>{const v=Ho(p)?{error:p,errorResult:!0}:void 0;return i.sg(t,r,a,v,l),p},p=>{throw i.sg(t,r,a,{error:p,errorResult:!1},l),p});var h;const d=Ho(c)?{error:c,errorResult:!0}:void 0;return i.sg(t,r,a,d,l),c}}),r}sg(e,t,s,i,r){const n=Date.now()-s.getTime();let o;for(const l of e.instances){var a;const u=jo(l.config.capture_webmcp);if(u){i&&!o&&(o=yp(i.error,i.errorResult));try{l.capture("$mcp_tool_call",f(f(f({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:Q?.hostname,$mcp_duration_ms:n,$mcp_is_error:!!i},o?{$mcp_error_type:o.type,$mcp_error_message:o.message}:{}),u.intent&&r.intent?{$mcp_intent:r.intent,$mcp_intent_source:"context_parameter"}:{}),u.model&&r.model?{$mcp_llm_model:r.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:s})}catch{continue}if(i&&o&&l.exceptions&&(!((a=l.exceptionObserver)===null||a===void 0)&&a.isEnabled))try{const c={$exception_list:_p(l.exceptions,i,o.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:Q?.hostname};l.exceptionObserver.captureException(c)}catch{}}}}}};fs.__defaultExtensionClasses=f({},f(f(f(f(f(f(f(f(f(f(f(f(f(f({},ai),bp),wp),xp),kp),$p),Sp),Ep),Pp),Mp),Ip),Op),Fp),Cp));const Ap=(function(){ke.SDK_DIST_CHANNEL="npm";const e=hs[is]=new fs;return(function(){function t(){t.done||(t.done=!0,tu=!1,J(hs,function(s){s._dom_loaded()}))}$?.addEventListener?$.readyState==="complete"?t():W($,"DOMContentLoaded",t,{capture:!1}):b&&S.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();var Tp=Ap;export{Pe as Compression,wr as DisplaySurveyType,fs as PostHog,sh as ProductTourEventName,eo as ProductTourEventProperties,Se as SurveyEventName,Ci as SurveyEventProperties,Yt as SurveyEventType,Fi as SurveyType,Tp as default,Ap as posthog};