tokentracker-cli 1.3.3 → 1.3.5

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 (187) hide show
  1. package/README.de.md +5 -5
  2. package/README.ja.md +3 -3
  3. package/README.ko.md +3 -3
  4. package/README.md +6 -5
  5. package/README.zh-CN.md +3 -3
  6. package/THIRD_PARTY_NOTICES.md +92 -0
  7. package/dashboard/dist/THIRD_PARTY_NOTICES.txt +92 -0
  8. package/dashboard/dist/assets/AchievementBadge-Dazs3pEa.js +1 -0
  9. package/dashboard/dist/assets/AchievementsPage-LWnxZvmw.js +2 -0
  10. package/dashboard/dist/assets/{AchievementsSection-CDUUEfIi.js → AchievementsSection-BLqczmU9.js} +1 -1
  11. package/dashboard/dist/assets/BadgeDetailModal-B_n4aj2S.js +1 -0
  12. package/dashboard/dist/assets/{BotAnimated-Dx_vvTtC.js → BotAnimated-KDWI_YcZ.js} +1 -1
  13. package/dashboard/dist/assets/Card-BYoxd4OC.js +1 -0
  14. package/dashboard/dist/assets/CloudCheckoutPage-BR2_B03P.js +1 -0
  15. package/dashboard/dist/assets/CloudPage-DL5RkJKK.js +1 -0
  16. package/dashboard/dist/assets/CloudUsageExport-C_DqZKo1.js +4 -0
  17. package/dashboard/dist/assets/CommandPalette-DkCaIQI4.js +1 -0
  18. package/dashboard/dist/assets/CommunityStatsModal-pX9OePi4.js +1 -0
  19. package/dashboard/dist/assets/{ConfirmModal-BQ-xB1S_.js → ConfirmModal-tkgZwz4u.js} +1 -1
  20. package/dashboard/dist/assets/Controls-MTUhGWy8.js +1 -0
  21. package/dashboard/dist/assets/DashboardPage-SOx-A7lH.js +1 -0
  22. package/dashboard/dist/assets/DateRangePopover-B-BMOm3O.js +1 -0
  23. package/dashboard/dist/assets/{DevicePage-Dg6XkIaY.js → DevicePage-DSK9lm7v.js} +1 -1
  24. package/dashboard/dist/assets/DialogClose-uVUNu4rg.js +1 -0
  25. package/dashboard/dist/assets/DialogDescription-DBqGGWNj.js +1 -0
  26. package/dashboard/dist/assets/DialogTitle-B-VifiA3.js +1 -0
  27. package/dashboard/dist/assets/{FadeIn-ChVf45WW.js → FadeIn-B6lrj4uo.js} +1 -1
  28. package/dashboard/dist/assets/{HeaderGithubStar-B740_G7a.js → HeaderGithubStar-Cx5zOhXa.js} +1 -1
  29. package/dashboard/dist/assets/{HoverTooltip-BzP5FudR.js → HoverTooltip-DY1ENf69.js} +1 -1
  30. package/dashboard/dist/assets/{IpCheckPage-BuZH3F14.js → IpCheckPage-D6TEq64d.js} +1 -1
  31. package/dashboard/dist/assets/LandingPage-OdZUfq--.js +2 -0
  32. package/dashboard/dist/assets/LeaderboardPage-DCK5xcAt.js +2 -0
  33. package/dashboard/dist/assets/LeaderboardProBadge-CBXJ1u_m.js +1 -0
  34. package/dashboard/dist/assets/{LeaderboardProfileModal-OUZvO6u-.js → LeaderboardProfileModal-Ccdzb7QK.js} +4 -4
  35. package/dashboard/dist/assets/{LeaderboardProfilePage-bHI1oTEK.js → LeaderboardProfilePage-CFXlZ0fL.js} +2 -2
  36. package/dashboard/dist/assets/LimitsPage-5krjm-g9.js +9 -0
  37. package/dashboard/dist/assets/{LocalOnlyNotice-BaEq6qN7.js → LocalOnlyNotice-Rk1B8PaZ.js} +1 -1
  38. package/dashboard/dist/assets/LoginCard-DTTIm8vk.js +1 -0
  39. package/dashboard/dist/assets/LoginModal-BNcDdjfr.js +1 -0
  40. package/dashboard/dist/assets/LoginPage-CQgXP7Ee.js +1 -0
  41. package/dashboard/dist/assets/{PetPage-BPBsUHyL.js → PetPage-Cw_kAPRs.js} +1 -1
  42. package/dashboard/dist/assets/PopoverPopup-NYiGE8A2.js +1 -0
  43. package/dashboard/dist/assets/{ProviderIcon-BshO2uER.js → ProviderIcon-Bp7iFJ_m.js} +1 -1
  44. package/dashboard/dist/assets/{ResetPasswordPage-RTFTD8Dr.js → ResetPasswordPage-Cf9kAWDW.js} +1 -1
  45. package/dashboard/dist/assets/Select-kIcvQFAo.js +1 -0
  46. package/dashboard/dist/assets/SelectItemText-BpIsAg3b.js +1 -0
  47. package/dashboard/dist/assets/{SelfHostPage-BlwTt8XM.js → SelfHostPage-Ch2vvSwI.js} +1 -1
  48. package/dashboard/dist/assets/{ServiceStatusPage-BkIcJpYK.js → ServiceStatusPage-hoYBvGbu.js} +1 -1
  49. package/dashboard/dist/assets/SessionsPage-BzRB6q-Z.js +3 -0
  50. package/dashboard/dist/assets/SessionsPage-GV2fuNmd.css +1 -0
  51. package/dashboard/dist/assets/SettingsPage-DRl2uX-i.js +2 -0
  52. package/dashboard/dist/assets/SkillsPage-CkqThTZL.js +1 -0
  53. package/dashboard/dist/assets/{TokenGalaxy-DiXUpXKF.js → TokenGalaxy-eLG-UIZY.js} +1 -1
  54. package/dashboard/dist/assets/TooltipPopup-bnMJyilQ.js +1 -0
  55. package/dashboard/dist/assets/TrendMonitor-X7-aGzIv.js +19 -0
  56. package/dashboard/dist/assets/WidgetsPage-CGznIzrW.js +1 -0
  57. package/dashboard/dist/assets/{WrappedPage-ClEo-RmR.js → WrappedPage-p31-uUoF.js} +1 -1
  58. package/dashboard/dist/assets/__vite-browser-external-2g_4s3ot.js +45 -0
  59. package/dashboard/dist/assets/__vite-browser-external-LpFw4zXh.css +1 -0
  60. package/dashboard/dist/assets/agent-logos-2TVT3fIE.js +1 -0
  61. package/dashboard/dist/assets/arrow-left-DL0hAp_7.js +1 -0
  62. package/dashboard/dist/assets/{arrow-right-CwBz5dwb.js → arrow-right-DFCpnV_9.js} +1 -1
  63. package/dashboard/dist/assets/{arrow-up-right-jPmRN562.js → arrow-up-right-DLvfE0Wu.js} +1 -1
  64. package/dashboard/dist/assets/calendar-days-B0aDoKSG.js +1 -0
  65. package/dashboard/dist/assets/{check-CKwHc4Hv.js → check-C_cfrxiz.js} +1 -1
  66. package/dashboard/dist/assets/chevron-down-Ck8ml43e.js +1 -0
  67. package/dashboard/dist/assets/cloud-checkout-PYnwNfdH.js +1 -0
  68. package/dashboard/dist/assets/composite-INW-ELWX.js +1 -0
  69. package/dashboard/dist/assets/download-B7uokeIo.js +1 -0
  70. package/dashboard/dist/assets/{external-link-B5yXxdPy.js → external-link-CI3crg4K.js} +1 -1
  71. package/dashboard/dist/assets/{flame-CKjAluj_.js → flame-DCzvFKV1.js} +1 -1
  72. package/dashboard/dist/assets/{format-tokens-mk49THtv.js → format-tokens-CSTEYK2m.js} +1 -1
  73. package/dashboard/dist/assets/gift-dEHDFMc6.js +1 -0
  74. package/dashboard/dist/assets/{host-mode-efKlSYjX.js → host-mode-r2SW9Mdv.js} +1 -1
  75. package/dashboard/dist/assets/{icons-ZB1ZthjH.js → icons-q-3zvEkh.js} +1 -1
  76. package/dashboard/dist/assets/{index-BImBG3eS.js → index-BV7qwUw4.js} +1 -1
  77. package/dashboard/dist/assets/{index-BgdM7kBl.js → index-BbrsgHf4.js} +1 -1
  78. package/dashboard/dist/assets/{index-DweUMAUD.js → index-CyHYj9XI.js} +1 -1
  79. package/dashboard/dist/assets/info-BBdY9hV4.js +1 -0
  80. package/dashboard/dist/assets/{link-2-Dn2soiyd.js → link-2-CLPePfXs.js} +1 -1
  81. package/dashboard/dist/assets/{loader-circle-CNT630zn.js → loader-circle-ETrjzfmn.js} +1 -1
  82. package/dashboard/dist/assets/{modifiers.esm-WPx0bc2K.js → modifiers.esm-DHqnp2ol.js} +1 -1
  83. package/dashboard/dist/assets/module-BNnaKM__.js +3 -0
  84. package/dashboard/dist/assets/monitor-smartphone-D1kdzrdb.js +1 -0
  85. package/dashboard/dist/assets/play-Cxp-ronD.js +1 -0
  86. package/dashboard/dist/assets/plus-4n94VzDK.js +1 -0
  87. package/dashboard/dist/assets/provider-display-CRlbeO7t.js +42 -0
  88. package/dashboard/dist/assets/{react-B7SkZTgg.js → react-DlHjGQFN.js} +1 -1
  89. package/dashboard/dist/assets/safePolygon-CVZ27a2_.js +1 -0
  90. package/dashboard/dist/assets/{search-Ol3OZBm4.js → search-BDPr56_h.js} +1 -1
  91. package/dashboard/dist/assets/{server-DFCbznC7.js → server-Bm7fHvVa.js} +1 -1
  92. package/dashboard/dist/assets/{shield-check-YcmLwVZ6.js → shield-check-DtT8ACzI.js} +1 -1
  93. package/dashboard/dist/assets/{skills-api-C-9vK884.js → skills-api-Dc1-2qu6.js} +1 -1
  94. package/dashboard/dist/assets/{sortable.esm-CKC9NuR-.js → sortable.esm-B-qN-Xk2.js} +1 -1
  95. package/dashboard/dist/assets/store-gHeBU8dQ.js +1 -0
  96. package/dashboard/dist/assets/{terminal-B3_fCLFs.js → terminal-D4VZbvhg.js} +1 -1
  97. package/dashboard/dist/assets/{trash-CZGfgbFa.js → trash-BZtLAFQy.js} +1 -1
  98. package/dashboard/dist/assets/{use-community-stats-CW-qkYn7.js → use-community-stats-BdqndrbB.js} +1 -1
  99. package/dashboard/dist/assets/{use-latest-request-guard-DHv7vfFE.js → use-latest-request-guard-DhGg1cDS.js} +1 -1
  100. package/dashboard/dist/assets/use-limits-display-prefs-D3HOcRFv.js +1 -0
  101. package/dashboard/dist/assets/{use-native-settings-CWiLqfZh.js → use-native-settings-BniKwA_n.js} +1 -1
  102. package/dashboard/dist/assets/{use-ordered-list-Df8pw-WJ.js → use-ordered-list-b09H7EHq.js} +1 -1
  103. package/dashboard/dist/assets/use-pet-settings-CPZdlq_e.js +2 -0
  104. package/dashboard/dist/assets/use-reduced-motion-D1gcKJUo.js +1 -0
  105. package/dashboard/dist/assets/{use-transform-BHwEAfmO.js → use-transform-CIdxjmI8.js} +1 -1
  106. package/dashboard/dist/assets/use-usage-limits-eJlU65yY.js +1 -0
  107. package/dashboard/dist/assets/{useCurrency-pwClnCZ5.js → useCurrency-CM22CmAq.js} +1 -1
  108. package/dashboard/dist/assets/usePositioner-B3l2ulTw.js +1 -0
  109. package/dashboard/dist/assets/{useTokenFormat-BMvVAe6V.js → useTokenFormat-D7nzgxKw.js} +1 -1
  110. package/dashboard/dist/assets/zap-Daxct1WV.js +1 -0
  111. package/dashboard/dist/index.html +14 -12
  112. package/dashboard/dist/ip-check.html +2 -2
  113. package/dashboard/dist/leaderboard.html +2 -2
  114. package/dashboard/dist/llms.txt +2 -2
  115. package/dashboard/dist/share.html +2 -2
  116. package/package.json +3 -2
  117. package/src/commands/init.js +43 -1
  118. package/src/commands/status.js +27 -0
  119. package/src/commands/sync.js +54 -4
  120. package/src/commands/uninstall.js +19 -0
  121. package/src/lib/claude-config.js +47 -15
  122. package/src/lib/codex-rollout-parser.js +11 -3
  123. package/src/lib/command-runner.js +15 -1
  124. package/src/lib/cursor-config.js +2 -1
  125. package/src/lib/gemini-config.js +3 -2
  126. package/src/lib/local-api.js +13 -3
  127. package/src/lib/notify-command.js +38 -0
  128. package/src/lib/openclaw-session-plugin.js +47 -14
  129. package/src/lib/passive-mode.js +12 -0
  130. package/src/lib/pricing/curated-overrides.json +42 -5
  131. package/src/lib/pricing/matcher.js +14 -5
  132. package/src/lib/pricing/seed-snapshot.json +1 -1
  133. package/src/lib/rollout.js +150 -28
  134. package/src/lib/session-analytics.js +108 -9
  135. package/src/lib/usage-limits.js +183 -20
  136. package/src/lib/zcode-limits.js +218 -18
  137. package/src/lib/zcode-reset-credits.js +66 -0
  138. package/dashboard/dist/assets/AchievementBadge-BaqdyZaV.js +0 -1
  139. package/dashboard/dist/assets/AchievementsPage-B4Ju0guv.js +0 -2
  140. package/dashboard/dist/assets/BadgeDetailModal-B-XMJAvL.js +0 -1
  141. package/dashboard/dist/assets/Card-D-5mABVt.js +0 -1
  142. package/dashboard/dist/assets/CloudCheckoutPage-BELoh56h.js +0 -1
  143. package/dashboard/dist/assets/CloudPage-CfBruNxe.js +0 -1
  144. package/dashboard/dist/assets/CloudUsageExport-BoFU7xCT.js +0 -4
  145. package/dashboard/dist/assets/CommandPalette-BmmKZWn-.js +0 -1
  146. package/dashboard/dist/assets/CommunityStatsModal-BF77zVhN.js +0 -1
  147. package/dashboard/dist/assets/Controls-BnTeX7T4.js +0 -1
  148. package/dashboard/dist/assets/DashboardPage-BWulHa5J.js +0 -1
  149. package/dashboard/dist/assets/DialogClose-DAyilsH-.js +0 -1
  150. package/dashboard/dist/assets/DialogDescription-j4XnRy6y.js +0 -1
  151. package/dashboard/dist/assets/DialogTitle-B1iNGD2S.js +0 -1
  152. package/dashboard/dist/assets/LandingPage-Dtgq_caz.js +0 -2
  153. package/dashboard/dist/assets/LeaderboardPage-Di1kEg2O.js +0 -2
  154. package/dashboard/dist/assets/LeaderboardProBadge-h8FfR0au.js +0 -1
  155. package/dashboard/dist/assets/LimitsPage-DKojB73_.js +0 -8
  156. package/dashboard/dist/assets/LoginCard-Dn5Xy4If.js +0 -1
  157. package/dashboard/dist/assets/LoginModal-C5h-5GOA.js +0 -1
  158. package/dashboard/dist/assets/LoginPage-BpX8Tgjj.js +0 -1
  159. package/dashboard/dist/assets/PopoverPopup-CVTiEVHs.js +0 -1
  160. package/dashboard/dist/assets/Select-CtTceC4T.js +0 -1
  161. package/dashboard/dist/assets/SelectItemText-C7xi8iGp.js +0 -1
  162. package/dashboard/dist/assets/SessionsPage-BngTWN7Q.css +0 -1
  163. package/dashboard/dist/assets/SessionsPage-okHobk_L.js +0 -3
  164. package/dashboard/dist/assets/SettingsPage-C-cc6wcF.js +0 -2
  165. package/dashboard/dist/assets/SkillsPage-D2LlKKJN.js +0 -1
  166. package/dashboard/dist/assets/TrendMonitor-C88S-5aa.js +0 -19
  167. package/dashboard/dist/assets/WidgetsPage-WsEFPNwp.js +0 -1
  168. package/dashboard/dist/assets/__vite-browser-external-DFRX9dp-.css +0 -1
  169. package/dashboard/dist/assets/__vite-browser-external-DUJeOWgd.js +0 -45
  170. package/dashboard/dist/assets/agent-logos-BM9jlReI.js +0 -1
  171. package/dashboard/dist/assets/arrow-left-BEM-HVmC.js +0 -1
  172. package/dashboard/dist/assets/cloud-checkout-nYNHDFoR.js +0 -1
  173. package/dashboard/dist/assets/composite-B4Z3F65o.js +0 -1
  174. package/dashboard/dist/assets/download-CJUnX1Bs.js +0 -1
  175. package/dashboard/dist/assets/info-CyDY7NYM.js +0 -1
  176. package/dashboard/dist/assets/module-WSx8viXK.js +0 -3
  177. package/dashboard/dist/assets/monitor-smartphone-C-qC0RAt.js +0 -1
  178. package/dashboard/dist/assets/plus-Cx82jb7o.js +0 -1
  179. package/dashboard/dist/assets/provider-display-CodMmiRb.js +0 -42
  180. package/dashboard/dist/assets/safePolygon-CKpREa4K.js +0 -1
  181. package/dashboard/dist/assets/store-C9yWYHfg.js +0 -1
  182. package/dashboard/dist/assets/use-limits-display-prefs-NZ-AAYD5.js +0 -1
  183. package/dashboard/dist/assets/use-pet-settings-Bg2CDprr.js +0 -2
  184. package/dashboard/dist/assets/use-reduced-motion-iDZEUyua.js +0 -1
  185. package/dashboard/dist/assets/use-usage-limits-CSxFFn3_.js +0 -1
  186. package/dashboard/dist/assets/usePositioner-B0j1orGj.js +0 -1
  187. package/dashboard/dist/assets/zap-DvX2aYx5.js +0 -1
@@ -1,3 +0,0 @@
1
- const y="u">typeof window?window:void 0,fe="u">typeof globalThis?globalThis:y,ce=fe?.navigator,$=fe?.document,ee=fe?.location,ls=fe?.fetch,yr=fe?.XMLHttpRequest&&"withCredentials"in new fe.XMLHttpRequest?fe.XMLHttpRequest:void 0,Hr=fe?.AbortController,ql=fe?.CompressionStream,ye=ce?.userAgent;function mo(){return!(!y||y.navigator.onLine===!1)}const Nt=typeof globalThis<"u"?globalThis:y;Nt&&typeof self>"u"&&(Nt.self=Nt),Nt&&typeof File>"u"&&(Nt.File=function(){});const O=y??{},Bl="0.9.0",Ue={DEBUG:!1,LIB_VERSION:Bl,LIB_NAME:"browser-common"};var Le=(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})({}),zi=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const zl=["$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"],Hl=["token"];function T(e,t){return e.indexOf(t)!==-1}const Qs=function(e){return e.trim()},Hi=function(e){return e.replace(/^\$/,"")};function yo(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 bo=Object.prototype,br=bo.hasOwnProperty,ei=bo.toString,M=Array.isArray||function(e){return ei.call(e)==="[object Array]"},ue=e=>typeof e=="function",N=e=>e===Object(e)&&!M(e),$e=e=>{if(N(e)){for(const t in e)if(br.call(e,t))return!1;return!0}return!1},x=e=>e===void 0,D=e=>ei.call(e)=="[object String]",Kt=e=>D(e)&&e.trim().length===0,te=e=>e===null,A=e=>x(e)||te(e),ne=e=>ei.call(e)=="[object Number]"&&e==e,Be=e=>ne(e)&&e>0,we=e=>ei.call(e)==="[object Boolean]",Vl=e=>T(zl,e),Wl=e=>T(Hl,e);function wo(e){return e===null||typeof e!="object"}function Ts(e,t){return{}.toString.call(e)===`[object ${t}]`}function Dt(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 xo(e,Error)}}function wr(e){return"u">typeof Event&&xo(e,Event)}function xo(e,t){try{return e instanceof t}catch{return!1}}const Ul=[!0,"true",1,"1","yes"],oi=e=>T(Ul,e),Gl=[!1,"false",0,"0","no"];function Vr(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 Z(e){return function(){var t=this,s=arguments;return new Promise(function(i,r){var n=e.apply(t,s);function o(l){Vr(n,i,r,o,a,"next",l)}function a(l){Vr(n,i,r,o,a,"throw",l)}o(void 0)})}}const Xl=["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"],Wr=function(e,t=[]){if(!e)return!1;const s=e.toLowerCase();return Xl.concat(t).some(i=>{const r=i.toLowerCase();return s.indexOf(r)!==-1})};function De(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),De(r??s,t,s,i))}var Yl=class{constructor(e){this.C={},this.I=e.I,this.R=De(e.bucketSize,0,100,e.$),this.A=De(e.refillRate,0,this.R,e.$),this.O=De(e.refillInterval,0,864e5,e.$)}F(e,t){const s=Math.floor((t-e.lastAccess)/this.O);s>0&&(e.tokens=Math.min(e.tokens+s*this.A,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 Ct="Mobile",us="Android",As="Tablet",$o="Android Tablet",ko="iPad",Eo="Apple Watch",Ps="Safari",ti="BlackBerry",So="Samsung Internet",Rs="Chrome",Po="Chrome iOS",Ro="Internet Explorer",Fo="Internet Explorer Mobile",Io="Opera",Oo="Microsoft Edge",Fs="Firefox",Co="Firefox iOS",Ls="Nintendo",Ds="PlayStation",si="Xbox",Mo="Android Mobile",To="Mobile Safari",ai="Windows",Ao="Windows Phone",Ur="Nokia",Vi="Ouya",Kl="Generic "+Ct.toLowerCase(),Lo="Generic "+As.toLowerCase(),Wi="Konqueror",Do="Oculus Browser",No="Vivaldi",jo="Yandex",qo="Whale",Bo="DuckDuckGo",zo="Pale Moon",Ho="Waterfox",Ui="Brave",Vo="Claude",Wo="Codex",Uo="ChatGPT",Go="Google Search App",li=new RegExp("Version/(\\d+(\\.\\d+)?)"),ui=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Jl=new RegExp(si,"i"),Zl=new RegExp("PlayStation \\w+","i"),Ql=new RegExp("Nintendo \\w+","i"),xr=new RegExp("BlackBerry|PlayBook|BB10","i"),eu={"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"},Xo=function(e,t,s,i){return t=t||"",(function(n){return n?.brave?Ui:null})(s)||(i?.detectGoogleSearchApp&&T(e,"GSA/")?Go:T(e," OPR/")&&T(e,"Mini")?"Opera Mini":T(e," OPR/")?Io:xr.test(e)?ti:T(e,"IEMobile")||T(e,"WPDesktop")?Fo:T(e,"OculusBrowser")?Do:T(e,"SamsungBrowser")?So:T(e,"Edge")||T(e,"Edg/")?Oo:T(e,"Vivaldi/")?No:T(e,"YaBrowser/")?jo:T(e,"Whale/")?qo:T(e,"DuckDuckGo/")||T(e,"Ddg/")?Bo:T(e,"Claude/")?Vo:T(e,"Codex/")?Wo:T(e,"ChatGPT/")?Uo:T(e,"FBIOS")?"Facebook Mobile":T(e,"UCWEB")||T(e,"UCBrowser")?"UC Browser":T(e,"CriOS")?Po:T(e,"CrMo")||T(e,Rs)?Rs:T(e,us)&&T(e,Ps)?Mo:T(e,"FxiOS")?Co:T(e.toLowerCase(),Wi.toLowerCase())?Wi:T(e,"Brave/")?Ui:((n,o)=>o&&T(o,"Apple")||(function(a){return T(a,Ps)&&!T(a,Rs)&&!T(a,us)})(n))(e,t)?T(e,Ct)?To:Ps:T(e,"PaleMoon/")?zo:T(e,"Waterfox/")?Ho:T(e,Fs)?Fs:T(e,"MSIE")||T(e,"Trident/")?Ro:T(e,"Gecko")?Fs:"")},tu={[Fo]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Oo]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Rs]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Po]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ps]:[li],[To]:[li],[Io]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Fs]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Co]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Wi]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[ti]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),li],[Mo]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[So]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Do]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[No]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[jo]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[qo]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Ui]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Vo]:[ui],[Wo]:[ui],[Uo]:[ui],[Bo]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[zo]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Ho]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Go]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Ro]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},su=function(e,t,s,i){const r=Xo(e,t,s,i),n=tu[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},Gr=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[si,e&&e[1]||""]],[new RegExp(Ls,"i"),[Ls,""]],[new RegExp(Ds,"i"),[Ds,""]],[xr,[ti,""]],[new RegExp(ai,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ao,""];if(new RegExp(Ct).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const s=/Windows NT ([0-9.]+)/i.exec(t);if(s&&s[1]){let i=eu[s[1]]||"";return/arm/i.test(t)&&(i="RT"),[ai,i]}return[ai,""]}],[/((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]?[us,[e[2],e[3],e[4]||"0"].join(".")]:[us,""]],[/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",""]]],Yo=function(e){for(let t=0;Gr.length>t;t++){const[s,i]=Gr[t],r=s.exec(e),n=r&&(ue(i)?i(r,e):i);if(n)return n}return["",""]},Ko=function(e){return Ql.test(e)?Ls:Zl.test(e)?Ds:Jl.test(e)?si:new RegExp(Vi,"i").test(e)?Vi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?Ao:/iPad/.test(e)?ko:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Eo:xr.test(e)?ti:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Ur,"i").test(e)?Ur:/(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(Ct).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)?us:$o:new RegExp("(pda|Mobile)","i").test(e)?Kl:new RegExp(As,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?Lo:""},iu=function(e,t){var s;const i=Ko(e);return i===ko||i===$o||i==="Kobo"||i==="Kindle Fire"||i===Lo?As:i===Ls||i===si||i===Ds||i===Vi?"Console":i===Eo?"Wearable":i?Ct: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)?Ct:As:"Desktop";var r,n,o},ci=/\bFBAV\/(\d+(?:\.\d+)*)/i,Xr=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ci],[/\bFBAN\/EMA\b/i,"Facebook Lite",ci],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ci],[/\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"]],Gi="[Truncated]",_s="[Unserializable]";function Ft(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 Jo(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=_s}Object.defineProperty(e,i,{value:r,enumerable:!0,writable:!0,configurable:!0})}return e}const Is=3e5;var Zo=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,Is);if(!t)return this.ts=s,void(this.es=s+i);this.es=Math.max(this.es,Math.min(s+i,this.ts+Is))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(Is,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 ru=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Yr(e,t){return typeof(s=e)=="string"&&ru.test(s)?e:t();var s}function Qo(e,t){const s=new Error(t);try{Object.defineProperty(s,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function nt(e){return e&&e.split("#")[0]}function Kr(e){try{return e()}catch{return}}function ea(e,t){const s=setTimeout(e,t);return s!=null&&s.unref&&s?.unref(),s}function Jr(e,t,s){return ta.apply(this,arguments)}function ta(){return(ta=Z(function*(e,t,s){let i;try{return yield Promise.race([e,new Promise((r,n)=>{i=ea(()=>{try{s?.(),r()}catch(o){n(o)}},t)})])}finally{clearTimeout(i)}})).apply(this,arguments)}let ys,Zr,di;function nu(e){const t=globalThis._posthogChunkIds;if(!t)return;const s=Object.keys(t);return di&&s.length===Zr||(Zr=s.length,di=s.reduce((i,r)=>{ys||(ys={});const n=ys[r];if(n)i[n[0]]=n[1];else{const o=e(r);for(let a=o.length-1;a>=0;a--){const l=o[a],u=l?.filename,c=t[r];if(u&&c){i[u]=c,ys[r]=[u,c];break}}}return i},{})),di}function Jt(e){return Jt=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},Jt(e)}function ou(e,t,s){return(t=(function(i){var r=(function(n){if(Jt(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var a=o.call(n,"string");if(Jt(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)})(i);return Jt(r)=="symbol"?r:r+""})(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Qr(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 v(e){for(var t=1;arguments.length>t;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Qr(Object(s),!0).forEach(function(i){ou(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Qr(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}var au=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 Z(function*(){for(const s of e)s.stacktrace&&s.stacktrace.frames&&M(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 v(v({},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 Z(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?v(v({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:nu(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(Dt(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 M(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,g=0)=>{const m=c(p,g),_=m.apply;if(m.apply=R=>{a.push(d);try{return _(R)}finally{a.pop()}},g>4||g>0&&a.indexOf(d)!==-1)return this.coerceFallback(m);const f=typeof d=="object"&&d!==null||typeof d=="function";if(g===0&&i>=50||f&&o.has(d))return;f&&o.add(d),g===0&&i++;const b=this.getAggregateErrors(d);let w,P;n||(n=!!b);try{if(w=this.applyCoercers(d,m),!w)throw l}catch(R){if(R===l)return void(g===0&&i--);if(!n)throw R;w=this.coerceFallback(m)}if(!b||i>=50)return w;try{P=b.length}catch{return w}if(!Number.isInteger(P)||0>P||P>4294967295)return w;const k=[];for(let R=0;50>i&&1e3>r&&P>R;R++){let I;r++;try{I=m.next(b[R])}catch{i++,I=this.coerceFallback(c(p+1))}I&&k.push(I)}return v(v({},w),{},{errors:k})},c=(d,p=0)=>v(v({},t),{},{syntheticException:d==0?t.syntheticException:void 0,mechanism:d==0?e:{},apply(g){const m=u(g,d,p+1);if(!m)throw l;return m},next:g=>u(g,d+1)}),h=c(s);return v(v({},h),{},{apply:d=>{var p;return(p=u(d,s))!==null&&p!==void 0?p:this.coerceFallback(h)}})}};const lu=/^([a-z][a-z0-9.+-]+):/i,uu=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function cu(e){if(!e||e==="<anonymous>")return!1;const t=lu.exec(e);return!t||uu.includes(t[1].toLowerCase())}function Xi(e,t,s,i,r){const n={platform:e,filename:t,function:s==="<anonymous>"?"?":s,in_app:cu(t)};return x(i)||(n.lineno=i),x(r)||(n.colno=r),n}const sa=(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]},du=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,hu=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pu=/\((\S*)(?::(\d+))(?::(\d+))\)/,vu=(e,t)=>{const s=du.exec(e);if(s){const[,r,n,o]=s;return Xi(t,r,"?",+n,+o)}const i=hu.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){const o=pu.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}const[r,n]=sa(i[1]||"?",i[2]);return Xi(t,n,r,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},fu=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,gu=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_u=(e,t)=>{const s=fu.exec(e);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){const n=gu.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]=sa(r,i),Xi(t,i,r,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},en=/\(error: (.*)\)/;function $r(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function mu(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(!$r(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 yu(e,t){const s=t.start+t.length,i=ra(e,t);i&&e.splice(s+i===e.length?s:t.start,i)}function ia(e,t){let s=t.start;for(;s>0&&$r(e[s-1],e[s-1+t.length]);)s--;return t.start-s}function ra(e,t){const s=t.start+t.length;let i=s;for(;e.length>i&&$r(e[i],e[i-t.length]);)i++;return i-s}function bu(e,t){const s=t[0];let i=e.length-(s?ia(e,s):0);for(const r of t)i-=ra(e,r);return i}function wu(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 xu=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 Ts(e,"DOMException")}isDOMError(e){return Ts(e,"DOMError")}},$u=class{match(e){return Dt(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}}},ku=class{match(e){return!!Ts(e,"ErrorEvent")&&(e.error!=null||this.ur(e))}coerce(e,t){var s;if(e.error!=null)return t.apply(e.error);const i=t.apply(e.message);return v(v({},i),{},{stack:(s=this.cr(e))!==null&&s!==void 0?s:i.stack,synthetic:!0})}ur(e){return D(e.message)&&e.message.length>0}cr(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 Eu=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Su=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(Eu);return i&&(t=i[1],s=i[2]),[t,s]}};const Pu=["fatal","error","warning","log","info","debug"];function na(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 Ru=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(wr(e))return e.constructor.name;const t="name"in e?e.name:void 0;return D(t)&&!Kt(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: ${na(e)}`}isSeverityLevel(e){return D(e)&&!Kt(e)&&Pu.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(Dt(s))return s}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Fu=class{match(e){return wr(e)}coerce(e,t){var s;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${na(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},Iu=class{match(e){return wo(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}}},Ou=class{match(e){return Ts(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!wr(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 wo(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 Ns="$message",js="$timestamp",Cu=new Set([Ns,js]),hi={enabled:!0,max_bytes:32768};function qs(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:hi.enabled,max_bytes:Tu(e.max_bytes,hi.max_bytes)}:v({},hi)}var Mu=class{constructor(e){this.ns=[],this.ss=0,this.Rr=qs(e)}setConfig(e){this.Rr=qs(e),this.rs()}add(e){const t=(function(i){let r;try{r=yo(i)}catch{return}try{const n=JSON.parse(r);if(!N(n))return;const o=n,a=o[Ns],l=o[js];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.Rr.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.Rr.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function Tu(e,t){if(!ne(e)||e===1/0||e===-1/0)return t;const s=Math.floor(e);return 0>s?t:s}const tn=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function sn(e){return typeof e=="string"||e}function rn(e){return typeof e=="string"?e:void 0}const Au=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],oa="NativeGzipValidationError",Yi=e=>e.length>=2&&e[0]===31&&e[1]===139,nn=(e,t)=>e===zi.GZipJS||t===zi.GZipJS||t==="gzip",on=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let jt;const bs=e=>{throw Qo(oa,`Native gzip produced invalid output: ${e}`)},Lu=(an=Z(function*(e,t){18>e.size&&bs("too-short");const s=new Uint8Array(yield e.slice(0,10).arrayBuffer());Yi(s)&&s[2]===8||bs("invalid-header");const i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(n=>{const o=(()=>{if(jt)return jt;jt=[];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;jt[l]=u>>>0}return jt})();let a=4294967295;for(let l=0;n.length>l;l++)a=o[255&(a^n[l])]^a>>>8;return(4294967295^a)>>>0})(t)&&bs("invalid-crc");const r=t.length>>>0;i.getUint32(4,!0)!==r&&bs("invalid-size")}),function(e,t){return an.apply(this,arguments)});var an;function Ki(){return Ki=Z(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=Z(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 Lu(u,r),u}catch(r){if(s?.rethrow)throw r;return t&&console.error("Failed to gzip compress data",r),null}var i}),Ki.apply(this,arguments)}function aa(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 Du={}.propertyIsEnumerable;function Bs(e,t){try{return la(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function kr(e,t,s,i){if(0>=s.remainingNodes)return{stringValue:Gi};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:Ft(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:Gi};if(e instanceof Date){const r=e.getTime(),n=Number.isFinite(r)?e.toISOString():String(e);return{stringValue:typeof n=="string"?Ft(n):String(n)}}s.ancestors.add(e);try{try{const r=e.toJSON;if(typeof r=="function")return kr(r.call(e),t,s,i+1)}catch{}return M(e)?{arrayValue:{values:Nu(e,t,s,i+1)}}:{kvlistValue:{values:la(e,t,s,i+1)}}}finally{s.ancestors.delete(e)}}return{stringValue:Ft(String(e))}}function Nu(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(A(a))continue;r.push(kr(a,t,s,i))}catch{r.push({stringValue:_s})}return e.length>o&&r.push({stringValue:Gi}),r}function la(e,t,s,i){const r=[];for(const n in e)if(Du.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(te(o)||x(o))continue;r.push({key:Ft(n),value:kr(o,t,s,i)})}catch{r.push({key:Ft(n),value:{stringValue:_s}})}}return r}function ua(e,t,s){return v(v(v(v({},Jo({},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 ju=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function ca(e,t){const s=Jo({},e),i={};for(const r of ju)({}).hasOwnProperty.call(s,r)&&(i[r]=s[r],delete s[r]);return[...Bs(s,t),...Bs(i,t)]}const ln={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"},da={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}},qu=da.info;function Bu(e){try{return Ft(String(e))}catch{return _s}}function zu(e,t,s,i){const r=e.level||"info",{text:n,number:o}=da[r]||qu,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),A(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),A(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=v({},l),c=e.attributes;if(c){let d=[];try{d=Object.keys(c)}catch{d=[]}for(const p of d){let g;try{g=c[p]}catch{g=_s}Object.defineProperty(u,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}const h={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:n,body:{stringValue:Bu(e.body)},attributes:Bs(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 ha(e,t,s){return ua(e,t,s)}function pa(e,t,s,i){return{resourceLogs:[{resource:{attributes:ca(t)},scopeLogs:[{scope:{name:s,version:i},logRecords:e}]}]}}var va=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=ea(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function fa(){return .75+.5*Math.random()}function ga(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 Hu=class{constructor(e,t,s,i,r,n=()=>Promise.resolve(),o){var a;this._instance=e,this.Rr=t,this.$=s,this.cs=i,this.ds=r,this.vs=n,this.fs=o,this.ps=new va(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Zo,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!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(Le.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Rr.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.$.info("Log was rejected in beforeSend function");if(!this.Ds())return;const r={record:zu(i,(s=t?.context)!==null&&s!==void 0?s:this.cs(),this.$,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){const t=this.Rr.beforeSend;if(!t)return e;const s=M(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.$.info("Log was rejected in beforeSend function"),null;i=n}catch(n){return this.$.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.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.$s=!0),!1)}flush(){var e=this;return Z(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Z(function*(){var t;e.ps.clear();let s=(t=e._instance.getPersistedProperty(Le.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=pa(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.$.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.$.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.Rr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Rr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(u.length),s=(o=e._instance.getPersistedProperty(Le.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,h.kind==="fatal"))throw h.error}})()}Bs(e){var t=this;return Z(function*(){var s;const i=Math.max(0,e-t.bs),r=(s=t._instance.getPersistedProperty(Le.LogsQueue))!==null&&s!==void 0?s:[];t._instance.setPersistedProperty(Le.LogsQueue,r.slice(i)),yield t.vs()})()}qs(){return ha(this.Rr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const s=(t=this._instance.getPersistedProperty(Le.LogsQueue))!==null&&t!==void 0?t:[];this.Is>s.length||(s.shift(),this.bs++,this.$.info("Logs queue is full, dropping oldest record.")),s.push(e),this._instance.setPersistedProperty(Le.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()))}Hs(){return Math.max(ga(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(Le.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Z(function*(){t.ps.clear();const s=t.flush().catch(()=>{});e!==void 0?yield Jr(s,e):yield s})()}flushWithTimeout(e){var t=this;return Z(function*(){const s=t.flush();yield Jr(s,e,()=>{s.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=fa(),this.$.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const pi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function un(e){return String(e)+"000000"}function cn(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 Vu=class{constructor(e,t,s){this._instance=e,this.Rr=t,this.$=s,this.zs=new Map,this.ps=new va(()=>this.flush().catch(i=>{this.$.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Zo,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,s){this.Zs({name:e,type:"count",value:t,unit:s?.unit,attributes:s?.attributes})}gauge(e,t,s){this.Zs({name:e,type:"gauge",value:t,unit:s?.unit,attributes:s?.attributes})}histogram(e,t,s){this.Zs({name:e,type:"histogram",value:t,unit:s?.unit,attributes:s?.attributes})}flush(){var e=this;const t=this.ys,s=(function(){var i=Z(function*(){t&&(yield t.catch(()=>{})),yield e.Qs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===s&&(this.ys=null)});return this.ys=s,s}drainWindow(){if(this.zs.size===0)return null;const e=this.zs;return this.zs=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.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(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.$.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=t.attributes?v({},t.attributes):void 0,i=cn(t.type,t.name,t.unit,s)}catch(o){return void this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,o)}let r=this.zs.get(i);if(!r){if(!this.Ks())return;r={name:t.name,type:t.type,unit:t.unit,attributes:s,windowStartMs:Date.now()},this.zs.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.$.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),this.Fs()}Ks(){return this.Rr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Rr.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(pi.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,pi)]+=1;break}}}Os(e){const t=this.Rr.beforeSend;if(!t)return e;const s=M(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.$.info("Metric was rejected in beforeSend function"),null;i=n}catch(n){return this.$.error("Error in beforeSend function for metric:",n),null}return i}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(ga(this.Rr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return Z(function*(){if(e.ps.clear(),e.zs.size===0)return;const t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const s=e.Gs,i=yield e._instance.Ys(e.Js(t));if(s===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=fa()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),i.kind){case"ok":return;case"retry-later":return e.ho(t),void e.ps.armNoEarlierThan(e.Hs());case"too-large":return void e.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.$.error("Failed to send metrics batch:",i.error)}})()}Js(e){return t=this.vo(e),s=(function(n,o,a){return ua(n,o,a)})(this.Rr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:ca(s)},scopeMetrics:[{scope:{name:i,version:r},metrics:t}]}]};var t,s,i,r}vo(e){const t=un(Date.now()),s=new Map;for(const o of e.values()){var i;const a=cn(o.type,o.name,o.unit,void 0);let l=s.get(a);l||(l=v({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=Bs((i=o.attributes)!==null&&i!==void 0?i:{},this.$),c=un(o.windowStartMs);if(o.type==="count"){var r;const h={attributes:u,startTimeUnixNano:c,timeUnixNano:t,asDouble:(r=o.total)!==null&&r!==void 0?r:0};l.sum.dataPoints.push(h)}else if(o.type==="gauge"){var n;const h={attributes:u,timeUnixNano:t,asDouble:(n=o.last)!==null&&n!==void 0?n:0};l.gauge.dataPoints.push(h)}else o.hist&&l.histogram.dataPoints.push({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:pi})}return Array.from(s.values())}ho(e){for(const[i,r]of e){const n=this.zs.get(i);if(n)switch(n.windowStartMs=Math.min(n.windowStartMs,r.windowStartMs),n.type){case"count":var t,s;n.total=((t=n.total)!==null&&t!==void 0?t:0)+((s=r.total)!==null&&s!==void 0?s:0);break;case"gauge":break;case"histogram":if(r.hist)if(n.hist){n.hist.count+=r.hist.count,n.hist.sum+=r.hist.sum,n.hist.min=Math.min(n.hist.min,r.hist.min),n.hist.max=Math.max(n.hist.max,r.hist.max);for(let o=0;n.hist.bucketCounts.length>o;o++)n.hist.bucketCounts[o]+=r.hist.bucketCounts[o]}else n.hist=r.hist}else this.Ks()&&this.zs.set(i,r)}}};const _a=(e,{debugEnabled:t}={})=>{const s={N(i,...r){y&&(Ue.DEBUG||y.POSTHOG_DEBUG||t)&&!x(y.console)&&y.console&&("__rrweb_original__"in y.console[i]?y.console[i].__rrweb_original__:y.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)=>_a(`${e} ${i}`,r)};return s},E=_a("[PostHog.js]"),ie=E.createLogger,Wu=ie("[ExternalScriptsLoader]"),zs=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]}},dt=(e,t,s)=>{if(e.config.disable_external_dependency_loading)return Wu.warn(`${t} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");const i=zs(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(zs(t))return dt(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)},vi={},dn=(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)};O.__PosthogExtensions__=O.__PosthogExtensions__||{},O.__PosthogExtensions__.loadExternalDependency=(e,t,s)=>{if(t==="remote-config"){const r=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void dt(e,r,s)}const i=e.config.strict_script_versioning;if(i){const r=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),n=vi[r];if(i==="fallback"&&n){if(zs(n))return void dt(e,n,s);delete vi[r]}return void dt(e,r,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;const u=dn(e,t);vi[r]=u;const c=zs(r);c==null||(l=c.parentNode)===null||l===void 0||l.removeChild(c),dt(e,u,s)}else s(void 0,a)}:s)}dt(e,dn(e,t),s)},O.__PosthogExtensions__.loadSiteApp=(e,t,s)=>{const i=e.requestRouter.endpointFor("api",t);dt(e,i,s)},Ue.DEBUG=!1,Ue.LIB_VERSION="1.434.15",Ue.LIB_NAME="web";var le=Ue;const Uu="$people_distinct_id",Ie="distinct_id",Er="$device_id",fi="$device_model",Hs="__alias",Gu="__cmpns",hn="$fbc",It="$fbc_persistence",pn="$fbp",Zt="$fbp_persistence",Ji="__timers",ma="$autocapture_disabled_server_side",Zi="$heatmaps_enabled_server_side",Qi="$exception_capture_enabled_server_side",ya="$error_tracking_suppression_rules",er="$error_tracking_capture_extension_exceptions",tr="$web_vitals_enabled_server_side",Sr="$dead_clicks_enabled_server_side",Pr="$product_tours_enabled_server_side",ba="$logs_capture_enabled_server_side",wa="$web_vitals_allowed_metrics",Qt="$session_recording_remote_config",Xu="$session_recording_enabled_server_side",Yu="$replay_sample_rate",Ku="$replay_override_sampling",Ju="$replay_override_linked_flag",Zu="$replay_override_url_trigger",Qu="$replay_override_event_trigger",Et="$sesid",xa="$session_is_sampled",ec="$session_past_minimum_duration",tc="$session_recording_url_trigger_activated_session",sc="$session_recording_event_trigger_activated_session",ic="$debug_first_full_snapshot_timestamp",rc="$sess_rec_flush_size",Oe="$enabled_feature_flags",He="$active_feature_flags",sr="$early_access_features",vt="$feature_flag_details",et="$feature_flag_payloads",ft="$feature_flag_request_id",es="$minimal_flag_called_events",Ae="$override_feature_flags",ht="$override_feature_flag_payloads",tt="$stored_person_properties",st="$stored_group_properties",$a="$groups",ir="$surveys",Vs="$surveys_loaded_at",ka="$surveys_activated",Ea="$surveys_activated_session",Sa="$surveys_activated_timestamps",rr="ph_product_tours",nc="$product_tours_activated",oc="$product_tours_activated_session",ac="$conversations_widget_session_id",lc="$conversations_ticket_id",uc="$conversations_widget_state",cc="$conversations_user_traits",it="$flag_call_reported",Xt="$flag_call_reported_session_id",cs="$feature_flag_errors",rt="$feature_flag_evaluated_at",be="$user_state",nr="$client_session_props",dc="$capture_rate_limit",Pa="$initial_campaign_params",Ra="$initial_referrer_info",St="$initial_person_info",Rr="$epp",gi="$posthog_cookieless",Fa="$cookieless_mode",Ia="$sdk_debug_extensions_init_method",Oa="$sdk_debug_extensions_init_time_ms",Ca="$sdk_debug_recording_script_not_loaded",Ma="$sdk_debug_replay_stale_config",hc="$sdk_debug_replay_event_trigger_status",pc="$sdk_debug_replay_linked_flag_trigger_status",vc="$sdk_debug_replay_matched_recording_trigger_groups",fc="$sdk_debug_replay_pending_trigger_conditions",gc="$sdk_debug_replay_remote_trigger_matching_config",_c="$sdk_debug_replay_trigger_groups_count",mc="$sdk_debug_replay_url_trigger_status",yc="$session_recording_start_reason",Fr="PostHog loadExternalDependency extension not found.",Ve="anonymous",Os="identified",Ta="identified_only",ds="visibilitychange",Ws="beforeunload",Ir="$pageview",vn="$pageleave",Aa="$identify",fn="$groupidentify";function Pt(e,t){M(e)&&e.forEach(t)}function G(e,t){if(!A(e))if(M(e))e.forEach(t);else if((s=>s instanceof FormData)(e))e.forEach((s,i)=>t(s,i));else for(const s in e)br.call(e,s)&&t(e[s],s)}const J=function(e,...t){for(const s of t)for(const i in s)s[i]!==void 0&&(e[i]=s[i]);return e};function Cs(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 bc=function(e){return function(...t){try{return e.apply(this,t)}catch(s){E.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),E.critical(s)}}},Or=function(e){const t={};return G(e,function(s,i){(D(s)&&s.length>0||ne(s))&&(t[i]=s)}),t};function La(e){const t=v({},e);for(const s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch{}return t}const wc=["herokuapp.com","vercel.app","netlify.app"];function xc(e){const t=e?.hostname;if(!D(t))return!1;const s=t.split(".").slice(-2).join(".");for(const i of wc)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 or(e){return e.name==="ph_toolbar_internal"}const ts=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 $c=class ar{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 ar(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 ar(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}},kc=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.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return $c.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(2,30)-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new Ec}};let Da=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};y&&!x(y.crypto)&&crypto.getRandomValues&&(Da=e=>crypto.getRandomValues(e));var Ec=class{nextUint32(){return this.Rt.length>this.$t||(Da(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}};let gn;const Ce=()=>Sc().toString(),Sc=()=>(gn||(gn=new kc)).generate();let qt="";const Pc=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let mt=null;const Q={Et(){if(!te(mt))return mt;if(mt=!1,$)try{const e=`__ph_cookie_support_${Ce()}`;Q.At(e,"xyz"),mt=ts(e)==='"xyz"',Q.Lt(e)}catch{mt=!1}return mt},Pt(e){E.error("cookieStore error: "+e)},Ot:ts,Dt(e){let t;try{t=JSON.parse(Q.Ot(e))||{}}catch{}return t},At(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(qt)return qt;if(!p||["localhost","127.0.0.1"].includes(d))return"";const g=d.split(".");let m=Math.min(g.length,8);const _="dmn_chk_"+Ce();for(;!qt&&m--;){const f=g.slice(m).join("."),b=_+"=1;domain=."+f+";path=/";p.cookie=b+";max-age=3",p.cookie.includes(_)&&(p.cookie=b+";max-age=0",qt=f)}return qt})(u);if(!h){const d=(p=>{const g=p.match(Pc);return g?g[0]:""})(u);d!==h&&E.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&&E.warn("cookieStore warning: large cookie, len="+l.length),$.cookie=l,!0}catch{return!1}},Lt(e,t){if($?.cookie&&(!t||!te(ts(e))))try{Q.At(e,"",-1,t)}catch{return}}};let _i=null;const B={Et(){if(!te(_i))return _i;let e=!0;if(x(y))e=!1;else try{const t="__mplssupport__";B.At(t,"xyz"),B.Ot(t)!=='"xyz"'&&(e=!1),B.Lt(t)}catch{e=!1}return e||E.error("localStorage unsupported; falling back to cookie store"),_i=e,e},Pt(e){E.error("localStorage error: "+e)},Ot(e){try{return y?.localStorage.getItem(e)}catch(t){B.Pt(t)}return null},Dt(e){try{return JSON.parse(B.Ot(e))||{}}catch{}return null},At(e,t){try{return y?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(s){B.Pt(s)}return!1},Lt(e){try{y?.localStorage.removeItem(e)}catch(t){B.Pt(t)}}},mi=[tt,He,Oe,vt,et,ft,rt,cs,it],pt=[Er,Ie,Et,xa,Rr,St,It,be],Us=e=>e+"_cpm",Rc=["__proto__","constructor","prototype"],yi=e=>{if(!N(e))return{};const t={};return Object.keys(e).forEach(s=>{Rc.indexOf(s)===-1&&(t[s]=e[s])}),t},bi=(e,t=[])=>{const s={};return[...pt,...t].forEach(i=>{const r=e[i];x(r)||te(r)||r===""||(s[i]=r)}),s},Na=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)},_n=(e,t)=>({p:t,f:Na(JSON.stringify(e))}),mn=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const s=Q.Dt(Us(e)),i=s?.f===Na(t)&&M(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},wi=(e,t)=>t+"|"+(Q.Ot(Us(e))||""),yt={},lr={Et:()=>!0,Pt(e){E.error("memoryStorage error: "+e)},Ot:e=>e in yt?yt[e]:null,Dt:e=>e in yt?yt[e]:null,At:(e,t)=>(yt[e]=t,!0),Lt(e){delete yt[e]}};let at=null;const Y={Et(){if(!te(at))return at;if(at=!0,x(y))at=!1;else try{const e="__support__";Y.At(e,"xyz"),Y.Ot(e)!=='"xyz"'&&(at=!1),Y.Lt(e)}catch{at=!1}return at},Pt(e){E.error("sessionStorage error: ",e)},Ot(e){try{return y?.sessionStorage.getItem(e)}catch(t){Y.Pt(t)}return null},Dt(e){try{return JSON.parse(Y.Ot(e))||null}catch{}return null},At(e,t){try{return y?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(s){Y.Pt(s)}return!1},Lt(e){try{y?.sessionStorage.removeItem(e)}catch(t){Y.Pt(t)}}};var Fc=class{constructor(e){this._instance=e}get Rr(){return this._instance.config}get consent(){return this.Lo()?0:this.No}isOptedOut(){return this.Rr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Rr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rr.opt_out_capturing_by_default}optInOut(e){this.qo.At(this.jo,e?1:0,this.Rr.cookie_expiration,this.Rr.cross_subdomain_cookie,this.Rr.secure_cookie)}reset(){this.qo.Lt(this.jo,this.Rr.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 oi(e)?1:T(Gl,e)?0:-1}get qo(){const e=this.Rr.opt_out_capturing_persistence_type,t=e==="localStorage"?B:Q,s=t.Et()?t:lr;if(!this.Bo||this.Bo!==s){this.Bo=s;const i=e==="localStorage"?Q:B;i.Ot(this.jo)&&(this.Bo.Ot(this.jo)||this.optInOut(oi(i.Ot(this.jo))),i.Lt(this.jo,this.Rr.cross_subdomain_cookie))}return this.Bo}Lo(){return!!this.Rr.respect_dnt&&[ce?.doNotTrack,ce?.msDoNotTrack,O.doNotTrack,ce?.globalPrivacyControl].some(e=>oi(e))}};function ja(e,t){var s;const i=e==null||(s=e.config)===null||s===void 0?void 0:s.get_current_url;if(!ue(i))return t;try{const r=i(t);return D(r)&&r?r:t}catch(r){return E.error("Error in get_current_url, falling back to window.location.href",r),t}}function yn(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 Ne(e){return!!e&&e.nodeType===1}function ve(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function qa(e){return!!e&&e.nodeType===3}function Cr(e){return!!e&&e.nodeType===11&&Ne(e.host)}function Mr(e){return e?Qs(e).split(/\s+/):[]}function bn(e,t){const s=(function(i){var r;const n=y==null||(r=y.location)===null||r===void 0?void 0:r.href;return x(n)?void 0:ja(i,n)})(t);return!!(s&&e&&e.some(i=>s.match(i)))}function Mt(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 Mr(t)}function Ba(e){return A(e)?null:Qs(e).split(/(\s+)/).filter(t=>is(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function hs(e){let t="";return Ot(e)&&!ps(e)&&e.childNodes&&e.childNodes.length&&G(e.childNodes,function(s){var i;qa(s)&&s.textContent&&(t+=(i=Ba(s.textContent))!==null&&i!==void 0?i:"")}),Qs(t)}function ss(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 Tr=["a","button","form","input","select","textarea","label"];function ur(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 cr(e,t){if(x(t))return!0;for(const s of e)if(t.some(i=>ur(s,i)))return!0;return!1}function za(e){const t=e.parentNode;return!(!t||!Ne(t))&&t}const xi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ha=["next","previous","prev",">","<"],Ic=[...Ha,"+","-","−","–"],wn=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,xn=[".ph-no-rageclick",".ph-no-capture"],Oc=["","text","search","email","password","url","tel","number"];function Va(e,t){if(!y||Ar(e))return!1;let s,i,r;var n,o;if(we(t)?(s=!!t&&xn,i=void 0,r=!1):(s=(n=t?.css_selector_ignorelist)!==null&&n!==void 0?n:xn,i=t?.content_ignorelist,r=(o=t?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||r&&(function(l){return!(!l||!Ne(l))&&(!!ve(l,"textarea")||(ve(l,"input")?T(Oc,(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}=Wa(e,!1);return!(function(l,u){if(l===!1||x(l))return!1;let c;if(l===!0)c=Ha;else{if(!M(l))return!1;if(l.length>10)return E.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(h=>h.toLowerCase())}return u.some(({safeText:h,ariaLabel:d})=>c.some(p=>wn(h,p)||wn(d,p)))})(i,a.map(l=>{var u;return{safeText:hs(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))===null||u===void 0?void 0:u.toLowerCase().trim())||""}}))&&!cr(a,s)}const Ar=e=>!e||ve(e,"html")||!Ne(e),Wa=(e,t)=>{if(!y||Ar(e))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const i=[e];let r=e;for(;r.parentNode&&!ve(r,"body");){if(Cr(r.parentNode)){i.push(r.parentNode.host),r=r.parentNode.host;continue}const n=za(r);if(!n)break;if(t||Tr.indexOf(n.tagName.toLowerCase())>-1)s=!0;else try{const o=y.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(n),r=n}return{parentIsUsefulElement:s,targetElementList:i}};function Ot(e){const t=new Set;let s=0;for(let n=e;n.parentNode&&!ve(n,"body");n=n.parentNode){if(s++>=1e3||t.has(n))return!1;t.add(n);const o=Mt(n);if(T(o,"ph-sensitive")||T(o,"ph-no-capture"))return!1}if(T(Mt(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 ps(e){return!!(ve(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ve(e,"select")||ve(e,"textarea")||e.getAttribute("contenteditable")==="true")}const $n=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}))$"),kn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Cc=[16,15,14,13],Mc=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),En=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Sn=/[0-9A-Za-z_]/;function Tc(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 is(e,t=!0){return!(A(e)||D(e)&&(e=Qs(e),(t?$n.test((e||"").replace(/[- ]/g,"")):(function(s){let i;for(kn.lastIndex=0;i=kn.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 Cc){const l=o+a;if(n.length>=l){const u=n.slice(o,l);if($n.test(u)&&Tc(u))return!0}}}return!1})(e))||(t?Mc.test(e):(function(s){let i;for(En.lastIndex=0;i=En.exec(s);){const r=i[1],n=i[3];if(!(r&&n&&Sn.test(r)&&Sn.test(n)))return!0}return!1})(e))))}function Pn(e){let t=hs(e);return t=`${t} ${Ua(e)}`.trim(),is(t)?t:""}function Ua(e){let t="";return e&&e.childNodes&&e.childNodes.length&&G(e.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{const r=hs(s);t=`${t} ${r}`.trim(),s.childNodes&&s.childNodes.length&&(t=`${t} ${Ua(s)}`.trim())}catch(r){E.error("[AutoCapture]",r)}}),t}function Rn(e){return e.replace(/"|\\"/g,'\\"')}function Ac(e){const t=e.attr__class;if(t)return M(t)?t:Mr(t)}const ws=ie("[Dead Clicks]"),Lc=()=>!0,Dc=e=>{var t;const s=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(Sr)),i=e.instance.config.capture_dead_clicks;return we(i)?i:!!N(i)||s};var Fn=class{get lazyLoadedDeadClicksAutocapture(){return this.Ho}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({[Sr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Uo()}):this.stop()}zo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",r=>{r?ws.error("failed to load script",r):e()})}Uo(){var e;if($){if(!this.Ho&&(!((e=O.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=N(this.instance.config.capture_dead_clicks)?v({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Ho=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Ho.start($),ws.info("starting...")}}else ws.error("`document` not found. Cannot start.")}stop(){this.Ho&&(this.Ho.stop(),this.Ho=void 0,ws.info("stopping..."))}};const Bt=ie("[SegmentIntegration]");function In(e,t,s=!0){const i=e.config.segment;if(!i)return t();const{analytics:r,filterProperties:n}=(a=>ue(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,u,c){const h=p=>{const g=()=>p.anonymousId()||Ce();a.config.get_device_id=g,c&&p.id()&&(a.register({distinct_id:p.id(),$device_id:g()}),a.persistence.set_property(be,Os)),u(c?void 0:p.anonymousId()||void 0)},d=l.user();"then"in d&&ue(d.then)?d.then(h):h(d)})(e,r,a=>{r.register(((l,u,{filterProperties:c}={})=>{typeof Promise<"u"&&Promise.resolve||Bt.warn("This browser does not have Promise support, and can not use the segment integration");const h=(d,p)=>{if(!p)return d;const g=!!u&&d.event.anonymousId===u&&!d.event.userId;g||d.event.userId||d.event.anonymousId===l.get_distinct_id()||(Bt.info("No userId set, resetting PostHog"),l.reset()),g||(u=void 0),d.event.userId&&d.event.userId!==l.get_distinct_id()&&(Bt.info("UserId set, identifying with PostHog"),l.identify(d.event.userId));let m=l.calculateEventProperties(p,d.event.properties);if(!A(c)){const _=d.event.properties||{},f={};for(const w of Object.keys(m))br.call(_,w)||(f[w]=m[w]);const b=((w,P)=>{const k=M(w)?w:[w];let R=v({},P);for(const I of k)try{if(R=I(R),A(R))return null}catch(S){return Bt.error("Error in Segment filterProperties:",S),null}return R})(c,f);if(A(b))return d;m=b}return d.event.properties=Object.assign({},m,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,Ir)},identify(d){return h(d,Aa)},screen(d){return h(d,"$screen")}}})(e,a,{filterProperties:n})).then(()=>{t()},l=>{Bt.error("Failed to register the Segment integration",l),t()})},s)}const Ga="posthog-js";function Xa(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)||[],g=p.map(f=>v(v({},f),{},{stacktrace:f.stacktrace?v(v({},f.stacktrace),{},{type:"raw",frames:(f.stacktrace.frames||[]).map(b=>v(v({},b),{},{platform:"web:javascript"}))}):void 0})),m={$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:g,$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 _;return t&&s&&(m.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+o.event_id),n&&((_=e.exceptions)===null||_===void 0||_.sendExceptionEvent(m)),o}}var Nc=class{constructor(e,t,s,i,r,n){this.name=Ga,this.setupOnce=function(o){o(Xa(e,{organization:t,projectId:s,prefix:i,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},On=class{constructor(e){this.Wo=(t,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(E.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.Zo=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Wo)}destroy(){var e;(e=this.Zo)===null||e===void 0||e.call(this),this.Zo=void 0}doPageView(e,t){var s;const i=this.Qo(e,t);return this.Vo={pathname:(s=y?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Qo(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}}Qo(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?De(o/n,0,1,E):1,d=n>1?De(a/n,0,1,E):1,p=l>1?De(u/l,0,1,E):1,g=l>1?De(c/l,0,1,E):1;i=J(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:g})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),i}};const zt=["flags","surveys"],jc={[Uu]:{exposure:"hidden"},[Hs]:{exposure:"hidden"},[Gu]:{exposure:"hidden"},[Ji]:{exposure:"hidden"},[It]:{exposure:"hidden"},[Zt]:{exposure:"hidden"},[ma]:{exposure:"event"},[Zi]:{exposure:"hidden"},[ba]:{exposure:"hidden"},[Qi]:{exposure:"event"},[ya]:{exposure:"hidden"},[er]:{exposure:"event"},[tr]:{exposure:"event"},[Sr]:{exposure:"event"},[Pr]:{exposure:"hidden"},[wa]:{exposure:"event"},[Qt]:{exposure:"hidden"},[Xu]:{exposure:"hidden"},[Et]:{exposure:"hidden"},[xa]:{exposure:"event"},[Yu]:{exposure:"event",shouldSkipFromEventProperties:e=>te(e)},[ec]:{exposure:"event"},[tc]:{exposure:"event"},[sc]:{exposure:"event"},[ic]:{exposure:"event"},[rc]:{exposure:"hidden"},[Oe]:{exposure:"hidden",storageGroup:"flags"},[He]:{exposure:"hidden",storageGroup:"flags"},[sr]:{exposure:"hidden"},[vt]:{exposure:"hidden",storageGroup:"flags"},[et]:{exposure:"hidden",storageGroup:"flags"},[ft]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[es]:{exposure:"hidden",storageGroup:"flags"},[Ae]:{exposure:"hidden"},[ht]:{exposure:"hidden"},[tt]:{exposure:"hidden"},[st]:{exposure:"hidden"},[ir]:{exposure:"hidden",storageGroup:"surveys"},[Vs]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[ka]:{exposure:"event"},[Ea]:{exposure:"hidden"},[Sa]:{exposure:"hidden"},[rr]:{exposure:"hidden"},[nc]:{exposure:"hidden"},[oc]:{exposure:"hidden"},[ac]:{exposure:"event"},[lc]:{exposure:"event"},[uc]:{exposure:"event"},[cc]:{exposure:"event"},[it]:{exposure:"hidden"},[Xt]:{exposure:"hidden"},[$a]:{exposure:"event"},[cs]:{exposure:"hidden"},[rt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[be]:{exposure:"hidden"},[nr]:{exposure:"hidden"},[dc]:{exposure:"hidden"},[Pa]:{exposure:"hidden"},[Ra]:{exposure:"hidden"},[St]:{exposure:"hidden"},[Rr]:{exposure:"hidden"},[Ku]:{exposure:"event"},[Ju]:{exposure:"event"},[Zu]:{exposure:"event"},[Qu]:{exposure:"event"},[Ia]:{exposure:"event"},[Oa]:{exposure:"event"},[Ca]:{exposure:"event"},[Ma]:{exposure:"event"},[hc]:{exposure:"event"},[pc]:{exposure:"event"},[vc]:{exposure:"event"},[fc]:{exposure:"event"},[gc]:{exposure:"event"},[_c]:{exposure:"event"},[mc]:{exposure:"event"},[yc]:{exposure:"event"}},qc=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],he=e=>{const t=jc[e];if(t)return t;for(const[s,i]of qc)if(e.indexOf(s)===0)return i},Rt=(e,t)=>{try{let s;return JSON.stringify(e,(i,r)=>{var n;return Dt(r)?((n=s)!==null&&n!==void 0||(s=new WeakMap),s.has(r)||s.set(r,La(r)),s.get(r)):typeof r=="bigint"?r.toString():r},t)}catch{return yo(e)}},Ge=e=>{const t=$?.createElement("a");return x(t)?null:(t.href=e,t)},Tt=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(!M(i)||2>i.length)return"";{let r=i[1];try{r=decodeURIComponent(r)}catch{E.error("Skipping decoding for malformed query param: "+r)}return r.replace(/\+/g," ")}},vs=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("=");M(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},Gs=function(e,t){const s=e.match(new RegExp(t+"=([^&]*)"));return s?s[1]:null},Ya=(e,t)=>e>=t&&mo(),Ka=(e,t,s,i)=>{if(e===0){if(mo()){const r=t+1;return r===s&&i(),r}return t}return 0},At=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Bc=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...At],fs="<masked>",zc=["li_fat_id"];function Ja(e,t,s){if(!$)return{};const i=t?[...At,...s||[]]:[],r=Za(vs($.URL,i,fs),e),n=(function(){const o={};return G(zc,function(a){const l=ts(a);o[a]=l||null}),o})();return J(n,r)}function Za(e,t){const s=Bc.concat(t||[]),i={};return G(s,function(r){const n=Tt(e,r);i[r]=n||null}),i}function Qa(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(!te(t)){i.$search_engine=t;const r=$?Tt($.referrer,s):"";r.length&&(i.ph_keyword=r)}return i}function el(){return navigator.language||navigator.userLanguage}function Hc(){const e=el();return typeof e=="string"?e.split("-")[0]:void 0}const Xs="$direct";function tl(){return $?.referrer||Xs}function sl(e,t,s=!1){const i=e?[...At,...t||[]]:[],r=s?nt(ee?.href):ee?.href,n=r?.substring(0,1e3);return{r:tl().substring(0,1e3),u:n?vs(n,i,fs):void 0}}function il(e,t=!1){var s;const{r:i,u:r}=e,n=t?nt(r):r,o={$referrer:i,$referring_domain:i==null?void 0:i==Xs?Xs:(s=Ge(i))===null||s===void 0?void 0:s.host};if(n){o.$current_url=n;const a=Ge(n);o.$host=a?.host,o.$pathname=a?.pathname;const l=Za(n);J(o,l)}if(i){const a=Qa(i);J(o,a)}return o}function rl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Vc(){try{return new Date().getTimezoneOffset()}catch{return}}const Wc={flags:rt,surveys:Vs},Uc=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],xs=e=>`${e}_cookie_identity_change_pending`,$s=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},ae="main",ze=[Oe,He,vt,et,ft,rt,es,tt],$i=e=>ze.indexOf(e)!==-1,nl=[It,Zt],Cn=e=>nl.indexOf(e)!==-1,Je=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},bt=e=>{if(!e)return{};const t=JSON.parse(e);return N(t)?t:{}},Mn=(e,t)=>{G(e,(s,i)=>{const r=he(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(t,i)||delete e[i]})};var ki=class{constructor(e,t,s=!0){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.Rr=e,this.la=s,this.props={},this.ua=void 0,this.ha=(i=>{let r="";return i.token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"})(e),this.qo=this.ca(e),this.Yo=this.da(e),this.load(),this.va(),e.debug&&E.info("Persistence loaded",e.persistence,v({},this.props)),this.update_config(e,e,t),this.save(),y){const i=()=>this.flush();W(y,"beforeunload",i,{capture:!1}),W(y,"pagehide",i,{capture:!1}),this.fa=r=>{if(this.Ko&&(!r.storageArea||r.storageArea===y?.localStorage)&&r.key)if(r.key!==this.ha){if(this.Yo){const n=zt.find(o=>r.key===this.pa(o));n&&this.ga(r.key,n)}}else this.ga(r.key,ae)},W(y,"storage",this.fa)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,s])=>{const i=this.ia.get(t);if(!$i(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&&y&&(y.removeEventListener("storage",this.fa),this.fa=void 0),this.aa.clear()}ga(e,t,s=!0){if(this.mi)return!1;let i,r;try{if(r=B.Ot(e),te(r)){const a=this.ya(t);return a.storageValue=null,t!==ae&&(a.persisted=!1),!1}i=bt(r)}catch{return!1}const n=t===ae?i:B.Dt(this.ha);if(n&&this.ba(n))return!1;const o=this._a(i,t,s);return t===ae&&this.Yo&&!Je(this.wa().main,i)||this.ka(i,t,!0,r),o}ba(e){const t=this.props[Ie],s=e[Ie];return!x(t)&&!x(s)&&t!==s}ka(e,t,s,i){const r=this.ya(t);r.storageValue=i,t!==ae&&(r.persisted=s);try{r.fingerprint=this.Sa(e,t)}catch{r.fingerprint=void 0}}_a(e,t,s){let i=!1;return ze.forEach(r=>{var n;const o=(n=he(r))===null||n===void 0?void 0:n.storageGroup;if(t===ae&&this.Yo&&o||t!==ae&&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&&Je(l,this.props[r])||(u?this.Ca(r,l,!1):this.$a(r,!1),i=!0)}),i&&s&&this.aa.forEach(r=>r()),i}Ta(){if(!this.Ko)return!1;try{this.ra=!1;const e=B.Ot(this.ha),t=this.ya(ae);let s,i=!1,r=!1;if(e!==t.storageValue)if(te(e))t.storageValue=null;else{if(s=bt(e),this.ra=!this.sa&&this.ba(s),this.ra)return!1;r=this._a(s,ae,!1),!this.Yo||Je(this.wa().main,s)?this.ka(s,ae,!0,e):t.storageValue=e,i=!0}return this.Yo&&zt.forEach(n=>{const o=B.Ot(this.pa(n)),a=this.ya(n),l=s||{},u=i&&ze.some(h=>{var d;return((d=he(h))===null||d===void 0?void 0:d.storageGroup)===n&&h in l});if(o===a.storageValue&&!u)return;if(te(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this._a(l,n,!1)||r));const c=bt(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=he(e);s?.volatile||(this.ya((this.Yo?s?.storageGroup:void 0)||ae).fingerprint=void 0,this.Ia(e))}Ma(){ze.forEach(e=>this.ia.set(e,!0))}va(){if(this.Ko)try{const e=B.Ot(this.ha),t=bt(e);this.ya(ae).storageValue=e,ze.forEach(s=>{var i;const r=this.Yo?(i=he(s))===null||i===void 0?void 0:i.storageGroup:void 0,n=r?B.Ot(this.pa(r)):null;if(r){const a=this.ya(r);a.storageValue=n,a.persisted=!te(n)}const o=r&&!te(n)?bt(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(M(t)?t:[]),o=new Set(M(this.props[e])?this.props[e]:[]);return s.forEach(a=>o.has(a)?n.add(a):n.delete(a)),Array.from(n)}const i=N(t)?v({},t):{},r=N(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(!$i(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=he(e))===null||n===void 0?void 0:n.storageGroup:void 0,l=a?this.pa(a):this.ha;r=bt(B.Ot(l))[e]}catch{}const o=new Set(i||[]);if(e==="$active_feature_flags"){if(!x(t)&&!M(t)||!x(r)&&!M(r)||!M(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(!N(s))return void(Je(r,s)?this.ia.delete(e):this.ma(e,!0));{if(!x(t)&&!N(t)||x(t)&&$e(s)&&x(r))return void this.ma(e,!0);const a=N(t)?t:{},l=N(r)?r:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(u=>{u in a==u in s&&Je(a[u],s[u])||o.add(u)}),o.forEach(u=>{u in l==u in s&&Je(l[u],s[u])&&o.delete(u)})}}o.size?this.ma(e,o):this.ia.delete(e)}Pa(){var e;const t=(e=this.Rr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return ne(t)&&t>0?t:0}Ra(e){if(this.Rr.cookieWinsOnConflict&&this.Rr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=bi(e,this.Rr.cookie_persisted_properties||[]),s=_n(t,this.Rr.cookie_persisted_properties||[]),i=JSON.stringify(t)+"|"+JSON.stringify(s),r=Q.Ot(this.ha)||void 0;r&&wi(this.ha,r)===i&&(this.Aa=i,this.Fa=r)}catch{}else try{const t=Q.Ot(this.ha)||void 0;this.Aa=t?wi(this.ha,t):void 0,this.Fa=t}catch{}}syncCookieProperties(){return this.Oa(this.Rr)}Oa(e,t=!1){if(this.mi&&!t||this.ea||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=Q.Ot(this.ha)||void 0}catch{}if(!s||s===this.Fa)return!1;const i=wi(this.ha,s);let r;try{r=yi(JSON.parse(s))}catch{return!1}if((Q.Ot(this.ha)||void 0)!==s)return!1;this.Aa=i,this.Fa=s;const n=mn(this.ha,s),o=[...pt,...n.properties],a={};if(Object.keys(r).forEach(m=>{const _=r[m];(x(_)||te(_)||_===""||m==="$user_state"&&_!=="anonymous"&&_!=="identified")&&(a[m]=!0,delete r[m])}),$e(r))return!1;const l="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",u=this.props,c=u[Ie],h=u[be],d=J({},u);[...pt,...e.cookie_persisted_properties||[]].forEach(m=>{if(o.indexOf(m)!==-1&&!(m in r)&&!a[m]&&(l||m!=="distinct_id"&&m!=="$user_state")){const _=d[m];(n.isValid||pt.indexOf(m)===-1||_!==!1&&_!==0)&&delete d[m]}}),this.props=J(d,r),ze.forEach(m=>{const _=m in this.props;m in u===_&&Je(u[m],this.props[m])||(_?this.Ea(m,u[m],this.props[m]):this.ma(m,!0))}),!l||"$user_state"in r||"$user_state"in this.props||this.Ca(be,Ve);const p=this.props[Ie],g=this.props[be];return!l||p===c&&g===h||(this.sa=!0,this.ta=!0,Y.At(xs(this.ha),!0),this.$a(tt),this.$a(He),this.$a(Oe),this.$a(vt),this.$a(et),this.$a(ft),this.$a(rt),this.$a(cs),this.$a(it),g!=="anonymous"||h!=="identified"&&r.$user_state!=="anonymous"&&(x(c)||p===c)||(Mn(this.props,r),this.$a(st)),g==="identified"?this.props.$user_id=p:delete this.props.$user_id,this.$a(Hs)),!0}consumeCookieIdentityChange(){const e=xs(this.ha),t=this.ta||!!Y.Ot(e);return this.ta=!1,t&&Y.Lt(e),t}Da(e=!1){return!(this.ea||this.mi&&!e||!this.Rr.cookieWinsOnConflict||this.Rr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ea=!0,0))}La(){this.ea&&(x(this.Na)||(clearTimeout(this.Na),this.Na=void 0),delete this.Jo[ae],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.mi}ca(e){Uc.indexOf(e.persistence.toLowerCase())===-1&&(E.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((o=[],a=!1)=>{const l=[...pt,...o];return v(v({},B),{},{Dt(u){try{let h,d={};try{h=Q.Ot(u)||void 0,d=h?yi(JSON.parse(h)):{}}catch{}const p=JSON.parse(B.Ot(u)||"{}");let g;if(a){const m=mn(u,h),_=[...pt,...m.properties],f={};Object.keys(d).forEach(w=>{const P=d[w];te(P)||P===""||w==="$user_state"&&P!=="anonymous"&&P!=="identified"||(f[w]=P)});const b="distinct_id"in f||f.$user_state==="anonymous"||f.$user_state==="identified";if(Object.keys(f).length>0){var c;const w=p[Ie],P=(c=p.$user_state)!==null&&c!==void 0?c:Ve;l.forEach(k=>{if(_.indexOf(k)!==-1&&!(k in d)&&(b||k!=="distinct_id"&&k!=="$user_state")){const R=p[k];(m.isValid||pt.indexOf(k)===-1||R!==!1&&R!==0)&&delete p[k]}}),!b||"$user_state"in d||"$user_state"in p||(p[be]=Ve),!b||("distinct_id"in f?f[Ie]:p[Ie])===w&&("$user_state"in f?f[be]:p[be])===P||(mi.forEach(k=>delete p[k]),f.$user_state==="identified"&&"distinct_id"in f?p.$user_id=f[Ie]:delete p.$user_id,f.$user_state!=="identified"&&(delete p[$a],delete p[st]),delete p.__alias)}g=J(p,f)}else g=J(d,p);return B.At(u,g),g}catch{}return null},At(u,c,h,d,p,g){const m=B.At(u,c,void 0,void 0,g);try{const _=bi(c,o);if(Object.keys(_).length){if(a){const f=Us(u),b=_n(_,o);if(Q.At(f,b,h,d,p,g),Q.Ot(f)!==JSON.stringify(b)){Q.Lt(f,d);const w=bi(c);return Q.At(u,w,h,d,p,g),m}}Q.At(u,_,h,d,p,g)}}catch(_){B.Pt(_)}return m},Lt(u,c){try{y?.localStorage.removeItem(u),Q.Lt(u,c),Q.Lt(Us(u),c)}catch(h){B.Pt(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict);let s,i=!1,r=!1;const n=e.persistence.toLowerCase();return n==="localstorage"&&B.Et()?(s=B,r=!0):n==="localstorage+cookie"&&t.Et()?(s=t,r=!0,i=!0):n==="sessionstorage"&&Y.Et()?s=Y:n==="memory"?s=lr:n==="cookie"&&Q.Et()?(s=Q,i=!0):t.Et()?(s=t,r=!0,i=!0):Q.Et()?(s=Q,i=!0):s=lr,this.Ko=r,this.Xo=i,s}pa(e){return`${this.ha}__${e}`}da(e){return this.Ko&&!!e.split_storage}properties(){const e={};return G(this.props,(t,s)=>{const i=he(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.mi&&!e)return;const t=this.Rr.cookieWinsOnConflict&&this.Rr.persistence.toLowerCase()==="localstorage+cookie",s=t?B.Dt(this.ha):null;let i={};if(t)try{i=yi(Q.Dt(this.ha)),G(i,(a,l)=>{(x(a)||te(a)||a==="")&&delete i[l]})}catch{}const r=this.qo.Dt(this.ha);if(r&&(this.props=J({},r)),this.Yo&&this.Ba(),t&&r){var n,o;const a=s?.[Ie],l=(n=s?.$user_state)!==null&&n!==void 0?n:Ve,u=r[Ie],c=(o=r.$user_state)!==null&&o!==void 0?o:Ve;if(u!==a||c!==l){this.ta=!0,Y.At(xs(this.ha),!0);const h=J({},this.props);mi.forEach(p=>delete h[p]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(x(a)||u===a)||(Mn(h,i),delete h[st]),this.props=h;const d=new Set;mi.forEach(p=>{var g;const m=(g=he(p))===null||g===void 0?void 0:g.storageGroup;m&&d.add(m)}),d.forEach(p=>{const g={};G(this.props,(m,_)=>{var f;((f=he(_))===null||f===void 0?void 0:f.storageGroup)===p&&(g[_]=m)}),$e(g)?(B.Lt(this.pa(p)),this.Jo[p]={}):B.At(this.pa(p),g)&&(this.Jo[p]={persisted:!0,fingerprint:this.Sa(g,p)})})}}Y.Ot(xs(this.ha))&&(this.ta=!0)}Ba(){for(const e of zt){const t=B.Dt(this.pa(e));if(t&&!$e(t)){const s=this.ya(e);s.persisted=!0,this.Ha(e)||(s.fingerprint=this.Sa(t,e)),this.za(e,t)||J(this.props,t)}}}Ha(e){return Object.keys(this.props).some(t=>{var s;return((s=he(t))===null||s===void 0?void 0:s.storageGroup)===e})}za(e,t){const s=Wc[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.mi||this.oa.has(e))return;const s=this.Yo?(t=he(e))===null||t===void 0?void 0:t.storageGroup:void 0,i=s?B.Dt(this.pa(s)):this.qo.Dt(this.ha);if(i&&e in i)this.Ca(e,i[e],!1);else{if(s){const r=this.qo.Dt(this.ha);if(r&&e in r)return void this.Ca(e,r[e],!1)}this.$a(e,!1)}}save(){if(this.mi)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.mi||this.ea&&!e)return;e||(this.syncCookieProperties(),this.Rr.cookieWinsOnConflict&&this.Rr.persistence.toLowerCase()==="localstorage+cookie"||nl.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.Rr.debug&&E.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.ha,this.props,ae);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.ha,e,ae);s==="written"&&this.Ra(e),s!=="failed"&&(this.sa=!1,this.oa.clear(),ze.forEach(r=>{var n;!((n=he(r))===null||n===void 0)&&n.storageGroup||this.ia.delete(r)}));for(const r of zt){var i;const n=t[r];if($e(n)&&!(!((i=this.Jo[r])===null||i===void 0)&&i.persisted)){ze.forEach(a=>{var l;((l=he(a))===null||l===void 0?void 0:l.storageGroup)===r&&this.ia.delete(a)});continue}const o=this.Wa(B,this.pa(r),n,r);o!=="failed"&&ze.forEach(a=>{const l=he(a);l?.storageGroup!==r||o!=="written"&&l.volatile||this.ia.delete(a)})}}wa(){const e={},t={flags:{},surveys:{}};return G(this.props,(s,i)=>{var r;const n=(r=he(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===ae)return JSON.stringify(e)+"|"+this.Va+"|"+this.Ga+"|"+this.Za;const s={};return G(e,(i,r)=>{var n;s[r]=!((n=he(r))===null||n===void 0)&&n.volatile?"__volatile__":i}),JSON.stringify(s)}Wa(e,t,s,i){const r=this.ya(i);if(i!==ae&&!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.At(t,s,this.Va,this.Ga,this.Za,this.Rr.debug)?(r.dirty=!1,i!==ae&&(r.persisted=!0),x(n)||(r.fingerprint=n),this.Ko&&(r.storageValue=B.Ot(t)),"written"):(this.Rr.debug&&E.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.Lt(this.ha,!1),this.qo.Lt(this.ha,!0),!e&&this.la)for(const t of zt)B.Lt(this.pa(t));e?delete this.Jo[ae]:this.Jo={},this.Aa=void 0,this.Fa=void 0}clear(){this.remove(),this.props={}}register_once(e,t,s){if(N(e)){this.syncCookieProperties(),x(t)&&(t="None"),this.Va=x(s)?this.Qa:s;let i=!1;if(G(e,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Ca(n,r),i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(N(e)){this.syncCookieProperties(),this.Va=x(t)?this.Qa:t;let s=!1;if(G(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||N(i)||M(i))&&(this.Ca(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.$a(i),s=!0);s&&this.save()}update_campaign_params(){const e=$?.URL;if(e===this.ua)return;const t=Ja(this.Rr.custom_campaign_params,this.Rr.mask_personal_data_properties,this.Rr.custom_personal_data_properties),s=!$e(Or(t));return s&&this.register(t),this.ua=e,s?t:void 0}update_search_keyword(){this.register((function(){const e=$?.referrer;return e?Qa(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:tl(),$referring_domain:$?.referrer&&((e=Ge($.referrer))===null||e===void 0?void 0:e.host)||Xs},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=sl(this.Rr.mask_personal_data_properties,this.Rr.custom_personal_data_properties,this.Rr.disable_capture_url_hashes);this.register_once({[St]:this.Xo?{r:$s(e.r),u:e.u?$s(e.u):void 0}:e},void 0)}get_initial_props(){const e={};G([Ra,Pa],s=>{const i=this.props[s];i&&G(i,function(r,n){e["$initial_"+Hi(n)]=r})});const t=this.props[St];if(t){const s=(function(i,r=!1){const n=il(i,r),o={};return G(n,function(a,l){o[`$initial_${Hi(l)}`]=a}),o})(t,this.Rr.disable_capture_url_hashes);J(e,s)}return e}safe_merge(e){return G(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,g)=>{if(p.length!==g.length)return!1;const m=[...p].sort(),_=[...g].sort();return m.every((f,b)=>f===_[b])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),n=i||r,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!s,l=!!this.mi&&!a;a||this.Oa(t,l),this.Rr=e,!a&&(i||r||o)&&(this.Aa=void 0,this.Fa=void 0,this.Oa(v(v({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const u=n||o?this.ca(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.Za)&&this.Da(l);this.na=h;try{if(this.Qa=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[ae],this.qa()))}finally{this.na=!1,d&&this.ja()}}Ja(){const e=this.props[St];if(!this.Xo||!N(e)||typeof e.r!="string")return;const t=$s(e.r),s=typeof e.u=="string"?$s(e.u):e.u;t===e.r&&s===e.u||this.Ca(St,v(v({},e),{},{r:t,u:s}))}set_disabled(e){this.mi=e,this.mi?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.Za&&(this.Za=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const s=this.props.__timers||{};s[e]=t,this.Ca(Ji,s),this.save()}remove_event_timer(e){const t=this.props.__timers||{},s=t[e];return x(s)||(delete t[e],this.Ca(Ji,t),this.save()),s}get_property(e){return this.props[e]}set_property(e,t){this.Ca(e,t),this.save()}Ca(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),Cn(e)&&!Je(r,t)&&this.oa.add(e),this.Ea(e,r,t),!((i=he(e))===null||i===void 0)&&i.volatile||this.Ia(e))}$a(e,t=!0){delete this.props[e],t&&($i(e)&&this.ma(e,!0),Cn(e)&&this.oa.add(e),this.Ia(e))}Ia(e){var t;const s=(t=he(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 Ee={GZipJS:"gzip-js",Base64:"base64"},Ht={Activation:"events",Cancellation:"cancelEvents"},Ei={Popover:"popover",API:"api",Widget:"widget"},We={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Si={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},dr={Popover:"popover",Inline:"inline"};function ks(e){let t=!0;return{dispose(){if(t){t=!1;const s=e();s&&ue(s.then)&&s.then(void 0,()=>{})}}}}const Gc={SHOWN:"product tour shown"},Tn={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},An=ie("[RateLimiter]");var Xc=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=>{An.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void An.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+=(o-a.last)/1e3*n,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!M(t)||!t.includes(e)}Ya(){var e;if(this.Xa("$current_url")&&this.Xa("$pathname")&&ee?.pathname)return`${(e=ee.origin)!==null&&e!==void 0?e:""}${ee.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=ie("[RemoteConfig]");var ol=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=O._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=O.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(s=O.__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)}}},Re=Uint8Array,ke=Uint16Array,Lt=Uint32Array,Lr=new Re([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]),Dr=new Re([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]),Ln=new Re([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),al=function(e,t){for(var s=new ke(31),i=0;31>i;++i)s[i]=t+=1<<e[i-1];var r=new Lt(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]},ll=al(Lr,2),hr=ll[1];ll[0][28]=258,hr[258]=28;for(var Dn=al(Dr,0)[1],ul=new ke(32768),se=0;32768>se;++se){var wt=(43690&se)>>>1|(21845&se)<<1;ul[se]=((65280&(wt=(61680&(wt=(52428&wt)>>>2|(13107&wt)<<2))>>>4|(3855&wt)<<4))>>>8|(255&wt)<<8)>>>1}var rs=function(e,t,s){for(var i=e.length,r=0,n=new ke(t);i>r;++r)++n[e[r]-1];var o,a=new ke(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;for(o=new ke(i),r=0;i>r;++r)o[r]=ul[a[e[r]-1]++]>>>15-e[r];return o},gt=new Re(288);for(se=0;144>se;++se)gt[se]=8;for(se=144;256>se;++se)gt[se]=9;for(se=256;280>se;++se)gt[se]=7;for(se=280;288>se;++se)gt[se]=8;var Ys=new Re(32);for(se=0;32>se;++se)Ys[se]=5;var Yc=rs(gt,9),Kc=rs(Ys,5),cl=function(e){return(e/8|0)+(7&e&&1)},dl=function(e,t,s){(s==null||s>e.length)&&(s=e.length);var i=new(e instanceof ke?ke:e instanceof Lt?Lt:Re)(s-t);return i.set(e.subarray(t,s)),i},je=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8},Vt=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8,e[i+2]|=s>>>16},Pi=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 Re(0),0];if(r==1){var o=new Re(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function(k,R){return k.f-R.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 ke(d+1),g=pr(s[c-1],p,0);if(g>t){i=0;var m=0,_=g-t,f=1<<_;for(n.sort(function(k,R){return p[R.s]-p[k.s]||k.f-R.f});r>i;++i){var b=n[i].s;if(t>=p[b])break;m+=f-(1<<g-p[b]),p[b]=t}for(m>>>=_;m>0;){var w=n[i].s;t>p[w]?m-=1<<t-p[w]++-1:++i}for(;i>=0&&m;--i){var P=n[i].s;p[P]==t&&(--p[P],++m)}g=t}return[new Re(p),g]},pr=function(e,t,s){return e.s==-1?Math.max(pr(e.l,t,s+1),pr(e.r,t,s+1)):t[e.s]=s},Nn=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new ke(++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]},Wt=function(e,t){for(var s=0,i=0;t.length>i;++i)s+=e[i]*t[i];return s},vr=function(e,t,s){var i=s.length,r=cl(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)},jn=function(e,t,s,i,r,n,o,a,l,u,c){je(t,c++,s),++r[256];for(var h=Pi(r,15),d=h[0],p=h[1],g=Pi(n,15),m=g[0],_=g[1],f=Nn(d),b=f[0],w=f[1],P=Nn(m),k=P[0],R=P[1],I=new ke(19),S=0;b.length>S;++S)I[31&b[S]]++;for(S=0;k.length>S;++S)I[31&k[S]]++;for(var F=Pi(I,7),j=F[0],z=F[1],H=19;H>4&&!j[Ln[H-1]];--H);var X,C,q,L,K=u+5<<3,V=Wt(r,gt)+Wt(n,Ys)+o,re=Wt(r,d)+Wt(n,m)+o+14+3*H+Wt(I,j)+(2*I[16]+3*I[17]+7*I[18]);if(V>=K&&re>=K)return vr(t,c,e.subarray(l,l+u));if(je(t,c,1+(V>re)),c+=2,V>re){X=rs(d,p),C=d,q=rs(m,_),L=m;var de=rs(j,z);for(je(t,c,w-257),je(t,c+5,R-1),je(t,c+10,H-4),c+=14,S=0;H>S;++S)je(t,c+3*S,j[Ln[S]]);c+=3*H;for(var oe=[b,k],Se=0;2>Se;++Se){var ge=oe[Se];for(S=0;ge.length>S;++S)je(t,c,de[pe=31&ge[S]]),c+=j[pe],pe>15&&(je(t,c,ge[S]>>>5&127),c+=ge[S]>>>12)}}else X=Yc,C=gt,q=Kc,L=Ys;for(S=0;a>S;++S)if(i[S]>255){var pe;Vt(t,c,X[257+(pe=i[S]>>>18&31)]),c+=C[pe+257],pe>7&&(je(t,c,i[S]>>>23&31),c+=Lr[pe]);var _e=31&i[S];Vt(t,c,q[_e]),c+=L[_e],_e>3&&(Vt(t,c,i[S]>>>5&8191),c+=Dr[_e])}else Vt(t,c,X[i[S]]),c+=C[i[S]];return Vt(t,c,X[256]),c+C[256]},Jc=new Lt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Zc=(function(){for(var e=new Lt(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 Qc(e,t){t===void 0&&(t={});var s=(function(){var h=4294967295;return{p(d){for(var p=h,g=0;d.length>g;++g)p=Zc[255&p^d[g]]^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,g,m,_){var f=h.length,b=new Re(g+f+5*(1+Math.floor(f/7e3))+m),w=b.subarray(g,b.length-m),P=0;if(!d||8>f)for(var k=0;f>=k;k+=65535){var R=k+65535;f>R?P=vr(w,P,h.subarray(k,R)):(w[k]=_,P=vr(w,P,h.subarray(k,f)))}else{for(var I=Jc[d-1],S=I>>>13,F=8191&I,j=(1<<p)-1,z=new ke(32768),H=new ke(j+1),X=Math.ceil(p/3),C=2*X,q=function(ni){return(h[ni]^h[ni+1]<<X^h[ni+2]<<C)&j},L=new Lt(25e3),K=new ke(288),V=new ke(32),re=0,de=0,oe=(k=0,0),Se=0,ge=0;f>k;++k){var pe=q(k),_e=32767&k,Xe=H[pe];if(z[_e]=Xe,H[pe]=_e,k>=Se){var _t=f-k;if((re>7e3||oe>24576)&&_t>423){P=jn(h,w,0,L,K,V,de,oe,ge,k-ge,P),oe=re=de=0,ge=k;for(var xe=0;286>xe;++xe)K[xe]=0;for(xe=0;30>xe;++xe)V[xe]=0}var Me=2,ot=0,Al=F,Ye=_e-Xe&32767;if(_t>2&&pe==q(k-Ye))for(var Ll=Math.min(S,_t)-1,Dl=Math.min(32767,k),Nl=Math.min(258,_t);Dl>=Ye&&--Al&&_e!=Xe;){if(h[k+Me]==h[k+Me-Ye]){for(var Ke=0;Nl>Ke&&h[k+Ke]==h[k+Ke-Ye];++Ke);if(Ke>Me){if(Me=Ke,ot=Ye,Ke>Ll)break;var jl=Math.min(Ye,Ke-2),jr=0;for(xe=0;jl>xe;++xe){var ri=k-Ye+xe+32768&32767,qr=ri-z[ri]+32768&32767;qr>jr&&(jr=qr,Xe=ri)}}}Ye+=(_e=Xe)-(Xe=z[_e])+32768&32767}if(ot){L[oe++]=268435456|hr[Me]<<18|Dn[ot];var Br=31&hr[Me],zr=31&Dn[ot];de+=Lr[Br]+Dr[zr],++K[257+Br],++V[zr],Se=k+Me,++re}else L[oe++]=h[k],++K[h[k]]}}P=jn(h,w,_,L,K,V,de,oe,ge,k-ge,P)}return dl(b,0,g+cl(P)+m)})(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 g=0;p.length>=g;++g)h[g+10]=p.charCodeAt(g)}})(u,t),Ri(u,c-8,s.d()),Ri(u,c-4,i),u}const ed=!!yr||!!ls,hl=new WeakMap,pl="text/plain";let Fi=0,Ms=!1;const vl=(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}`:""}`},ms=(e,t,s=!0)=>{var i;const[r,n]=e.split("?"),o=v({},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 G(u,function(g,m){x(g)||x(m)||m==="undefined"||(h=encodeURIComponent((_=>_ instanceof File)(g)?g.name:g.toString()),d=encodeURIComponent(m),p[p.length]=d+"="+h)}),p.join(c)})(o);return l&&a.push(l),a.length>0?`${r}?${a.join("&")}`:r},Ii=e=>{if(e.sl)return e.sl;const{data:t,compression:s}=e;if(!t)return;if(s===Ee.GZipJS){const r=Qc((function(n){var o=n.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(n);for(var a=new Re(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 Re(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 dl(a,0,l)})(Rt(t)),{mtime:0});return{contentType:pl,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(s===Ee.Base64){const r=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Rt(t)),n=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Rt(o)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}const i=Rt(t);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},fl=e=>{const t=()=>e.transport==="sendBeacon"?{url:ms(e.url,{compression:Ee.Base64}),encodedBody:Ii(v(v({},e),{},{compression:Ee.Base64,sl:void 0}))}:{url:vl(e.url,"compression"),encodedBody:Ii(v(v({},e),{},{compression:void 0,sl:void 0}))};let s;try{s=Ii(e)}catch(r){if(nn(e.compression,Tt(e.url,"compression")))return E.error("Failed to gzip request body, sending uncompressed payload",r),t();throw r}return s&&nn(e.compression,Tt(e.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?Yi(new Uint8Array(i)):ArrayBuffer.isView(i)&&Yi(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Ms=!0,t()):{url:e.url,encodedBody:s};var i},gl=e=>{try{return fl(e)}catch(s){var t;return E.error(s),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:s}))}},td=(function(){var e=Z(function*(t){const s=yield(function(r){return Ki.apply(this,arguments)})(Rt(t.data),le.DEBUG,{rethrow:!0});if(!s)return t;const i=yield s.arrayBuffer();return v(v({},t),{},{sl:{contentType:pl,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}})(),sd=/Failed to fetch|NetworkError|Load failed/i,_l=e=>e?.name==="TypeError"&&sd.test(e?.message||""),ml=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,Is):void 0})(e());return x(t)?void 0:Math.min(t,3e4)}catch{return}},yl=e=>{const t=gl(e);if(!t)return;const s=new yr;hl.set(s,!0);const{url:i,encodedBody:r}=t;s.open(e.method||"GET",i,!0);const{contentType:n,body:o}=r??{};G(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,ml(()=>s.getResponseHeader("Retry-After")))}},s.send(o)},bl=e=>{const t=gl(e);if(!t)return;const{url:s,encodedBody:i}=t,{contentType:r,body:n,estimatedSize:o}=i??{},a=new Headers;G(e.headers,function(g,m){a.append(m,g)}),r&&a.append("Content-Type",r);let l=null,u=!1;if(Hr){const g=new Hr;l={signal:g.signal,timeout:setTimeout(()=>{u=!0;try{g.abort(Qo("AbortError","PostHog request timed out"+((m=e.timeout)?` after ${m}ms`:"")))}catch(_){h(_)}var m},e.timeout)}}let c=!1;const h=g=>{var m;c||(c=!0,u&&g?.name==="AbortError"||_l(g)?E.warn(g):E.error(g),(m=e.callback)===null||m===void 0||m.call(e,{statusCode:0,error:g}))};let d=0;const p=()=>{Fi-=d,d=0,l&&clearTimeout(l.timeout)};try{const g=v({method:e?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:n,signal:l?.signal},e.fetchOptions),m=o??(x(n)?0:void 0);g.keepalive=g.method==="POST"&&!e.rl&&g.keepalive!==!1&&g.body===n&&!x(m)&&m>=0&&52428.8>Fi+m,g.keepalive&&(d=m,Fi+=d),ls(s,g).then(_=>_.text().then(f=>{var b;if(c)return;const w={statusCode:_.status,text:f};if(_.status===200)try{w.json=JSON.parse(f)}catch(P){E.error(P)}c=!0,p(),(b=e.callback)===null||b===void 0||b.call(e,w,ml(()=>_.headers.get("Retry-After")))})).catch(_=>{p(),h(_)}).finally(p)}catch(g){p(),h(g)}},fr=e=>{try{var t;const{url:s,encodedBody:i}=fl(e),{contentType:r,body:n,estimatedSize:o}=i??{};if(!n)return;const a=n instanceof Blob?n:new Blob([n],{type:r});if(ce.sendBeacon(s,a))return;const l=M(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(M(l)&&l.length>1&&(o??0)>16384){const u=Math.ceil(l.length/2),c=h=>M(e.data)?h:v(v({},e.data),{},{batch:h});return fr(v(v({},e),{},{data:c(l.slice(0,u))})),void fr(v(v({},e),{},{data:c(l.slice(u))}))}E.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${ls?"fetch":"XHR"}`),ls?bl(v(v({},e),{},{rl:!0})):yl(e)}catch(s){E.warn("Beacon send failed",s)}},qn=(e,t,s,i)=>{const r=i==="query"?t==="POST"?"sent_at":"_":void 0;return ms(s===Ee.GZipJS?vl(e,"compression"):e,v(v({},r?{[r]:Date.now().toString()}:{}),s===Ee.GZipJS?{}:{compression:s}))},id=(()=>{const e=[];return ls&&e.push({transport:"fetch",method:bl}),yr&&e.push({transport:"XHR",method:yl}),ce?.sendBeacon&&e.push({transport:"sendBeacon",method:fr}),e})();let wl=!ed&&ye?.indexOf("MSIE")===-1&&ye?.indexOf("Mozilla")===-1;function xl(e,t,s){var i,r,n;s&&(t=v(v({},t),{},{callback:o=>s(o)})),e.__loaded?wl?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=v(v({},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=v(v({},o),{},{callback:a??(_=>{var f;return(f=o.callback)===null||f===void 0?void 0:f.call(o,_)})});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=Ee.Base64),h.method==="POST"&&h.data&&(h.timestampMode==="capture-body"?h.data=(_=>{var f,b;const w=(M(_)?_:[_]).map(k=>v(v({},k),k.timestamp instanceof Date&&!isNaN(k.timestamp.getTime())?{timestamp:k.timestamp.toISOString()}:{})),P=w[0];return{api_key:(f=P==null||(b=P.properties)===null||b===void 0?void 0:b.token)!==null&&f!==void 0?f:P?.token,batch:w,sent_at:new Date().toISOString()}})(h.data):h.timestampMode==="body"&&(h.data=((_,f=new Date().toISOString())=>M(_)?_.map(b=>v(v({},b),{},{sent_at:f})):v(v({},_),{},{sent_at:f}))(h.data))),h.url=qn(h.url,h.method,h.compression,h.timestampMode);const p=id.filter(_=>!h.disableTransport||!_.transport||!h.disableTransport.includes(_.transport)),g=(u=(c=(function(_,f){for(let b=0;_.length>b;b++)if(f(_[b]))return _[b]})(p,_=>_.transport===d))===null||c===void 0?void 0:c.method)!==null&&u!==void 0?u:p[0].method;if(!g)throw new Error("No available transport method");const m=_=>{try{g(_)}catch(b){var f;_l(b)?E.warn(b):E.error(b),(f=h.callback)===null||f===void 0||f.call(h,{statusCode:0,error:b})}};d!=="sendBeacon"&&!h.preferSyncCompression&&h.data&&h.compression===Ee.GZipJS&&ql&&typeof Promise<"u"&&!Ms?td(h).then(_=>{m(_)}).catch(_=>{if(on(_))return Ms=!0,void m(v(v({},h),{},{compression:void 0,url:qn(o.url,o.method,void 0,o.timestampMode)}));(f=>{if(!f||typeof f!="object")return!1;const b="name"in f?String(f.name):"";return on(f)||b===oa})(_)&&(Ms=!0),m(h)}):m(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 rd=class{constructor(e,t){this.ol=!0,this.al=[],this.ll=De(t?.flush_interval_ms||3e3,250,5e3,E.createLogger("flush interval"),3e3),this.ul=e}enqueue(e){this.al.push(e),this.hl||this.cl()}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(s,"sendBeacon")})}enable(){this.ol=!1,this.cl()}cl(){this.ol||(this.hl=setTimeout(()=>{if(this.dl(),this.al.length>0){const e=this.vl();for(const t in e)this.fl(e[t])}},this.ll))}fl(e,t){try{this.ul(e,t)}catch(s){E.error(s)}}dl(){clearTimeout(this.hl),this.hl=void 0}vl(){const e={};return G(this.al,t=>{var s;const i=t,r=((i?i.batchKey:null)||i.url)+(i.batchGroup?`:${i.batchGroup}`:"");x(e[r])&&(e[r]=v(v({},i),{},{data:[]})),(s=e[r].data)===null||s===void 0||s.push(i.data)}),this.al=[],e}};const nd=["retriesPerformedSoFar"];var od=class{constructor(e){this._instance=e,this.pl=!1,this.gl=3e3,this.al=[],this.al=[],this.ml=!0,this.resume()}resume(){if(!x(y)&&"onLine"in y.navigator){if(this.ml=y.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.bl()},this._l=()=>{this.ml=!1},W(y,"online",this.yl),W(y,"offline",this._l)}}get length(){return this.al.length}retriableRequest(e,t){let{retriesPerformedSoFar:s}=e,i=aa(e,nd);Be(s)&&(i.url=ms(i.url,{retry_count:s})),xl(this._instance,t?v(v({},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(v({retriesPerformedSoFar:s},i),n);r.statusCode===0&&E.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)"),E.warn(n),this.pl||(this.pl=!0,this.wl())}wl(){if(this.kl&&clearTimeout(this.kl),this.al.length===0)return this.pl=!1,void(this.kl=void 0);this.kl=setTimeout(()=>{this.ml&&this.al.length>0&&this.bl(),this.wl()},this.gl)}bl(){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.pl=!1,x(y)||(this.yl&&(y.removeEventListener("online",this.yl),this.yl=void 0),this._l&&(y.removeEventListener("offline",this._l),this._l=void 0));for(const{requestOptions:e}of this.al)try{this._instance._send_request(v(v({},e),{},{transport:"sendBeacon"}))}catch(t){E.error(t)}this.al=[]}},ad=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 Cl(){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(y,"scroll",this.Sl,{capture:!0}),W(y,"scrollend",this.Sl,{capture:!0}),W(y,"resize",this.Sl)}scrollElement(){if(this.Cl){const s=M(this.Cl)?this.Cl:[this.Cl];for(const i of s){var e;const r=y==null||(e=y.document)===null||e===void 0?void 0:e.querySelector(i);if(r)return r}return}var t;return y==null||(t=y.document)===null||t===void 0?void 0:t.documentElement}$l(e){var t,s;const i=e==="y"?"scrollTop":"scrollLeft";if(this.Cl){const r=this.scrollElement();return r&&r[i]||0}return y?e==="y"?y.scrollY||y.pageYOffset||((t=y.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:y.scrollX||y.pageXOffset||((s=y.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}};const ld=e=>sl(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes);var Bn=class{constructor(e,t,s,i){this.Be=r=>{const n=this.Tl();if(n&&n.sessionId===r)return;const o={sessionId:r,props:this.Il(this._instance)};this.Ml.register({[nr]:o})},this._instance=e,this.El=t,this.Ml=s,this.Il=i||ld,this.El.onSessionId(this.Be)}Tl(){return this.Ml.props[nr]}getSetOnceProps(){var e;const t=(e=this.Tl())===null||e===void 0?void 0:e.props;return t?"r"in t?il(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 G(Or(this.getSetOnceProps()),(t,s)=>{s==="$current_url"&&(s="url"),e[`$session_entry_${Hi(s)}`]=t}),e}},Ks=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 xt=ie("[SessionId]"),zn=864e5;var Hn=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 Ks,this.Nl=(n,o)=>!(!Be(n)||!Be(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.Rr=e.config,this.Ml=e.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.ql=void 0,this._sessionActivityTimestamp=null,this.jl=t||Ce,this.Bl=s||Ce;const r=this.Rr.persistence_name||this.Rr.token;if(this._sessionTimeoutMs=1e3*De(this.Rr.session_idle_timeout_seconds||1800,60,36e3,xt.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Hl(),this.zl="ph_"+r+"_window_id",this.Ul="ph_"+r+"_primary_window_exists",this.Wl()){const n=Y.Dt(this.zl),o=Y.Dt(this.Ul);n&&!o?this.He=n:Y.Lt(this.zl),Y.At(this.Ul,!0)}!((i=this.Rr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Rr.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.He),()=>{this.Ol=this.Ol.filter(t=>t!==e)}}Wl(){return this.Rr.persistence!=="memory"&&!this.Ml.mi&&Y.Et()}Gl(e){e!==this.He&&(this.He=e,this.Wl()&&Y.At(this.zl,e))}Zl(){return this.He?this.He:this.Wl()?Y.Dt(this.zl):null}Ql(e){const t=this.Al;return!te(t)&&!te(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.Ql(t)||(this.Al=t,this.Ml.register({[Et]:[t,e,s]}))}Kl(){var e;const t=(e=this.Rr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return Be(t)&&t>0}Xl(){this.Kl()?this.Ml.refreshKey(Et):(this.Ml.flush(),this.Ml.load())}Yl(){var e;if(te(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({[Et]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Ml.flush())}eu(){const[e]=this.tu(),t=Be(e)?e:0,s=Be(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[Et];return M(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 xt.error("Bootstrap sessionID cannot be in the future"):n}catch(n){return void xt.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&&y&&(y.removeEventListener(Ws,this.Dl,{capture:!1}),this.Dl=void 0),this.Ol=[]}Vl(){this.Dl=()=>{this.Yl(),this.Wl()&&Y.Lt(this.Ul)},W(y,Ws,this.Dl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,s=!1){if(this.Rr.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(te(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.Zl();const d=this.ql,p=!!d&&(d.sessionStartTimestamp>i+6e4||i-d.sessionStartTimestamp>zn),g=d?p:Be(l)&&Math.abs(i-l)>zn;let m=!1,_=u,f=!a||!!d;const b=a;let w=!f&&!e&&this.Nl(i,c);if(w&&(w=this.iu(i),w||xt.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.tu(),w||(f=!a||!!d)),f||w||g){_=!1;const I=d&&!p;a=I?d.sessionId:this.jl(),h=this.Bl(),xt.info("new session ID assigned",{sessionId:a,windowId:h,bootstrapped:!!I,changeReason:{noSessionId:f,activityTimeout:w,sessionPastMaximumLength:g}}),l=I?d.sessionStartTimestamp:i,this.ql=void 0,m=!0}else h||(h=this.Bl(),m=!0),_=_||a!==b,_&&(xt.info("adopted cross-tab session id",{sessionId:a,windowId:h}),m=!0);const P=Be(c)&&e&&!g?c:i,k=Be(l)?l:new Date().getTime();this.Gl(h),this.Jl(a,P,k),e||this.Hl();const R={noSessionId:f,activityTimeout:w,sessionPastMaximumLength:g,crossTabAdoption:_};return m&&this.Ol.forEach(I=>I(a,h,R)),{sessionId:a,windowId:h,sessionStartTimestamp:k,changeReason:m?R:void 0,lastActivityTimestamp:c}}Hl(){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.Hl()},1.1*this.sessionTimeoutMs))}};const $l=function(e,t){if(!e)return!1;const s=e.userAgent;if(s&&Wr(s,t))return!0;try{const i=e?.userAgentData;if(i?.brands&&i.brands.some(r=>Wr(r?.brand,t)))return!0}catch{}return!!e.webdriver};function kl(){return(kl=Z(function*(){const e=ce?.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 E.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function ud(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 El(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 Js=(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}},Es=e=>e.toLowerCase(),Sl={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=>Js(s,i))),not_regex:(e,t)=>t.every(s=>e.every(i=>!Js(s,i))),icontains:(e,t)=>t.map(Es).some(s=>e.map(Es).some(i=>s.includes(i))),not_icontains:(e,t)=>t.map(Es).every(s=>e.map(Es).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 Pl(e,t){return!e||Object.entries(e).every(([s,i])=>{const r=t?.[s];if(r==null)return!1;const n=Sl[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}function Oi(e,t,s){return Rt({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:s})}const gr="custom",Vn="i.posthog.com",cd=/^\/static\//,dd=["/s/","/e/","/i/"];var hd=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(`.${Vn}`,".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":gr),this.su[this.apiHost]}ru(e){if(!cd.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}ou(e){const t=Ge(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=Ge(s))===null||n===void 0?void 0:n.href)||s;i=r(new URL(o)).toString()}if(r&&e==="api"&&dd.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===gr)return this.au(e,t,this.apiHost+t);const s=Vn+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 U=ie("[Surveys]"),Rl=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){U.error("Failed to persist survey seen state",t)}},pd=[Ei.Popover,Ei.Widget,Ei.API],vd={ignoreConditions:!1,ignoreDelay:!1,displayType:dr.Popover},fd=ie("[PostHog ExternalIntegrations]"),gd={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var _d=class{constructor(e){this._instance=e}zo(e,t){var s,i;(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,e,r=>{if(r)return fd.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=O.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[r])&&this.zo(gd[r],()=>{var o;(o=O.__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=O.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[r])&&((i=O.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[r])===null||i===void 0||i.stop())}}},md=class{constructor(e,t){this.$=e,this.wo=t,this.uu=new Map,this.Io=!1}add(e){var t=this;return Z(function*(){if(t.Io)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.uu.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);t.uu.set(e.name,e);try{const s=e.setup(t.wo);s&&(yield s)}catch(s){const i=t.uu.get(e.name)===e;i&&t.uu.delete(e.name),t.$.error(`Failed to set up browser extension "${e.name}"`,s),i&&t.hu(e)}})()}getExtension(e){return this.uu.get(e)}dispose(){if(this.Io)return;this.Io=!0;const e=Array.from(this.uu.values()).reverse();this.uu.clear();for(const t of e)this.hu(t)}hu(e){try{var t;const s=(t=e.dispose)===null||t===void 0?void 0:t.call(e);s&&ue(s.then)&&s.then(void 0,i=>{this.$.error(`Failed to dispose browser extension "${e.name}"`,i)})}catch(s){this.$.error(`Failed to dispose browser extension "${e.name}"`,s)}}},yd=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)}};const Wn="extensionsRemoteConfig";var bd=class{constructor(e){this.instance=e,this.Io=!1,this.$=E,this.cu=e.du,this.kv=new yd(e),this.onEvent=t=>ks(this.instance.on("eventCaptured",s=>{try{t({event:s.event,properties:s.properties})}catch(i){this.$.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=t=>{if(this.Io)return ks(()=>{});const s=r=>{try{t(r)}catch(n){this.$.error("Browser extension remote config listener failed",n)}},i=this.instance.vu.on(Wn,s);return this.cu&&s(this.cu),ks(i)},this.fu=new md(E.createLogger("[BrowserExtensions]"),this)}get logger(){return this.$}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(Er);return typeof e=="string"?e:void 0}get library(){return{name:le.LIB_NAME,version:le.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;const r=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=r?.sessionId)!==null&&t!==void 0?t:"",windowId:(s=r?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.fu.add(e)}getExtension(e){return this.fu.getExtension(e)}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 ks(this.instance.pu(e))}handleRemoteConfig(e){this.Io||(this.cu=e,this.instance.vu.emit(Wn,e))}sendRequest(e){var t=this;return Z(function*(s,i={}){var r;const n=t.instance.requestRouter.endpointFor((r=i.target)!==null&&r!==void 0?r:"api",s),o={method:i.method,url:i.query?ms(n,i.query):n,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"?zi.Base64:void 0,timestampMode:i.sentAt};return i.transport==="sendBeacon"?(t.instance._send_request(o),{statusCode:202}):new Promise(a=>{o.callback=a,t.instance._send_request(o)})}).apply(this,arguments)}dispose(){this.Io||(this.Io=!0,this.fu.dispose())}};const ns={};let Ci=0;const os=()=>{},Un='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ut="Surveys module not available",Gn="sanitize_properties is deprecated. Use before_send instead",Fl="Invalid value for property_denylist config: ",wd=/^[A-Za-z0-9_-]{1,400}$/,Xn=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Yn=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,xd=["token","distinct_id",Fa],Yt="posthog",$d=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},Mi=e=>{var t;return v({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:xc($?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:os,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_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:ee&&D(ee?.search)&&ee.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:(y==null||(t=y.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){E.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:Ta,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:os},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:Ic,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:$d(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))},kd=[["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"]],Kn=e=>{const t={};for(const[r,n]of kd)x(e[r])||(t[n]=e[r]);const s=J({},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)),M(e.property_blacklist)&&(x(e.property_denylist)?s.property_denylist=e.property_blacklist:M(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:E.error(Fl+e.property_denylist)),s};var Ed=class{constructor(){this.__forceAllowLocalhost=!1}get gu(){return this.__forceAllowLocalhost}set gu(e){E.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},as=class Qe{mu(t){if(!t)return;const s=this.uu.indexOf(t);s!==-1&&this.uu.splice(s,1)}yu(t,s){var i;return this.mu(t),this.uu.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}bu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}_u(){if(this.wu||this.config.reuseAnonymousId||this.config.segment||this.bu())return;const t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this.ku)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.wu=!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}`)}Su(){if(this.bu()||this.get_distinct_id()!=="$posthog_cookieless")return;const t=this.persistence;if(!t)return;this.xu()||t.load(!0);const s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){const i=this.config.get_device_id(Ce());this.register({distinct_id:i,$device_id:i}),t.set_property(be,Ve)}this.Cu()}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.Tu=!1,this.webPerformance=new Ed,this.Iu=!1,this.version=le.LIB_VERSION,this.Mu=new Set,this.Eu="",this.vu=new Ks,this.uu=[],this.Pu=[],this.ku=!1,this.wu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Mi(),this.SentryIntegration=Nc,this.sentryIntegration=i=>(function(r,n){const o=Xa(r,n);return{name:Ga,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 ad(this),this.pageViewManager=new On(this),this.rateLimiter=new Xc(this),this.requestRouter=new hd(this),this.consent=new Fc(this),this.externalIntegrations=new _d(this);const s=(t=Qe.__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=>E.info(`send "${i?.event}"`,i))}init(t,s,i){if(i&&i!==Yt){var r;const n=(r=ns[i])!==null&&r!==void 0?r:new Qe;return n._init(t,s,i),ns[i]=n,ns[Yt][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 E.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=Mi(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=Mi(s.defaults),c=Kn(s),h=J({},u,c,{name:i,token:a});N(u.rageclick)&&N(c.rageclick)&&(h.rageclick=J({},u.rageclick,c.rageclick)),N(u.session_recording)&&N(c.session_recording)&&(h.session_recording=J({},u.session_recording,c.session_recording)),this.set_config(h),this.config.on_xhr_error&&E.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Ee.GZipJS;const d=this.xu();if(this.persistence=new ki(this.config,d),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new ki(v(v({},this.config),{},{persistence:"sessionStorage"}),d,!1),this.Eu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&Y.Et()){const f=Y.Dt(this.Eu);M(f)&&f.forEach(b=>{D(b)&&this.Mu.add(b)})}else Y.Lt(this.Eu);const p=v({},this.persistence.props),g=v({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.qu=new rd((f,b)=>this.ju(f,b),this.config.request_queue_config),this.Bu=new od(this),this.__request_queue=[];const m=this.bu();m||(this.sessionManager=new Hn(this),this.sessionPropsManager=new Bn(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((f,b,w)=>{(w?.activityTimeout||w?.sessionPastMaximumLength||w?.crossTabAdoption)&&this.Hu()})),this.zu(),this.config.__preview_deferred_init_extensions?(E.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Uu(m)},0)):(E.info("Initializing extensions synchronously"),this.Uu(m)),le.DEBUG=le.DEBUG||this.config.debug,le.DEBUG&&E.info("Starting in debug mode",{this:this,config:s,thisC:v({},this.config),p,s:g}),this.config.identity_distinct_id&&!(!((r=s.bootstrap)===null||r===void 0)&&r.distinctID)&&(s.bootstrap=v(v({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const _=(n=s.bootstrap)===null||n===void 0?void 0:n.distinctID;if(this.ku=!!_&&!Kt(_),(o=s.bootstrap)===null||o===void 0?void 0:o.distinctID){const f=s.bootstrap.distinctID,b=this.get_distinct_id(),w=this.persistence.get_property(be);if(s.bootstrap.isIdentifiedID&&b!=null&&b!==f&&w==="anonymous")this.identify(f);else if(s.bootstrap.isIdentifiedID&&b!=null&&b!==f&&w==="identified")E.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 P=this.config.get_device_id(Ce()),k=s.bootstrap.isIdentifiedID?P:f;this.persistence.set_property(be,s.bootstrap.isIdentifiedID?Os:Ve),this.register({distinct_id:f,$device_id:k})}}if(m)this.register_once({distinct_id:gi,$device_id:null},"");else if(!this.get_distinct_id()){const f=this.config.get_device_id(Ce());this.register_once({distinct_id:f,$device_id:f},""),this.persistence.set_property(be,Ve)}return W(y,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),W(y,"pageshow",()=>{var f;this.$u=!1,this.Tu||(f=this.Bu)===null||f===void 0||f.resume()}),s.segment?In(this,()=>this.Wu()):this.Wu(),ue(this.config._onCapture)&&this.config._onCapture!==os&&(E.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",f=>this.config._onCapture(f.event,f))),this.config.ip&&E.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 kl.apply(this,arguments)})().then(f=>{f&&this.register({[fi]:f})}).catch(os),this}Vu(t){const s=t;return D(s.name)&&ue(s.setup)}Gu(t,s){this.Vu(t)?s.push(()=>{this.Zu().add(t).catch(()=>{var i;return(i=t.dispose)===null||i===void 0?void 0:i.call(t)}).catch(i=>{E.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.uu.push(t)}zu(){var t,s,i;const r=(t=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&t!==void 0?t:(i=Qe.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var n,o,a;r&&(this.featureFlags&&this.featureFlags instanceof r||((n=this.Qu)===null||n===void 0||n.call(this),this.Qu=void 0,this.featureFlags=new r(this)),ue(this.featureFlags.onReloading)&&ue(this.featureFlags.setup)?this.Qu||(this.Qu=this.featureFlags.onReloading(()=>{this.vu.emit("featureFlagsReloading",!0)}),this.Zu().add(this.featureFlags)):(o=(a=this.featureFlags).initialize)===null||o===void 0||o.call(a))}Uu(t){const s=performance.now(),i=v(v({},Qe.__defaultExtensionClasses),this.config.__extensionClasses),r=[];var n,o,a,l,u,c,h;i.exceptions&&this.uu.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new i.exceptions(this)),i.historyAutocapture&&this.uu.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.uu.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.uu.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!t&&this.uu.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.Gu(this.autocapture=new i.autocapture(this),r),i.surveys&&this.Gu(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),r),i.logs&&this.Gu(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),r),i.metrics&&this.uu.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.uu.push(this.conversations=(u=this.conversations)!==null&&u!==void 0?u:new i.conversations(this)),i.productTours&&this.uu.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.uu.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.uu.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.uu.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.uu.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,Dc)),i.toolbar&&this.uu.push(this.toolbar=(c=this.toolbar)!==null&&c!==void 0?c:new i.toolbar(this)),i.experiments&&this.uu.push(this.experiments=(h=this.experiments)!==null&&h!==void 0?h:new i.experiments(this)),this.uu.forEach(d=>{d.initialize&&r.push(()=>{var p;(p=d.initialize)===null||p===void 0||p.call(d)})}),r.push(()=>{if(this.Ju){const d=this.Ju;this.Ju=void 0,this.uu.forEach(p=>{var g;return(g=p.onRemoteConfig)===null||g===void 0?void 0:g.call(p,d)})}}),this.Ku(r,s)}Ku(t,s){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&t.length>0)return void setTimeout(()=>{this.Ku(t,s)},0);const r=t.shift();if(r)try{r()}catch(n){E.error("Error initializing extension:",n)}}const i=Math.round(performance.now()-s);this.register_for_session({[Ia]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Oa]:i}),this.config.__preview_deferred_init_extensions&&E.info(`PostHog extensions initialized (${i}ms)`)}il(t){var s;if(!$||!$.body)return E.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.il(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ju=t),this.du=t,this.compression=void 0,t.ok){var i;const r=t.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=T(r.supportedCompression,Ee.GZipJS)?Ee.GZipJS:T(r.supportedCompression,Ee.Base64)?Ee.Base64:void 0),!((i=r.analytics)===null||i===void 0)&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.Fu?this.Fu:Ta}),(s=this.Xu)===null||s===void 0||s.handleRemoteConfig(t),this.uu.forEach(r=>{var n;return(n=r.onRemoteConfig)===null||n===void 0?void 0:n.call(r,t)})}Wu(){try{this.config.loaded(this)}catch(t){E.critical("`loaded` function failed",t)}if(this.Yu(),this.config.internal_or_test_user_hostname&&ee?.hostname){const t=ee.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.bu())&&this.th()},1),this.eh=new ol(this),this.eh.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()&&Pt(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.ih()&&this.capture(vn),(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.ih()&&this.capture(vn,null,{transport:"sendBeacon"})}_send_request(t){xl(this,t)}ju(t,s){this.Bu?this.Bu.retriableRequest(t,s):this._send_request(s?v(v({},t),{},{transport:s}):t)}_execute_array(t){Ci++;try{let s;const i=[],r=[],n=[];Pt(t,a=>{if(a)if(s=a[0],M(s))n.push(a);else if(ue(a))try{a.call(this)}catch(l){E.error("Error executing queued PostHog call",a,l)}else M(a)&&s==="alias"?i.push(a):M(a)&&s.indexOf("capture")!==-1&&ue(this[s])?n.push(a):r.push(a)});const o=function(a,l){Pt(a,function(u){try{if(M(u[0])){let c=l;G(u,function(h){c=c[h[0]].apply(c,h.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(c){E.error("Error executing queued PostHog call",u,c)}})};o(i,this),o(r,this),o(n,this)}finally{Ci--}}push(t){if(Ci>0&&M(t)&&D(t[0])){const s=Qe.prototype[t[0]];return void(ue(s)&&s.apply(this,t.slice(1)))}this._execute_array([t])}get nh(){return{property:hn,persistenceKey:It,cookieName:"_fbc",pattern:Xn,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[It]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(It)}}}get sh(){return{property:pn,persistenceKey:Zt,cookieName:"_fbp",pattern:Yn,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[Zt]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Zt)}}}rh(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}:N(i)&&D(i.value)&&t.pattern.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}oh(t,s,i){return s===i?.value?{value:s,pending:!i.delivered}:(t.register(s,!1),{value:s,pending:!0})}ah(t){if(!this.config.save_campaign_params||this.bu())return;const s=ts(t.cookieName);return D(s)&&t.pattern.test(s)?s:void 0}uh(t,s,i,r){if(!this.persistence)return;const n=this.nh;this.persistence.refreshKey(n.persistenceKey);const o=this.rh(n);if(r)return void n.unregister();if(i)return D(s)&&Xn.test(s)?this.oh(n,s,o):void n.unregister();const a=D(t)&&wd.test(t)?t:void 0,l=this.ah(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.oh(n,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.oh(n,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}hh(t,s,i){if(!this.persistence)return;const r=this.sh;this.persistence.refreshKey(r.persistenceKey);const n=this.rh(r);if(i)return void r.unregister();if(s)return D(t)&&Yn.test(t)?this.oh(r,t,n):void r.unregister();const o=this.ah(r);return o?this.oh(r,o,n):n?{value:n.value,pending:!n.delivered}:void 0}dh(t,s){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const i=this.rh(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 E.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(x(t)||!D(t))return void E.error("No event name provided to posthog.capture");this.Su();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 E.critical("This capture call is ignored due to client rate limiting.");let l;s?.$current_url&&!D(s?.$current_url)&&(E.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?.fh||E.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=Yr(i?.uuid,Ce);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 g=N(s?.$set)?s.$set:void 0,m=M(s?.$unset)?s.$unset:[],_=i?.$unset||[],f=C=>{var q;const L=!!i?.$set&&C in i.$set;return{hasProvided:L||!!g&&C in g,provided:L?i==null||(q=i.$set)===null||q===void 0?void 0:q[C]:g?.[C],unset:m.indexOf(C)!==-1||_.indexOf(C)!==-1}},b=f(hn),w=f(pn),P=[{channel:this.nh,hasProvided:b.hasProvided,update:this.uh(l?.fbclid,b.provided,b.hasProvided,b.unset)},{channel:this.sh,hasProvided:w.hasProvided,update:this.hh(w.provided,w.hasProvided,w.unset)}];for(const{channel:C,hasProvided:q,update:L}of P)L&&d.properties.$process_person_profile===!0&&L.pending&&!q&&!p&&(d.$set=v({[C.property]:L.value},d.$set));const k=i?.$unset;k&&(d.$unset=k);const R=p?void 0:this.ph(i?.$set_once,t!==fn,t===Aa);if(R&&(d.$set_once=R),i?._noTruncate||(I=this.config.properties_string_max_length,d=(function(C,q){const L=new Set;return(function K(V,re){if(V!==Object(V))return q?q(V):V;if(L.has(V))return;let de;if(L.add(V),M(V))de=[],Pt(V,oe=>{de.push(K(oe))});else{const oe={};G(Dt(V)?La(V):V,(Se,ge)=>{L.has(Se)||(oe[ge]=K(Se))}),de=oe}return de})(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,q=[])=>{const L={},K=V=>{C[V]!==void 0&&(L[V]=C[V])};return Au.forEach(K),q.forEach(K),L})(d.properties,xd)),t===We.DISMISSED||t===We.SENT){const C=s?.[Si.SURVEY_ID],q=s?.[Si.SURVEY_ITERATION];Rl({id:C,current_iteration:q}),d.$set=v(v({},d.$set),{},{[ud({id:C,current_iteration:q},t===We.SENT?"responded":"dismissed")]:!0})}else t===We.SHOWN&&(d.$set=v(v({},d.$set),{},{[Si.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var I;if(t===Gc.SHOWN){const C=s?.[Tn.TOUR_TYPE];C&&(d.$set=v(v({},d.$set),{},{[`${Tn.TOUR_LAST_SEEN_DATE}/${C}`]:new Date().toISOString()}))}const S=v(v({},d.properties.$set),d.$set);if($e(S)||this.setPersonPropertiesForFlags(S),!A(this.config.before_send)){const C=this.Os(d);if(!C)return;d=C,d.uuid=Yr(d.uuid,Ce)}const F=P.filter(({channel:C,update:q})=>{var L,K,V;const re=(L=(K=d.$set)===null||K===void 0?void 0:K[C.property])!==null&&L!==void 0?L:N((V=d.properties)===null||V===void 0?void 0:V.$set)?d.properties.$set[C.property]:void 0;return q?.pending&&re===q.value});this.vu.emit("eventCaptured",d);const j=(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),z=i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(j),H=v(v(v({method:"POST",url:j,data:d,compression:"best-available",preferSyncCompression:i?.send_instantly,timestampMode:z?"body":"capture-body",batchKey:i?._batchKey},z&&(!((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}:{}),F.length?{fireCallbackOnDrop:!0,callback:C=>{if(C.statusCode>=200&&300>C.statusCode)for(const{channel:q,update:L}of F)this.dh(q,L.value)}}:{});if(!this.config.request_batching||i&&!i?._batchKey||i?.send_instantly||F.length){var X;let C;!H.transport&&!H.callback&&$e((X=this.config.request_headers)!==null&&X!==void 0?X:{})&&this.$u&&(C="sendBeacon"),this.ju(H,C)}else this.qu.enqueue(H);return d}_addCaptureHook(t){return this.on("eventCaptured",s=>t(s.event,s))}getExtension(t){var s;return(s=this.Xu)===null||s===void 0?void 0:s.getExtension(t)}Zu(){var t;return(t=this.Xu)!==null&&t!==void 0?t:this.Xu=new bd(this)}pu(t){this.Pu.push(t);let s=!0;return()=>{if(!s)return;s=!1;const i=this.Pu.indexOf(t);i!==-1&&this.Pu.splice(i,1)}}gh(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.Mu.clear(),this.mh()),(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.persistence.syncCookieProperties(),this.gh();const o=n?void 0:this.persistence.remove_event_timer(t);let a=v({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.bu()&&(a[Fa]=!0),t==="$snapshot"){const b=v(v({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=b.distinct_id,(!D(a.distinct_id)&&!ne(a.distinct_id)||Kt(a.distinct_id))&&E.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=(function(b,w,P,k=!1){var R,I,S,F;if(!ye)return{};const j=b?[...At,...w||[]]:[],[z,H]=Yo(ye),[X,C]=(function(pe){for(let _e=0;Xr.length>_e;_e++){const[Xe,_t,xe]=Xr[_e],Me=pe.match(Xe);if(Me){const ot=xe&&pe.match(xe)||Me;return[_t,ot?.[1]||""]}}return["",""]})(ye),q=(function(){const pe="u">typeof navigator?navigator:void 0;return pe?.brave?{brave:!0}:{}})(),L={};x(P)||(L.detectGoogleSearchApp=P);const K={},V=(R=navigator)===null||R===void 0||(R=R.userAgentData)===null||R===void 0?void 0:R.platform,re=(I=navigator)===null||I===void 0?void 0:I.maxTouchPoints,de=y==null||(S=y.screen)===null||S===void 0?void 0:S.width,oe=y==null||(F=y.screen)===null||F===void 0?void 0:F.height,Se=y?.devicePixelRatio;x(V)||(K.userAgentDataPlatform=V),x(re)||(K.maxTouchPoints=re),x(de)||(K.screenWidth=de),x(oe)||(K.screenHeight=oe),x(Se)||(K.devicePixelRatio=Se);const ge=J(Or({$os:z,$os_version:H,$browser:Xo(ye,navigator.vendor,q,L),$webview_app:X,$webview_app_version:C,$device:Ko(ye),$device_type:iu(ye,K),$timezone:rl(),$timezone_offset:Vc()}),{$current_url:vs(k?nt(ee?.href):ee?.href,j,fs),$host:ee?.host,$pathname:ee?.pathname,$raw_user_agent:ye.length>1e3?ye.substring(0,997)+"...":ye,$browser_version:su(ye,navigator.vendor,q,L),$browser_language:el(),$browser_language_prefix:Hc(),$screen_height:y?.screen.height,$screen_width:y?.screen.width,$viewport_height:y?.innerHeight,$viewport_width:y?.innerWidth,$lib:Ue.LIB_NAME,$lib_version:Ue.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ue.SDK_DIST_CHANNEL&&(ge.$sdk_dist_channel=Ue.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:b,windowId:w}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0);a.$session_id=b,a.$window_id=w}this.sessionPropsManager&&J(a,this.sessionPropsManager.getSessionProps());try{var u;this.sessionRecording&&J(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(u=this.Bu)===null||u===void 0?void 0:u.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}let c;if(this.requestRouter.region===gr&&(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=J(a,c),t==="$pageview"&&$&&(a.title=$.title),!x(o)){const b=i.getTime()-o;a.$duration=parseFloat((b/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,g=h.$groups;N(p)&&!$e(p)&&(a.$groups=v(v({},N(g)?g:{}),p)),G(["$referrer","$referring_domain"],b=>{b in h&&delete d[b]});const m={};if(this.Pu.length>0)for(const b of this.Pu.slice())try{J(m,b())}catch(w){E.error("Failed to produce browser extension event properties",w)}a=J({},l,h,d,v(v({},m),a)),a.$is_identified=this._isIdentified(),M(this.config.property_denylist)?G(this.config.property_denylist,function(b){delete a[b]}):E.error(Fl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const _=this.config.sanitize_properties;_&&(E.error(Gn),a=_(a,t));const f=this.yh();return a.$process_person_profile=f,f&&!n&&this.bh("_calculate_event_properties"),a}ph(t,s=!0,i=!1){var r;if(!this.persistence||!this.yh()||this.Iu&&!i)return t;const n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)===null||r===void 0?void 0:r.getSetOnceProps();let a=J({},n,o||{},t||{});const l=this.config.sanitize_properties;return l&&(E.error(Gn),a=l(a,"$set_once")),s&&(this.Iu=!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.gh(),(i=this.sessionPersistence)===null||i===void 0||i.register(t),Object.keys(t).forEach(r=>this.Mu.add(r)),this.mh()}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.Mu.delete(t),this.mh()}_h(t,s){this.register({[t]:s})}Hu(){this.Mu.forEach(t=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t)}),this.Mu.clear(),this.mh()}mh(){var t;if(!this.Eu)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.mi||!Y.Et())return void Y.Lt(this.Eu);const s=[];this.Mu.forEach(i=>s.push(i)),s.length>0?Y.At(this.Eu,s):Y.Lt(this.Eu)}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.vu.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:Ut}),()=>{})}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:Ut})}getActiveMatchingSurveys(t,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,s):t([],{isLoaded:!1,error:Ut})}renderSurvey(t,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(t,s)}displaySurvey(t,s=vd){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:Ut}}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:Ut})}wh(t){return!t||Kt(t)?(E.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(E.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())||(E.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 E.uninitializedWarning("posthog.identify");if(ne(t)&&(t=t.toString(),E.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.wh(t)||!this.bh("posthog.identify"))return;this.Su();const r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.gh(!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(Hs),this.register({distinct_id:t}));const h=(this.persistence.get_property("$user_state")||"anonymous")===Ve,d=t!==c,p=!d&&h;if(d&&h){var u;const g=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:c};this.persistence.set_property(be,Os),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.La(),this.capture("$identify",g,{$set:s||{},$set_once:i||{}})&&(this.Ou=Oi(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,Os);const g=s||{},m=i||{};this.setPersonPropertiesForFlags({$set:g,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.La(),this.capture("$set",{$set:g,$set_once:m})&&(this.Ou=Oi(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.bh("posthog.setPersonProperties"))return;const i=Oi(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)):E.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var s;const i=(M(t)?t:[t]).filter(r=>D(r)&&r.length>0);i.length!==0&&this.bh("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 E.error("posthog.group requires a group type and group key");(r=this.persistence)===null||r===void 0||r.syncCookieProperties(),this.gh();const n=this.getGroups(),o=n[t]!==s;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:v(v({},n),{},{[t]:s})}),(o||i)&&this.yh()){const a={$group_type:t,$group_key:s};i&&(a.$group_set=i),this.capture(fn,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.bh("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.kh(s,!1,i)}kh(t,s=!1,i){var r,n,o,a,l,u;if(E.info("reset"),!this.__loaded)return E.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(Er),d=this.get_property(fi),p=this.get_property(Qt);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const g=this.is_capturing();this.consent.reset(),s||!g||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 m=(l=this.persistence)===null||l===void 0||(u=l.Da)===null||u===void 0?void 0:u.call(l);let _=!1;try{var f,b,w,P,k,R,I,S,F,j,z,H,X;if((f=this.persistence)===null||f===void 0||f.clear(),(b=this.sessionPersistence)===null||b===void 0||b.clear(),this.Mu.clear(),this.mh(),x(p)||(j=this.persistence)===null||j===void 0||j.register({$session_recording_remote_config:p}),(w=this.surveys)===null||w===void 0||w.reset(),(P=this.featureFlags)===null||P===void 0||P.reset(),(k=this.conversations)===null||k===void 0||k.reset(),(R=this.logs)===null||R===void 0||R.reset(),(I=this.metrics)===null||I===void 0||I.reset(),(S=this.persistence)===null||S===void 0||S.set_property("$user_state","anonymous"),(F=this.sessionManager)===null||F===void 0||F.resetSessionId(),this.Ou=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:gi,$device_id:null},"");else{const L=this.config.get_device_id(Ce());this.register_once({distinct_id:L,$device_id:t?L:h},""),t||x(d)||this.register({[fi]:d})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID&&!this.bu()&&((X=this.persistence)===null||X===void 0||X.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(z=this.featureFlags)===null||z===void 0||z.initialize(),!A(c)&&!(!((H=this.sessionManager)===null||H===void 0)&&H.setBootstrapSessionId(c,!0)))){const L=v({},i);delete L.sessionID,this.config.bootstrap=L}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var C,q;m&&((C=this.persistence)===null||C===void 0||(q=C.ja)===null||q===void 0||q.call(C,_))}this.reloadFeatureFlags()}shutdown(t){var s=this;return Z(function*(){var i,r,n,o,a,l,u,c;if(s.__loaded){s.Tu=!0,s.Zu().dispose(),(i=s.sessionRecording)===null||i===void 0||i.dispose(),(r=s.logs)===null||r===void 0||r.flushLogs("sendBeacon"),(n=s.metrics)===null||n===void 0||n.flush("sendBeacon"),(o=s.metrics)===null||o===void 0||o.dispose(),(a=s.qu)===null||a===void 0||a.unload(),(l=s.Bu)===null||l===void 0||l.unload();try{var h;(h=s.featureFlags)===null||h===void 0||h.destroy()}catch(d){E.error("Error while destroying feature flags",d)}(u=s.persistence)===null||u===void 0||u.destroy(),(c=s.sessionPersistence)===null||c===void 0||c.destroy()}else E.uninitializedWarning("posthog.shutdown")})()}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.Sh()}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.xh()}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")?(E.critical("Attempting to create alias for existing People user - aborting."),-2):this.bh("posthog.alias")?(x(s)&&(s=this.get_distinct_id()),t!==s?(this._h(Hs,t),this.capture("$create_alias",{alias:t,distinct_id:s})):(E.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const s=v({},this.config);if(N(t)){var i,r,n,o,a,l,u,c,h,d,p,g,m,_;J(this.config,Kn(t));const b=this.xu();(i=this.persistence)===null||i===void 0||i.update_config(this.config,s,b),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new ki(v(v({},this.config),{},{persistence:"sessionStorage"}),b,!1);const w=this.Du(this.config.debug);var f;we(w)&&(this.config.debug=w),we(this.config.debug)&&(this.config.debug?(le.DEBUG=!0,B.Et()&&B.At("ph_debug",!0),E.info("set_config",{config:t,oldConfig:s,newConfig:v({},this.config)})):(le.DEBUG=!1,B.Et()&&B.Lt("ph_debug"))),(r=this.featureFlags)===null||r===void 0||(n=r.updateConfig)===null||n===void 0||n.call(r,this.config,this.nl()),(o=this.exceptionObserver)===null||o===void 0||o.onConfigChange(),(a=this.exceptions)===null||a===void 0||a.onConfigChange(),(l=this.metrics)===null||l===void 0||l.onConfigChange(),(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)&&((f=this.historyAutocapture)===null||f===void 0||f.startIfEnabledOrStop()),(p=this.exceptionObserver)===null||p===void 0||p.startIfEnabledOrStop(),(g=this.deadClicksAutocapture)===null||g===void 0||g.startIfEnabledOrStop(),(m=this.surveys)===null||m===void 0||m.loadIfEnabled(),this.Cu(),(_=this.externalIntegrations)===null||_===void 0||_.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&In(this,os,!1)}}_overrideSDKInfo(t,s){le.LIB_NAME=t,le.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(v(v({},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:Qe.Ch}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:Yt;return s!==Yt&&(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"}yh(){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))}ih(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.yh()||this.bh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}bh(t){return this.config.person_profiles==="never"?(E.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._u(),this._h(Rr,!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")}Cu(){var t,s;const i=this.xu();var r,n,o;return this.is_capturing()||(r=this.logs)===null||r===void 0||r.$h(),((t=this.persistence)===null||t===void 0?void 0:t.mi)!==i&&((n=this.persistence)===null||n===void 0||n.set_disabled(i)),((s=this.sessionPersistence)===null||s===void 0?void 0:s.mi)!==i&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(i)),i&&(this.Mu.clear(),this.mh()),i}opt_in_capturing(t){var s;if(this.config.cookieless_mode!=="always"){if(this.bu()){var i,r,n,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.kh(!0,!0),(r=this.sessionManager)===null||r===void 0||r.destroy(),(n=this.pageViewManager)===null||n===void 0||n.destroy(),this.sessionManager=new Hn(this),this.pageViewManager=new On(this),this.persistence&&(this.sessionPropsManager=new Bn(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=Qe.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var u,c;p&&(this.sessionRecording=this.yu(this.sessionRecording,new p(this)),this.du&&((u=this.sessionRecording)===null||u===void 0||(c=u.onRemoteConfig)===null||c===void 0||c.call(u,this.du)))}var h,d;this.consent.optInOut(!0),this.Cu(),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.th()}else E.warn(Un)}opt_out_capturing(){if(this.config.cookieless_mode==="always")return void E.warn(Un);const t=this.config.cookieless_mode==="on_reject"?this.sessionRecording:void 0;var s,i;t?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.kh(!0,!0),this.consent.optInOut(!1),this.Cu(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:gi,$device_id:null}),this.mu(t),this.sessionRecording=void 0,(s=this.sessionManager)===null||s===void 0||s.destroy(),(i=this.pageViewManager)===null||i===void 0||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.th(),this.Yu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return 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.Cu()}_is_bot(){return ce?$l(ce,this.config.custom_blocked_useragents):void 0}th(){$&&($.visibilityState==="visible"?this.Ru||(this.Ru=!0,this.capture(Ir,{title:$.title},{send_instantly:!0}),this.Au&&($.removeEventListener(ds,this.Au),this.Au=null)):this.Au||(this.Au=this.th.bind(this),W($,ds,this.Au)))}debug(t){t===!1?(y?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(y?.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?(E.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&&!A(s[i]),l=r in s&&!A(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,E)}Os(t){var s;if(A(this.config.before_send))return t;const i=Object.keys((s=t.properties)!==null&&s!==void 0?s:{}).filter(Wl),r=M(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),A(n)){const a=`Event '${t.event}' was rejected in beforeSend function`;return Vl(t.event)?E.warn(`${a}. This can cause unexpected behavior.`):E.info(a),null}n.properties&&!$e(n.properties)||E.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return E.error(`Error in beforeSend function for event '${t.event}':`,a),null}for(const o of i)if(n.properties&&A(n.properties[o]))return E.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=B.Et()&&B.Ot("ph_debug")==="true";return!s&&(!!i||t)}};as.__defaultExtensionClasses={},as.Ch=(()=>{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]]=bc(e.prototype[t[s]])})(as,["identify"]);var Il=class{constructor(e){this.disabled=e===!1;const t=N(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 Ti="$copy_autocapture",Ai=ie("[AutoCapture]");function Li(e,t){return t.length>e?t.slice(0,e)+"...":t}function Sd(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Ne(t));return t}function Pd(e,{e:t,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:r,elementsChainAsString:n,disableCaptureUrlHashes:o}){var a,l;if(!Ne(e))return{props:{}};const u=[e],c=new Set([e]);let h=e;for(;h.parentNode&&!ve(h,"body")&&1e3>u.length;){if(Cr(h.parentNode)){const R=h.parentNode.host;if(c.has(R))break;c.add(R),u.push(R),h=R;continue}if(!Ne(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(R=>ve(R,"button")||ve(R,"a")):-1;d>0&&(i=i||u.slice(0,d+1).some(R=>!Ot(R)||ps(R)));const p=[],g={};let m,_=!1,f=!1;if(G(u,R=>{const I=Ot(R);if(ve(R,"a")&&!s&&!r?.includes("href")){const S=R.getAttribute("href");_=!!(I&&S&&is(S))&&(o?nt(S):S)}T(Mt(R),"ph-no-capture")&&(f=!0),p.push((function(S,F,j,z,H=!1){const X=S.tagName.toLowerCase(),C={tag_name:X};Tr.indexOf(X)>-1&&!j&&(C.$el_text=X.toLowerCase()==="a"||X.toLowerCase()==="button"?Li(1024,Pn(S)):Li(1024,hs(S)));const q=Mt(S);F||z?.includes("class")||0>=q.length||(C.classes=q.filter(function(re){return re!==""})),G(S.attributes,function(re){var de;if((!ps(S)||["name","id","class","aria-label"].indexOf(re.name)!==-1)&&!z?.includes(re.name)&&!F&&is(re.value)&&(!D(de=re.name)||de.substring(0,10)!=="_ngcontent"&&de.substring(0,7)!=="_nghost")){let oe=re.value;re.name==="class"&&(oe=Mr(oe).join(" ")),C["attr__"+re.name]=Li(1024,re.name==="href"&&H?nt(oe):oe)}});let L=1,K=1,V=S;for(;V=Sd(V);)L++,V.tagName===S.tagName&&K++;return C.nth_child=L,C.nth_of_type=K,C})(R,s,i,r,o)),G((function(S){if(!Ot(S))return{};const F={};return G(S.attributes,function(j){if(j.name&&j.name.indexOf("data-ph-capture-attribute")===0){const z=j.name.replace("data-ph-capture-attribute-",""),H=j.value;z&&H&&is(H)&&(F[z]=H)}}),F})(R),(S,F)=>{({}).hasOwnProperty.call(g,F)||(g[F]=S)})}),f)return{props:{},explicitNoCapture:f};if(d>0&&(e=u[d],p.splice(0,d)),i||(p[0].$el_text=ve(e,"a")||ve(e,"button")?Pn(e):hs(e)),_){var b,w;p[0].attr__href=_;const R=(b=Ge(_))===null||b===void 0?void 0:b.host,I=y==null||(w=y.location)===null||w===void 0?void 0:w.host;R&&I&&R!==I&&(m=_)}return{props:J((k=t.type,{$event_type:k,$ce_version:1}),n?{}:{$elements:p},{$elements_chain:(P=p,M(P)?(function(R){return R.map(I=>{var S,F;let j="";if(I.tag_name&&(j+=I.tag_name),I.attr_class){I.attr_class.sort();for(const X of I.attr_class)j+=`.${X.replace(/"/g,"")}`}const z=v(v(v(v({},I.text?{text:I.text}:{}),{},{"nth-child":(S=I.nth_child)!==null&&S!==void 0?S:0,"nth-of-type":(F=I.nth_of_type)!==null&&F!==void 0?F:0},I.href?{href:I.href}:{}),I.attr_id?{attr_id:I.attr_id}:{}),I.attributes),H={};return Cs(z).sort(([X],[C])=>(function(q,L){return L>q?-1:q>L?1:0})(X,C)).forEach(([X,C])=>H[Rn(X.toString())]=Rn(C.toString())),j+=":",j+=Cs(H).map(([X,C])=>`${X}="${C}"`).join(""),j}).join(";")})((function(R){return R.map(I=>{var S,F;const j={text:(S=I.$el_text)===null||S===void 0?void 0:S.slice(0,400),tag_name:I.tag_name,href:(F=I.attr__href)===null||F===void 0?void 0:F.slice(0,2048),attr_class:Ac(I),attr_id:I.attr__id,nth_child:I.nth_child,nth_of_type:I.nth_of_type,attributes:{}};return Cs(I).filter(([z])=>z.indexOf("attr__")===0).forEach(([z,H])=>j.attributes[z]=H),j})})(P)):"")},!((a=p[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=p[0])===null||l===void 0?void 0:l.$el_text}:{},m&&t.type==="click"?{$external_click_url:m}:{},g),target:e};var P,k}var Rd=class{fo(){this.po=void 0,clearTimeout(this.mo),this.mo=void 0}yo(e){var t;if(!Ot(e))return!0;const s=(t=this.bo().css_selector_ignorelist)!==null&&t!==void 0?t:xi,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const n=r,o=Mt(n);if(T(o,"ph-no-capture")||T(o,"ph-sensitive")||ps(n)||s.some(l=>ur(n,l)))return!0;const a=r.parentNode;r=Cr(a)?a.host:a&&Ne(a)?a:null}return!1}_o(e){if(!this.isEnabled||e.type==="pointercancel")return void this.fo();if(e.type==="pointerdown"){this.fo();const i=ss(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&Ne(i)&&(this.po={target:i,excluded:this.yo(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this.wo)===null||t===void 0?void 0:t.distinctId}))}const s=this.po;s&&(e.pointerId!==s.id||Math.abs(e.clientX-s.x)>5||Math.abs(e.clientY-s.y)>5?this.fo():e.type==="pointerup"&&(s.released=!0,this.mo=setTimeout(()=>this.fo(),0)))}ko(e){var t;const s=this.po;this.fo();const i=ss(e);if(s?.released&&s.target.isConnected&&s.distinctId===((t=this.wo)===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&&(ve(i,"html")||ve(i,"body"))){var r;if(s.excluded)return null;const n=(r=this.bo().css_selector_ignorelist)!==null&&r!==void 0?r:xi;return[i,$?.documentElement,$?.body].some(o=>{if(!o)return!1;const a=Mt(o);return T(a,"ph-no-capture")||T(a,"ph-sensitive")||!Ot(o)||ps(o)||n.some(l=>ur(o,l))})?null:s.target}}constructor(e){this.So=e,this.name="autocapture",this.xo=!1,this.Co=null,this.$o=!1,this.To=!1,this.Rr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Io=!1,this.So.refresh(this.Rr),this.rageclicks=new Il(this.Rr.rageclick),this.Mo=null}setup(e){this.Eo(),this.wo=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.wo=void 0,(e=this.Po)===null||e===void 0||e.dispose(),this.Po=void 0,this.Ro())}bo(){return this.So.refresh(this.Rr),this.Rr}Eo(){var e,t;return this.bo(),this.Rr.url_allowlist=(e=this.Rr.url_allowlist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Rr.url_ignorelist=(t=this.Rr.url_ignorelist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Rr}Ao(){if(!this.isBrowserSupported())return void Ai.info("Disabling Automatic Event Collection because this browser is not supported");if(!y||!$)return;const e=this.Fo=t=>{t=t||y?.event;try{if(t.type==="blur")return void this.fo();if(t.type.indexOf("pointer")===0)return void this._o(t);const s=t.type==="click"?this.ko(t):void 0;if(te(s))return;this.Oo(t,"$autocapture",s)}catch(s){Ai.error("Failed to capture event",s)}};if(W(y,"blur",e),W($,"submit",e,{capture:!0}),W($,"change",e,{capture:!0}),W($,"click",e,{capture:!0}),G(["pointerdown","pointermove","pointerup","pointercancel"],t=>{W($,t,e,{capture:!0})}),this.bo().capture_copied_text){const t=this.Do=s=>{s=s||y?.event;try{this.Oo(s,Ti)}catch(i){Ai.error("Failed to capture clipboard event",i)}};W($,"copy",t,{capture:!0}),W($,"cut",t,{capture:!0}),W($,"paste",t,{capture:!0})}}Ro(){this.fo(),this.Fo&&(y?.removeEventListener("blur",this.Fo),G(["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.xo=!1}startIfEnabled(){this.isEnabled||this.fo(),!this.Io&&this.wo&&this.isEnabled&&!this.xo&&(this.Ao(),this.xo=!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.wo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.Co=s),this.startIfEnabled()}setElementSelectors(e){this.Mo=e}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||T(i,r)||i.push(r)})}),i}get isEnabled(){var e,t;if(this.Io)return!1;const s=(e=this.wo)===null||e===void 0?void 0:e.kv.get(ma),i=this.Co,r=this.bo();if(!r.remoteRequestsDisabled&&!this.$o)return!1;const n=r.remoteRequestsDisabled&&!this.$o;if(te(i)&&!we(s)&&!n)return!1;const o=(t=this.Co)!==null&&t!==void 0?t:!!s;return!!r.enabled&&!o}Oo(e,t="$autocapture",s){if(!this.isEnabled)return void this.fo();let i=s||ss(e);qa(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()))&&Va(i,r.rageclick)&&this.Oo(e,"$rageclick",s);const o=t===Ti,a=o?v(v({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(h,d,p,g,m,_){var f;if(!y||Ar(h)||p?.url_allowlist&&!bn(p.url_allowlist,_)||p?.url_ignorelist&&bn(p.url_ignorelist,_))return!1;if(p?.dom_event_allowlist){const k=p.dom_event_allowlist;if(k&&!k.some(R=>d.type===R))return!1}const{parentIsUsefulElement:b,targetElementList:w}=Wa(h,g);if(!(function(k,R){const I=R?.element_allowlist;if(x(I))return!0;for(const S of k)if(I.some(F=>S.tagName.toLowerCase()===F))return!0;return!1})(w,p)||!cr(w,p?.css_selector_allowlist)||cr(w,(f=p?.css_selector_ignorelist)!==null&&f!==void 0?f:xi))return!1;try{const k=y.getComputedStyle(h);if(k&&k.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0}catch{}const P=h.tagName.toLowerCase();switch(P){case"html":return!1;case"form":return(m||["submit"]).indexOf(d.type)>=0;case"input":case"select":case"textarea":return(m||["change","click"]).indexOf(d.type)>=0;default:return b?(m||["click"]).indexOf(d.type)>=0:(m||["click"]).indexOf(d.type)>=0&&(Tr.indexOf(P)>-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}=Pd(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.To,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(d)return!1;const g=this.getElementSelectors(i,p);if(g&&g.length>0&&(h.$element_selectors=g),t===Ti){const m=e.type||"clipboard";if(m!=="paste"){var u,c;const _=y==null||(u=y.getSelection())===null||u===void 0?void 0:u.toString(),f=Ba(_);if(!f)return!1;h.$selected_content=f,h.$clipboard_text_length=(c=_?.length)!==null&&c!==void 0?c:0}h.$copy_type=m}return(l=this.wo)===null||l===void 0||l.capture(t,h),!0}}isBrowserSupported(){return ue($?.querySelectorAll)}},Fd=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,s=N(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 Gt=ie("[ExceptionAutocapture]"),Jn=()=>{},Zn=e=>{var t;if(ue(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function gs(e,t,s){try{if(!(t in e))return Jn;const i={next:e[t]},r=s(function(...n){return i.next.apply(this,n)});return ue(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=Zn(n);for(;o;){if(o.next===r)return void(o.next=i.next);n=o.next,o=Zn(n)}}}catch{return Jn}}const Id=ie("[TracingHeaders]"),lt=ie("[Web Vitals]"),Qn=9e5,eo=["CLS","FCP","INP","LCP"],Od=["INP","LCP"],Cd=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Di="disabled",to="lazy_loading",qe=ie("[SessionRecording]"),Md=ie("[Heatmaps]");function Ni(e){return N(e)&&"clientX"in e&&"clientY"in e&&ne(e.clientX)&&ne(e.clientY)}const Ss=ie("[Product Tours]"),ji=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(Pr))},Td=["$set_once","$set"],Te=ie("[SiteApps]"),so="Error while initializing PostHog app with config id ",Ol=(e,t)=>e?.then?e.then(t):t(e),$t="SDK is not enabled or survey functionality is not yet loaded",io="Disabled. Not loading surveys.";var Ad=class{constructor(e,t){this.So=e,this.Th=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Ih=!1,this.Mh=[],this.Eh=null,this.Ph=null,this.Io=!1,this.Rh=new Set,this.onRemoteConfig=s=>{if(this.Io||this.Rr.disableSurveys)return;if(!s.ok)return U.warn("Remote config unavailable. Not loading surveys.");const i=s.config.surveys;if(A(i))return U.warn("Flags not loaded yet. Not loading surveys.");this.Ah=we(i)?i:i.length>0,U.info(`flags response received, isSurveysEnabled: ${this.Ah}`),this.loadIfEnabled()}}setup(e){if(!this.Io)return this.Fh=e,Ol(e.kv.initialize(),()=>{if(this.Fh!==e||this.Io)return;this.Fh=void 0,this.wo=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.Io?t.dispose():(this.Po=t,this.loadIfEnabled())})}dispose(){var e,t,s,i;this.Io||(this.Io=!0,this.Fh=void 0,this.wo=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.Mh=[],this.Eh=null,this.Rh.forEach(r=>clearTimeout(r)),this.Rh.clear())}get Rr(){return this.So.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{}}loadIfEnabled(){if(this.Io||!this.wo)return;const e=this.Rr;if(this._surveyManager)return;if(this.Ih)return void U.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void U.info(io);if(e.cookielessMode&&this.So.isOptedOut())return void U.info("Not loading surveys in cookieless mode without consent.");const t=this.So.getExtensions();if(!t)return void U.error("PostHog Extensions not found.");if(x(this.Ah)&&!e.advancedEnableSurveys)return;const s=this.Ah||e.advancedEnableSurveys;this.Ih=!0;try{const i=t.generateSurveys;if(i)return this.Oh(i,s),void(this.Ih=!1);const r=t.loadExternalDependency;if(!r)return this.Dh(Fr),void(this.Ih=!1);r(n=>{try{if(this.Io)return;const o=this.So.getExtensions();n||!o?.generateSurveys?this.Dh("Could not load surveys script",n):this.Oh(o.generateSurveys,s)}finally{this.Ih=!1}})}catch(i){throw this.Ih=!1,this.Dh("Error initializing surveys",i),i}}Oh(e,t){this.Io||(this._surveyManager=e(t),this._surveyEventReceiver=this.So.createEventReceiver(),U.info("Surveys loaded successfully"),this.Lh({isLoaded:!0}))}Dh(e,t){U.error(e,t),this.Lh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Mh.push(e),this._surveyManager&&this.Lh({isLoaded:!0}),()=>{this.Mh=this.Mh.filter(t=>t!==e)}}getSurveys(e,t=!1){var s;const i=(s=this.wo)!==null&&s!==void 0?s:this.Th;if(!i||this.Io)return;if(this.Rr.disableSurveys)return U.info(io),e([]);const r=i.kv.get(ir);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Nh()&&this.getSurveys(()=>{},!0));if(this.Eh)return void this.Eh.then(({surveys:a,context:l})=>{this.Io||e(a,l)}).catch(a=>U.error("Error in survey callback",a));const n=this.qh("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Rr.requestTimeoutMs}).then(a=>{try{return this.jh(i,a)}catch(l){return U.error("Error processing surveys response",l),this.jh(i,{statusCode:0,error:l})}},a=>this.jh(i,{statusCode:0,error:a}));this.Eh=n;const o=()=>{this.Eh===n&&(this.Eh=null)};n.then(a=>{o(),this.Io||e(a.surveys,a.context)},o).catch(a=>U.error("Error in survey callback",a))}qh(e,t){const s=this.wo;return s?s.sendRequest(e,t):new Promise(i=>i({statusCode:0,error:new Error($t)}))}jh(e,t){if(this.Io)return{surveys:[],context:{isLoaded:!1,error:$t}};const s=t.statusCode;if(s!==200||!t.json){const o=`Surveys API could not be loaded, status: ${s}`;return s!==0?U.error(o):t.error||U.warn(o),this.Ph=Date.now(),{surveys:[],context:{isLoaded:!1,error:o}}}this.Ph=null;const i=t.json.surveys||[],r=i.filter(o=>(function(a){return!(!a.start_date||a.end_date)})(o)&&(El(o)||(function(a){var l;return!!(!((l=a.conditions)===null||l===void 0||(l=l.actions)===null||l===void 0||(l=l.values)===null||l===void 0)&&l.length)})(o)));var n;return r.length>0&&((n=this._surveyEventReceiver)===null||n===void 0||n.register(r)),e.kv.set({[ir]:i,[Vs]:Date.now()}),{surveys:i,context:{isLoaded:!0}}}Nh(){return this.Bh()&&!this.Eh&&!this.Hh()}Bh(){var e,t;const s=(e=(t=this.wo)!==null&&t!==void 0?t:this.Th)===null||e===void 0?void 0:e.kv.get(Vs);return ne(s)&&Date.now()-s>3e5}Hh(){return ne(this.Ph)&&3e5>Date.now()-this.Ph}markSurveyAsSeen(e,t){var s;const i={id:e,current_iteration:(s=t?.iteration)!==null&&s!==void 0?s:null};Rl(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}Lh(e){for(const t of this.Mh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(s){U.error("Error in survey callback",s)}}getActiveMatchingSurveys(e,t=!1){if(!A(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);U.warn("init was not called")}zh(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}Uh(e){if(A(this._surveyManager))return{eligible:!1,reason:$t};const t=typeof e=="string"?this.zh(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Wh(e){if(!this.So.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(A(this._surveyManager))return{eligible:!1,reason:$t};const t=typeof e=="string"?this.zh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(A(this._surveyManager))return U.warn("init was not called"),{visible:!1,disabledReason:$t};const t=this.Wh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return A(this._surveyManager)?(U.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:$t})):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.Wh(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.So.isCapturing())return;if(A(this._surveyManager))return void U.warn("init was not called");const r=typeof e=="string"?this.zh(e):e;if(!r?.id)return void U.warn("Survey not found");if(!pd.includes(r.type))return void U.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){U.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const o=setTimeout(()=>{var a,l;this.Rh.delete(o),!this.Io&&this.So.isCapturing()&&(U.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),U.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Rh.add(o)}this._surveyManager.renderSurvey(r,n,s)}else U.warn("Survey element not found")}displaySurvey(e,t){var s;if(!this.So.isCapturing())return;if(A(this._surveyManager))return void U.warn("init was not called");const i=this.zh(e);if(!i)return void U.warn("Survey not found");let r=i;if(!((s=i.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=v(v({},i),{},{appearance:v(v({},i.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==dr.Popover&&t.initialResponses&&U.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){const n=this.Uh(i);if(!n.eligible)return void U.warn("Survey is not eligible to be displayed: ",n.reason)}t.displayType!==dr.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){A(this._surveyManager)?U.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 kt(e,t,s){if(A(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 Ld=class{constructor(e){this._instance=e,this.Vh=new Set,this.Gh=new Set,this.Zh=new Ks,this.Qh=(t,s)=>this.Jh(t,s)&&this.Kh(t,s)&&this.Xh(t,s)&&this.Yh(t,s),this.Jh=(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.tc=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var e;(e=this.tc)===null||e===void 0||e.call(this),this.tc=void 0,this.Zh=new Ks}register(e){var t,s;if(!x((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(i=>{var r;this.Vh.add(i),(r=i.steps)===null||r===void 0||r.forEach(n=>{this.Gh.add(n?.event||"")})}),(s=this._instance)===null||s===void 0?void 0:s.autocapture)){const i=new Set;this.Vh.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)}}replace(e){this.Vh.clear(),this.Gh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Gh.has(e)||this.Gh.has(t.event))&&this.Vh.forEach(s=>{this.ec(t,s)&&this.Zh.emit("actionCaptured",s.name)})}nc(e){this.onAction("actionCaptured",t=>e(t))}ec(e,t){if(t?.steps==null)return!1;for(const s of t.steps)if(this.Qh(e,s))return!0;return!1}onAction(e,t){return this.Zh.on(e,t)}Kh(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"||!kt(i,t.url,t.url_matching||"contains"))return!1}return!0}Xh(e,t){return!!this.sc(e,t)&&!!this.rc(e,t)&&!!this.oc(e,t)}sc(e,t){var s;if(!t?.href)return!0;const i=this.ac(e);if(i.length>0)return i.some(n=>kt(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&&kt((function(n){const o=n.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(r),t.href,t.href_matching||"exact")}rc(e,t){var s;if(!t?.text)return!0;const i=this.ac(e);if(i.length>0)return i.some(l=>kt(l.text,t.text,t.text_matching||"exact")||kt(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(;!A(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=>kt(l,o,a)));var n,o,a}oc(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}ac(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e?.properties.$elements}Yh(e,t){return!t?.properties||t.properties.length===0||Pl(t.properties.reduce((s,i)=>{const r=M(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)}},Dd=class{constructor(e){var t,s;this.lc=[],this._instance=e,this.uc=new Map,this.hc=new Map,this.cc=new Map,this.dc=(t=this._instance)===null||t===void 0||(s=t.onSessionId)===null||s===void 0?void 0:s.call(t,i=>this.vc(i))}fc(e){return!1}gc(){return null}mc(e){}yc(){}bc(e,t){return!!e&&Pl(e.propertyFilters,t?.properties)}_c(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}wc(e,t,s){const i=(s===Ht.Activation?this.uc:this.hc).get(e);let r=[];return this.kc(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.bc(a,t)})}register(e){this.Sc(e,!1)}replace(e){this.Sc(e,!0)}Sc(e,t){var s;x((s=this._instance)===null||s===void 0?void 0:s._addCaptureHook)||(this.xc(e,t),this.Cc(e,t))}Cc(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.cc.clear(),s.length===0)return void(t&&((i=this.$c)===null||i===void 0||i.replace([])));this.$c||(this.$c=new Ld(this._instance),this.$c.init(),this.$c.nc(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.cc.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.cc.set(a.name,u)}})}),t?this.$c.replace(r):this.$c.register(r)}Tc(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)})}xc(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._c(e,Ht.Activation),a=this._c(e,Ht.Cancellation);t?(this.uc=o,this.hc=a):(this.Tc(this.uc,o),this.Tc(this.hc,a)),(r.length!==0||n.length!==0)&&((s=this.tc)!==null&&s!==void 0||(this.tc=(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.Ic(),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.Mc(e,n);if(a==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this.Ec([n]);if(a==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this.Pc(n),void this.Rc([n])}if(this.hc.has(e)){const a=this.wc(e,t,Ht.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(l=>l.id)}),this.Ec(a.map(l=>l.id)),a.forEach(l=>this.Ac(l.id)))}if(!this.uc.has(e))return;r.info("event name matched",{event:e,eventPayload:t,items:this.uc.get(e)});const o=this.wc(e,t,Ht.Activation);this.Fc(o.map(a=>a.id))}onAction(e){this.cc.has(e)&&this.Fc(this.cc.get(e)||[])}Fc(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.fc(n)?this.Pc(n)&&this.Oc(n):r.push(n);r.length>0&&(this.lc=[...new Set([...this.lc,...r])]),this.Ic().info("updating activated items",{activatedItems:this.getActivatedIds()})}Pc(e){this.lc=this.lc.filter(s=>s!==e);const t=this.Dc();return!t.includes(e)&&(this.Lc([...t,e]),this.Nc(),!0)}Ec(e){const t=new Set(e);this.lc=this.lc.filter(r=>!t.has(r));const s=this.qc(),i=s.filter(r=>!t.has(r));i.length!==s.length&&(this.Lc(i),i.length===0&&this.jc()),this.Rc(e)}Bc(){var e;const t=this.gc();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:{}}Oc(e){if(!this.gc())return;const t=this.Bc();this.mc(v(v({},t),{},{[e]:Date.now()}))}Rc(e){if(!this.gc())return;const t=this.Bc(),s={};let i=!1;for(const[r,n]of Object.entries(t))e.includes(r)?i=!0:s[r]=n;i&&($e(s)?this.yc():this.mc(s))}Hc(){this.gc()&&this.yc()}getActivationTimestamp(e){if(!this.Dc().includes(e))return;const t=this.Bc()[e];return ne(t)?t:void 0}qc(){var e;const t=this.zc();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t])||[]}Dc(){var e,t,s;const i=this.qc();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.Uc()],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:[]}Nc(){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.Wc(s)}jc(){this.Vc()}vc(e){var t;const s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.Uc()];if(s&&s!==e){const i=this.qc(),r=this.Bc();i.length>0&&(this.Lc([]),i.filter(n=>ne(r[n])).forEach(n=>this.Ac(n))),this.jc(),this.Hc()}}getActivatedIds(){return[...new Set([...this.Dc(),...this.lc])].filter(e=>!this.Gc(e))}dispose(){var e,t,s;(e=this.dc)===null||e===void 0||e.call(this),this.dc=void 0,(t=this.tc)===null||t===void 0||t.call(this),this.tc=void 0,(s=this.$c)===null||s===void 0||s.dispose(),this.$c=void 0}reset(){this.lc=[],this.qc().length>0&&this.Lc([]),this.jc(),this.Hc()}getEventToItemsMap(){return this.uc}Zc(){return this.$c}},Nd=class extends Dd{constructor(e){super(e)}zc(){return ka}Uc(){return Ea}gc(){return Sa}mc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_timestamps:e})}yc(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}fc(e){var t;let s;this.kc(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}Qc(){return We.SHOWN}kc(e){var t;(t=this._instance)===null||t===void 0||t.getSurveys(e)}Ac(e){var t;(t=this._instance)===null||t===void 0||t.cancelPendingSurvey(e)}Ic(){return U}Lc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated:e})}Wc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_session:e})}Vc(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}Gc(){return!1}Mc(e,t){let s;return this.kc(i=>{s=i.find(r=>r.id===t)}),!s||(function(i){var r;return El(i)&&!!(!((r=i.conditions)===null||r===void 0||(r=r.events)===null||r===void 0)&&r.repeatedActivation)||i.schedule==="always"})(s)?e===We.SHOWN?"consume":"ignore":e===We.SHOWN?"persist":e===We.DISMISSED||e===We.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},jd=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)}},qd=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=O?.__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(){return new Nd(this._instance)}};const Bd=y?.location?Gs(y.location.hash,"__posthog")||Gs(location.hash,"state"):null,ro="_postHogToolbarParams",no=ie("[Toolbar]"),oo=ie("[FeatureFlags]");var zd=class{constructor(e,t=!1){this.Jc=!1,this.update(e,t)}update(e,t){this.Kc=((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:M(s.flag_keys)?s.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.Jc||(oo.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Jc=!0),x(e.flag_keys)||M(e.flag_keys)||oo.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.Kc}};const ao=ie("[FeatureFlags]"),ut=ie("[FeatureFlags]",{debugEnabled:!0}),qi=`" failed. Feature flags didn't load in time.`,Hd=[502,504],lo=["click","keydown","wheel","touchstart","pointerdown"],uo="connection_error",co=e=>{const t={};for(let s=0;e.length>s;s++)t[e[s]]=!0;return t},ho=e=>{const t={};for(const[s,i]of Cs(e||{}))i&&(t[s]=i);return t},po=e=>Dt(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Fe=ie("[Error tracking]"),_r="webkit-masked-url:",Vd=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Wd=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",_r],Ud=["__firefox__","__gCrWeb"],vo="Refusing to render web experiment since the viewer is a likely bot",Gd={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Js(t,e),not_regex:(e,t)=>!Js(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Pe=ie("[Conversations]"),ct="Conversations not available yet.";function fo(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=v(v({},(function(){let g="",m="";try{const _=ce?.userAgent;_&&([g,m]=Yo(_))}catch{}return(function(_,f){const b=(function(w){if(w)return{}.hasOwnProperty.call(ln,w)?ln[w]:w})(_);return v(v({},b?{"os.name":b}:{}),f?{"os.version":f}:{})})(g,m)})()),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 Xd=["debug","log","warn","error","info"],Yd=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},go="console",Cl="__posthogHandledLogsRequestError",Bi=(e,t)=>{const s=e instanceof Error?e:new Error(t);return s[Cl]=!0,s},_o=e=>!!e&&typeof e=="object"&&e[Cl]===!0,Zs=ie("[NetworkMetrics]"),Nr=()=>{var e;return!(y==null||(e=y.performance)===null||e===void 0)&&e.now?y.performance.now():Date.now()},Kd={"http:":80,"https:":443},Jd=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Ml=(e,t)=>{var s;const i=String(t);return{method:String(e).toUpperCase(),url:((s=Ge(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=Nr()-i,d=Ge(t.url);if(d&&d.protocol!=="http:"&&d.protocol!=="https:")return;const p={url:d?.href||t.url,method:t.method},g=ue(u.name)?u.name(p):D(u.name)?u.name:"http.client.request.duration";if(!g)return;const m=o&&!c?void 0:((f,b)=>f?400>f?void 0:String(f):b?.name||"_OTHER")(c,n),_=v(v(v(v(v({},(f=>{const b=Jd.has(f)?f:"_OTHER";return v({"http.request.method":b},b==="_OTHER"&&f!==b?{"http.request.method_original":f}:{})})(p.method)),d?(f=>{return{"server.address":f.hostname.startsWith("[")&&f.hostname.endsWith("]")?f.hostname.slice(1,-1):f.hostname,"server.port":Number(f.port)||Kd[f.protocol],"url.scheme":f.protocol.slice(0,-1),"url.template":(b=f.pathname,b.split("/").map(w=>(P=>/^\d+$/.test(P)||P.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(P))(w)?":id":w).join("/"))};var b})(d):{}),c?{"http.response.status_code":c}:{}),m?{"error.type":m}:{}),(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(g,h,{unit:"ms",attributes:_})}catch(u){Zs.error("Failed to record network metric",u)}},Tl=()=>{},Zd=(e,t)=>ue(y?.fetch)?gs(y,"fetch",s=>function(...i){const r=Nr(),n=s.apply(this,i);if(!t())return n;try{var o,a,l;const[u,c]=i,h=Ml((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 Zs.error("Failed to observe fetch",u),n}}):Tl,Qd=(e,t)=>{var s;const i=y==null||(s=y.XMLHttpRequest)===null||s===void 0?void 0:s.prototype;if(!i)return Tl;const r=new WeakMap,n=gs(i,"open",a=>function(...l){try{hl.has(this)||r.set(this,Ml(l[0],l[1]))}catch(u){Zs.error("Failed to observe XHR open",u)}return a.apply(this,l)}),o=gs(i,"send",a=>function(...l){let u;try{const c=r.get(this);if(c&&t()){const h=Nr();u=()=>{this.removeEventListener("loadend",u),mr(e,c,this.status,h,t)},W(this,"loadend",u)}}catch(c){Zs.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()}},ii={featureFlags:class{constructor(e){this.name="featureFlags",this.Xc=!1,this.featureFlagEventHandlers=[],this.$=ao,this.Yc={},this.td={},this.ed=[],this.nd=!1,this.sd=!1,this.rd=0,this.od=!1,this.ad=!1,this.ld=!1,this.ud=!1,this.hd=0,this.dd=!1,this.an=()=>{const t=this.vd();this.hd=0,t&&this.reloadFeatureFlags()},this.fd=()=>{var t,s;const i=this.pd,r=(t=this.gd)!==null&&t!==void 0?t:i;x(i)||x(r)||this.Rr.remoteRequestsDisabled||!$||$.visibilityState==="hidden"||Date.now()-((s=this.md)!==null&&s!==void 0?s:0)<r||(this.gd=this.dd||!this.Rr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.dd=!1,this.reloadFeatureFlags(),this.yd())},this.bd=()=>{this.dd&&this.gd===this.pd||this._d()},this.ln=()=>{$?.visibilityState==="visible"&&this._d()},"get"in e?this.So=e:(this._instance=e,this.wd=new zd(e.config,e.nl()),this.So=this.wd)}updateConfig(e,t){var s;(s=this.wd)===null||s===void 0||s.update(e,t),this.wo&&this.kd()}setup(e){return this.Fh=e,this.$=e.logger.createLogger("[FeatureFlags]"),Ol(e.kv.initialize(),()=>{this.Fh===e&&(this.Fh=void 0,this.wo=e,this.Sd(e))})}Sd(e){var t;if(this.wo===e)return y&&W(y,"online",this.an),this.kd(),this.xd=e.registerDynamicEventProperties(()=>this.Cd()?this.Yc:this.td),this.$d=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.Td(),this.Id(),this.Md()}),this.Id(),this.initialize()}_d(){this.dd=!0,this.gd=this.pd,this.fd()}kd(){const e=this.Rr.refreshIntervalMs,t=!this.Rr.remoteRequestsDisabled&&$&&!x(e)&&e>0?e:void 0;this.Rr.idleRefreshBackoff||(this.gd=t),t!==this.pd&&(this.Ed(),x(t)||(this.pd=t,this.gd=t,this.yd(),$?.addEventListener&&(W($,ds,this.ln),Pt(lo,s=>{W($,s,this.bd,{capture:!0})}))))}yd(){x(this.pd)||(x(this.Pd)||clearInterval(this.Pd),this.md=Date.now(),this.Pd=setInterval(this.fd,this.pd))}Ed(){var e;x(this.Pd)||(clearInterval(this.Pd),this.Pd=void 0,$==null||(e=$.removeEventListener)===null||e===void 0||e.call($,"visibilitychange",this.ln),Pt(lo,t=>{var s;$==null||(s=$.removeEventListener)===null||s===void 0||s.call($,t,this.bd,{capture:!0})})),this.pd=void 0,this.gd=void 0,this.dd=!1,this.md=void 0}destroy(){this.Rd()}dispose(){this.Rd()}Rd(){var e,t;this.Ed(),this.rd++,this.ad=!1,this.Fh=void 0,this.wo&&(this.Ad(),(e=this.xd)===null||e===void 0||e.dispose(),this.xd=void 0,(t=this.$d)===null||t===void 0||t.call(this),this.$d=void 0,this.ed=[],y?.removeEventListener("online",this.an),this.wo=void 0)}get Rr(){return this.So.get()}Fd(e){var t;return this.Od&&e in this.Od?this.Od[e]:(t=this.wo)===null||t===void 0?void 0:t.kv.get(e)}Td(){return!!this.Od&&(this.Od=void 0,!0)}Dd(){var e;return!x((e=this.wo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.Td()}At(e){this.Ld(()=>{var t;return(t=this.wo)===null||t===void 0?void 0:t.kv.set(e)})}Nd(e,t,s){var i;if(!(!((i=this._instance)===null||i===void 0)&&i.persistence)||!e.$enabled_feature_flags)return;const r=this.Fd("$enabled_feature_flags")||{},n=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(([,f])=>!f?.failed).map(([f])=>f):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,u=l?a:s&&!M(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),c=this.Fd("$feature_flag_payloads")||{},h=e.$feature_flag_payloads||{},d=l||s?u:Array.from(new Set([...Object.keys(c),...Object.keys(h)])),p=!l&&!s,g=!!p||u,m=!!p||d,_={[He]:g,[Oe]:g,[et]:m};e.$feature_flag_details&&(_[vt]=g);for(const f of[ft,rt,es])x(e[f])||(_[f]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(_)}Lt(e){this.Ld(()=>{var t;return(t=this.wo)===null||t===void 0?void 0:t.kv.remove(e)})}Ld(e){try{e()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}Id(){const e={};for(const i of[He,et,ft,Ae]){const r=this.Fd(i);x(r)||(e[i]=r)}this.Yc=e;const t=v({},e),s=this.Fd(Oe);if(s)for(const[i,r]of Object.entries(s))t[`$feature/${i}`]=r;this.td=t}Cd(){const e=this.Rr.cacheTtlMs;if(!e||0>=e)return!1;const t=this.Fd(rt);return typeof t!="number"||Date.now()-t>e}qd(){return!!this.Cd()&&(this.ud||this.sd||(this.ud=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}jd(){const e=this.Rr.evaluationContexts;return e?.length?e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),s}):[]}Bd(){const e=this.Rr.flagKeys;if(!x(e))return e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),s})}initialize(){var e,t;const s=this.Rr,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.Hd({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,s){var i,r;const n=s?.merge&&(i=this.Fd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s?.merge&&(r=this.Fd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=v(v({},n),e),l=v(v({},o),t),u={};for(const[c,h]of Object.entries(a))u[c]={key:c,enabled:sn(h),variant:rn(h),reason:void 0,metadata:x(l?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}};this.Hd({flags:u})}get hasLoadedFlags(){return this.nd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Fd(vt),t=this.Fd(Ae),s=this.Fd(ht);if(!s&&!t)return e||{};const i=J({},e||{}),r=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(const a of r){var n;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=v(v({},l),{},{enabled:c,variant:c?h??l?.variant:void 0});var o;c!==l?.enabled&&(p.original_enabled=l?.enabled),h!==l?.variant&&(p.original_variant=l?.variant),d&&(p.metadata=v(v({},l?.metadata),{},{payload:d,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=p}return this.Xc||(this.$.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:i}),this.Xc=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(s=>{const i=e[s];return{key:s,enabled:sn(i),variant:rn(i),payload:tn(t[s])}})}getFlagVariants(){const e=this.Fd(Oe),t=this.Fd(Ae);if(!t)return e||{};const s=J({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.Xc||(this.$.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:s}),this.Xc=!0),s}getFlagPayloads(){const e=this.Fd(et),t=this.Fd(ht);if(!t)return e||{};const s=J({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.Xc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:s}),this.Xc=!0),s}reloadFeatureFlags(){this.od||this.Rr.featureFlagsDisabled||this.vd()||(this.sd&&(this.ad=!0),this.zd||(this.ed.slice().forEach(e=>{try{e()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.zd=setTimeout(()=>{this.Ud()},5)))}Ad(){clearTimeout(this.zd),this.zd=void 0}onReloading(e){return this.ed.push(e),()=>{this.ed=this.ed.filter(t=>t!==e)}}ensureFlagsLoaded(){this.nd||this.sd||this.zd||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.od=e}resetFlagCallReported(){this.Lt(it)}Ud(e){this.Ad();const t=this.wo;if(!t||this.Rr.remoteRequestsDisabled||this.vd())return;if(this.sd)return void(this.ad=!0);const s={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:v(v(v({},t.initialPersonProperties),this.Fd("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Fd(st),timezone:rl()};x(t.deviceId)||(s.$device_id=t.deviceId),(e?.disableFlags||this.Rr.featureFlagsDisabled)&&(s.disable_flags=!0);const i=this.jd();i.length&&(s.evaluation_contexts=i);const r=this.Bd();x(r)||(s.flag_keys=r);const n=this.Rr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.rd;this.sd=!0;const l=()=>{this.ad&&(this.ad=!1,this.Ud())},u=g=>{var m,_;const f=(m=g.json)!==null&&m!==void 0?m:{},b=g.statusCode!==200;if(this.sd=!1,a!==this.rd)return void l();if(this.Wd(g.statusCode),b||this.ad||(this.$anon_distinct_id=void 0),s.disable_flags&&!this.ad)return;this.ld=!b;const w=[];g.error?w.push(g.error instanceof Error&&g.error.name==="AbortError"?"timeout":g.error instanceof Error?uo:"unknown_error"):g.statusCode!==200&&w.push(`api_error_${g.statusCode}`),f.errorsWhileComputingFlags&&w.push("errors_while_computing_flags");const P=!!(!((_=f.quotaLimited)===null||_===void 0)&&_.includes("feature_flags"));P&&w.push("quota_limited"),this.At({[cs]:w}),P?this.$.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."):s.disable_flags||this.Hd(f,b,{partialResponse:n}),l()},c=g=>{this.sd=!1,a===this.rd&&(this.At({[cs]:[uo]}),this.$.error("Feature flag request failed",g),this.Dd()&&this.Md(!0)),l()};let h=this.Rr.requestMaxRetries;const d=()=>h>0&&a===this.rd,p=()=>{if(a!==this.rd||!this.wo||this.Rr.remoteRequestsDisabled)return this.sd=!1,void l();try{t.sendRequest(o,{target:"flags",method:"POST",body:s,compression:this.Rr.compression,sentAt:"body",timeoutMs:this.Rr.requestTimeoutMs}).then(g=>{if((m=>Hd.includes(m.statusCode)||(_=>_.statusCode===0&&_.error instanceof Error&&_.error.name==="AbortError")(m))(g)&&d())return h--,void setTimeout(p,500);u(g)}).catch(c)}catch(g){c(g)}};p()}vd(){return Ya(this.hd,3)}Wd(e){this.hd=Ka(e,this.hd,3,()=>this.$.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.ld)return;if(!(this.nd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+e+qi);if(this.qd())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.ld)return;if(!(this.nd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+e+qi);if(this.qd())return;const s=this.getFlagVariants(),i=e in s,r=s[e],n=this.getFlagPayloads()[e],o=String(r),a=this.Fd("$feature_flag_request_id")||void 0,l=this.Fd("$feature_flag_evaluated_at")||void 0;let u,c=this.Fd("$flag_call_reported")||{};if(this.Rr.deduplicateCallsPerSession){var h;const F=(h=this.wo)===null||h===void 0?void 0:h.session.sessionId,j=this.Fd(Xt);F&&F!==j&&(c={},u=F)}if(t.send_event||!("send_event"in t))if(e in c&&c[e].includes(o))u&&this.At({[it]:c,[Xt]:u});else{var d,p,g,m,_,f,b,w,P,k,R,I;M(c[e])?c[e].push(o):c[e]=[o],this.At(v({[it]:c},u?{[Xt]:u}:{}));const F=this.getFeatureFlagDetails(e),j=[...(d=this.Fd("$feature_flag_errors"))!==null&&d!==void 0?d:[]];x(r)&&j.push("flag_missing");const z={$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=(g=this.Rr.bootstrap)===null||g===void 0||(g=g.featureFlags)===null||g===void 0?void 0:g[e])!==null&&p!==void 0?p:null,$feature_flag_bootstrapped_payload:(m=(_=this.Rr.bootstrap)===null||_===void 0||(_=_.featureFlagPayloads)===null||_===void 0?void 0:_[e])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.ld};x(F==null||(f=F.metadata)===null||f===void 0?void 0:f.has_experiment)||(z.$feature_flag_has_experiment=F.metadata.has_experiment),x(F==null||(b=F.metadata)===null||b===void 0?void 0:b.version)||(z.$feature_flag_version=F.metadata.version);const H=(w=F==null||(P=F.reason)===null||P===void 0?void 0:P.description)!==null&&w!==void 0?w:F==null||(k=F.reason)===null||k===void 0?void 0:k.code;var S;H&&(z.$feature_flag_reason=H),!(F==null||(R=F.metadata)===null||R===void 0)&&R.id&&(z.$feature_flag_id=F.metadata.id),x(F?.original_variant)&&x(F?.original_enabled)||(z.$feature_flag_original_response=x(F.original_variant)?F.original_enabled:F.original_variant),!(F==null||(I=F.metadata)===null||I===void 0)&&I.original_payload&&(z.$feature_flag_original_payload=F==null||(S=F.metadata)===null||S===void 0?void 0:S.original_payload),j.length&&(z.$feature_flag_error=j.join(",")),this.Vd(z)}else u&&this.At({[it]:c,[Xt]:u});return i?{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:tn(n)}:void 0}Vd(e){try{var t;(t=this.wo)===null||t===void 0||t.capture("$feature_flag_called",e)}catch(s){this.$.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(e,t){this.Gd(e,t)}Gd(e,t){var s=this;return Z(function*(){const i=s.wo;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.jd();n.length&&(r.evaluation_contexts=n);const o=s.Bd();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.Rr.compression,sentAt:"body",timeoutMs:s.Rr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=u?.[e]||void 0}catch(u){return void s.$.error("Remote config feature flag request failed",u)}try{t(a)}catch(u){s.$.error("Remote config feature flag callback failed",u)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.ld)return t.defaultValue;if(!(this.nd||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+e+qi),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.Hd(e,t,s)}Hd(e,t,s){if(!this.wo)return;this.nd=!0;const i=((r,n={},o={},a={},l,u=ao)=>{const c=((w,P)=>{const k=w.flags;if(k){const R=Object.fromEntries(Object.keys(k).map(S=>{var F;return[S,(F=k[S].variant)!==null&&F!==void 0?F:k[S].enabled]})),I=Object.fromEntries(Object.keys(k).filter(S=>k[S].enabled).filter(S=>{var F;return!x((F=k[S].metadata)===null||F===void 0?void 0:F.payload)}).map(S=>{var F;return[S,(F=k[S].metadata)===null||F===void 0?void 0:F.payload]}));return v(v({},w),{},{featureFlags:R,featureFlagPayloads:I})}return w.featureFlags&&P.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 g=r.requestId,m=r.evaluatedAt;if(M(d)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const w={};if(d)for(let P=0;d.length>P;P++)w[d[P]]=!0;return{[He]:d,[Oe]:w,[es]:!1}}let _=d,f=p,b=h;if(l?.partialResponse){const w=Object.keys(_),P=f||{};_=v(v({},n),_),f=v(v({},o),P),w.forEach(k=>{k in P||f==null||delete f[k]}),b=v(v({},a),b)}else if(r.errorsWhileComputingFlags)if(h){const w=new Set(Object.keys(h).filter(k=>{var R;return!(!((R=h[k])===null||R===void 0)&&R.failed)}));_=v(v({},n),Object.fromEntries(Object.entries(_).filter(([k])=>w.has(k))));const P=Object.fromEntries(Object.entries(f||{}).filter(([k])=>w.has(k)));f=v(v({},o),P),w.forEach(k=>{k in P||f==null||delete f[k]}),b=v(v({},a),Object.fromEntries(Object.entries(b||{}).filter(([k])=>w.has(k))))}else _=v(v({},n),_),f=v(v({},o),f),b=v(v({},a),b);return v(v({[He]:Object.keys(ho(_)),[Oe]:_||{},[et]:f||{},[vt]:b||{},[es]:r.minimalFlagCalledEvents===!0},g?{[ft]:g}:{}),m?{[rt]:m}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.$);if(i)if(s?.persist===!1){const r=!x(this.wo.kv.get(Oe));this.Od=i,r||this.At(i)}else this.Td(),this.Nd(i,e,!!s?.partialResponse),this.At(i);else t&&this.Dd();t||(this.ud=!1),this.Md(t)}override(e,t=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Zd(e)}Zd(e){if(this.wo){if(e===!1)return this.Lt([Ae,ht]),this.Md(),void ut.info("All overrides cleared");if(M(e))return this.At({[Ae]:co(e)}),this.Md(),void ut.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;const s=e;this.Xc=!!((t=s.suppressWarning)!==null&&t!==void 0&&t);const i={},r=s.flags,n=s.payloads;return r&&(i[Ae]=M(r)?co(r):r),n&&(i[ht]=n),Object.keys(i).length&&this.At(i),r===!1&&n===!1?this.Lt([Ae,ht]):r===!1?this.Lt(Ae):n===!1&&this.Lt(ht),this.Md(),r===!1?ut.info("Flag overrides cleared"):r&&ut.info("Flag overrides set",{flags:r}),void(n===!1?ut.info("Payload overrides cleared"):n&&ut.info("Payload overrides set",{payloads:n}))}if(e&&typeof e=="object")return this.At({[Ae]:e}),this.Md(),void ut.info("Flag overrides set",{flags:e});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.nd){const{flags:t,flagVariants:s}=this.Qd();try{e(t,s)}catch(i){this.$.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var i;const r=(this.Fd("$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=v(v({},this.getFlagVariants()),{},{[e]:t});(i=this._instance)===null||i===void 0||(i=i.persistence)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(n)}),this.At({[He]:Object.keys(ho(a)),[Oe]:a,[tt]:v(v({},this.Fd("$stored_person_properties")||{}),n)}),this.Md();try{var l;(l=this.wo)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(u){this.$.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(e,t=!1,s){const i=this.Fd(sr);!i||t?this.Jd(e,s):e(i)}Jd(e,t){var s=this;return Z(function*(){const i=s.wo;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.At({[sr]:n})}catch(o){return void s.$.error("Early access feature request failed",o)}try{e(n)}catch(o){s.$.error("Early access feature callback failed",o)}})()}Qd(){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),{})}}Md(e){this.Id();const{flags:t,flagVariants:s}=this.Qd();this.featureFlagEventHandlers.forEach(i=>{try{i(t,s,{errorsLoading:e})}catch(r){this.$.error("Error while running feature flags callback",r)}})}setPersonPropertiesForFlags(e,t=!0){this.Kd(e,t)}Kd(e,t=!0){const s=this.Fd("$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.At({[tt]:v(v(v({},s),n),i)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const s=v({},this.Fd("$stored_person_properties")||{});e.forEach(i=>{delete s[i]}),this.At({[tt]:s}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(tt),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const s=this.Fd("$stored_group_properties")||{},i=v({},s);for(const r of Object.keys(e))i[r]=v(v({},s[r]),e[r]);this.At({[st]:i}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.Fd("$stored_group_properties")||{};this.At({[st]:v(v({},t),{},{[e]:{}})})}else this.Lt(st)}reset(){this.rd++,this.ad=!1,this.Yc={},this.td={},this.Od=void 0,this.nd=!1,this.od=!1,this.ld=!1,this.$anon_distinct_id=void 0,this.Ad(),this.Xc=!1,this.hd=0}}},eh={sessionRecording:class{get Rr(){return this._instance.config}get Ml(){return this._instance.persistence}get started(){var e;return!!(!((e=this.Xd)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.Yd==="awaiting_config"||this.Yd==="missing_config"?this.Yd:(e=(t=this.Xd)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.Yd}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.Yd=Di,this.tv=void 0,this.ev=!1,this.Xe=(()=>{var t,s;if(!$?.visibilityState||$.visibilityState==="visible")return!0;const i=y==null||(t=y.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.ln=()=>{var t,s;$?.visibilityState==="visible"&&(this.Xe=!0,(t=this.Xd)===null||t===void 0||(s=t.setDocumentWasEverVisible)===null||s===void 0||s.call(t,!0))},!this._instance.sessionManager)throw qe.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Rr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');$?.addEventListener&&W($,"visibilitychange",this.ln)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.ev=!0,$==null||(t=$.removeEventListener)===null||t===void 0||t.call($,"visibilitychange",this.ln),e?this.iv(!0):this.stopRecording()}get nv(){var e;const t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),s=!this.Rr.disable_session_recording,i=this.Rr.disable_session_recording||this._instance.consent.isOptedOut();return y&&t&&s&&!i}startIfEnabledOrStop(e){var t;if(this.ev||this.nv&&(!((t=this.Xd)===null||t===void 0)&&t.isStarted))return;const s=!x(Object.assign)&&!x(Array.from);this.nv&&s?(this.sv(e),qe.info("starting")):(this.Yd=Di,this.stopRecording())}sv(e){var t,s;if(this.nv)if(this.Yd!=="awaiting_config"&&this.Yd!=="missing_config"&&(this.Yd=to),(O==null||(t=O.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((s=O.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this.rv(e);else{var i,r;const n=this._instance.sessionManager;(i=O.__PosthogExtensions__)===null||i===void 0||(r=i.loadExternalDependency)===null||r===void 0||r.call(i,this._instance,this.ov,o=>{if(!this.ev&&this.nv&&this._instance.sessionManager===n)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),qe.error("could not load recorder",o)):void this.rv(e);this.Yd="disabled"})}}stopRecording(){var e,t;(e=this.tv)===null||e===void 0||e.call(this),this.tv=void 0,(t=this.Xd)===null||t===void 0||t.stop()}iv(e=!1){var t,s;(t=this.tv)===null||t===void 0||t.call(this),this.tv=void 0,(s=this.Xd)===null||s===void 0||s.discard({discardProducerEvents:e})}av(){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")}lv(e,t){if(A(e))return null;const s=ne(e)?e:parseFloat(e);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(qe.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):s;var i}uv(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.lv((n=this.Rr.session_recording)===null||n===void 0?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.lv(o?.sampleRate,"remote config sampleRate"),u=a??l;A(u)&&this.av();const c=o?.minimumDurationMilliseconds;i.register({[Qt]:v(v({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:v({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.tv)===null||t===void 0||t.call(this),this.tv=(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.uv(t),void this.iv()):(this.uv(t),void this.startIfEnabledOrStop()):(this.Yd==="awaiting_config"&&(this.Yd="missing_config",this._instance.register_for_session({[Ma]:!0}),qe.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var s;!((s=this.Xd)===null||s===void 0)&&s.log?this.Xd.log(e,t):qe.warn("log called before recorder was ready")}get ov(){var e,t;const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(Qt);return(s==null||(t=s.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}hv(){const e=this._instance.get_property(Qt);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return qe.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!A(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}rv(e){var t,s,i;if(!this.ev&&this.nv&&this._instance.sessionManager){if(!(!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return qe.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ca]:!0});var r;if(this.Xd||(this.Xd=(r=O.__PosthogExtensions__)===null||r===void 0?void 0:r.initSessionRecording(this._instance,this.Xe),this.Xd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.hv())return this.Yd==="missing_config"||this.Yd==="awaiting_config"?void 0:(this.Yd="awaiting_config",qe.info("persisted remote config is stale, requesting fresh config before starting"),void new ol(this._instance).load());this.Yd=to,(s=(i=this.Xd).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Xe),this.Xd.start(e)}else this.Yd=Di}onRRwebEmit(e){var t,s;(t=this.Xd)===null||t===void 0||(s=t.onRRwebEmit)===null||s===void 0||s.call(t,e)}overrideLinkedFlag(){var e,t;this.Xd||(t=this.Ml)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.Xd)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Xd||(t=this.Ml)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.Xd)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,s;this.Xd||(s=this.Ml)===null||s===void 0||s.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Xd)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Xd)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var s;return!!(!((s=this.Xd)===null||s===void 0)&&s.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.Xd)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},th={autocapture:class extends Rd{constructor(e){super(new Fd(e)),this.instance=e}},historyAutocapture:class{constructor(e){this.dv=!1,this._instance=e,this.vv=this.fv()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.pv();return!!(e.path||e.search||this.gv(e))}startIfEnabled(){this.isEnabled&&(E.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.vv=this.fv(),this.startIfEnabled()}stop(){this.mv&&this.mv(),this.mv=void 0,this.yv&&this.yv(),this.yv=void 0,E.info("History API monitoring stopped")}monitorHistoryChanges(){y&&y.history&&(this.bv("pushState"),this.bv("replaceState"),this._v(),this.gv()&&this.wv())}bv(e){var t;if(!y||!((t=y.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const s=this;gs(y.history,e,i=>function(r,n,o){var a;s.Sv(o)&&s.xv(),i.call(this,r,n,o),s.Cv(e,!s.dv&&(y==null||(a=y.event)===null||a===void 0?void 0:a.type)!=="popstate")})}fv(){const e=y?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}pv(){const e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:N(e)?e:{}}gv(e=this.pv()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}$v(e){const t=this.pv(),s=this.vv;return!(!s||!(t.path&&e.pathname!==s.pathname||t.search&&e.search!==s.search||this.gv(t)&&e.hash!==s.hash))}Cv(e,t=!1){try{t||this.xv();const s=this.fv();if(!s)return;if(this.$v(s)){const i=()=>this._instance.capture(Ir,{navigation_type:e});t?(this.Tv=i,Promise.resolve().then(()=>this.xv())):i()}this.vv=s}catch(s){E.error(`Error capturing ${e} pageview`,s)}}Sv(e){var t,s;return!(A(e)||!y)&&((t=Ge(String(e)))===null||t===void 0?void 0:t.href)!==((s=y.location)===null||s===void 0?void 0:s.href)}xv(){const e=this.Tv;if(e){this.Tv=void 0,this.dv=!0;try{e()}catch(t){E.error("Error capturing deferred pageview",t)}finally{this.dv=!1}this.vv=this.fv()}}_v(){if(this.mv)return;const e=()=>{this.Cv("popstate")};W(y,"popstate",e),this.mv=()=>{y&&y.removeEventListener("popstate",e)}}wv(){if(this.yv)return;const e=()=>{this.Cv("hashchange")};W(y,"hashchange",e),this.yv=()=>{y&&y.removeEventListener("hashchange",e)}}},heatmaps:class{get Rr(){return this.instance.config}constructor(e){var t;this.Iv=!1,this.xo=!1,this.Mv=null,this.instance=e,this.Iv=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[Zi]),this.rageclicks=new Il(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return N(this.Rr.capture_heatmaps)&&this.Rr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return A(this.Rr.capture_heatmaps)?A(this.Rr.enable_heatmaps)?this.Iv:this.Rr.enable_heatmaps:this.Rr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.xo)return;Md.info("starting..."),this.Ev(),this.ln()}else{var e;clearInterval((e=this.Mv)!==null&&e!==void 0?e:void 0),this.Pv(),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({[Zi]:s}),this.Iv=s,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}Rv(e){Ni(e.originalEvent)&&this.Tr(e.originalEvent,"deadclick")}ln(){this.Mv&&clearInterval(this.Mv),this.Mv=$?.visibilityState==="visible"?setInterval(this.bl.bind(this),this.flushIntervalMilliseconds):null}Ev(){y&&$&&(this.Av=this.bl.bind(this),W(y,Ws,this.Av),this.Fv=e=>this.Tr(e||y?.event),W($,"click",this.Fv,{capture:!0}),this.Ov=e=>this.Dv(e||y?.event),W($,"mousemove",this.Ov,{capture:!0}),this.Lv=new Fn(this.instance,Lc,this.Rv.bind(this)),this.Lv.startIfEnabledOrStop(),this.Nv=this.ln.bind(this),W($,ds,this.Nv),this.xo=!0)}Pv(){var e;y&&$&&(this.Av&&y.removeEventListener(Ws,this.Av),this.Fv&&$.removeEventListener("click",this.Fv,{capture:!0}),this.Ov&&$.removeEventListener("mousemove",this.Ov,{capture:!0}),this.Nv&&$.removeEventListener(ds,this.Nv),clearTimeout(this.qv),(e=this.Lv)===null||e===void 0||e.stop(),this.xo=!1)}jv(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&&Ne(u)&&!ve(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:y)===null||c===void 0?void 0:c.getComputedStyle(u).position}catch{return!1}if(T(a,p))return!0;u=za(u)}return!1})(ss(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:i),y:e.clientY+(n?0:s),target_fixed:n,type:t}}Tr(e,t="click"){var s;if(yn(e.target)||!Ni(e))return;const i=this.jv(e,t);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Va(ss(e),this.instance.config.rageclick)&&this.Zs(v(v({},i),{},{type:"rageclick"})),this.Zs(i)}Dv(e){!yn(e.target)&&Ni(e)&&(clearTimeout(this.qv),this.qv=setTimeout(()=>{this.Zs(this.jv(e,"mousemove"))},500))}Zs(e){if(!y)return;const t=this.Rr.disable_capture_url_hashes?nt(y.location.href):y.location.href,s=this.Rr.custom_personal_data_properties,i=this.Rr.mask_personal_data_properties?[...At,...s||[]]:[],r=vs(t,i,fs);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(e)}bl(){this.Rt&&!$e(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Fn,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.Iv=!1,this.xo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Bv=()=>{clearTimeout(this.Hv),this.Hv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",v({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>v(v({},s),{},{[`$web_vitals_${i.name}_event`]:v({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.zv=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},A(s?.name)||A(s?.value))return void lt.error("Invalid metric received",s);const r=typeof s.navigationURL=="string"?s.navigationURL:void 0,n=this.Uv(r);if(x(n))return;const o=ne(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${n}`;if(this.Wv&&s.value>=this.Wv)return void lt.error("Ignoring metric with value >= "+this.Wv,s);this.Rt.navigationKey!==o&&(this.Bv(),this.Hv=setTimeout(this.Bv,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=v(v(v({},s),r?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,N(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){const u={};for(const c of Cd){const h=c==="url"&&typeof s.attribution[c]=="string"?this.Uv(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.Bv()},this.Vv=()=>{if(this.xo)return;let s,i,r,n,o=!1;const a=O.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.Gv]||(this.Gv==="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 lt.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},h=o&&this.attributionMetrics.indexOf("INP")>-1?v(v({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&s(this.zv.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.zv.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.zv.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.zv.bind(this),h),this.xo=!0},this.Iv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[tr]),this.startIfEnabled()}get Zv(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const s=N(this.Zv)?(e=this.Zv)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return A(s)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||eo:s}get flushToCaptureTimeoutMs(){return(N(this.Zv)?this.Zv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=N(this.Zv)?this.Zv.web_vitals_attribution:void 0;return we(e)?e?eo:[]:M(e)?e:Od}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=N(this.Zv)?this.Zv.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Wv(){const e=N(this.Zv)&&ne(this.Zv.__web_vitals_max_value)?this.Zv.__web_vitals_max_value:Qn;return e>0&&6e4>=e?Qn:e}get isEnabled(){const e=ee?.protocol;if(e!=="http:"&&e!=="https:")return lt.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=N(this.Zv)?this.Zv.web_vitals:we(this.Zv)?this.Zv:void 0;return we(t)?t:this.Iv}startIfEnabled(){this.isEnabled&&!this.xo&&(lt.info("enabled, starting..."),this.zo(this.Vv))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const s=N(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=N(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[tr]:s}),this._instance.persistence.register({[wa]:i})),this.Iv=s,this.startIfEnabled()}get Gv(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}zo(e){var t;const s=O.__PosthogExtensions__,i=this.Gv,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?lt.error("failed to load script",n):e()})}Uv(e){const t=e||y?.location.href;if(!t)return void lt.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?nt(t):t,i=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...At,...i||[]]:[];return vs(s,r,fs)}}},sh={exceptionObserver:class{constructor(e){var t;this.Vv=()=>{var s;if(!y||!this.isEnabled||!(!((s=O.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;const i=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Qv&&this.Rr.capture_unhandled_errors&&(this.Qv=i(this.captureException.bind(this))),!this.Jv&&this.Rr.capture_unhandled_rejections&&(this.Jv=r(this.captureException.bind(this))),!this.Kv&&this.Rr.capture_console_errors&&(this.Kv=n(this.captureException.bind(this)))}catch(o){Gt.error("failed to start",o),this.Xv()}},this._instance=e,this.Yv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[Qi]),this.wt=new Yl(v(v({},(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,$:Gt})),this.Rr=this.tf(),this.startIfEnabledOrStop()}tf(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return N(e)?t=v(v({},t),e):(x(e)?this.Yv:e)&&(t=v(v({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rr.capture_console_errors||this.Rr.capture_unhandled_errors||this.Rr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Gt.info("enabled"),this.Xv(),this.zo(this.Vv)):this.Xv()}zo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",r=>{if(r)return Gt.error("failed to load script",r);e()})}Xv(){var e,t,s;(e=this.Qv)===null||e===void 0||e.call(this),this.Qv=void 0,(t=this.Jv)===null||t===void 0||t.call(this),this.Jv=void 0,(s=this.Kv)===null||s===void 0||s.call(this),this.Kv=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.Yv=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Qi]:this.Yv}),this.Rr=this.tf(),this.startIfEnabledOrStop())}onConfigChange(){this.Rr=this.tf()}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 Gt.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.ef=[],this.if=new au([new xu,new Ou,new ku,new $u,new Fu,new Ru,new Su,new Iu],(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 g=l[p];if(g.length>1024)continue;const m=en.test(g)?g.replace(en,"$1"):g;if(!m.match(/\S*Error: /)){for(const _ of r){const f=_(m,i);if(f){a.push(f);const b=mu(a);if(b){for(let w=c.length-1;w>=0;w--){const P=c[w];if(b.start>=P.start+P.length)break;c.pop()}c.push(b)}break}}if(bu(a,c)>=50)break}}const h=[...c].sort((p,g)=>g.start-p.start),d=h[h.length-1];if(d){const p=ia(a,d);a.splice(d.start-p,p);for(const g of h)g.start-=p}for(const p of h)yu(a,p);return c.some(p=>p.start===0&&a.length===p.length)&&(function(p){const g=p.map(_=>`${_.function}|${_.filename}|${_.lineno}|${_.colno}|${_.module}`);let m=0;for(let _=1;g.length>_;_++)wu(g,_,m)&&(m=_);p.push(...p.splice(0,m))})(a),(function(p){if(!p.length)return[];const g=Array.from(p);return g.reverse(),g.slice(0,50).map(m=>{return v(v({},m),{},{filename:m.filename||(_=g,_[_.length-1]||{}).filename,function:m.function||"?"});var _})})(a)}})("web:javascript",vu,_u)),this._instance=e,this.ef=(t=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.nf=qs(this.sf()),this.rf=new Mu(this.nf)}onConfigChange(){this.nf=qs(this.sf()),this.rf.setConfig(this.nf)}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.ef=n,this._instance.persistence&&this._instance.persistence.register({[ya]:this.ef,[er]:o})}get af(){var e;const t=!!this._instance.get_property(er),s=this._instance.config.error_tracking.captureExtensionExceptions;return(e=s??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.if.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.nf.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)=>Cu.has(a)?(n.push(a),o):(o[a]=r[a],o),{}),droppedKeys:n}})(this.lf(t));i.length>0&&Fe.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.rf.add(v({[Ns]:e,[js]: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.uf(t)){if(this.hf(t))return this.cf("Exception dropped: matched a suppression rule"),void Fe.info("Skipping exception capture because a suppression rule matched");if(!this.af&&this.df(t))return this.cf("Exception dropped: thrown by a browser extension"),void Fe.info("Skipping exception capture because it was thrown by an extension");if(!this.af&&this.vf(t))return this.cf("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.ff(t))return this.cf("Exception dropped: thrown by the PostHog SDK"),void Fe.info("Skipping exception capture because it was thrown by the PostHog SDK")}const s=this.nf.enabled&&A(e.$exception_steps)?this.pf(e):e,i=(function(){const r=globalThis._posthogReleaseId;return typeof r=="string"&&r.length>0?r:void 0})();i&&(s.$release_id=i);try{const r=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",fh:!0});return r&&this.rf.clear(),r}catch(r){return po(r)||Fe.error("Failed to capture exception event. Dropping this exception.",r),void this.rf.clear()}}catch(t){return void(po(t)||Fe.error("Failed to process exception event. Ignoring this exception.",t))}}pf(e){try{const t=this.rf.getAttachable();return t.length===0?e:v(v({},e),{},{$exception_steps:t})}catch(t){return Fe.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}cf(e){this.nf.enabled&&this.rf.add({[Ns]:e,[js]:new Date().toISOString()})}lf(e){return N(e)?v({},e):{}}sf(){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:{}}hf(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.ef.some(s=>{const i=s.values.map(r=>{const n=Sl[r.operator],o=t[r.key];if(!n||!o)return!1;const a=M(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}}df(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&&Wd.some(r=>i.startsWith(r)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(_r))||e.some(({type:i,value:r})=>i==="NoResponse"||D(r)&&Vd.some(({value:n,exact:o})=>o?r===n:r.includes(n)))&&!t.some(({in_app:i,filename:r})=>i&&!r?.startsWith(_r)))}vf(e){return e.some(({value:t})=>D(t)&&Ud.some(s=>t.includes(s)))}ff(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}uf(e){return!A(e)&&M(e)}}},ih=v({productTours:class{get Ml(){return this._instance.persistence}constructor(e){this.gf=null,this.mf=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({[Pr]:!!t.productTours}),!ji(this._instance))return!this.gf&&A((s=this.Ml)===null||s===void 0?void 0:s.props.ph_product_tours)||Ss.info("product tours disabled; stopping and clearing cached tours"),(i=this.gf)===null||i===void 0||i.stop(),this.gf=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.gf&&ji(this._instance)&&this.zo(()=>this.yf())}zo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",r=>{r?Ss.error("Could not load product tours script",r):e()})}yf(){var e;!this.gf&&(!((e=O.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.gf=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(M(this.mf)&&!t)return void e(this.mf,{isLoaded:!0});const s=this.Ml;if(s){const i=s.props[rr];if(M(i)&&!t)return this.mf=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(!ji(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||Ss.warn(o):Ss.error(o),void e([],{isLoaded:!1,error:o})}const n=M(i.json.product_tours)?i.json.product_tours:[];this.mf=n,s&&s.register({[rr]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){A(this.gf)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.gf.getActiveProductTours(e)}showProductTour(e){var t;(t=this.gf)===null||t===void 0||t.showTourById(e)}previewTour(e){this.gf?this.gf.previewTour(e):this.zo(()=>{var t;this.yf(),(t=this.gf)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.gf)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.gf)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.gf)===null||e===void 0||e.previousStep()}clearCache(){var e;this.mf=null,(e=this.Ml)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.gf)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.gf)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.gf)===null||t===void 0||t.cancelPendingTour(e)}}},ii),rh={siteApps:class{constructor(e){this._instance=e,this.bf=0,this._f=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wf(e,t){if(!t)return;const s=this.globalsForEvent(t);this._f.push(s),this._f.length>1e3&&(this._f=this._f.slice(10))}get siteAppLoaders(){var e;return(e=O._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.wf.bind(this));this.kf=()=>{e(),this._f=[],this.kf=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,g]of Object.entries(c))l[p]={id:u[p],type:p,properties:g};const{$set_once:h,$set:d}=e;return{event:v(v({},aa(e,Td)),{},{properties:v(v(v({},e.properties),d?{$set:v(v({},(t=(s=e.properties)===null||s===void 0?void 0:s.$set)!==null&&t!==void 0?t:{}),d)}:{}),h?{$set_once:v(v({},(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}}Sf(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)||(Te.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)||(Te.error("prepare_external_dependency_script returned null"),null):e}xf(){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.bf++,this.Cf)return this.$f();const c=[],h=this,d=new WeakSet,p=(_,f,b)=>{if(!_?.[f])return;const w=_[f];_[f]=b(w),c.push(()=>{_[f]=w})},g=_=>{if(d.has(_))return _;const f=h.Sf(_);return f&&d.add(f),f},m=_=>_.map(f=>typeof f=="string"?f:g(f)).filter(f=>!te(f));return p(u,"appendChild",_=>function(f){const b=g(f);return b?_.call(this,b):f}),p(u,"insertBefore",_=>function(f,b){const w=g(f);return w?_.call(this,w,b):f}),p(u,"replaceChild",_=>function(f,b){const w=g(f);return w?_.call(this,w,b):b}),[(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(_=>{p(_,"append",f=>function(...b){return f.apply(this,m(b))}),p(_,"prepend",f=>function(...b){return f.apply(this,m(b))})}),[(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(_=>{p(_,"before",f=>function(...b){return f.apply(this,m(b))}),p(_,"after",f=>function(...b){return f.apply(this,m(b))}),p(_,"replaceWith",f=>function(...b){const w=m(b);return b.length&&!w.length?void 0:f.apply(this,w)})}),p((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",_=>function(f,b){const w=g(b);return w?_.call(this,f,w):null}),this.Cf=()=>{c.forEach(_=>_()),this.Cf=void 0},this.$f()}$f(){let e=!1;return()=>{var t;e||(e=!0,this.bf--,this.bf===0&&((t=this.Cf)===null||t===void 0||t.call(this)))}}Tf(e,t=!0){const s=this.xf();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._f.length&&(Te.info(`Processing ${this._f.length} events for site app with id ${e.id}`),this._f.forEach(o=>this.Tf(()=>{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.kf)===null||n===void 0||n.call(this))};let i=!1;const r=n=>{t.errored=!n,t.loaded=!0,Te.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),i&&s()};try{const{processEvent:n}=this.Tf(o=>e.init({posthog:this._instance,callback(a){o(),r(a)}}),!1);n&&(t.processEvent=n),i=!0}catch(n){Te.error(so+e.id,n),r(!1)}if(i&&t.loaded)try{s()}catch(n){Te.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}If(){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)}Mf(e){if(Object.keys(this.apps).length===0)return;const t=this.globalsForEvent(e);for(const s of Object.values(this.apps))try{this.Tf(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,t)})}catch(i){Te.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.If(),void this._instance.on("eventCaptured",a=>this.Mf(a))):void Te.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.kf)===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;O[`__$$ph_site_app_${a}`]=this._instance,(n=O.__PosthogExtensions__)===null||n===void 0||(o=n.loadSiteApp)===null||o===void 0||o.call(n,this._instance,l,u=>{if(u)return Te.error(so+a,u)})}else Te.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},nh={tracingHeaders:class{constructor(e){this._instance=e,this.Ef=void 0,this.Pf=void 0,this.Rf=void 0,this.Vv=()=>{const t=this.Af();var s,i;t?(x(this.Ef)&&(this.Ef=(s=O.__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.Pf)&&(this.Pf=(i=O.__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.Xv()}}initialize(){this.startIfEnabledOrStop()}zo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",r=>{if(r)return Id.error("failed to load script",r);e()})}Ff(){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}Af(){const e=this.Ff();return M(e)?(M(this.Rf)?this.Rf.splice(0,this.Rf.length,...e):this.Rf=[...e],e.length>0?this.Rf:void 0):(M(this.Rf)&&this.Rf.splice(0),this.Rf=e||void 0,this.Rf)}Xv(){var e,t;(e=this.Ef)===null||e===void 0||e.call(this),(t=this.Pf)===null||t===void 0||t.call(this),this.Ef=void 0,this.Pf=void 0}startIfEnabledOrStop(){this.Af()?this.zo(this.Vv):this.Xv()}}},oh=v({surveys:class extends Ad{constructor(e){var t;super(new qd(e),(t=e,{get projectToken(){return t.config.token},kv:new jd(t)})),this._instance=e}qh(e,t){const s=t.query?ms(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})})}}},ii),ah={toolbar:class{constructor(e){this.instance=e}Of(e){O.ph_toolbar_state=e}Df(){var e;return(e=O.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(or(this.instance.config)||!y||!$)return!1;e=(i=e)!==null&&i!==void 0?i:y.location,s=(r=s)!==null&&r!==void 0?r:y.history;try{if(!t){try{y.localStorage.setItem("test","test"),y.localStorage.removeItem("test")}catch{return!1}t=y?.localStorage}const n=Bd||Gs(e.hash,"__posthog")||Gs(e.hash,"state");let o;const a=n?Kr(()=>JSON.parse(atob(decodeURIComponent(n))))||Kr(()=>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(ro)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Lf(e){const t=O.ph_load_toolbar||O.ph_load_editor;!A(t)&&ue(t)?t(e,this.instance):no.warn("No toolbar load function found")}loadToolbar(e){const t=!!$?.getElementById("__POSTHOG_TOOLBAR__");if(!y||t)return!1;const s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=v(v({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(y.localStorage.setItem(ro,JSON.stringify(v(v({},i),{},{source:void 0}))),this.Df()===2)this.Lf(i);else if(this.Df()===0){var r,n;this.Of(1),(r=O.__PosthogExtensions__)===null||r===void 0||(n=r.loadExternalDependency)===null||n===void 0||n.call(r,this.instance,"toolbar",o=>{if(o)return no.error("[Toolbar] Failed to load",o),void this.Of(0);this.Of(2),this.Lf(i)}),W(y,"turbolinks:load",()=>{this.Of(0),this.loadToolbar(i)})}return!0}Nf(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,s=void 0){return this.maybeLoadToolbar(e,t,s)}}},lh=v({experiments:class me{get Rr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{me.qf("retrieved web experiments from the server"),this.jf=new Map,i.forEach(r=>{if(r.feature_flag_key){var n;this.jf&&(me.qf("setting flag key ",r.feature_flag_key," to web experiment ",r),(n=this.jf)===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.Bf(r.name,o,r.variants[o].transforms)}else if(r.variants)for(const o in r.variants){const a=r.variants[o];me.Hf(a,this._instance)&&this.Bf(r.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(t){if(this._is_bot())me.qf(vo);else if(!this.Rr.disable_web_experiments){if(A(this.jf))return this.jf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();me.qf("applying feature flags",t),t.forEach(s=>{var i;if(this.jf&&(!((i=this.jf)===null||i===void 0)&&i.has(s))){var r;const n=this._instance.getFeatureFlag(s),o=(r=this.jf)===null||r===void 0?void 0:r.get(s);n&&o?.variants[n]&&this.Bf(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){const t=me.getWindowLocation();if(t?.search){const s=Tt(t?.search,"__experiment_id"),i=Tt(t?.search,"__experiment_variant");s&&i&&(me.qf(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(r=>{this.zf(parseInt(s),i,r)},!1,!0))}}loadIfEnabled(){this.Rr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,s,i){if(this.Rr.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.Rr.token}`),method:"GET",timestampMode:"query",callback:n=>t(n.statusCode===200&&n.json&&n.json.experiments||[])})}zf(t,s,i){const r=i.filter(n=>n.id===t);r&&r.length>0&&(me.qf(`Previewing web experiment [${r[0].name}] with variant [${s}]`),this.Bf(r[0].name,s,r[0].variants[s].transforms))}static Hf(t,s){return!A(t.conditions)&&me.Uf(t,s)&&me.Wf(t)}static Uf(t,s){var i;if(A(t.conditions)||A((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=ja(s,r.href);return!(!((n=t.conditions)===null||n===void 0)&&n.url)||Gd[(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 y?.location}static Wf(t){var s;if(A(t.conditions)||A((s=t.conditions)===null||s===void 0?void 0:s.utm))return!0;const i=Ja();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,g=!(!((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,m=!(!((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&&g&&m&&p}return!1}static qf(t,...s){E.info(`[WebExperiments] ${t}`,s)}Bf(t,s,i){this._is_bot()?me.qf(vo):s!=="control"?i.forEach(r=>{if(r.selector){var n;me.qf(`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.qf("Control variants leave the page unmodified.")}_is_bot(){return ce&&this._instance?$l(ce,this.Rr.custom_blocked_useragents):void 0}}},ii),uh={conversations:class{constructor(e){this._instance=e,this.Vf=void 0,this._conversationsManager=null,this.Gf=!1,this.ne=null,this.Zf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Qf=e.ok,!e.ok))return;const t=e.config.conversations;A(t)||(we(t)?this.Vf=t:(this.Vf=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this.Vf=void 0,this.ne=null,this.Qf=void 0,this.Zf=!1}loadIfEnabled(){if(this._conversationsManager||this.Gf||this._instance.config.disable_conversations||or(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=O?.__PosthogExtensions__;if(e&&!x(this.Vf)&&this.Vf)if(this.ne&&this.ne.token){this.Gf=!0;try{const t=e.initConversations;if(t)return this.Jf(t),void(this.Gf=!1);const s=e.loadExternalDependency;if(!s)return void this.Kf(Fr);s(this._instance,"conversations",i=>{i||!e.initConversations?this.Kf("Could not load conversations script",i):this.Jf(e.initConversations),this.Gf=!1})}catch(t){this.Kf("Error initializing conversations",t),this.Gf=!1}}else Pe.error("Conversations enabled but missing token in remote config.")}Jf(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.Zf=!1,Pe.info("Conversations loaded successfully")}catch(t){this.Kf("Error completing conversations initialization",t)}else Pe.error("Cannot complete initialization: remote config is null")}Kf(e,t){Pe.error(e,t),this._conversationsManager=null,this.Gf=!1,this.Zf=!0}show(){this._conversationsManager?this._conversationsManager.show():Pe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Vf===!0&&!te(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":or(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Qf===!1?"remote_config_failed":x(this.Vf)?this.Qf?"disabled_in_project":"remote_config_pending":this.Vf?A(this.ne)||!this.ne.token?"missing_token":O?.__PosthogExtensions__?this.Gf?"initializing":this.Zf?"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 Z(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,s):(Pe.warn(ct),null)})()}getMessages(e,t){var s=this;return Z(function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,t):(Pe.warn(ct),null)})()}markAsRead(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Pe.warn(ct),null)})()}getTickets(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Pe.warn(ct),null)})()}requestRestoreLink(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Pe.warn(ct),null)})()}restoreFromToken(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Pe.warn(ct),null)})()}restoreFromUrlToken(){var e=this;return Z(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Pe.warn(ct),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}Sh(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}xh(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},ch={logs:class{constructor(e){var t;this._instance=e,this.name="logs",this.Xf=!1,this.Yf=!1,this.tp=!1,this.$=ie("[logs]"),this.ep=v(v({},this.$),{},{error:(...s)=>{s.some(_o)||this.$.error(...s)}}),this.al=[],this.np=[],this.hd=0,this.Io=!1,this.sp=[],this.rp=[],this.op=!1,this.ap=!1,this.lp=()=>{var s,i;this.Io||(this.hd=0,(s=this.up)===null||s===void 0||s.onReconnect(),(i=this.hp)===null||i===void 0||i.onReconnect())},this._instance&&(!((t=this._instance.config.logs)===null||t===void 0)&&t.captureConsoleLogs)&&(this.Xf=!0),y&&W(y,"online",this.lp)}cp(e,t,s,i){var r;const n=fo((r=this._instance)===null||r===void 0||(r=r.config)===null||r===void 0?void 0:r.logs,s);return[new Hu(this.dp(e,t),n,this.ep,()=>this.vp(),o=>o(),void 0,i),n]}fp(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var s;return this.up&&this.pp===t||((s=this.up)===null||s===void 0||s.reset(),this.pp=t,[this.up,this.gp]=this.cp(()=>this.al,i=>{this.al=i})),this.up}mp(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var s;return this.hp&&this.yp===t||((s=this.hp)===null||s===void 0||s.reset(),this.yp=t,[this.hp,this.bp]=this.cp(()=>this.np,i=>{this.np=i},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},go)),this.hp}setup(e){var t;if(this.Io)return;this.wo=e,!((t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0||(t=t.logs)===null||t===void 0)&&t.captureConsoleLogs&&(this.Xf=!0),(this.Xf||this._p()&&this.wp())&&this.kp();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;this.Io||(this.Io=!0,this.Sp(),(e=this.Po)===null||e===void 0||e.dispose(),this.Po=void 0,this.wo=void 0,this.tp=!1,y?.removeEventListener("online",this.lp),(t=this.xp)===null||t===void 0||t.call(this),this.xp=void 0,(s=this.up)===null||s===void 0||s.reset(),(i=this.hp)===null||i===void 0||i.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;A(i)?this.Cp():((s=this._instance)===null||s===void 0||(s=s.persistence)===null||s===void 0||s.register({$logs_capture_enabled_server_side:!!i}),i?(this.Xf=!0,this.Yf||this.kp(),this.loadIfEnabled()):this.Cp())}reset(){var e,t,s,i;this.Sp(),(e=this.up)===null||e===void 0||e.clearQueue(),this.al=[],(t=this.up)===null||t===void 0||t.reset(),(s=this.hp)===null||s===void 0||s.clearQueue(),this.np=[],(i=this.hp)===null||i===void 0||i.reset(),this.hd=0}captureLog(e){this.Io||this.fp().captureLog(e)}captureConsoleLog(e){this.Io||this.mp().captureLog(e)}captureBufferedConsoleLog(e,t,s){this.Io||this.mp().captureLog(e,{context:t,occurredAtMs:s})}wp(){var e;return!!(!((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e[ba])}_p(){var e,t,s;return!(!((e=this._instance)===null||e===void 0||(t=e.nl)===null||t===void 0)&&t.call(e))||!!(!((s=O._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[this._instance.config.token])===null||s===void 0)&&s.config)}$h(){var e;this.Sp(),(e=this.hp)===null||e===void 0||e.clearQueue(),this.np=[]}Cp(){this.Xf||this.Sp()}kp(){var e;if(this.op||!O?.console)return;const t=fo((e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs).maxBufferSize;let s=!0;this.rp.push(()=>{s=!1});for(const i of Xd){let r;try{r=Yd(O.console[i])}catch{continue}r&&this.rp.push(gs(O.console,i,n=>{const o=(...a)=>{try{s&&this.$p(i,a,t)}catch{}return n.apply(O.console,a)};return o.__rrweb_original__=r,o}))}this.op=!0,this.Tp=setTimeout(()=>{this.Sp()},3e4)}$p(e,t,s){var i;if(this.op&&!this.ap&&t.length!==0)if(!((i=this._instance)===null||i===void 0)&&i.is_capturing()){if(s>this.sp.length){this.ap=!0;try{this.sp.push({level:e,args:t,occurredAtMs:Date.now(),context:this.vp()})}finally{this.ap=!1}}}else this.Sp()}Sp(){if(this.sp=[],this.op){this.op=!1,this.Tp&&(clearTimeout(this.Tp),this.Tp=void 0);for(const e of this.rp)e();this.rp=[]}}Ip(){const e=this.sp;return this.Sp(),e}get logger(){return this.Mp||(this.Mp={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.Mp}flushLogs(e){e?this.Ep(e):(this.up&&this.up.flush().catch(t=>this.Pp(t)),this.hp&&this.hp.flush().catch(t=>this.Pp(t)))}Pp(e){_o(e)||this.$.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.Io||!this.Xf||this.Yf||this.tp)return;const e=O?.__PosthogExtensions__;if(!e)return this.$.error("PostHog Extensions not found."),void this.Sp();const t=e.loadExternalDependency;if(!t)return this.$.error(Fr),void this.Sp();this.tp=!0;try{t(this._instance,"logs",s=>{if(this.tp=!1,this.Io||!this.Xf)return;const i=e.logs;if(s||!i?.initializeLogs)this.$.error("Could not load logs script",s),this.Sp();else{var r;const a=this.Ip();var n,o;this.xp=i.initializeLogs((r=this.wo)!==null&&r!==void 0?r:this._instance),this.Yf=!0,a.length>0&&((n=i.replayConsoleBuffer)===null||n===void 0||n.call(i,(o=this.wo)!==null&&o!==void 0?o:this._instance,a))}})}catch(s){throw this.tp=!1,s}}dp(e,t){const s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===Le.LogsQueue?e():void 0,setPersistedProperty(i,r){var n;i===Le.LogsQueue&&t((n=r)!==null&&n!==void 0?n:[])},js:i=>this.js(i),getLibraryId:()=>le.LIB_NAME,getLibraryVersion:()=>le.LIB_VERSION}}js(e){return new Promise(t=>{if(Ya(this.hd,3))return void t({kind:"fatal",error:Bi(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1;const i=n=>{s||(s=!0,clearTimeout(r),t(n))},r=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:Bi(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Rp(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{const o=n.statusCode;if(this.Ap(o),o>=200&&300>o)i({kind:"ok"});else if(o===413)i({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)i({kind:"fatal",error:new Error(`logs request failed with status ${o}`)});else{var a;o===0?(n.error||this.$.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:Bi(n.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=n.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${o}`)})}}})})}Ap(e){(e!==0||this._instance.__loaded)&&(this.hd=Ka(e,this.hd,3,()=>this.$.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.")))}Ep(e){this.al.length>0&&this.Fp(e,this.al,this.gp,le.LIB_NAME,t=>{this.al=t}),this.np.length>0&&this.Fp(e,this.np,this.bp,go,t=>{this.np=t})}Fp(e,t,s,i,r){if(t.length===0)return;const n=t.map(a=>a.record);r([]);const o=pa(n,ha(s,le.LIB_NAME,le.LIB_VERSION),i,le.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Rp(),data:o,compression:"best-available",batchKey:"logs",transport:e})}Rp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}vp(){var e;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:s,windowId:i,sessionStartTimestamp:r,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=s,t.windowId=i,A(r)||(t.sessionStartTimestamp=r),A(n)||(t.lastActivityTimestamp=n)}if(!(O==null||(e=O.location)===null||e===void 0)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?nt(O.location.href):O.location.href),this._instance.featureFlags){const s=this._instance.featureFlags.getFlags();s&&s.length>0&&(t.activeFeatureFlags=s)}return t}}},dh={metrics:class{constructor(e){this._instance=e,this.$=ie("[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.Op?this.Op=(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=Zd(s,r),o=Qd(s,r);return()=>{i=!1,n(),o()}})(this._instance):!t&&this.Op&&(this.Op(),this.Op=void 0)}fp(){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.up&&this.pp===t||((s=this.up)===null||s===void 0||s.reset(),this.pp=t,this.up=new Vu(this.dp(),(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.$)),this.up}count(e,t=1,s){this.fp().count(e,t,s)}gauge(e,t,s){this.fp().gauge(e,t,s)}histogram(e,t,s){this.fp().histogram(e,t,s)}flush(e){if(!this.up)return Promise.resolve();if(e){const t=this.up.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this.up.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this.up)===null||e===void 0||e.reset()}dispose(){var e,t;this.Io=!0,(e=this.Op)===null||e===void 0||e.call(this),this.Op=void 0,(t=this.up)===null||t===void 0||t.reset()}dp(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:s=>t.Ys(s),getLibraryId:()=>le.LIB_NAME,getLibraryVersion:()=>le.LIB_VERSION}}Ys(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(v(v({method:"POST",url:this.Dp(),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}`)})}}}))})}Dp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};as.__defaultExtensionClasses=v({},v(v(v(v(v(v(v(v(v(v(v(v(v({},ii),eh),th),sh),ih),rh),oh),nh),ah),lh),uh),ch),dh));const hh=(function(){le.SDK_DIST_CHANNEL="npm";const e=ns[Yt]=new as;return(function(){function t(){t.done||(t.done=!0,wl=!1,G(ns,function(s){s._dom_loaded()}))}$?.addEventListener?$.readyState==="complete"?t():W($,"DOMContentLoaded",t,{capture:!1}):y&&E.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();var ph=hh;export{Ee as Compression,dr as DisplaySurveyType,as as PostHog,Gc as ProductTourEventName,Tn as ProductTourEventProperties,We as SurveyEventName,Si as SurveyEventProperties,Ht as SurveyEventType,Ei as SurveyType,ph as default,hh as posthog};