cozyclay 1.3.0 → 1.6.0

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 (101) hide show
  1. package/CHANGELOG.md +130 -6
  2. package/LICENSE +67 -80
  3. package/LICENSES/GPL-3.0-or-later.txt +674 -0
  4. package/LICENSING.md +32 -0
  5. package/README.md +69 -12
  6. package/THIRD_PARTY_NOTICES.md +20 -2
  7. package/bin/cozyclay.mjs +230 -88
  8. package/bin/mcp-runtime.mjs +115 -0
  9. package/bin/open-browser.mjs +10 -0
  10. package/bin/package-signature.mjs +95 -0
  11. package/bin/telemetry-state.mjs +111 -0
  12. package/bin/update-check.mjs +158 -0
  13. package/dist/ai-camera-control/index.html +4 -5
  14. package/dist/app/index.html +3 -4
  15. package/dist/assets/app-CqOk49Bk.css +1 -0
  16. package/dist/assets/app-G55dPEDB.js +4811 -0
  17. package/dist/assets/module-MzlRiBjI.js +3 -0
  18. package/dist/cozyclay-package.json +1 -0
  19. package/dist/favicon.ico +0 -0
  20. package/dist/icons/apple-touch-icon.png +0 -0
  21. package/dist/icons/icon-192.png +0 -0
  22. package/dist/icons/icon-32.png +0 -0
  23. package/dist/icons/icon-512.png +0 -0
  24. package/dist/icons/icon-maskable-512.png +0 -0
  25. package/dist/index.html +27 -23
  26. package/dist/sw.js +2 -1
  27. package/mcp/LIVE-PROTOCOL.md +93 -12
  28. package/mcp/README.md +28 -10
  29. package/mcp/ardy-prompts.mjs +96 -78
  30. package/mcp/live-hub.mjs +231 -17
  31. package/mcp/package.json +5 -2
  32. package/mcp/runtime/package-lock.json +1211 -0
  33. package/mcp/runtime/package.json +16 -0
  34. package/mcp/server.mjs +798 -184
  35. package/package.json +32 -8
  36. package/src/App.jsx +2744 -713
  37. package/src/analytics-toggle.jsx +24 -0
  38. package/src/analytics.js +386 -0
  39. package/src/ardy/motion-edit.js +172 -0
  40. package/src/ardy/pose-pin.js +97 -0
  41. package/src/ardy/root-drop.js +180 -0
  42. package/src/ardy/timeline-resize.js +3 -1
  43. package/src/ardy/timeline.jsx +362 -73
  44. package/src/ardy/waypoints.js +4 -1
  45. package/src/asset-pane.jsx +339 -21
  46. package/src/asset-shelf.js +82 -0
  47. package/src/camera-block.js +42 -0
  48. package/src/camera-follow.js +149 -27
  49. package/src/camera-move.js +45 -19
  50. package/src/camera-rail-schedule.js +6 -0
  51. package/src/cuts.js +67 -54
  52. package/src/dualview.jsx +45 -5
  53. package/src/generation/generation-request.js +17 -0
  54. package/src/generation/use-generation.js +3 -14
  55. package/src/hierarchy-model.js +5 -3
  56. package/src/live-control.js +22 -2
  57. package/src/main.jsx +2 -0
  58. package/src/mp4-muxer.js +52 -0
  59. package/src/object-gizmo.jsx +211 -16
  60. package/src/offscreen-export.js +166 -0
  61. package/src/otio.js +217 -0
  62. package/src/planview.jsx +18 -10
  63. package/src/pose-extract/detector.js +7 -2
  64. package/src/pose-extract/image-frame.js +40 -0
  65. package/src/pose-extract/index.js +2 -1
  66. package/src/pose-extract/take.js +27 -0
  67. package/src/poses.js +19 -265
  68. package/src/posestudio.jsx +82 -8
  69. package/src/project-poses.js +9 -0
  70. package/src/project.js +86 -2
  71. package/src/pwa.js +6 -0
  72. package/src/room.jsx +77 -4
  73. package/src/sample-at.js +136 -0
  74. package/src/scene-asset-cache.js +137 -96
  75. package/src/scene-assets.js +94 -4
  76. package/src/scene-objects.js +82 -19
  77. package/src/scenes.js +34 -6
  78. package/src/shot-authoring.js +65 -28
  79. package/src/shot.js +53 -13
  80. package/src/source-offer.jsx +12 -0
  81. package/src/stable-items.js +83 -0
  82. package/src/styles.css +882 -115
  83. package/src/ui.jsx +32 -4
  84. package/src/usd-camera.js +145 -0
  85. package/tools/ardy/BRIDGE.md +8 -5
  86. package/tools/ardy/README.md +15 -0
  87. package/tools/ardy/artifacts.mjs +34 -0
  88. package/tools/ardy/bridge.mjs +32 -11
  89. package/tools/ardy/extract.mjs +16 -11
  90. package/tools/ardy/footage.mjs +15 -10
  91. package/tools/ardy/runners/local.mjs +4 -1
  92. package/tools/ardy/setup-text-encoder.py +14 -4
  93. package/tools/dev-full.mjs +63 -5
  94. package/tools/generation/bridge.mjs +14 -1
  95. package/tools/metrics/archive-traffic.mjs +1 -1
  96. package/tools/metrics-snapshot.mjs +98 -0
  97. package/tools/prepare-package.mjs +50 -0
  98. package/tools/process-supervisor.mjs +108 -2
  99. package/tools/run-tests.mjs +173 -0
  100. package/dist/assets/app-B3U5aut1.js +0 -4811
  101. package/dist/assets/app-BrRF0wso.css +0 -1
@@ -0,0 +1,3 @@
1
+ var e=typeof window<`u`?window:void 0,t=typeof globalThis<`u`?globalThis:e,n=t?.navigator,r=t?.document,i=t?.location,a=t?.fetch,o=t!=null&&t.XMLHttpRequest&&`withCredentials`in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,s=t?.AbortController,c=t?.CompressionStream,l=n?.userAgent;function u(){return!(!e||!1===e.navigator.onLine)}var d=typeof globalThis<`u`?globalThis:e;d&&typeof self>`u`&&(d.self=d),d&&typeof File>`u`&&(d.File=function(){});var f=e??{},p={DEBUG:!1,LIB_VERSION:`0.5.0`,LIB_NAME:`browser-common`};function m(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){m(a,r,i,o,s,`next`,e)}function s(e){m(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g.apply(null,arguments)}function _(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var v=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function y(e){return typeof e==`string`||e}function b(e){return typeof e==`string`?e:void 0}var x,S=`$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`.split(`.`),C=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.AiQueue=`ai_queue`,e.AiCaptureQueue=`ai_capture_queue`,e.LogsQueue=`logs_queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.PushRegistered=`push_registered`,e.SessionReplayEventTriggerActivatedSession=`session_replay_event_trigger_activated_session`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e.DeviceId=`device_id`,e}({}),w=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),T=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`],E=[`token`],D=`NativeGzipValidationError`,O=e=>e.length>=2&&e[0]===31&&e[1]===139,ee=(e,t)=>e===w.GZipJS||t===w.GZipJS||t===`gzip`,te=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,ne=e=>{var t=Error(`Native gzip produced invalid output: `+e);throw t.name=D,t},re=function(){var e=h((function*(e,t){18>e.size&&ne(`too-short`);var n=new Uint8Array(yield e.slice(0,10).arrayBuffer());O(n)&&n[2]===8||ne(`invalid-header`);var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(x)return x;x=[];for(var e=0;256>e;e++){for(var t=e,n=0;8>n;n++)t=1&t?3988292384^t>>>1:t>>>1;x[e]=t>>>0}return x})(),n=4294967295,r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&ne(`invalid-crc`);var i=t.length>>>0;r.getUint32(4,!0)!==i&&ne(`invalid-size`)}));return function(t,n){return e.apply(this,arguments)}}();function k(){return k=h((function*(e,t,n){t===void 0&&(t=!0);try{var r=new TextEncoder().encode(e),i=new globalThis.CompressionStream(`gzip`),a=i.writable.getWriter(),o=a.write(r).then((()=>a.close())).catch(function(){var e=h((function*(e){try{yield a.abort(e)}catch{}throw e}));return function(t){return e.apply(this,arguments)}}()),s=new Response(i.readable).blob(),c=(yield Promise.all([s,o]))[0];return yield re(c,r),c}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}})),k.apply(this,arguments)}var ie=20,ae=1e3,oe=1e4,se=`[Circular]`,ce=`[Truncated]`,le=`[Unserializable]`,ue=`[Function]`;function A(e){for(var t=``,n=0;e.length>n;n++){var r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:`�`;else{var i=e.charCodeAt(n+1);56320>i||i>57343?t+=`�`:(t+=e[n]+e[n+1],n++)}}return t}var de=`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,pinterest,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`.split(`,`),fe=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return de.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function j(e,t){return e.indexOf(t)!==-1}var pe=function(e){return e.trim()},me=function(e){return e.replace(/^\$/,``)};function he(e){var t=[];return JSON.stringify(e,(function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n}}))??`null`}var ge=Object.prototype,_e=ge.hasOwnProperty,ve=ge.toString,M=Array.isArray||function(e){return ve.call(e)===`[object Array]`},ye=e=>typeof e==`function`,N=e=>e===Object(e)&&!M(e),be=e=>{if(N(e)){for(var t in e)if(_e.call(e,t))return!1;return!0}return!1},P=e=>e===void 0,F=e=>ve.call(e)==`[object String]`,xe=e=>F(e)&&e.trim().length===0,I=e=>e===null,L=e=>P(e)||I(e),R=e=>ve.call(e)==`[object Number]`&&e==e,Se=e=>R(e)&&e>0,Ce=e=>ve.call(e)===`[object Boolean]`,we=e=>e instanceof FormData,Te=e=>j(T,e),Ee=e=>j(E,e);function De(e){return typeof e!=`object`||!e}function Oe(e,t){return{}.toString.call(e)===`[object `+t+`]`}function ke(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 je(e,Error)}}function Ae(e){return typeof Event<`u`&&je(e,Event)}function je(e,t){try{return e instanceof t}catch{return!1}}var Me=[!0,`true`,1,`1`,`yes`],Ne=e=>j(Me,e),Pe=[!1,`false`,0,`0`,`no`];function Fe(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),R(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),Fe(i||n,t,n,r))}var Ie=class{constructor(e){this.k={},this.S=e.S,this.C=Fe(e.bucketSize,0,100,e.I),this.R=Fe(e.refillRate,0,this.C,e.I),this.A=Fe(e.refillInterval,0,864e5,e.I)}O(e,t){var n=Math.floor((t-e.lastAccess)/this.A);n>0&&(e.tokens=Math.min(e.tokens+n*this.R,this.C),e.lastAccess+=n*this.A)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.k[r];return i?this.O(i,n):this.k[r]=i={tokens:this.C,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.S)==null||t.call(this,e)),i.tokens===0)}stop(){this.k={}}},Le=`Mobile`,Re=`iOS`,ze=`Android`,Be=`Tablet`,Ve=ze+` `+Be,He=`iPad`,Ue=`Apple`,We=Ue+` Watch`,Ge=`Safari`,Ke=`BlackBerry`,qe=`Samsung`,Je=qe+`Browser`,Ye=qe+` Internet`,Xe=`Chrome`,Ze=Xe+` OS`,Qe=Xe+` `+Re,$e=`Internet Explorer`,et=$e+` `+Le,tt=`Opera`,nt=tt+` Mini`,rt=`Edge`,it=`Microsoft `+rt,at=`Firefox`,ot=at+` `+Re,st=`Nintendo`,ct=`PlayStation`,lt=`Xbox`,ut=ze+` `+Le,dt=Le+` `+Ge,ft=`Windows`,pt=ft+` Phone`,mt=`Nokia`,ht=`Ouya`,gt=`Generic`,_t=gt+` `+Le.toLowerCase(),vt=gt+` `+Be.toLowerCase(),yt=`Konqueror`,bt=`Oculus Browser`,xt=`Vivaldi`,St=`Yandex`,Ct=`Whale`,wt=`DuckDuckGo`,Tt=`Pale Moon`,Et=`Waterfox`,Dt=`Brave`,Ot=`Google Search App`,z=`(\\d+(\\.\\d+)?)`,kt=RegExp(`Version/`+z),At=new RegExp(lt,`i`),jt=RegExp(ct+` \\w+`,`i`),Mt=RegExp(st+` \\w+`,`i`),Nt=RegExp(Ke+`|PlayBook|BB10`,`i`),Pt={"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`},Ft=function(e,t,n,r){return t||=``,function(e){return e!=null&&e.brave?Dt:null}(n)||(r!=null&&r.detectGoogleSearchApp&&j(e,`GSA/`)?Ot:j(e,` OPR/`)&&j(e,`Mini`)?nt:j(e,` OPR/`)?tt:Nt.test(e)?Ke:j(e,`IE`+Le)||j(e,`WPDesktop`)?et:j(e,`OculusBrowser`)?bt:j(e,Je)?Ye:j(e,rt)||j(e,`Edg/`)?it:j(e,xt+`/`)?xt:j(e,`YaBrowser/`)?St:j(e,Ct+`/`)?Ct:j(e,wt+`/`)||j(e,`Ddg/`)?wt:j(e,`FBIOS`)?`Facebook `+Le:j(e,`UCWEB`)||j(e,`UCBrowser`)?`UC Browser`:j(e,`CriOS`)?Qe:j(e,`CrMo`)||j(e,Xe)?Xe:j(e,ze)&&j(e,Ge)?ut:j(e,`FxiOS`)?ot:j(e.toLowerCase(),yt.toLowerCase())?yt:j(e,Dt+`/`)?Dt:((e,t)=>t&&j(t,Ue)||function(e){return j(e,Ge)&&!j(e,Xe)&&!j(e,ze)}(e))(e,t)?j(e,Le)?dt:Ge:j(e,`PaleMoon/`)?Tt:j(e,Et+`/`)?Et:j(e,at)?at:j(e,`MSIE`)||j(e,`Trident/`)?$e:j(e,`Gecko`)?at:``)},It={[et]:[RegExp(`rv:`+z)],[it]:[RegExp(rt+`?\\/`+z)],[Xe]:[RegExp(`(`+Xe+`|CrMo)\\/`+z)],[Qe]:[RegExp(`CriOS\\/`+z)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+z)],[Ge]:[kt],[dt]:[kt],[tt]:[RegExp(`(Opera|OPR)\\/`+z)],[at]:[RegExp(at+`\\/`+z)],[ot]:[RegExp(`FxiOS\\/`+z)],[yt]:[RegExp(`Konqueror[:/]?`+z,`i`)],[Ke]:[RegExp(Ke+` `+z),kt],[ut]:[RegExp(`android\\s`+z,`i`)],[Ye]:[RegExp(Je+`\\/`+z)],[bt]:[RegExp(`OculusBrowser\\/`+z)],[xt]:[RegExp(xt+`\\/`+z)],[St]:[RegExp(`YaBrowser\\/`+z)],[Ct]:[RegExp(Ct+`\\/`+z)],[Dt]:[RegExp(Dt+`\\/`+z)],[wt]:[RegExp(`(DuckDuckGo|Ddg)\\/`+z)],[Tt]:[RegExp(`PaleMoon\\/`+z)],[Et]:[RegExp(Et+`\\/`+z)],[Ot]:[RegExp(`GSA\\/`+z)],[$e]:[RegExp(`(rv:|MSIE )`+z)],Mozilla:[RegExp(`rv:`+z)]},Lt=function(e,t,n,r){var i=It[Ft(e,t,n,r)];if(P(i))return null;for(var a=0;i.length>a;a++){var o=e.match(i[a]);if(o)return parseFloat(o[o.length-2])}return null},Rt=[[RegExp(lt+`; `+lt+` (.*?)[);]`,`i`),e=>[lt,e&&e[1]||``]],[new RegExp(st,`i`),[st,``]],[new RegExp(ct,`i`),[ct,``]],[Nt,[Ke,``]],[new RegExp(ft,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[pt,``];if(new RegExp(Le).test(t)&&!/IEMobile\b/.test(t))return[ft+` `+Le,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=Pt[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[ft,r]}return[ft,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[Re,[e[3],e[4],e[5]||`0`].join(`.`)]:[Re,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=P(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+ze+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+ze+`)`,`i`),e=>e&&e[2]?[ze,[e[2],e[3],e[4]||`0`].join(`.`)]:[ze,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[Ze,``]],[/Linux|debian/i,[`Linux`,``]]],zt=function(e){return Mt.test(e)?st:jt.test(e)?ct:At.test(e)?lt:new RegExp(ht,`i`).test(e)?ht:RegExp(`(`+pt+`|WPDesktop)`,`i`).test(e)?pt:/iPad/.test(e)?He:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?We:Nt.test(e)?Ke:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(mt,`i`).test(e)?mt:/(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(Le).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)?ze:Ve:RegExp(`(pda|`+Le+`)`,`i`).test(e)?_t:new RegExp(Be,`i`).test(e)&&!RegExp(Be+` pc`,`i`).test(e)?vt:``},Bt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Vt(e,t){return typeof(n=e)==`string`&&Bt.test(n)?e:t();var n}function Ht(e){return e&&e.split(`#`)[0]}function Ut(e,t){var n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}function Wt(e,t,n){return Gt.apply(this,arguments)}function Gt(){return(Gt=h((function*(e,t,n){var r;try{return yield Promise.race([e,new Promise(((e,i)=>{r=Ut((()=>{try{n?.(),e()}catch(e){i(e)}}),t)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Kt={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}},qt=Kt.info,Jt=0x8000000000000000,Yt={}.propertyIsEnumerable;function Xt(e,t){try{return $t(e,t,{ancestors:new WeakSet,remainingNodes:oe},0)}catch{return[]}}function Zt(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:ce};if(n.remainingNodes--,Ce(e))return{boolValue:e};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)};var i=BigInt(e).toString();return e>=Jt||-Jt>e?(t?.debug(`Attribute `+i+` is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if(typeof e==`string`)return{stringValue:A(e)};if(typeof e==`function`)return{stringValue:ue};if(typeof e==`symbol`)return{stringValue:String(e)};if(typeof e==`object`&&e){if(n.ancestors.has(e))return{stringValue:se};if(r>=ie)return{stringValue:ce};if(e instanceof Date){var a=e.getTime(),o=Number.isFinite(a)?e.toISOString():String(e);return{stringValue:typeof o==`string`?A(o):String(o)}}n.ancestors.add(e);try{try{var s=e.toJSON;if(typeof s==`function`)return Zt(s.call(e),t,n,r+1)}catch{}return M(e)?{arrayValue:{values:Qt(e,t,n,r+1)}}:{kvlistValue:{values:$t(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:A(String(e))}}function Qt(e,t,n,r){for(var i=[],a=Math.min(e.length,ae),o=0;a>o&&n.remainingNodes>0;o++)try{var s=o in e?e[o]:void 0;if(L(s))continue;i.push(Zt(s,t,n,r))}catch{i.push({stringValue:le})}return e.length>o&&i.push({stringValue:ce}),i}function $t(e,t,n,r){var i=[];for(var a in e)if(Yt.call(e,a)){if(i.length>=ae||0>=n.remainingNodes){t?.debug(`Attributes truncated: the value exceeds the OTLP encoder budget`);break}try{var o=e[a];if(I(o)||P(o))continue;i.push({key:A(a),value:Zt(o,t,n,r)})}catch{i.push({key:A(a),value:{stringValue:le}})}}return i}function en(e){try{return A(String(e))}catch{return le}}function tn(e,t,n){var r=Kt[e.level||`info`]||qt,i=r.text,a=r.number,o=String(Date.now())+`000000`,s={};t.distinctId&&(s.posthogDistinctId=t.distinctId),t.sessionId&&(s.sessionId=t.sessionId),t.windowId&&(s[`window.id`]=t.windowId),L(t.sessionStartTimestamp)||(s.sessionStartTimestamp=String(t.sessionStartTimestamp)),L(t.lastActivityTimestamp)||(s.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(s[`url.full`]=t.currentUrl),t.screenName&&(s[`screen.name`]=t.screenName),t.appState&&(s[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(s.feature_flags=t.activeFeatureFlags);var c=g({},s),l=e.attributes;if(l){var u=[];try{u=Object.keys(l)}catch{u=[]}for(var d of u){var f=void 0;try{f=l[d]}catch{f=le}Object.defineProperty(c,d,{value:f,enumerable:!0,writable:!0,configurable:!0})}}var p={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:a,severityText:i,body:{stringValue:en(e.body)},attributes:Xt(c,n)};return e.trace_id&&(p.traceId=e.trace_id),e.span_id&&(p.spanId=e.span_id),P(e.trace_flags)||(p.flags=e.trace_flags),p}function nn(e,t,n){return g({},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":n})}function rn(e,t,n,r){return{resourceLogs:[{resource:{attributes:Xt(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var an=class{constructor(e,t,n,r,i,a,o){a===void 0&&(a=()=>Promise.resolve()),this._instance=e,this.Di=t,this.I=n,this.tn=r,this.en=i,this.rn=a,this.nn=o,this.sn=null,this.an=0,this.ln=0,this.un=0,this.hn=0,this.dn=!1,this.vn=t.maxBufferSize,this.cn=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this.fn=t.flushIntervalMs,this.pn=t.maxBatchRecordsPerPost,this.gn=t.rateCapWindowMs,this.mn=t.maxLogsPerInterval}reset(){this.yn(),this.sn=null,this.un=0,this.hn=0,this.dn=!1,this.an=0,this.ln=0,this.pn=this.Di.maxBatchRecordsPerPost}onReconnect(){this.ln=0,this.bn()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var t=this._n(e);if(t!==null)if(t.body){if(this.wn()){var n={record:tn(t,this.tn(),this.I)};this.en((()=>this.kn(n)))}}else this.I.info(`Log was rejected in beforeSend function`)}}_n(e){var t=this.Di.beforeSend;if(!t)return e;var n=M(t)?t:[t],r=e;for(var i of n)try{var a=i(r);if(!a)return this.I.info(`Log was rejected in beforeSend function`),null;r=a}catch(e){return this.I.error(`Error in beforeSend function for log:`,e),null}return r}wn(){if(this.mn===void 0)return!0;var e=Date.now(),t=e-this.un;return this.gn>t&&t>=0||(this.un=e,this.hn=0,this.dn=!1),this.mn>this.hn?(this.hn++,!0):(this.dn||=(this.I.warn(`captureLog dropping logs: exceeded `+this.mn+` logs per `+this.gn+`ms`),!0),!1)}flush(){var e=this;return h((function*(){if(!e._instance.isDisabled)return e.sn||=e.Sn().finally((()=>{e.sn=null})),e.sn}))()}Sn(){var e=this;return h((function*(){e.yn();var t=e._instance.getPersistedProperty(C.LogsQueue)??[];if(t.length!==0)for(var n=t.length,r=0;t.length>0&&n>r;){e.an=0;var i=Math.min(t.length,e.pn),a=t.slice(0,i),o=rn(a.map((e=>e.record)),e.xn(),e.nn??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance.Cn(o);if(s.kind===`too-large`&&a.length>1)e.pn=Math.max(1,Math.floor(a.length/2)),e.I.warn(`Received 413 when sending logs batch of size `+a.length+`, reducing batch size to `+e.pn);else if(s.kind===`retry-later`||(s.kind===`too-large`?e.I.warn(`Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further.`):s.kind===`ok`&&e.Di.maxBatchRecordsPerPost>e.pn&&(e.pn=Math.min(e.Di.maxBatchRecordsPerPost,e.pn+1)),yield e.Tn(a.length),t=e._instance.getPersistedProperty(C.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}}))()}Tn(e){var t=this;return h((function*(){var n=Math.max(0,e-t.an),r=t._instance.getPersistedProperty(C.LogsQueue)??[];t._instance.setPersistedProperty(C.LogsQueue,r.slice(n)),yield t.rn()}))()}xn(){return nn(this.Di,this._instance.getLibraryId(),this._instance.getLibraryVersion())}kn(e){if(!this._instance.optedOut){var t=this._instance.getPersistedProperty(C.LogsQueue)??[];this.cn>t.length||(t.shift(),this.an++,this.I.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(C.LogsQueue,t),this.vn>t.length?this.Mn():this.bn()}}Mn(e){e===void 0&&(e=this.fn),this.En||=Ut((()=>{this.En=void 0,this.bn()}),e)}In(){var e=Math.min(Math.max(0,this.ln-1),6);return this.fn*2**e}Rn(){var e=this._instance.getPersistedProperty(C.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return h((function*(){t.yn();var n=t.flush().catch((()=>{}));e===void 0?yield n:yield Wt(n,e)}))()}flushWithTimeout(e){var t=this;return h((function*(){var n=t.flush();yield Wt(n,e,(()=>{n.catch((()=>{}))}))}))()}bn(){this.flush().then((()=>{this.ln=0}),(e=>{this.ln++,this.I.error(`PostHog logs flush failed:`,e)})).finally((()=>{!this._instance.isDisabled&&this.Rn()&&this.Mn(this.In())}))}yn(){this.En&&=(clearTimeout(this.En),void 0)}},on=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function sn(e){return String(e)+`000000`}function cn(e,t,n,r){var i=``;return r&&(i=Object.keys(r).sort().map((e=>JSON.stringify(e)+`:`+JSON.stringify(r[e]))).join(`,`)),e+`\0`+t+`\0`+(n??``)+`\0`+i}var ln=class{constructor(e,t,n){this._instance=e,this.Di=t,this.I=n,this.Pn=new Map,this.sn=null,this.An=!1,this.Fn=new Map,this.On=new Set,this.Ln=0}count(e,t,n){t===void 0&&(t=1),this.$n({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this.$n({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this.$n({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this,t=this.sn,n=function(){var n=h((function*(){t&&(yield t.catch((()=>{}))),yield e.Dn()}));return function(){return n.apply(this,arguments)}}()().finally((()=>{this.sn===n&&(this.sn=null)}));return this.sn=n,n}drainWindow(){if(this.Pn.size===0)return null;var e=this.Pn;return this.Pn=new Map,this.An=!1,this.Fn=new Map,this.On=new Set,this.Nn(e)}reset(){this.Ln++,this.yn(),this.Pn=new Map,this.sn=null,this.An=!1,this.Fn=new Map,this.On=new Set}$n(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this._n(e);if(t!==null)if(t.name&&typeof t.name==`string`)if(typeof t.value==`number`&&Number.isFinite(t.value))if(t.type===`count`&&0>t.value)this.I.warn(`Dropping count '`+t.name+`': counters are monotonic, value must be >= 0`);else{var n,r;try{n=t.attributes?g({},t.attributes):void 0,r=cn(t.type,t.name,t.unit,n)}catch(e){this.I.warn(`Dropping metric '`+t.name+`': attributes could not be serialized`,e);return}var i=this.Pn.get(r);if(!i){if(!this.qn())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.Pn.set(r,i)}var a=this.Fn.get(t.name);a===void 0?this.Fn.set(t.name,t.type):a===t.type||this.On.has(t.name)||(this.On.add(t.name),this.I.warn(`Metric name '`+t.name+`' is already used as a `+a+`; recording it as a `+t.type+` too will blend both series in charts. Use a distinct name.`)),this.jn(i,t.value),this.Mn()}else this.I.warn(`Dropping metric '`+t.name+`': value must be a finite number`);else this.I.warn(`Dropping metric with empty name`)}}qn(){return this.Di.maxSeriesPerFlush>this.Pn.size||(this.An||(this.An=!0,this.I.warn(`Metric series cap reached (`+this.Di.maxSeriesPerFlush+` per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}jn(e,t){switch(e.type){case`count`:e.total=(e.total??0)+t;break;case`gauge`:e.last=t;break;case`histogram`:e.hist||={count:0,sum:0,min:t,max:t,bucketCounts:Array(on.length+1).fill(0)};var n=e.hist;n.count+=1,n.sum+=t,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.bucketCounts[function(e,t){for(var n=0;t.length>n;n++)if(t[n]>=e)return n;return t.length}(t,on)]+=1}}_n(e){var t=this.Di.beforeSend;if(!t)return e;var n=M(t)?t:[t],r=e;for(var i of n)try{var a=i(r);if(!a)return this.I.info(`Metric was rejected in beforeSend function`),null;r=a}catch(e){return this.I.error(`Error in beforeSend function for metric:`,e),null}return r}Mn(){this.En||=Ut((()=>{this.En=void 0,this.flush().catch((e=>{this.I.error(`Metrics flush failed:`,e)}))}),this.Di.flushIntervalMs)}yn(){this.En&&=(clearTimeout(this.En),void 0)}Dn(){var e=this;return h((function*(){if(e.Pn.size!==0){var t=e.Pn;e.Pn=new Map,e.An=!1,e.Fn=new Map,e.On=new Set;var n=e.Ln,r=yield e._instance.Bn(e.Nn(t));if(n===e.Ln)switch(r.kind){case`ok`:return;case`retry-later`:e.Hn(t),e.Mn();return;case`too-large`:e.I.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e.I.error(`Failed to send metrics batch:`,r.error);return}}}))()}Nn(e){return t=this.Un(e),n=function(e,t,n){return g({},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":n})}(this.Di,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Xt(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}Un(e){var t=sn(Date.now()),n=new Map;for(var r of e.values()){var i=cn(r.type,r.name,r.unit,void 0),a=n.get(i);a||(a=g({name:r.name},r.unit&&{unit:r.unit}),r.type===`count`?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type===`gauge`?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},n.set(i,a));var o=Xt(r.attributes??{},this.I),s=sn(r.windowStartMs);if(r.type===`count`){var c={attributes:o,startTimeUnixNano:s,timeUnixNano:t,asDouble:r.total??0};a.sum.dataPoints.push(c)}else if(r.type===`gauge`){var l={attributes:o,timeUnixNano:t,asDouble:r.last??0};a.gauge.dataPoints.push(l)}else r.hist&&a.histogram.dataPoints.push({attributes:o,startTimeUnixNano:s,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:on})}return Array.from(n.values())}Hn(e){for(var t of e){var n=t[0],r=t[1],i=this.Pn.get(n);if(i)switch(i.windowStartMs=Math.min(i.windowStartMs,r.windowStartMs),i.type){case`count`:i.total=(i.total??0)+(r.total??0);break;case`gauge`:break;case`histogram`:if(r.hist)if(i.hist){i.hist.count+=r.hist.count,i.hist.sum+=r.hist.sum,i.hist.min=Math.min(i.hist.min,r.hist.min),i.hist.max=Math.max(i.hist.max,r.hist.max);for(var a=0;i.hist.bucketCounts.length>a;a++)i.hist.bucketCounts[a]+=r.hist.bucketCounts[a]}else i.hist=r.hist}else this.qn()&&this.Pn.set(n,r)}}},un,dn,fn;function pn(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return fn&&n.length===dn||(dn=n.length,fn=n.reduce(((n,r)=>{un||={};var i=un[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,un[r]=[s,c];break}}return n}),{})),fn}}var mn=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return h((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&M(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),g({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return h((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,g({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:pn(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return g({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},hn=`?`;function gn(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?hn:n,in_app:!(t!=null&&t.startsWith(`webkit-masked-url://`))&&t!==`<anonymous>`};return P(r)||(a.lineno=r),P(i)||(a.colno=i),a}var _n=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?hn:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},vn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,yn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,bn=/\((\S*)(?::(\d+))(?::(\d+))\)/,xn=(e,t)=>{var n=vn.exec(e);if(n)return gn(t,n[1],hn,+n[2],+n[3]);var r=yn.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){var i=bn.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}var a=_n(r[1]||hn,r[2]);return gn(t,a[1],a[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Sn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Cn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wn=(e,t)=>{var n=Sn.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=Cn.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||hn,o=_n(a,i);return gn(t,i=o[1],a=o[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Tn=/\(error: (.*)\)/,En=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=F(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return Oe(e,`DOMException`)}isDOMError(e){return Oe(e,`DOMError`)}},Dn=class{match(e){return ke(e)}coerce(e,t){var n=this.getStack(e),r=n===void 0;return{type:this.getType(e),value:this.getMessage(e,t),stack:n??t.syntheticException?.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},On=class{constructor(){}match(e){return!!Oe(e,`ErrorEvent`)&&(e.error!=null||this.di(e))}coerce(e,t){if(e.error!=null)return t.apply(e.error);var n=t.apply(e.message);return g({},n,{stack:this.vi(e)??n.stack,synthetic:!0})}di(e){return F(e.message)&&e.message.length>0}vi(e){var t=e,n=t.lineno??0,r=t.colno??0;if(F(t.filename)&&t.filename.length!==0&&n!==0)return`Error
2
+ at `+t.filename+`:`+n+`:`+r}},kn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,An=class{match(e){return typeof e==`string`}coerce(e,t){var n=this.getInfos(e),r=n[0],i=n[1];return{type:r??`Error`,value:i??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(kn);return r&&(t=r[1],n=r[2]),[t,n]}},jn=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Mn(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var Nn=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:this.getStack(e)??t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){if(Ae(e))return e.constructor.name;var t=`name`in e?e.name:void 0;return F(t)&&!xe(t)?t:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+Mn(e)}isSeverityLevel(e){return F(e)&&!xe(e)&&jn.indexOf(e)>=0}getStack(e){try{return F(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:F(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(ke(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Pn=class{match(e){return Ae(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+Mn(e),stack:t.syntheticException?.stack,synthetic:!0}}},Fn=class{match(e){return De(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},In=class{match(e){return Oe(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ae(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return De(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}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}},Ln=`$message`,Rn=`$timestamp`,zn=new Set([Ln,Rn]),Bn={enabled:!0,max_bytes:32768};function Vn(e){return e?{enabled:e.enabled??Bn.enabled,max_bytes:Un(e.max_bytes,Bn.max_bytes)}:g({},Bn)}var Hn=class{constructor(e){this.zn=[],this.Wn=0,this.Di=Vn(e)}setConfig(e){this.Di=Vn(e),this.Vn()}add(e){var t=function(e){var t;try{t=he(e)}catch{return}try{var n=JSON.parse(t);if(!N(n))return;var r=n,i=r[Ln],a=r[Rn];return!F(i)||i.trim().length===0||!F(a)&&!R(a)?void 0:{step:r,json:t}}catch{return}}(e);if(t){var n=function(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e).length;for(var t=encodeURIComponent(e),n=0,r=0;t.length>r;r++)t[r]===`%`?(n+=1,r+=2):n+=1;return n}(t.json);n>this.Di.max_bytes||(this.zn.push({step:t.step,bytes:n}),this.Wn+=n,this.Vn())}}getAttachable(){return this.zn.map((e=>e.step))}clear(){this.zn=[],this.Wn=0}size(){return this.zn.length}Vn(){for(;this.Wn>this.Di.max_bytes&&this.zn.length>0;){var e=this.zn.shift();e&&(this.Wn-=e.bytes)}}};function Un(e,t){if(!R(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var Wn=function(t,n){var r=(n===void 0?{}:n).debugEnabled,i={F(n){if(e&&(p.DEBUG||e.POSTHOG_DEBUG||r)&&!P(e.console)&&e.console){for(var i=(`__rrweb_original__`in e.console[n])?e.console[n].__rrweb_original__:e.console[n],a=arguments.length,o=Array(a>1?a-1:0),s=1;a>s;s++)o[s-1]=arguments[s];i(t,...o)}},debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.F(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.F(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.F(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.F(`error`,...t)},critical(){for(var e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];console.error(t,...n)},uninitializedWarning(e){i.error(`You must initialize PostHog before calling `+e)},createLogger:(e,n)=>Wn(t+` `+e,n)};return i},B=Wn(`[PostHog.js]`),V=B.createLogger,Gn=V(`[ExternalScriptsLoader]`),Kn=e=>{var t=r?.querySelectorAll(`script`);if(t){for(var n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute(`src`)===e)return t[n]}},qn=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Gn.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var i=Kn(t);if(i){if(i.__posthog_loading_callback_fired)return n();var a=i.__posthog_loading_error;return a?n(a):(i.addEventListener(`load`,(e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)})),void i.addEventListener(`error`,(e=>{i.__posthog_loading_error=e,n(e)})))}var o=()=>{if(!r)return n(`document not found`);if(Kn(t))return qn(e,t,n);var i=r.createElement(`script`);if(i.type=`text/javascript`,i.crossOrigin=`anonymous`,i.src=t,i.onload=e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)},i.onerror=e=>{i.__posthog_loading_error=e,n(e)},e.config.prepare_external_dependency_script&&(i=e.config.prepare_external_dependency_script(i)),!i)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)r.head.appendChild(i);else{var a,o=r.querySelectorAll(`body > script`);o.length>0?(a=o[0].parentNode)==null||a.insertBefore(i,o[0]):r.body.appendChild(i)}};r!=null&&r.body?o():r?.addEventListener(`DOMContentLoaded`,o)},Jn={},Yn=(e,t)=>{var n=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var r=3e5;n=n+`&t=`+Math.floor(Date.now()/r)*r}return e.requestRouter.endpointFor(`assets`,n)};f.__PosthogExtensions__=f.__PosthogExtensions__||{},f.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r=e.config.strict_script_versioning;if(r){var i=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`),a=Jn[i];if(r===`fallback`&&a){if(Kn(a))return void qn(e,a,n);delete Jn[i]}qn(e,i,r===`fallback`?(r,a)=>{if(r)if(typeof r==`string`)n(r);else{var o,s=Yn(e,t);Jn[i]=s;var c=Kn(i);c==null||(o=c.parentNode)==null||o.removeChild(c),qn(e,s,n)}else n(void 0,a)}:n)}else qn(e,Yn(e,t),n)}else qn(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},f.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{qn(e,e.requestRouter.endpointFor(`api`,t),n)},p.DEBUG=!1,p.LIB_VERSION=`1.418.12`,p.LIB_NAME=`web`;var Xn=`$people_distinct_id`,Zn=`distinct_id`,Qn=`$device_id`,$n=`$device_model`,er=`__alias`,tr=`__timers`,nr=`$autocapture_disabled_server_side`,rr=`$heatmaps_enabled_server_side`,ir=`$exception_capture_enabled_server_side`,ar=`$error_tracking_suppression_rules`,or=`$error_tracking_capture_extension_exceptions`,sr=`$web_vitals_enabled_server_side`,cr=`$dead_clicks_enabled_server_side`,lr=`$product_tours_enabled_server_side`,ur=`$web_vitals_allowed_metrics`,dr=`$session_recording_remote_config`,fr=`$replay_sample_rate`,pr=`$replay_override_sampling`,mr=`$replay_override_linked_flag`,hr=`$replay_override_url_trigger`,gr=`$replay_override_event_trigger`,_r=`$sesid`,vr=`$session_is_sampled`,yr=`$enabled_feature_flags`,br=`$active_feature_flags`,xr=`$early_access_features`,Sr=`$feature_flag_details`,Cr=`$feature_flag_payloads`,wr=`$feature_flag_request_id`,Tr=`$minimal_flag_called_events`,Er=`$override_feature_flags`,Dr=`$override_feature_flag_payloads`,Or=`$stored_person_properties`,kr=`$stored_group_properties`,Ar=`$groups`,jr=`$surveys`,Mr=`$surveys_loaded_at`,Nr=`$surveys_activated`,Pr=`$surveys_activated_session`,Fr=`$surveys_activated_timestamps`,Ir=`ph_product_tours`,Lr=`$flag_call_reported`,Rr=`$flag_call_reported_session_id`,zr=`$feature_flag_errors`,Br=`$feature_flag_evaluated_at`,H=`$user_state`,Vr=`$client_session_props`,Hr=`$capture_rate_limit`,Ur=`$initial_campaign_params`,Wr=`$initial_referrer_info`,Gr=`$initial_person_info`,Kr=`$epp`,qr=`$posthog_cookieless`,Jr=`$cookieless_mode`,Yr=`$sdk_debug_extensions_init_method`,Xr=`$sdk_debug_extensions_init_time_ms`,Zr=`$sdk_debug_recording_script_not_loaded`,Qr=`PostHog loadExternalDependency extension not found.`,$r=`on_reject`,ei=`always`,U=`anonymous`,W=`identified`,ti=`identified_only`,ni=`visibilitychange`,ri=`beforeunload`,ii=`$pageview`,ai=`$pageleave`,oi=`$identify`,si=`$groupidentify`;function ci(e,t){M(e)&&e.forEach(t)}function G(e,t){if(!L(e))if(M(e))e.forEach(t);else if(we(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)_e.call(e,n)&&t(e[n],n)}var K=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function li(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var ui=function(e){try{return e()}catch{return}},di=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){B.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),B.critical(e)}}},fi=function(e){var t={};return G(e,(function(e,n){(F(e)&&e.length>0||R(e))&&(t[n]=e)})),t},pi=[`herokuapp.com`,`vercel.app`,`netlify.app`];function mi(e){var t=e?.hostname;if(!F(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of pi)if(n===r)return!1;return!0}function q(e,t,n,r){var i=r??{},a=i.capture,o=i.passive;e?.addEventListener(t,n,{capture:a!==void 0&&a,passive:o===void 0||o})}function hi(e){return e.name===`ph_toolbar_internal`}var gi=e=>{if(r){try{for(var t=e+`=`,n=r.cookie.split(`;`).filter((e=>e.length)),i=0;n.length>i;i++){for(var a=n[i];a.charAt(0)==` `;)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.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 R(e)&&isFinite(e)&&Math.floor(e)===e});var _i=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},vi=class{generate(){var e=this.generateOrAbort();if(!P(e))return e;this.Rr=0;var t=this.generateOrAbort();if(P(t))throw Error(`Could not generate UUID after timestamp reset`);return t}generateOrAbort(){var e=Date.now();if(e>this.Rr)this.Rr=e,this.Ar();else{if(this.Rr>=e+1e4)return;this.Lr++,this.Lr>4398046511103&&(this.Rr++,this.Ar())}return _i.fromFieldsV7(this.Rr,Math.trunc(this.Lr/2**30),this.Lr&2**30-1,this.Or.nextUint32())}Ar(){this.Lr=1024*this.Or.nextUint32()+(1023&this.Or.nextUint32())}constructor(){this.Rr=0,this.Lr=0,this.Or=new xi}},yi,bi=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!P(e.crypto)&&crypto.getRandomValues&&(bi=e=>crypto.getRandomValues(e));var xi=class{nextUint32(){return this.ft.length>this.Fr||(bi(this.ft),this.Fr=0),this.ft[this.Fr++]}constructor(){this.ft=new Uint32Array(8),this.Fr=1/0}},Si=()=>Ci().toString(),Ci=()=>(yi||=new vi).generate(),wi=``,Ti=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,J={Nr:()=>!!r,jr(e){B.error(`cookieStore error: `+e)},Pr:gi,Br(e){var t;try{t=JSON.parse(J.Pr(e))||{}}catch{}return t},Dr(e,t,n,i,a){if(!r)return!1;try{var o=``,s=``,c=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=r),wi)return wi;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),i=Math.min(n.length,8),a=`dmn_chk_`+Si();!wi&&i--;){var o=n.slice(i).join(`.`),s=a+`=1;domain=.`+o+`;path=/`;t.cookie=s+`;max-age=3`,t.cookie.includes(a)&&(t.cookie=s+`;max-age=0`,wi=o)}return wi}(e);if(!n){var i=(e=>{var t=e.match(Ti);return t?t[0]:``})(e);i!==n&&B.info(`Warning: cookie subdomain discovery mismatch`,i,n),n=i}return n?`; domain=.`+n:``}return``}(r.location.hostname,i);if(n){var l=new Date;l.setTime(l.getTime()+864e5*n),o=`; expires=`+l.toUTCString()}a&&(s=`; secure`);var u=e+`=`+encodeURIComponent(JSON.stringify(t))+o+`; SameSite=Lax; path=/`+c+s;return u.length>3686.4&&B.warn(`cookieStore warning: large cookie, len=`+u.length),r.cookie=u,!0}catch{return!1}},qr(e,t){if(r!=null&&r.cookie)try{J.Dr(e,``,-1,t)}catch{return}}},Ei=null,Y={Nr(){if(!I(Ei))return Ei;var t=!0;if(P(e))t=!1;else try{var n=`__mplssupport__`;Y.Dr(n,`xyz`),Y.Pr(n)!==`"xyz"`&&(t=!1),Y.qr(n)}catch{t=!1}return t||B.error(`localStorage unsupported; falling back to cookie store`),Ei=t,t},jr(e){B.error(`localStorage error: `+e)},Pr(t){try{return e?.localStorage.getItem(t)}catch(e){Y.jr(e)}return null},Br(e){try{return JSON.parse(Y.Pr(e))||{}}catch{}return null},Dr(t,n){try{return e?.localStorage.setItem(t,JSON.stringify(n)),!0}catch(e){Y.jr(e)}return!1},qr(t){try{e?.localStorage.removeItem(t)}catch(e){Y.jr(e)}}},Di=[Or,br,yr,Sr,Cr,wr,Br,zr,Lr],Oi=[Qn,Zn,_r,vr,Kr,Gr,H],ki=e=>e+`_cpm`,Ai=[`__proto__`,`constructor`,`prototype`],ji=e=>{if(!N(e))return{};var t={};return Object.keys(e).forEach((n=>{Ai.indexOf(n)===-1&&(t[n]=e[n])})),t},Mi=function(e,t){t===void 0&&(t=[]);var n={};return[...Oi,...t].forEach((t=>{var r=e[t];P(r)||I(r)||r===``||(n[t]=r)})),n},Ni=e=>{for(var t=5381,n=2166136261,r=0;e.length>r;r++){var i=e.charCodeAt(r);t=33*t^i,n=Math.imul(n^i,16777619)}return e.length.toString(36)+`.`+(t>>>0).toString(36)+`.`+(n>>>0).toString(36)},Pi=(e,t)=>({p:t,f:Ni(JSON.stringify(e))}),Fi=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var n=J.Br(ki(e)),r=n?.f===Ni(t)&&M(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},Ii=(e,t)=>t+`|`+(J.Pr(ki(e))||``),Li={},Ri={Nr:()=>!0,jr(e){B.error(`memoryStorage error: `+e)},Pr:e=>Li[e]||null,Br:e=>Li[e]||null,Dr:(e,t)=>(Li[e]=t,!0),qr(e){delete Li[e]}},zi=null,X={Nr(){if(!I(zi))return zi;if(zi=!0,P(e))zi=!1;else try{var t=`__support__`;X.Dr(t,`xyz`),X.Pr(t)!==`"xyz"`&&(zi=!1),X.qr(t)}catch{zi=!1}return zi},jr(e){B.error(`sessionStorage error: `,e)},Pr(t){try{return e?.sessionStorage.getItem(t)}catch(e){X.jr(e)}return null},Br(e){try{return JSON.parse(X.Pr(e))||null}catch{}return null},Dr(t,n){try{return e?.sessionStorage.setItem(t,JSON.stringify(n)),!0}catch(e){X.jr(e)}return!1},qr(t){try{e?.sessionStorage.removeItem(t)}catch(e){X.jr(e)}}},Bi=class{constructor(e){this._instance=e}get Di(){return this._instance.config}get consent(){return this.Gn()?0:this.Zn}isOptedOut(){return this.Di.cookieless_mode===ei||this.isRejected()||this.consent===-1&&this.Di.cookieless_mode===$r}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Di.opt_out_capturing_by_default}optInOut(e){this.Qn.Dr(this.Jn,+!!e,this.Di.cookie_expiration,this.Di.cross_subdomain_cookie,this.Di.secure_cookie)}reset(){this.Qn.qr(this.Jn,this.Di.cross_subdomain_cookie)}get Jn(){var e=this._instance.config,t=e.token,n=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(n?n+t:`__ph_opt_in_out_`+t)}get Zn(){var e=this.Qn.Pr(this.Jn);return Ne(e)?1:j(Pe,e)?0:-1}get Qn(){var e=this.Di.opt_out_capturing_persistence_type,t=e===`localStorage`?Y:J;if(!this.Kn||this.Kn!==t){this.Kn=t;var n=e===`localStorage`?J:Y;n.Pr(this.Jn)&&(this.Kn.Pr(this.Jn)||this.optInOut(Ne(n.Pr(this.Jn))),n.qr(this.Jn,this.Di.cross_subdomain_cookie))}return this.Kn}Gn(){return!!this.Di.respect_dnt&&[n?.doNotTrack,n?.msDoNotTrack,f.doNotTrack].some((e=>Ne(e)))}};function Vi(e,t){var n,r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!ye(r))return t;try{var i=r(t);return F(i)&&i?i:t}catch(e){return B.error(`Error in get_current_url, falling back to window.location.href`,e),t}}var Hi=`__POSTHOG_TOOLBAR__`,Ui=1,Wi=3,Gi=11;function Ki(e){return e instanceof Element&&(e.id===Hi||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function qi(e){return!!e&&e.nodeType===Ui}function Ji(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Yi(e){return!!e&&e.nodeType===Wi}function Xi(e){return!!e&&e.nodeType===Gi&&qi(e.host)}var Zi=1e3;function Qi(e){return e?pe(e).split(/\s+/):[]}function $i(t,n){var r=function(t){var n,r=e==null||(n=e.location)==null?void 0:n.href;return P(r)?void 0:Vi(t,r)}(n);return!!(r&&t&&t.some((e=>r.match(e))))}function ea(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return Qi(t)}function ta(e){return L(e)?null:pe(e).split(/(\s+)/).filter((e=>Ta(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function na(e){var t=``;return ga(e)&&!_a(e)&&e.childNodes&&e.childNodes.length&&G(e.childNodes,(function(e){Yi(e)&&e.textContent&&(t+=ta(e.textContent)??``)})),pe(t)}function ra(e){var t;return P(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var ia=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function aa(e,t){if(P(t))return!0;var n,r=function(e){if(t.some((t=>function(e,t){var n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}(e,t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function oa(e){var t=e.parentNode;return!(!t||!qi(t))&&t}var sa=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],ca=[`next`,`previous`,`prev`,`>`,`<`],la=[...ca,`+`,`-`,`−`,`–`],ua=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,da=[`.ph-no-rageclick`,`.ph-no-capture`],fa=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function pa(t,n){if(!e||ma(t))return!1;var r,i,a,o;if(Ce(n)?(r=!!n&&da,i=void 0,a=!1):(r=n?.css_selector_ignorelist??da,i=n?.content_ignorelist,a=(o=n?.ignore_text_selection)!=null&&o),!1===r||a&&function(e){return!(!e||!qi(e))&&(!!Ji(e,`textarea`)||(Ji(e,`input`)?j(fa,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=e.getAttribute==null?void 0:e.getAttribute(`contenteditable`);return t===`true`||t===``}(e)))}(t))return!1;var s=ha(t,!1).targetElementList;return!function(e,t){if(!1===e||P(e))return!1;var n;if(!0===e)n=ca;else{if(!M(e))return!1;if(e.length>10)return B.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var t=e.safeText,r=e.ariaLabel;return n.some((e=>ua(t,e)||ua(r,e)))}))}(i,s.map((e=>({safeText:na(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!aa(s,r)}var ma=e=>!e||Ji(e,`html`)||!qi(e),ha=(t,n)=>{if(!e||ma(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,i=[t],a=t;a.parentNode&&!Ji(a,`body`);)if(Xi(a.parentNode))i.push(a.parentNode.host),a=a.parentNode.host;else{var o=oa(a);if(!o)break;if(n||ia.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var s=e.getComputedStyle(o);s&&s.getPropertyValue(`cursor`)===`pointer`&&(r=!0)}catch{}i.push(o),a=o}return{parentIsUsefulElement:r,targetElementList:i}};function ga(e){for(var t=new Set,n=0,r=e;r.parentNode&&!Ji(r,`body`);r=r.parentNode){if(n++>=Zi||t.has(r))return!1;t.add(r);var i=ea(r);if(j(i,`ph-sensitive`)||j(i,`ph-no-capture`))return!1}if(j(ea(e),`ph-include`))return!0;var a=e.type||``;if(F(a))switch(a.toLowerCase()){case`hidden`:case`password`:return!1}var o=e.name||e.id||``;return!F(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,``))}function _a(e){return!!(Ji(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Ji(e,`select`)||Ji(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var va=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}))$`),ya=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,ba=[16,15,14,13],xa=RegExp(`^(\\d{3}-?\\d{2}-?\\d{4})$`),Sa=RegExp(`(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))`,`g`),Ca=/[0-9A-Za-z_]/;function wa(e){for(var t=0,n=!1,r=e.length-1;r>=0;r--){var i=e.charCodeAt(r)-48;n&&(i*=2)>9&&(i-=9),t+=i,n=!n}return t%10==0}function Ta(e,t){return t===void 0&&(t=!0),!(L(e)||F(e)&&(e=pe(e),(t?va.test((e||``).replace(/[- ]/g,``)):function(e){var t;for(ya.lastIndex=0;t=ya.exec(e);){var n=t[2];if(n)for(var r=n.replace(/[- ]/g,``),i=0;r.length>i;i++)for(var a of ba){var o=i+a;if(r.length>=o){var s=r.slice(i,o);if(va.test(s)&&wa(s))return!0}}}return!1}(e))||(t?xa.test(e):function(e){var t;for(Sa.lastIndex=0;t=Sa.exec(e);){var n=t[1],r=t[3];if(!(n&&r&&Ca.test(n)&&Ca.test(r)))return!0}return!1}(e))))}function Ea(e){var t=na(e);return Ta(t=(t+` `+Da(e)).trim())?t:``}function Da(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&G(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=na(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+Da(e)).trim())}catch(e){B.error(`[AutoCapture]`,e)}})),t}function Oa(e){return e.replace(/"|\\"/g,`\\"`)}function ka(e){var t=e.attr__class;if(t)return M(t)?t:Qi(t)}var Aa=V(`[Dead Clicks]`),ja=()=>!0,Ma=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(cr)),r=e.instance.config.capture_dead_clicks;return Ce(r)?r:!!N(r)||n},Na=class{get lazyLoadedDeadClicksAutocapture(){return this.Yn}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;`captureDeadClicks`in t&&(this.instance.persistence&&this.instance.persistence.register({[cr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Xn((()=>{this.ts()})):this.stop()}Xn(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?Aa.error(`failed to load script`,t):e()}))}ts(){var e;if(r){if(!this.Yn&&(e=f.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=N(this.instance.config.capture_dead_clicks)?g({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Yn=f.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Yn.start(r),Aa.info(`starting...`)}}else Aa.error("`document` not found. Cannot start.")}stop(){this.Yn&&(this.Yn.stop(),this.Yn=void 0,Aa.info(`stopping...`))}},Pa=V(`[SegmentIntegration]`),Fa=`posthog-js`;function Ia(e,t){var n=t===void 0?{}:t,r=n.organization,i=n.projectId,a=n.prefix,o=n.severityAllowList,s=o===void 0?[`error`]:o,c=n.sendExceptionsToPostHog,l=c===void 0||c;return t=>{if(s!==`*`&&!s.includes(t.level)||!e.__loaded)return t;t.tags||={};var n=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=n,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var o,c=t.exception?.values||[],u=c.map((e=>g({},e,{stacktrace:e.stacktrace?g({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>g({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:c[0]?.value||t.message,$exception_type:c[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:c[0]?.value||t.message,$sentry_exception_type:c[0]?.type,$sentry_tags:t.tags};return r&&i&&(d.$sentry_url=(a||`https://sentry.io/organizations/`)+r+`/issues/?project=`+i+`&query=`+t.event_id),l&&((o=e.exceptions)==null||o.sendExceptionEvent(d)),t}}var La=class{constructor(e,t,n,r,i,a){this.name=Fa,this.setupOnce=function(o){o(Ia(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},Ra=class{constructor(e){this.es=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(B.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.rs=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.ns()}ns(){this.ss=this._instance.sessionManager?.onSessionId(this.es)}destroy(){var e;(e=this.ss)==null||e.call(this),this.ss=void 0}doPageView(t,n){var r=this.os(t,n);return this.rs={pathname:e?.location.pathname??``,pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(e){return this.os(e,this.rs?.pageViewId)}doEvent(){return{$pageview_id:this.rs?.pageViewId}}os(e,t){var n=this.rs;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var a=i.maxScrollHeight,o=i.lastScrollY,s=i.maxScrollY,c=i.maxContentHeight,l=i.lastContentY,u=i.maxContentY;if(!(P(a)||P(o)||P(s)||P(c)||P(l)||P(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?Fe(o/a,0,1,B):1,f=a>1?Fe(s/a,0,1,B):1,p=c>1?Fe(l/c,0,1,B):1,m=c>1?Fe(u/c,0,1,B):1;r=K(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},za=[`flags`,`surveys`],Ba={[Xn]:{exposure:`hidden`},[er]:{exposure:`hidden`},__cmpns:{exposure:`hidden`},[tr]:{exposure:`hidden`},[nr]:{exposure:`event`},[rr]:{exposure:`hidden`},[ir]:{exposure:`event`},[ar]:{exposure:`hidden`},[or]:{exposure:`event`},[sr]:{exposure:`event`},[cr]:{exposure:`event`},[lr]:{exposure:`hidden`},[ur]:{exposure:`event`},[dr]:{exposure:`hidden`},$session_recording_enabled_server_side:{exposure:`hidden`},[_r]:{exposure:`hidden`},[vr]:{exposure:`event`},[fr]:{exposure:`event`,shouldSkipFromEventProperties:e=>I(e)},$session_past_minimum_duration:{exposure:`event`},$session_recording_url_trigger_activated_session:{exposure:`event`},$session_recording_event_trigger_activated_session:{exposure:`event`},$debug_first_full_snapshot_timestamp:{exposure:`event`},$sess_rec_flush_size:{exposure:`hidden`},[yr]:{exposure:`hidden`,storageGroup:`flags`},[br]:{exposure:`hidden`,storageGroup:`flags`},[xr]:{exposure:`hidden`},[Sr]:{exposure:`hidden`,storageGroup:`flags`},[Cr]:{exposure:`hidden`,storageGroup:`flags`},[wr]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[Tr]:{exposure:`hidden`,storageGroup:`flags`},[Er]:{exposure:`hidden`},[Dr]:{exposure:`hidden`},[Or]:{exposure:`hidden`},[kr]:{exposure:`hidden`},[jr]:{exposure:`hidden`,storageGroup:`surveys`},[Mr]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[Nr]:{exposure:`event`},[Pr]:{exposure:`hidden`},[Fr]:{exposure:`hidden`},[Ir]:{exposure:`hidden`},$product_tours_activated:{exposure:`hidden`},$product_tours_activated_session:{exposure:`hidden`},$conversations_widget_session_id:{exposure:`event`},$conversations_ticket_id:{exposure:`event`},$conversations_widget_state:{exposure:`event`},$conversations_user_traits:{exposure:`event`},[Lr]:{exposure:`hidden`},[Rr]:{exposure:`hidden`},[Ar]:{exposure:`event`},[zr]:{exposure:`hidden`},[Br]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[H]:{exposure:`hidden`},[Vr]:{exposure:`hidden`},[Hr]:{exposure:`hidden`},[Ur]:{exposure:`hidden`},[Wr]:{exposure:`hidden`},[Gr]:{exposure:`hidden`},[Kr]:{exposure:`hidden`},[pr]:{exposure:`event`},[mr]:{exposure:`event`},[hr]:{exposure:`event`},[gr]:{exposure:`event`},[Yr]:{exposure:`event`},[Xr]:{exposure:`event`},[Zr]:{exposure:`event`},$sdk_debug_replay_event_trigger_status:{exposure:`event`},$sdk_debug_replay_linked_flag_trigger_status:{exposure:`event`},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:`event`},$sdk_debug_replay_pending_trigger_conditions:{exposure:`event`},$sdk_debug_replay_remote_trigger_matching_config:{exposure:`event`},$sdk_debug_replay_trigger_groups_count:{exposure:`event`},$sdk_debug_replay_url_trigger_status:{exposure:`event`},$session_recording_start_reason:{exposure:`event`}},Va=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],Ha=e=>{var t=Ba[e];if(t)return t;for(var n of Va){var r=n[1];if(e.indexOf(n[0])===0)return r}},Ua=(e,t)=>{try{return JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t)}catch{return he(e)}},Wa=e=>{var t=r?.createElement(`a`);return P(t)?null:(t.href=e,t)},Ga=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!M(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{B.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},Ka=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);M(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},qa=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},Ja=(e,t)=>e>=t&&u(),Ya=(e,t,n,r)=>{if(e===0){if(u()){var i=t+1;return i===n&&r(),i}return t}return 0},Xa=`https?://(.*)`,Za=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Qa=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Za],$a=`<masked>`,eo=[`li_fat_id`];function to(e,t,n){if(!r)return{};var i,a=t?[...Za,...n||[]]:[],o=no(Ka(r.URL,a,$a),e);return K((i={},G(eo,(function(e){var t=gi(e);i[e]=t||null})),i),o)}function no(e,t){var n=Qa.concat(t||[]),r={};return G(n,(function(t){r[t]=Ga(e,t)||null})),r}function ro(e){var t=function(e){return e?e.search(Xa+`google.([^/?]*)`)===0?`google`:e.search(Xa+`bing.com`)===0?`bing`:e.search(Xa+`yahoo.com`)===0?`yahoo`:e.search(Xa+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,i={};if(!I(t)){i.$search_engine=t;var a=r?Ga(r.referrer,n):``;a.length&&(i.ph_keyword=a)}return i}function io(){return navigator.language||navigator.userLanguage}var ao=`$direct`;function oo(){return r?.referrer||ao}function so(e,t,n){n===void 0&&(n=!1);var r=e?[...Za,...t||[]]:[],a=(n?Ht(i?.href):i?.href)?.substring(0,1e3);return{r:oo().substring(0,1e3),u:a?Ka(a,r,$a):void 0}}function co(e,t){t===void 0&&(t=!1);var n=e.r,r=e.u,i=t?Ht(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==ao?ao:Wa(n)?.host};if(i){a.$current_url=i;var o=Wa(i);a.$host=o?.host,a.$pathname=o?.pathname,K(a,no(i))}return n&&K(a,ro(n)),a}function lo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function uo(){try{return new Date().getTimezoneOffset()}catch{return}}var fo={flags:Br,surveys:Mr},po=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],mo=e=>e+`_cookie_identity_change_pending`,ho=`main`,go=(e,t)=>{G(e,((n,r)=>{var i=Ha(r);i&&i.exposure!==`event`||{}.hasOwnProperty.call(t,r)||delete e[r]}))},_o=class{constructor(t,n,r){if(r===void 0&&(r=!0),this.ls={},this.us=!1,this.hs=!1,this.ds=!1,this.vs=!1,this.Di=t,this.cs=r,this.props={},this.fs=void 0,this.ps=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(t),this.Qn=this.gs(t),this.hs=this.ys(t),this.load(),t.debug&&B.info(`Persistence loaded`,t.persistence,g({},this.props)),this.update_config(t,t,n),this.save(),e){var i=()=>this.flush();q(e,`beforeunload`,i,{capture:!1}),q(e,`pagehide`,i,{capture:!1})}}bs(){var e=this.Di?.persistence_save_debounce_ms;return R(e)&&e>0?e:0}_s(e){if(this.Di.cookieWinsOnConflict&&this.Di.persistence.toLowerCase()===`localstorage+cookie`)if(e)try{var t=Mi(e,this.Di.cookie_persisted_properties||[]),n=Pi(t,this.Di.cookie_persisted_properties||[]),r=JSON.stringify(t)+`|`+JSON.stringify(n),i=J.Pr(this.ps)||void 0;i&&Ii(this.ps,i)===r&&(this.ws=r,this.ks=i)}catch{}else try{var a=J.Pr(this.ps)||void 0;this.ws=a?Ii(this.ps,a):void 0,this.ks=a}catch{}}syncCookieProperties(){return this.Ss(this.Di)}Ss(e,t){if(t===void 0&&(t=!1),this.xs&&!t||this.vs||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!==`localstorage+cookie`)return!1;var n;try{n=J.Pr(this.ps)||void 0}catch{}if(!n||n===this.ks)return!1;var r,i=Ii(this.ps,n);try{r=ji(JSON.parse(n))}catch{return!1}if((J.Pr(this.ps)||void 0)!==n)return!1;this.ws=i,this.ks=n;var a=Fi(this.ps,n),o=[...Oi,...a.properties],s={};if(Object.keys(r).forEach((e=>{var t=r[e];(P(t)||I(t)||t===``||e===H&&t!==U&&t!==W)&&(s[e]=!0,delete r[e])})),be(r))return!1;var c=Zn in r||r[H]===U||r[H]===W,l=this.props[Zn],u=this.props[H],d=K({},this.props);[...Oi,...e.cookie_persisted_properties||[]].forEach((e=>{if(o.indexOf(e)!==-1&&!(e in r)&&!s[e]&&(c||e!==Zn&&e!==H)){var t=d[e];!a.isValid&&Oi.indexOf(e)!==-1&&(!1===t||t===0)||delete d[e]}})),this.props=K(d,r),!c||H in r||H in this.props||this.Cs(H,U);var f=this.props[Zn],p=this.props[H];return!c||f===l&&p===u||(this.ds=!0,X.Dr(mo(this.ps),!0),this.Ts(Or),this.Ts(br),this.Ts(yr),this.Ts(Sr),this.Ts(Cr),this.Ts(wr),this.Ts(Br),this.Ts(zr),this.Ts(Lr),p===U&&(u===W||r[H]===U||!P(l)&&f!==l)&&(go(this.props,r),this.Ts(kr)),p===W?this.props.$user_id=f:delete this.props.$user_id,this.Ts(er)),!0}consumeCookieIdentityChange(){var e=mo(this.ps),t=this.ds||!!X.Pr(e);return this.ds=!1,t&&X.qr(e),t}Ms(e){return e===void 0&&(e=!1),!(this.vs||this.xs&&!e||!this.Di.cookieWinsOnConflict||this.Di.persistence.toLowerCase()!==`localstorage+cookie`||(this.vs=!0,0))}Es(){this.vs&&(P(this.Is)||(clearTimeout(this.Is),this.Is=void 0),delete this.ls[ho],this.Rs(!0))}Ps(e){if(e===void 0&&(e=!0),this.vs)try{e?this.Es():P(this.Is)||(clearTimeout(this.Is),this.Is=void 0)}finally{this.vs=!1}}isDisabled(){return!!this.xs}gs(t){po.indexOf(t.persistence.toLowerCase())===-1&&(B.critical(`Unknown persistence type `+t.persistence+`; falling back to localStorage+cookie`),t.persistence=`localStorage+cookie`);var n,r=function(t,n){t===void 0&&(t=[]),n===void 0&&(n=!1);var r=[...Oi,...t];return g({},Y,{Br(e){try{var t,i={};try{t=J.Pr(e)||void 0,i=t?ji(JSON.parse(t)):{}}catch{}var a,o=JSON.parse(Y.Pr(e)||`{}`);if(n){var s=Fi(e,t),c=[...Oi,...s.properties],l={};Object.keys(i).forEach((e=>{var t=i[e];I(t)||t===``||e===H&&t!==U&&t!==W||(l[e]=t)}));var u=Zn in l||l[H]===U||l[H]===W;if(Object.keys(l).length>0){var d=o[Zn],f=o[H]??U;r.forEach((e=>{if(c.indexOf(e)!==-1&&!(e in i)&&(u||e!==Zn&&e!==H)){var t=o[e];!s.isValid&&Oi.indexOf(e)!==-1&&(!1===t||t===0)||delete o[e]}})),!u||H in i||H in o||(o[H]=U),!u||(Zn in l?l[Zn]:o[Zn])===d&&(H in l?l[H]:o[H])===f||(Di.forEach((e=>delete o[e])),l[H]===W&&Zn in l?o.$user_id=l[Zn]:delete o.$user_id,l[H]!==W&&(delete o[Ar],delete o[kr]),delete o.__alias)}a=K(o,l)}else a=K(i,o);return Y.Dr(e,a),a}catch{}return null},Dr(e,r,i,a,o,s){var c=Y.Dr(e,r,void 0,void 0,s);try{var l=Mi(r,t);if(Object.keys(l).length){if(n){var u=ki(e),d=Pi(l,t);if(J.Dr(u,d,i,a,o,s),J.Pr(u)!==JSON.stringify(d)){J.qr(u,a);var f=Mi(r);return J.Dr(e,f,i,a,o,s),c}}J.Dr(e,l,i,a,o,s)}}catch(e){Y.jr(e)}return c},qr(t,n){try{e?.localStorage.removeItem(t),J.qr(t,n),J.qr(ki(t),n)}catch(e){Y.jr(e)}}})}(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),i=!1,a=t.persistence.toLowerCase();return a===`localstorage`&&Y.Nr()?(n=Y,i=!0):a===`localstorage+cookie`&&r.Nr()?(n=r,i=!0):a===`sessionstorage`&&X.Nr()?n=X:a===`memory`?n=Ri:a===`cookie`?n=J:r.Nr()?(n=r,i=!0):n=J,this.us=i,n}As(e){return this.ps+`__`+e}ys(e){return this.us&&!!e.split_storage}properties(){var e={};return G(this.props,((t,n)=>{var r=Ha(n);if(!r||r.exposure===`event`){if(r!=null&&r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t))return;e[n]=t}})),e}load(e){if(e===void 0&&(e=!1),!this.xs||e){var t=this.Di.cookieWinsOnConflict&&this.Di.persistence.toLowerCase()===`localstorage+cookie`,n=t?Y.Br(this.ps):null,r={};if(t)try{G(r=ji(J.Br(this.ps)),((e,t)=>{(P(e)||I(e)||e===``)&&delete r[t]}))}catch{}var i=this.Qn.Br(this.ps);if(i&&(this.props=K({},i)),this.hs&&this.Fs(),t&&i){var a=n?.[Zn],o=n?.[H]??U,s=i[Zn],c=i[H]??U;if(s!==a||c!==o){this.ds=!0,X.Dr(mo(this.ps),!0);var l=K({},this.props);Di.forEach((e=>delete l[e])),c===U&&(o===W||r[H]===U||!P(a)&&s!==a)&&(go(l,r),delete l[kr]),this.props=l;var u=new Set;Di.forEach((e=>{var t=Ha(e)?.storageGroup;t&&u.add(t)})),u.forEach((e=>{var t={};G(this.props,((n,r)=>{Ha(r)?.storageGroup===e&&(t[r]=n)})),be(t)?(Y.qr(this.As(e)),this.ls[e]={}):Y.Dr(this.As(e),t)&&(this.ls[e]={persisted:!0,fingerprint:this.Os(t,e)})}))}}X.Pr(mo(this.ps))&&(this.ds=!0)}}Fs(){for(var e of za){var t=Y.Br(this.As(e));if(t&&!be(t)){var n=this.Ls(e);n.persisted=!0,this.$s(e)||(n.fingerprint=this.Os(t,e)),this.Ds(e,t)||K(this.props,t)}}}$s(e){return Object.keys(this.props).some((t=>Ha(t)?.storageGroup===e))}Ds(e,t){var n=fo[e];if(!n)return!1;var r=t[n],i=this.props[n];return R(r)&&R(i)&&i>r}refreshKey(e){if(!this.xs){var t=this.hs?Ha(e)?.storageGroup:void 0,n=t?Y.Br(this.As(t)):this.Qn.Br(this.ps);if(n&&e in n)this.Cs(e,n[e]);else{if(t){var r=this.Qn.Br(this.ps);if(r&&e in r)return void this.Cs(e,r[e])}this.Ts(e)}}}save(){if(!this.xs){var e=this.bs();e>0?P(this.Is)&&(this.Is=setTimeout((()=>{this.Is=void 0,this.Rs()}),e)):this.Rs()}}flush(){P(this.Is)||(clearTimeout(this.Is),this.Is=void 0,this.Rs())}Rs(e){e===void 0&&(e=!1),this.xs||this.vs&&!e||(e||this.syncCookieProperties(),this.hs?this.Ns():this.qs(this.Qn,this.ps,this.props,ho)&&this._s(this.props))}Ns(){var e=this.js(),t=e.main,n=e.groups;for(var r of(this.qs(this.Qn,this.ps,t,ho)&&this._s(t),za)){var i,a=n[r];(!be(a)||(i=this.ls[r])!=null&&i.persisted)&&this.qs(Y,this.As(r),a,r)}}js(){var e={},t={flags:{},surveys:{}};return G(this.props,((n,r)=>{var i=Ha(r)?.storageGroup;i?t[i][r]=n:e[r]=n})),{main:e,groups:t}}Os(e,t){if(t===ho)return JSON.stringify(e)+`|`+this.Bs+`|`+this.Hs+`|`+this.Us;var n={};return G(e,((e,t)=>{var r;n[t]=(r=Ha(t))!=null&&r.volatile?`__volatile__`:e})),JSON.stringify(n)}qs(e,t,n,r){var i,a=this.Ls(r);if(r!==ho&&!a.dirty&&!P(a.fingerprint))return!1;try{if((i=this.Os(n,r))===a.fingerprint)return a.dirty=!1,!1}catch{i=void 0}return e.Dr(t,n,this.Bs,this.Hs,this.Us,this.Di.debug)?(a.dirty=!1,r!==ho&&(a.persisted=!0),P(i)||(a.fingerprint=i),!0):(this.Di.debug&&B.warn(`failed to persist storage entry "`+t+`"; will retry on next save`),!1)}remove(e){var t=(e===void 0?{}:e).keepGroupEntries,n=t!==void 0&&t;if(P(this.Is)||(clearTimeout(this.Is),this.Is=void 0),this.Qn.qr(this.ps,!1),this.Qn.qr(this.ps,!0),!n&&this.cs)for(var r of za)Y.qr(this.As(r));n?delete this.ls[ho]:this.ls={},this.ws=void 0,this.ks=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(N(e)){this.syncCookieProperties(),P(t)&&(t=`None`),this.Bs=P(n)?this.zs:n;var r=!1;if(G(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Cs(n,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(N(e)){this.syncCookieProperties(),this.Bs=P(t)?this.zs:t;var n=!1;if(G(e,((t,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==t||N(t)||M(t))&&(this.Cs(r,t),n=!0)})),n)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t=typeof e==`string`?[e]:e,n=!1;for(var r of t)r in this.props&&(this.Ts(r),n=!0);n&&this.save()}update_campaign_params(){var e=r?.URL;if(e!==this.fs){var t=to(this.Di.custom_campaign_params,this.Di.mask_personal_data_properties,this.Di.custom_personal_data_properties);be(fi(t))||this.register(t),this.fs=e}}update_search_keyword(){var e;this.register((e=r?.referrer)?ro(e):{})}update_referrer_info(){this.register_once({$referrer:oo(),$referring_domain:r!=null&&r.referrer&&Wa(r.referrer)?.host||ao},void 0)}set_initial_person_info(){this.props[Ur]||this.props[Wr]||this.register_once({[Gr]:so(this.Di.mask_personal_data_properties,this.Di.custom_personal_data_properties,this.Di.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};G([Wr,Ur],(t=>{var n=this.props[t];n&&G(n,(function(t,n){e[`$initial_`+me(n)]=t}))}));var t=this.props[Gr];return t&&K(e,function(e,t){t===void 0&&(t=!1);var n=co(e,t),r={};return G(n,(function(e,t){r[`$initial_`+me(t)]=e})),r}(t,this.Di.disable_capture_url_hashes)),e}safe_merge(e){return G(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){var r=e.persistence!==t.persistence,i=!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||i,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,s=e.disable_persistence||!!n,c=!!this.xs&&!s;s||this.Ss(t,c),this.Di=e,!s&&(r||i||o)&&(this.ws=void 0,this.ks=void 0,this.Ss(g({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),c));var l=a||o?this.gs(e):this.Qn,u=this.ys(e),d=a||u!==this.hs,f=!s&&(d||e.cross_subdomain_cookie!==this.Hs||e.secure_cookie!==this.Us)&&this.Ms(c);try{if(this.zs=this.Bs=e.cookie_expiration,this.set_disabled(s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){var p=this.props;this.clear(),this.Qn=l,this.hs=u,this.props=p,this.save()}else o&&(this.Qn=l,s||(delete this.ls[ho],this.Rs()))}finally{f&&this.Ps()}}set_disabled(e){this.xs=e,this.xs?this.remove():this.save()}set_cross_subdomain(e){e!==this.Hs&&(this.Hs=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Us&&(this.Us=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var n=this.props[tr]||{};n[e]=t,this.Cs(tr,n),this.save()}remove_event_timer(e){var t=this.props[tr]||{},n=t[e];return P(n)||(delete t[e],this.Cs(tr,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Cs(e,t),this.save()}Cs(e,t){var n;this.props[e]=t,(n=Ha(e))!=null&&n.volatile||this.Ws(e)}Ts(e){delete this.props[e],this.Ws(e)}Ws(e){var t=Ha(e)?.storageGroup;t&&(this.Ls(t).dirty=!0)}Ls(e){return this.ls[e]||(this.ls[e]={})}};function vo(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&ye(n.then)&&n.then(void 0,(()=>{}))}}}}var Z={GZipJS:`gzip-js`,Base64:`base64`},yo={Activation:`events`,Cancellation:`cancelEvents`},bo={Button:`button`,Tab:`tab`,Selector:`selector`},xo={TopLeft:`top_left`,TopRight:`top_right`,TopCenter:`top_center`,MiddleLeft:`middle_left`,MiddleRight:`middle_right`,MiddleCenter:`middle_center`,Left:`left`,Center:`center`,Right:`right`,NextToTrigger:`next_to_trigger`},So={Top:`top`,Left:`left`,Right:`right`,Bottom:`bottom`},Co={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},wo={Open:`open`,MultipleChoice:`multiple_choice`,SingleChoice:`single_choice`,Rating:`rating`,Link:`link`},To={NextQuestion:`next_question`,End:`end`,ResponseBased:`response_based`,SpecificQuestion:`specific_question`},Eo={Once:`once`,Recurring:`recurring`,Always:`always`},Do={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Oo={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},ko={Popover:`popover`,Inline:`inline`},Ao={backgroundColor:`#ffffff`,textColor:`#1d1f27`,buttonColor:`#1d1f27`,borderRadius:8,buttonBorderRadius:6,borderColor:`#e5e7eb`,fontFamily:`system-ui`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},jo={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},Mo={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},No=V(`[RateLimiter]`),Po=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{No.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){No.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var n=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,i=new Date().getTime(),a=this.instance.persistence?.get_property(Hr)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;if(o||e||(a.tokens=Math.max(0,a.tokens-1)),o&&!e){var s=(R(a.dropped)?a.dropped:0)+1;a.dropped=s,!this.lastEventRateLimited&&this.Vs(s)&&(a.dropped=0)}return this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(Hr,a),{isRateLimited:o,remainingTokens:a.tokens}}Gs(e){var t=this.instance.config.property_denylist;return!M(t)||!t.includes(e)}Zs(){if(this.Gs(`$current_url`)&&this.Gs(`$pathname`)&&i!=null&&i.pathname)return``+(i.origin??``)+i.pathname}Vs(e){var t,n=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,i=this.Zs(),a=this.Gs(`$session_id`)?(t=this.instance).get_session_id?.call(t):void 0,o=[e+` event(s) dropped since the last warning`,i?`triggered on `+i:void 0,a?`session `+a:void 0].filter(Boolean).join(`, `);return!!this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited: `+o+`. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Fo=V(`[RemoteConfig]`),Io=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Qs(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Js(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 Fo.info(`Using preloaded remote config`,this.remoteConfig),this.Ks(this.remoteConfig),void this.Ys();if(this._instance.Xs())return void Fo.warn(`Remote config is disabled. Falling back to local config.`);this.Qs((e=>{if(!e)return Fo.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Js((e=>{this.Ks(e.json,e),this.Ys()}));this.Ks(e),this.Ys()}))}catch(e){Fo.error(`Error loading remote config`,e),this.Ks()}}stop(){this.ta&&=(clearInterval(this.ta),void 0)}refresh(){!this._instance.Xs()&&r&&r.visibilityState!==`hidden`&&this._instance.reloadFeatureFlags()}Ys(){if(!this.ta){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.ta=setInterval((()=>{this.refresh()}),e))}}Ks(e,t){!e&&t&&(t.statusCode===0?t.error||Fo.warn(`Failed to fetch remote config from PostHog.`):Fo.error(`Failed to fetch remote config from PostHog.`));try{this._instance.Ks(e?{ok:!0,config:e}:{ok:!1})}catch(e){Fo.error(`Error applying remote config`,e)}if(!1!==e?.hasFeatureFlags&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var n;(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded()}catch(e){Fo.error(`Error loading feature flags`,e)}}},Lo=[`fatal`,`error`,`warning`,`log`,`info`,`debug`],Ro=Uint8Array,zo=Uint16Array,Bo=Uint32Array,Vo=new Ro([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]),Ho=new Ro([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]),Uo=new Ro([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wo=function(e,t){for(var n=new zo(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Bo(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},Go=Wo(Vo,2),Ko=Go[1];Go[0][28]=258,Ko[258]=28;for(var qo=Wo(Ho,0)[1],Jo=new zo(32768),Q=0;32768>Q;++Q){var Yo=(43690&Q)>>>1|(21845&Q)<<1;Jo[Q]=((65280&(Yo=(61680&(Yo=(52428&Yo)>>>2|(13107&Yo)<<2))>>>4|(3855&Yo)<<4))>>>8|(255&Yo)<<8)>>>1}var Xo=function(e,t,n){for(var r=e.length,i=0,a=new zo(t);r>i;++i)++a[e[i]-1];var o,s=new zo(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new zo(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[Jo[d]>>>c]=l}else for(o=new zo(r),i=0;r>i;++i)o[i]=Jo[s[e[i]-1]++]>>>15-e[i];return o},Zo=new Ro(288);for(Q=0;144>Q;++Q)Zo[Q]=8;for(Q=144;256>Q;++Q)Zo[Q]=9;for(Q=256;280>Q;++Q)Zo[Q]=7;for(Q=280;288>Q;++Q)Zo[Q]=8;var Qo=new Ro(32);for(Q=0;32>Q;++Q)Qo[Q]=5;var $o=Xo(Zo,9,0),es=Xo(Qo,5,0),ts=function(e){return(e/8>>0)+(7&e&&1)},ns=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof zo?zo:e instanceof Bo?Bo:Ro)(n-t);return r.set(e.subarray(t,n)),r},rs=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},is=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},as=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new Ro(0),0];if(i==1){var o=new Ro(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new zo(f+1),m=os(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new Ro(p),m]},os=function(e,t,n){return e.s==-1?Math.max(os(e.l,t,n+1),os(e.r,t,n+1)):t[e.s]=n},ss=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new zo(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},cs=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},ls=function(e,t,n){var r=n.length,i=ts(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},us=function(e,t,n,r,i,a,o,s,c,l,u){rs(t,u++,n),++i[256];for(var d=as(i,15),f=d[0],p=d[1],m=as(a,15),h=m[0],g=m[1],_=ss(f),v=_[0],y=_[1],b=ss(h),x=b[0],S=b[1],C=new zo(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var T=as(C,7),E=T[0],D=T[1],O=19;O>4&&!E[Uo[O-1]];--O);var ee,te,ne,re,k=l+5<<3,ie=cs(i,Zo)+cs(a,Qo)+o,ae=cs(i,f)+cs(a,h)+o+14+3*O+cs(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(ie>=k&&ae>=k)return ls(t,u,e.subarray(c,c+l));if(rs(t,u,1+(ie>ae)),u+=2,ie>ae){ee=Xo(f,p,0),te=f,ne=Xo(h,g,0),re=h;var oe=Xo(E,D,0);for(rs(t,u,y-257),rs(t,u+5,S-1),rs(t,u+10,O-4),u+=14,w=0;O>w;++w)rs(t,u+3*w,E[Uo[w]]);u+=3*O;for(var se=[v,x],ce=0;2>ce;++ce){var le=se[ce];for(w=0;le.length>w;++w)rs(t,u,oe[ue=31&le[w]]),u+=E[ue],ue>15&&(rs(t,u,le[w]>>>5&127),u+=le[w]>>>12)}}else ee=$o,te=Zo,ne=es,re=Qo;for(w=0;s>w;++w)if(r[w]>255){var ue;is(t,u,ee[257+(ue=r[w]>>>18&31)]),u+=te[ue+257],ue>7&&(rs(t,u,r[w]>>>23&31),u+=Vo[ue]);var A=31&r[w];is(t,u,ne[A]),u+=re[A],A>3&&(is(t,u,r[w]>>>5&8191),u+=Ho[A])}else is(t,u,ee[r[w]]),u+=te[r[w]];return is(t,u,ee[256]),u+te[256]},ds=new Bo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fs=function(){for(var e=new Bo(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),ps=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function ms(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=fs[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new Ro(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=ls(c,l,e.subarray(u,d)):(c[u]=!0,l=ls(c,l,e.subarray(u,o)))}else{for(var f=ds[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new zo(32768),_=new zo(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new Bo(25e3),S=new zo(288),C=new zo(32),w=0,T=0,E=(u=0,0),D=0,O=0;o>u;++u){var ee=b(u),te=32767&u,ne=_[ee];if(g[te]=ne,_[ee]=te,u>=D){var re=o-u;if((w>7e3||E>24576)&&re>423){l=us(e,c,0,x,S,C,T,E,O,u-O,l),E=w=T=0,O=u;for(var k=0;286>k;++k)S[k]=0;for(k=0;30>k;++k)C[k]=0}var ie=2,ae=0,oe=m,se=te-ne&32767;if(re>2&&ee==b(u-se))for(var ce=Math.min(p,re)-1,le=Math.min(32767,u),ue=Math.min(258,re);le>=se&&--oe&&te!=ne;){if(e[u+ie]==e[u+ie-se]){for(var A=0;ue>A&&e[u+A]==e[u+A-se];++A);if(A>ie){if(ie=A,ae=se,A>ce)break;var de=Math.min(se,A-2),fe=0;for(k=0;de>k;++k){var j=u-se+k+32768&32767,pe=j-g[j]+32768&32767;pe>fe&&(fe=pe,ne=j)}}}se+=(te=ne)-(ne=g[te])+32768&32767}if(ae){x[E++]=268435456|Ko[ie]<<18|qo[ae];var me=31&Ko[ie],he=31&qo[ae];T+=Vo[me]+Ho[he],++S[257+me],++C[he],D=u+ie,++w}else x[E++]=e[u],++S[e[u]]}}l=us(e,c,!0,x,S,C,T,E,O,u-O,l)}return ns(s,0,r+ts(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&ps(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),ps(l,u-8,n.d()),ps(l,u-4,r),l}var hs=!!o||!!a,gs=`text/plain`,_s=!1,vs=(e,t)=>{var n=e.split(`#`),r=n[1],i=n[0].split(`?`),a=i[0],o=i[1];if(!o)return e;var s=o.split(`&`).filter((e=>e.split(`=`)[0]!==t)).join(`&`);return a+(s?`?`+s:``)+(r?`#`+r:``)},ys=function(e,t,n){n===void 0&&(n=!0);var r=e.split(`?`),i=r[0],a=r[1],o=g({},t),s=a?.split(`&`).map((e=>{var t,r=e.split(`=`),i=r[0],a=n&&(t=o[i])!=null?t:r[1];return delete o[i],i+`=`+a}))??[],c=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return G(e,(function(e,t){P(e)||P(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(o);return c&&s.push(c),s.length>0?i+`?`+s.join(`&`):i},bs=e=>{if(e.ea)return e.ea;var t=e.data,n=e.compression;if(t){if(n===Z.GZipJS){var r=ms(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new Ro(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new Ro(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return ns(r,0,i)}(Ua(t)),{mtime:0});return{contentType:gs,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Z.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Ua(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(Ua(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=Ua(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},xs=e=>{var t,n,r=()=>e.transport===`sendBeacon`?{url:ys(e.url,{compression:Z.Base64}),encodedBody:bs(g({},e,{compression:Z.Base64,ea:void 0}))}:{url:vs(e.url,`compression`),encodedBody:bs(g({},e,{compression:void 0,ea:void 0}))};try{t=bs(e)}catch(t){if(ee(e.compression,Ga(e.url,`compression`)))return B.error(`Failed to gzip request body, sending uncompressed payload`,t),r();throw t}return t&&ee(e.compression,Ga(e.url,`compression`))&&!((n=t.body)instanceof ArrayBuffer?O(new Uint8Array(n)):ArrayBuffer.isView(n)&&O(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(_s=!0,r()):{url:e.url,encodedBody:t}},Ss=e=>{try{return xs(e)}catch(t){B.error(t),e.callback==null||e.callback({statusCode:0,error:t});return}},Cs=function(){var e=h((function*(e){var t=yield function(e,t,n){return k.apply(this,arguments)}(Ua(e.data),p.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return g({},e,{ea:{contentType:gs,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),ws=/Failed to fetch|NetworkError|Load failed/i,Ts=e=>e?.name===`TypeError`&&ws.test(e?.message||``),Es=e=>{var t=Ss(e);if(t){var n=t.url,r=t.encodedBody??{},i=r.contentType,o=r.body,c=r.estimatedSize,l=new Headers;G(e.headers,(function(e,t){l.append(t,e)})),i&&l.append(`Content-Type`,i);var u=null,d=!1;if(s){var f=new s;u={signal:f.signal,timeout:setTimeout((()=>{var t,n;d=!0,f.abort((t=e.timeout,(n=Error(`PostHog request timed out`+(t?` after `+t+`ms`:``))).name=`AbortError`,n))}),e.timeout)}}var p=t=>{d&&t?.name===`AbortError`||Ts(t)?B.warn(t):B.error(t),e.callback==null||e.callback({statusCode:0,error:t})};try{a(n,g({method:e?.method||`GET`,headers:l,keepalive:e.method===`POST`&&!e.ia&&52428.8>(c||0),body:o,signal:u?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){B.error(e)}e.callback==null||e.callback(r)})))).catch(p).finally((()=>u?clearTimeout(u.timeout):null))}catch(e){u&&clearTimeout(u.timeout),p(e)}}},Ds=e=>{try{var t=xs(e),r=t.url,i=t.encodedBody??{},a=i.body,o=i.estimatedSize;if(!a)return;var s=a instanceof Blob?a:new Blob([a],{type:i.contentType});if(n.sendBeacon(r,s))return;var c=M(e.data)?e.data:e.data?.batch;if(M(c)&&c.length>1&&(o??0)>16384){var l=Math.ceil(c.length/2),u=t=>M(e.data)?t:g({},e.data,{batch:t});Ds(g({},e,{data:u(c.slice(0,l))})),Ds(g({},e,{data:u(c.slice(l))}));return}B.warn(`Beacon of ~`+(o??0)+` bytes was rejected by the browser, falling back to fetch`),Es(g({},e,{ia:!0}))}catch(e){B.warn(`Beacon send failed`,e)}},Os=(e,t,n,r)=>{var i=r===`query`?t===`POST`?`sent_at`:`_`:void 0;return ys(n===Z.GZipJS?vs(e,`compression`):e,g({},i?{[i]:Date.now().toString()}:{},n===Z.GZipJS?{}:{compression:n}))},ks=[];a&&ks.push({transport:`fetch`,method:Es}),o&&ks.push({transport:`XHR`,method(e){var t=Ss(e);if(t){var n=new o,r=t.encodedBody;n.open(e.method||`GET`,t.url,!0);var i=r??{},a=i.contentType,s=i.body;G(e.headers,(function(e,t){n.setRequestHeader(t,e)})),a&&n.setRequestHeader(`Content-Type`,a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var t={statusCode:n.status,text:n.responseText};if(n.status===200)try{t.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(t)}},n.send(s)}}}),n!=null&&n.sendBeacon&&ks.push({transport:`sendBeacon`,method:Ds});var As=3e3,js=class{constructor(e,t){this.ra=!0,this.na=[],this.sa=Fe(t?.flush_interval_ms||As,250,5e3,B.createLogger(`flush interval`),As),this.aa=e}enqueue(e){this.na.push(e),this.oa||this.la()}unload(){this.ua();var e=this.na.length>0?this.ha():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.da(g({},e,{transport:`sendBeacon`}))}))}enable(){this.ra=!1,this.la()}la(){var e=this;this.ra||(this.oa=setTimeout((()=>{if(this.ua(),this.na.length>0){var t=this.ha(),n=function(){var n=t[r],i=new Date().getTime();n.data&&M(n.data)&&G(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.da(n)};for(var r in t)n()}}),this.sa))}da(e){try{this.aa(e)}catch(e){B.error(e)}}ua(){clearTimeout(this.oa),this.oa=void 0}ha(){var e={};return G(this.na,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;P(e[i])&&(e[i]=g({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.na=[],e}},Ms=[`retriesPerformedSoFar`],Ns=class{constructor(t){this.va=!1,this.ca=3e3,this.na=[],this._instance=t,this.na=[],this.fa=!0,!P(e)&&`onLine`in e.navigator&&(this.fa=e.navigator.onLine,this.pa=()=>{this.fa=!0,this.ga()},this.ma=()=>{this.fa=!1},q(e,`online`,this.pa),q(e,`offline`,this.ma))}get length(){return this.na.length}retriableRequest(e){var t=e.retriesPerformedSoFar,n=_(e,Ms);Se(t)&&(n.url=ys(n.url,{retry_count:t})),this._instance._send_request(g({},n,{callback:e=>{if(e.statusCode!==200&&(400>e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(t??0))return void this.kn(g({retriesPerformedSoFar:t},n));e.statusCode===0&&B.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after `+(t??0)+` retries.`)}n.callback==null||n.callback(e)}}))}kn(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.na.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),B.warn(i),this.va||(this.va=!0,this.ya())}ya(){if(this.ba&&clearTimeout(this.ba),this.na.length===0)return this.va=!1,void(this.ba=void 0);this.ba=setTimeout((()=>{this.fa&&this.na.length>0&&this.ga(),this.ya()}),this.ca)}ga(){var e=Date.now(),t=[],n=this.na.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.na=t,n.length>0)for(var r of n)this.retriableRequest(r.requestOptions)}unload(){for(var t of(this.ba&&=(clearTimeout(this.ba),void 0),this.va=!1,P(e)||(this.pa&&=(e.removeEventListener(`online`,this.pa),void 0),this.ma&&=(e.removeEventListener(`offline`,this.ma),void 0)),this.na)){var n=t.requestOptions;try{this._instance._send_request(g({},n,{transport:`sendBeacon`}))}catch(e){B.error(e)}}this.na=[]}},Ps=class{constructor(e){this._a=()=>{this.wa||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.wa.lastScrollY=Math.ceil(t),this.wa.maxScrollY=Math.max(t,this.wa.maxScrollY??0),this.wa.maxScrollHeight=Math.max(n,this.wa.maxScrollHeight??0),this.wa.lastContentY=r,this.wa.maxContentY=Math.max(r,this.wa.maxContentY??0),this.wa.maxContentHeight=Math.max(i,this.wa.maxContentHeight??0)},this._instance=e}get ka(){return this._instance.config.scroll_root_selector}getContext(){return this.wa}resetContext(){var e=this.wa;return setTimeout(this._a,0),e}startMeasuringScrollPosition(){q(e,`scroll`,this._a,{capture:!0}),q(e,`scrollend`,this._a,{capture:!0}),q(e,`resize`,this._a)}scrollElement(){if(!this.ka)return e?.document.documentElement;for(var t of M(this.ka)?this.ka:[this.ka]){var n=e?.document.querySelector(t);if(n)return n}}Sa(t){var n=t===`y`?`scrollTop`:`scrollLeft`;if(this.ka){var r=this.scrollElement();return r&&r[n]||0}return e?t===`y`?e.scrollY||e.pageYOffset||e.document.documentElement.scrollTop||0:e.scrollX||e.pageXOffset||e.document.documentElement.scrollLeft||0:0}scrollY(){return this.Sa(`y`)}scrollX(){return this.Sa(`x`)}},Fs=e=>so(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),Is=class{constructor(e,t,n,r){this.ot=e=>{var t=this.xa();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.Ca(this._instance)};this.Ta.register({[Vr]:n})}},this._instance=e,this.Ma=t,this.Ta=n,this.Ca=r||Fs,this.Ma.onSessionId(this.ot)}xa(){return this.Ta.props[Vr]}getSetOnceProps(){var e=this.xa()?.props;return e?`r`in e?co(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return G(fi(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+me(n)]=t})),e}},Ls=class{on(e,t){return this.Ea[e]||(this.Ea[e]=[]),this.Ea[e].push(t),()=>{this.Ea[e]=this.Ea[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.Ea[e]||[])n(t);for(var r of this.Ea[`*`]||[])r(e,t)}constructor(){this.Ea={}}},Rs=V(`[SessionId]`),zs=864e5,Bs=class{on(e,t){return this.Ia.on(e,t)}constructor(e,t,n){var r;if(this.Ra=null,this.Pa=null,this.Aa=[],this.Fa=void 0,this.Oa=!1,this.Ia=new Ls,this.La=(e,t)=>!(!Se(e)||!Se(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===ei)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Di=e.config,this.Ta=e.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.$a=void 0,this._sessionActivityTimestamp=null,this.Da=t||Si,this.Na=n||Si;var i=this.Di.persistence_name||this.Di.token;if(this._sessionTimeoutMs=1e3*Fe(this.Di.session_idle_timeout_seconds||1800,60,36e3,Rs.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.qa(),this.ja=`ph_`+i+`_window_id`,this.Ba=`ph_`+i+`_primary_window_exists`,this.Ha()){var a=X.Br(this.ja),o=X.Br(this.Ba);a&&!o?this.st=a:X.qr(this.ja),X.Dr(this.Ba,!0)}(r=this.Di.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.Di.bootstrap.sessionID),this.Ua()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.Aa)&&(this.Aa=[]),this.Aa.push(e),this._e&&e(this._e,this.st),()=>{this.Aa=this.Aa.filter((t=>t!==e))}}Ha(){return this.Di.persistence!==`memory`&&!this.Ta.xs&&X.Nr()}za(e){e!==this.st&&(this.st=e,this.Ha()&&X.Dr(this.ja,e))}Wa(){return this.st?this.st:this.Ha()?X.Br(this.ja):null}Va(e){var t=this.Ra;return!I(t)&&!I(e)&&5e3>Math.abs(e-t)}Ga(e,t,n){var r=t!==this._sessionActivityTimestamp,i=e===this._e&&n===this._sessionStartTimestamp;this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this._e=e,i&&!r||i&&this.Va(t)||(this.Ra=t,this.Ta.register({[_r]:[t,e,n]}))}Za(){var e=this.Di?.persistence_save_debounce_ms;return Se(e)&&e>0}Qa(){this.Za()?this.Ta.refreshKey(_r):(this.Ta.flush(),this.Ta.load())}Ja(){if(!I(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Ra){this.Qa();var e=this.Ka();e[1]===this._e&&e[2]===this._sessionStartTimestamp&&(this.Ra=this._sessionActivityTimestamp,this.Ta.register({[_r]:[this._sessionActivityTimestamp,this._e??null,this._sessionStartTimestamp]}),this.Ta.flush())}}Ya(){var e=this.Ka()[0],t=Se(e)?e:0,n=Se(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}Xa(e){return this.Qa(),this.La(e,this.Ya())}Ka(){var e=this.Ta.props[_r];return M(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Ra=null,this.$a=void 0,clearTimeout(this.eo),this.eo=void 0,this.Ga(null,null,null)}setBootstrapSessionId(e,t){t===void 0&&(t=!1);var n=function(e,t){t===void 0&&(t=new Date().getTime());try{var n=(e=>{var t=e.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})(e);return n>t+6e4?void Rs.error(`Bootstrap sessionID cannot be in the future`):n}catch(e){Rs.error(`Invalid sessionID in bootstrap`,e);return}}(e);return!P(n)&&(t?this.$a={sessionId:e,sessionStartTimestamp:n}:this.Ga(e,new Date().getTime(),n),!0)}destroy(){this.Oa=!0,this.Ja(),clearTimeout(this.eo),this.eo=void 0,this.Fa&&e&&(e.removeEventListener(ri,this.Fa,{capture:!1}),this.Fa=void 0),this.Aa=[]}Ua(){this.Fa=()=>{this.Ja(),this.Ha()&&X.qr(this.Ba)},q(e,ri,this.Fa,{capture:!1})}checkAndGetSessionAndWindowId(e,t,n){if(e===void 0&&(e=!1),t===void 0&&(t=null),n===void 0&&(n=!1),this.Di.cookieless_mode===ei)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var r=t||new Date().getTime(),i=this._e;if(n)this.Pa=r;else if(I(this.Pa)||this.Pa>r||r-this.Pa>=1e3){var a,o;(a=(o=this.Ta).syncCookieProperties)==null||a.call(o),this.Pa=r}var s=this.Ka(),c=s[1],l=s[2],u=!P(i)&&c!==i,d=this.Ya(),f=this.Wa(),p=this.$a,m=!!p&&(p.sessionStartTimestamp>r+6e4||r-p.sessionStartTimestamp>zs),h=p?m:Se(l)&&Math.abs(r-l)>zs,g=!1,_=u,v=!c||!!p,y=c,b=!v&&!e&&this.La(r,d);if(b){(b=this.Xa(r))||Rs.info(`cross-tab refresh kept the session alive`,{sessionId:c});var x=this.Ka();c=x[1],l=x[2]}if(v||b||h){_=!1;var S=p&&!m;c=S?p.sessionId:this.Da(),f=this.Na(),Rs.info(`new session ID assigned`,{sessionId:c,windowId:f,bootstrapped:!!S,changeReason:{noSessionId:v,activityTimeout:b,sessionPastMaximumLength:h}}),l=S?p.sessionStartTimestamp:r,this.$a=void 0,g=!0}else f||(f=this.Na(),g=!0),(_||=c!==y)&&(Rs.info(`adopted cross-tab session id`,{sessionId:c,windowId:f}),g=!0);var C=Se(d)&&e&&!h?d:r,w=Se(l)?l:new Date().getTime();this.za(f),this.Ga(c,C,w),e||this.qa();var T={noSessionId:v,activityTimeout:b,sessionPastMaximumLength:h,crossTabAdoption:_};return g&&this.Aa.forEach((e=>e(c,f,T))),{sessionId:c,windowId:f,sessionStartTimestamp:w,changeReason:g?T:void 0,lastActivityTimestamp:d}}qa(){this.Oa||(clearTimeout(this.eo),this.eo=setTimeout((()=>{if(!this.Oa)if(this.Xa(new Date().getTime())){var e=this._e;this.resetSessionId(),this.Ia.emit(`forcedIdleReset`,{idleSessionId:e})}else this.qa()}),1.1*this.sessionTimeoutMs))}},Vs=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&fe(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>fe(e?.brand,t))))return!0}catch{}return!!e.webdriver};function Hs(){return(Hs=h((function*(){var e=n?.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=(yield e.getHighEntropyValues([`model`]))?.model;return F(t)&&t.length>0?t:void 0}catch(e){B.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}}))).apply(this,arguments)}var Us=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function Ws(e,t,n){return Ua({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Gs={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>Us(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Us(t,e))))),icontains:(e,t)=>t.map(Ks).some((t=>e.map(Ks).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Ks).every((t=>e.map(Ks).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},Ks=e=>e.toLowerCase();function qs(e,t){return!e||Object.entries(e).every((e=>{var n=e[1],r=t?.[e[0]];if(P(r)||I(r))return!1;var i=[String(r)],a=Gs[n.operator];return!!a&&a(n.values,i)}))}var Js=`custom`,Ys=`i.posthog.com`,Xs=/^\/static\//,Zs=[`/s/`,`/e/`,`/i/`],Qs=class{constructor(e){this.io={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+Ys,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.io[this.apiHost]||(this.io[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`:Js),this.io[this.apiHost]}ro(e){if(Xs.test(e)){var t=this.instance.config.asset_host;if(typeof t==`string`)return t.trim().replace(/\/$/,``)||void 0}}no(e){var t=Wa(e);return t?t.protocol+`//`+t.host+t.pathname:void 0}so(e,t,n){if(e===`ui`)return n;var r=n,i=this.instance.config.rewriteRequestPath;if(i){var a=Wa(n)?.href||n;r=i(new URL(a)).toString()}if(i&&e===`api`&&Zs.some((e=>t.indexOf(e)===0))){var o=this.no(r);if(o){var s=this.apiHost,c=this.ao;c?.apiHost===s&&c.rewriteRequestPath===i||(c={apiHost:s,rewriteRequestPath:i,urls:new Set},this.ao=c),c.urls.add(o)}}return r}isIngestionEndpoint(e){var t=this.ao,n=this.no(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&t.urls.has(n)}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.so(e,t,this.uiHost+t);if(e===`flags`)return this.so(e,t,this.flagsApiHost+t);if(e===`assets`){var n=this.ro(t);if(n)return this.so(e,t,``+n+t)}if(this.region===Js)return this.so(e,t,this.apiHost+t);var r=Ys+t;switch(e){case`assets`:return this.so(e,t,`https://`+this.region+`-assets.`+r);case`api`:return this.so(e,t,`https://`+this.region+`.`+r)}}};function $s(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var $=V(`[Surveys]`),ec=`seenSurvey_`,tc=e=>{try{var t=(e=>((e,t)=>``+ec+function(e){return e.current_iteration&&e.current_iteration>0?e.id+`_`+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){$.error(`Failed to persist survey seen state`,e)}},nc=[Co.Popover,Co.Widget,Co.API],rc={ignoreConditions:!1,ignoreDelay:!1,displayType:ko.Popover},ic=V(`[PostHog ExternalIntegrations]`),ac={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},oc=class{constructor(e){this._instance=e}Xn(e,t){var n;(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return ic.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(){var t,r,i,a=n[0],o=n[1];!o||(t=f.__PosthogExtensions__)!=null&&(t=t.integrations)!=null&&t[a]||e.Xn(ac[a],(()=>{var t;(t=f.__PosthogExtensions__)==null||(t=t.integrations)==null||(t=t[a])==null||t.start(e._instance)})),!o&&(r=f.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]&&((i=f.__PosthogExtensions__)==null||(i=i.integrations)==null||(i=i[a])==null||i.stop())};for(var n of Object.entries((r=this._instance.config.integrations)??{})){var r;t()}}},sc=class{constructor(e,t){this.I=e,this.oo=t,this.lo=new Map,this.uo=!1}add(e){var t=this;return h((function*(){if(t.uo)throw Error(`Cannot add an extension to a disposed ExtensionRuntime`);if(t.lo.has(e.name))throw Error(`Browser extension "`+e.name+`" is already registered`);t.lo.set(e.name,e);try{var n=e.setup(t.oo);n&&(yield n)}catch(n){var r=t.lo.get(e.name)===e;r&&t.lo.delete(e.name),t.I.error(`Failed to set up browser extension "`+e.name+`"`,n),r&&t.ho(e)}}))()}dispose(){if(!this.uo){this.uo=!0;var e=Array.from(this.lo.values()).reverse();for(var t of(this.lo.clear(),e))this.ho(t)}}ho(e){try{var t=e.dispose==null?void 0:e.dispose();t&&ye(t.then)&&t.then(void 0,(t=>{this.I.error(`Failed to dispose browser extension "`+e.name+`"`,t)}))}catch(t){this.I.error(`Failed to dispose browser extension "`+e.name+`"`,t)}}},cc=class{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if(typeof e==`string`)return t?.get_property(e);var n={};for(var r of e){var i=t?.get_property(r);P(i)||(n[r]=i)}return n}set(e,t){var n;(n=this._instance.persistence)==null||n.register(typeof e==`string`?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}},lc=`extensionsRemoteConfig`,uc=class{constructor(e){this.uo=!1,this.instance=e,this.I=B,this.do=e.vo,this.kv=new cc(e),this.onEvent=e=>vo(this.instance.on(`eventCaptured`,(t=>{try{e({event:t.event,properties:t.properties})}catch(e){this.I.error(`Browser extension event listener failed`,e)}}))),this.onRemoteConfig=e=>{if(this.uo)return vo((()=>{}));var t=t=>{try{e(t)}catch(e){this.I.error(`Browser extension remote config listener failed`,e)}},n=this.instance.co.on(lc,t);return this.do&&t(this.do),vo(n)},this.fo=new sc(B.createLogger(`[BrowserExtensions]`),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){return this.instance.get_property(Qn)??this.distinctId}get deviceId(){var e=this.instance.get_property(Qn);return typeof e==`string`?e:void 0}get library(){return{name:p.LIB_NAME,version:p.LIB_VERSION}}get initialPersonProperties(){return this.instance.persistence?.get_initial_props()??{}}get groups(){return this.instance.getGroups()}get session(){try{var e=this.instance.sessionManager?.checkAndGetSessionAndWindowId(!0);return{sessionId:e?.sessionId??``,windowId:e?.windowId??``,sessionStartTimestamp:e?.sessionStartTimestamp??0}}catch{return{sessionId:``,windowId:``,sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(e){return this.fo.add(e)}capture(e,t,n){var r=this;return h((function*(){n?r.instance.capture(e,t,{timestamp:n.timestamp,uuid:n.uuid,$set:n.set,$set_once:n.setOnce}):r.instance.capture(e,t)}))()}registerDynamicEventProperties(e){return vo(this.instance.po(e))}handleRemoteConfig(e){this.uo||(this.do=e,this.instance.co.emit(lc,e))}sendRequest(e,t){var n=this;return h((function*(){t===void 0&&(t={});var r=n.instance.requestRouter.endpointFor(t.target??`api`,e),i={method:t.method,url:t.query?ys(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt};return t.transport===`sendBeacon`?(n.instance._send_request(i),{statusCode:202}):new Promise((e=>{i.callback=e,n.instance._send_request(i)}))}))()}dispose(){this.uo||(this.uo=!0,this.fo.dispose())}},dc={},fc=0,pc=()=>{},mc=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,hc=`Surveys module not available`,gc=`sanitize_properties is deprecated. Use before_send instead`,_c=`Invalid value for property_denylist config: `,vc=[`token`,`distinct_id`,Jr],yc=`posthog`,bc=!hs&&l?.indexOf(`MSIE`)===-1&&l?.indexOf(`Mozilla`)===-1,xc=t=>{var n;return g({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:mi(r?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:pc,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:t??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:i&&F(i?.search)&&i.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,disable_external_dependency_loading:!1,strict_script_versioning:`fallback`,enable_recording_console_log:void 0,secure_cookie:(e==null||(n=e.location)==null?void 0:n.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,surveys_request_timeout_ms:1e4,on_request_error(e){B.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ti,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:As},error_tracking:{},_onCapture:pc},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:la,ignore_text_selection:!0}:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2026-06-25`?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:e&&e>=`2026-05-30`?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>=`2026-05-30`?250:0,split_storage:!(!e||`2026-05-30`>e),detect_google_search_app:!(!e||`2026-05-30`>e),disable_capture_url_hashes:!(!e||`2026-06-25`>e),cookieWinsOnConflict:!(!e||e===`unset`||`2026-08-29`>e)}))(t))},Sc=[[`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`]],Cc=e=>{var t={};for(var n of Sc){var r=n[0],i=n[1];P(e[r])||(t[i]=e[r])}var a=K({},t,e),o=e.__preview_external_dependency_versioned_paths;return P(o)||(P(e.strict_script_versioning)&&(a.strict_script_versioning=!!o),F(o)&&P(e.asset_host)&&(a.asset_host=o)),M(e.property_blacklist)&&(P(e.property_denylist)?a.property_denylist=e.property_blacklist:M(e.property_denylist)?a.property_denylist=[...e.property_blacklist,...e.property_denylist]:B.error(_c+e.property_denylist)),a},wc=class{constructor(){this.__forceAllowLocalhost=!1}get mo(){return this.__forceAllowLocalhost}set mo(e){B.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Tc=class t{yo(e,t){if(e){var n=this.lo.indexOf(e);n!==-1&&this.lo.splice(n,1)}return this.lo.push(t),t.initialize==null||t.initialize(),t}bo(){return this.config.cookieless_mode===ei||this.config.cookieless_mode===$r&&this.consent.isRejected()}_o(){if(!this.bo()&&this.get_distinct_id()===qr){var e=this.persistence;if(e){this.wo()||e.load(!0);var t=this.get_distinct_id();if(!t||t===qr){var n=this.config.get_device_id(Si());this.register({distinct_id:n,$device_id:n}),e.set_property(H,U)}this.ko()}}}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new wc,this.So=!1,this.version=p.LIB_VERSION,this.xo=new Set,this.Co=``,this.co=new Ls,this.lo=[],this.To=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=xc(),this.SentryIntegration=La,this.sentryIntegration=e=>function(e,t){var n=Ia(e,t);return{name:Fa,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Mo=!1,this.Eo=null,this.Io=null,this.Ro=null,this.scrollManager=new Ps(this),this.pageViewManager=new Ra(this),this.rateLimiter=new Po(this),this.requestRouter=new Qs(this),this.consent=new Bi(this),this.externalIntegrations=new oc(this);var e=t.__defaultExtensionClasses??{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(e,t,n)=>{var r=F(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=F(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>B.info(`send "`+e?.event+`"`,e)))}init(e,n,r){if(r&&r!==yc){var i=dc[r]??new t;return i._init(e,n,r),dc[r]=i,dc[yc][r]=i,i}return this._init(e,n,r)}_init(t,n,r){var i;n===void 0&&(n={});var a=F(t)?t.trim():``;if(!a)return B.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return a===this.config?.token?console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`):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')`),this;this.__loaded=!0,this.config=xc(n.defaults),n.debug=this.Po(n.debug),this.Ao=n,this.Fo=[],n.person_profiles?this.Io=n.person_profiles:n.process_person&&(this.Io=n.process_person);var o=xc(n.defaults),s=Cc(n),c=K({},o,s,{name:r,token:a});N(o.rageclick)&&N(s.rageclick)&&(c.rageclick=K({},o.rageclick,s.rageclick)),N(o.session_recording)&&N(s.session_recording)&&(c.session_recording=K({},o.session_recording,s.session_recording)),this.set_config(c),this.config.on_xhr_error&&B.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=n.disable_compression?void 0:Z.GZipJS;var l=this.wo();if(this.persistence=new _o(this.config,l),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new _o(g({},this.config,{persistence:`sessionStorage`}),l,!1),this.Co=`ph_`+(this.config.persistence_name||this.config.token)+`_session_registered_properties`,this.config.persistence!==`memory`&&!l&&X.Nr()){var u=X.Br(this.Co);M(u)&&u.forEach((e=>{F(e)&&this.xo.add(e)}))}else X.qr(this.Co);var d=g({},this.persistence.props),f=g({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Oo=new js((e=>this.Lo(e)),this.config.request_queue_config),this.$o=new Ns(this),this.__request_queue=[];var m=this.bo();if(m||(this.sessionManager=new Bs(this),this.sessionPropsManager=new Is(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((e,t,n)=>{(n!=null&&n.activityTimeout||n!=null&&n.sessionPastMaximumLength||n!=null&&n.crossTabAdoption)&&this.Do()}))),this.No(),this.config.__preview_deferred_init_extensions?(B.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.qo(m)}),0)):(B.info(`Initializing extensions synchronously`),this.qo(m)),p.DEBUG=p.DEBUG||this.config.debug,p.DEBUG&&B.info(`Starting in debug mode`,{this:this,config:n,thisC:g({},this.config),p:d,s:f}),!this.config.identity_distinct_id||(i=n.bootstrap)!=null&&i.distinctID||(n.bootstrap=g({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),n.bootstrap?.distinctID!==void 0){var h=n.bootstrap.distinctID,_=this.get_distinct_id(),v=this.persistence.get_property(H);if(n.bootstrap.isIdentifiedID&&_!=null&&_!==h&&v===U)this.identify(h);else if(n.bootstrap.isIdentifiedID&&_!=null&&_!==h&&v===W)B.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var y=this.config.get_device_id(Si()),b=n.bootstrap.isIdentifiedID?y:h;this.persistence.set_property(H,n.bootstrap.isIdentifiedID?W:U),this.register({distinct_id:h,$device_id:b})}}if(m)this.register_once({distinct_id:qr,$device_id:null},``);else if(!this.get_distinct_id()){var x=this.config.get_device_id(Si());this.register_once({distinct_id:x,$device_id:x},``),this.persistence.set_property(H,U)}return q(e,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),n.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||Si();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(H,W)),t()},i=n.user();`then`in i&&ye(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{typeof Promise<`u`&&Promise.resolve||Pa.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Pa.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Pa.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,ii),identify:e=>t(e,oi),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.jo())):this.jo(),ye(this.config._onCapture)&&this.config._onCapture!==pc&&(B.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&B.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 Hs.apply(this,arguments)}().then((e=>{e&&this.register({[$n]:e})})).catch(pc),this}No(){var e,n,r,i=this.config.__extensionClasses?.featureFlags??t.__defaultExtensionClasses?.featureFlags;i&&(this.featureFlags&&this.featureFlags instanceof i||((e=this.Bo)==null||e.call(this),this.Bo=void 0,this.featureFlags=new i(this)),ye(this.featureFlags.onReloading)&&ye(this.featureFlags.setup)?this.Bo||(this.Bo=this.featureFlags.onReloading((()=>{this.co.emit(`featureFlagsReloading`,!0)})),this.Ho().add(this.featureFlags)):(n=(r=this.featureFlags).initialize)==null||n.call(r))}qo(e){var n=performance.now(),r=g({},t.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.exceptions&&this.lo.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.lo.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.lo.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.lo.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!e&&this.lo.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.lo.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.lo.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.lo.push(this.logs=this.logs??new r.logs(this)),r.metrics&&this.lo.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this.lo.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.lo.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.lo.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.lo.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.lo.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.lo.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,Ma)),r.toolbar&&this.lo.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.lo.push(this.experiments=this.experiments??new r.experiments(this)),this.lo.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Uo){var e=this.Uo;this.Uo=void 0,this.lo.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}})),this.zo(i,n)}zo(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.zo(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){B.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({[Yr]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Xr]:r}),this.config.__preview_deferred_init_extensions&&B.info(`PostHog extensions initialized (`+r+`ms)`)}Ks(e){var t;if(!r||!r.body)return B.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Ks(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Uo=e),this.vo=e,this.compression=void 0,e.ok){var n,i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=j(i.supportedCompression,Z.GZipJS)?Z.GZipJS:j(i.supportedCompression,Z.Base64)?Z.Base64:void 0),(n=i.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Io?this.Io:ti}),(t=this.Wo)==null||t.handleRemoteConfig(e),this.lo.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}jo(){try{this.config.loaded(this)}catch(e){B.critical("`loaded` function failed",e)}if(this.Vo(),this.config.internal_or_test_user_hostname&&i!=null&&i.hostname){var e=i.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.bo())&&this.Go()}),1),this.Zo=new Io(this),this.Zo.load()}Vo(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Oo)==null||e.enable())}_dom_loaded(){this.is_capturing()&&ci(this.__request_queue,(e=>this.Lo(e))),this.__request_queue=[],this.Vo()}_handle_unload(){var e,t,n,r,i;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(t=this.metrics)==null||t.flush(`sendBeacon`),this.config.request_batching?(this.Qo()&&this.capture(ai),(n=this.logs)==null||n.flushLogs(`sendBeacon`),(r=this.Oo)==null||r.unload(),(i=this.$o)==null||i.unload()):this.Qo()&&this.capture(ai,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded?bc?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=g({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,(P(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=g({},e);t.timeout=t.timeout||6e4;var n,r,i,a,o=t.transport??`fetch`;o===`sendBeacon`&&P(t.compression)&&t.data&&(t.compression=Z.Base64),t.method===`POST`&&t.data&&(t.timestampMode===`capture-body`?t.data={api_key:((a=(i=(M(n=t.data)?n:[n]).map((e=>g({},e,e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{}))))[0])==null||(r=a.properties)==null?void 0:r.token)??a?.token,batch:i,sent_at:new Date().toISOString()}:t.timestampMode===`body`&&(t.data=function(e,t){return t===void 0&&(t=new Date().toISOString()),M(e)?e.map((e=>g({},e,{sent_at:t}))):g({},e,{sent_at:t})}(t.data))),t.url=Os(t.url,t.method,t.compression,t.timestampMode);var s=ks.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),l=function(e,t){for(var n=0;e.length>n;n++)if(e[n].transport===o)return e[n]}(s)?.method??s[0].method;if(!l)throw Error(`No available transport method`);var u=e=>{try{l(e)}catch(e){Ts(e)?B.warn(e):B.error(e),t.callback==null||t.callback({statusCode:0,error:e})}};o!==`sendBeacon`&&t.data&&t.compression===Z.GZipJS&&c&&typeof Promise<`u`&&!_s?Cs(t).then((e=>{u(e)})).catch((n=>{if(te(n))return _s=!0,void u(g({},t,{compression:void 0,url:Os(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||typeof e!=`object`)return!1;var t=`name`in e?String(e.name):``;return te(e)||t===D})(n)&&(_s=!0),u(t)})):l(t)})(g({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}Lo(e){this.$o?this.$o.retriableRequest(e):this._send_request(e)}_execute_array(e){fc++;try{var t,n=[],r=[],i=[];ci(e,(e=>{if(e)if(M(t=e[0]))i.push(e);else if(ye(e))try{e.call(this)}catch(t){B.error(`Error executing queued PostHog call`,e,t)}else M(e)&&t===`alias`?n.push(e):M(e)&&t.indexOf(`capture`)!==-1&&ye(this[t])?i.push(e):r.push(e)}));var a=function(e,t){ci(e,(function(e){try{if(M(e[0])){var n=t;G(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){B.error(`Error executing queued PostHog call`,e,t)}}))};a(n,this),a(r,this),a(i,this)}finally{fc--}}push(e){if(fc>0&&M(e)&&F(e[0])){var n=t.prototype[e[0]];ye(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Oo){if(this.is_capturing())if(!P(e)&&F(e)){this._o();var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!F(t?.$current_url)&&(B.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.Jo||B.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&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=Vt(n?.uuid,Si),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===ii&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens);var p=e===`$feature_flag_called`&&!1===f.properties.$feature_flag_has_experiment&&!0===this.get_property(Tr);n!=null&&n.$set&&!p&&(f.$set=n?.$set);var m=n?.$unset;m&&(f.$unset=m);var h,_,v,y=p?void 0:this.Ko(n?.$set_once,e!==si,e===oi);if(y&&(f.$set_once=y),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>F(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){if(t!==Object(t))return a?a(t):t;if(!o.has(t)){var r;if(o.add(t),M(t))r=[],ci(t,(t=>{r.push(e(t))}));else{var i={};G(t,((t,n)=>{o.has(t)||(i[n]=e(t,n))})),r=i}return r}}(i)),f.timestamp=u,P(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),p&&(f.properties=function(e,t){t===void 0&&(t=[]);var n={},r=t=>{e[t]!==void 0&&(n[t]=e[t])};return S.forEach(r),t.forEach(r),n}(f.properties,vc)),e===Do.DISMISSED||e===Do.SENT){var b=t?.[Oo.SURVEY_ID],x=t?.[Oo.SURVEY_ITERATION];tc({id:b,current_iteration:x}),f.$set=g({},f.$set,{[(h={id:b,current_iteration:x},_=e===Do.SENT?`responded`:`dismissed`,v=`$survey_`+_+`/`+h.id,h.current_iteration&&h.current_iteration>0&&(v=`$survey_`+_+`/`+h.id+`/`+h.current_iteration),v)]:!0})}else e===Do.SHOWN&&(f.$set=g({},f.$set,{[Oo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===jo.SHOWN){var C=t?.[Mo.TOUR_TYPE];C&&(f.$set=g({},f.$set,{[Mo.TOUR_LAST_SEEN_DATE+`/`+C]:new Date().toISOString()}))}var w=g({},f.properties.$set,f.$set);if(be(w)||this.setPersonPropertiesForFlags(w),!L(this.config.before_send)){var T=this._n(f);if(!T)return;(f=T).uuid=Vt(f.uuid,Si)}this.co.emit(`eventCaptured`,f);var E=n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),D={method:`POST`,url:E,data:f,compression:`best-available`,timestampMode:n?._batchKey===`recordings`||/\/s\/(?:\?|$)/.test(E)?`body`:`capture-body`,batchKey:n?._batchKey,transport:n?.transport};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Lo(D):this.Oo.enqueue(D),f}B.critical(`This capture call is ignored due to client rate limiting.`)}}else B.error(`No event name provided to posthog.capture`)}else B.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}Ho(){return this.Wo??=new uc(this)}po(e){this.To.push(e);var t=!0;return()=>{if(t){t=!1;var n=this.To.indexOf(e);n!==-1&&this.To.splice(n,1)}}}Yo(e){var t,n,r;return e===void 0&&(e=!0),!((t=this.persistence)==null||!t.consumeCookieIdentityChange())&&(this.Ro=null,this.persistence.get_property(H)===U&&((r=this.sessionPersistence)==null||r.clear(),this.xo.clear(),this.Xo()),(n=this.featureFlags)==null||n.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,a,o,s){if(a||=new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.Yo();var c=s?void 0:this.persistence.remove_event_timer(t),u=g({},n);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this.bo()&&(u[Jr]=!0),t===`$snapshot`){var d=g({},this.persistence.properties(),this.sessionPersistence.properties());return u.distinct_id=d.distinct_id,(!F(u.distinct_id)&&!R(u.distinct_id)||xe(u.distinct_id))&&B.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),u}var f,m=function(t,n,r,a){var o,s,c;if(a===void 0&&(a=!1),!l)return{};var u,d=t?[...Za,...n||[]]:[],f=function(e){for(var t=0;Rt.length>t;t++){var n=Rt[t],r=n[1],i=n[0].exec(e),a=i&&(ye(r)?r(i,e):r);if(a)return a}return[``,``]}(l),m=f[0],h=f[1],g=(u=typeof navigator<`u`?navigator:void 0)!=null&&u.brave?{brave:!0}:{},_={};P(r)||(_.detectGoogleSearchApp=r);var v={},y=(o=navigator)==null||(o=o.userAgentData)==null?void 0:o.platform,b=navigator?.maxTouchPoints,x=e==null||(s=e.screen)==null?void 0:s.width,S=e==null||(c=e.screen)==null?void 0:c.height,C=e?.devicePixelRatio;P(y)||(v.userAgentDataPlatform=y),P(b)||(v.maxTouchPoints=b),P(x)||(v.screenWidth=x),P(S)||(v.screenHeight=S),P(C)||(v.devicePixelRatio=C);var w,T,E,D,O=K(fi({$os:m,$os_version:h,$browser:Ft(l,navigator.vendor,g,_),$device:zt(l),$device_type:(T=l,E=v,D=zt(T),D===He||D===Ve||D===`Kobo`||D===`Kindle Fire`||D===vt?Be:D===st||D===lt||D===ct||D===ht?`Console`:D===We?`Wearable`:D?Le:E?.userAgentDataPlatform===`Android`&&(E?.maxTouchPoints??0)>0?600>Math.min(E?.screenWidth??0,E?.screenHeight??0)/(E?.devicePixelRatio??1)?Le:Be:`Desktop`),$timezone:lo(),$timezone_offset:uo()}),{$current_url:Ka(a?Ht(i?.href):i?.href,d,$a),$host:i?.host,$pathname:i?.pathname,$raw_user_agent:l.length>1e3?l.substring(0,997)+`...`:l,$browser_version:Lt(l,navigator.vendor,g,_),$browser_language:io(),$browser_language_prefix:(w=io(),typeof w==`string`?w.split(`-`)[0]:void 0),$screen_height:e?.screen.height,$screen_width:e?.screen.width,$viewport_height:e?.innerHeight,$viewport_width:e?.innerWidth,$lib:p.LIB_NAME,$lib_version:p.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return p.SDK_DIST_CHANNEL&&(O.$sdk_dist_channel=p.SDK_DIST_CHANNEL),O}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var h=this.sessionManager.checkAndGetSessionAndWindowId(s,a.getTime(),!0),_=h.windowId;u.$session_id=h.sessionId,u.$window_id=_}this.sessionPropsManager&&K(u,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&K(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=this.$o?.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===Js&&(u.$lib_custom_api_host=this.config.api_host),f=t!==ii||s?t!==ai||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(a):this.pageViewManager.doPageView(a,o),u=K(u,f),t===ii&&r&&(u.title=r.title),!P(c)){var v=a.getTime()-c;u.$duration=parseFloat((v/1e3).toFixed(3))}l&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?`bot`:`browser`);var y=this.persistence.properties(),b=this.sessionPersistence.properties();G([`$referrer`,`$referring_domain`],(e=>{e in y&&delete b[e]}));var x={};if(this.To.length>0)for(var S of this.To.slice())try{K(x,S())}catch(e){B.error(`Failed to produce browser extension event properties`,e)}(u=K({},m,y,b,g({},x,u))).$is_identified=this._isIdentified(),M(this.config.property_denylist)?G(this.config.property_denylist,(function(e){delete u[e]})):B.error(_c+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var C=this.config.sanitize_properties;C&&(B.error(gc),u=C(u,t));var w=this.tl();return u.$process_person_profile=w,w&&!s&&this.el(`_calculate_event_properties`),u}Ko(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.tl()||this.So&&!n)return e;var r=K({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(B.error(gc),r=i(r,`$set_once`)),t&&(this.So=!0),be(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t,n;(t=this.persistence)==null||t.syncCookieProperties(),this.Yo(),(n=this.sessionPersistence)==null||n.register(e),Object.keys(e).forEach((e=>this.xo.add(e))),this.Xo()}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e),this.xo.delete(e),this.Xo()}il(e,t){this.register({[e]:t})}Do(){this.xo.forEach((e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)})),this.xo.clear(),this.Xo()}Xo(){var e;if(this.Co)if(this.config.persistence===`memory`||(e=this.sessionPersistence)!=null&&e.xs||!X.Nr())X.qr(this.Co);else{var t=[];this.xo.forEach((e=>t.push(e))),t.length>0?X.Dr(this.Co,t):X.qr(this.Co)}}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}getAllFeatureFlags(){return this.featureFlags?.getAllFeatureFlags()??[]}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)??t?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.co.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:hc}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:hc})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:hc})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=rc),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:hc}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:hc})}rl(e){return!e||xe(e)?(B.critical(`Unique user id has not been set in posthog.identify`),!1):e===qr?(B.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(B.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return B.uninitializedWarning(`posthog.identify`);if(R(e)&&(e=e.toString(),B.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.rl(e)&&this.el(`posthog.identify`)){this._o();var r=this.get_distinct_id(),i=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this.Yo(!1),o=this.persistence.Ms(),s=!1;try{var c=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Qn)||this.register_once({$had_persisted_distinct_id:!0,$device_id:c},``),e!==c&&e!==this.get_property(er)&&(this.unregister(er),this.register({distinct_id:e}));var l,u=(this.persistence.get_property(H)||U)===U,d=e!==c,f=!d&&u;if(d&&u)this.persistence.set_property(H,W),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Es(),this.capture(oi,{distinct_id:e,$anon_distinct_id:c},{$set:t||{},$set_once:n||{}}),this.Ro=Ws(e,t,n),(l=this.featureFlags)==null||l.setAnonymousDistinctId(c);else if(f){this.persistence.set_property(H,W);var p=t||{},m=n||{};this.setPersonPropertiesForFlags({$set:p,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.Es(),this.capture(`$set`,{$set:p,$set_once:m}),this.Ro=Ws(e,t,n)}else(t||n)&&this.setPersonProperties(t,n);d||i||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Lr)):f&&(t||n)&&this.reloadFeatureFlags(),s=!0}finally{o&&this.persistence.Ps(s)}}}setPersonProperties(e,t){if((e||t)&&this.el(`posthog.setPersonProperties`)){var n=Ws(this.get_distinct_id(),e,t);this.Ro===n?B.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Ro=n)}}unsetPersonProperties(e){var t,n=(M(e)?e:[e]).filter((e=>F(e)&&e.length>0));n.length!==0&&this.el(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this.Ro=null)}group(e,t,n){var r;if(e&&t){(r=this.persistence)==null||r.syncCookieProperties(),this.Yo();var i=this.getGroups(),a=i[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:g({},i,{[e]:t})}),a||n){var o={$group_type:e,$group_key:t};n&&(o.$group_set=n),this.capture(si,o)}n&&this.setGroupPropertiesForFlags({[e]:n}),a&&!n&&this.reloadFeatureFlags()}else B.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;e===void 0&&(e=!0),(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.el(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t=Ce(e)?e:e?.resetDeviceID,n=Ce(e)||e==null?void 0:e.bootstrap;this.nl(t,!1,n)}nl(e,t,n){var r,i;if(t===void 0&&(t=!1),B.info(`reset`),!this.__loaded)return B.uninitializedWarning(`posthog.reset`);var a=n?.sessionID;this.config.bootstrap=n||this.Ao?.bootstrap||{},(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.Xs());var o=this.get_property(Qn),s=this.get_property($n),c=this.get_property(dr),l=this.is_capturing();this.consent.reset(),t||!l||this.is_capturing()||console.warn(`[PostHog.js]`,"reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var u=(i=this.persistence)==null||i.Ms==null?void 0:i.Ms(),d=!1;try{var f,p,m,h,_,v,y,b,x,S,C,w,T,E;if((f=this.persistence)==null||f.clear(),(p=this.sessionPersistence)==null||p.clear(),this.xo.clear(),this.Xo(),P(c)||(C=this.persistence)==null||C.register({[dr]:c}),(m=this.surveys)==null||m.reset(),(h=this.Zo)==null||h.stop(),(_=this.featureFlags)==null||_.reset(),(v=this.conversations)==null||v.reset(),(y=this.logs)==null||y.reset(),(b=this.metrics)==null||b.reset(),(x=this.persistence)==null||x.set_property(H,U),(S=this.sessionManager)==null||S.resetSessionId(),this.Ro=null,this.config.cookieless_mode===ei)this.register_once({distinct_id:qr,$device_id:null},``);else{var D=this.config.get_device_id(Si());this.register_once({distinct_id:D,$device_id:e?D:o},``),e||P(s)||this.register({[$n]:s})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),n&&(n.distinctID===void 0||this.bo()||((E=this.persistence)==null||E.set_property(H,n.isIdentifiedID?W:U),this.register({distinct_id:n.distinctID})),(w=this.featureFlags)==null||w.initialize(),!(P(a)||(T=this.sessionManager)!=null&&T.setBootstrapSessionId(a,!0)))){var O=g({},n);delete O.sessionID,this.config.bootstrap=O}delete this.config.identity_distinct_id,delete this.config.identity_hash,d=!0}finally{var ee;u&&((ee=this.persistence)==null||ee.Ps==null||ee.Ps(d))}this.reloadFeatureFlags()}shutdown(e){var t=this;return h((function*(){var e,n,r,i,a,o,s;if(t.__loaded){(e=t.Zo)==null||e.stop(),(n=t.Wo)==null||n.dispose(),(r=t.sessionRecording)==null||r.dispose(),(i=t.logs)==null||i.flushLogs(`sendBeacon`),(a=t.metrics)==null||a.flush(`sendBeacon`),(o=t.Oo)==null||o.unload(),(s=t.$o)==null||s.unload();try{var c;(c=t.featureFlags)==null||c.destroy()}catch(e){B.error(`Error while destroying feature flags`,e)}}else B.uninitializedWarning(`posthog.shutdown`)}))()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.sl()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.al()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=t.sessionStartTimestamp,r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t.sessionId);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Xn)?(B.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.el(`posthog.alias`)?(P(t)&&(t=this.get_distinct_id()),e===t?(B.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.il(er,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=g({},this.config);if(N(e)){var n,r,i,a,o,s,c,l,u,d,f,m;K(this.config,Cc(e));var h=this.wo();(n=this.persistence)==null||n.update_config(this.config,t,h),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new _o(g({},this.config,{persistence:`sessionStorage`}),h,!1);var _=this.Po(this.config.debug);Ce(_)&&(this.config.debug=_),Ce(this.config.debug)&&(this.config.debug?(p.DEBUG=!0,Y.Nr()&&Y.Dr(`ph_debug`,!0),B.info(`set_config`,{config:e,oldConfig:t,newConfig:g({},this.config)})):(p.DEBUG=!1,Y.Nr()&&Y.qr(`ph_debug`))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.Xs()),(i=this.exceptionObserver)==null||i.onConfigChange(),(a=this.exceptions)==null||a.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(s=this.tracingHeaders)==null||s.startIfEnabledOrStop(),(c=this.autocapture)==null||c.startIfEnabled(),(l=this.heatmaps)==null||l.startIfEnabled(),(u=this.exceptionObserver)==null||u.startIfEnabledOrStop(),(d=this.deadClicksAutocapture)==null||d.startIfEnabledOrStop(),(f=this.surveys)==null||f.loadIfEnabled(),this.ko(),(m=this.externalIntegrations)==null||m.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){p.LIB_NAME=e,p.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(g({},r,t))}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??t.ol}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??yc;return e!==yc&&(e=yc+`.`+e),e}_isIdentified(){return this.persistence?.get_property(H)===W||this.sessionPersistence?.get_property(H)===W}tl(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===ti&&!this._isIdentified()&&be(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[er])&&((t=this.persistence)==null||(t=t.props)==null||!t[Kr]))}Qo(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.tl()||this.el(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.el(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}el(e){return this.config.person_profiles===`never`?(B.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.il(Kr,!0),!0)}wo(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==$r)}ko(){var e,t,n=this.wo();return this.persistence?.xs!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.xs!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n&&(this.xo.clear(),this.Xo()),n}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==ei){if(this.bo()){var r,i;this.nl(!0,!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Bs(this),this.pageViewManager=new Ra(this),this.persistence&&(this.sessionPropsManager=new Is(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??t.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.yo(this.sessionRecording,new o(this)),this.vo&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.vo)))}var s;this.consent.optInOut(!0),this.ko(),this.Vo(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==$r&&((s=this.surveys)==null||s.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture(e?.captureEventName??`$opt_in`,e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Go()}else B.warn(mc)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===ei?B.warn(mc):(this.config.cookieless_mode===$r&&this.consent.isOptedIn()&&this.nl(!0,!0),this.consent.optInOut(!1),this.ko(),this.config.cookieless_mode===$r&&(this.register({distinct_id:qr,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Go(),this.Vo()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===ei||(this.config.cookieless_mode===$r?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.ko()}_is_bot(){return n?Vs(n,this.config.custom_blocked_useragents):void 0}Go(){r&&(r.visibilityState===`visible`?this.Mo||(this.Mo=!0,this.capture(ii,{title:r.title},{send_instantly:!0}),this.Eo&&=(r.removeEventListener(ni,this.Eo),null)):this.Eo||(this.Eo=this.Go.bind(this),q(r,ni,this.Eo)))}debug(t){!1===t?(e?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(e?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Xs(){var e=this.Ao||{};return`advanced_disable_flags`in e?!!e.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(B.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):function(e,t,n,r,i){var a=t in e&&!L(e[t]),o=n in e&&!L(e[n]);return a?e[t]:!!o&&(i&&i.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])}(e,`advanced_disable_flags`,`advanced_disable_decide`,0,B):!!this.config.advanced_disable_flags}_n(e){if(L(this.config.before_send))return e;var t=Object.keys(e.properties??{}).filter(Ee),n=M(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n)try{if(r=i(r),L(r)){var a=`Event '`+e.event+`' was rejected in beforeSend function`;return Te(e.event)?B.warn(a+`. This can cause unexpected behavior.`):B.info(a),null}r.properties&&!be(r.properties)||B.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}catch(t){return B.error(`Error in beforeSend function for event '`+e.event+`':`,t),null}for(var o of t)if(r.properties&&L(r.properties[o]))return B.warn(`Event '`+e.event+`' had its '`+o+`' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){return this.pageViewManager.rs?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Po(e){var t=Ce(e)&&!e,n=Y.Nr()&&Y.Pr(`ph_debug`)===`true`;return!t&&(!!n||e)}};Tc.__defaultExtensionClasses={},Tc.ol=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=di(e.prototype[t[n]])}(Tc,[`identify`]);var Ec=class{constructor(e){this.disabled=!1===e;var 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,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},Dc=`$copy_autocapture`,Oc=V(`[AutoCapture]`);function kc(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Ac(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!qi(t));return t}function jc(t,n){var r,i=n.e,a=n.maskAllElementAttributes,o=n.maskAllText,s=n.elementAttributeIgnoreList,c=n.elementsChainAsString,l=n.disableCaptureUrlHashes;if(!qi(t))return{props:{}};for(var u=[t],d=new Set([t]),f=t;f.parentNode&&!Ji(f,`body`)&&Zi>u.length;)if(Xi(f.parentNode)){var p=f.parentNode.host;if(d.has(p))break;d.add(p),u.push(p),f=p}else{if(!qi(f.parentNode)||d.has(f.parentNode))break;d.add(f.parentNode),u.push(f.parentNode),f=f.parentNode}var m,h,_=[],v={},y=!1,b=!1;if(G(u,(e=>{var t=ga(e);if(Ji(e,`a`)){var n=e.getAttribute(`href`);y=!!(t&&n&&Ta(n))&&(l?Ht(n):n)}j(ea(e),`ph-no-capture`)&&(b=!0),_.push(function(e,t,n,r,i){i===void 0&&(i=!1);var a=e.tagName.toLowerCase(),o={tag_name:a};ia.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?kc(1024,Ea(e)):kc(1024,na(e)));var s=ea(e);s.length>0&&(o.classes=s.filter((function(e){return e!==``}))),G(e.attributes,(function(n){var a;if((!_a(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&Ta(n.value)&&(!F(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){var s=n.value;n.name===`class`&&(s=Qi(s).join(` `)),o[`attr__`+n.name]=kc(1024,n.name===`href`&&i?Ht(s):s)}}));for(var c=1,l=1,u=e;u=Ac(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,a,o,s,l)),K(v,function(e){if(!ga(e))return{};var t={};return G(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&Ta(r)&&(t[n]=r)}})),t}(e))})),b)return{props:{},explicitNoCapture:b};if(o||(_[0].$el_text=Ji(t,`a`)||Ji(t,`button`)?Ea(t):na(t)),y){var x;_[0].attr__href=y;var S=Wa(y)?.host,C=e==null||(x=e.location)==null?void 0:x.host;S&&C&&S!==C&&(m=y)}return{props:K({$event_type:i.type,$ce_version:1},c?{}:{$elements:_},{$elements_chain:(h=_,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=g({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return li(r).sort(((e,t)=>e[0].localeCompare(t[0]))).forEach((e=>{var t=e[1];return i[Oa(e[0].toString())]=Oa(t.toString())})),(t+=`:`)+li(i).map((e=>e[0]+`="`+e[1]+`"`)).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:ka(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return li(e).filter((e=>e[0].indexOf(`attr__`)===0)).forEach((e=>t.attributes[e[0]]=e[1])),t}))}(h)))},(r=_[0])!=null&&r.$el_text?{$el_text:_[0]?.$el_text}:{},m&&i.type===`click`?{$external_click_url:m}:{},v)}}var Mc=V(`[ExceptionAutocapture]`),Nc=()=>{},Pc=V(`[TracingHeaders]`),Fc=V(`[Web Vitals]`),Ic=9e5,Lc=`disabled`,Rc=`lazy_loading`,zc=`awaiting_config`,Bc=`missing_config`;V(`[SessionRecording]`),V(`[SessionRecording]`);var Vc=`[SessionRecording]`,Hc=V(Vc),Uc=V(`[Heatmaps]`);function Wc(e){return N(e)&&`clientX`in e&&`clientY`in e&&R(e.clientX)&&R(e.clientY)}var Gc=V(`[Product Tours]`),Kc=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(lr))},qc=[`$set_once`,`$set`],Jc=V(`[SiteApps]`),Yc=`Error while initializing PostHog app with config id `;function Xc(e,t,n){if(L(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Zc=class{constructor(e){this.ll=new Ls,this.ul=(e,t)=>this.hl(e,t)&&this.dl(e,t)&&this.vl(e,t)&&this.cl(e,t),this.hl=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.fl=new Set,this.pl=new Set}init(){var e;P(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!P(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.pl)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.fl)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.fl.has(e)||this.fl.has(t.event))&&this.pl&&this.pl?.size>0&&this.pl.forEach((e=>{this.gl(t,e)&&this.ll.emit(`actionCaptured`,e.name)}))}ml(e){this.onAction(`actionCaptured`,(t=>e(t)))}gl(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.ul(e,n))return!0;return!1}onAction(e,t){return this.ll.on(e,t)}dl(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!Xc(r,t.url,t.url_matching||`contains`))return!1}return!0}vl(e,t){return!!this.yl(e,t)&&!!this.bl(e,t)&&!!this._l(e,t)}yl(e,t){var n;if(t==null||!t.href)return!0;var r=this.wl(e);if(r.length>0)return r.some((e=>Xc(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&Xc((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}bl(e,t){var n;if(t==null||!t.text)return!0;var r=this.wl(e);if(r.length>0)return r.some((e=>Xc(e.text,t.text,t.text_matching||`exact`)||Xc(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!L(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>Xc(e,a,o))))}_l(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}wl(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}cl(e,t){return t==null||!t.properties||t.properties.length===0||qs(t.properties.reduce(((e,t)=>{var n=M(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},Qc=class{constructor(e){var t;this.kl=[],this._instance=e,this.Sl=new Map,this.xl=new Map,this.Cl=new Map,(t=this._instance)==null||t.onSessionId==null||t.onSessionId((e=>this.Tl(e)))}Ml(e){return!1}El(){return null}Il(e){}Rl(){}Pl(e,t){return!!e&&qs(e.propertyFilters,t?.properties)}Al(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}Fl(e,t,n){var r=(n===yo.Activation?this.Sl:this.xl).get(e),i=[];return this.Ol((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Pl(a,t)}))}register(e){P(this._instance?._addCaptureHook)||(this.Ll(e),this.$l(e))}$l(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.Dl??(this.Dl=new Zc(this._instance),this.Dl.init(),this.Dl.ml((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.Dl)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.Cl.get(t.name);n&&n.push(e.id),this.Cl.set(t.name,n||[e.id])}})))})))}Ll(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this.Sl=this.Al(e,yo.Activation),this.xl=this.Al(e,yo.Cancellation))}onEvent(e,t){var n,r,i=this.Nl(),a=(t==null||(n=t.properties)==null?void 0:n.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var o=this.ql(e,a);if(o===`consume`)return i.info(`event consumed activated item, removing it`,{event:e,itemId:a}),void this.jl([a]);if(o===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),this.Bl(a),void this.Hl([a])}if(this.xl.has(e)){var s=this.Fl(e,t,yo.Cancellation);s.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:s.map((e=>e.id))}),this.jl(s.map((e=>e.id))),s.forEach((e=>this.Ul(e.id))))}if(this.Sl.has(e)){i.info(`event name matched`,{event:e,eventPayload:t,items:this.Sl.get(e)});var c=this.Fl(e,t,yo.Activation);this.zl(c.map((e=>e.id)))}}onAction(e){this.Cl.has(e)&&this.zl(this.Cl.get(e)||[])}zl(e){var t;if(e.length!==0){var n=!((t=this._instance)==null||t.get_session_id==null||!t.get_session_id()),r=[];for(var i of e)n&&this.Ml(i)?this.Bl(i)&&this.Wl(i):r.push(i);r.length>0&&(this.kl=[...new Set([...this.kl,...r])]),this.Nl().info(`updating activated items`,{activatedItems:this.getActivatedIds()})}}Bl(e){this.kl=this.kl.filter((t=>t!==e));var t=this.Vl();return!t.includes(e)&&(this.Gl([...t,e]),this.Zl(),!0)}jl(e){var t=new Set(e);this.kl=this.kl.filter((e=>!t.has(e)));var n=this.Ql(),r=n.filter((e=>!t.has(e)));r.length!==n.length&&(this.Gl(r),r.length===0&&this.Jl()),this.Hl(e)}Kl(){var e,t=this.El();if(!t)return{};var n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return n&&typeof n==`object`?n:{}}Wl(e){if(this.El()){var t=this.Kl();this.Il(g({},t,{[e]:Date.now()}))}}Hl(e){if(this.El()){var t=this.Kl(),n={},r=!1;for(var i of Object.entries(t)){var a=i[0],o=i[1];e.includes(a)?r=!0:n[a]=o}r&&(be(n)?this.Rl():this.Il(n))}}Yl(){this.El()&&this.Rl()}getActivationTimestamp(e){if(this.Vl().includes(e)){var t=this.Kl()[e];return R(t)?t:void 0}}Ql(){var e,t=this.Xl();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}Vl(){var e,t,n=this.Ql();if(n.length===0)return[];var r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.tu()],i=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();return i&&r===i?n:[]}Zl(){var e,t=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();t&&this.eu(t)}Jl(){this.iu()}Tl(e){var t,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.tu()];if(n&&n!==e){var r=this.Ql(),i=this.Kl();r.length>0&&(this.Gl([]),r.filter((e=>R(i[e]))).forEach((e=>this.Ul(e)))),this.Jl(),this.Yl()}}getActivatedIds(){return[...new Set([...this.Vl(),...this.kl])].filter((e=>!this.ru(e)))}reset(){this.kl=[],this.Ql().length>0&&this.Gl([]),this.Jl(),this.Yl()}getEventToItemsMap(){return this.Sl}nu(){return this.Dl}},$c=class extends Qc{constructor(e){super(e)}Xl(){return Nr}tu(){return Pr}El(){return Fr}Il(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Fr]:e})}Rl(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Fr)}Ml(e){var t,n;this.Ol((t=>{n=t.find((t=>t.id===e))}));var r=(t=n)==null||(t=t.appearance)==null?void 0:t.surveyPopupDelaySeconds;return R(r)&&r>0}su(){return Do.SHOWN}Ol(e){var t;(t=this._instance)==null||t.getSurveys(e)}Ul(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Nl(){return $}Gl(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Nr]:e})}eu(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Pr]:e})}iu(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Pr)}ru(){return!1}ql(e,t){var n;return this.Ol((e=>{n=e.find((e=>e.id===t))})),!n||function(e){var t;return $s(e)&&!((t=e.conditions)==null||(t=t.events)==null||!t.repeatedActivation)||e.schedule===`always`}(n)?e===Do.SHOWN?`consume`:`ignore`:e===Do.SHOWN?`persist`:e===Do.DISMISSED||e===Do.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},el=`SDK is not enabled or survey functionality is not yet loaded`,tl=`Disabled. Not loading surveys.`,nl=e!=null&&e.location?qa(e.location.hash,`__posthog`)||qa(location.hash,`state`):null,rl=`_postHogToolbarParams`,il=V(`[Toolbar]`),al=V(`[FeatureFlags]`),ol=class{constructor(e,t){t===void 0&&(t=!1),this.au=!1,this.update(e,t)}update(e,t){this.ou=((e,t)=>({bootstrap:{featureFlags:e.bootstrap?.featureFlags,featureFlagPayloads:e.bootstrap?.featureFlagPayloads},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?`none`:`base64`,evaluationContexts:e.evaluation_contexts??e.evaluation_environments??[],flagKeys:M(e.flag_keys)?e.flag_keys:void 0}))(e,t),!e.evaluation_environments||e.evaluation_contexts||this.au||(al.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.au=!0),P(e.flag_keys)||M(e.flag_keys)||al.error(`Invalid flag_keys found:`,e.flag_keys,`Expected array of non-empty strings`)}get(){return this.ou}},sl=V(`[FeatureFlags]`),cl=V(`[FeatureFlags]`,{debugEnabled:!0}),ll=`" failed. Feature flags didn't load in time.`,ul=`connection_error`,dl=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},fl=e=>{var t={};for(var n of li(e||{})){var r=n[1];r&&(t[n[0]]=r)}return t},pl=V(`[Error tracking]`),ml=[`chrome-extension://`,`moz-extension://`,`safari-extension:`,`safari-web-extension:`],hl=`Refusing to render web experiment since the viewer is a likely bot`,gl={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Us(t,e),not_regex:(e,t)=>!Us(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},_l=class t{get Di(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){e===void 0&&(e=!1),n.getWebExperiments((e=>{t.lu(`retrieved web experiments from the server`),n.uu=new Map,e.forEach((e=>{if(e.feature_flag_key){var r;n.uu&&(t.lu(`setting flag key `,e.feature_flag_key,` to web experiment `,e),(r=n.uu)==null||r.set(e.feature_flag_key,e));var i=n._instance.getFeatureFlag(e.feature_flag_key);F(i)&&e.variants[i]&&n.hu(e.name,i,e.variants[i].transforms)}else if(e.variants)for(var a in e.variants){var o=e.variants[a];t.du(o,n._instance)&&n.hu(e.name,a,o.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())t.lu(hl);else if(!this.Di.disable_web_experiments){if(L(this.uu))return this.uu=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.lu(`applying feature flags`,e),e.forEach((e=>{var t;if(this.uu&&(t=this.uu)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.uu?.get(e);n&&r!=null&&r.variants[n]&&this.hu(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var n=Ga(e?.search,`__experiment_id`),r=Ga(e?.search,`__experiment_variant`);n&&r&&(t.lu(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.vu(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Di.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Di.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.Di.token),method:`GET`,timestampMode:`query`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}vu(e,n,r){var i=r.filter((t=>t.id===e));i&&i.length>0&&(t.lu(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.hu(i[0].name,n,i[0].variants[n].transforms))}static du(e,n){return!L(e.conditions)&&t.cu(e,n)&&t.fu(e)}static cu(e,n){if(L(e.conditions)||L(e.conditions?.url))return!0;var r=t.getWindowLocation();if(r){var i,a=Vi(n,r.href);return(i=e.conditions)==null||!i.url||gl[e.conditions?.urlMatchType??`icontains`](e.conditions.url,a)}return!1}static getWindowLocation(){return e?.location}static fu(e){if(L(e.conditions)||L(e.conditions?.utm))return!0;var t=to();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static lu(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];B.info(`[WebExperiments] `+e,n)}hu(e,n,r){this._is_bot()?t.lu(hl):n===`control`?t.lu(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(t.lu(`applying transform of variant `+n+` for experiment `+e+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return n&&this._instance?Vs(n,this.Di.custom_blocked_useragents):void 0}},vl=V(`[Conversations]`),yl=`Conversations not available yet.`,bl=`console`,xl=`__posthogHandledLogsRequestError`,Sl=(e,t)=>{var n=e instanceof Error?e:Error(t);return n[xl]=!0,n},Cl=e=>!!e&&typeof e==`object`&&!0===e[xl],wl={featureFlags:class{constructor(e){this.name=`featureFlags`,this.pu=!1,this.featureFlagEventHandlers=[],this.I=sl,this.gu={},this.mu={},this.yu=[],this.bu=!1,this._u=!1,this.wu=0,this.ku=!1,this.Su=!1,this.xu=!1,this.Cu=!1,this.Tu=0,this.Tt=()=>{var e=this.Mu();this.Tu=0,e&&this.reloadFeatureFlags()},`get`in e?this.Eu=e:(this.Iu=new ol(e.config,e.Xs()),this.Eu=this.Iu)}updateConfig(e,t){var n;(n=this.Iu)==null||n.update(e,t)}setup(e){return this.Ru=e,this.I=e.logger.createLogger(`[FeatureFlags]`),n=()=>{this.Ru===e&&(this.Ru=void 0,this.oo=e,this.Pu(e))},(t=e.kv.initialize())!=null&&t.then?t.then(n):n();var t,n}Pu(t){if(this.oo===t)return e&&q(e,`online`,this.Tt),this.Au=t.registerDynamicEventProperties((()=>this.Fu()?this.gu:this.mu)),this.Ou(),this.initialize()}destroy(){e?.removeEventListener(`online`,this.Tt)}dispose(){var t;this.wu++,this.Su=!1,this.Ru=void 0,this.oo&&=(this.Lu(),(t=this.Au)==null||t.dispose(),this.Au=void 0,this.yu=[],e?.removeEventListener(`online`,this.Tt),void 0)}get Di(){return this.Eu.get()}$u(e){return this.oo?.kv.get(e)}Dr(e){this.Du((()=>this.oo?.kv.set(e)))}qr(e){this.Du((()=>this.oo?.kv.remove(e)))}Du(e){try{e()}catch(e){this.I.error(`Failed to update feature flag persistence`,e)}}Ou(){var e={};for(var t of[br,Cr,wr,Er]){var n=this.$u(t);P(n)||(e[t]=n)}this.gu=e;var r=g({},e),i=this.$u(yr);if(i)for(var a of Object.entries(i))r[`$feature/`+a[0]]=a[1];this.mu=r}Fu(){var e=this.Di.cacheTtlMs;if(!e||0>=e)return!1;var t=this.$u(Br);return typeof t!=`number`||Date.now()-t>e}Nu(){return!!this.Fu()&&(this.Cu||this._u||(this.Cu=!0,this.I.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}qu(){var e=this.Di.evaluationContexts;return e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||this.I.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}ju(){var e=this.Di.flagKeys;if(!P(e))return e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||this.I.error(`Invalid flag key found:`,e,`Expected non-empty string`),t}))}initialize(){var e=this.Di,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(e[t]=n[t],e)),{});return this.Bu({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r,i,a=n!=null&&n.merge&&(r=this.$u(yr))!=null?r:{},o=n!=null&&n.merge&&(i=this.$u(Cr))!=null?i:{},s=g({},a,e),c=g({},o,t),l={};for(var u of Object.entries(s)){var d=u[0],f=u[1];l[d]={key:d,enabled:y(f),variant:b(f),reason:void 0,metadata:P(c?.[d])?void 0:{id:0,version:void 0,description:void 0,payload:c[d]}}}this.Bu({flags:l})}get hasLoadedFlags(){return this.bu}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.$u(Sr),t=this.$u(Er),n=this.$u(Dr);if(!n&&!t)return e||{};var r=K({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=P(c)?(a=s?.enabled)!=null&&a:!!c,u=P(c)?s?.variant:typeof c==`string`?c:void 0,d=n?.[i],f=g({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=g({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.pu||=(this.I.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((n=>{var r=e[n];return{key:n,enabled:y(r),variant:b(r),payload:v(t[n])}}))}getFlagVariants(){var e=this.$u(yr),t=this.$u(Er);if(!t)return e||{};for(var n=K({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.pu||=(this.I.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.$u(Cr),t=this.$u(Dr);if(!t)return e||{};for(var n=K({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.pu||=(this.I.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.ku||this.Di.featureFlagsDisabled||this.Mu()||this.Hu||(this.yu.slice().forEach((e=>{try{e()}catch(e){this.I.error(`Error while running feature flags reloading callback`,e)}})),this.Hu=setTimeout((()=>{this.Uu()}),5))}Lu(){clearTimeout(this.Hu),this.Hu=void 0}onReloading(e){return this.yu.push(e),()=>{this.yu=this.yu.filter((t=>t!==e))}}ensureFlagsLoaded(){this.bu||this._u||this.Hu||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ku=e}resetFlagCallReported(){this.qr(Lr)}Uu(e){this.Lu();var t=this.oo;if(t&&!this.Di.remoteRequestsDisabled&&!this.Mu())if(this._u)this.Su=!0;else{var n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:g({},t.initialPersonProperties,this.$u(Or)||{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.$u(kr),timezone:lo()};P(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Di.featureFlagsDisabled)&&(n.disable_flags=!0);var r=this.qu();r.length&&(n.evaluation_contexts=r);var i=this.ju();P(i)||(n.flag_keys=i);var a=this.Di.onlyEvaluateSurveyFeatureFlags,o=`/flags/?v=2`+(a?`&only_evaluate_survey_feature_flags=true`:``),s=this.wu;this._u=!0;var c=()=>{this.Su&&(this.Su=!1,this.Uu())},l=e=>{this._u=!1,s===this.wu?(this.Dr({[zr]:[ul]}),this.I.error(`Feature flag request failed`,e),c()):c()};try{t.sendRequest(o,{target:`flags`,method:`POST`,body:n,compression:this.Di.compression===`base64`?Z.Base64:void 0,sentAt:`body`,timeoutMs:this.Di.requestTimeoutMs}).then((e=>{var t,r=e.json??{},i=e.statusCode!==200;if(this._u=!1,s===this.wu){if(this.zu(e.statusCode),i||this.Su||(this.$anon_distinct_id=void 0),!n.disable_flags||this.Su){this.xu=!i;var o=[];e.error?o.push(e.error instanceof Error&&e.error.name===`AbortError`?`timeout`:e.error instanceof Error?ul:`unknown_error`):e.statusCode!==200&&o.push(`api_error_`+e.statusCode),r.errorsWhileComputingFlags&&o.push(`errors_while_computing_flags`);var l=!((t=r.quotaLimited)==null||!t.includes(`feature_flags`));l&&o.push(`quota_limited`),this.Dr({[zr]:o}),l?this.I.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.`):n.disable_flags||this.Bu(r,i,{partialResponse:a}),c()}}else c()})).catch(l)}catch(e){l(e)}}}Mu(){return Ja(this.Tu,3)}zu(e){this.Tu=Ya(e,this.Tu,3,(()=>this.I.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){if(t===void 0&&(t={}),!t.fresh||this.xu)if(this.bu||this.getFlags()&&this.getFlags().length>0){if(!this.Nu()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else this.I.warn(`getFeatureFlag for key "`+e+ll)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.xu)if(this.bu||this.getFlags()&&this.getFlags().length>0){if(!this.Nu()){var n,r=this.getFlagVariants(),i=e in r,a=r[e],o=this.getFlagPayloads()[e],s=String(a),c=this.$u(wr)||void 0,l=this.$u(Br)||void 0,u=this.$u(Lr)||{};if(this.Di.deduplicateCallsPerSession){var d=this.oo?.session.sessionId,f=this.$u(Rr);d&&d!==f&&(u={},n=d)}if(t.send_event||!(`send_event`in t))if(e in u&&u[e].includes(s))n&&this.Dr({[Lr]:u,[Rr]:n});else{var p,m,h,_,y,b,x,S;M(u[e])?u[e].push(s):u[e]=[s],this.Dr(g({[Lr]:u},n?{[Rr]:n}:{}));var C=this.getFeatureFlagDetails(e),w=[...this.$u(zr)??[]];P(a)&&w.push(`flag_missing`);var T={$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:o??null,$feature_flag_request_id:c,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((p=this.Di.bootstrap)==null||(p=p.featureFlags)==null?void 0:p[e])??null,$feature_flag_bootstrapped_payload:((m=this.Di.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[e])??null,$used_bootstrap_value:!this.xu};P(C==null||(h=C.metadata)==null?void 0:h.has_experiment)||(T.$feature_flag_has_experiment=C.metadata.has_experiment),P(C==null||(_=C.metadata)==null?void 0:_.version)||(T.$feature_flag_version=C.metadata.version);var E,D=(C==null||(y=C.reason)==null?void 0:y.description)??(C==null||(b=C.reason)==null?void 0:b.code);D&&(T.$feature_flag_reason=D),C!=null&&(x=C.metadata)!=null&&x.id&&(T.$feature_flag_id=C.metadata.id),P(C?.original_variant)&&P(C?.original_enabled)||(T.$feature_flag_original_response=P(C.original_variant)?C.original_enabled:C.original_variant),C!=null&&(S=C.metadata)!=null&&S.original_payload&&(T.$feature_flag_original_payload=C==null||(E=C.metadata)==null?void 0:E.original_payload),w.length&&(T.$feature_flag_error=w.join(`,`)),this.Wu(T)}else n&&this.Dr({[Lr]:u,[Rr]:n});if(i)return{key:e,enabled:!!a,variant:typeof a==`string`?a:void 0,payload:v(o)}}}else this.I.warn(`getFeatureFlagResult for key "`+e+ll)}Wu(e){try{var t;(t=this.oo)==null||t.capture(`$feature_flag_called`,e).catch((e=>{this.I.error(`Failed to capture feature flag call`,e)}))}catch(e){this.I.error(`Failed to capture feature flag call`,e)}}getRemoteConfigPayload(e,t){this.Vu(e,t)}Vu(e,t){var n=this;return h((function*(){var r=n.oo;if(r){var i={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},a=n.qu();a.length&&(i.evaluation_contexts=a);var o,s=n.ju();P(s)||(i.flag_keys=s);try{o=(yield r.sendRequest(`/flags/?v=2`,{target:`flags`,method:`POST`,body:i,compression:n.Di.compression===`base64`?Z.Base64:void 0,sentAt:`body`,timeoutMs:n.Di.requestTimeoutMs})).json?.featureFlagPayloads?.[e]||void 0}catch(e){n.I.error(`Remote config feature flag request failed`,e);return}try{t(o)}catch(e){n.I.error(`Remote config feature flag callback failed`,e)}}}))()}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.xu)return t.defaultValue;if(!(this.bu||this.getFlags()&&this.getFlags().length>0))return this.I.warn(`isFeatureEnabled for key "`+e+ll),t.defaultValue;var n=this.getFeatureFlag(e,t);return P(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){this.Bu(e,t,n)}Bu(e,t,n){if(this.oo){this.bu=!0;var r=function(e,t,n,r,i,a){t===void 0&&(t={}),n===void 0&&(n={}),r===void 0&&(r={}),a===void 0&&(a=sl);var o=((e,t)=>{var n=e.flags;return n?g({},e,{featureFlags:Object.fromEntries(Object.keys(n).map((e=>[e,n[e].variant??n[e].enabled]))),featureFlagPayloads:Object.fromEntries(Object.keys(n).filter((e=>n[e].enabled)).filter((e=>n[e].metadata?.payload)).map((e=>[e,n[e].metadata?.payload])))}):(e.featureFlags&&t.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e)})(e,a),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(M(c)){a.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;return{[br]:c,[yr]:f,[Tr]:!1}}var m=c,h=l,_=s;if(i!=null&&i.partialResponse)m=g({},t,m),h=g({},n,h),_=g({},r,_);else if(e.errorsWhileComputingFlags)if(s){var v=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=g({},t,Object.fromEntries(Object.entries(m).filter((e=>v.has(e[0]))))),h=g({},n,Object.fromEntries(Object.entries(h||{}).filter((e=>v.has(e[0]))))),_=g({},r,Object.fromEntries(Object.entries(_||{}).filter((e=>v.has(e[0])))))}else m=g({},t,m),h=g({},n,h),_=g({},r,_);return g({[br]:Object.keys(fl(m)),[yr]:m||{},[Cr]:h||{},[Sr]:_||{},[Tr]:!0===e.minimalFlagCalledEvents},u?{[wr]:u}:{},d?{[Br]:d}:{})}}(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.I);r&&this.Dr(r),t||(this.Cu=!1),this.Gu(t)}}override(e,t){t===void 0&&(t=!1),this.I.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Zu(e)}Zu(e){if(this.oo){if(!1===e)return this.qr([Er,Dr]),this.Gu(),void cl.info(`All overrides cleared`);if(M(e))return this.Dr({[Er]:dl(e)}),this.Gu(),void cl.info(`Flag overrides set`,{flags:e});if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var t,n=e;this.pu=!!((t=n.suppressWarning)!=null&&t);var r={},i=n.flags,a=n.payloads;i&&(r[Er]=M(i)?dl(i):i),a&&(r[Dr]=a),Object.keys(r).length&&this.Dr(r),!1===i&&!1===a?this.qr([Er,Dr]):!1===i?this.qr(Er):!1===a&&this.qr(Dr),this.Gu(),!1===i?cl.info(`Flag overrides cleared`):i&&cl.info(`Flag overrides set`,{flags:i}),!1===a?cl.info(`Payload overrides cleared`):a&&cl.info(`Payload overrides set`,{payloads:a});return}if(e&&typeof e==`object`)return this.Dr({[Er]:e}),this.Gu(),void cl.info(`Flag overrides set`,{flags:e});this.I.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}else this.I.warn(`posthog.featureFlags.overrideFeatureFlags called before feature flags were ready`)}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.bu){var t=this.Qu(),n=t.flags,r=t.flagVariants;try{e(n,r)}catch(e){this.I.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r=(this.$u(xr)||[]).find((t=>t.flagKey===e)),i={[`$feature_enrollment/`+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:i};r&&(a.$early_access_feature_name=r.name),n&&(a.$feature_enrollment_stage=n);var o=g({},this.getFlagVariants(),{[e]:t});this.Dr({[br]:Object.keys(fl(o)),[yr]:o,[Or]:g({},this.$u(Or)||{},i)}),this.Gu();try{var s;(s=this.oo)==null||s.capture(`$feature_enrollment_update`,a).catch((e=>{this.I.error(`Failed to capture early access feature enrollment`,e)}))}catch(e){this.I.error(`Failed to capture early access feature enrollment`,e)}}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.$u(xr);!r||t?this.Ju(e,n):e(r)}Ju(e,t){var n=this;return h((function*(){var r=n.oo;if(r){var i,a=t?`&`+t.map((e=>`stage=`+e)).join(`&`):``;try{var o=yield r.sendRequest(`/api/early_access_features/?token=`+r.projectToken+a,{target:`api`,method:`GET`,sentAt:`query`});if(!o.json)return;n.Dr({[xr]:i=o.json.earlyAccessFeatures})}catch(e){n.I.error(`Early access feature request failed`,e);return}try{e(i)}catch(e){n.I.error(`Early access feature callback failed`,e)}}}))()}Qu(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}Gu(e){this.Ou();var t=this.Qu(),n=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach((t=>{try{t(n,r,{errorsLoading:e})}catch(e){this.I.error(`Error while running feature flags callback`,e)}}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.Ku(e,t)}Ku(e,t){t===void 0&&(t=!0);var n=this.$u(Or)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this.Dr({[Or]:g({},n,a,r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=g({},this.$u(Or)||{});e.forEach((e=>{delete n[e]})),this.Dr({[Or]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this.qr(Or),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.$u(kr)||{},r=g({},n);for(var i of Object.keys(e))r[i]=g({},n[i],e[i]);this.Dr({[kr]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.$u(kr)||{};this.Dr({[kr]:g({},t,{[e]:{}})})}else this.qr(kr)}reset(){this.wu++,this.Su=!1,this.gu={},this.mu={},this.bu=!1,this.ku=!1,this.xu=!1,this.$anon_distinct_id=void 0,this.Lu(),this.pu=!1,this.Tu=0}}},Tl={sessionRecording:class{get Di(){return this._instance.config}get Ta(){return this._instance.persistence}get started(){var e;return!((e=this.Yu)==null||!e.isStarted)}get status(){return this.Xu===zc||this.Xu===Bc?this.Xu:this.Yu?.status??this.Xu}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Xu=Lc,this.th=void 0,this.eh=!1,this.kt=(()=>{var t;if(r==null||!r.visibilityState||r.visibilityState===`visible`)return!0;var n=e==null||(t=e.performance)==null||t.getEntriesByType==null?void 0:t.getEntriesByType(`visibility-state`);return!(n!=null&&n.length)||n.some((e=>e.name===`visible`))})(),this.It=()=>{var e;r?.visibilityState===`visible`&&(this.kt=!0,(e=this.Yu)==null||e.setDocumentWasEverVisible==null||e.setDocumentWasEverVisible(!0))},this._instance=t,!this._instance.sessionManager)throw Hc.error(`started without valid sessionManager`),Error(Vc+` started without valid sessionManager. This is a bug.`);if(this.Di.cookieless_mode===ei)throw Error(Vc+` cannot be used with cookieless_mode="always"`);r!=null&&r.addEventListener&&q(r,`visibilitychange`,this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.eh=!0,r==null||r.removeEventListener==null||r.removeEventListener(`visibilitychange`,this.It),this.stopRecording()}get ih(){var t,n=!((t=this._instance.get_property(dr))==null||!t.enabled),r=!this.Di.disable_session_recording,i=this.Di.disable_session_recording||this._instance.consent.isOptedOut();return e&&n&&r&&!i}startIfEnabledOrStop(e){var t;if(!(this.eh||this.ih&&(t=this.Yu)!=null&&t.isStarted)){var n=!P(Object.assign)&&!P(Array.from);this.ih&&n?(this.rh(e),Hc.info(`starting`)):(this.Xu=Lc,this.stopRecording())}}rh(e){var t,n,r;this.ih&&(this.Xu!==zc&&this.Xu!==Bc&&(this.Xu=Rc),f!=null&&(t=f.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=f.__PosthogExtensions__)!=null&&n.initSessionRecording?this.nh(e):(r=f.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.sh,(t=>{if(t)return this._instance.register_for_session({[Zr]:!0}),Hc.error(`could not load recorder`,t);this.nh(e)})))}stopRecording(){var e,t;(e=this.th)==null||e.call(this),this.th=void 0,(t=this.Yu)==null||t.stop()}ah(){var e,t;(e=this.th)==null||e.call(this),this.th=void 0,(t=this.Yu)==null||t.discard()}oh(){var e,t;(e=this.Ta)==null||e.unregister(vr),(t=this.Ta)==null||t.unregister(fr)}lh(e,t){if(L(e))return null;var n,r=R(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(Hc.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}uh(e){if(this.Ta){var t,n=this.Ta,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.lh(this.Di.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.lh(t?.sampleRate,`remote config sampleRate`),a=r??i;L(a)&&this.oh();var o=t?.minimumDurationMilliseconds;n.register({[dr]:g({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:g({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:P(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.th)==null||t.call(this),this.th=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;t&&`sessionRecording`in t?!1===t.sessionRecording?(this.uh(t),this.ah()):(this.uh(t),this.startIfEnabledOrStop()):(this.Xu===zc&&(this.Xu=Bc,Hc.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.Yu)!=null&&n.log?this.Yu.log(e,t):Hc.warn(`log called before recorder was ready`)}get sh(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(dr);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}hh(){var e,t=this._instance.get_property(dr);if(!t)return!1;try{e=typeof t==`object`?t:JSON.parse(t)}catch(e){return Hc.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}return!L(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}nh(e){var t,n,r;if(!this.eh){if((t=f.__PosthogExtensions__)==null||!t.initSessionRecording)return Hc.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Zr]:!0});if(this.Yu||(this.Yu=f.__PosthogExtensions__?.initSessionRecording(this._instance,this.kt),this.Yu._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.hh()){if(this.Xu===Bc||this.Xu===zc)return;this.Xu=zc,Hc.info(`persisted remote config is stale, requesting fresh config before starting`),new Io(this._instance).load();return}this.Xu=Rc,(n=(r=this.Yu).setDocumentWasEverVisible)==null||n.call(r,this.kt),this.Yu.start(e)}}onRRwebEmit(e){var t;(t=this.Yu)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Yu||(t=this.Ta)==null||t.register({[mr]:!0}),(e=this.Yu)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Yu||(t=this.Ta)==null||t.register({[pr]:!0}),(e=this.Yu)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.Yu||(n=this.Ta)==null||n.register({[e===`url`?hr:gr]:!0}),(t=this.Yu)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.Yu?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.Yu)==null||!n.tryAddCustomEvent(e,t))}}},El={autocapture:class{constructor(e){this.dh=!1,this.fh=null,this.ph=!1,this.gh=!1,this.instance=e,this.rageclicks=new Ec(e.config.rageclick),this.mh=null}initialize(){this.startIfEnabled()}get Di(){var e=N(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}yh(){if(this.isBrowserSupported()){if(e&&r){var t=t=>{t||=e?.event;try{this.bh(t)}catch(e){Oc.error(`Failed to capture event`,e)}};if(q(r,`submit`,t,{capture:!0}),q(r,`change`,t,{capture:!0}),q(r,`click`,t,{capture:!0}),this.Di.capture_copied_text){var n=t=>{t||=e?.event;try{this.bh(t,Dc)}catch(e){Oc.error(`Failed to capture copy/cut event`,e)}};q(r,`copy`,n,{capture:!0}),q(r,`cut`,n,{capture:!0})}}}else Oc.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.dh&&(this.yh(),this.dh=!0)}onRemoteConfig(e){if(this.ph=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this.gh=t.elementsChainAsString);var n=t.autocapture_opt_out;Ce(n)&&(this.instance.persistence&&this.instance.persistence.register({[nr]:n}),this.fh=n),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this.mh=e}getElementSelectors(e){var t,n=[];return(t=this.mh)==null||t.forEach((t=>{(r?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[nr],t=this.fh,n=this.instance.Xs()&&!this.ph;if(I(t)&&!Ce(e)&&!n)return!1;var r=this.fh??!!e;return!!this.instance.config.autocapture&&!r}bh(t,n){if(n===void 0&&(n=`$autocapture`),this.isEnabled){var r,i=ra(t);Yi(i)&&(i=i.parentNode||null),n===`$autocapture`&&t.type===`click`&&t instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&pa(i,this.instance.config.rageclick)&&this.bh(t,`$rageclick`);var a=n===Dc;if(i&&function(t,n,r,i,a,o){if(!e||ma(t)||r!=null&&r.url_allowlist&&!$i(r.url_allowlist,o)||r!=null&&r.url_ignorelist&&$i(r.url_ignorelist,o))return!1;if(r!=null&&r.dom_event_allowlist){var s=r.dom_event_allowlist;if(s&&!s.some((e=>n.type===e)))return!1}var c=ha(t,i),l=c.parentIsUsefulElement,u=c.targetElementList;if(!function(e,t){var n=t?.element_allowlist;if(P(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,r)||!aa(u,r?.css_selector_allowlist)||aa(u,r?.css_selector_ignorelist??sa))return!1;try{var d=e.getComputedStyle(t);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&n.type===`click`)return!0}catch{}var f=t.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(a||[`submit`]).indexOf(n.type)>=0;case`input`:case`select`:case`textarea`:return(a||[`change`,`click`]).indexOf(n.type)>=0;default:return l?(a||[`click`]).indexOf(n.type)>=0:(a||[`click`]).indexOf(n.type)>=0&&(ia.indexOf(f)>-1||t.getAttribute(`contenteditable`)===`true`)}}(i,t,this.Di,a,a?[`copy`,`cut`]:void 0,this.instance)){var o=jc(i,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Di.element_attribute_ignorelist,elementsChainAsString:this.gh,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),s=o.props;if(o.explicitNoCapture)return!1;var c=this.getElementSelectors(i);if(c&&c.length>0&&(s.$element_selectors=c),n===Dc){var l,u=ta(e==null||(l=e.getSelection())==null?void 0:l.toString()),d=t.type||`clipboard`;if(!u)return!1;s.$selected_content=u,s.$copy_type=d}return this.instance.capture(n,s),!0}}}isBrowserSupported(){return ye(r?.querySelectorAll)}},historyAutocapture:class{constructor(t){var n;this._instance=t,this._h=(e==null||(n=e.location)==null?void 0:n.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(B.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.wh&&this.wh(),this.wh=void 0,B.info(`History API monitoring stopped`)}monitorHistoryChanges(){e&&e.history&&(this.kh(`pushState`),this.kh(`replaceState`),this.Sh())}kh(t){var n;if(e&&((n=e.history[t])==null||!n.__posthog_wrapped__)){var r=this;(function(e,t,n){try{if(!(t in e))return Nc;var r={next:e[t]},i=n((function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.next.apply(this,t)}));return ye(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=i,()=>{if(e[t]!==i)for(var n=e[t];ye(n)&&n.__posthog_layer__;){var a=n.__posthog_layer__;if(a.next===i)return void(a.next=r.next);n=a.next}else e[t]=r.next}}catch{return Nc}})(e.history,t,(e=>function(n,i,a){e.call(this,n,i,a),r.xh(t)}))}}xh(t){try{var n,r=e==null||(n=e.location)==null?void 0:n.pathname;if(!r)return;r!==this._h&&this.isEnabled&&this._instance.capture(ii,{navigation_type:t}),this._h=r}catch(e){B.error(`Error capturing `+t+` pageview`,e)}}Sh(){if(!this.wh){var t=()=>{this.xh(`popstate`)};q(e,`popstate`,t),this.wh=()=>{e&&e.removeEventListener(`popstate`,t)}}}},heatmaps:class{get Di(){return this.instance.config}constructor(e){var t;this.Ch=!1,this.dh=!1,this.Th=null,this.instance=e,this.Ch=!((t=this.instance.persistence)==null||!t.props[rr]),this.rageclicks=new Ec(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return N(this.Di.capture_heatmaps)&&this.Di.capture_heatmaps.flush_interval_milliseconds&&(e=this.Di.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return L(this.Di.capture_heatmaps)?L(this.Di.enable_heatmaps)?this.Ch:this.Di.enable_heatmaps:!1!==this.Di.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.dh)return;Uc.info(`starting...`),this.Mh(),this.It()}else clearInterval(this.Th??void 0),this.Eh(),this.getAndClearBuffer()}onRemoteConfig(e){if(e.ok){var t=e.config;if(`heatmaps`in t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[rr]:n}),this.Ch=n,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.ft;return this.ft=void 0,e}Ih(e){Wc(e.originalEvent)&&this.bi(e.originalEvent,`deadclick`)}It(){this.Th&&clearInterval(this.Th),this.Th=r?.visibilityState===`visible`?setInterval(this.ga.bind(this),this.flushIntervalMilliseconds):null}Mh(){e&&r&&(this.Rh=this.ga.bind(this),q(e,ri,this.Rh),this.Ph=t=>this.bi(t||e?.event),q(r,`click`,this.Ph,{capture:!0}),this.Ah=t=>this.Fh(t||e?.event),q(r,`mousemove`,this.Ah,{capture:!0}),this.Oh=new Na(this.instance,ja,this.Ih.bind(this)),this.Oh.startIfEnabledOrStop(),this.Lh=this.It.bind(this),q(r,ni,this.Lh),this.dh=!0)}Eh(){var t;e&&r&&(this.Rh&&e.removeEventListener(ri,this.Rh),this.Ph&&r.removeEventListener(`click`,this.Ph,{capture:!0}),this.Ah&&r.removeEventListener(`mousemove`,this.Ah,{capture:!0}),this.Lh&&r.removeEventListener(ni,this.Lh),clearTimeout(this.$h),(t=this.Oh)==null||t.stop(),this.dh=!1)}Dh(t,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),a=this.instance.scrollManager.scrollElement(),o=function(t,n,r){for(var i=t;i&&qi(i)&&!Ji(i,`body`);){if(i===r)return!1;var a=void 0;try{a=(i.ownerDocument?.defaultView??e)?.getComputedStyle(i).position}catch{return!1}if(j(n,a))return!0;i=oa(i)}return!1}(ra(t),[`fixed`,`sticky`],a);return{x:t.clientX+(o?0:i),y:t.clientY+(o?0:r),target_fixed:o,type:n}}bi(e,t){var n;if(t===void 0&&(t=`click`),!Ki(e.target)&&Wc(e)){var r=this.Dh(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&pa(ra(e),this.instance.config.rageclick)&&this.$n(g({},r,{type:`rageclick`})),this.$n(r)}}Fh(e){!Ki(e.target)&&Wc(e)&&(clearTimeout(this.$h),this.$h=setTimeout((()=>{this.$n(this.Dh(e,`mousemove`))}),500))}$n(t){if(e){var n=this.Di.disable_capture_url_hashes?Ht(e.location.href):e.location.href,r=this.Di.custom_personal_data_properties,i=Ka(n,this.Di.mask_personal_data_properties?[...Za,...r||[]]:[],$a);this.ft=this.ft||{},this.ft[i]||(this.ft[i]=[]),this.ft[i].push(t)}}ga(){this.ft&&!be(this.ft)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Na,webVitalsAutocapture:class{constructor(e){var t;this.Ch=!1,this.dh=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Nh=()=>{clearTimeout(this.qh),this.qh=void 0,this.ft.metrics.length!==0&&(this._instance.capture(`$web_vitals`,g({$current_url:this.ft.url},this.ft.metrics.reduce(((e,t)=>g({},e,{[`$web_vitals_`+t.name+`_event`]:g({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.jh=e=>{if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},L(e?.name)||L(e?.value))Fc.error(`Invalid metric received`,e);else{var t=typeof e.navigationURL==`string`?e.navigationURL:void 0,n=this.Bh(t);if(!P(n)){var r=R(e.navigationId)||typeof e.navigationId==`string`?`navigation:`+e.navigationId:`url:`+n;if(!this.Hh||this.Hh>e.value){this.ft.navigationKey!==r&&(this.Nh(),this.qh=setTimeout(this.Nh,this.flushToCaptureTimeoutMs)),P(this.ft.navigationKey)&&(this.ft.navigationKey=r,this.ft.url=n),this.ft.firstMetricTimestamp=P(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var i=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),a=g({},e,t?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});P(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this.ft.metrics.push(a),this.ft.metrics.length===this.allowedMetrics.length&&this.Nh()}else Fc.error(`Ignoring metric with value >= `+this.Hh,e)}}},this.Uh=()=>{if(!this.dh){var e,t,n,r,i=f.__PosthogExtensions__,a=i?.postHogWebVitalsCallbacksByFlavor,o=a?.[this.zh]||(this.zh===`web-vitals`&&P(a)?i?.postHogWebVitalsCallbacks:void 0);if(P(o)||(e=o.onLCP,t=o.onCLS,n=o.onFCP,r=o.onINP),e&&t&&n&&r){var s={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.jh.bind(this),s),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.jh.bind(this),s),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.jh.bind(this),s),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.jh.bind(this),s),this.dh=!0}else Fc.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Ch=!((t=this._instance.persistence)==null||!t.props[sr]),this.startIfEnabled()}get Wh(){return this._instance.config.capture_performance}get allowedMetrics(){var e=N(this.Wh)?this.Wh?.web_vitals_allowed_metrics:void 0;return L(e)?this._instance.persistence?.props[ur]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(N(this.Wh)?this.Wh.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=N(this.Wh)?this.Wh.web_vitals_attribution:void 0;return e!=null&&e}get useSoftNavs(){var e=N(this.Wh)?this.Wh.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Hh(){var e=N(this.Wh)&&R(this.Wh.__web_vitals_max_value)?this.Wh.__web_vitals_max_value:Ic;return e>0&&6e4>=e?Ic:e}get isEnabled(){var e=i?.protocol;if(e!==`http:`&&e!==`https:`)return Fc.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=N(this.Wh)?this.Wh.web_vitals:Ce(this.Wh)?this.Wh:void 0;return Ce(t)?t:this.Ch}startIfEnabled(){this.isEnabled&&!this.dh&&(Fc.info(`enabled, starting...`),this.Xn(this.Uh))}onRemoteConfig(e){if(e.ok){var t=e.config;if(`capturePerformance`in t){var n=N(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=N(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[sr]:n}),this._instance.persistence.register({[ur]:r})),this.Ch=n,this.startIfEnabled()}}}get zh(){return this.useSoftNavs?this.useAttribution?`web-vitals-with-attribution-soft-navs`:`web-vitals-soft-navs`:this.useAttribution?`web-vitals-with-attribution`:`web-vitals`}Xn(e){var t=f.__PosthogExtensions__,n=this.zh,r=t?.postHogWebVitalsCallbacksByFlavor;r!=null&&r[n]||n===`web-vitals`&&P(r)&&t!=null&&t.postHogWebVitalsCallbacks?e():t==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,n,(t=>{t?Fc.error(`failed to load script`,t):e()}))}Bh(t){var n=t||e?.location.href;if(n){var r=this._instance.config.disable_capture_url_hashes?Ht(n):n,i=this._instance.config.custom_personal_data_properties;return Ka(r,this._instance.config.mask_personal_data_properties?[...Za,...i||[]]:[],$a)}Fc.error(`Could not determine current URL`)}}},Dl={exceptionObserver:class{constructor(t){var n;this.Uh=()=>{var t;if(e&&this.isEnabled&&(t=f.__PosthogExtensions__)!=null&&t.errorWrappingFunctions){var n=f.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=f.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,i=f.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Vh&&this.Di.capture_unhandled_errors&&(this.Vh=n(this.captureException.bind(this))),!this.Gh&&this.Di.capture_unhandled_rejections&&(this.Gh=r(this.captureException.bind(this))),!this.Zh&&this.Di.capture_console_errors&&(this.Zh=i(this.captureException.bind(this)))}catch(e){Mc.error(`failed to start`,e),this.Qh()}}},this._instance=t,this.Jh=!((n=this._instance.persistence)==null||!n.props[ir]),this.oe=new Ie(g({},function(e){return e===void 0&&(e={}),{refillRate:e.exceptionRateLimiterRefillRate??e.__exceptionRateLimiterRefillRate??1,bucketSize:e.exceptionRateLimiterBucketSize??e.__exceptionRateLimiterBucketSize??10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:Mc})),this.Di=this.Kh(),this.startIfEnabledOrStop()}Kh(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return N(e)?t=g({},t,e):(P(e)?this.Jh:e)&&(t=g({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Di.capture_console_errors||this.Di.capture_unhandled_errors||this.Di.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Mc.info(`enabled`),this.Qh(),this.Xn(this.Uh)):this.Qh()}Xn(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return Mc.error(`failed to load script`,t);e()}))}Qh(){var e,t,n;(e=this.Vh)==null||e.call(this),this.Vh=void 0,(t=this.Gh)==null||t.call(this),this.Gh=void 0,(n=this.Zh)==null||n.call(this),this.Zh=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;`autocaptureExceptions`in t&&(this.Jh=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[ir]:this.Jh}),this.Di=this.Kh(),this.startIfEnabledOrStop())}}onConfigChange(){this.Di=this.Kh()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.oe.consumeRateLimit(r)?Mc.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.Yh=[],this.Xh=new mn([new En,new In,new On,new Dn,new Pn,new Nn,new An,new Fn],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
3
+ `),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=Tn.test(s)?s.replace(Tn,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return g({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||hn});var n}))}(i)}}(`web:javascript`,xn,wn)),this._instance=e,this.Yh=this._instance.persistence?.get_property(ar)??[],this.td=Vn(this.ed()),this.rd=new Hn(this.td)}onConfigChange(){this.td=Vn(this.ed()),this.rd.setConfig(this.td)}onRemoteConfig(e){if(e.ok){var t=e.config;if(`errorTracking`in t){var n=t.errorTracking?.suppressionRules??[],r=t.errorTracking?.captureExtensionExceptions;this.Yh=n,this._instance.persistence&&this._instance.persistence.register({[ar]:this.Yh,[or]:r})}}}get nd(){var e,t=!!this._instance.get_property(or);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.Xh.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.td.enabled)try{if(!F(e)||e.trim().length===0)return void pl.warn(`Ignoring exception step because message must be a non-empty string`);var n=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>zn.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this.sd(t)),r=n.sanitizedProperties,i=n.droppedKeys;i.length>0&&pl.warn(`Ignoring reserved exception step fields`,{droppedKeys:i}),this.rd.add(g({[Ln]:e,[Rn]:new Date().toISOString()},r))}catch(e){pl.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.ad(t)){if(this.od(t))return this.ld(`Exception dropped: matched a suppression rule`),void pl.info(`Skipping exception capture because a suppression rule matched`);if(!this.nd&&this.ud(t))return this.ld(`Exception dropped: thrown by a browser extension`),void pl.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.hd(t))return this.ld(`Exception dropped: thrown by the PostHog SDK`),void pl.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.td.enabled&&L(e.$exception_steps)?this.dd(e):e,r=typeof(a=globalThis._posthogReleaseId)==`string`&&a.length>0?a:void 0;r&&(n.$release_id=r);try{var i=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,Jo:!0});return i&&this.rd.clear(),i}catch(e){pl.error(`Failed to capture exception event. Dropping this exception.`,e),this.rd.clear();return}}catch(e){pl.error(`Failed to process exception event. Ignoring this exception.`,e);return}var a}dd(e){try{var t=this.rd.getAttachable();return t.length===0?e:g({},e,{$exception_steps:t})}catch(t){return pl.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}ld(e){this.td.enabled&&this.rd.add({[Ln]:e,[Rn]:new Date().toISOString()})}sd(e){return N(e)?g({},e):{}}ed(){return this._instance.config.error_tracking?.exception_steps??{}}od(e){if(e.length===0)return!1;try{var t=e.reduce(((e,t)=>{var n=t.type,r=t.value;return F(n)&&n.length>0&&e.$exception_types.push(n),F(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.Yh.some((e=>{var n=e.values.map((e=>{var n=Gs[e.operator],r=t[e.key];if(!n||!r)return!1;var i=M(e.value)?e.value:[e.value];return i.length>0&&n(i,r)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}catch(e){return pl.warn(`Failed to evaluate suppression rules. Capturing the exception.`,e),!1}}ud(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>{var t=e.filename;return!!t&&ml.some((e=>t.startsWith(e)))}))}hd(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}ad(e){return!L(e)&&M(e)}}},Ol=g({productTours:class{get Ta(){return this._instance.persistence}constructor(e){this.vd=null,this.fd=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if(`productTours`in t){var n;if(this.Ta&&this.Ta.register({[lr]:!!t.productTours}),!Kc(this._instance))return!this.vd&&L(this.Ta?.props[Ir])||Gc.info(`product tours disabled; stopping and clearing cached tours`),(n=this.vd)==null||n.stop(),this.vd=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.vd&&Kc(this._instance)&&this.Xn((()=>this.pd()))}Xn(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?Gc.error(`Could not load product tours script`,t):e()}))}pd(){var e;!this.vd&&(e=f.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.vd=f.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!M(this.fd)||t){var n=this.Ta;if(n){var r=n.props[Ir];if(M(r)&&!t)return this.fd=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,timestampMode:`query`,callback:t=>{if(Kc(this._instance)){var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;r===0?t.error||Gc.warn(i):Gc.error(i),e([],{isLoaded:!1,error:i});return}var a=M(t.json.product_tours)?t.json.product_tours:[];this.fd=a,n&&n.register({[Ir]:a}),e(a,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.fd,{isLoaded:!0})}getActiveProductTours(e){L(this.vd)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.vd.getActiveProductTours(e)}showProductTour(e){var t;(t=this.vd)==null||t.showTourById(e)}previewTour(e){this.vd?this.vd.previewTour(e):this.Xn((()=>{var t;this.pd(),(t=this.vd)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.vd)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.vd)==null||e.nextStep()}previousStep(){var e;(e=this.vd)==null||e.previousStep()}clearCache(){var e;this.fd=null,(e=this.Ta)==null||e.unregister(Ir)}resetTour(e){var t;(t=this.vd)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.vd)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.vd)==null||t.cancelPendingTour(e)}}},wl),kl={siteApps:class{constructor(e){this.gd=0,this._instance=e,this.md=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yd(e,t){if(t){var n=this.globalsForEvent(t);this.md.push(n),this.md.length>1e3&&(this.md=this.md.slice(10))}}get siteAppLoaders(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yd.bind(this));this.bd=()=>{e(),this.md=[],this.bd=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var i of Object.entries(r)){var a=i[0];t[a]={id:n[a],type:a,properties:i[1]}}var o=e.$set_once,s=e.$set;return{event:g({},_(e,qc),{properties:g({},e.properties,s?{$set:g({},e.properties?.$set??{},s)}:{},o?{$set_once:g({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}_d(e){var t=e.tagName?.toLowerCase();return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Jc.error(`prepare_external_dependency_stylesheet returned null`),null):t===`script`&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Jc.error(`prepare_external_dependency_script returned null`),null):e}wd(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var t=r?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this.gd++,this.kd)return this.Sd();var i=[],a=this,o=new WeakSet,s=(e,t,n)=>{if(e!=null&&e[t]){var r=e[t];e[t]=n(r),i.push((()=>{e[t]=r}))}},c=e=>{if(o.has(e))return e;var t=a._d(e);return t&&o.add(t),t},l=e=>e.map((e=>typeof e==`string`?e:c(e))).filter((e=>!I(e)));return s(n,`appendChild`,(e=>function(t){var n=c(t);return n?e.call(this,n):t})),s(n,`insertBefore`,(e=>function(t,n){var r=c(t);return r?e.call(this,r,n):t})),s(n,`replaceChild`,(e=>function(t,n){var r=c(t);return r?e.call(this,r,n):n})),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach((e=>{s(e,`append`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))})),s(e,`prepend`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))}))})),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach((e=>{s(e,`before`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))})),s(e,`after`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))})),s(e,`replaceWith`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=l(n);return n.length&&!i.length?void 0:e.apply(this,i)}))})),s(t.Element?.prototype,`insertAdjacentElement`,(e=>function(t,n){var r=c(n);return r?e.call(this,t,r):null})),this.kd=()=>{i.forEach((e=>e())),this.kd=void 0},this.Sd()}Sd(){var e=!1;return()=>{var t;e||(e=!0,this.gd--,this.gd===0&&((t=this.kd)==null||t.call(this)))}}xd(e,t){t===void 0&&(t=!0);var n=this.wd();try{var r=e(n);return t&&n(),r}catch(e){throw n(),e}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.md.length&&(Jc.info(`Processing `+this.md.length+` events for site app with id `+e.id),this.md.forEach((e=>this.xd((()=>t.processEvent==null?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.bd)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Jc.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var a=this.xd((t=>e.init({posthog:this._instance,callback(e){t(),i(e)}})),!1).processEvent;a&&(t.processEvent=a),r=!0}catch(t){Jc.error(Yc+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Jc.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}Cd(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}Td(e){var t=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e),r=function(r){try{t.xd((()=>r.processEvent==null?void 0:r.processEvent(n)))}catch(t){Jc.error(`Error while processing event `+e.event+` for site app `+r.id,t)}};for(var i of Object.values(this.apps))r(i)}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Cd(),void this._instance.on(`eventCaptured`,(e=>this.Td(e)))):void Jc.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.bd)==null||n.call(this),e.ok){var a=e.config;if((r=a.siteApps)!=null&&r.length)if(this.isEnabled){var o=function(){var e,t=s.id,n=s.url;f[`__$$ph_site_app_`+t]=i._instance,(e=f.__PosthogExtensions__)==null||e.loadSiteApp==null||e.loadSiteApp(i._instance,n,(e=>{if(e)return Jc.error(Yc+t,e)}))};for(var s of a.siteApps)o()}else Jc.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}}},Al={tracingHeaders:class{constructor(e){this.Md=void 0,this.Ed=void 0,this.Id=void 0,this.Uh=()=>{var e,t,n=this.Rd();n?(P(this.Md)&&(this.Md=(e=f.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(n,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),P(this.Ed)&&(this.Ed=(t=f.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchFetch(n,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Qh()},this._instance=e}initialize(){this.startIfEnabledOrStop()}Xn(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return Pc.error(`failed to load script`,t);e()}))}Pd(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}Rd(){var e=this.Pd();return M(e)?(M(this.Id)?this.Id.splice(0,this.Id.length,...e):this.Id=[...e],e.length>0?this.Id:void 0):(M(this.Id)&&this.Id.splice(0),this.Id=e||void 0,this.Id)}Qh(){var e,t;(e=this.Md)==null||e.call(this),(t=this.Ed)==null||t.call(this),this.Md=void 0,this.Ed=void 0}startIfEnabledOrStop(){this.Rd()?this.Xn(this.Uh):this.Qh()}}},jl=g({surveys:class{get Di(){return this._instance.config}constructor(e){this.Ad=void 0,this._surveyManager=null,this.Fd=!1,this.Od=[],this.Ld=null,this.$d=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Di.disable_surveys){if(!e.ok)return $.warn(`Remote config unavailable. Not loading surveys.`);var t=e.config.surveys;if(L(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);var n=M(t);this.Ad=n?t.length>0:t,$.info(`flags response received, isSurveysEnabled: `+this.Ad),this.loadIfEnabled()}}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem(`lastSeenSurveyDate`);for(var t=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(ec)||r!=null&&r.startsWith(`inProgressSurvey_`))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.Fd)$.info(`Already initializing surveys, skipping...`);else if(this.Di.disable_surveys)$.info(tl);else if(this.Di.cookieless_mode&&this._instance.consent.isOptedOut())$.info(`Not loading surveys in cookieless mode without consent.`);else{var e=f?.__PosthogExtensions__;if(e){if(!P(this.Ad)||this.Di.advanced_enable_surveys){var t=this.Ad||this.Di.advanced_enable_surveys;this.Fd=!0;try{var n=e.generateSurveys;if(n)return void this.Dd(n,t);var r=e.loadExternalDependency;if(!r)return void this.Nd(Qr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Nd(`Could not load surveys script`,n):this.Dd(e.generateSurveys,t)}))}catch(e){throw this.Nd(`Error initializing surveys`,e),e}finally{this.Fd=!1}}}else $.error(`PostHog Extensions not found.`)}}Dd(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new $c(this._instance),$.info(`Surveys loaded successfully`),this.qd({isLoaded:!0})}Nd(e,t){$.error(e,t),this.qd({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Od.push(e),this._surveyManager&&this.qd({isLoaded:!0}),()=>{this.Od=this.Od.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Di.disable_surveys)return $.info(tl),e([]);var n,r=this._instance.get_property(jr);if(r&&!t)return e(r,{isLoaded:!0}),void(this.jd()&&this.getSurveys((()=>{}),!0));typeof Promise<`u`&&this.Ld?this.Ld.then((t=>e(t.surveys,t.context))):(typeof Promise<`u`&&(this.Ld=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Di.token),method:`GET`,timestampMode:`query`,timeout:this.Di.surveys_request_timeout_ms,callback:t=>{var r;this.Ld=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;i===0?t.error||$.warn(a):$.error(a),this.$d=Date.now();var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}this.$d=null;var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&($s(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[jr]:c,[Mr]:Date.now()});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}jd(){return this.Bd()&&!this.Ld&&!this.Hd()}Bd(){var e=this._instance.get_property(Mr);return R(e)&&Date.now()-e>3e5}Hd(){return R(this.$d)&&3e5>Date.now()-this.$d}markSurveyAsSeen(e,t){tc({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}qd(e){for(var t of this.Od)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!L(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}Ud(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}zd(e){if(L(this._surveyManager))return{eligible:!1,reason:el};var t=typeof e==`string`?this.Ud(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}Wd(e){if(L(this._surveyManager))return{eligible:!1,reason:el};var t=typeof e==`string`?this.Ud(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(L(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:el};var t=this.Wd(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return L(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:el})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Wd(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var i;if(L(this._surveyManager))$.warn(`init was not called`);else{var a=typeof e==`string`?this.Ud(e):e;if(a!=null&&a.id)if(nc.includes(a.type)){var o=r?.querySelector(t);if(o)return(i=a.appearance)!=null&&i.surveyPopupDelaySeconds?($.info(`Rendering survey `+a.id+` with delay of `+a.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;$.info(`Rendering survey `+a.id+` with delay of `+a.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(a,o,n),$.info(`Survey `+a.id+` rendered`)}),1e3*a.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(a,o,n);$.warn(`Survey element not found`)}else $.warn(`Surveys of type `+a.type+` cannot be rendered in the app`);else $.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(L(this._surveyManager))$.warn(`init was not called`);else{var r=this.Ud(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=g({},r,{appearance:g({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==ko.Popover&&t.initialResponses&&$.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.zd(r);if(!a.eligible)return void $.warn(`Survey is not eligible to be displayed: `,a.reason)}t.displayType===ko.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else $.warn(`Survey not found`)}}cancelPendingSurvey(e){L(this._surveyManager)?$.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload==null||e.handlePageUnload()}}},wl),Ml={toolbar:class{constructor(e){this.instance=e}Vd(e){f.ph_toolbar_state=e}Gd(){return f.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,n,i){if(t===void 0&&(t=void 0),n===void 0&&(n=void 0),i===void 0&&(i=void 0),hi(this.instance.config)||!e||!r)return!1;t??=e.location,i??=e.history;try{if(!n){try{e.localStorage.setItem(`test`,`test`),e.localStorage.removeItem(`test`)}catch{return!1}n=e?.localStorage}var a,o=nl||qa(t.hash,`__posthog`)||qa(t.hash,`state`),s=o?ui((()=>JSON.parse(atob(decodeURIComponent(o)))))||ui((()=>JSON.parse(decodeURIComponent(o)))):null;return s&&s.action===`ph_authorize`?((a=s).source=`url`,a&&Object.keys(a).length>0&&(s.desiredHash?t.hash=s.desiredHash:i?i.replaceState(i.state,``,t.pathname+t.search):t.hash=``)):((a=JSON.parse(n.getItem(rl)||`{}`)).source=`localstorage`,delete a.userIntent),!(!a.token||this.instance.config.token!==a.token||(this.loadToolbar(a),0))}catch{return!1}}Zd(e){var t=f.ph_load_toolbar||f.ph_load_editor;!L(t)&&ye(t)?t(e,this.instance):il.warn(`No toolbar load function found`)}loadToolbar(t){var n=!(r==null||!r.getElementById(Hi));if(!e||n)return!1;var i=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,a=g({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},i?{instrument:!1}:{});if(e.localStorage.setItem(rl,JSON.stringify(g({},a,{source:void 0}))),this.Gd()===2)this.Zd(a);else if(this.Gd()===0){var o;this.Vd(1),(o=f.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return il.error(`[Toolbar] Failed to load`,e),void this.Vd(0);this.Vd(2),this.Zd(a)})),q(e,`turbolinks:load`,(()=>{this.Vd(0),this.loadToolbar(a)}))}return!0}Qd(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},Nl=g({experiments:_l},wl),Pl=g({},wl,Tl,El,Dl,Ol,kl,jl,Al,Ml,Nl,{conversations:class{constructor(e){this.Jd=void 0,this._conversationsManager=null,this.Kd=!1,this.Me=null,this.Yd=!1,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this.Xd=e.ok,e.ok)){var t=e.config.conversations;L(t)||(Ce(t)?this.Jd=t:(this.Jd=t.enabled,this.Me=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Jd=void 0,this.Me=null,this.Xd=void 0,this.Yd=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Kd||this._instance.config.disable_conversations||hi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=f?.__PosthogExtensions__;if(e&&!P(this.Jd)&&this.Jd)if(this.Me&&this.Me.token){this.Kd=!0;try{var t=e.initConversations;if(t)return this.tv(t),void(this.Kd=!1);var n=e.loadExternalDependency;if(!n)return void this.ev(Qr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.ev(`Could not load conversations script`,t):this.tv(e.initConversations),this.Kd=!1}))}catch(e){this.ev(`Error initializing conversations`,e),this.Kd=!1}}else vl.error(`Conversations enabled but missing token in remote config.`)}}tv(e){if(this.Me)try{this._conversationsManager=e(this.Me,this._instance),this.Yd=!1,vl.info(`Conversations loaded successfully`)}catch(e){this.ev(`Error completing conversations initialization`,e)}else vl.error(`Cannot complete initialization: remote config is null`)}ev(e,t){vl.error(e,t),this._conversationsManager=null,this.Kd=!1,this.Yd=!0}show(){this._conversationsManager?this._conversationsManager.show():vl.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Jd&&!I(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?`disabled_by_config`:hi(this._instance.config)?`disabled_for_toolbar`:this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?`consent_opted_out`:!1===this.Xd?`remote_config_failed`:P(this.Jd)?this.Xd?`disabled_in_project`:`remote_config_pending`:this.Jd?L(this.Me)||!this.Me.token?`missing_token`:f!=null&&f.__PosthogExtensions__?this.Kd?`initializing`:this.Yd?`load_failed`:`not_loaded`:`extensions_unavailable`:`disabled_in_project`}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return h((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(vl.warn(yl),null)}))()}getMessages(e,t){var n=this;return h((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(vl.warn(yl),null)}))()}markAsRead(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(vl.warn(yl),null)}))()}getTickets(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(vl.warn(yl),null)}))()}requestRestoreLink(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(vl.warn(yl),null)}))()}restoreFromToken(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(vl.warn(yl),null)}))()}restoreFromUrlToken(){var e=this;return h((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(vl.warn(yl),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}sl(){var e;(e=this._conversationsManager)==null||e.setIdentity()}al(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(t){var n,r=this;this.iv=!1,this.rv=!1,this.I=V(`[logs]`),this.nv=g({},this.I,{error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];t.some(Cl)||r.I.error(...t)}}),this.na=[],this.sv=[],this.Tu=0,this.av=()=>{var e,t;this.Tu=0,(e=this.ov)==null||e.onReconnect(),(t=this.lv)==null||t.onReconnect()},this._instance=t,this._instance&&(n=this._instance.config.logs)!=null&&n.captureConsoleLogs&&(this.iv=!0),e&&q(e,`online`,this.av)}uv(e,t,n,r){var i,a=function(e,t){var n=e?.flushIntervalMs??3e3,r=e?.maxBufferSize??100,i=t!=null&&t.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,a=P(i)?Math.max(r,2048):Math.max(r,i),o=e?.resourceAttributes;return{serviceName:o?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:o?.[`service.version`]??e?.serviceVersion,environment:o?.[`deployment.environment`]??e?.environment,resourceAttributes:o,beforeSend:e?.beforeSend,flushIntervalMs:n,maxBufferSize:r,maxQueueSize:a,maxBatchRecordsPerPost:100,rateCapWindowMs:n,maxLogsPerInterval:i,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new an(this.hv(e,t),a,this.nv,(()=>this.dv()),(e=>e()),void 0,r),a]}vv(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.ov||this.fv!==t){var n;(n=this.ov)==null||n.reset(),this.fv=t;var r=this.uv((()=>this.na),(e=>{this.na=e}));this.ov=r[0],this.pv=r[1]}return this.ov}gv(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.lv||this.mv!==t){var n;(n=this.lv)==null||n.reset(),this.mv=t;var r=this.uv((()=>this.sv),(e=>{this.sv=e}),{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},bl);this.lv=r[0],this.yv=r[1]}return this.lv}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config.logs?.captureConsoleLogs;!L(t)&&t&&(this.iv=!0,this.loadIfEnabled())}}reset(){var e,t;this.na=[],(e=this.ov)==null||e.reset(),this.sv=[],(t=this.lv)==null||t.reset(),this.Tu=0}captureLog(e){this.vv().captureLog(e)}ci(e){this.gv().captureLog(e)}get logger(){return this.bv||={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.bv}flushLogs(e){e?this._v(e):(this.ov&&this.ov.flush().catch((e=>this.wv(e))),this.lv&&this.lv.flush().catch((e=>this.wv(e))))}wv(e){Cl(e)||this.I.error(`PostHog logs flush failed:`,e)}loadIfEnabled(){if(this.iv&&!this.rv){var e=f?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.I.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.rv=!0)})):this.I.error(Qr)}else this.I.error(`PostHog Extensions not found.`)}}hv(e,t){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:t=>t===C.LogsQueue?e():void 0,setPersistedProperty(e,n){e===C.LogsQueue&&t(n??[])},Cn:e=>this.Cn(e),getLibraryId:()=>p.LIB_NAME,getLibraryVersion:()=>p.LIB_VERSION}}Cn(e){return new Promise((t=>{if(Ja(this.Tu,3))t({kind:`fatal`,error:Sl(void 0,`logs endpoint is unreachable, dropping batch`)});else{var n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout((()=>{this.I.warn(`Logs request timed out before receiving a response`),r({kind:`retry-later`,error:Sl(void 0,`logs request timed out`)})}),9e4);this._instance._send_request({method:`POST`,url:this.Sv(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;this.xv(t),t>=200&&300>t?r({kind:`ok`}):t===413?r({kind:`too-large`}):t!==0&&t!==429&&500>t?r({kind:`fatal`,error:Error(`logs request failed with status `+t)}):t===0?(e.error||this.I.warn(`Logs request failed before receiving an HTTP response`),r({kind:`retry-later`,error:Sl(e.error,`logs request failed before receiving an HTTP response`)})):r({kind:`retry-later`,error:e.error??Error(`logs request failed with status `+t)})}})}}))}xv(e){(e!==0||this._instance.__loaded)&&(this.Tu=Ya(e,this.Tu,3,(()=>this.I.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.`))))}_v(e){this.na.length>0&&this.Cv(e,this.na,this.pv,p.LIB_NAME,(e=>{this.na=e})),this.sv.length>0&&this.Cv(e,this.sv,this.yv,bl,(e=>{this.sv=e}))}Cv(e,t,n,r,i){if(t.length!==0){var a=t.map((e=>e.record));i([]);var o=rn(a,nn(n,p.LIB_NAME,p.LIB_VERSION),r,p.LIB_VERSION);this._instance._send_request({method:`POST`,url:this.Sv(),data:o,compression:`best-available`,batchKey:`logs`,transport:e})}}Sv(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}dv(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.windowId,i=n.sessionStartTimestamp,a=n.lastActivityTimestamp;t.sessionId=n.sessionId,t.windowId=r,L(i)||(t.sessionStartTimestamp=i),L(a)||(t.lastActivityTimestamp=a)}if(f!=null&&(e=f.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Ht(f.location.href):f.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},{metrics:class{constructor(e){this.I=V(`[metrics]`),this._instance=e}initialize(){}vv(){var e,t,n=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.ov&&this.fv===n||((t=this.ov)==null||t.reset(),this.fv=n,this.ov=new ln(this.hv(),function(e){var t=e?.resourceAttributes;return{serviceName:t?.[`service.name`]??e?.serviceName,serviceVersion:t?.[`service.version`]??e?.serviceVersion,environment:t?.[`deployment.environment`]??e?.environment,resourceAttributes:t,beforeSend:e?.beforeSend,flushIntervalMs:e?.flushIntervalMs??1e4,maxSeriesPerFlush:e?.maxSeriesPerFlush??1e3}}(n),this.I)),this.ov}count(e,t,n){t===void 0&&(t=1),this.vv().count(e,t,n)}gauge(e,t,n){this.vv().gauge(e,t,n)}histogram(e,t,n){this.vv().histogram(e,t,n)}flush(e){if(!this.ov)return Promise.resolve();if(e){var t=this.ov.drainWindow();return t&&this.Bn(t,e),Promise.resolve()}return this.ov.flush().catch((e=>this.I.error(`PostHog metrics flush failed:`,e)))}reset(){var e;(e=this.ov)==null||e.reset()}hv(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Bn:e=>t.Bn(e),getLibraryId:()=>p.LIB_NAME,getLibraryVersion:()=>p.LIB_VERSION}}Bn(e,t){return new Promise((n=>{var r=!1,i=e=>{r||(r=!0,clearTimeout(a),n(e))},a=setTimeout((()=>i({kind:`retry-later`,error:Error(`metrics request timed out`)})),9e4);this._instance._send_request(g({method:`POST`,url:this.Tv(),data:e,compression:`best-available`,batchKey:`metrics`},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;i(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==429&&500>t?{kind:`fatal`,error:Error(`metrics request failed with status `+t)}:{kind:`retry-later`,error:e.error??Error(`metrics request failed with status `+t)})}}))}))}Tv(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}});Tc.__defaultExtensionClasses=g({},Pl);var Fl=function(){p.SDK_DIST_CHANNEL=`npm`;var t=dc[yc]=new Tc;return function(){function t(){t.done||(t.done=!0,bc=!1,G(dc,(function(e){e._dom_loaded()})))}r!=null&&r.addEventListener?r.readyState===`complete`?t():q(r,`DOMContentLoaded`,t,{capture:!1}):e&&B.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();export{Z as Compression,Ao as DEFAULT_PRODUCT_TOUR_APPEARANCE,ko as DisplaySurveyType,Tc as PostHog,jo as ProductTourEventName,Mo as ProductTourEventProperties,Do as SurveyEventName,Oo as SurveyEventProperties,yo as SurveyEventType,xo as SurveyPosition,To as SurveyQuestionBranchingType,wo as SurveyQuestionType,Eo as SurveySchedule,So as SurveyTabPosition,Co as SurveyType,bo as SurveyWidgetType,Fl as default,Fl as posthog,Lo as severityLevels};