posthog-js 1.438.16 → 1.438.17

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 (44) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.js +1 -1
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -1
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -1
  9. package/dist/array.no-external.js +1 -1
  10. package/dist/customizations.full.js +1 -1
  11. package/dist/customizations.js +1 -1
  12. package/dist/default-extensions.js +1 -1
  13. package/dist/extension-bundles.js +1 -1
  14. package/dist/lazy-recorder.js +1 -1
  15. package/dist/lazy-recorder.js.map +1 -1
  16. package/dist/main.js +1 -1
  17. package/dist/module.full.cjs +1 -1
  18. package/dist/module.full.js +1 -1
  19. package/dist/module.full.js.map +1 -1
  20. package/dist/module.full.no-external.cjs +1 -1
  21. package/dist/module.full.no-external.js +1 -1
  22. package/dist/module.full.no-external.js.map +1 -1
  23. package/dist/module.js +1 -1
  24. package/dist/module.mjs +1 -1
  25. package/dist/module.no-external.cjs +1 -1
  26. package/dist/module.no-external.js +1 -1
  27. package/dist/module.slim.js +1 -1
  28. package/dist/module.slim.no-external.js +1 -1
  29. package/dist/posthog-recorder.js +1 -1
  30. package/dist/posthog-recorder.js.map +1 -1
  31. package/dist/recorder-v2.js +1 -1
  32. package/dist/recorder-v2.js.map +1 -1
  33. package/dist/recorder.js +1 -1
  34. package/dist/recorder.js.map +1 -1
  35. package/dist/rrweb.js +1 -1
  36. package/dist/rrweb.js.map +1 -1
  37. package/dist/surveys-preview.js +1 -1
  38. package/dist/surveys.js +1 -1
  39. package/lib/package.json +1 -1
  40. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +6 -2
  41. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
  42. package/lib/src/extensions/replay/external/sessionrecording-utils.js +10 -35
  43. package/lib/src/extensions/replay/external/sessionrecording-utils.js.map +1 -1
  44. package/package.json +5 -5
package/dist/module.js CHANGED
@@ -1,2 +1,2 @@
1
- const t="u">typeof window?window:void 0,i="u">typeof globalThis?globalThis:t,e=null==i?void 0:i.navigator,s=null==i?void 0:i.document,n=null==i?void 0:i.location,r=null==i?void 0:i.fetch,o=(null==i?void 0:i.XMLHttpRequest)&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,l=null==i?void 0:i.AbortController,a=null==i?void 0:i.CompressionStream,u=null==e?void 0:e.userAgent,h="undefined"!=typeof globalThis?globalThis:t;h&&"undefined"==typeof self&&(h.self=h),h&&"undefined"==typeof File&&(h.File=function(){});const d=null!=t?t:{},c="0.9.8",v={DEBUG:!1,LIB_VERSION:c,LIB_NAME:"browser-common",JS_SDK_VERSION:c};var f=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),p=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({});const _=["$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"],g=["token"];function m(t,i){return-1!==t.indexOf(i)}const y=function(t){return t.trim()},b=function(t){return t.replace(/^\$/,"")};function w(t){var i;const e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}const S=Object.prototype,x=S.hasOwnProperty,E=S.toString,k=Array.isArray||function(t){return"[object Array]"===E.call(t)},T=t=>"function"==typeof t,P=t=>t===Object(t)&&!k(t),C=t=>{if(P(t)){for(const i in t)if(x.call(t,i))return!1;return!0}return!1},R=t=>void 0===t,O=t=>"[object String]"==E.call(t),A=t=>O(t)&&0===t.trim().length,I=t=>null===t,F=t=>R(t)||I(t),M=t=>"[object Number]"==E.call(t)&&t==t,D=t=>M(t)&&t>0,N=t=>"[object Boolean]"===E.call(t),j=t=>m(_,t),L=t=>m(g,t);function U(t){return null===t||"object"!=typeof t}function B(t,i){return{}.toString.call(t)===`[object ${i}]`}function z(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return q(t,Error)}}function H(t){return"u">typeof Event&&q(t,Event)}function q(t,i){try{return t instanceof i}catch(t){return!1}}const V=[!0,"true",1,"1","yes"],W=t=>m(V,t),G=[!1,"false",0,"0","no"];function K(t,i,e,s,n,r,o){try{var l=t[r](o),a=l.value}catch(t){return void e(t)}l.done?i(a):Promise.resolve(a).then(s,n)}function J(t){return function(){var i=this,e=arguments;return new Promise(function(s,n){var r=t.apply(i,e);function o(t){K(r,s,n,o,l,"next",t)}function l(t){K(r,s,n,o,l,"throw",t)}o(void 0)})}}const Y=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Z=new Map,X=function(t,i=[]){if(!t)return!1;const e=function(t,i){let e="";for(let t=0;i.length>t;t++){const s=i[t];e+=s.length+":"+s}return t.length+":"+t+"|"+i.length+":"+e}(t,i),s=Z.get(e);if(void 0!==s)return s;const n=t.toLowerCase(),r=Y.concat(i).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>Z.size||Z.clear(),Z.set(e,r),r};function Q(t,i,e,s,n){return i>e&&(s.warn("min cannot be greater than max."),i=e),M(t)?t>e?(s.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(s.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(s.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+n),Q(null!=n?n:e,i,e,s))}var tt=class{constructor(t){this.C={},this.I=t.I,this.R=Q(t.bucketSize,0,100,t.$),this.A=Q(t.refillRate,0,this.R,t.$),this.O=Q(t.refillInterval,0,864e5,t.$)}F(t,i){const e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i;const e=Date.now(),s=String(t);let n=this.C[s];return n?this.F(n,e):(n={tokens:this.R,lastAccess:e},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(i=this.I)||void 0===i||i.call(this,t)),0===n.tokens)}stop(){this.C={}}};const it="Mobile",et="Android",st="Tablet",nt="Android Tablet",rt="iPad",ot="Apple Watch",lt="Safari",at="BlackBerry",ut="Samsung Internet",ht="Chrome",dt="Chrome iOS",ct="Internet Explorer",vt="Internet Explorer Mobile",ft="Opera",pt="Microsoft Edge",_t="Firefox",gt="Firefox iOS",mt="Nintendo",yt="PlayStation",bt="Xbox",wt="Android Mobile",$t="Mobile Safari",St="Windows",xt="Windows Phone",Et="Nokia",kt="Ouya",Tt="Generic "+it.toLowerCase(),Pt="Generic "+st.toLowerCase(),Ct="Konqueror",Rt="Oculus Browser",Ot="Vivaldi",At="Yandex",It="Whale",Ft="DuckDuckGo",Mt="Pale Moon",Dt="Waterfox",Nt="Brave",jt="Claude",Lt="Codex",Ut="ChatGPT",Bt="Google Search App",zt=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ht=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),qt=new RegExp(bt,"i"),Vt=new RegExp("PlayStation \\w+","i"),Wt=new RegExp("Nintendo \\w+","i"),Gt=new RegExp("BlackBerry|PlayBook|BB10","i"),Kt={"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"},Jt=function(t,i,e,s){i=i||"";const n=function(t){return(null==t?void 0:t.brave)?Nt:null}(e);return n||((null==s?void 0:s.detectGoogleSearchApp)&&m(t,"GSA/")?Bt:m(t," OPR/")&&m(t,"Mini")?"Opera Mini":m(t," OPR/")?ft:Gt.test(t)?at:m(t,"IEMobile")||m(t,"WPDesktop")?vt:m(t,"OculusBrowser")?Rt:m(t,"SamsungBrowser")?ut:m(t,"Edge")||m(t,"Edg/")?pt:m(t,"Vivaldi/")?Ot:m(t,"YaBrowser/")?At:m(t,"Whale/")?It:m(t,"DuckDuckGo/")||m(t,"Ddg/")?Ft:m(t,"Claude/")?jt:m(t,"Codex/")?Lt:m(t,"ChatGPT/")?Ut:m(t,"FBIOS")?"Facebook Mobile":m(t,"UCWEB")||m(t,"UCBrowser")?"UC Browser":m(t,"CriOS")?dt:m(t,"CrMo")||m(t,ht)?ht:m(t,et)&&m(t,lt)?wt:m(t,"FxiOS")?gt:m(t.toLowerCase(),Ct.toLowerCase())?Ct:m(t,"Brave/")?Nt:((t,i)=>i&&m(i,"Apple")||function(t){return m(t,lt)&&!m(t,ht)&&!m(t,et)}(t))(t,i)?m(t,it)?$t:lt:m(t,"PaleMoon/")?Mt:m(t,"Waterfox/")?Dt:m(t,_t)?_t:m(t,"MSIE")||m(t,"Trident/")?ct:m(t,"Gecko")?_t:"")},Yt={[vt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[pt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ht]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[dt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[lt]:[zt],[$t]:[zt],[ft]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[_t]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[gt]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ct]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[at]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),zt],[wt]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ut]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Rt]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Ot]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[At]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[It]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Nt]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[jt]:[Ht],[Lt]:[Ht],[Ut]:[Ht],[Ft]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Mt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Dt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Bt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ct]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Zt=function(t,i,e,s){const n=Jt(t,i,e,s),r=Yt[n];if(R(r))return null;for(let i=0;r.length>i;i++){const e=t.match(r[i]);if(e)return parseFloat(e[e.length-2])}return null},Xt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[bt,t&&t[1]||""]],[new RegExp(mt,"i"),[mt,""]],[new RegExp(yt,"i"),[yt,""]],[Gt,[at,""]],[new RegExp(St,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[xt,""];if(new RegExp(it).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];const e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){let t=Kt[e[1]]||"";return/arm/i.test(i)&&(t="RT"),[St,t]}return[St,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let i="";return t&&t.length>=3&&(i=R(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[et,[t[2],t[3],t[4]||"0"].join(".")]:[et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Qt=function(t){for(let i=0;Xt.length>i;i++){const[e,s]=Xt[i],n=e.exec(t),r=n&&(T(s)?s(n,t):s);if(r)return r}return["",""]},ti=function(t){return Wt.test(t)?mt:Vt.test(t)?yt:qt.test(t)?bt:new RegExp(kt,"i").test(t)?kt:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?xt:/iPad/.test(t)?rt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?ot:Gt.test(t)?at:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Et,"i").test(t)?Et:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(it).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?et:nt:new RegExp("(pda|Mobile)","i").test(t)?Tt:new RegExp(st,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?Pt:""},ii=function(t,i){var e;const s=ti(t);return s===rt||s===nt||"Kobo"===s||"Kindle Fire"===s||s===Pt?st:s===mt||s===bt||s===yt||s===kt?"Console":s===ot?"Wearable":s?it:"Android"===(null==i?void 0:i.userAgentDataPlatform)&&(null!==(e=null==i?void 0:i.maxTouchPoints)&&void 0!==e?e:0)>0?600>Math.min(null!==(n=null==i?void 0:i.screenWidth)&&void 0!==n?n:0,null!==(r=null==i?void 0:i.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==i?void 0:i.devicePixelRatio)&&void 0!==o?o:1)?it:st:"Desktop";var n,r,o},ei=/\bFBAV\/(\d+(?:\.\d+)*)/i,si=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ei],[/\bFBAN\/EMA\b/i,"Facebook Lite",ei],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ei],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],ni="[Truncated]",ri="[Unserializable]";function oi(t){let i="";for(let e=0;t.length>e;e++){const s=t.charCodeAt(e);if(55296>s||s>56319)i+=56320>s||s>57343?t[e]:"�";else{const s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}function li(t,i){if(!i)return t;let e=[];try{e=Object.keys(i)}catch(t){e=[]}for(const s of e){let e;try{e=i[s]}catch(t){e=ri}Object.defineProperty(t,s,{value:e,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;const ai=3e5;var ui=class{record(t){if("too-large"===t.kind)return;if("retry-later"!==t.kind)return void this.reset();if(!t.retryAfterMs)return;const i=this.isOpen(),e=Date.now(),s=Math.min(t.retryAfterMs,ai);if(!i)return this.ts=e,void(this.es=e+s);this.es=Math.max(this.es,Math.min(e+s,this.ts+ai))}remainingMs(){const t=Date.now();if(this.ts-5e3>t)return this.reset(),0;const i=Math.min(ai,Math.max(0,this.es-t));return 0===i&&this.reset(),i}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const hi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function di(t,i){return"string"==typeof(e=t)&&hi.test(e)?t:i();var e}function ci(t,i){const e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function vi(t){return t?t.split("#")[0]:t}function fi(t){try{return t()}catch(t){return}}function pi(t,i){const e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function _i(t,i,e){return gi.apply(this,arguments)}function gi(){return(gi=J(function*(t,i,e){let s;try{return yield Promise.race([t,new Promise((t,n)=>{s=pi(()=>{try{null==e||e(),t()}catch(t){n(t)}},i)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function mi(t){return mi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(t)}function yi(t,i,e){return(i=function(t){var i=function(t){if("object"!=mi(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var e=i.call(t,"string");if("object"!=mi(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mi(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function bi(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,s)}return e}function wi(t){for(var i=1;arguments.length>i;i++){var e=null!=arguments[i]?arguments[i]:{};i%2?bi(Object(e),!0).forEach(function(i){yi(t,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):bi(Object(e)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}return t}let $i,Si,xi,Ei;function ki(t){var i;const e=globalThis._posthogChunkIds,s=globalThis._debugIds;if(!e&&!s)return;const n=e?Object.keys(e):[],r=s?Object.keys(s):[];if(Ei&&Ti(e,n,Si)&&Ti(s,r,xi))return Ei;Si=e?wi({},e):void 0,xi=s?wi({},s):void 0,Ei={},null!==(i=$i)&&void 0!==i||($i={});const o=(i,e)=>{for(const n of i){const i=e[n];if(!i)continue;const r=null==$i?void 0:$i[n];if(r){Ei[r]=i;continue}const o=t(n);for(let t=o.length-1;t>=0;t--){var s;const e=null===(s=o[t])||void 0===s?void 0:s.filename;if(e){Ei[e]=i,$i[n]=e;break}}}};return s&&o(r,s),e&&o(n,e),Ei}function Ti(t,i,e){return t&&e?i.length===Object.keys(e).length&&i.every(i=>t[i]===e[i]):t===e}var Pi=class{constructor(t,i,e=[]){this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i={}){const e=i&&i.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(e,i,0).apply(t),n=this.buildParsingContext(i),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,e),$exception_level:"error"}}modifyFrames(t){var i=this;return J(function*(){for(const e of t)e.stacktrace&&e.stacktrace.frames&&k(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e;let s,n;if(null!=t.cause&&(s=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)}catch(t){}return wi(wi({},t),{},{cause:s,stack:n,errors:null===(e=t.errors)||void 0===e?void 0:e.map(t=>this.parseStacktrace(t,i))})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(const e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return J(function*(){let e=t;for(const t of i.modifiers)e=yield t(e);return e})()}convertToExceptionList(t,i){const e=[],s=(t,n,r)=>{var o;const l=e.length,a=void 0===n?wi(wi({type:"string"==typeof i.type&&i.type.length>0?i.type:"generic"},"boolean"==typeof i.handled?{handled:i.handled}:void 0===i.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof i.synthetic?i.synthetic:t.synthetic,exception_id:l}):{type:"chained",source:r,synthetic:t.synthetic,exception_id:l,parent_id:n},u={type:t.type,value:t.value,mechanism:a};t.stack&&(u.stacktrace={type:"raw",frames:t.stack}),e.push(u),t.cause&&s(t.cause,l,"cause");for(const i of null!==(o=t.errors)&&void 0!==o?o:[])s(i,l,"member")};return s(t),e}buildParsingContext(t){var i;return{chunkIdMap:ki(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}getAggregateErrors(t){try{if(z(t)){let e=Object.getPrototypeOf(t);for(let s=0;e&&100>s;s++){var i;const s=null===(i=Object.getOwnPropertyDescriptor(e,"constructor"))||void 0===i?void 0:i.value;if("function"==typeof s&&"AggregateError"===s.name){const i=t.errors;return k(i)?i:void 0}e=Object.getPrototypeOf(e)}}}catch(t){}}buildCoercingContext(t,i,e=0){let s=0,n=0,r=!1;const o=new Set,l=[],a={},u=(t,i,e=0)=>{const u=h(i,e),d=u.apply;if(u.apply=i=>{l.push(t);try{return d(i)}finally{l.pop()}},e>4||e>0&&-1!==l.indexOf(t))return this.coerceFallback(u);const c="object"==typeof t&&null!==t||"function"==typeof t;if(0===e&&s>=50||c&&o.has(t))return;c&&o.add(t),0===e&&s++;const v=this.getAggregateErrors(t);let f,p;r||(r=!!v);try{if(f=this.applyCoercers(t,u),!f)throw a}catch(t){if(t===a)return void(0===e&&s--);if(!r)throw t;f=this.coerceFallback(u)}if(!v||s>=50)return f;try{p=v.length}catch(t){return f}if(!Number.isInteger(p)||0>p||p>4294967295)return f;const _=[];for(let t=0;50>s&&1e3>n&&p>t;t++){let e;n++;try{e=u.next(v[t])}catch(t){s++,e=this.coerceFallback(h(i+1))}e&&_.push(e)}return wi(wi({},f),{},{errors:_})},h=(e,s=0)=>wi(wi({},i),{},{syntheticException:0==e?i.syntheticException:void 0,mechanism:0==e?t:{},apply(t){const i=u(t,e,s+1);if(!i)throw a;return i},next:t=>u(t,e+1)}),d=h(e);return wi(wi({},d),{},{apply:t=>{var i;return null!==(i=u(t,e))&&void 0!==i?i:this.coerceFallback(d)}})}};const Ci=/^([a-z][a-z0-9.+-]+):/i,Ri=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function Oi(t){if(!t||"<anonymous>"===t)return!1;const i=Ci.exec(t);return!i||Ri.includes(i[1].toLowerCase())}function Ai(t,i,e,s,n){const r={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:Oi(i)};return R(s)||(r.lineno=s),R(n)||(r.colno=n),r}const Ii=(t,i)=>{const e=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return e||s?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?`safari-extension:${i}`:`safari-web-extension:${i}`]:[t,i]},Fi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Mi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Di=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ni=(t,i)=>{const e=Fi.exec(t);if(e){const[,t,s,n]=e;return Ai(i,t,"?",+s,+n)}const s=Mi.exec(t);if(s){if(s[2]&&0===s[2].indexOf("eval")){const t=Di.exec(s[2]);t&&(s[2]=t[1],s[3]=t[2],s[4]=t[3])}const[t,e]=Ii(s[1]||"?",s[2]);return Ai(i,e,t,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},ji=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Li=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ui=(t,i)=>{const e=ji.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=Li.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],s=e[1]||"?";return[s,t]=Ii(s,t),Ai(i,t,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Bi=/\(error: (.*)\)/;function zi(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function Hi(t){for(let i=1;10>=i;i++){const e=t.length-2*i;if(0>e)break;let s=!0;for(let n=0;i>n;n++)if(!zi(t[e+n],t[e+i+n])){s=!1;break}if(s){for(let s=0;i>s;s++)t[e+s]=t[e+i+s];return t.length=e+i,{start:e,length:i}}}}function qi(t,i){const e=i.start+i.length,s=Wi(t,i);s&&t.splice(e+s===t.length?e:i.start,s)}function Vi(t,i){let e=i.start;for(;e>0&&zi(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function Wi(t,i){const e=i.start+i.length;let s=e;for(;t.length>s&&zi(t[s],t[s-i.length]);)s++;return s-e}function Gi(t,i){const e=i[0];let s=t.length-(e?Vi(t,e):0);for(const e of i)s-=Wi(t,e);return s}function Ki(t,i,e){for(let s=0;t.length>s;s++){const n=t[(i+s)%t.length],r=t[(e+s)%t.length];if(n!==r)return r>n}return!1}var Ji=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){const e=O(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){const i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${i}: ${t.message}`:i}isDOMException(t){return B(t,"DOMException")}isDOMError(t){return B(t,"DOMError")}},Yi=class{match(t){return z(t)}coerce(t,i){var e;const s=this.getStack(t),n=void 0===s?null===(e=i.syntheticException)||void 0===e?void 0:e.stack:void 0,r=!!n;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=s?s:n,cause:t.cause?i.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,i){const e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){try{const i=t.stacktrace;if("string"==typeof i&&i.length>0)return i;const e=t.stack;return"string"==typeof e&&e.length>0?e:void 0}catch(t){return}}},Zi=class{match(t){return!!B(t,"ErrorEvent")&&(null!=t.error||this.hr(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);const s=i.apply(t.message);return wi(wi({},s),{},{stack:null!==(e=this.vr(t))&&void 0!==e?e:s.stack,synthetic:!0})}hr(t){return O(t.message)&&t.message.length>0}vr(t){var i,e;const s=t,n=null!==(i=s.lineno)&&void 0!==i?i:0,r=null!==(e=s.colno)&&void 0!==e?e:0;if(O(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Xi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Qi=class{match(t){return"string"==typeof t}coerce(t,i){var e;const[s,n]=this.getInfos(t);return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}getInfos(t){let i="Error",e=t;const s=t.match(Xi);return s&&(i=s[1],e=s[2]),[i,e]}};const te=["fatal","error","warning","log","info","debug"];function ie(t,i=40){const e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(let t=e.length;t>0;t--){const s=e.slice(0,t).join(", ");if(i>=s.length)return t===e.length?s:s.length>i?`${s.slice(0,i)}...`:s}return""}var ee=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,s;const n=this.getErrorPropertyFromObject(t);return n?i.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null===(s=i.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(H(t))return t.constructor.name;const i="name"in t?t.name:void 0;return O(i)&&!A(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){let i=`'${t.name}' captured as exception`;return"message"in t&&"string"==typeof t.message&&(i+=` with message: '${t.message}'`),i}if("message"in t&&"string"==typeof t.message)return t.message;const i=this.getObjectClassName(t);return`${i&&"Object"!==i?`'${i}'`:"Object"} captured as exception with keys: ${ie(t)}`}isSeverityLevel(t){return O(t)&&!A(t)&&te.indexOf(t)>=0}getStack(t){try{return O(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:O(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(const i in t)if({}.hasOwnProperty.call(t,i)){const e=t[i];if(z(e))return e}}getObjectClassName(t){try{const i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},se=class{match(t){return H(t)}coerce(t,i){var e;const s=t.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${ie(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},ne=class{match(t){return U(t)}coerce(t,i){var e;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},re=class{match(t){return B(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!H(t))return!1;try{const i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e;const s=this.getUnhandledRejectionReason(t);return U(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}:i.apply(s)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}};const oe="$message",le="$timestamp",ae=new Set([oe,le]),ue={enabled:!0,max_bytes:32768};function he(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:ue.enabled,max_bytes:ce(t.max_bytes,ue.max_bytes)}:wi({},ue)}var de=class{constructor(t){this.ns=[],this.ss=0,this.Ar=he(t)}setConfig(t){this.Ar=he(t),this.rs()}add(t){const i=function(t){let i;try{i=w(t)}catch(t){return}try{const t=JSON.parse(i);if(!P(t))return;const e=t,s=e[oe],n=e[le];if(!O(s)||0===s.trim().length)return;if(!O(n)&&!M(n))return;return{step:e,json:i}}catch(t){return}}(t);if(!i)return;const e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;const i=encodeURIComponent(t);let e=0;for(let t=0;i.length>t;t++)"%"===i[t]?(e+=1,t+=2):e+=1;return e}(i.json);e>this.Ar.max_bytes||(this.ns.push({step:i.step,bytes:e}),this.ss+=e,this.rs())}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Ar.max_bytes&&this.ns.length>0;){const t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function ce(t,i){if(!M(t)||1/0===t||-1/0===t)return i;const e=Math.floor(t);return 0>e?i:e}const ve=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function fe(t){return"string"==typeof t||t}function pe(t){return"string"==typeof t?t:void 0}const _e=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],ge="NativeGzipValidationError",me=t=>t.length>=2&&31===t[0]&&139===t[1],ye=(t,i)=>t===p.GZipJS||i===p.GZipJS||"gzip"===i,be=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):"");let we;const $e=t=>{throw ci(ge,`Native gzip produced invalid output: ${t}`)},Se=(xe=J(function*(t,i){18>t.size&&$e("too-short");const e=new Uint8Array(yield t.slice(0,10).arrayBuffer());me(e)&&8===e[2]||$e("invalid-header");const s=new DataView(yield t.slice(t.size-8).arrayBuffer());s.getUint32(0,!0)!==(t=>{const i=(()=>{if(we)return we;we=[];for(let t=0;256>t;t++){let i=t;for(let t=0;8>t;t++)i=1&i?3988292384^i>>>1:i>>>1;we[t]=i>>>0}return we})();let e=4294967295;for(let s=0;t.length>s;s++)e=i[255&(e^t[s])]^e>>>8;return(4294967295^e)>>>0})(i)&&$e("invalid-crc");const n=i.length>>>0;s.getUint32(4,!0)!==n&&$e("invalid-size")}),function(t,i){return xe.apply(this,arguments)});var xe;function Ee(){return Ee=J(function*(t,i=!0,e){try{const i=(new TextEncoder).encode(t),e=new globalThis.CompressionStream("gzip"),n=e.writable.getWriter(),r=n.write(i).then(()=>n.close()).catch((s=J(function*(t){try{yield n.abort(t)}catch(t){}throw t}),function(t){return s.apply(this,arguments)})),o=new Response(e.readable).blob(),[l]=yield Promise.all([o,r]);return yield Se(l,i),l}catch(t){if(null==e?void 0:e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}var s}),Ee.apply(this,arguments)}function ke(t,i){if(null==t)return{};var e,s,n=function(t,i){if(null==t)return{};var e={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(i.includes(s))continue;e[s]=t[s]}return e}(t,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(s=0;r.length>s;s++)i.includes(e=r[s])||{}.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}const Te="[redacted]",Pe=/^[A-Za-z0-9+/\n\r]+=*$/,Ce=/^[A-Za-z0-9_-]+={0,2}$/,Re=/[-_]/,Oe=/^data:[^,\s]*;base64,/i,Ae=/^[A-Za-z0-9+/_-]+={0,2}$/,Ie=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Fe=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Me=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,De=/[\s<>"]/,Ne=new RegExp(Me.source,"i"),je=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Le=new RegExp(`^${je.source}`,"i"),Ue=new RegExp(je.source,"gi"),Be=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,ze=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,He=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,qe=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Ve=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,We=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,Ge=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Ke=/\b\d(?:[ ./-]?\d){12,}\b/g,Je=/\d+/g,Ye=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Ze=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function Xe(t){return function(t){return Fe.test(t)}(t)||Be.test(t)||ze.test(t)}function Qe(t){return t.split("&",129).length>128}function ts(t,i,e){return Xe(t)||i.includes(";")&&function(t){return t.split(";").some(t=>Xe(t.split("=",1)[0]))}(i)?Te:Ne.test(i)?e?os(i,{allowNestedUrls:!1,stripPunctuation:!0}):Te:i}function is(t,i){const e=new URLSearchParams;let s=!1,n=!1;for(const[r,o]of new URLSearchParams(t)){const t=ls(r),l=ls(o);s||(s=t!==r||l!==o);const a=ts(t,l,i);s||(s=a!==l),n=Xe(t)||a!==l,e.append(t,a)}return{changed:s,lastFieldSensitive:n,serialized:e.toString()}}function es(t,i){if(!t.includes("="))return{value:ss(t,i),lastFieldSensitive:!1};const e=is(t,i);return{value:e.changed?e.serialized:t,lastFieldSensitive:e.lastFieldSensitive}}function ss(t,i){return i?os(t,{allowNestedUrls:!1,stripPunctuation:!0}):Ne.test(t)?Te:t}function ns(t,i,e){return"#"===t?!i.fragment&&(i.fragment=!0):"?"===t&&(i.fragment?"="!==e&&!i.fragmentQuery&&(i.fragmentQuery=!0):!i.query&&(i.query=!0))}function rs(t,i){var e;if(t.length>8192&&Le.test(t))return Te;const{address:s,suffix:n}=i.stripPunctuation?function(t){let i=t.length;for(;i>0&&".,;:!?)]}'".includes(t[i-1]);)i--;return{address:t.slice(0,i),suffix:t.slice(i)}}(t):{address:t,suffix:""};let r;try{r=new URL(s)}catch(t){return Te+n}const o=r.search.slice(1),l=""!==r.hash,a=function(t){const i=t.slice(1),e=i.indexOf("?");return 0>e?{head:i,tail:null}:{head:i.slice(0,e),tail:i.slice(e+1)}}(r.hash);if(Qe(o)||Qe(a.head)||Qe(null!==(e=a.tail)&&void 0!==e?e:""))return Te+n;let u=!1;(r.username||r.password)&&(r.username=Te,r.password="",u=!0);const h=is(o,i.allowNestedUrls);h.changed&&(r.search=h.serialized,u=!0);const d=es(a.head,i.allowNestedUrls),c=null===a.tail?null:(v=a.tail,d.lastFieldSensitive?{value:""===v?"":Te,lastFieldSensitive:!0}:es(v,i.allowNestedUrls));var v;const f=null===c?d.value:`${d.value}?${c.value}`;f!==r.hash.slice(1)&&(r.hash=f,u=!0);const p=l?null!=c?c:d:h;return(u?ls(r.toString()):s)+(p.lastFieldSensitive?"":n)}function os(t,i){return t.replace(Me,e=>function(t,i){const e=function(t){if(!t.includes("://"))return[];const i=[...t.matchAll(Ue)].map(t=>t.index),e=[],s={query:!1,fragment:!1,fragmentQuery:!1};let n=0,r=!1,o="";for(let l=0;t.length>l&&i.length>n;l++){i[n]===l&&(l>0&&"="!==o&&e.push(l),n++);const a=t[l];ns(a,s,o)?(o=a,r=!0):r&&"=&".includes(a)&&(o=a)}return e}(t);if(0===e.length)return rs(t,i);let s="",n=0;for(const r of e)s+=rs(t.slice(n,r),wi(wi({},i),{},{stripPunctuation:!1})),n=r;return s+rs(t.slice(n),i)}(e,wi(wi({},i),{},{stripPunctuation:i.stripPunctuation&&e.length!==t.length})))}function ls(t){return t.replace(Ie,Te)}function as(t,i){return function(t){return t.length>=10240&&(Pe.test(t)||function(t){const i=Oe.exec(t);if(!i)return!1;let e;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Ae.test(e.replace(/[\r\n]/g,""))}(t)||Re.test(t)&&Ce.test(t))}(t)?"[binary data redacted - not supported by PostHog MCP analytics]":function(t,i,e){const s=4*e.maxStringLength;if(t.length>s){const n=i(t.slice(0,function(t,i){let e=i;for(;e>0&&!De.test(t[e-1]);)e--;return e}(t,s)));if(n.length>=2*e.maxStringLength)return n+e.truncationSuffix}return i(t)}(t,t=>function(t){return os(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){let i=t.replace(He," ");return i=i.replace(qe,Te),i=i.replace(Ve,Te),i=i.replace(We,`$1${Te}`),i=i.replace(Ke,hs),i=i.replace(Ge,Te),i=i.replace(Ye,`$1${Te}`),i=i.replace(Ze,`$1${Te}`),i}(ls(t))),i)}function us(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;if(0>n||n>9)return!1;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function hs(t){const i=[];for(let e=Je.exec(t);null!==e;e=Je.exec(t))i.push({digits:e[0],start:e.index,end:e.index+e[0].length});let e="",s=0,n=0;for(;i.length>n;){let r="",o=-1;for(let t=n;i.length>t&&(r+=i[t].digits,19>=r.length);t++)r.length>=13&&us(r)&&(o=t);0>o?n++:(e+=t.slice(s,i[n].start)+Te,s=i[o].end,n=o+1)}return e+t.slice(s)}const ds={}.propertyIsEnumerable;function cs(t,i){try{return ps(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function vs(t,i,e,s){if(0>=e.remainingNodes)return{stringValue:ni};if(e.remainingNodes--,N(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){const e=t.toString(),s=BigInt("9223372036854775808");return t>=s||-s>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const e=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:oi(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ni};if(t instanceof Date){const i=t.getTime(),e=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:"string"==typeof e?oi(e):String(e)}}e.ancestors.add(t);try{try{const n=t.toJSON;if("function"==typeof n)return vs(n.call(t),i,e,s+1)}catch(t){}return k(t)?{arrayValue:{values:fs(t,i,e,s+1)}}:{kvlistValue:{values:ps(t,i,e,s+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:oi(String(t))}}function fs(t,i,e,s){const n=[],r=Math.min(t.length,1e3);let o=0;for(;r>o&&e.remainingNodes>0;o++)try{const r=o in t?t[o]:void 0;if(F(r))continue;n.push(vs(r,i,e,s))}catch(t){n.push({stringValue:ri})}return t.length>o&&n.push({stringValue:ni}),n}function ps(t,i,e,s){const n=[];for(const r in t)if(ds.call(t,r)){if(!r){null==i||i.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=t[r];if(I(o)||R(o))continue;n.push({key:oi(r),value:vs(o,i,e,s)})}catch(t){n.push({key:oi(r),value:{stringValue:ri}})}}return n}function _s(t,i,e){return wi(wi(wi(wi({},li({},t.resourceAttributes)),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}const gs=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function ms(t,i){const e=li({},t),s={};for(const t of gs)({}).hasOwnProperty.call(e,t)&&(s[t]=e[t],delete e[t]);return[...cs(e,i),...cs(s,i)]}const ys={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const bs={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}},ws=bs.info;function $s(t){try{return oi(String(t))}catch(t){return ri}}function Ss(t,i,e,s){const n=t.level||"info",{text:r,number:o}=bs[n]||ws,l=function(t=Date.now()){return String(t)+"000000"}(M(s)?s:void 0),a={};i.distinctId&&(a.posthogDistinctId=i.distinctId),i.sessionId&&(a.sessionId=i.sessionId),i.windowId&&(a["window.id"]=i.windowId),F(i.sessionStartTimestamp)||(a.sessionStartTimestamp=String(i.sessionStartTimestamp)),F(i.lastActivityTimestamp)||(a.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(a["url.full"]=i.currentUrl),i.screenName&&(a["screen.name"]=i.screenName),i.appState&&(a["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(a.feature_flags=i.activeFeatureFlags);const u=wi({},a),h=t.attributes;if(h){let t=[];try{t=Object.keys(h)}catch(i){t=[]}for(const i of t){let t;try{t=h[i]}catch(i){t=ri}Object.defineProperty(u,i,{value:t,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:o,severityText:r,body:{stringValue:$s(t.body)},attributes:cs(u,e)};return t.trace_id&&(d.traceId=t.trace_id),t.span_id&&(d.spanId=t.span_id),R(t.trace_flags)||(d.flags=t.trace_flags),d}function xs(t,i,e){return _s(t,i,e)}function Es(t,i,e,s){return{resourceLogs:[{resource:{attributes:ms(i)},scopeLogs:[{scope:{name:e,version:s},logRecords:t}]}]}}var ks=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=pi(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Ts(){return.75+.5*Math.random()}function Ps(t,i,e,s){const n=Math.min(Math.max(0,i-1),6),r=t*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,t)))*e)}var Cs=class{constructor(t,i,e,s,n,r=()=>Promise.resolve(),o){var l;this._instance=t,this.Ar=i,this.$=e,this.hs=s,this.ds=n,this.vs=r,this.fs=o,this.ps=new ks(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new ui,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=i.maxBufferSize,this.Is=Math.max(null!==(l=i.maxQueueSize)&&void 0!==l?l:i.maxBufferSize,i.maxBufferSize),this.Ms=i.flushIntervalMs,this.Es=i.maxBatchRecordsPerPost,this.Ps=i.rateCapWindowMs,this.Rs=i.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(f.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Ar.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,i){var e;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==t?void 0:t.body))return;const s=this.Os(t);if(null===s)return;if(!s.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ds())return;const n={record:Ss(s,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.hs(),this.$,null==i?void 0:i.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(t){const i=this.Ar.beforeSend;if(!i)return t;const e=k(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Log was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for log:",t),null}return s}Ds(){if(void 0===this.Rs)return!0;const t=Date.now(),i=t-this.xs;return this.Ps>i&&i>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var t=this;return J(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return J(function*(){var i;t.ps.clear();let e=null!==(i=t._instance.getPersistedProperty(f.LogsQueue))&&void 0!==i?i:[];if(0===e.length)return;const s=e.length;let n=0;for(;e.length>0&&s>n;){var r,o;const i=t._s;t.bs=0;const s=Math.min(e.length,t.Es),l=e.slice(0,s),a=Es(l.map(t=>t.record),t.qs(),null!==(r=t.fs)&&void 0!==r?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),u=yield t._instance.js(a);if(t._s!==i)return;if("too-large"===u.kind&&l.length>1)t.Es=Math.max(1,Math.floor(l.length/2)),t.$.warn(`Logs batch of size ${l.length} was too large for the ingestion endpoint, reducing batch size to ${t.Es}`);else{if(t.ws.record(u),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),"retry-later"===u.kind)throw u.error;if("too-large"===u.kind?t.$.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===u.kind&&t.Ar.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Ar.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(l.length),e=null!==(o=t._instance.getPersistedProperty(f.LogsQueue))&&void 0!==o?o:[],n+=l.length,"fatal"===u.kind)throw u.error}}})()}Bs(t){var i=this;return J(function*(){var e;const s=Math.max(0,t-i.bs),n=null!==(e=i._instance.getPersistedProperty(f.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(f.LogsQueue,n.slice(s)),yield i.vs()})()}qs(){return xs(this.Ar,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var i;if(this._instance.optedOut)return;const e=null!==(i=this._instance.getPersistedProperty(f.LogsQueue))&&void 0!==i?i:[];this.Is>e.length||(e.shift(),this.bs++,this.$.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(f.LogsQueue,e),this.Ts>e.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Ps(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const t=this._instance.getPersistedProperty(f.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return J(function*(){i.ps.clear();const e=i.flush().catch(()=>{});void 0!==t?yield _i(e,t):yield e})()}flushWithTimeout(t){var i=this;return J(function*(){const e=i.flush();yield _i(e,t,()=>{e.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=Ts(),this.$.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}};const Rs=/^[0-9a-f]+$/;function Os(t,i,e){return"string"==typeof t&&t.length===i&&t!==e&&Rs.test(t)}const As=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;const Is="00",Fs=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ms(t){return String(t)+"000000"}function Ds(t,i,e,s){let n="";return s&&(n=Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${JSON.stringify(s[t])}`).join(",")),`${t}\0${i}\0${null!=e?e:""}\0${n}`}var Ns=class{constructor(t,i,e){this._instance=t,this.Ar=i,this.$=e,this.Hs=new Map,this.ps=new ks(()=>this.flush().catch(t=>{this.$.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new ui,this.ks=0,this.Ss=1,this.Gs=0}count(t,i=1,e){this.Qs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Qs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Qs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this;const i=this.ys,e=function(){var e=J(function*(){i&&(yield i.catch(()=>{})),yield t.Zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.ys===e&&(this.ys=null)});return this.ys=e,e}drainWindow(){if(0===this.Hs.size)return null;const t=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(t){if(this._instance.isDisabled||this._instance.optedOut)return;const i=this.Os(t);if(null===i)return;if(!i.name||"string"!=typeof i.name)return void this.$.warn("Dropping metric with empty name");if("number"!=typeof i.value||!Number.isFinite(i.value))return void this.$.warn(`Dropping metric '${i.name}': value must be a finite number`);if("count"===i.type&&0>i.value)return void this.$.warn(`Dropping count '${i.name}': counters are monotonic, value must be >= 0`);let e,s;try{e=i.attributes?wi({},i.attributes):void 0,s=Ds(i.type,i.name,i.unit,e)}catch(t){return void this.$.warn(`Dropping metric '${i.name}': attributes could not be serialized`,t)}let n=this.Hs.get(s);if(!n){if(!this.Ks())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Hs.set(s,n)}const r=this.Ws.get(i.name);void 0===r?this.Ws.set(i.name,i.type):r===i.type||this.Vs.has(i.name)||(this.Vs.add(i.name),this.$.warn(`Metric name '${i.name}' is already used as a ${r}; recording it as a ${i.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,i.value);const o=this.Ys();o&&(n.exemplar=wi(wi({},o),{},{value:i.value,timeMs:Date.now()})),this.Fs()}Ys(){try{var t,i;const e=function(t){const i=function(t){if("string"!=typeof t)return;const i=As.exec(t.trim());if(!i)return;const[,e,s,n,r,o]=i;return"ff"===e||"00"===e&&o||!function(t){return Os(t,32,"00000000000000000000000000000000")}(s)||!function(t){return Os(t,16,"0000000000000000")}(n)?void 0:{version:e,traceId:s,spanId:n,flags:r}}(t);return i&&{traceId:i.traceId,spanId:i.spanId,flags:(e=i.flags,1&parseInt(e,16)?"01":Is)};var e}(null===(t=(i=this._instance).getActiveSpan)||void 0===t||null===(t=t.call(i))||void 0===t?void 0:t.traceparent());if(e&&"01"===e.flags)return{traceId:e.traceId,spanId:e.spanId}}catch(t){}}Ks(){return this.Ar.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Ar.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(t,i){switch(t.type){case"count":var e;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Fs.length+1).fill(0)});const e=t.hist;e.count+=1,e.sum+=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.bucketCounts[function(t,i){for(let e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Fs)]+=1;break}}}Os(t){const i=this.Ar.beforeSend;if(!i)return t;const e=k(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Metric was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for metric:",t),null}return s}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Ps(this.Ar.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var t=this;return J(function*(){if(t.ps.clear(),0===t.Hs.size)return;const i=t.Hs;t.Hs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;const e=t.Gs,s=yield t._instance.po(t.Js(i));if(e===t.Gs)switch(t.ws.record(s),"retry-later"===s.kind?(t.ks++,t.Ss=Ts()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),s.kind){case"ok":return;case"retry-later":return t.mo(i),void t.ps.armNoEarlierThan(t.zs());case"too-large":return void t.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.$.error("Failed to send metrics batch:",s.error)}})()}Js(t){return i=this.yo(t),e=function(t,i,e){return _s(t,i,e)}(this.Ar,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:ms(e)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,e,s,n}yo(t){const i=Ms(Date.now()),e=new Map;for(const o of t.values()){var s;const t=Ds(o.type,o.name,o.unit,void 0);let l=e.get(t);l||(l=wi({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},e.set(t,l));const a=cs(null!==(s=o.attributes)&&void 0!==s?s:{},this.$),u=Ms(o.windowStartMs),h=js(o.exemplar);if("count"===o.type){var n;const t=wi({attributes:a,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(n=o.total)&&void 0!==n?n:0},h);l.sum.dataPoints.push(t)}else if("gauge"===o.type){var r;const t=wi({attributes:a,timeUnixNano:i,asDouble:null!==(r=o.last)&&void 0!==r?r:0},h);l.gauge.dataPoints.push(t)}else if(o.hist){const t=wi({attributes:a,startTimeUnixNano:u,timeUnixNano:i,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Fs},h);l.histogram.dataPoints.push(t)}}return Array.from(e.values())}mo(t){for(const[n,r]of t){var i;const t=this.Hs.get(n);if(t)switch(t.windowStartMs=Math.min(t.windowStartMs,r.windowStartMs),t.exemplar=null!==(i=t.exemplar)&&void 0!==i?i:r.exemplar,t.type){case"count":var e,s;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+(null!==(s=r.total)&&void 0!==s?s:0);break;case"gauge":break;case"histogram":if(r.hist)if(t.hist){t.hist.count+=r.hist.count,t.hist.sum+=r.hist.sum,t.hist.min=Math.min(t.hist.min,r.hist.min),t.hist.max=Math.max(t.hist.max,r.hist.max);for(let i=0;t.hist.bucketCounts.length>i;i++)t.hist.bucketCounts[i]+=r.hist.bucketCounts[i]}else t.hist=r.hist}else this.Ks()&&this.Hs.set(n,r)}}};function js(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:Ms(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}const Ls=(t,{debugEnabled:i}={})=>{const e={N(e,...s){let n;try{n=typeof window>"u"?void 0:window}catch(t){return}n&&(v.DEBUG||n.POSTHOG_DEBUG||i)&&!R(n.console)&&n.console&&("__rrweb_original__"in n.console[e]?n.console[e].__rrweb_original__:n.console[e])(t,...s)},debug(...t){e.N("debug",...t)},info(...t){e.N("log",...t)},warn(...t){e.N("warn",...t)},error(...t){e.N("error",...t)},critical(...i){console.error(t,...i)},uninitializedWarning(t){e.error(`You must initialize PostHog before calling ${t}`)},createLogger:(i,e)=>Ls(`${t} ${i}`,e)};return e},Us=Ls("[PostHog.js]"),Bs=Us.createLogger,zs=Bs("[ExternalScriptsLoader]"),Hs=t=>{const i=null==s?void 0:s.querySelectorAll("script");if(i)for(let e=0;i.length>e;e++)if(i[e].src===t||i[e].getAttribute("src")===t)return i[e]},qs=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return zs.warn(`${i} was requested but loading of external scripts is disabled.`),e("Loading of external scripts is disabled");const n=Hs(i);if(n){if(n.__posthog_loading_callback_fired)return e();const t=n.__posthog_loading_error;return t?e(t):(n.addEventListener("load",t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)}),void n.addEventListener("error",t=>{n.__posthog_loading_error=t,e(t)}))}const r=()=>{if(!s)return e("document not found");if(Hs(i))return qs(t,i,e);let n=s.createElement("script");if(n.type="text/javascript",n.crossOrigin="anonymous",n.src=i,n.onload=t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)},n.onerror=t=>{n.__posthog_loading_error=t,e(t)},t.config.prepare_external_dependency_script&&(n=t.config.prepare_external_dependency_script(n)),!n)return e("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)s.head.appendChild(n);else{const t=s.querySelectorAll("body > script");var r;t.length>0?null===(r=t[0].parentNode)||void 0===r||r.insertBefore(n,t[0]):s.body.appendChild(n)}};(null==s?void 0:s.body)?r():null==s||s.addEventListener("DOMContentLoaded",r)},Vs={},Ws=(t,i)=>{let e=`/static/${i}.js?v=${t.version}`;if("toolbar"===i){const t=3e5;e=`${e}&t=${Math.floor(Date.now()/t)*t}`}return t.requestRouter.endpointFor("assets",e)};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{if("remote-config"===i){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void qs(t,i,e)}const s=t.config.strict_script_versioning;if(s){const n=t.requestRouter.endpointFor("assets",`/static/${t.version}/${i}.js`),r=Vs[n];if("fallback"===s&&r){if(Hs(r))return void qs(t,r,e);delete Vs[n]}return void qs(t,n,"fallback"===s?(s,r)=>{if(s)if("string"==typeof s)e(s);else{var o;const s=Ws(t,i);Vs[n]=s;const r=Hs(n);null==r||null===(o=r.parentNode)||void 0===o||o.removeChild(r),qs(t,s,e)}else e(void 0,r)}:e)}qs(t,Ws(t,i),e)},d.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{const s=t.requestRouter.endpointFor("api",i);qs(t,s,e)},v.DEBUG=!1,v.LIB_VERSION="1.438.16",v.LIB_NAME="web";var Gs=v;const Ks="$surveys",Js="$surveys_loaded_at",Ys="PostHog loadExternalDependency extension not found.",Zs="$surveys_activated",Xs="$surveys_activated_session",Qs="$surveys_activated_timestamps",tn="$early_access_features",en="$active_feature_flags",sn="$feature_flag_details",nn="$feature_flag_errors",rn="$feature_flag_evaluated_at",on="$feature_flag_request_id",ln="$minimal_flag_called_events",an="$enabled_feature_flags",un="$stored_group_properties",hn="$stored_person_properties",dn="$flag_call_reported",cn="$flag_call_reported_session_id",vn="$feature_flag_payloads",fn="$override_feature_flags",pn="$override_feature_flag_payloads",_n="visibilitychange",gn="$people_distinct_id",mn="distinct_id",yn="$device_id",bn="$device_model",wn="__alias",$n="__cmpns",Sn="$fbc",xn="$fbc_persistence",En="$fbp",kn="$fbp_persistence",Tn="__timers",Pn="$autocapture_disabled_server_side",Cn="$heatmaps_enabled_server_side",Rn="$exception_capture_enabled_server_side",On="$error_tracking_suppression_rules",An="$error_tracking_capture_extension_exceptions",In="$web_vitals_enabled_server_side",Fn="$dead_clicks_enabled_server_side",Mn="$product_tours_enabled_server_side",Dn="$logs_capture_enabled_server_side",Nn="$web_vitals_allowed_metrics",jn="$session_recording_remote_config",Ln="$session_recording_enabled_server_side",Un="$replay_sample_rate",Bn="$replay_override_sampling",zn="$replay_override_linked_flag",Hn="$replay_override_url_trigger",qn="$replay_override_event_trigger",Vn="$sesid",Wn="$session_is_sampled",Gn="$session_past_minimum_duration",Kn="$session_recording_url_trigger_activated_session",Jn="$session_recording_event_trigger_activated_session",Yn="$debug_first_full_snapshot_timestamp",Zn="$sess_rec_flush_size",Xn="$groups",Qn="ph_product_tours",tr="$product_tours_activated",ir="$product_tours_activated_session",er="$conversations_widget_session_id",sr="$conversations_ticket_id",nr="$conversations_widget_state",rr="$conversations_user_traits",or="$user_state",lr="$client_session_props",ar="$capture_rate_limit",ur="$initial_campaign_params",hr="$initial_referrer_info",dr="$initial_person_info",cr="$epp",vr="$posthog_cookieless",fr="$cookieless_mode",pr="$sdk_debug_extensions_init_method",_r="$sdk_debug_extensions_init_time_ms",gr="$sdk_debug_recording_script_not_loaded",mr="$sdk_debug_replay_stale_config",yr="$sdk_debug_replay_event_trigger_status",br="$sdk_debug_replay_linked_flag_trigger_status",wr="$sdk_debug_replay_matched_recording_trigger_groups",$r="$sdk_debug_replay_pending_trigger_conditions",Sr="$sdk_debug_replay_remote_trigger_matching_config",xr="$sdk_debug_replay_trigger_groups_count",Er="$sdk_debug_replay_url_trigger_status",kr="$session_recording_start_reason",Tr="anonymous",Pr="identified",Cr="identified_only",Rr="beforeunload",Or="$pageview",Ar="$pageleave",Ir="$identify",Fr="$groupidentify";function Mr(t,i){k(t)&&t.forEach(i)}function Dr(t,i){if(!F(t))if(k(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(const e in t)x.call(t,e)&&i(t[e],e)}const Nr=function(t,...i){for(const e of i)for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t};function jr(t){const i=Object.keys(t);let e=i.length;const s=new Array(e);for(;e--;)s[e]=[i[e],t[i[e]]];return s}const Lr=function(t){return function(...i){try{return t.apply(this,i)}catch(t){Us.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Us.critical(t)}}},Ur=function(t){const i={};return Dr(t,function(t,e){(O(t)&&t.length>0||M(t))&&(i[e]=t)}),i};function Br(t){const i=wi({},t);for(const e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}const zr=["herokuapp.com","vercel.app","netlify.app"];function Hr(t){const i=null==t?void 0:t.hostname;if(!O(i))return!1;const e=i.split(".").slice(-2).join(".");for(const t of zr)if(e===t)return!1;return!0}function qr(t,i,e,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==t||t.addEventListener(i,e,{capture:n,passive:r})}function Vr(t){return"ph_toolbar_internal"===t.name}const Wr=t=>{if(s){try{const i=t+"=",e=s.cookie.split(";").filter(t=>t.length);for(let t=0;e.length>t;t++){let s=e[t];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return M(t)&&isFinite(t)&&Math.floor(t)===t});var Gr=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,s,n){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(n)||0>i||0>e||0>s||0>n||i>0xffffffffffff||e>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=i/Math.pow(2,40),r[1]=i/Math.pow(2,32),r[2]=i/Math.pow(2,24),r[3]=i/Math.pow(2,16),r[4]=i/256,r[5]=i,r[6]=112|e>>>8,r[7]=e,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new t(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(let i=0;16>i;i++){const e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Kr=class{generate(){const t=this.generateOrAbort();if(!R(t))return t;{this.Ct=0;const t=this.generateOrAbort();if(R(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const t=(()=>{const t=Date.now();return M(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.It();else{if(this.Ct>=t+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Gr.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Zr}};const Jr=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};let Yr;var Zr=class{nextUint32(){var t;return this.Rt.length>this.Et||((null!==(t=Yr)&&void 0!==t?t:Yr="u">typeof window&&!R(window.crypto)&&crypto.getRandomValues?t=>crypto.getRandomValues(t):Jr)(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let Xr;const Qr=()=>to().toString(),to=()=>(Xr||(Xr=new Kr)).generate();let io="";const eo=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let so=null;const no={$t(){if(!I(so))return so;if(so=!1,s)try{const t=`__ph_cookie_support_${Qr()}`;no.At(t,"xyz"),so='"xyz"'===Wr(t),no.Pt(t)}catch(t){so=!1}return so},Ft(t){Us.error("cookieStore error: "+t)},Ot:Wr,Lt(t){let i;try{i=JSON.parse(no.Ot(t))||{}}catch(t){}return i},At(t,i,e,n,r){if(!s)return!1;try{let o="",l="";const a=function(t,i){if(i){let i=function(t,i=s){if(io)return io;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";const e=t.split(".");let n=Math.min(e.length,8);const r="dmn_chk_"+Qr();for(;!io&&n--;){const t=e.slice(n).join("."),s=r+"=1;domain=."+t+";path=/";i.cookie=s+";max-age=3",i.cookie.includes(r)&&(i.cookie=s+";max-age=0",io=t)}return io}(t);if(!i){const e=(t=>{const i=t.match(eo);return i?i[0]:""})(t);e!==i&&Us.info("Warning: cookie subdomain discovery mismatch",e,i),i=e}return i?"; domain=."+i:""}return""}(s.location.hostname,n);if(e){const t=new Date;t.setTime(t.getTime()+864e5*e),o="; expires="+t.toUTCString()}r&&(l="; secure");const u=t+"="+encodeURIComponent(JSON.stringify(i))+o+"; SameSite=Lax; path=/"+a+l;return u.length>3686.4&&Us.warn("cookieStore warning: large cookie, len="+u.length),s.cookie=u,!0}catch(t){return!1}},Pt(t,i){if((null==s?void 0:s.cookie)&&(!i||!I(Wr(t))))try{no.At(t,"",-1,i)}catch(t){return}}};let ro=null;const oo={$t(){if(!I(ro))return ro;let i=!0;if(R(t))i=!1;else try{const t="__mplssupport__";oo.At(t,"xyz"),'"xyz"'!==oo.Ot(t)&&(i=!1),oo.Pt(t)}catch(t){i=!1}return i||Us.error("localStorage unsupported; falling back to cookie store"),ro=i,i},Ft(t){Us.error("localStorage error: "+t)},Ot(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){oo.Ft(t)}return null},Lt(t){try{return JSON.parse(oo.Ot(t))||{}}catch(t){}return null},At(i,e){try{return null==t||t.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){oo.Ft(t)}return!1},Pt(i){try{null==t||t.localStorage.removeItem(i)}catch(t){oo.Ft(t)}}},lo=[hn,en,an,sn,vn,on,rn,nn,dn],ao=[yn,mn,Vn,Wn,cr,dr,xn,or],uo=t=>t+"_cpm",ho=["__proto__","constructor","prototype"],co=t=>{if(!P(t))return{};const i={};return Object.keys(t).forEach(e=>{-1===ho.indexOf(e)&&(i[e]=t[e])}),i},vo=(t,i=[])=>{const e={};return[...ao,...i].forEach(i=>{const s=t[i];R(s)||I(s)||""===s||(e[i]=s)}),e},fo=t=>{let i=5381,e=2166136261;for(let s=0;t.length>s;s++){const n=t.charCodeAt(s);i=33*i^n,e=Math.imul(e^n,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},po=(t,i)=>({p:i,f:fo(JSON.stringify(t))}),_o=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{const e=no.Lt(uo(t)),s=(null==e?void 0:e.f)===fo(i)&&k(e.p);return{properties:s?e.p:[],isValid:s}}catch(t){return{properties:[],isValid:!1}}},go=(t,i)=>i+"|"+(no.Ot(uo(t))||""),mo={},yo={$t:()=>!0,Ft(t){Us.error("memoryStorage error: "+t)},Ot:t=>t in mo?mo[t]:null,Lt:t=>t in mo?mo[t]:null,At:(t,i)=>(mo[t]=i,!0),Pt(t){delete mo[t]}};let bo=null;const wo={$t(){if(!I(bo))return bo;if(bo=!0,R(t))bo=!1;else try{const t="__support__";wo.At(t,"xyz"),'"xyz"'!==wo.Ot(t)&&(bo=!1),wo.Pt(t)}catch(t){bo=!1}return bo},Ft(t){Us.error("sessionStorage error: ",t)},Ot(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){wo.Ft(t)}return null},Lt(t){try{return JSON.parse(wo.Ot(t))||null}catch(t){}return null},At(i,e){try{return null==t||t.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){wo.Ft(t)}return!1},Pt(i){try{null==t||t.sessionStorage.removeItem(i)}catch(t){wo.Ft(t)}}};var $o=class{constructor(t){this._instance=t}get Ar(){return this._instance.config}get consent(){return this.bl()?0:this._l}isOptedOut(){return"always"===this.Ar.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Ar.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Ar.opt_out_capturing_by_default}optInOut(t){this.wl.At(this.kl,t?1:0,this.Ar.cookie_expiration,this.Ar.cross_subdomain_cookie,this.Ar.secure_cookie)}reset(){this.wl.Pt(this.kl,this.Ar.cross_subdomain_cookie)}get kl(){const{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get _l(){const t=this.wl.Ot(this.kl);return W(t)?1:m(G,t)?0:-1}get wl(){const t=this.Ar.opt_out_capturing_persistence_type,i="localStorage"===t?oo:no,e=i.$t()?i:yo;if(!this.Sl||this.Sl!==e){this.Sl=e;const i="localStorage"===t?no:oo;i.Ot(this.kl)&&(this.Sl.Ot(this.kl)||this.optInOut(W(i.Ot(this.kl))),i.Pt(this.kl,this.Ar.cross_subdomain_cookie))}return this.Sl}bl(){return!!this.Ar.respect_dnt&&[null==e?void 0:e.doNotTrack,null==e?void 0:e.msDoNotTrack,d.doNotTrack,null==e?void 0:e.globalPrivacyControl].some(t=>W(t))}};function So(t,i){var e;const s=null==t||null===(e=t.config)||void 0===e?void 0:e.get_current_url;if(!T(s))return i;try{const t=s(i);return O(t)&&t?t:i}catch(t){return Us.error("Error in get_current_url, falling back to window.location.href",t),i}}function xo(t){var i;return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!!(null===(i=t.closest)||void 0===i?void 0:i.call(t,".toolbar-global-fade-container")))}function Eo(t){return!!t&&1===t.nodeType}function ko(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function To(t){return!!t&&3===t.nodeType}function Po(t){return!!t&&11===t.nodeType&&Eo(t.host)}function Co(t){return t?y(t).split(/\s+/):[]}function Ro(t,i){const e=function(t){var i;const e="u">typeof window?null===(i=window.location)||void 0===i?void 0:i.href:void 0;return R(e)?void 0:So(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Oo(t){let i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return Co(i)}function Ao(t){return F(t)?null:y(t).split(/(\s+)/).filter(t=>al(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Io(t){let i="";return Qo(t)&&!tl(t)&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,function(t){var e;To(t)&&t.textContent&&(i+=null!==(e=Ao(t.textContent))&&void 0!==e?e:"")}),y(i)}function Fo(t){var i;return R(t.target)?t.srcElement||null:(null===(i=t.target)||void 0===i?void 0:i.shadowRoot)?t.composedPath()[0]||null:t.target||null}const Mo=["a","button","form","input","select","textarea","label"];function Do(t,i){const e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function No(t,i){if(R(i))return!0;for(const e of t)if(i.some(t=>Do(e,t)))return!0;return!1}function jo(t){const i=t.parentNode;return!(!i||!Eo(i))&&i}const Lo=[".ph-no-autocapture","[data-ph-no-autocapture]"],Uo=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Bo=[...Uo,"+","-","−","–"],zo=Bo.length+10,Ho=["button","a","input","select","textarea","label"],qo=["button","link","tab","menuitem","option"],Vo=(t,i)=>/[a-z0-9]/i.test(i)?m(Bo,i)?new RegExp(`\\b${i}\\b`).test(t):t.includes(i):t===i,Wo=t=>m(Ho,t.tagName.toLowerCase())||m(qo,(t.getAttribute("role")||"").toLowerCase());function Go(t){let i="",e="";const s=t=>{Eo(t)&&Qo(t)&&!tl(t)&&(i+=` ${Io(t)}`,e=e||t.getAttribute("aria-label")||"",Dr(t.childNodes,s))};s(t),i=y(i.replace(/\s+/g," "));const n=(al(i)?i:"").toLowerCase(),r=t.getAttribute("aria-label")||(n?"":e);return{safeText:n,ariaLabel:y(r).toLowerCase()}}const Ko=[".ph-no-rageclick",".ph-no-capture"],Jo=["","text","search","email","password","url","tel","number"];function Yo(t,i){if(typeof window>"u"||Zo(t))return!1;let e,s,n;var r,o;if(N(i)?(e=!!i&&Ko,s=void 0,n=!1):(e=null!==(r=null==i?void 0:i.css_selector_ignorelist)&&void 0!==r?r:Ko,s=null==i?void 0:i.content_ignorelist,n=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(n&&function(t){return!(!t||!Eo(t))&&(!!ko(t,"textarea")||(ko(t,"input")?m(Jo,(t.getAttribute("type")||"").toLowerCase()):function(t){var i;if(t.isContentEditable)return!0;const e=null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"contenteditable");return"true"===e||""===e}(t)))}(t))return!1;const{targetElementList:l}=Xo(t,!1);return!(s&&function(t,{safeText:i,ariaLabel:e}){let s;if(!0===t)s=Uo;else{if(!k(t))return!1;if(t.length>zo)return Us.error(`[PostHog] content_ignorelist array cannot exceed ${zo} items. Use css_selector_ignorelist for more complex matching.`),!1;s=t.map(t=>t.toLowerCase())}return s.some(t=>Vo(i,t)||Vo(e,t))}(s,function(t,i){for(const t of i)if(Wo(t))return Go(t);for(const t of i){try{var e;if("pointer"!==(null===(e=window)||void 0===e?void 0:e.getComputedStyle(t).getPropertyValue("cursor")))break}catch(t){break}const i=Go(t);if(i.safeText||i.ariaLabel)return i}return Go(t)}(t,l))||No(l,e))}const Zo=t=>!t||ko(t,"html")||!Eo(t),Xo=(t,i)=>{if(typeof window>"u"||Zo(t))return{parentIsUsefulElement:!1,targetElementList:[]};let e=!1;const s=[t];let n=t;for(;n.parentNode&&!ko(n,"body");){if(Po(n.parentNode)){s.push(n.parentNode.host),n=n.parentNode.host;continue}const t=jo(n);if(!t)break;if(i||Mo.indexOf(t.tagName.toLowerCase())>-1)e=!0;else try{const i=window.getComputedStyle(t);i&&"pointer"===i.getPropertyValue("cursor")&&(e=!0)}catch(t){}s.push(t),n=t}return{parentIsUsefulElement:e,targetElementList:s}};function Qo(t){const i=new Set;let e=0;for(let s=t;s.parentNode&&!ko(s,"body");s=s.parentNode){if(e++>=1e3||i.has(s))return!1;i.add(s);const t=Oo(s);if(m(t,"ph-sensitive")||m(t,"ph-no-capture"))return!1}if(m(Oo(t),"ph-include"))return!0;const s=t.type||"";if(O(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=t.name||t.id||"";return!O(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function tl(t){return!!(ko(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ko(t,"select")||ko(t,"textarea")||"true"===t.getAttribute("contenteditable"))}const il=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),el=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,sl=[16,15,14,13],nl=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),rl=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ol=/[0-9A-Za-z_]/;function ll(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function al(t,i=!0){if(F(t))return!1;if(O(t)){if(t=y(t),i?il.test((t||"").replace(/[- ]/g,"")):function(t){let i;for(el.lastIndex=0;i=el.exec(t);){const t=i[2];if(!t)continue;const e=t.replace(/[- ]/g,"");for(let t=0;e.length>t;t++)for(const i of sl){const s=t+i;if(e.length>=s){const i=e.slice(t,s);if(il.test(i)&&ll(i))return!0}}}return!1}(t))return!1;if(i?nl.test(t):function(t){let i;for(rl.lastIndex=0;i=rl.exec(t);){const t=i[1],e=i[3];if(!(t&&e&&ol.test(t)&&ol.test(e)))return!0}return!1}(t))return!1}return!0}function ul(t){let i=Io(t);return i=`${i} ${hl(t)}`.trim(),al(i)?i:""}function hl(t){let i="";return t&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,function(t){var e;if(t&&"span"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()))try{const e=Io(t);i=`${i} ${e}`.trim(),t.childNodes&&t.childNodes.length&&(i=`${i} ${hl(t)}`.trim())}catch(t){Us.error("[AutoCapture]",t)}}),i}function dl(t){return t.replace(/"|\\"/g,'\\"')}function cl(t){const i=t.attr__class;if(i)return k(i)?i:Co(i)}const vl=Bs("[Dead Clicks]"),fl=()=>!0,pl=t=>{var i;const e=!!(null===(i=t.instance.persistence)||void 0===i?void 0:i.get_property(Fn)),s=t.instance.config.capture_dead_clicks;return N(s)?s:!!P(s)||e};var _l=class{get lazyLoadedDeadClicksAutocapture(){return this.xl}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[Fn]:i.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.$l(()=>{this.Cl()}):this.stop()}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.initDeadClicksAutocapture)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this.instance,"dead-clicks-autocapture",i=>{i?vl.error("failed to load script",i):t()})}Cl(){var t;if(s){if(!this.xl&&(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)){const t=P(this.instance.config.capture_dead_clicks)?wi({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.xl=d.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.xl.start(s),vl.info("starting...")}}else vl.error("`document` not found. Cannot start.")}stop(){this.xl&&(this.xl.stop(),this.xl=void 0,vl.info("stopping..."))}};const gl=Bs("[SegmentIntegration]");function ml(t,i,e=!0){const s=t.config.segment;if(!s)return i();const{analytics:n,filterProperties:r}=(t=>T(t.register))(o=s)?{analytics:o}:o;var o;!function(t,i,e,s){const n=i=>{const n=()=>i.anonymousId()||Qr();t.config.get_device_id=n,s&&i.id()&&(t.register({distinct_id:i.id(),$device_id:n()}),t.persistence.set_property(or,Pr)),e(s?void 0:i.anonymousId()||void 0)},r=i.user();"then"in r&&T(r.then)?r.then(n):n(r)}(t,n,e=>{n.register(((t,i,{filterProperties:e}={})=>{"undefined"!=typeof Promise&&Promise.resolve||gl.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!i&&s.event.anonymousId===i&&!s.event.userId;r||s.event.userId||s.event.anonymousId===t.get_distinct_id()||(gl.info("No userId set, resetting PostHog"),t.reset()),r||(i=void 0),s.event.userId&&s.event.userId!==t.get_distinct_id()&&(gl.info("UserId set, identifying with PostHog"),t.identify(s.event.userId));let o=t.calculateEventProperties(n,s.event.properties);if(!F(e)){const t=s.event.properties||{},i={};for(const e of Object.keys(o))x.call(t,e)||(i[e]=o[e]);const n=((t,i)=>{const e=k(t)?t:[t];let s=wi({},i);for(const t of e)try{if(s=t(s),F(s))return null}catch(t){return gl.error("Error in Segment filterProperties:",t),null}return s})(e,i);if(F(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return s(t,t.event.event)},page(t){return s(t,Or)},identify(t){return s(t,Ir)},screen(t){return s(t,"$screen")}}})(t,e,{filterProperties:r})).then(()=>{i()},t=>{gl.error("Failed to register the Segment integration",t),i()})},e)}const yl="posthog-js";function bl(t,{organization:i,projectId:e,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var l,a,u,h,d;if("*"!==n&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});const c=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=c,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const v=(null===(l=o.exception)||void 0===l?void 0:l.values)||[],f=v.map(t=>wi(wi({},t),{},{stacktrace:t.stacktrace?wi(wi({},t.stacktrace),{},{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>wi(wi({},t),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:(null===(a=v[0])||void 0===a?void 0:a.value)||o.message,$exception_type:null===(u=v[0])||void 0===u?void 0:u.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(h=v[0])||void 0===h?void 0:h.value)||o.message,$sentry_exception_type:null===(d=v[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var _;return i&&e&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+e+"&query="+o.event_id),r&&(null===(_=t.exceptions)||void 0===_||_.sendExceptionEvent(p)),o}}var wl=class{constructor(t,i,e,s,n,r){this.name=yl,this.setupOnce=function(o){o(bl(t,{organization:i,projectId:e,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},$l=class{constructor(t){this.Tl=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(Us.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Il=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Ml()}Ml(){var t;this.El=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.onSessionId(this.Tl)}destroy(){var t;null===(t=this.El)||void 0===t||t.call(this),this.El=void 0}doPageView(i,e){var s;const n=this.Pl(i,e);return this.Il={pathname:null!==(s=null==t?void 0:t.location.pathname)&&void 0!==s?s:"",pageViewId:e,timestamp:i},this._instance.scrollManager.resetContext(),n}doPageLeave(t){var i;return this.Pl(t,null===(i=this.Il)||void 0===i?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null===(t=this.Il)||void 0===t?void 0:t.pageViewId}}Pl(t,i){const e=this.Il;if(!e)return{$pageview_id:i};let s={$pageview_id:i,$prev_pageview_id:e.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:t,lastScrollY:i,maxScrollY:e,maxContentHeight:r,lastContentY:o,maxContentY:l}=n;if(!(R(t)||R(i)||R(e)||R(r)||R(o)||R(l))){t=Math.ceil(t),i=Math.ceil(i),e=Math.ceil(e),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l);const n=t>1?Q(i/t,0,1,Us):1,a=t>1?Q(e/t,0,1,Us):1,u=r>1?Q(o/r,0,1,Us):1,h=r>1?Q(l/r,0,1,Us):1;s=Nr(s,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:e,$prev_pageview_max_scroll_percentage:a,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:u,$prev_pageview_max_content:l,$prev_pageview_max_content_percentage:h})}}return e.pathname&&(s.$prev_pageview_pathname=e.pathname),e.timestamp&&(s.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),s}};const Sl=["flags","surveys"],xl={[gn]:{exposure:"hidden"},[wn]:{exposure:"hidden"},[$n]:{exposure:"hidden"},[Tn]:{exposure:"hidden"},[xn]:{exposure:"hidden"},[kn]:{exposure:"hidden"},[Pn]:{exposure:"event"},[Cn]:{exposure:"hidden"},[Dn]:{exposure:"hidden"},[Rn]:{exposure:"event"},[On]:{exposure:"hidden"},[An]:{exposure:"event"},[In]:{exposure:"event"},[Fn]:{exposure:"event"},[Mn]:{exposure:"hidden"},[Nn]:{exposure:"event"},[jn]:{exposure:"hidden"},[Ln]:{exposure:"hidden"},[Vn]:{exposure:"hidden"},[Wn]:{exposure:"event"},[Un]:{exposure:"event",shouldSkipFromEventProperties:t=>I(t)},[Gn]:{exposure:"event"},[Kn]:{exposure:"event"},[Jn]:{exposure:"event"},[Yn]:{exposure:"event"},[Zn]:{exposure:"hidden"},[an]:{exposure:"hidden",storageGroup:"flags"},[en]:{exposure:"hidden",storageGroup:"flags"},[tn]:{exposure:"hidden"},[sn]:{exposure:"hidden",storageGroup:"flags"},[vn]:{exposure:"hidden",storageGroup:"flags"},[on]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ln]:{exposure:"hidden",storageGroup:"flags"},[fn]:{exposure:"hidden"},[pn]:{exposure:"hidden"},[hn]:{exposure:"hidden"},[un]:{exposure:"hidden"},[Ks]:{exposure:"hidden",storageGroup:"surveys"},[Js]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Zs]:{exposure:"event"},[Xs]:{exposure:"hidden"},[Qs]:{exposure:"hidden"},[Qn]:{exposure:"hidden"},[tr]:{exposure:"hidden"},[ir]:{exposure:"hidden"},[er]:{exposure:"event"},[sr]:{exposure:"event"},[nr]:{exposure:"event"},[rr]:{exposure:"event"},[dn]:{exposure:"hidden"},[cn]:{exposure:"hidden"},[Xn]:{exposure:"event"},[nn]:{exposure:"hidden"},[rn]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[or]:{exposure:"hidden"},[lr]:{exposure:"hidden"},[ar]:{exposure:"hidden"},[ur]:{exposure:"hidden"},[hr]:{exposure:"hidden"},[dr]:{exposure:"hidden"},[cr]:{exposure:"hidden"},[Bn]:{exposure:"event"},[zn]:{exposure:"event"},[Hn]:{exposure:"event"},[qn]:{exposure:"event"},[pr]:{exposure:"event"},[_r]:{exposure:"event"},[gr]:{exposure:"hidden"},[mr]:{exposure:"hidden"},[yr]:{exposure:"hidden"},[br]:{exposure:"hidden"},[wr]:{exposure:"hidden"},[$r]:{exposure:"hidden"},[Sr]:{exposure:"hidden"},[xr]:{exposure:"hidden"},[Er]:{exposure:"hidden"},[kr]:{exposure:"event"}},El=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],kl=t=>{const i=xl[t];if(i)return i;for(const[i,e]of El)if(0===t.indexOf(i))return e};function Tl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}const Pl=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},Cl=(t,i)=>t>=i&&Pl(),Rl=(t,i,e,s)=>{if(0===t){if(Pl()){const t=i+1;return t===e&&s(),t}return i}return 0},Ol=(t,i)=>{try{let e;return JSON.stringify(t,(t,i)=>{var s;return z(i)?(null!==(s=e)&&void 0!==s||(e=new WeakMap),e.has(i)||e.set(i,Br(i)),e.get(i)):"bigint"==typeof i?i.toString():i},i)}catch(i){return w(t)}},Al=t=>{const i=null==s?void 0:s.createElement("a");return R(i)?null:(i.href=t,i)},Il=function(t,i){const e=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let t=0;e.length>t;t++){const n=e[t].split("=");if(n[0]===i){s=n;break}}if(!k(s)||2>s.length)return"";{let t=s[1];try{t=decodeURIComponent(t)}catch(i){Us.error("Skipping decoding for malformed query param: "+t)}return t.replace(/\+/g," ")}},Fl=function(t,i,e){if(!t||!i||!i.length)return t;const s=t.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],l=r[0],a=(o||"").split("&"),u=[];for(let t=0;a.length>t;t++){const s=a[t].split("=");k(s)&&(i.includes(s[0])?u.push(s[0]+"="+e):u.push(a[t]))}let h=l;return null!=o&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},Ml=function(t,i){const e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Dl=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Nl=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Dl],jl="<masked>",Ll=["li_fat_id"];function Ul(t,i,e){if(!s)return{};const n=i?[...Dl,...e||[]]:[],r=Bl(Fl(s.URL,n,jl),t),o=function(){const t={};return Dr(Ll,function(i){const e=Wr(i);t[i]=e||null}),t}();return Nr(o,r)}function Bl(t,i){const e=Nl.concat(i||[]),s={};return Dr(e,function(i){const e=Il(t,i);s[i]=e||null}),s}function zl(t){const i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",n={};if(!I(i)){n.$search_engine=i;const t=s?Il(s.referrer,e):"";t.length&&(n.ph_keyword=t)}return n}function Hl(){return navigator.language||navigator.userLanguage}function ql(){const t=Hl();return"string"==typeof t?t.split("-")[0]:void 0}const Vl="$direct";function Wl(){return(null==s?void 0:s.referrer)||Vl}function Gl(t,i,e=!1){const s=t?[...Dl,...i||[]]:[],r=e?vi(null==n?void 0:n.href):null==n?void 0:n.href,o=null==r?void 0:r.substring(0,1e3);return{r:Wl().substring(0,1e3),u:o?Fl(o,s,jl):void 0}}function Kl(t,i=!1){var e;const{r:s,u:n}=t,r=i?vi(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Vl?Vl:null===(e=Al(s))||void 0===e?void 0:e.host};if(r){o.$current_url=r;const t=Al(r);o.$host=null==t?void 0:t.host,o.$pathname=null==t?void 0:t.pathname;const i=Bl(r);Nr(o,i)}if(s){const t=zl(s);Nr(o,t)}return o}function Jl(){try{return(new Date).getTimezoneOffset()}catch(t){return}}const Yl={flags:rn,surveys:Js},Zl=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Xl=t=>`${t}_cookie_identity_change_pending`,Ql=t=>{let i="",e=0;for(const s of t){const t=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(e+t>1e3)break;i+=s,e+=t}return i},ta="main",ia=[an,en,sn,vn,on,rn,ln,hn],ea=t=>-1!==ia.indexOf(t),sa=[xn,kn],na=t=>-1!==sa.indexOf(t),ra=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},oa=t=>{if(!t)return{};const i=JSON.parse(t);return P(i)?i:{}},la=(t,i)=>{Dr(t,(e,s)=>{const n=kl(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(i,s)||delete t[s]})};var aa=class{constructor(i,e,s=!0,n=!i.cookieless_mode){if(this.Rl={},this.Al=!1,this.Fl=!1,this.Ol=!1,this.Dl=!1,this.Ll=!1,this.Nl=new Map,this.ql=!1,this.jl=!1,this.Bl=!1,this.zl=new Set,this.Hl=new Set,this.Ar=i,this.Ul=s,this.props={},this.Wl=void 0,this.Vl=(t=>{let i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(i),this.hi=i.disable_persistence||!!e,this.wl=this.Gl(i),this.Ol=this.Ql(i),this.load(n),this.Zl(),i.debug&&Us.info("Persistence loaded",i.persistence,wi({},this.props)),this.update_config(i,i,e),this.save(),t){const i=()=>this.flush();qr(t,"beforeunload",i,{capture:!1}),qr(t,"pagehide",i,{capture:!1}),this.Jl=i=>{if(this.Al&&(!i.storageArea||i.storageArea===(null==t?void 0:t.localStorage))&&i.key)if(i.key!==this.Vl){if(this.Ol){const t=Sl.find(t=>i.key===this.Kl(t));t&&this.Xl(i.key,t)}}else this.Xl(i.key,ta)},qr(t,"storage",this.Jl)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([t,i])=>{const e=this.Nl.get(t);if(!ea(t)||!0===e)return;if(!0===i)return void this.Yl(t,!0);const s=new Set(e||[]);i.forEach(t=>s.add(t)),s.size&&this.Yl(t,s)})}onCrossTabFeatureFlagChange(t){return this.Hl.add(t),()=>this.Hl.delete(t)}destroy(){this.Jl&&t&&(t.removeEventListener("storage",this.Jl),this.Jl=void 0),this.Hl.clear()}Xl(t,i,e=!0){if(this.hi)return!1;let s,n;try{if(n=oo.Ot(t),I(n)){const t=this.tu(i);return t.storageValue=null,i!==ta&&(t.persisted=!1),!1}s=oa(n)}catch(t){return!1}const r=i===ta?s:oo.Lt(this.Vl);if(r&&this.eu(r))return!1;const o=this.iu(s,i,e);return i===ta&&this.Ol&&!ra(this.nu().main,s)||this.su(s,i,!0,n),o}eu(t){const i=this.props[mn],e=t[mn];return!R(i)&&!R(e)&&i!==e}su(t,i,e,s){const n=this.tu(i);n.storageValue=s,i!==ta&&(n.persisted=e);try{n.fingerprint=this.ru(t,i)}catch(t){n.fingerprint=void 0}}iu(t,i,e){let s=!1;return ia.forEach(e=>{var n;const r=null===(n=kl(e))||void 0===n?void 0:n.storageGroup;if(i===ta&&this.Ol&&r||i!==ta&&r!==i)return;const o=e in t,l=this.ou(e,o?t[e]:void 0),a=this.Nl.has(e)?e in this.props:o;a===e in this.props&&ra(l,this.props[e])||(a?this.au(e,l,!1):this.lu(e,!1),s=!0)}),s&&e&&this.Hl.forEach(t=>t()),s}uu(){if(!this.Al)return!1;try{this.Bl=!1;const t=oo.Ot(this.Vl),i=this.tu(ta);let e,s=!1,n=!1;if(t!==i.storageValue)if(I(t))i.storageValue=null;else{if(e=oa(t),this.Bl=!this.jl&&this.eu(e),this.Bl)return!1;n=this.iu(e,ta,!1),!this.Ol||ra(this.nu().main,e)?this.su(e,ta,!0,t):i.storageValue=t,s=!0}return this.Ol&&Sl.forEach(t=>{const i=oo.Ot(this.Kl(t)),r=this.tu(t),o=e||{},l=s&&ia.some(i=>{var e;return(null===(e=kl(i))||void 0===e?void 0:e.storageGroup)===t&&i in o});if(i===r.storageValue&&!l)return;if(I(i))return r.storageValue=null,r.persisted=!1,void(l&&(n=this.iu(o,t,!1)||n));const a=oa(i);n=this.iu(a,t,!1)||n,this.su(a,t,!0,i)}),n}catch(t){return!1}}Yl(t,i){this.Nl.set(t,i);const e=kl(t);(null==e?void 0:e.volatile)||(this.tu((this.Ol?null==e?void 0:e.storageGroup:void 0)||ta).fingerprint=void 0,this.cu(t))}hu(){ia.forEach(t=>this.Nl.set(t,!0))}Zl(){if(this.Al)try{const t=oo.Ot(this.Vl),i=oa(t);this.tu(ta).storageValue=t,ia.forEach(t=>{var e;const s=this.Ol?null===(e=kl(t))||void 0===e?void 0:e.storageGroup:void 0,n=s?oo.Ot(this.Kl(s)):null;if(s){const t=this.tu(s);t.storageValue=n,t.persisted=!I(n)}const r=s&&!I(n)?oa(n):i;t in this.props?this.du(t,r[t],this.props[t]):t in r&&this.Yl(t,!0)})}catch(t){}}ou(t,i){const e=this.Nl.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){const s=new Set(k(i)?i:[]),n=new Set(k(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}const s=P(i)?wi({},i):{},n=P(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in n?s[t]=n[t]:delete s[t]}),s}du(t,i,e){if(!ea(t))return;const s=this.Nl.get(t);if(!0===s)return;let n=i;if(this.Al)try{var r;const i=this.Ol?null===(r=kl(t))||void 0===r?void 0:r.storageGroup:void 0,e=i?this.Kl(i):this.Vl;n=oa(oo.Ot(e))[t]}catch(t){}const o=new Set(s||[]);if("$active_feature_flags"===t){if(!R(i)&&!k(i)||!R(n)&&!k(n)||!k(e))return void this.Yl(t,!0);const s=new Set(i||[]),r=new Set(n||[]),l=new Set(e);new Set([...s,...l]).forEach(t=>{s.has(t)!==l.has(t)&&o.add(t)}),o.forEach(t=>{r.has(t)===l.has(t)&&o.delete(t)})}else{if(!P(e))return void(ra(n,e)?this.Nl.delete(t):this.Yl(t,!0));{if(!R(i)&&!P(i)||R(i)&&C(e)&&R(n))return void this.Yl(t,!0);const s=P(i)?i:{},r=P(n)?n:{};new Set([...Object.keys(s),...Object.keys(e)]).forEach(t=>{t in s==t in e&&ra(s[t],e[t])||o.add(t)}),o.forEach(t=>{t in r==t in e&&ra(r[t],e[t])&&o.delete(t)})}}o.size?this.Yl(t,o):this.Nl.delete(t)}vu(){var t;const i=null===(t=this.Ar)||void 0===t?void 0:t.persistence_save_debounce_ms;return M(i)&&i>0?i:0}fu(t){if(this.Ar.cookieWinsOnConflict&&"localstorage+cookie"===this.Ar.persistence.toLowerCase())if(t)try{const i=vo(t,this.Ar.cookie_persisted_properties||[]),e=po(i,this.Ar.cookie_persisted_properties||[]),s=JSON.stringify(i)+"|"+JSON.stringify(e),n=no.Ot(this.Vl)||void 0;n&&go(this.Vl,n)===s&&(this.pu=s,this.gu=n)}catch(t){}else try{const t=no.Ot(this.Vl)||void 0;this.pu=t?go(this.Vl,t):void 0,this.gu=t}catch(t){}}syncCookieProperties(){return this.mu(this.Ar)}mu(t,i=!1){if(this.hi&&!i||this.Ll||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;let e;try{e=no.Ot(this.Vl)||void 0}catch(t){}if(!e||e===this.gu)return!1;const s=go(this.Vl,e);let n;try{n=co(JSON.parse(e))}catch(t){return!1}if((no.Ot(this.Vl)||void 0)!==e)return!1;this.pu=s,this.gu=e;const r=_o(this.Vl,e),o=[...ao,...r.properties],l={};if(Object.keys(n).forEach(t=>{const i=n[t];(R(i)||I(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(l[t]=!0,delete n[t])}),C(n))return!1;const a="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,u=this.props,h=u[mn],d=u[or],c=Nr({},u);[...ao,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==o.indexOf(t)&&!(t in n)&&!l[t]&&(a||"distinct_id"!==t&&"$user_state"!==t)){const i=c[t];(r.isValid||-1===ao.indexOf(t)||!1!==i&&0!==i)&&delete c[t]}}),this.props=Nr(c,n),ia.forEach(t=>{const i=t in this.props;t in u===i&&ra(u[t],this.props[t])||(i?this.du(t,u[t],this.props[t]):this.Yl(t,!0))}),!a||"$user_state"in n||"$user_state"in this.props||this.au(or,Tr);const v=this.props[mn],f=this.props[or];return!a||v===h&&f===d||(this.jl=!0,this.Dl=!0,wo.At(Xl(this.Vl),!0),this.lu(hn),this.lu(en),this.lu(an),this.lu(sn),this.lu(vn),this.lu(on),this.lu(rn),this.lu(nn),this.lu(dn),"anonymous"!==f||"identified"!==d&&"anonymous"!==n.$user_state&&(R(h)||v===h)||(la(this.props,n),this.lu(un)),"identified"===f?this.props.$user_id=v:delete this.props.$user_id,this.lu(wn)),!0}consumeCookieIdentityChange(){const t=Xl(this.Vl),i=this.Dl||!!wo.Ot(t);return this.Dl=!1,i&&wo.Pt(t),i}yu(t=!1){return!(this.Ll||this.hi&&!t||!this.Ar.cookieWinsOnConflict||"localstorage+cookie"!==this.Ar.persistence.toLowerCase()||(this.Ll=!0,0))}bu(){this.Ll&&(R(this._u)||(clearTimeout(this._u),this._u=void 0),delete this.Rl[ta],this.wu(!0))}ku(t=!0){if(this.Ll)try{t?this.bu():R(this._u)||(clearTimeout(this._u),this._u=void 0)}finally{this.Ll=!1}}isDisabled(){return!!this.hi}Gl(i){-1===Zl.indexOf(i.persistence.toLowerCase())&&(Us.critical("Unknown persistence type "+i.persistence+"; falling back to localStorage+cookie"),i.persistence="localStorage+cookie");const e=((i=[],e=!1,s=()=>!1)=>{const n=[...ao,...i];return wi(wi({},oo),{},{Lt(t){try{let r,o={};try{r=no.Ot(t)||void 0,o=r?co(JSON.parse(r)):{}}catch(t){}const l=JSON.parse(oo.Ot(t)||"{}");let a;if(e){const e=_o(t,r),s=[...ao,...e.properties],u={};Object.keys(o).forEach(t=>{const i=o[t];I(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(u[t]=i)});const h="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var i;const t=l[mn],r=null!==(i=l.$user_state)&&void 0!==i?i:Tr;n.forEach(t=>{if(-1!==s.indexOf(t)&&!(t in o)&&(h||"distinct_id"!==t&&"$user_state"!==t)){const i=l[t];(e.isValid||-1===ao.indexOf(t)||!1!==i&&0!==i)&&delete l[t]}}),!h||"$user_state"in o||"$user_state"in l||(l[or]=Tr),!h||("distinct_id"in u?u[mn]:l[mn])===t&&("$user_state"in u?u[or]:l[or])===r||(lo.forEach(t=>delete l[t]),"identified"===u.$user_state&&"distinct_id"in u?l.$user_id=u[mn]:delete l.$user_id,"identified"!==u.$user_state&&(delete l[Xn],delete l[un]),delete l.__alias)}a=Nr(l,u)}else a=Nr(o,l);return s()||oo.At(t,a),a}catch(t){}return null},At(t,s,n,r,o,l){const a=oo.At(t,s,void 0,void 0,l);try{const u=vo(s,i);if(Object.keys(u).length){if(e){const e=uo(t),h=po(u,i);if(no.At(e,h,n,r,o,l),no.Ot(e)!==JSON.stringify(h)){no.Pt(e,r);const i=vo(s);return no.At(t,i,n,r,o,l),a}}no.At(t,u,n,r,o,l)}}catch(t){oo.Ft(t)}return a},Pt(i,e){try{null==t||t.localStorage.removeItem(i),no.Pt(i,e),no.Pt(uo(i),e)}catch(t){oo.Ft(t)}}})})(i.cookie_persisted_properties||[],i.cookieWinsOnConflict,()=>!!this.hi);let s,n=!1,r=!1;const o=i.persistence.toLowerCase();return"localstorage"===o&&oo.$t()?(s=oo,r=!0):"localstorage+cookie"===o&&e.$t()?(s=e,r=!0,n=!0):"sessionstorage"===o&&wo.$t()?s=wo:"memory"===o?s=yo:"cookie"===o&&no.$t()?(s=no,n=!0):e.$t()?(s=e,r=!0,n=!0):no.$t()?(s=no,n=!0):s=yo,this.Al=r,this.Fl=n,s}Kl(t){return`${this.Vl}__${t}`}Ql(t){return this.Al&&!!t.split_storage}properties(){const t={};return Dr(this.props,(i,e)=>{const s=kl(e);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,i))return;t[e]=i}}),t}load(t=!1){if(this.hi&&!t)return;const i=this.Ar.cookieWinsOnConflict&&"localstorage+cookie"===this.Ar.persistence.toLowerCase(),e=i?oo.Lt(this.Vl):null;let s={};if(i)try{s=co(no.Lt(this.Vl)),Dr(s,(t,i)=>{(R(t)||I(t)||""===t)&&delete s[i]})}catch(t){}const n=this.wl.Lt(this.Vl);if(n&&(this.props=Nr({},n)),this.Ol&&this.Su(),i&&n){var r,o;const t=null==e?void 0:e[mn],i=null!==(r=null==e?void 0:e.$user_state)&&void 0!==r?r:Tr,l=n[mn],a=null!==(o=n.$user_state)&&void 0!==o?o:Tr;if(l!==t||a!==i){this.Dl=!0,this.hi||wo.At(Xl(this.Vl),!0);const e=Nr({},this.props);lo.forEach(t=>delete e[t]),"anonymous"!==a||"identified"!==i&&"anonymous"!==s.$user_state&&(R(t)||l===t)||(la(e,s),delete e[un]),this.props=e;const n=new Set;lo.forEach(t=>{var i;const e=null===(i=kl(t))||void 0===i?void 0:i.storageGroup;e&&n.add(e)}),n.forEach(t=>{if(this.hi)return;const i={};Dr(this.props,(e,s)=>{var n;(null===(n=kl(s))||void 0===n?void 0:n.storageGroup)===t&&(i[s]=e)}),C(i)?(oo.Pt(this.Kl(t)),this.Rl[t]={}):oo.At(this.Kl(t),i)&&(this.Rl[t]={persisted:!0,fingerprint:this.ru(i,t)})})}}wo.Ot(Xl(this.Vl))&&(this.Dl=!0)}Su(){for(const t of Sl){const i=oo.Lt(this.Kl(t));if(i&&!C(i)){const e=this.tu(t);e.persisted=!0,this.xu(t)||(e.fingerprint=this.ru(i,t)),this.$u(t,i)||Nr(this.props,i)}}}xu(t){return Object.keys(this.props).some(i=>{var e;return(null===(e=kl(i))||void 0===e?void 0:e.storageGroup)===t})}$u(t,i){const e=Yl[t];if(!e)return!1;const s=i[e],n=this.props[e];return M(s)&&M(n)&&n>s}refreshKey(t){var i;if(this.hi)return;if(this.zl.has(t))return;const e=this.Ol?null===(i=kl(t))||void 0===i?void 0:i.storageGroup:void 0,s=e?oo.Lt(this.Kl(e)):this.wl.Lt(this.Vl);if(s&&t in s)this.au(t,s[t],!1);else{if(e){const i=this.wl.Lt(this.Vl);if(i&&t in i)return void this.au(t,i[t],!1)}this.lu(t,!1)}}save(){if(this.hi)return;const t=this.vu();t>0?R(this._u)&&(this._u=setTimeout(()=>{this._u=void 0,this.wu()},t)):this.wu()}flush(){R(this._u)||(clearTimeout(this._u),this._u=void 0,this.wu())}wu(t=!1){if(this.hi||this.Ll&&!t)return;t||(this.syncCookieProperties(),this.Ar.cookieWinsOnConflict&&"localstorage+cookie"===this.Ar.persistence.toLowerCase()||sa.forEach(t=>this.refreshKey(t)));const i=!t&&!this.ql;i||(this.Bl=!1);const e=!!i&&this.uu();if(this.Bl)return void(this.Ar.debug&&Us.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Ol)return this.Cu(),void(e&&this.Hl.forEach(t=>t()));const s=this.Tu(this.wl,this.Vl,this.props,ta);"written"===s&&this.fu(this.props),"failed"!==s&&(this.Nl.clear(),this.jl=!1,this.zl.clear()),e&&this.Hl.forEach(t=>t())}Cu(){const{main:t,groups:i}=this.nu(),e=this.Tu(this.wl,this.Vl,t,ta);"written"===e&&this.fu(t),"failed"!==e&&(this.jl=!1,this.zl.clear(),ia.forEach(t=>{var i;(null===(i=kl(t))||void 0===i?void 0:i.storageGroup)||this.Nl.delete(t)}));for(const t of Sl){var s;const e=i[t];if(C(e)&&!(null===(s=this.Rl[t])||void 0===s?void 0:s.persisted)){ia.forEach(i=>{var e;(null===(e=kl(i))||void 0===e?void 0:e.storageGroup)===t&&this.Nl.delete(i)});continue}const n=this.Tu(oo,this.Kl(t),e,t);"failed"!==n&&ia.forEach(i=>{const e=kl(i);(null==e?void 0:e.storageGroup)!==t||"written"!==n&&e.volatile||this.Nl.delete(i)})}}nu(){const t={},i={flags:{},surveys:{}};return Dr(this.props,(e,s)=>{var n;const r=null===(n=kl(s))||void 0===n?void 0:n.storageGroup;r?i[r][s]=e:t[s]=e}),{main:t,groups:i}}ru(t,i){if(i===ta)return JSON.stringify(t)+"|"+this.Iu+"|"+this.Mu+"|"+this.Eu;const e={};return Dr(t,(t,i)=>{var s;e[i]=(null===(s=kl(i))||void 0===s?void 0:s.volatile)?"__volatile__":t}),JSON.stringify(e)}Tu(t,i,e,s){const n=this.tu(s);if(s!==ta&&!n.dirty&&!R(n.fingerprint))return"skipped";let r;try{if(r=this.ru(e,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){r=void 0}return t.At(i,e,this.Iu,this.Mu,this.Eu,this.Ar.debug)?(n.dirty=!1,s!==ta&&(n.persisted=!0),R(r)||(n.fingerprint=r),this.Al&&(n.storageValue=oo.Ot(i)),"written"):(this.Ar.debug&&Us.warn(`failed to persist storage entry "${i}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.hu(),R(this._u)||(clearTimeout(this._u),this._u=void 0),this.wl.Pt(this.Vl,!1),this.wl.Pt(this.Vl,!0),!t&&this.Ul)for(const t of Sl)oo.Pt(this.Kl(t));t?delete this.Rl[ta]:this.Rl={},this.pu=void 0,this.gu=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(P(t)){this.syncCookieProperties(),R(i)&&(i="None"),this.Iu=R(e)?this.Pu:e;let s=!1;if(Dr(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.au(e,t),s=!0)}),s)return this.save(),!0}return!1}register(t,i){if(P(t)){this.syncCookieProperties(),this.Iu=R(i)?this.Pu:i;let e=!1;if(Dr(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||P(i)||k(i))&&(this.au(s,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();const i="string"==typeof t?[t]:t;let e=!1;for(const t of i)t in this.props&&(this.lu(t),e=!0);e&&this.save()}update_campaign_params(){const t=null==s?void 0:s.URL;if(t===this.Wl)return;const i=Ul(this.Ar.custom_campaign_params,this.Ar.mask_personal_data_properties,this.Ar.custom_personal_data_properties),e=!C(Ur(i));return e&&this.register(i),this.Wl=t,e?i:void 0}update_search_keyword(){this.register(function(){const t=null==s?void 0:s.referrer;return t?zl(t):{}}())}update_referrer_info(){var t;this.register_once({$referrer:Wl(),$referring_domain:(null==s?void 0:s.referrer)&&(null===(t=Al(s.referrer))||void 0===t?void 0:t.host)||Vl},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const t=Gl(this.Ar.mask_personal_data_properties,this.Ar.custom_personal_data_properties,this.Ar.disable_capture_url_hashes);this.register_once({[dr]:this.Fl?{r:Ql(t.r),u:t.u?Ql(t.u):void 0}:t},void 0)}get_initial_props(){const t={};Dr([hr,ur],i=>{const e=this.props[i];e&&Dr(e,function(i,e){t["$initial_"+b(e)]=i})});const i=this.props[dr];if(i){const e=function(t,i=!1){const e=Kl(t,i),s={};return Dr(e,function(t,i){s[`$initial_${b(i)}`]=t}),s}(i,this.Ar.disable_capture_url_hashes);Nr(t,e)}return t}safe_merge(t){return Dr(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){const s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;const e=[...t].sort(),s=[...i].sort();return e.every((t,i)=>t===s[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),r=s||n,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,a=!!this.hi&&!l;l||this.mu(i,a),this.Ar=t,!l&&(s||n||o)&&(this.pu=void 0,this.gu=void 0,this.mu(wi(wi({},t),{},{cookie_persisted_properties:i.cookie_persisted_properties}),a));const u=r||o?this.Gl(t):this.wl;this.Ru();const h=this.Ql(t),d=r||h!==this.Ol,c=!l&&(d||t.cross_subdomain_cookie!==this.Mu||t.secure_cookie!==this.Eu)&&this.yu(a);this.ql=d;try{if(this.Pu=this.Iu=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){const t=this.props;this.clear(),this.wl=u,this.Ol=h,this.props=t,this.save()}else o&&(this.wl=u,l||(delete this.Rl[ta],this.wu()))}finally{this.ql=!1,c&&this.ku()}}Ru(){const t=this.props[dr];if(!this.Fl||!P(t)||"string"!=typeof t.r)return;const i=Ql(t.r),e="string"==typeof t.u?Ql(t.u):t.u;i===t.r&&e===t.u||this.au(dr,wi(wi({},t),{},{r:i,u:e}))}set_disabled(t){this.hi=t,this.hi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Mu&&(this.Mu=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Eu&&(this.Eu=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){const e=this.props.__timers||{};e[t]=i,this.au(Tn,e),this.save()}remove_event_timer(t){const i=this.props.__timers||{},e=i[t];return R(e)||(delete i[t],this.au(Tn,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.au(t,i),this.save()}au(t,i,e=!0){var s;const n=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||n===i||(this.jl=!0),na(t)&&!ra(n,i)&&this.zl.add(t),this.du(t,n,i),(null===(s=kl(t))||void 0===s?void 0:s.volatile)||this.cu(t))}lu(t,i=!0){delete this.props[t],i&&(ea(t)&&this.Yl(t,!0),na(t)&&this.zl.add(t),this.cu(t))}cu(t){var i;const e=null===(i=kl(t))||void 0===i?void 0:i.storageGroup;e&&(this.tu(e).dirty=!0)}tu(t){return this.Rl[t]||(this.Rl[t]={})}};const ua={GZipJS:"gzip-js",Base64:"base64"},ha={Activation:"events",Cancellation:"cancelEvents"},da={Button:"button",Tab:"tab",Selector:"selector"},ca={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"},va={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},fa={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},pa={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},_a={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ga={Once:"once",Recurring:"recurring",Always:"always"},ma={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},ya={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"},ba={Popover:"popover",Inline:"inline"};function wa(t){let i=!0;return{dispose(){if(i){i=!1;const e=t();e&&T(e.then)&&e.then(void 0,()=>{})}}}}const $a={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},Sa={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"},xa={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"},Ea=Bs("[RateLimiter]");var ka=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{Ea.info(`${t||"events"} is quota limited.`),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void Ea.warn(`could not rate limit - continuing. Error: "${null==t?void 0:t.message}"`,{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var i,e,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),l=null!==(i=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:n,last:o};l.tokens+=Math.max(0,o-l.last)/1e3*r,l.last=Math.max(l.last,o),l.tokens>n&&(l.tokens=n);const a=1>l.tokens;if(a||t||(l.tokens=Math.max(0,l.tokens-1)),a&&!t){const t=(M(l.dropped)?l.dropped:0)+1;l.dropped=t,!this.lastEventRateLimited&&this.Au(t)&&(l.dropped=0)}return this.lastEventRateLimited=a,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",l),{isRateLimited:a,remainingTokens:l.tokens}}Fu(t){const i=this.instance.config.property_denylist;return!k(i)||!i.includes(t)}Ou(){var t;if(this.Fu("$current_url")&&this.Fu("$pathname")&&(null==n?void 0:n.pathname))return`${null!==(t=n.origin)&&void 0!==t?t:""}${n.pathname}`}Au(t){var i,e;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Ou(),o=this.Fu("$session_id")?null===(i=(e=this.instance).get_session_id)||void 0===i?void 0:i.call(e):void 0,l=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${l}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){const i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}};const Ta=Bs("[RemoteConfig]");var Pa=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null===(t=d._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.config}Du(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.loadExternalDependency)?null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Lu(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return Ta.info("Using preloaded remote config",this.remoteConfig),void this.Nu(this.remoteConfig);if(this._instance.qu())return void Ta.warn("Remote config is disabled. Falling back to local config.");this.Du(t=>{if(!t)return Ta.info("No config found after loading remote JS config. Falling back to JSON."),void this.Lu(t=>{this.Nu(t.json,t)});this.Nu(t)})}catch(t){Ta.error("Error loading remote config",t),this.Nu()}}Nu(t,i){!t&&i&&(0===i.statusCode?i.error||Ta.warn("Failed to fetch remote config from PostHog."):Ta.error("Failed to fetch remote config from PostHog."));try{this._instance.Nu(t?{ok:!0,config:t}:{ok:!1})}catch(t){Ta.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null===(e=this._instance.featureFlags)||void 0===e||e.ensureFlagsLoaded()}catch(t){Ta.error("Error loading feature flags",t)}}};const Ca=["fatal","error","warning","log","info","debug"];var Ra=Uint8Array,Oa=Uint16Array,Aa=Uint32Array,Ia=new Ra([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]),Fa=new Ra([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]),Ma=new Ra([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Da=function(t,i){for(var e=new Oa(31),s=0;31>s;++s)e[s]=i+=1<<t[s-1];var n=new Aa(e[30]);for(s=1;30>s;++s)for(var r=e[s];e[s+1]>r;++r)n[r]=r-e[s]<<5|s;return[e,n]},Na=Da(Ia,2),ja=Na[1];Na[0][28]=258,ja[258]=28;for(var La=Da(Fa,0)[1],Ua=new Oa(32768),Ba=0;32768>Ba;++Ba){var za=(43690&Ba)>>>1|(21845&Ba)<<1;Ua[Ba]=((65280&(za=(61680&(za=(52428&za)>>>2|(13107&za)<<2))>>>4|(3855&za)<<4))>>>8|(255&za)<<8)>>>1}var Ha=function(t,i,e){for(var s=t.length,n=0,r=new Oa(i);s>n;++n)++r[t[n]-1];var o,l=new Oa(i);for(n=0;i>n;++n)l[n]=l[n-1]+r[n-1]<<1;if(e){o=new Oa(1<<i);var a=15-i;for(n=0;s>n;++n)if(t[n])for(var u=n<<4|t[n],h=i-t[n],d=l[t[n]-1]++<<h,c=d|(1<<h)-1;c>=d;++d)o[Ua[d]>>>a]=u}else for(o=new Oa(s),n=0;s>n;++n)o[n]=Ua[l[t[n]-1]++]>>>15-t[n];return o},qa=new Ra(288);for(Ba=0;144>Ba;++Ba)qa[Ba]=8;for(Ba=144;256>Ba;++Ba)qa[Ba]=9;for(Ba=256;280>Ba;++Ba)qa[Ba]=7;for(Ba=280;288>Ba;++Ba)qa[Ba]=8;var Va=new Ra(32);for(Ba=0;32>Ba;++Ba)Va[Ba]=5;var Wa=Ha(qa,9,0),Ga=Ha(Va,5,0),Ka=function(t){return(t/8|0)+(7&t&&1)},Ja=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var s=new(t instanceof Oa?Oa:t instanceof Aa?Aa:Ra)(e-i);return s.set(t.subarray(i,e)),s},Ya=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8},Za=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8,t[s+2]|=e>>>16},Xa=function(t,i){for(var e=[],s=0;t.length>s;++s)t[s]&&e.push({s:s,f:t[s]});var n=e.length,r=e.slice();if(!n)return[new Ra(0),0];if(1==n){var o=new Ra(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var l=e[0],a=e[1],u=0,h=1,d=2;for(e[0]={s:-1,f:l.f+a.f,l:l,r:a};h!=n-1;)l=e[e[d].f>e[u].f?u++:d++],a=e[u!=h&&e[d].f>e[u].f?u++:d++],e[h++]={s:-1,f:l.f+a.f,l:l,r:a};var c=r[0].s;for(s=1;n>s;++s)r[s].s>c&&(c=r[s].s);var v=new Oa(c+1),f=Qa(e[h-1],v,0);if(f>i){s=0;var p=0,_=f-i,g=1<<_;for(r.sort(function(t,i){return v[i.s]-v[t.s]||t.f-i.f});n>s;++s){var m=r[s].s;if(i>=v[m])break;p+=g-(1<<f-v[m]),v[m]=i}for(p>>>=_;p>0;){var y=r[s].s;i>v[y]?p-=1<<i-v[y]++-1:++s}for(;s>=0&&p;--s){var b=r[s].s;v[b]==i&&(--v[b],++p)}f=i}return[new Ra(v),f]},Qa=function(t,i,e){return-1==t.s?Math.max(Qa(t.l,i,e+1),Qa(t.r,i,e+1)):i[t.s]=e},tu=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new Oa(++i),s=0,n=t[0],r=1,o=function(t){e[s++]=t},l=1;i>=l;++l)if(t[l]==n&&l!=i)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[l]}return[e.subarray(0,s),i]},iu=function(t,i){for(var e=0,s=0;i.length>s;++s)e+=t[s]*i[s];return e},eu=function(t,i,e){var s=e.length,n=Ka(i+2);t[n]=255&s,t[n+1]=s>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;s>r;++r)t[n+r+4]=e[r];return 8*(n+4+s)},su=function(t,i,e,s,n,r,o,l,a,u,h){Ya(i,h++,e),++n[256];for(var d=Xa(n,15),c=d[0],v=d[1],f=Xa(r,15),p=f[0],_=f[1],g=tu(c),m=g[0],y=g[1],b=tu(p),w=b[0],S=b[1],x=new Oa(19),E=0;m.length>E;++E)x[31&m[E]]++;for(E=0;w.length>E;++E)x[31&w[E]]++;for(var k=Xa(x,7),T=k[0],P=k[1],C=19;C>4&&!T[Ma[C-1]];--C);var R,O,A,I,F=u+5<<3,M=iu(n,qa)+iu(r,Va)+o,D=iu(n,c)+iu(r,p)+o+14+3*C+iu(x,T)+(2*x[16]+3*x[17]+7*x[18]);if(M>=F&&D>=F)return eu(i,h,t.subarray(a,a+u));if(Ya(i,h,1+(M>D)),h+=2,M>D){R=Ha(c,v,0),O=c,A=Ha(p,_,0),I=p;var N=Ha(T,P,0);for(Ya(i,h,y-257),Ya(i,h+5,S-1),Ya(i,h+10,C-4),h+=14,E=0;C>E;++E)Ya(i,h+3*E,T[Ma[E]]);h+=3*C;for(var j=[m,w],L=0;2>L;++L){var U=j[L];for(E=0;U.length>E;++E)Ya(i,h,N[B=31&U[E]]),h+=T[B],B>15&&(Ya(i,h,U[E]>>>5&127),h+=U[E]>>>12)}}else R=Wa,O=qa,A=Ga,I=Va;for(E=0;l>E;++E)if(s[E]>255){var B;Za(i,h,R[257+(B=s[E]>>>18&31)]),h+=O[B+257],B>7&&(Ya(i,h,s[E]>>>23&31),h+=Ia[B]);var z=31&s[E];Za(i,h,A[z]),h+=I[z],z>3&&(Za(i,h,s[E]>>>5&8191),h+=Fa[z])}else Za(i,h,R[s[E]]),h+=O[s[E]];return Za(i,h,R[256]),h+O[256]},nu=new Aa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ru=new Ra(0),ou=function(){for(var t=new Aa(256),i=0;256>i;++i){for(var e=i,s=9;--s;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),lu=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function au(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,s=0;i.length>s;++s)e=ou[255&e^i[s]]^e>>>8;t=e},d(){return 4294967295^t}}}(),s=t.length;e.p(t);var n,r,o,l,a,u,h=(l=10+((n=i).filename&&n.filename.length+1||0),a=8,function(t,i,e,s,n,r){var o=t.length,l=new Ra(s+o+5*(1+Math.floor(o/7e3))+n),a=l.subarray(s,l.length-n),u=0;if(!i||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=eu(a,u,t.subarray(h,d)):(a[h]=r,u=eu(a,u,t.subarray(h,o)))}else{for(var c=nu[i-1],v=c>>>13,f=8191&c,p=(1<<e)-1,_=new Oa(32768),g=new Oa(p+1),m=Math.ceil(e/3),y=2*m,b=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<y)&p},w=new Aa(25e3),S=new Oa(288),x=new Oa(32),E=0,k=0,T=(h=0,0),P=0,C=0;o>h;++h){var R=b(h),O=32767&h,A=g[R];if(_[O]=A,g[R]=O,h>=P){var I=o-h;if((E>7e3||T>24576)&&I>423){u=su(t,a,0,w,S,x,k,T,C,h-C,u),T=E=k=0,C=h;for(var F=0;286>F;++F)S[F]=0;for(F=0;30>F;++F)x[F]=0}var M=2,D=0,N=f,j=O-A&32767;if(I>2&&R==b(h-j))for(var L=Math.min(v,I)-1,U=Math.min(32767,h),B=Math.min(258,I);U>=j&&--N&&O!=A;){if(t[h+M]==t[h+M-j]){for(var z=0;B>z&&t[h+z]==t[h+z-j];++z);if(z>M){if(M=z,D=j,z>L)break;var H=Math.min(j,z-2),q=0;for(F=0;H>F;++F){var V=h-j+F+32768&32767,W=V-_[V]+32768&32767;W>q&&(q=W,A=V)}}}j+=(O=A)-(A=_[O])+32768&32767}if(D){w[T++]=268435456|ja[M]<<18|La[D];var G=31&ja[M],K=31&La[D];k+=Ia[G]+Fa[K],++S[257+G],++x[K],P=h+M,++E}else w[T++]=t[h],++S[t[h]]}}u=su(t,a,r,w,S,x,k,T,C,h-C,u),r||(u=eu(a,u,ru))}return Ja(l,0,s+Ka(u)+n)}(r=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,l,a,!u)),d=h.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&lu(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var s=0;e.length>=s;++s)t[s+10]=e.charCodeAt(s)}}(h,i),lu(h,d-8,e.d()),lu(h,d-4,s),h}const uu=!!o||!!r,hu=new WeakMap,du="text/plain";let cu=0,vu=!1;const fu=(t,i)=>{const[e,s]=t.split("#"),[n,r]=e.split("?");if(!r)return t;const o=r.split("&").filter(t=>t.split("=")[0]!==i).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},pu=(t,i,e=!0)=>{var s;const[n,r]=t.split("?"),o=wi({},i),l=null!==(s=null==r?void 0:r.split("&").map(t=>{var i;const[s,n]=t.split("="),r=e&&null!==(i=o[s])&&void 0!==i?i:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],a=function(t,i="&"){let e,s;const n=[];return Dr(t,function(t,i){R(t)||R(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),s=encodeURIComponent(i),n[n.length]=s+"="+e)}),n.join(i)}(o);return a&&l.push(a),l.length>0?`${n}?${l.join("&")}`:n},_u=t=>{if(t.lr)return t.lr;const{data:i,compression:e}=t;if(!i)return;if(e===ua.GZipJS){const t=au(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new Ra(t.length+(t.length>>>1)),s=0,n=function(t){e[s++]=t},r=0;i>r;++r){if(s+5>e.length){var o=new Ra(s+8+(i-r<<1));o.set(e),e=o}var l=t.charCodeAt(r);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Ja(e,0,s)}(Ol(i)),{mtime:0});return{contentType:du,body:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),estimatedSize:t.byteLength}}if(e===ua.Base64){const t=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(Ol(i)),e=(t=>"data="+encodeURIComponent("string"==typeof t?t:Ol(t)))(t);return{contentType:"application/x-www-form-urlencoded",body:e,estimatedSize:new Blob([e]).size}}const s=Ol(i);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},gu=t=>{const i=()=>"sendBeacon"===t.transport?{url:pu(t.url,{compression:ua.Base64}),encodedBody:_u(wi(wi({},t),{},{compression:ua.Base64,lr:void 0}))}:{url:fu(t.url,"compression"),encodedBody:_u(wi(wi({},t),{},{compression:void 0,lr:void 0}))};let e;try{e=_u(t)}catch(e){if(ye(t.compression,Il(t.url,"compression")))return Us.error("Failed to gzip request body, sending uncompressed payload",e),i();throw e}return e&&ye(t.compression,Il(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?me(new Uint8Array(s)):ArrayBuffer.isView(s)&&me(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(vu=!0,i()):{url:t.url,encodedBody:e};var s},mu=t=>{try{return gu(t)}catch(e){var i;return Us.error(e),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0,error:e}))}},yu=function(){var t=J(function*(t){const i=yield function(t){return Ee.apply(this,arguments)}(Ol(t.data),Gs.DEBUG,{rethrow:!0});if(!i)return t;const e=yield i.arrayBuffer();return wi(wi({},t),{},{lr:{contentType:du,body:e,estimatedSize:e.byteLength}})});return function(i){return t.apply(this,arguments)}}(),bu=/Failed to fetch|NetworkError|Load failed/i,wu=t=>"TypeError"===(null==t?void 0:t.name)&&bu.test((null==t?void 0:t.message)||""),$u=t=>{try{const i=function(t,i=Date.now()){if("string"!=typeof t||!t)return;const e=t.trim(),s=/^\d+\s*,/.test(e)?e.slice(0,e.indexOf(",")).trim():e;if(/^\d+$/.test(s)){const t=1e3*Math.min(Number(s),300);return t>0?t:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,r=Date.parse(n)-i;return Number.isFinite(r)&&r>0?Math.min(r,ai):void 0}(t());return R(i)?void 0:Math.min(i,3e4)}catch(t){return}},Su=t=>{const i=mu(t);if(!i)return;const e=new o;hu.set(e,!0);const{url:s,encodedBody:n}=i;e.open(t.method||"GET",s,!0);const{contentType:r,body:l}=null!=n?n:{};Dr(t.headers,function(t,i){e.setRequestHeader(i,t)}),r&&e.setRequestHeader("Content-Type",r),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i;const s={statusCode:e.status,text:e.responseText};if(200===e.status)try{s.json=JSON.parse(e.responseText)}catch(t){}null===(i=t.callback)||void 0===i||i.call(t,s,$u(()=>e.getResponseHeader("Retry-After")))}},e.send(l)},xu=t=>{const i=mu(t);if(!i)return;const{url:e,encodedBody:s}=i,{contentType:n,body:o,estimatedSize:a}=null!=s?s:{},u=new Headers;Dr(t.headers,function(t,i){u.append(i,t)}),n&&u.append("Content-Type",n);let h=null,d=!1;if(l){const i=new l;h={signal:i.signal,timeout:setTimeout(()=>{d=!0;try{i.abort(ci("AbortError","PostHog request timed out"+((e=t.timeout)?` after ${e}ms`:"")))}catch(t){v(t)}var e},t.timeout)}}let c=!1;const v=i=>{var e;c||(c=!0,d&&"AbortError"===(null==i?void 0:i.name)||wu(i)?Us.warn(i):Us.error(i),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0,error:i}))};let f=0;const p=()=>{cu-=f,f=0,h&&clearTimeout(h.timeout)};try{const i=wi({method:(null==t?void 0:t.method)||"GET",headers:u,referrerPolicy:"strict-origin",body:o,signal:null==h?void 0:h.signal},t.fetchOptions),s=null!=a?a:R(o)?0:void 0;i.keepalive="POST"===i.method&&!t.Ya&&!1!==i.keepalive&&i.body===o&&!R(s)&&s>=0&&52428.8>cu+s,i.keepalive&&(f=s,cu+=f),r(e,i).then(i=>i.text().then(e=>{var s;if(c)return;const n={statusCode:i.status,text:e};if(200===i.status)try{n.json=JSON.parse(e)}catch(t){Us.error(t)}c=!0,p(),null===(s=t.callback)||void 0===s||s.call(t,n,$u(()=>i.headers.get("Retry-After")))})).catch(t=>{p(),v(t)}).finally(p)}catch(t){p(),v(t)}},Eu=t=>{try{var i;const{url:s,encodedBody:n}=gu(t),{contentType:o,body:l,estimatedSize:a}=null!=n?n:{};if(!l)return;const u=l instanceof Blob?l:new Blob([l],{type:o});if(e.sendBeacon(s,u))return;const h=k(t.data)?t.data:null===(i=t.data)||void 0===i?void 0:i.batch;if(k(h)&&h.length>1&&(null!=a?a:0)>16384){const i=Math.ceil(h.length/2),e=i=>k(t.data)?i:wi(wi({},t.data),{},{batch:i});return Eu(wi(wi({},t),{},{data:e(h.slice(0,i))})),void Eu(wi(wi({},t),{},{data:e(h.slice(i))}))}Us.warn(`Beacon of ~${null!=a?a:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?xu(wi(wi({},t),{},{Ya:!0})):Su(t)}catch(t){Us.warn("Beacon send failed",t)}},ku=(t,i,e,s)=>{const n="query"===s?"POST"===i?"sent_at":"_":void 0;return pu(e===ua.GZipJS?fu(t,"compression"):t,wi(wi({},n?{[n]:Date.now().toString()}:{}),e===ua.GZipJS?{}:{compression:e}))},Tu=(()=>{const t=[];return r&&t.push({transport:"fetch",method:xu}),o&&t.push({transport:"XHR",method:Su}),(null==e?void 0:e.sendBeacon)&&t.push({transport:"sendBeacon",method:Eu}),t})();let Pu=!uu&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla"));function Cu(t,i,e){var s,n,r;e&&(i=wi(wi({},i),{},{callback:t=>e(t)})),t.__loaded?Pu?t.__request_queue.push(i):t.rateLimiter.isServerRateLimited(i.batchKey)?i.fireCallbackOnDrop&&(null===(n=i.callback)||void 0===n||n.call(i,{statusCode:429})):(i.transport=i.transport||t.config.api_transport,i.headers=wi(wi({},t.config.request_headers),i.headers),i.compression="best-available"===i.compression?null!==(s=t.compression)&&void 0!==s?s:i.compressionFallback:i.compression,(R(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(i.disableTransport=["sendBeacon"]),i.fetchOptions=i.fetchOptions||t.config.fetch_options,((t,i)=>{var e,s,n;const r=wi(wi({},t),{},{callback:null!=i?i:i=>{var e;return null===(e=t.callback)||void 0===e?void 0:e.call(t,i)}});r.timeout=r.timeout||6e4;const o=null!==(e=r.transport)&&void 0!==e?e:"fetch";"sendBeacon"===o&&R(r.compression)&&r.data&&(r.compression=ua.Base64),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(t=>{var i,e;const s=(k(t)?t:[t]).map(t=>wi(wi({},t),t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(i=null==n||null===(e=n.properties)||void 0===e?void 0:e.token)&&void 0!==i?i:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((t,i=(new Date).toISOString())=>k(t)?t.map(t=>wi(wi({},t),{},{sent_at:i})):wi(wi({},t),{},{sent_at:i}))(r.data))),r.url=ku(r.url,r.method,r.compression,r.timestampMode);const l=Tu.filter(t=>!r.disableTransport||!t.transport||!r.disableTransport.includes(t.transport)),u=null!==(s=null===(n=function(t,i){for(let e=0;t.length>e;e++)if(i(t[e]))return t[e]}(l,t=>t.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:l[0].method;if(!u)throw new Error("No available transport method");const h=t=>{try{u(t)}catch(t){var i;wu(t)?Us.warn(t):Us.error(t),null===(i=r.callback)||void 0===i||i.call(r,{statusCode:0,error:t})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===ua.GZipJS&&a&&"undefined"!=typeof Promise&&!vu?yu(r).then(t=>{h(t)}).catch(i=>{if(be(i))return vu=!0,void h(wi(wi({},r),{},{compression:void 0,url:ku(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;const i="name"in t?String(t.name):"";return be(t)||i===ge})(i)&&(vu=!0),h(r)}):h(r)})(i,(s,n)=>{var r,o,l;t.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=t.config).on_request_error)||void 0===r||r.call(o,s),e?e(s,n):null===(l=i.callback)||void 0===l||l.call(i,s)})):i.fireCallbackOnDrop&&(null===(r=i.callback)||void 0===r||r.call(i,{statusCode:0}))}var Ru=class{constructor(t,i){this.ju=!0,this.Bu=[],this.zu=Q((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,Us.createLogger("flush interval"),3e3),this.Hu=t}enqueue(t){this.Bu.push(t),this.Uu||this.Wu()}unload(){this.Vu();const t=this.Bu.length>0?this.Gu():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.Qu(wi(wi({},t),{},{callback:void 0}),"sendBeacon")})}enable(){this.ju=!1,this.Wu()}Wu(){this.ju||(this.Uu=setTimeout(()=>{this.Vu(),this.Zu()},this.zu))}Zu(){if(this.Bu.length>0){const t=this.Gu();for(const i in t)this.Qu(t[i])}}Qu(t,i){try{this.Hu(t,i)}catch(t){Us.error(t)}}Vu(){clearTimeout(this.Uu),this.Uu=void 0}Gu(){const t={},i={};Dr(this.Bu,e=>{var s;const n=e,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");R(t[r])&&(t[r]=wi(wi({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),i[r]=[]),null===(s=t[r].data)||void 0===s||s.push(n.data),n.callback&&i[r].push(n.callback)});for(const e in i){const s=i[e];s.length&&(t[e].callback=t=>{for(const i of s)i(t)})}return this.Bu=[],t}};const Ou=["retriesPerformedSoFar"];var Au=class{constructor(t){this._instance=t,this.Ju=!1,this.Ku=3e3,this.Bu=[],this.Bu=[],this.Xu=!0,this.resume()}resume(){if(!R(t)&&"onLine"in t.navigator){if(this.Xu=t.navigator.onLine,this.Yu)return;this.Yu=()=>{this.Xu=!0,this.Zu()},this.tc=()=>{this.Xu=!1},qr(t,"online",this.Yu),qr(t,"offline",this.tc)}}get length(){return this.Bu.length}retriableRequest(t,i){let{retriesPerformedSoFar:e}=t,s=ke(t,Ou);D(e)&&(s.url=pu(s.url,{retry_count:e})),Cu(this._instance,i?wi(wi({},s),{},{transport:i}):s,(t,i)=>{var n;if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.Ls(wi({retriesPerformedSoFar:e},s),i);0===t.statusCode&&Us.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=e?e:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,t)})}Ls(t,i){const e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;const s=Math.max(function(t){const i=3e3*Math.pow(2,t),e=i/2,s=Math.min(18e5,i),n=(Math.random()-.5)*(s-e);return Math.ceil(s+n)}(e),null!=i?i:0),n=Date.now()+s;this.Bu.push({retryAt:n,requestOptions:t});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),Us.warn(r),this.Ju||(this.Ju=!0,this.ec())}ec(){if(this.nc&&clearTimeout(this.nc),0===this.Bu.length)return this.Ju=!1,void(this.nc=void 0);this.nc=setTimeout(()=>{this.Xu&&this.Bu.length>0&&this.Zu(),this.ec()},this.Ku)}Zu(){const t=Date.now(),i=[],e=this.Bu.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.Bu=i,e.length>0)for(const{requestOptions:t}of e)this.retriableRequest(t)}unload(){this.nc&&(clearTimeout(this.nc),this.nc=void 0),this.Ju=!1,R(t)||(this.Yu&&(t.removeEventListener("online",this.Yu),this.Yu=void 0),this.tc&&(t.removeEventListener("offline",this.tc),this.tc=void 0));for(const{requestOptions:t}of this.Bu)try{this._instance._send_request(wi(wi({},t),{},{callback:k(t.data)?void 0:t.callback,transport:"sendBeacon"}))}catch(t){Us.error(t)}this.Bu=[]}},Iu=class{constructor(t){this._instance=t,this.sc=()=>{var t,i,e,s;this.rc||(this.rc={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=r+((null==n?void 0:n.clientHeight)||0),a=(null==n?void 0:n.scrollHeight)||0;this.rc.lastScrollY=Math.ceil(r),this.rc.maxScrollY=Math.max(r,null!==(t=this.rc.maxScrollY)&&void 0!==t?t:0),this.rc.maxScrollHeight=Math.max(o,null!==(i=this.rc.maxScrollHeight)&&void 0!==i?i:0),this.rc.lastContentY=l,this.rc.maxContentY=Math.max(l,null!==(e=this.rc.maxContentY)&&void 0!==e?e:0),this.rc.maxContentHeight=Math.max(a,null!==(s=this.rc.maxContentHeight)&&void 0!==s?s:0)}}get oc(){return this._instance.config.scroll_root_selector}getContext(){return this.rc}resetContext(){const t=this.rc;return this.rc=void 0,setTimeout(this.sc,0),t}startMeasuringScrollPosition(){qr(t,"scroll",this.sc,{capture:!0}),qr(t,"scrollend",this.sc,{capture:!0}),qr(t,"resize",this.sc)}scrollElement(){if(this.oc){const e=k(this.oc)?this.oc:[this.oc];for(const s of e){var i;const e=null==t||null===(i=t.document)||void 0===i?void 0:i.querySelector(s);if(e)return e}return}var e;return null==t||null===(e=t.document)||void 0===e?void 0:e.documentElement}ac(i){var e,s;const n="y"===i?"scrollTop":"scrollLeft";if(this.oc){const t=this.scrollElement();return t&&t[n]||0}return t?"y"===i?t.scrollY||t.pageYOffset||(null===(e=t.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.scrollTop)||0:t.scrollX||t.pageXOffset||(null===(s=t.document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.scrollLeft)||0:0}scrollY(){return this.ac("y")}scrollX(){return this.ac("x")}};const Fu=t=>Gl(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);var Mu=class{constructor(t,i,e,s){this.qe=t=>{const i=this.lc();if(i&&i.sessionId===t)return;const e={sessionId:t,props:this.uc(this._instance)};this.cc.register({[lr]:e})},this._instance=t,this.hc=i,this.cc=e,this.uc=s||Fu,this.hc.onSessionId(this.qe)}lc(){return this.cc.props[lr]}getSetOnceProps(){var t;const i=null===(t=this.lc())||void 0===t?void 0:t.props;return i?"r"in i?Kl(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){const t={};return Dr(Ur(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t[`$session_entry_${b(e)}`]=i}),t}},Du=class{on(t,i){return this.bo[t]||(this.bo[t]=[]),this.bo[t].push(i),()=>{this.bo[t]=this.bo[t].filter(t=>t!==i)}}emit(t,i){for(const e of this.bo[t]||[])e(i);for(const e of this.bo["*"]||[])e(t,i)}constructor(){this.bo={}}};const Nu=Bs("[SessionId]"),ju=864e5;var Lu=class{on(t,i){return this.dc.on(t,i)}constructor(t,i,e){var s;if(this.vc=null,this.fc=null,this.gc=[],this.mc=void 0,this.yc=!1,this.dc=new Du,this.bc=(t,i)=>!(!D(t)||!D(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Ar=t.config,this.cc=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this._c=void 0,this._sessionActivityTimestamp=null,this.wc=i||Qr,this.kc=e||Qr;const n=this.Ar.persistence_name||this.Ar.token;if(this._sessionTimeoutMs=1e3*Q(this.Ar.session_idle_timeout_seconds||1800,60,36e3,Nu.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Sc(),this.xc="ph_"+n+"_window_id",this.$c="ph_"+n+"_primary_window_exists",this.Cc()){const t=wo.Lt(this.xc),i=wo.Lt(this.$c);t&&!i?this.je=t:wo.Pt(this.xc),wo.At(this.$c,!0)}(null===(s=this.Ar.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Ar.bootstrap.sessionID),this.Tc()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return R(this.gc)&&(this.gc=[]),this.gc.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.gc=this.gc.filter(i=>i!==t)}}Cc(){return"memory"!==this.Ar.persistence&&!this.cc.hi&&wo.$t()}Ic(t){t!==this.je&&(this.je=t,this.Cc()&&wo.At(this.xc,t))}Mc(){return this.je?this.je:this.Cc()?wo.Lt(this.xc):null}Ec(t){const i=this.vc;return!I(i)&&!I(t)&&5e3>Math.abs(t-i)}Pc(t,i,e){const s=i!==this._sessionActivityTimestamp,n=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,n&&!s||n&&this.Ec(i)||(this.vc=i,this.cc.register({[Vn]:[i,t,e]}))}Rc(){var t;const i=null===(t=this.Ar)||void 0===t?void 0:t.persistence_save_debounce_ms;return D(i)&&i>0}Ac(){this.Rc()?this.cc.refreshKey(Vn):(this.cc.flush(),this.cc.load())}Fc(){var t;if(I(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.vc)return;this.Ac();const[,i,e]=this.Oc();i===this.Xt&&e===this._sessionStartTimestamp&&(this.vc=this._sessionActivityTimestamp,this.cc.register({[Vn]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.cc.flush())}Dc(){const[t]=this.Oc(),i=D(t)?t:0,e=D(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}Lc(t){return this.Ac(),this.bc(t,this.Dc())}Oc(){const t=this.cc.props[Vn];return k(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.vc=null,this._c=void 0,clearTimeout(this.Nc),this.Nc=void 0,this.Pc(null,null,null)}setBootstrapSessionId(t,i=!1){const e=((t,i=(new Date).getTime())=>{try{const e=(t=>{const i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void Nu.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void Nu.error("Invalid sessionID in bootstrap",t)}})(t);return!R(e)&&(i?this._c={sessionId:t,sessionStartTimestamp:e}:this.Pc(t,(new Date).getTime(),e),!0)}destroy(){this.yc=!0,this.Fc(),clearTimeout(this.Nc),this.Nc=void 0,this.mc&&t&&(t.removeEventListener(Rr,this.mc,{capture:!1}),this.mc=void 0),this.gc=[]}Tc(){this.mc=()=>{this.Fc(),this.Cc()&&wo.Pt(this.$c)},qr(t,Rr,this.mc,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,i=null,e=!1){if("always"===this.Ar.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=i||(new Date).getTime(),n=this.Xt;if(e)this.fc=s;else if(I(this.fc)||this.fc>s||s-this.fc>=1e3){var r,o;null===(r=(o=this.cc).syncCookieProperties)||void 0===r||r.call(o),this.fc=s}let[,l,a]=this.Oc();const u=!R(n)&&l!==n,h=this.Dc();let d=this.Mc();const c=this._c,v=!!c&&(c.sessionStartTimestamp>s+6e4||s-c.sessionStartTimestamp>ju),f=c?v:D(a)&&Math.abs(s-a)>ju;let p=!1,_=u,g=!l||!!c;const m=l;let y=!g&&!t&&this.bc(s,h);if(y&&(y=this.Lc(s),y||Nu.info("cross-tab refresh kept the session alive",{sessionId:l}),[,l,a]=this.Oc(),y||(g=!l||!!c)),g||y||f){_=!1;const t=c&&!v;l=t?c.sessionId:this.wc(),d=this.kc(),Nu.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!t,changeReason:{noSessionId:g,activityTimeout:y,sessionPastMaximumLength:f}}),a=t?c.sessionStartTimestamp:s,this._c=void 0,p=!0}else d||(d=this.kc(),p=!0),_=_||l!==m,_&&(Nu.info("adopted cross-tab session id",{sessionId:l,windowId:d}),p=!0);const b=D(h)&&t&&!f?h:s,w=D(a)?a:(new Date).getTime();this.Ic(d),this.Pc(l,b,w),t||this.Sc();const S={noSessionId:g,activityTimeout:y,sessionPastMaximumLength:f,crossTabAdoption:_};return p&&this.gc.forEach(t=>t(l,d,S)),{sessionId:l,windowId:d,sessionStartTimestamp:w,changeReason:p?S:void 0,lastActivityTimestamp:h}}Sc(){this.yc||(clearTimeout(this.Nc),this.Nc=setTimeout(()=>{if(!this.yc)if(this.Lc((new Date).getTime())){const t=this.Xt;this.resetSessionId(),this.dc.emit("forcedIdleReset",{idleSessionId:t})}else this.Sc()},1.1*this.sessionTimeoutMs))}};const Uu=function(t,i){if(!t)return!1;const e=t.userAgent;if(e&&X(e,i))return!0;try{const e=null==t?void 0:t.userAgentData;if((null==e?void 0:e.brands)&&e.brands.some(t=>X(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function Bu(){return(Bu=J(function*(){const t=null==e?void 0:e.userAgentData;if(null==t?void 0:t.getHighEntropyValues)try{const i=yield t.getHighEntropyValues(["model"]),e=null==i?void 0:i.model;return O(e)&&e.length>0?e:void 0}catch(t){return void Us.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function zu(t,i){let e=`$survey_${i}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(e=`$survey_${i}/${t.id}/${t.current_iteration}`),e}function Hu(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}const qu=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Vu=t=>t.toLowerCase(),Wu={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>qu(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!qu(i,t))),icontains:(t,i)=>i.map(Vu).some(i=>t.map(Vu).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Vu).every(i=>t.map(Vu).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function Gu(t,i){return!t||Object.entries(t).every(([t,e])=>{const s=null==i?void 0:i[t];if(null==s)return!1;const n=Wu[e.operator];return!!n&&n(e.values.map(String),[String(s)])})}function Ku(t,i,e){return Ol({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}const Ju="custom",Yu="i.posthog.com",Zu=/^\/static\//,Xu=["/s/","/e/","/i/"];var Qu=class{constructor(t){this.qc={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let i=null===(t=this.instance.config.ui_host)||void 0===t?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace(`.${Yu}`,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.qc[this.apiHost]||(this.qc[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":Ju),this.qc[this.apiHost]}jc(t){if(!Zu.test(t))return;const i=this.instance.config.asset_host;return"string"==typeof i&&i.trim().replace(/\/$/,"")||void 0}Bc(t){const i=Al(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}zc(t,i,e){if("ui"===t)return e;let s=e;const n=this.instance.config.rewriteRequestPath;if(n){var r;const t=(null===(r=Al(e))||void 0===r?void 0:r.href)||e;s=n(new URL(t)).toString()}if(n&&"api"===t&&Xu.some(t=>0===i.indexOf(t))){const t=this.Bc(s);if(t){const i=this.apiHost;let e=this.Hc;(null==e?void 0:e.apiHost)===i&&e.rewriteRequestPath===n||(e={apiHost:i,rewriteRequestPath:n,urls:new Set},this.Hc=e),e.urls.add(t)}}return s}isIngestionEndpoint(t){const i=this.Hc,e=this.Bc(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i=""){if(i&&(i="/"===i[0]?i:`/${i}`),"ui"===t)return this.zc(t,i,this.uiHost+i);if("flags"===t)return this.zc(t,i,this.flagsApiHost+i);if("assets"===t){const e=this.jc(i);if(e)return this.zc(t,i,`${e}${i}`)}if(this.region===Ju)return this.zc(t,i,this.apiHost+i);const e=Yu+i;switch(t){case"assets":return this.zc(t,i,`https://${this.region}-assets.${e}`);case"api":return this.zc(t,i,`https://${this.region}.${e}`)}}};const th=Bs("[Surveys]"),ih=t=>{try{const i=(t=>((t,i)=>`seenSurvey_${function(t){return t.current_iteration&&t.current_iteration>0?`${t.id}_${t.current_iteration}`:t.id}(i)}`)(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){th.error("Failed to persist survey seen state",t)}},eh=[fa.Popover,fa.Widget,fa.API],sh={ignoreConditions:!1,ignoreDelay:!1,displayType:ba.Popover},nh=Bs("[PostHog ExternalIntegrations]"),rh={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var oh=class{constructor(t){this._instance=t}$l(t,i){var e,s;null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,t,t=>{if(t)return nh.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t;for(const[n,r]of Object.entries(null!==(t=this._instance.config.integrations)&&void 0!==t?t:{})){var i,e,s;r&&!(null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&this.$l(rh[n],()=>{var t;null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t||null===(t=t[n])||void 0===t||t.start(this._instance)}),!r&&(null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e?void 0:e[n])&&(null===(s=d.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}};const lh="autocapture",ah="featureFlags",uh="logs";var hh=class{constructor(t){this._instance=t}initialize(){}get(t){const i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);const e={};for(const s of t){const t=null==i?void 0:i.get_property(s);R(t)||(e[s]=t)}return e}set(t,i){var e;null===(e=this._instance.persistence)||void 0===e||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null===(i=this._instance.persistence)||void 0===i||i.unregister(t)}},dh=class{constructor(t){this.instance=t,this.$=Us,this.kv=new hh(t),this.onSession=t=>wa(this.instance.onSessionId(i=>{try{t(i)}catch(t){this.$.error("Browser extension session listener failed",t)}})),this.onEvent=t=>wa(this.instance._addCaptureHook((i,e)=>{if(e)try{t({event:i,properties:e.properties})}catch(t){this.$.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{const i=i=>{try{t(i)}catch(t){this.$.error("Browser extension remote config listener failed",t)}},e=this.instance.ur.on("extensionsRemoteConfig",i);return this.instance.cr&&i(this.instance.cr),wa(e)}}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){const t=this.instance.get_property(yn);return"string"==typeof t?t:void 0}get library(){return{name:Gs.LIB_NAME,version:Gs.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,s,n;const r=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==r?void 0:r.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==r?void 0:r.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0,lastActivityTimestamp:null!==(n=null==r?void 0:r.lastActivityTimestamp)&&void 0!==n?n:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return T(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(t){let i;switch(t){case ah:case"featureFlagsCommon":i=this.instance.featureFlags;break;case uh:i=this.instance.logs;break;case"surveys":i=this.instance.surveys;break;case lh:i=this.instance.autocapture}return i}capture(t,i,e){if(!e)return void this.instance.capture(t,i);const s=wi({timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce},"unload"===e.delivery?{transport:"sendBeacon",send_instantly:!0}:{});this.instance.capture(t,i,s)}registerDynamicEventProperties(t){return wa(this.instance.dr(t))}sendRequest(t){var i=this;return J(function*(t,e={}){var s;const n=null!==(s=e.target)&&void 0!==s?s:"api",r=e.query?pu(t,e.query):t,o=i.instance.requestRouter.endpointFor(n,r),l={method:e.method,url:o,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:"flags"===e.target&&"best-available"===e.compression?p.Base64:void 0,timestampMode:e.sentAt};return"api"===n&&"/i/v1/logs"===t&&(l.batchKey="logs"),"sendBeacon"===e.transport?(i.instance._send_request(l),{statusCode:202}):new Promise(t=>{l.callback=t,i.instance._send_request(l)})}).apply(this,arguments)}};const ch={};let vh=0;const fh=()=>{},ph='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',_h="Surveys module not available",gh="sanitize_properties is deprecated. Use before_send instead",mh="Invalid value for property_denylist config: ",yh=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],bh=["$feature_flag_called","$$heatmap","$snapshot"],wh=t=>"$"===t.charAt(0)&&!m(bh,t),$h=/^[A-Za-z0-9_-]{1,400}$/,Sh=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,xh=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Eh=["token","distinct_id",fr],kh="posthog",Th=t=>{const i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},Ph=i=>{var e;return wi({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Hr(null==s?void 0:s.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=i?i:"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:n&&O(null==n?void 0:n.search)&&-1!==n.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==t||null===(e=t.location)||void 0===e?void 0:e.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(t){Us.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Cr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:fh},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Bo,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:Th(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(i))},Ch=[["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"]],Rh=t=>{const i={};for(const[e,s]of Ch)R(t[e])||(i[s]=t[e]);const e=Nr({},i,t),s=t.__preview_external_dependency_versioned_paths;return R(s)||(R(t.strict_script_versioning)&&(e.strict_script_versioning=!!s),O(s)&&R(t.asset_host)&&(e.asset_host=s)),k(t.property_blacklist)&&(R(t.property_denylist)?e.property_denylist=t.property_blacklist:k(t.property_denylist)?e.property_denylist=[...t.property_blacklist,...t.property_denylist]:Us.error(mh+t.property_denylist)),e};var Oh=class{constructor(){this.__forceAllowLocalhost=!1}get Uc(){return this.__forceAllowLocalhost}set Uc(t){Us.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},Ah=class i{Wc(t){if(!t)return;const i=this.Vc.indexOf(t);-1!==i&&this.Vc.splice(i,1)}Gc(t,i){var e;return this.Wc(t),this.Vc.push(i),null===(e=i.initialize)||void 0===e||e.call(i),i}Qc(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}Zc(){if(this.Jc)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.Qc())return;const t="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!t&&!this.config.disable_persistence)return;if(this.Kc)return;let i,e,s;t?(i=`persistence is set to '${this.config.persistence}'`,e="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(i="persistence is disabled (disable_persistence is true)",e="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.Jc=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${e}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}Xc(){const t=this.persistence;if(!t||this.Yc)return;if(this.Qc())return void("on_reject"===this.config.cookieless_mode&&"$posthog_cookieless"!==this.get_distinct_id()&&(this.th(),this.eh()));if("$posthog_cookieless"!==this.get_distinct_id())return;this.ih()||t.load(!0);const i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){const i=this.config.get_device_id(Qr());this.register({distinct_id:i,$device_id:i}),t.set_property(or,Tr)}this.th()}get decideEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.nh=!1,this.sh=!1,this.webPerformance=new Oh,this.rh=!1,this.version=Gs.LIB_VERSION,this.oh=new Set,this.ah="",this.ur=new Du,this.Vc=[],this.uh=[],this.hh=!1,this.Kc=!1,this.Jc=!1,this.Yc=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ph(),this.SentryIntegration=wl,this.sentryIntegration=t=>function(t,i){const e=bl(t,i);return{name:yl,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.dh=!1,this.fh=null,this.ph=null,this.gh=null,this.scrollManager=new Iu(this),this.pageViewManager=new $l(this),this.rateLimiter=new ka(this),this.requestRouter=new Qu(this),this.consent=new $o(this),this.externalIntegrations=new oh(this);const e=null!==(t=i.__defaultExtensionClasses)&&void 0!==t?t:{};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:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(s),null==e||e({})},set_once:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(void 0,s),null==e||e({})}},this.on("eventCaptured",t=>Us.info(`send "${null==t?void 0:t.event}"`,t))}init(t,e,s){if(s&&s!==kh){var n;const r=null!==(n=ch[s])&&void 0!==n?n:new i;return r._init(t,e,s),ch[s]=r,ch[kh][s]=r,r}return this._init(t,e,s)}_init(i,e={},s){var n,r,o;const l=O(i)?i.trim():"";if(!l)return Us.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var a;if(this.__loaded)return l!==(null===(a=this.config)||void 0===a?void 0:a.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${l}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ph(e.defaults),e.debug=this.mh(e.debug),this.yh=e,this.bh=[],e.person_profiles?this.ph=e.person_profiles:e.process_person&&(this.ph=e.process_person);const u=Ph(e.defaults),h=Rh(e),d=Nr({},u,h,{name:s,token:l});P(u.rageclick)&&P(h.rageclick)&&(d.rageclick=Nr({},u.rageclick,h.rageclick)),P(u.session_recording)&&P(h.session_recording)&&(d.session_recording=Nr({},u.session_recording,h.session_recording)),this.set_config(d),this.config.on_xhr_error&&Us.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=e.disable_compression?void 0:ua.GZipJS;const c=this.ih(),v=!this.Qc();if(this.persistence=new aa(this.config,c,!0,v),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new aa(wi(wi({},this.config),{},{persistence:"sessionStorage"}),c,!1,v),this.ah="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!c&&wo.$t()){const t=wo.Lt(this.ah);k(t)&&t.forEach(t=>{O(t)&&this.oh.add(t)})}else wo.Pt(this.ah);const f=wi({},this.persistence.props),p=wi({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._h=new Ru((t,i)=>this.wh(t,i),this.config.request_queue_config),this.kh=new Au(this),this.__request_queue=[];const _=this.Qc();_||(this.sessionManager=new Lu(this),this.sessionPropsManager=new Mu(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{((null==e?void 0:e.activityTimeout)||(null==e?void 0:e.sessionPastMaximumLength)||(null==e?void 0:e.crossTabAdoption))&&this.Sh()})),this.xh(),this.config.__preview_deferred_init_extensions?(Us.info("Deferring extension initialization to improve startup performance"),this.$h=setTimeout(()=>{this.$h=void 0,this.Ch(_)},0)):(Us.info("Initializing extensions synchronously"),this.Ch(_)),Gs.DEBUG=Gs.DEBUG||this.config.debug,Gs.DEBUG&&Us.info("Starting in debug mode",{this:this,config:e,thisC:wi({},this.config),p:f,s:p}),this.config.identity_distinct_id&&!(null===(n=e.bootstrap)||void 0===n?void 0:n.distinctID)&&(e.bootstrap=wi(wi({},e.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const g=null===(r=e.bootstrap)||void 0===r?void 0:r.distinctID;if(this.Kc=!!g&&!A(g),null===(o=e.bootstrap)||void 0===o?void 0:o.distinctID){const t=e.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(or);if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"anonymous"===s)this.identify(t);else if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"identified"===s)Us.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const i=this.config.get_device_id(Qr()),s=e.bootstrap.isIdentifiedID?i:t;this.persistence.set_property(or,e.bootstrap.isIdentifiedID?Pr:Tr),this.register({distinct_id:t,$device_id:s})}}if(_)this.register_once({distinct_id:vr,$device_id:null},"");else if(!this.get_distinct_id()){const t=this.config.get_device_id(Qr());this.register_once({distinct_id:t,$device_id:t},""),this.persistence.set_property(or,Tr)}return qr(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),qr(t,"pageshow",()=>{var t;this.nh=!1,this.sh||null===(t=this.kh)||void 0===t||t.resume()}),e.segment?ml(this,()=>this.Th()):this.Th(),T(this.config._onCapture)&&this.config._onCapture!==fh&&(Us.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&Us.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 Bu.apply(this,arguments)}().then(t=>{t&&this.register({[bn]:t})}).catch(fh),this}Ih(t){const i=t;return O(i.name)&&T(i.setup)}Mh(t,i){var e=this;this.Ih(t)?i.push(J(function*(){try{yield t.setup(e.Eh())}catch(e){Us.error(`Failed to set up extension "${t.name}"`,e);try{var i;yield null===(i=t.dispose)||void 0===i?void 0:i.call(t)}catch(i){Us.error(`Failed to dispose extension "${t.name}"`,i)}}})):this.Vc.push(t)}xh(){var t,e,s,n=this;const r=null!==(t=null===(e=this.config.__extensionClasses)||void 0===e?void 0:e.featureFlags)&&void 0!==t?t:null===(s=i.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var o,l,a;if(r)if(this.featureFlags&&this.featureFlags instanceof r||(null===(o=this.Ph)||void 0===o||o.call(this),this.Ph=void 0,this.featureFlags=new r(this)),T(this.featureFlags.onReloading)&&T(this.featureFlags.setup)){if(!this.Ph){this.Ph=this.featureFlags.onReloading(()=>{this.ur.emit("featureFlagsReloading",!0)});const t=this.featureFlags;J(function*(){try{yield t.setup(n.Eh())}catch(i){Us.error("Failed to set up feature flags",i);const e=n.Ph;n.Ph=void 0;try{null==e||e()}catch(t){Us.error("Failed to unsubscribe feature flag reloading",t)}try{yield t.dispose()}catch(t){Us.error("Failed to dispose feature flags",t)}}})()}}else null===(l=(a=this.featureFlags).initialize)||void 0===l||l.call(a)}Ch(t){const e=performance.now(),s=wi(wi({},i.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,l,a,u,h,d,c;s.exceptions&&this.Vc.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.Vc.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.Vc.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.Vc.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this.Vc.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Mh(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Mh(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Mh(this.logs=null!==(l=this.logs)&&void 0!==l?l:new s.logs(this),n),s.metrics&&this.Vc.push(this.metrics=null!==(a=this.metrics)&&void 0!==a?a:new s.metrics(this)),s.conversations&&this.Vc.push(this.conversations=null!==(u=this.conversations)&&void 0!==u?u:new s.conversations(this)),s.productTours&&this.Vc.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.Vc.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.Vc.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.Vc.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.Vc.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,pl)),s.toolbar&&this.Vc.push(this.toolbar=null!==(h=this.toolbar)&&void 0!==h?h:new s.toolbar(this)),s.experiments&&this.Vc.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),s.webMCP&&this.Vc.push(this.webMCP=null!==(c=this.webMCP)&&void 0!==c?c:new s.webMCP(this)),this.Vc.forEach(t=>{t.initialize&&n.push(()=>{var i;null===(i=t.initialize)||void 0===i||i.call(t)})}),n.push(()=>{if(this.Rh){const t=this.Rh;this.Rh=void 0,this.Vc.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}}),this.Ah(n,e)}Ah(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void(this.$h=setTimeout(()=>{this.$h=void 0,this.Ah(t,i)},0));const e=t.shift();if(e)try{e()}catch(t){Us.error("Error initializing extension:",t)}}const e=Math.round(performance.now()-i);this.register_for_session({[pr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[_r]:e}),this.config.__preview_deferred_init_extensions&&Us.info(`PostHog extensions initialized (${e}ms)`)}Nu(t){if(!s||!s.body)return Us.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Nu(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Rh=t),this.cr=t,this.compression=void 0,t.ok){var i;const e=t.config;e.supportedCompression&&!this.config.disable_compression&&(this.compression=m(e.supportedCompression,ua.GZipJS)?ua.GZipJS:m(e.supportedCompression,ua.Base64)?ua.Base64:void 0),(null===(i=e.analytics)||void 0===i?void 0:i.endpoint)&&(this.analyticsDefaultEndpoint=e.analytics.endpoint)}this.set_config({person_profiles:this.ph?this.ph:Cr}),this.ur.emit("extensionsRemoteConfig",t),this.Vc.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}Th(){try{this.config.loaded(this)}catch(t){Us.critical("`loaded` function failed",t)}if(this.Fh(),this.config.internal_or_test_user_hostname&&(null==n?void 0:n.hostname)){const t=n.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Qc())&&this.Oh()},1),this.Dh=new Pa(this),this.Dh.load()}Fh(){var t;this.is_capturing()&&this.config.request_batching&&(null===(t=this._h)||void 0===t||t.enable())}_dom_loaded(){this.is_capturing()&&Mr(this.__request_queue,t=>this.wh(t)),this.__request_queue=[],this.Fh()}_handle_unload(){var t,i,e,s,n,r;this.nh=!0,null===(t=this.surveys)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t),null===(e=this.metrics)||void 0===e||e.flush("sendBeacon"),this.config.request_batching?(this.Lh()&&this.capture(Ar),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this._h)||void 0===n||n.unload(),null===(r=this.kh)||void 0===r||r.unload()):this.Lh()&&this.capture(Ar,null,{transport:"sendBeacon"})}_send_request(t){Cu(this,t)}wh(t,i){this.kh?this.kh.retriableRequest(t,i):this._send_request(i?wi(wi({},t),{},{transport:i}):t)}_execute_array(t){vh++;try{let i;const e=[],s=[],n=[];Mr(t,t=>{if(t)if(i=t[0],k(i))n.push(t);else if(T(t))try{t.call(this)}catch(i){Us.error("Error executing queued PostHog call",t,i)}else k(t)&&"alias"===i?e.push(t):k(t)&&-1!==i.indexOf("capture")&&T(this[i])?n.push(t):s.push(t)});const r=function(t,i){Mr(t,function(t){try{if(k(t[0])){let e=i;Dr(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){Us.error("Error executing queued PostHog call",t,i)}})};r(e,this),r(s,this),r(n,this)}finally{vh--}}push(t){if(vh>0&&k(t)&&O(t[0])){const e=i.prototype[t[0]];return void(T(e)&&e.apply(this,t.slice(1)))}this._execute_array([t])}get Nh(){return{property:Sn,persistenceKey:xn,cookieName:"_fbc",pattern:Sh,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[xn]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(xn)}}}get qh(){return{property:En,persistenceKey:kn,cookieName:"_fbp",pattern:xh,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[kn]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(kn)}}}jh(t){var i;const e=null===(i=this.persistence)||void 0===i?void 0:i.get_property(t.persistenceKey);return O(e)&&t.pattern.test(e)?{value:e,delivered:!1}:P(e)&&O(e.value)&&t.pattern.test(e.value)?{value:e.value,delivered:!0===e.delivered}:void 0}Bh(t,i,e){return i===(null==e?void 0:e.value)?{value:i,pending:!e.delivered}:(t.register(i,!1),{value:i,pending:!0})}zh(t){if(!this.config.save_campaign_params||this.Qc())return;const i=Wr(t.cookieName);return O(i)&&t.pattern.test(i)?i:void 0}Hh(t,i,e,s){if(!this.persistence)return;const n=this.Nh;this.persistence.refreshKey(n.persistenceKey);const r=this.jh(n);if(s)return void n.unregister();if(e)return O(i)&&Sh.test(i)?this.Bh(n,i,r):void n.unregister();const o=O(t)&&$h.test(t)?t:void 0,l=this.zh(n);return l&&((t,i,e)=>{const s=t.split(".");if(i)return s[3]===i;if(!e)return!0;const n=e.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(l,o,r)?this.Bh(n,l,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this.Bh(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}Uh(t,i,e){if(!this.persistence)return;const s=this.qh;this.persistence.refreshKey(s.persistenceKey);const n=this.jh(s);if(e)return void s.unregister();if(i)return O(t)&&xh.test(t)?this.Bh(s,t,n):void s.unregister();const r=this.zh(s);return r?this.Bh(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}Wh(t,i){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const e=this.jh(t);(null==e?void 0:e.value)!==i||e.delivered||t.register(i,!0)}capture(t,i,e){var s,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._h))return void Us.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(R(t)||!O(t))return void Us.error("No event name provided to posthog.capture");if(this.Xc(),"$snapshot"===t&&this.Qc())return;const r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;const o=(null==e?void 0:e.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==o?void 0:o.isRateLimited)return void Us.critical("This capture call is ignored due to client rate limiting.");let l;(null==i?void 0:i.$current_url)&&!O(null==i?void 0:i.$current_url)&&(Us.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||(null==e?void 0:e.Vh)||Us.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const a=new Date,u=(null==e?void 0:e.timestamp)||a,h=di(null==e?void 0:e.uuid,Qr);let d={uuid:h,event:t,properties:this.calculateEventProperties(t,i||{},u,h)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&r&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),o&&(d.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens);const c="$feature_flag_called"===t&&!1===d.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==e?void 0:e.$set)&&!c&&(d.$set=null==e?void 0:e.$set);const v=P(null==i?void 0:i.$set)?i.$set:void 0,f=k(null==i?void 0:i.$unset)?i.$unset:[],p=(null==e?void 0:e.$unset)||[],_=t=>{var i;const s=!!(null==e?void 0:e.$set)&&t in e.$set;return{hasProvided:s||!!v&&t in v,provided:s?null==e||null===(i=e.$set)||void 0===i?void 0:i[t]:null==v?void 0:v[t],unset:-1!==f.indexOf(t)||-1!==p.indexOf(t)}},g=_(Sn),m=_(En),y=[{channel:this.Nh,hasProvided:g.hasProvided,update:this.Hh(null==l?void 0:l.fbclid,g.provided,g.hasProvided,g.unset)},{channel:this.qh,hasProvided:m.hasProvided,update:this.Uh(m.provided,m.hasProvided,m.unset)}];for(const{channel:t,hasProvided:i,update:e}of y)e&&!0===d.properties.$process_person_profile&&e.pending&&!i&&!c&&(d.$set=wi({[t.property]:e.value},d.$set));const b=null==e?void 0:e.$unset;b&&(d.$unset=b);const w=c?void 0:this.Gh(null==e?void 0:e.$set_once,t!==Fr,t===Ir);if(w&&(d.$set_once=w),(null==e?void 0:e._noTruncate)||(S=this.config.properties_string_max_length,d=function(t,i){const e=new Set;return function t(s,n){if(s!==Object(s))return i?i(s):s;if(e.has(s))return;let r;if(e.add(s),k(s))r=[],Mr(s,i=>{r.push(t(i))});else{const i={};Dr(z(s)?Br(s):s,(s,n)=>{e.has(s)||(i[n]=t(s,n))}),r=i}return r}(t)}(d,t=>O(t)?t.slice(0,S):t)),d.timestamp=u,R(null==e?void 0:e.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=a),c&&(d.properties=((t,i=[])=>{const e={},s=i=>{void 0!==t[i]&&(e[i]=t[i])};return _e.forEach(s),i.forEach(s),e})(d.properties,Eh)),t===ma.DISMISSED||t===ma.SENT){const e=null==i?void 0:i[ya.SURVEY_ID],s=null==i?void 0:i[ya.SURVEY_ITERATION];ih({id:e,current_iteration:s}),d.$set=wi(wi({},d.$set),{},{[zu({id:e,current_iteration:s},t===ma.SENT?"responded":"dismissed")]:!0})}else t===ma.SHOWN&&(d.$set=wi(wi({},d.$set),{},{[ya.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var S;if(t===Sa.SHOWN){const t=null==i?void 0:i[xa.TOUR_TYPE];t&&(d.$set=wi(wi({},d.$set),{},{[`${xa.TOUR_LAST_SEEN_DATE}/${t}`]:(new Date).toISOString()}))}const x=wi(wi({},d.properties.$set),d.$set);if(C(x)||this.setPersonPropertiesForFlags(x),!F(this.config.before_send)){const t=this.Os(d);if(!t)return;d=t,d.uuid=di(d.uuid,Qr)}this.sessionRecording&&!this.hh&&wh(t)&&(this.hh=!0,setTimeout(()=>this.hh=!1,3e4));const E=y.filter(({channel:t,update:i})=>{var e,s,n;const r=null!==(e=null===(s=d.$set)||void 0===s?void 0:s[t.property])&&void 0!==e?e:P(null===(n=d.properties)||void 0===n?void 0:n.$set)?d.properties.$set[t.property]:void 0;return(null==i?void 0:i.pending)&&r===i.value});this.ur.emit("eventCaptured",d);const T=null!==(s=null==e?void 0:e._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),A="recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(T),I=wi(wi(wi({method:"POST",url:T,data:d,compression:"best-available",preferSyncCompression:null==e?void 0:e.send_instantly,timestampMode:A?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},A&&(null===(n=d.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),(null==e?void 0:e.transport)?{transport:e.transport}:{}),E.length?{fireCallbackOnDrop:!0,callback:t=>{if(t.statusCode>=200&&300>t.statusCode)for(const{channel:t,update:i}of E)this.Wh(t,i.value)}}:{});if(!this.config.request_batching||e&&!(null==e?void 0:e._batchKey)||(null==e?void 0:e.send_instantly)){var M;let t;!I.transport&&!I.callback&&C(null!==(M=this.config.request_headers)&&void 0!==M?M:{})&&this.nh&&(t="sendBeacon"),this.wh(I,t)}else this._h.enqueue(I);return d}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null===(i=this.Qh)||void 0===i?void 0:i.getExtension(t)}Eh(){var t;return null!==(t=this.Qh)&&void 0!==t?t:this.Qh=new dh(this)}dr(t){this.uh.push(t);let i=!0;return()=>{if(!i)return;i=!1;const e=this.uh.indexOf(t);-1!==e&&this.uh.splice(e,1)}}Zh(t=!0){var i,e,s;return!!(null===(i=this.persistence)||void 0===i?void 0:i.consumeCookieIdentityChange())&&(this.gh=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.oh.clear(),this.Jh()),null===(e=this.featureFlags)||void 0===e||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(i,e,r,o,l){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return e;this.Xc(),this.persistence.syncCookieProperties(),this.Zh();const a=l?void 0:this.persistence.remove_event_timer(i);let h=wi({},e);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.Qc()&&(h[fr]=!0),"$snapshot"===i){const t=wi(wi({},this.persistence.properties()),this.sessionPersistence.properties());return h.distinct_id=t.distinct_id,(!O(h.distinct_id)&&!M(h.distinct_id)||A(h.distinct_id))&&Us.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}const d=function(i,e,s,r=!1){var o,l,a,h;if(!u)return{};const d=i?[...Dl,...e||[]]:[],[c,f]=Qt(u),[p,_]=function(t){for(let i=0;si.length>i;i++){const[e,s,n]=si[i],r=t.match(e);if(r){const i=n&&t.match(n)||r;return[s,(null==i?void 0:i[1])||""]}}return["",""]}(u),g=function(){const t="u">typeof navigator?navigator:void 0;return(null==t?void 0:t.brave)?{brave:!0}:{}}(),m={};R(s)||(m.detectGoogleSearchApp=s);const y={},b=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,w=null===(l=navigator)||void 0===l?void 0:l.maxTouchPoints,S=null==t||null===(a=t.screen)||void 0===a?void 0:a.width,x=null==t||null===(h=t.screen)||void 0===h?void 0:h.height,E=null==t?void 0:t.devicePixelRatio;R(b)||(y.userAgentDataPlatform=b),R(w)||(y.maxTouchPoints=w),R(S)||(y.screenWidth=S),R(x)||(y.screenHeight=x),R(E)||(y.devicePixelRatio=E);const k=Nr(Ur({$os:c,$os_version:f,$browser:Jt(u,navigator.vendor,g,m),$webview_app:p,$webview_app_version:_,$device:ti(u),$device_type:ii(u,y),$timezone:Tl(),$timezone_offset:Jl()}),{$current_url:Fl(r?vi(null==n?void 0:n.href):null==n?void 0:n.href,d,jl),$host:null==n?void 0:n.host,$pathname:null==n?void 0:n.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:Zt(u,navigator.vendor,g,m),$browser_language:Hl(),$browser_language_prefix:ql(),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:v.LIB_NAME,$lib_version:v.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return v.SDK_DIST_CHANNEL&&(k.$sdk_dist_channel=v.SDK_DIST_CHANNEL),k}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId(l,r.getTime(),!0);h.$session_id=t,h.$window_id=i}this.sessionPropsManager&&Nr(h,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const t=this.sessionRecording.sdkDebugProperties,e=!this.hh&&wh(i);for(const i in t)(e||m(yh,i))&&(h[i]=t[i])}h.$sdk_debug_retry_queue_size=null===(c=this.kh)||void 0===c?void 0:c.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}let f;if(this.requestRouter.region===Ju&&(h.$lib_custom_api_host=this.config.api_host),f="$pageview"!==i||l?"$pageleave"!==i||l?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),h=Nr(h,f),"$pageview"===i&&s&&(h.title=s.title),!R(a)){const t=r.getTime()-a;h.$duration=parseFloat((t/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");const p=this.persistence.properties(),_=this.sessionPersistence.properties(),g=h.$groups,y=p.$groups;P(g)&&!C(g)&&(h.$groups=wi(wi({},P(y)?y:{}),g)),Dr(["$referrer","$referring_domain"],t=>{t in p&&delete _[t]});const b={};if(this.uh.length>0)for(const t of this.uh.slice())try{Nr(b,t())}catch(t){Us.error("Failed to produce browser extension event properties",t)}h=Nr({},d,p,_,wi(wi({},b),h)),h.$is_identified=this._isIdentified(),k(this.config.property_denylist)?Dr(this.config.property_denylist,function(t){delete h[t]}):Us.error(mh+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const w=this.config.sanitize_properties;w&&(Us.error(gh),h=w(h,i));const S=this.Kh();return h.$process_person_profile=S,S&&!l&&this.Xh("_calculate_event_properties"),h}Gh(t,i=!0,e=!1){var s;if(!this.persistence||!this.Kh())return t;if(this.rh&&!e)return t;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Nr({},n,r||{},t||{});const l=this.config.sanitize_properties;return l&&(Us.error(gh),o=l(o,"$set_once")),i&&(this.rh=!0),C(o)?void 0:o}register(t,i){var e;null===(e=this.persistence)||void 0===e||e.register(t,i)}register_once(t,i,e){var s;null===(s=this.persistence)||void 0===s||s.register_once(t,i,e)}register_for_session(t){var i,e;null===(i=this.persistence)||void 0===i||i.syncCookieProperties(),this.Zh(),null===(e=this.sessionPersistence)||void 0===e||e.register(t),Object.keys(t).forEach(t=>this.oh.add(t)),this.Jh()}unregister(t){var i;null===(i=this.persistence)||void 0===i||i.unregister(t)}unregister_for_session(t){var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t),this.oh.delete(t),this.Jh()}Yh(t,i){this.register({[t]:i})}Sh(){this.oh.forEach(t=>{var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t)}),this.oh.clear(),this.Jh()}Jh(){var t;if(!this.ah)return;if("memory"===this.config.persistence||(null===(t=this.sessionPersistence)||void 0===t?void 0:t.hi)||!wo.$t())return void wo.Pt(this.ah);const i=[];this.oh.forEach(t=>i.push(t)),i.length>0?wo.At(this.ah,i):wo.Pt(this.ah)}getFeatureFlag(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,s;return null!==(e=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null===(t=this.featureFlags)||void 0===t||t.reloadFeatureFlags()}updateFlags(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i=!1,e){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.ur.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:_h}),()=>{})}onSessionId(t){var i,e;return null!==(i=null===(e=this.sessionManager)||void 0===e?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:_h})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:_h})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:_h}),()=>{})}renderSurvey(t,i){var e;null===(e=this.surveys)||void 0===e||e.renderSurvey(t,i)}displaySurvey(t,i=sh){var e;null===(e=this.surveys)||void 0===e||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null===(i=this.surveys)||void 0===i||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null===(e=this.surveys)||void 0===e?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:_h}}canRenderSurveyAsync(t,i=!1){var e,s;return null!==(e=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:_h})}td(t){return!t||A(t)?(Us.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(Us.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Us.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return Us.uninitializedWarning("posthog.identify");if(M(t)&&(t=t.toString(),Us.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.td(t))return;if(!this.Xh("posthog.identify"))return;this.Xc();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.Zh(!1),o=this.persistence.yu();let l=!1;try{const s=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),t!==s&&t!==this.get_property("__alias")&&(this.unregister(wn),this.register({distinct_id:t}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Tr,u=t!==s,h=!u&&o;if(u&&o){var a;const n=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:s};this.persistence.set_property(or,Pr),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.bu(),this.capture("$identify",n,{$set:i||{},$set_once:e||{}})&&(this.gh=Ku(t,i,e)),null===(a=this.featureFlags)||void 0===a||a.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(h){this.persistence.set_property(or,Pr);const s=i||{},n=e||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.bu(),this.capture("$set",{$set:s,$set_once:n})&&(this.gh=Ku(t,i,e))}else(i||e)&&this.setPersonProperties(i,e);u||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(dn)):h&&(i||e)&&this.reloadFeatureFlags(),l=!0}finally{o&&this.persistence.ku(l)}}setPersonProperties(t,i){if(!t&&!i)return;if(!this.Xh("posthog.setPersonProperties"))return;const e=Ku(this.get_distinct_id(),t,i);this.gh!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}})&&(this.gh=e)):Us.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;const e=(k(t)?t:[t]).filter(t=>O(t)&&t.length>0);0!==e.length&&this.Xh("posthog.unsetPersonProperties")&&(null===(i=this.featureFlags)||void 0===i||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.gh=null)}group(t,i,e){var s;if(!t||!i)return void Us.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.Zh();const n=this.getGroups(),r=n[t]!==i;if(r&&this.resetGroupPropertiesForFlags(t),this.register({$groups:wi(wi({},n),{},{[t]:i})}),(r||e)&&this.Kh()){const s={$group_type:t,$group_key:i};e&&(s.$group_set=e),this.capture(Fr,s)}e&&this.setGroupPropertiesForFlags({[t]:e}),r&&!e&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var e;null===(e=this.featureFlags)||void 0===e||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var e;this.Xh("posthog.setGroupPropertiesForFlags")&&(null===(e=this.featureFlags)||void 0===e||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null===(i=this.featureFlags)||void 0===i||i.resetGroupPropertiesForFlags(t)}reset(t){const i=N(t)?t:null==t?void 0:t.resetDeviceID,e=N(t)||null==t?void 0:t.bootstrap;this.ed(i,!1,e)}ed(t,i=!1,e){var s,n,r,o,l,a;if(Us.info("reset"),!this.__loaded)return Us.uninitializedWarning("posthog.reset");const u=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null===(s=this.yh)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.qu());const h=this.get_property(yn),d=this.get_property(bn),c=this.get_property(jn);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const v=this.is_capturing();i||this.consent.reset(),i||!v||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const f=null===(l=this.persistence)||void 0===l||null===(a=l.yu)||void 0===a?void 0:a.call(l),p=this.Yc;this.Yc=p||i;let _=!1;try{var g,m,y,b,w,S,x,E,k,T,P,C,O;if(null===(g=this.persistence)||void 0===g||g.clear(),null===(m=this.sessionPersistence)||void 0===m||m.clear(),this.oh.clear(),this.Jh(),R(c)||null===(T=this.persistence)||void 0===T||T.register({$session_recording_remote_config:c}),null===(y=this.surveys)||void 0===y||y.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(w=this.conversations)||void 0===w||w.reset(),null===(S=this.logs)||void 0===S||S.reset(),null===(x=this.metrics)||void 0===x||x.reset(),null===(E=this.persistence)||void 0===E||E.set_property("$user_state","anonymous"),null===(k=this.sessionManager)||void 0===k||k.resetSessionId(),this.gh=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:vr,$device_id:null},"");else{const i=this.config.get_device_id(Qr());this.register_once({distinct_id:i,$device_id:t?i:h},""),t||R(d)||this.register({[bn]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(e.distinctID&&!this.Qc()&&(null===(O=this.persistence)||void 0===O||O.set_property("$user_state",e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:e.distinctID})),null===(P=this.featureFlags)||void 0===P||P.initialize(),!F(u)&&!(null===(C=this.sessionManager)||void 0===C?void 0:C.setBootstrapSessionId(u,!0))){const t=wi({},e);delete t.sessionID,this.config.bootstrap=t}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var A,I;this.Yc=p,f&&(null===(A=this.persistence)||void 0===A||null===(I=A.ku)||void 0===I||I.call(A,_))}this.reloadFeatureFlags()}shutdown(t){var i=this;return J(function*(){if(!i.__loaded)return void Us.uninitializedWarning("posthog.shutdown");i.sh=!0,clearTimeout(i.$h),i.$h=void 0;const t=i.Ph;i.Ph=void 0;for(const e of[()=>{var t;return null===(t=i.sessionRecording)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.logs)||void 0===t?void 0:t.flushLogs("sendBeacon")},()=>{var t;return null===(t=i.metrics)||void 0===t?void 0:t.flush("sendBeacon")},()=>{var t;return null===(t=i.metrics)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.logs)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.surveys)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.autocapture)||void 0===t?void 0:t.dispose()},()=>null==t?void 0:t(),()=>{var t;return null===(t=i._h)||void 0===t?void 0:t.unload()},()=>{var t;return null===(t=i.kh)||void 0===t?void 0:t.unload()},()=>{var t;return null===(t=i.featureFlags)||void 0===t?void 0:t.destroy()},()=>{var t;return null===(t=i.persistence)||void 0===t?void 0:t.destroy()},()=>{var t;return null===(t=i.sessionPersistence)||void 0===t?void 0:t.destroy()}])try{const t=e();t&&T(t.then)&&t.then(void 0,t=>{Us.error("Error during shutdown",t)})}catch(t){Us.error("Error during shutdown",t)}})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null===(e=this.conversations)||void 0===e||e.nd()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(t=this.conversations)||void 0===t||t.sd()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:i,sessionStartTimestamp:e}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if((null==t?void 0:t.withTimestamp)&&e){var n;const i=null!==(n=t.timestampLookBack)&&void 0!==n?n:10;if(!e)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-e)/1e3)-i,0)}`}return s}alias(t,i){return t===this.get_property("$people_distinct_id")?(Us.critical("Attempting to create alias for existing People user - aborting."),-2):this.Xh("posthog.alias")?(R(i)&&(i=this.get_distinct_id()),t!==i?(this.Yh(wn,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(Us.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const i=wi({},this.config);if(P(t)){var e,s,n,r,o,l,a,u,h,d,c,v,f,p;Nr(this.config,Rh(t));const b=this.ih();if(this.persistence){const t="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;var _,g;if(t&&this.sessionPersistence!==this.persistence&&(null===(_=this.sessionPersistence)||void 0===_||_.remove(),null===(g=this.sessionPersistence)||void 0===g||g.destroy()),this.persistence.update_config(this.config,i,b),t)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new aa(wi(wi({},this.config),{},{persistence:"sessionStorage"}),b,!1);else{var m;null===(m=this.sessionPersistence)||void 0===m||m.update_config(wi(wi({},this.config),{},{persistence:"sessionStorage"}),wi(wi({},i),{},{persistence:"sessionStorage"}),b)}}const w=this.mh(this.config.debug);var y;N(w)&&(this.config.debug=w),N(this.config.debug)&&(this.config.debug?(Gs.DEBUG=!0,oo.$t()&&oo.At("ph_debug",!0),Us.info("set_config",{config:t,oldConfig:i,newConfig:wi({},this.config)})):(Gs.DEBUG=!1,oo.$t()&&oo.Pt("ph_debug"))),null===(e=this.featureFlags)||void 0===e||null===(s=e.updateConfig)||void 0===s||s.call(e,this.config,this.qu()),null===(n=this.exceptionObserver)||void 0===n||n.onConfigChange(),null===(r=this.exceptions)||void 0===r||r.onConfigChange(),null===(o=this.metrics)||void 0===o||o.onConfigChange(),null===(l=this.webMCP)||void 0===l||l.startIfEnabled(),null===(a=this.sessionRecording)||void 0===a||a.startIfEnabledOrStop(),null===(u=this.tracingHeaders)||void 0===u||u.startIfEnabledOrStop(),null===(h=this.autocapture)||void 0===h||h.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null===(y=this.historyAutocapture)||void 0===y||y.startIfEnabledOrStop()),null===(c=this.exceptionObserver)||void 0===c||c.startIfEnabledOrStop(),null===(v=this.deadClicksAutocapture)||void 0===v||v.startIfEnabledOrStop(),null===(f=this.surveys)||void 0===f||f.loadIfEnabled(),this.th(),null===(p=this.externalIntegrations)||void 0===p||p.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&ml(this,fh,!1)}}_overrideSDKInfo(t,i){Gs.LIB_NAME=t,Gs.LIB_VERSION=i}startSessionRecording(t){const i=!0===t,e={sampling:i||!!(null==t?void 0:t.sampling),linked_flag:i||!!(null==t?void 0:t.linked_flag),url_trigger:i||!!(null==t?void 0:t.url_trigger),event_trigger:i||!!(null==t?void 0:t.event_trigger)};var s,n,r,o,l;Object.values(e).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),e.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),e.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),e.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),e.event_trigger&&(null===(l=this.sessionRecording)||void 0===l||l.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(null===(t=this.sessionRecording)||void 0===t?void 0:t.started)}captureException(t,i){try{if(!this.exceptions)return;const e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(wi(wi({},e),i))}catch(t){return}}addExceptionStep(t,i){var e;null===(e=this.exceptions)||void 0===e||e.addExceptionStep(t,i)}captureLog(t){var i;null===(i=this.logs)||void 0===i||i.captureLog(t)}get logger(){var t,e;return null!==(t=null===(e=this.logs)||void 0===e?void 0:e.logger)&&void 0!==t?t:i.rd}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null===(e=this.toolbar)||void 0===e?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null===(i=this.persistence)||void 0===i?void 0:i.props[t]}getSessionProperty(t){var i;return null===(i=this.sessionPersistence)||void 0===i?void 0:i.props[t]}toString(){var t;let i=null!==(t=this.config.name)&&void 0!==t?t:kh;return i!==kh&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))||"identified"===(null===(i=this.sessionPersistence)||void 0===i?void 0:i.get_property("$user_state"))}Kh(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&C(this.getGroups())&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.__alias)&&!(null===(i=this.persistence)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.$epp))}Lh(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Kh()||this.Xh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Xh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Xh(t){return"never"===this.config.person_profiles?(Us.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Zc(),this.Yh(cr,!0),!0)}ih(){if("always"===this.config.cookieless_mode)return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}th(){var t,i;const e=this.ih();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.od(),(null===(t=this.persistence)||void 0===t?void 0:t.hi)!==e&&(null===(n=this.persistence)||void 0===n||n.set_disabled(e)),(null===(i=this.sessionPersistence)||void 0===i?void 0:i.hi)!==e&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(e)),this.Jh(),e}opt_in_capturing(t){var e;if("always"!==this.config.cookieless_mode){if(this.Qc()){var s,n,r,o,l,a;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.ed(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Lu(this),this.pageViewManager=new $l(this),this.persistence&&(this.sessionPropsManager=new Mu(this,this.sessionManager,this.persistence));const t=null!==(o=null===(l=this.config.__extensionClasses)||void 0===l?void 0:l.sessionRecording)&&void 0!==o?o:null===(a=i.__defaultExtensionClasses)||void 0===a?void 0:a.sessionRecording;var u,h;t&&(this.sessionRecording=this.Gc(this.sessionRecording,new t(this)),this.cr&&(null===(u=this.sessionRecording)||void 0===u||null===(h=u.onRemoteConfig)||void 0===h||h.call(u,this.cr)))}var d,c;this.consent.optInOut(!0),this.th(),this.Fh(),null===(e=this.sessionRecording)||void 0===e||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(R(null==t?void 0:t.captureEventName)||(null==t?void 0:t.captureEventName))&&this.capture(null!==(c=null==t?void 0:t.captureEventName)&&void 0!==c?c:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Oh()}else Us.warn(ph)}opt_out_capturing(){"always"!==this.config.cookieless_mode?(this.consent.optInOut(!1),this.th(),"on_reject"===this.config.cookieless_mode&&this.eh()):Us.warn(ph)}eh(){var t,i;const e=this.sessionRecording;null==e||e.dispose({discardBufferedEvents:!0}),"$posthog_cookieless"!==this.get_distinct_id()&&this.ed(!0,!0),this.register({distinct_id:vr,$device_id:null}),this.Wc(e),this.sessionRecording=void 0,null===(t=this.sessionManager)||void 0===t||t.destroy(),null===(i=this.pageViewManager)||void 0===i||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Oh(),this.Fh()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return!this.Yc&&("always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.th()}_is_bot(){return e?Uu(e,this.config.custom_blocked_useragents):void 0}Oh(){s&&("visible"===s.visibilityState?this.dh||(this.dh=!0,this.capture(Or,{title:s.title},{send_instantly:!0}),this.fh&&(s.removeEventListener(_n,this.fh),this.fh=null)):this.fh||(this.fh=this.Oh.bind(this),qr(s,_n,this.fh)))}debug(i){!1===i?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}qu(){const t=this.yh||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Us.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(t,i,e,s,n){const r=i in t&&!F(t[i]),o=e in t&&!F(t[e]);return r?t[i]:!!o&&(n&&n.warn(`Config field '${e}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,Us)}Os(t){var i;if(F(this.config.before_send))return t;const e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(L),s=k(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const i of s)try{if(n=i(n),F(n)){const i=`Event '${t.event}' was rejected in beforeSend function`;return j(t.event)?Us.warn(`${i}. This can cause unexpected behavior.`):Us.info(i),null}n.properties&&!C(n.properties)||Us.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(i){return Us.error(`Error in beforeSend function for event '${t.event}':`,i),null}for(const i of e)if(n.properties&&F(n.properties[i]))return Us.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return null===(t=this.pageViewManager.Il)||void 0===t?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}mh(t){const i=N(t)&&!t,e=oo.$t()&&"true"===oo.Ot("ph_debug");return!i&&(!!e||t)}};Ah.__defaultExtensionClasses={},Ah.rd=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(let e=0;i.length>e;e++)t.prototype[i[e]]=Lr(t.prototype[i[e]])}(Ah,["identify"]);var Ih=class{constructor(t){this.disabled=!1===t;const i=P(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(t-s.x)+Math.abs(i-s.y)<this.thresholdPx&&this.timeoutMs>e-s.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}};const Fh="$copy_autocapture",Mh=Bs("[AutoCapture]");function Dh(t,i){return i.length>t?i.slice(0,t)+"...":i}function Nh(t){if(t.previousElementSibling)return t.previousElementSibling;let i=t;do{i=i.previousSibling}while(i&&!Eo(i));return i}function jh(i,{e:e,maskAllElementAttributes:s,maskAllText:n,elementAttributeIgnoreList:r,elementsChainAsString:o,disableCaptureUrlHashes:l}){var a,u;if(!Eo(i))return{props:{}};const h=[i],d=new Set([i]);let c=i;for(;c.parentNode&&!ko(c,"body")&&1e3>h.length;){if(Po(c.parentNode)){const t=c.parentNode.host;if(d.has(t))break;d.add(t),h.push(t),c=t;continue}if(!Eo(c.parentNode))break;if(d.has(c.parentNode))break;d.add(c.parentNode),h.push(c.parentNode),c=c.parentNode}const v="click"===e.type&&"http://www.w3.org/2000/svg"===i.namespaceURI?h.findIndex(t=>ko(t,"button")||ko(t,"a")):-1;v>0&&(n=n||h.slice(0,v+1).some(t=>!Qo(t)||tl(t)));const f=[],p={};let _,g=!1,y=!1;if(Dr(h,t=>{const i=Qo(t);if(ko(t,"a")&&!s&&!(null==r?void 0:r.includes("href"))){const e=t.getAttribute("href");g=!!(i&&e&&al(e))&&(l?vi(e):e)}m(Oo(t),"ph-no-capture")&&(y=!0),f.push(function(t,i,e,s,n=!1){const r=t.tagName.toLowerCase(),o={tag_name:r};Mo.indexOf(r)>-1&&!e&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?Dh(1024,ul(t)):Dh(1024,Io(t)));const l=Oo(t);i||(null==s?void 0:s.includes("class"))||0>=l.length||(o.classes=l.filter(function(t){return""!==t})),Dr(t.attributes,function(e){var r;if((!tl(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&!(null==s?void 0:s.includes(e.name))&&!i&&al(e.value)&&(!O(r=e.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let t=e.value;"class"===e.name&&(t=Co(t).join(" ")),o["attr__"+e.name]=Dh(1024,"href"===e.name&&n?vi(t):t)}});let a=1,u=1,h=t;for(;h=Nh(h);)a++,h.tagName===t.tagName&&u++;return o.nth_child=a,o.nth_of_type=u,o}(t,s,n,r,l)),Dr(function(t){if(!Qo(t))return{};const i={};return Dr(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){const e=t.name.replace("data-ph-capture-attribute-",""),s=t.value;e&&s&&al(s)&&(i[e]=s)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(p,i)||(p[i]=t)})}),y)return{props:{},explicitNoCapture:y};if(v>0&&(i=h[v],f.splice(0,v)),n||(f[0].$el_text=ko(i,"a")||ko(i,"button")?ul(i):Io(i)),g){var b,w;f[0].attr__href=g;const i=null===(b=Al(g))||void 0===b?void 0:b.host,e=null==t||null===(w=t.location)||void 0===w?void 0:w.host;i&&e&&i!==e&&(_=g)}return{props:Nr((x=e.type,{$event_type:x,$ce_version:1}),o?{}:{$elements:f},{$elements_chain:(S=f,k(S)?function(t){return t.map(t=>{var i,e;let s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class){t.attr_class.sort();for(const i of t.attr_class)s+=`.${i.replace(/"/g,"")}`}const n=wi(wi(wi(wi({},t.text?{text:t.text}:{}),{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{}),t.attr_id?{attr_id:t.attr_id}:{}),t.attributes),r={};return jr(n).sort(([t],[i])=>function(t,i){return i>t?-1:t>i?1:0}(t,i)).forEach(([t,i])=>r[dl(t.toString())]=dl(i.toString())),s+=":",s+=jr(r).map(([t,i])=>`${t}="${i}"`).join(""),s}).join(";")}(function(t){return t.map(t=>{var i,e;const s={text:null===(i=t.$el_text)||void 0===i?void 0:i.slice(0,400),tag_name:t.tag_name,href:null===(e=t.attr__href)||void 0===e?void 0:e.slice(0,2048),attr_class:cl(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return jr(t).filter(([t])=>0===t.indexOf("attr__")).forEach(([t,i])=>s.attributes[t]=i),s})}(S)):"")},(null===(a=f[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(u=f[0])||void 0===u?void 0:u.$el_text}:{},_&&"click"===e.type?{$external_click_url:_}:{},p),target:i};var S,x}var Lh=class{tl(){this.el=void 0,clearTimeout(this.il),this.il=void 0}nl(t){var i;if(!Qo(t))return!0;const e=null!==(i=this.sl().css_selector_ignorelist)&&void 0!==i?i:Lo,s=new Set;let n=t;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const t=n,i=Oo(t);if(m(i,"ph-no-capture")||m(i,"ph-sensitive")||tl(t)||e.some(i=>Do(t,i)))return!0;const r=n.parentNode;n=Po(r)?r.host:r&&Eo(r)?r:null}return!1}rl(t){if(!this.isEnabled||"pointercancel"===t.type)return void this.tl();if("pointerdown"===t.type){this.tl();const e=Fo(t);var i;return void(t.isPrimary&&0===t.button&&!t.ctrlKey&&e&&Eo(e)&&(this.el={target:e,excluded:this.nl(e),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null===(i=this.xa)||void 0===i?void 0:i.distinctId}))}const e=this.el;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.tl():"pointerup"===t.type&&(e.released=!0,this.il=setTimeout(()=>this.tl(),0)))}ol(t){var i;const e=this.el;this.tl();const n=Fo(t);if((null==e?void 0:e.released)&&e.target.isConnected&&e.distinctId===(null===(i=this.xa)||void 0===i?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&n&&(ko(n,"html")||ko(n,"body"))){var r;if(e.excluded)return null;const t=null!==(r=this.sl().css_selector_ignorelist)&&void 0!==r?r:Lo;return[n,null==s?void 0:s.documentElement,null==s?void 0:s.body].some(i=>{if(!i)return!1;const e=Oo(i);return m(e,"ph-no-capture")||m(e,"ph-sensitive")||!Qo(i)||tl(i)||t.some(t=>Do(i,t))})?null:e.target}}constructor(t){this.Ta=t,this.name=lh,this.al=!1,this.ll=null,this.ul=!1,this.cl=new Map,this.hl=!1,this.Ar={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ci=!1,this.Ta.refresh(this.Ar),this.rageclicks=new Ih(this.Ar.rageclick),this.dl=null}setup(t){this.vl(),this.xa=t;const i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ci?i.dispose():(this.qa=i,this.startIfEnabled())}dispose(){var t;this.Ci||(this.Ci=!0,this.xa=void 0,null===(t=this.qa)||void 0===t||t.dispose(),this.qa=void 0,this.cl.clear(),this.dl=null,this.fl())}sl(){return this.Ta.refresh(this.Ar),this.Ar}vl(){var t,i;return this.sl(),this.Ar.url_allowlist=null===(t=this.Ar.url_allowlist)||void 0===t?void 0:t.map(t=>new RegExp(t)),this.Ar.url_ignorelist=null===(i=this.Ar.url_ignorelist)||void 0===i?void 0:i.map(t=>new RegExp(t)),this.Ar}pl(){if(!this.isBrowserSupported())return void Mh.info("Disabling Automatic Event Collection because this browser is not supported");if(!t||!s)return;const i=this.gl=i=>{i=i||(null==t?void 0:t.event);try{if("blur"===i.type)return void this.tl();if(0===i.type.indexOf("pointer"))return void this.rl(i);const t="click"===i.type?this.ol(i):void 0;if(I(t))return;this.ml(i,"$autocapture",t)}catch(t){Mh.error("Failed to capture event",t)}};if(qr(t,"blur",i),qr(s,"submit",i,{capture:!0}),qr(s,"change",i,{capture:!0}),qr(s,"click",i,{capture:!0}),Dr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{qr(s,t,i,{capture:!0})}),this.sl().capture_copied_text){const i=this.yl=i=>{i=i||(null==t?void 0:t.event);try{this.ml(i,Fh)}catch(t){Mh.error("Failed to capture clipboard event",t)}};qr(s,"copy",i,{capture:!0}),qr(s,"cut",i,{capture:!0}),qr(s,"paste",i,{capture:!0})}}fl(){this.tl(),this.gl&&(null==t||t.removeEventListener("blur",this.gl),Dr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==s||s.removeEventListener(t,this.gl,!0)}),null==s||s.removeEventListener("submit",this.gl,!0),null==s||s.removeEventListener("change",this.gl,!0),null==s||s.removeEventListener("click",this.gl,!0),this.gl=void 0),this.yl&&(null==s||s.removeEventListener("copy",this.yl,!0),null==s||s.removeEventListener("cut",this.yl,!0),null==s||s.removeEventListener("paste",this.yl,!0),this.yl=void 0),this.al=!1}startIfEnabled(){this.isEnabled||this.tl(),!this.Ci&&this.xa&&this.isEnabled&&!this.al&&(this.pl(),this.al=!0)}onRemoteConfig(t){if(this.Ci)return;if(this.ul=!0,!t.ok)return void this.startIfEnabled();const i=t.config;i.elementsChainAsString&&(this.hl=i.elementsChainAsString);const e=i.autocapture_opt_out;var s;N(e)&&(null===(s=this.xa)||void 0===s||s.kv.set("$autocapture_disabled_server_side",e),this.ll=e),this.startIfEnabled()}setElementSelectors(t,i=this){if(this.Ci)return;t.size?this.cl.set(i,new Set(t)):this.cl.delete(i);const e=new Set;this.cl.forEach(t=>{t.forEach(t=>e.add(t))}),this.dl=e}getElementSelectors(t,i){var e;const n=[];return null===(e=this.dl)||void 0===e||e.forEach(e=>{const r=null==s?void 0:s.querySelectorAll(e);null==r||r.forEach(s=>{t!==s&&i!==s||m(n,e)||n.push(e)})}),n}get isEnabled(){var t,i;if(this.Ci)return!1;const e=null===(t=this.xa)||void 0===t?void 0:t.kv.get(Pn),s=this.ll,n=this.sl();if(!n.remoteRequestsDisabled&&!this.ul)return!1;const r=n.remoteRequestsDisabled&&!this.ul;if(I(s)&&!N(e)&&!r)return!1;const o=null!==(i=this.ll)&&void 0!==i?i:!!e;return!!n.enabled&&!o}ml(i,e="$autocapture",s){if(!this.isEnabled)return void this.tl();let n=s||Fo(i);To(n)&&(n=n.parentNode||null);const r=this.vl();var o;"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent&&r.rageclick&&(null===(o=this.rageclicks)||void 0===o?void 0:o.isRageClick(i.clientX,i.clientY,i.timeStamp||(new Date).getTime()))&&Yo(n,r.rageclick)&&this.ml(i,"$rageclick",s);const l=e===Fh,a=l?wi(wi({},r),{},{dom_event_allowlist:void 0}):r;if(n&&function(t,i,e,s,n,r){var o;if(typeof window>"u"||Zo(t))return!1;if((null==e?void 0:e.url_allowlist)&&!Ro(e.url_allowlist,r))return!1;if((null==e?void 0:e.url_ignorelist)&&Ro(e.url_ignorelist,r))return!1;if(null==e?void 0:e.dom_event_allowlist){const t=e.dom_event_allowlist;if(t&&!t.some(t=>i.type===t))return!1}const{parentIsUsefulElement:l,targetElementList:a}=Xo(t,s);if(!function(t,i){const e=null==i?void 0:i.element_allowlist;if(R(e))return!0;for(const i of t)if(e.some(t=>i.tagName.toLowerCase()===t))return!0;return!1}(a,e))return!1;if(!No(a,null==e?void 0:e.css_selector_allowlist))return!1;if(No(a,null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:Lo))return!1;try{const e=window.getComputedStyle(t);if(e&&"pointer"===e.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}const u=t.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return l?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(Mo.indexOf(u)>-1||"true"===t.getAttribute("contenteditable"))}}(n,i,a,l,l?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var u;const{props:s,explicitNoCapture:o,target:l}=jh(n,{e:i,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.hl,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(o)return!1;const a=this.getElementSelectors(n,l);if(a&&a.length>0&&(s.$element_selectors=a),e===Fh){const e=i.type||"clipboard";if("paste"!==e){var h,d;const i=null==t||null===(h=t.getSelection())||void 0===h?void 0:h.toString(),e=Ao(i);if(!e)return!1;s.$selected_content=e,s.$clipboard_text_length=null!==(d=null==i?void 0:i.length)&&void 0!==d?d:0}s.$copy_type=e}return null===(u=this.xa)||void 0===u||u.capture(e,s),!0}}isBrowserSupported(){return T(null==s?void 0:s.querySelectorAll)}},Uh=class{constructor(t){this._instance=t}refresh(t){const i=this._instance.config,e=P(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.qu(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}};const Bh=Bs("[ExceptionAutocapture]"),zh=()=>{},Hh=t=>{var i;if(T(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function qh(t,i,e){try{if(!(i in t))return zh;const s={next:t[i]},n=e(function(...t){return s.next.apply(this,t)});return T(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),t[i]=n,()=>{if(t[i]===n)return void(t[i]=s.next);let e=t[i],r=Hh(e);for(;r;){if(r.next===n)return void(r.next=s.next);e=r.next,r=Hh(e)}}}catch(t){return zh}}const Vh=Bs("[TracingHeaders]"),Wh=Bs("[Web Vitals]"),Gh=9e5,Kh=["CLS","FCP","INP","LCP"],Jh=["INP","LCP"],Yh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Zh="disabled",Xh="lazy_loading",Qh=Bs("[SessionRecording]"),td=[gr,mr,yr,br,wr,$r,Sr,xr,Er],id=Bs("[Heatmaps]");function ed(t){return P(t)&&"clientX"in t&&"clientY"in t&&M(t.clientX)&&M(t.clientY)}const sd=Bs("[Product Tours]"),nd=t=>{var i;return!t.config.disable_product_tours&&!!(null===(i=t.persistence)||void 0===i?void 0:i.get_property(Mn))},rd=["$set_once","$set"],od=Bs("[SiteApps]"),ld="Error while initializing PostHog app with config id ";function ad(t,i,e){if(F(t))return!1;switch(e){case"exact":return t===i;case"contains":{const e=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(e,"i").test(t)}case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var ud=class{constructor(t){this.Ai=t,this._o=new Set,this.wo=new Set,this.ko=new Du,this.So=(t,i)=>this.xo(t,i)&&this.$o(t,i)&&this.Co(t,i)&&this.To(t,i),this.xo=(t,i)=>!(null==i?void 0:i.event)||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;R(null===(t=this.Ai)||void 0===t?void 0:t.subscribeCapture)||(this.Io=null===(i=this.Ai)||void 0===i?void 0:i.subscribeCapture((t,i)=>{this.on(t,i)}))}dispose(){var t,i,e;null===(t=this.Io)||void 0===t||t.call(this),this.Io=void 0,null===(i=this.Ai)||void 0===i||null===(e=i.setElementSelectors)||void 0===e||e.call(i,new Set,this),this.ko=new Du}register(t){var i,e;if(!R(null===(i=this.Ai)||void 0===i?void 0:i.subscribeCapture)&&(t.forEach(t=>{var i;this._o.add(t),null===(i=t.steps)||void 0===i||i.forEach(t=>{this.wo.add((null==t?void 0:t.event)||"")})}),null===(e=this.Ai)||void 0===e?void 0:e.setElementSelectors)){const t=new Set;this._o.forEach(i=>{var e;null===(e=i.steps)||void 0===e||e.forEach(i=>{(null==i?void 0:i.selector)&&t.add(i.selector)})}),this.Ai.setElementSelectors(t,this)}}replace(t){this._o.clear(),this.wo.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.wo.has(t)||this.wo.has(i.event))&&this._o.forEach(t=>{this.Mo(i,t)&&this.ko.emit("actionCaptured",t.name)})}Eo(t){this.onAction("actionCaptured",i=>t(i))}Mo(t,i){if(null==(null==i?void 0:i.steps))return!1;for(const e of i.steps)if(this.So(t,e))return!0;return!1}onAction(t,i){return this.ko.on(t,i)}$o(t,i){if(null==i?void 0:i.url){var e;const s=null==t||null===(e=t.properties)||void 0===e?void 0:e.$current_url;if(!s||"string"!=typeof s)return!1;if(!ad(s,i.url,i.url_matching||"contains"))return!1}return!0}Co(t,i){return!!this.Po(t,i)&&!!this.Ro(t,i)&&!!this.Ao(t,i)}Po(t,i){var e;if(!(null==i?void 0:i.href))return!0;const s=this.Fo(t);if(s.length>0)return s.some(t=>ad(t.href,i.href,i.href_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&ad(function(t){const i=t.match(/(?::|")href="(.*?)"/);return i?i[1]:""}(n),i.href,i.href_matching||"exact")}Ro(t,i){var e;if(!(null==i?void 0:i.text))return!0;const s=this.Fo(t);if(s.length>0)return s.some(t=>ad(t.text,i.text,i.text_matching||"exact")||ad(t.$el_text,i.text,i.text_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&(r=function(t){const i=[],e=/(?::|")text="(.*?)"/g;let s;for(;!F(s=e.exec(t));)i.includes(s[1])||i.push(s[1]);return i}(n),o=i.text,l=i.text_matching||"exact",r.some(t=>ad(t,o,l)));var r,o,l}Ao(t,i){var e,s;if(!(null==i?void 0:i.selector))return!0;const n=null==t||null===(e=t.properties)||void 0===e?void 0:e.$element_selectors;if(null==n?void 0:n.includes(i.selector))return!0;const r=(null==t||null===(s=t.properties)||void 0===s?void 0:s.$elements_chain)||"";if(i.selector_regex&&r)try{return new RegExp(i.selector_regex).test(r)}catch(t){}return!1}Fo(t){var i;return null==(null==t||null===(i=t.properties)||void 0===i?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}To(t,i){return!(null==i?void 0:i.properties)||0===i.properties.length||Gu(i.properties.reduce((t,i)=>{const e=k(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},hd=class{constructor(t,i){this.Oo=i,this.Do=[],this.Ai=t,this.Lo=new Map,this.No=new Map,this.qo=new Map}jo(){var t,i;this.Bo=null===(t=(i=this.Ai).subscribeSession)||void 0===t?void 0:t.call(i,t=>this.zo(t))}Ho(t){return!1}Uo(){return null}Wo(t){}Vo(){}Go(t,i){return!!t&&Gu(t.propertyFilters,null==i?void 0:i.properties)}Qo(t,i){const e=new Map;return t.forEach(t=>{var s;null===(s=t.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(i=>{if(null==i?void 0:i.name){const s=e.get(i.name)||[];s.push(t.id),e.set(i.name,s)}})}),e}Zo(t,i,e){const s=(e===ha.Activation?this.Lo:this.No).get(t);let n=[];return this.Jo(t=>{n=t.filter(t=>null==s?void 0:s.includes(t.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[e])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(i=>i.name===t);return this.Go(r,i)})}register(t){this.Ko(t,!1)}replace(t){this.Ko(t,!0)}Ko(t,i){R(this.Ai.subscribeCapture)||(this.Xo(t,i),this.Yo(t,i))}Yo(t,i){const e=t.filter(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length});var s;if(i&&this.qo.clear(),0===e.length)return void(i&&(null===(s=this.ta)||void 0===s||s.replace([])));this.ta||(this.ta=new ud(this.Ai),this.ta.init(),this.ta.Eo(t=>this.onAction(t)));const n=[];e.forEach(t=>{var i;null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||i.values.forEach(i=>{if(n.push(i),i.name){var e;const s=null!==(e=this.qo.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.qo.set(i.name,s)}})}),i?this.ta.replace(n):this.ta.register(n)}ea(t,i){i.forEach((i,e)=>{var s;const n=null!==(s=t.get(e))&&void 0!==s?s:[];i.forEach(t=>{n.includes(t)||n.push(t)}),t.set(e,n)})}Xo(t,i){var e,s,n;const r=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.events)&&(null===(e=t.conditions)||void 0===e||null===(e=e.events)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),o=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.cancelEvents)&&(null===(e=t.conditions)||void 0===e||null===(e=e.cancelEvents)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),l=this.Qo(t,ha.Activation),a=this.Qo(t,ha.Cancellation);i?(this.Lo=l,this.No=a):(this.ea(this.Lo,l),this.ea(this.No,a)),(0!==r.length||0!==o.length||t.some(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length}))&&(null!==(e=this.Io)&&void 0!==e||(this.Io=null===(s=(n=this.Ai).subscribeCapture)||void 0===s?void 0:s.call(n,(t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,s;const n=this.ia(),r=(null==i||null===(e=i.properties)||void 0===e?void 0:e.$survey_id)||(null==i||null===(s=i.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const e=this.na(t,r,i);if("consume"===e)return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.sa([r]);if("persist"===e)return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.ra(r),void this.oa([r])}if(this.No.has(t)){const e=this.Zo(t,i,ha.Cancellation);e.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:e.map(t=>t.id)}),this.sa(e.map(t=>t.id)),e.forEach(t=>this.aa(t.id)))}if(!this.Lo.has(t))return;n.info("event name matched",{event:t,eventPayload:i,items:this.Lo.get(t)});const o=this.Zo(t,i,ha.Activation);this.la(o.map(t=>t.id))}onAction(t){this.qo.has(t)&&this.la(this.qo.get(t)||[])}la(t){if(0===t.length)return;const i=!!this.Ai.getSessionId(),e=[];for(const s of t)i&&this.Ho(s)?this.ra(s)&&this.ua(s):e.push(s);e.length>0&&(this.Do=[...new Set([...this.Do,...e])]),this.ia().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.ca()}ra(t){this.Do=this.Do.filter(i=>i!==t);const i=this.ha();return!i.includes(t)&&(this.da([...i,t]),this.va(),!0)}sa(t){const i=new Set(t);this.Do=this.Do.filter(t=>!i.has(t));const e=this.fa(),s=e.filter(t=>!i.has(t));s.length!==e.length&&(this.da(s),0===s.length&&this.pa()),this.oa(t),this.ca()}ca(){try{var t;null===(t=this.Oo)||void 0===t||t.call(this)}catch(t){this.ia().error("Error while handling activated items change",t)}}ga(){const t=this.Uo();if(!t)return{};const i=this.Ai.getProperty(t);return i&&"object"==typeof i?i:{}}ua(t){if(!this.Uo())return;const i=this.ga();this.Wo(wi(wi({},i),{},{[t]:Date.now()}))}oa(t){if(!this.Uo())return;const i=this.ga(),e={};let s=!1;for(const[n,r]of Object.entries(i))t.includes(n)?s=!0:e[n]=r;s&&(C(e)?this.Vo():this.Wo(e))}ma(){this.Uo()&&this.Vo()}getActivationTimestamp(t){if(!this.ha().includes(t))return;const i=this.ga()[t];return M(i)?i:void 0}fa(){const t=this.ya();return this.Ai.getProperty(t)||[]}ha(){const t=this.fa();if(0===t.length)return[];const i=this.Ai.getProperty(this.ba()),e=this.Ai.getSessionId();return e&&i===e?t:[]}va(){const t=this.Ai.getSessionId();t&&this._a(t)}pa(){this.wa()}zo(t){const i=this.Ai.getProperty(this.ba());if(i&&i!==t){const t=this.fa(),i=this.ga();t.length>0&&(this.da([]),t.filter(t=>M(i[t])).forEach(t=>this.aa(t))),this.pa(),this.ma(),t.length>0&&this.ca()}}getActivatedIds(){return[...new Set([...this.ha(),...this.Do])].filter(t=>!this.ka(t))}dispose(){var t,i,e;null===(t=this.Bo)||void 0===t||t.call(this),this.Bo=void 0,null===(i=this.Io)||void 0===i||i.call(this),this.Io=void 0,null===(e=this.ta)||void 0===e||e.dispose(),this.ta=void 0}reset(){this.Do=[],this.fa().length>0&&this.da([]),this.pa(),this.ma(),this.ca()}getEventToItemsMap(){return this.Lo}Sa(){return this.ta}},dd=class extends hd{constructor(t,i,e){super({subscribeCapture(i){const e=t.onEvent(t=>i(t.event,t));return()=>e.dispose()},subscribeSession(i){const e=t.onSession(i);return()=>e.dispose()},getSessionId(){var i;return null===(i=t.session)||void 0===i?void 0:i.sessionId},getProperty:i=>t.kv.get(i),setElementSelectors(i,e){var s;return null===(s=t.getExtension("autocapture"))||void 0===s?void 0:s.setElementSelectors(i,e)}},e),this.xa=t,this.$a=i,this.jo()}ya(){return Zs}ba(){return Xs}Uo(){return Qs}Wo(t){this.xa.kv.set({[Qs]:t})}Vo(){this.xa.kv.remove(Qs)}Ho(t){var i;let e;this.Jo(i=>{e=i.find(i=>i.id===t)});const s=null==e||null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds;return M(s)&&s>0}Ca(){return ma.SHOWN}Jo(t){this.$a.getSurveys(t)}aa(t){this.$a.cancelPendingSurvey(t)}ia(){return th}da(t){this.xa.kv.set({[Zs]:t})}_a(t){this.xa.kv.set({[Xs]:t})}wa(){this.xa.kv.remove(Xs)}ka(){return!1}na(t,i,e){var s;if(t===ma.SENT&&!1===(null==e||null===(s=e.properties)||void 0===s?void 0:s.$survey_completed))return"ignore";let n;return this.Jo(t=>{n=t.find(t=>t.id===i)}),!n||function(t){var i;return Hu(t)&&!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i?void 0:i.repeatedActivation)||"always"===t.schedule}(n)?t===ma.SHOWN?"consume":"ignore":t===ma.SHOWN?"persist":t===ma.DISMISSED||t===ma.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const cd=(t,i)=>(null==t?void 0:t.then)?t.then(i):i(t),vd="SDK is not enabled or survey functionality is not yet loaded",fd="Disabled. Not loading surveys.";var pd=class{constructor(t){this.Ta=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Ia=!1,this.Ma=!1,this.Ea=[],this.Pa=[],this.Ra=null,this.Aa=null,this.Ci=!1,this.Fa=new Set,this.onRemoteConfig=t=>{if(this.Ci)return;if(this.Ar.disableSurveys)return;if(!t.ok)return this.Ma=!0,this.Oa({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),th.warn("Remote config unavailable. Not loading surveys.");const i=t.config.surveys;if(F(i))return th.warn("Flags not loaded yet. Not loading surveys.");this.Da=N(i)?i:i.length>0,th.info(`flags response received, isSurveysEnabled: ${this.Da}`),this.loadIfEnabled()},this.Oa=t=>{this.Pa.slice().forEach(i=>this.La(i,t))}}setup(t){if(!this.Ci)return this.Na=t,cd(t.kv.initialize(),()=>{if(this.Na!==t||this.Ci)return;this.Na=void 0,this.xa=t;const i=t.onRemoteConfig(this.onRemoteConfig);this.Ci?i.dispose():(this.qa=i,this.loadIfEnabled())})}dispose(){var t,i,e,s,n;this.Ci||(this.Ci=!0,this.Na=void 0,this.xa=void 0,null===(t=this.qa)||void 0===t||t.dispose(),this.qa=void 0,null===(i=this._surveyEventReceiver)||void 0===i||i.dispose(),this._surveyEventReceiver=null,null===(e=this._surveyManager)||void 0===e||null===(s=e.dispose)||void 0===s||s.call(e),this._surveyManager=null,this.Ea=[],this.Pa.forEach(t=>{t.active=!1}),this.Pa=[],null===(n=this.ja)||void 0===n||n.call(this),this.ja=void 0,this.Ra=null,this.Fa.forEach(t=>clearTimeout(t)),this.Fa.clear())}get Ar(){return this.Ta.get()}getRenderContext(){if(!this.xa)return;const t=this;return{client:this.xa,get config(){return t.Ar},surveys:t}}initialize(){this.loadIfEnabled()}reset(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.clearInMemoryInProgressSurveyState)||void 0===i||i.call(t);try{var e;null===(e=this._surveyEventReceiver)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let i=0;i<localStorage.length;i++){const e=localStorage.key(i);((null==e?void 0:e.startsWith("seenSurvey_"))||(null==e?void 0:e.startsWith("inProgressSurvey_")))&&t.push(e)}t.forEach(t=>localStorage.removeItem(t))}catch(t){}this.Oa()}loadIfEnabled(){if(this.Ci||!this.xa)return;const t=this.Ar;if(this._surveyManager)return;if(this.Ia)return void th.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void th.info(fd);if(t.cookielessMode&&this.xa.isOptedOut)return void th.info("Not loading surveys in cookieless mode without consent.");const i=this.Ta.getExtensions();if(!i)return void this.Ba("PostHog Extensions not found.");if(R(this.Da)&&!t.advancedEnableSurveys)return;const e=this.Da||t.advancedEnableSurveys;this.Ia=!0,this.Ma=!1;try{const t=i.generateSurveys;if(t)return this.za(t,e),void(this.Ia=!1);const s=i.loadExternalDependency;if(!s)return this.Ba(Ys),void(this.Ia=!1);s(t=>{try{if(this.Ci)return;const i=this.Ta.getExtensions();t||!(null==i?void 0:i.generateSurveys)?this.Ba("Could not load surveys script",t):this.za(i.generateSurveys,e)}finally{this.Ia=!1}})}catch(t){throw this.Ia=!1,this.Ba("Error initializing surveys",t),t}}za(t,i){var e;if(this.Ci)return;this._surveyManager=t(i),this._surveyEventReceiver=new dd(this.xa,this,this.Oa);const s=null===(e=this.xa)||void 0===e?void 0:e.kv.get(Ks);s&&this.Ha(s),th.info("Surveys loaded successfully"),this.Ua(),this.Oa(),this.Wa({isLoaded:!0})}Ba(t,i){this.Ma=!0,th.error(t,i),this.Oa({isLoaded:!1,error:t}),this.Wa({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ea.push(t),this._surveyManager&&this.Wa({isLoaded:!0}),()=>{this.Ea=this.Ea.filter(i=>i!==t)}}getSurveys(t,i=!1){if(this.Ci)return;const e=this.xa;if(!e)return t([],{isLoaded:!1,error:vd});if(this.Ar.disableSurveys)return th.info(fd),t([]);const s=e.kv.get(Ks);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Va()&&this.getSurveys(()=>{},!0));if(this.Ra)return void this.Ra.then(({surveys:i,context:e})=>{this.Ci||t(i,e)}).catch(t=>th.error("Error in survey callback",t));const n=e.sendRequest("/api/surveys/",{method:"GET",query:{token:e.projectToken},sentAt:"query",timeoutMs:this.Ar.requestTimeoutMs}).then(t=>{try{return this.Ga(e,t)}catch(t){return th.error("Error processing surveys response",t),this.Ga(e,{statusCode:0,error:t})}},t=>this.Ga(e,{statusCode:0,error:t}));this.Ra=n;const r=()=>{this.Ra===n&&(this.Ra=null)};n.then(i=>{r(),this.Ci||(this.Oa(i.context),t(i.surveys,i.context))},r).catch(t=>th.error("Error in survey callback",t))}Ga(t,i){if(this.Ci)return{surveys:[],context:{isLoaded:!1,error:vd}};const e=i.statusCode;if(200!==e||!i.json){const t=`Surveys API could not be loaded, status: ${e}`;return 0!==e?th.error(t):i.error||th.warn(t),this.Aa=Date.now(),{surveys:[],context:{isLoaded:!1,error:t}}}this.Aa=null;const s=i.json.surveys||[];return t.kv.set({[Ks]:s,[Js]:Date.now()}),this.Ha(s),{surveys:s,context:{isLoaded:!0}}}Ha(t){var i;const e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Hu(t)||function(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}(t)));null===(i=this._surveyEventReceiver)||void 0===i||i.replace(e)}Va(){return this.Qa()&&!this.Ra&&!this.Za()}Qa(){var t;const i=null===(t=this.xa)||void 0===t?void 0:t.kv.get(Js);return M(i)&&Date.now()-i>3e5}Za(){return M(this.Aa)&&3e5>Date.now()-this.Aa}markSurveyAsSeen(t,i){var e;const s={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};ih(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Oa()}Wa(t){for(const i of this.Ea){if(this.Ci)return;try{t.isLoaded?this.getSurveys(i):i([],t)}catch(t){th.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,i=!1){if(!F(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);th.warn("init was not called")}onActiveMatchingSurveysChanged(t){var i;if(this.Ci)return()=>{};const e={callback:t,active:!0,revision:0};this.Pa.push(e),this.Ua();const s=null===(i=this.xa)||void 0===i?void 0:i.kv.get(Ks);return this.Ar.disableSurveys||!this._surveyManager&&this.Ma&&!this.Ia||!s&&!F(this.Aa)&&!this.Ra?this.La(e,{isLoaded:!1}):this._surveyManager&&this.La(e),()=>{var t;e.active=!1,this.Pa=this.Pa.filter(t=>t!==e),0===this.Pa.length&&(null===(t=this.ja)||void 0===t||t.call(this),this.ja=void 0)}}Ua(){var t,i,e;this._surveyManager&&this.Pa.length>0&&(null!==(t=this.ja)&&void 0!==t||(this.ja=null===(i=(e=this.Ta).onMatchingConditionsChanged)||void 0===i?void 0:i.call(e,this.Oa)))}La(t,i){if(this.Ci||!t.active)return;const e=++t.revision,s=s=>{if(!this.Ci&&t.active&&e===t.revision)try{const e=null!=i?i:{isLoaded:!0},n=JSON.stringify([s,e]);if(n===t.lastResult)return;t.lastResult=n,t.callback(s,e)}catch(t){th.error("Error in active matching surveys callback",t)}};try{i&&!i.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(t){th.error("Error in active matching surveys callback",t)}}Ja(t){let i=null;return this.getSurveys(e=>{var s;i=null!==(s=e.find(i=>i.id===t))&&void 0!==s?s:null}),i}Ka(t){if(F(this._surveyManager))return{eligible:!1,reason:vd};const i="string"==typeof t?this.Ja(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Xa(t){var i;if(!(null===(i=this.xa)||void 0===i?void 0:i.canCapture))return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(F(this._surveyManager))return{eligible:!1,reason:vd};const e="string"==typeof t?this.Ja(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(F(this._surveyManager))return th.warn("init was not called"),{visible:!1,disabledReason:vd};const i=this.Xa(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return F(this._surveyManager)?(th.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:vd})):new Promise(e=>{this.getSurveys(i=>{var s;const n=null!==(s=i.find(i=>i.id===t))&&void 0!==s?s:null;if(n){const t=this.Xa(n);e({visible:t.eligible,disabledReason:t.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var s,n,r;if(!(null===(s=this.xa)||void 0===s?void 0:s.canCapture))return;if(F(this._surveyManager))return void th.warn("init was not called");const o="string"==typeof t?this.Ja(t):t;if(!(null==o?void 0:o.id))return void th.warn("Survey not found");if(!eh.includes(o.type))return void th.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const l=null===(n=typeof document>"u"?void 0:document)||void 0===n?void 0:n.querySelector(i);if(l){if(null===(r=o.appearance)||void 0===r?void 0:r.surveyPopupDelaySeconds){th.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const t=setTimeout(()=>{var i,s,n;this.Fa.delete(t),!this.Ci&&(null===(i=this.xa)||void 0===i?void 0:i.canCapture)&&(th.info(`Rendering survey ${o.id} with delay of ${null===(s=o.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds} seconds`),null===(n=this._surveyManager)||void 0===n||n.renderSurvey(o,l,e),th.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this.Fa.add(t)}this._surveyManager.renderSurvey(o,l,e)}else th.warn("Survey element not found")}displaySurvey(t,i){var e,s;if(!(null===(e=this.xa)||void 0===e?void 0:e.canCapture))return;if(F(this._surveyManager))return void th.warn("init was not called");const n=this.Ja(t);if(!n)return void th.warn("Survey not found");let r=n;if((null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds)&&i.ignoreDelay&&(r=wi(wi({},n),{},{appearance:wi(wi({},n.appearance),{},{surveyPopupDelaySeconds:0})})),i.displayType!==ba.Popover&&i.initialResponses&&th.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){const t=this.Ka(n);if(!t.eligible)return void th.warn("Survey is not eligible to be displayed: ",t.reason)}i.displayType!==ba.Inline?this._surveyManager.handlePopoverSurvey(r,i):this.renderSurvey(r,i.selector,i.properties)}cancelPendingSurvey(t){F(this._surveyManager)?th.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t)}},_d=class{constructor(t){this._instance=t}get(){var t,i,e,s;const n=null===(t=this._instance)||void 0===t?void 0:t.config;return{disableSurveys:!!(null==n?void 0:n.disable_surveys),cookielessMode:!!(null==n?void 0:n.cookieless_mode),advancedEnableSurveys:!!(null==n?void 0:n.advanced_enable_surveys),requestTimeoutMs:null!==(i=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==i?i:1e4,prefillFromUrl:!!(null==n||null===(e=n.surveys)||void 0===e?void 0:e.prefillFromUrl),automaticDisplay:!(null==n?void 0:n.disable_surveys_automatic_display),featureFlagEvaluation:!(null==n?void 0:n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null===(s=this._instance)||void 0===s||null===(s=s.requestRouter)||void 0===s?void 0:s.endpointFor("ui","")}}getExtensions(){const t=null==d?void 0:d.__PosthogExtensions__;if(!t||!this._instance)return;const i=this._instance,{generateSurveys:e,loadExternalDependency:s}=t;return{generateSurveys:e?t=>e(i,t):void 0,loadExternalDependency:s?t=>s(i,"surveys",t):void 0}}onMatchingConditionsChanged(i){var e,s;const n=null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook(t=>{"$pageview"!==t&&t!==ma.SHOWN&&t!==ma.DISMISSED&&t!==ma.SENT||i()}),r=()=>i();qr(t,"PHSurveyShown",r);let o=!1;const l=null===(s=this._instance)||void 0===s?void 0:s.onFeatureFlags(()=>{o&&i()});return o=!0,()=>{o=!1,null==n||n(),null==l||l(),null==t||t.removeEventListener("PHSurveyShown",r)}}};const gd=(null==t?void 0:t.location)?Ml(t.location.hash,"__posthog")||Ml(location.hash,"state"):null,md="_postHogToolbarParams",yd=Bs("[Toolbar]"),bd=Bs("[FeatureFlags]"),wd=Bs("[FeatureFlags]",{debugEnabled:!0}),$d="\" failed. Feature flags didn't load in time.",Sd=[502,504],xd=["click","keydown","wheel","touchstart","pointerdown"],Ed="connection_error",kd=t=>{const i={};for(let e=0;t.length>e;e++)i[t[e]]=!0;return i},Td=t=>{const i={};for(const[e,s]of jr(t||{}))s&&(i[e]=s);return i};var Pd=class{constructor(t){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.$=bd,this.ld={},this.ud={},this.hd=[],this.dd=new Set,this.vd=new Set,this.fd=!1,this.pd=!1,this.gd=0,this.md=!1,this.yd=!1,this.bd=!1,this._d=!1,this.wd=!1,this.kd=0,this.Sd=!1,this.rn=()=>{const t=this.xd();this.kd=0,t&&this.reloadFeatureFlags()},this.$d=()=>{var t,i;const e=this.Cd,s=null!==(t=this.Td)&&void 0!==t?t:e;R(e)||R(s)||this.Ar.remoteRequestsDisabled||!this.Id||"hidden"===this.Id.visibilityState||Date.now()-(null!==(i=this.Md)&&void 0!==i?i:0)<s||(this.Td=this.Sd||!this.Ar.idleRefreshBackoff?e:Math.min(2*s,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Ed())},this.Pd=()=>{this.Sd&&this.Td===this.Cd||this.Rd()},this.sn=()=>{var t;"visible"===(null===(t=this.Id)||void 0===t?void 0:t.visibilityState)&&this.Rd()},this.Ta=t}get Ad(){}Fd(){this.xa&&this.Od()}setup(t){try{this.Dd=typeof window>"u"?void 0:window,this.Id=typeof document>"u"?void 0:document}catch(t){this.Dd=void 0,this.Id=void 0}return this.Na=t,this.$=t.logger.createLogger("[FeatureFlags]"),cd(t.kv.initialize(),()=>{this.Na===t&&(this.Na=void 0,this.xa=t,this.Ld(t))})}Ld(t){var i;if(this.xa===t)return this.Dd&&qr(this.Dd,"online",this.rn),this.Od(),this.Nd=t.registerDynamicEventProperties(()=>this.qd()?this.ld:this.ud),this.jd=null===(i=this.Ad)||void 0===i?void 0:i.onCrossTabFeatureFlagChange(()=>{this.Bd(),this.zd(),this.Hd()}),this.zd(),this.initialize()}Rd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Od(){var t;const i=this.Ar.refreshIntervalMs,e=!this.Ar.remoteRequestsDisabled&&this.Id&&!R(i)&&i>0?i:void 0;this.Ar.idleRefreshBackoff||(this.Td=e),e!==this.Cd&&(this.Ud(),R(e)||(this.Cd=e,this.Td=e,this.Ed(),(null===(t=this.Id)||void 0===t?void 0:t.addEventListener)&&(qr(this.Id,_n,this.sn),Mr(xd,t=>{qr(this.Id,t,this.Pd,{capture:!0})}))))}Ed(){R(this.Cd)||(R(this.Wd)||clearInterval(this.Wd),this.Md=Date.now(),this.Wd=setInterval(this.$d,this.Cd))}Ud(){var t,i;R(this.Wd)||(clearInterval(this.Wd),this.Wd=void 0,null===(t=this.Id)||void 0===t||null===(i=t.removeEventListener)||void 0===i||i.call(t,"visibilitychange",this.sn),Mr(xd,t=>{var i,e;null===(i=this.Id)||void 0===i||null===(e=i.removeEventListener)||void 0===e||e.call(i,t,this.Pd,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Md=void 0}destroy(){this.Vd()}dispose(){this.Vd()}Vd(){var t,i,e;this.Ud(),this.gd++,this.yd=!1,this.Na=void 0,this.Gd(this.dd,"cancelled"),this.Gd(this.vd,"cancelled"),this.xa&&(this.Qd(),null===(t=this.Nd)||void 0===t||t.dispose(),this.Nd=void 0,null===(i=this.jd)||void 0===i||i.call(this),this.jd=void 0,this.hd=[],null===(e=this.Dd)||void 0===e||e.removeEventListener("online",this.rn),this.xa=void 0)}get Ar(){return this.Ta.get()}Zd(t){var i;return this.Jd&&t in this.Jd?this.Jd[t]:null===(i=this.xa)||void 0===i?void 0:i.kv.get(t)}Bd(){return!!this.Jd&&(this.Jd=void 0,!0)}Kd(){var t;return!R(null===(t=this.xa)||void 0===t?void 0:t.kv.get("$enabled_feature_flags"))&&this.Bd()}At(t){this.Xd(()=>{var i;return null===(i=this.xa)||void 0===i?void 0:i.kv.set(t)})}Yd(t,i,e){if(!this.Ad||!t.$enabled_feature_flags)return;const s=this.Zd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},r=i.flags||i.featureFlags,o=i.flags?Object.entries(i.flags).filter(([,t])=>!(null==t?void 0:t.failed)).map(([t])=>t):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,a=l?o:e&&!k(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),u=this.Zd("$feature_flag_payloads")||{},h=t.$feature_flag_payloads||{},d=l||e?a:Array.from(new Set([...Object.keys(u),...Object.keys(h)])),c=!l&&!e,v=!!c||a,f=!!c||d,p={[en]:v,[an]:v,[vn]:f};t.$feature_flag_details&&(p[sn]=v);for(const i of[on,rn,ln])R(t[i])||(p[i]=!0);this.Ad.markCrossTabFeatureFlagChanges(p)}Pt(t){this.Xd(()=>{var i;return null===(i=this.xa)||void 0===i?void 0:i.kv.remove(t)})}Xd(t){try{t()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}zd(){const t={};for(const i of[en,vn,on,fn]){const e=this.Zd(i);R(e)||(t[i]=e)}this.ld=t;const i=wi({},t),e=this.Zd(an);if(e)for(const[t,s]of Object.entries(e))i[`$feature/${t}`]=s;this.ud=i}qd(){const t=this.Ar.cacheTtlMs;if(!t||0>=t)return!1;const i=this.Zd(rn);return"number"!=typeof i||Date.now()-i>t}tv(){return!!this.qd()&&(this.wd||this.pd||(this.wd=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ev(){const t=this.Ar.evaluationContexts;return(null==t?void 0:t.length)?t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}iv(){const t=this.Ar.flagKeys;if(!R(t))return t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i;const e=this.Ar,s=null!==(t=null===(i=e.bootstrap)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(s).length){var n,r;const t=null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},i=Object.keys(s).filter(t=>!R(s[t])).reduce((t,i)=>(t[i]=s[i],t),{}),o=Object.keys(t).filter(t=>i[t]).reduce((i,e)=>(i[e]=t[e],i),{});return this.nv({featureFlags:i,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n;const r=(null==e?void 0:e.merge)&&null!==(s=this.Zd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==e?void 0:e.merge)&&null!==(n=this.Zd("$feature_flag_payloads"))&&void 0!==n?n:{},l=wi(wi({},r),t),a=wi(wi({},o),i),u={};for(const[t,i]of Object.entries(l))u[t]={key:t,enabled:fe(i),variant:pe(i),reason:void 0,metadata:R(null==a?void 0:a[t])?void 0:{id:0,version:void 0,description:void 0,payload:a[t]}};this.nv({flags:u})}get hasLoadedFlags(){return this.fd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.Zd(sn),i=this.Zd(fn),e=this.Zd(pn);if(!e&&!i)return t||{};const s=Nr({},t||{}),n=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(const t of n){var r,o;const n=s[t],l=null==i?void 0:i[t],a=R(l)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!l,u=R(l)?null==n?void 0:n.variant:"string"==typeof l?l:void 0,h=null==e?void 0:e[t],d=wi(wi({},n),{},{enabled:a,variant:a?null!=u?u:null==n?void 0:n.variant:void 0});a!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),u!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),h&&(d.metadata=wi(wi({},null==n?void 0:n.metadata),{},{payload:h,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[t]=d}return this.ad||(this.$.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.ad=!0),s}getAllFeatureFlags(){const t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{const s=t[e];return{key:e,enabled:fe(s),variant:pe(s),payload:ve(i[e])}})}getFlagVariants(){const t=this.Zd(an),i=this.Zd(fn);if(!i)return t||{};const e=Nr({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ad||(this.$.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.ad=!0),e}getFlagPayloads(){const t=this.Zd(vn),i=this.Zd(pn);if(!i)return t||{};const e=Nr({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ad||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.ad=!0),e}reloadFeatureFlags(){this.md||this.Ar.featureFlagsDisabled||this.xd()||(this.bd&&this.$.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this.pd&&(this.yd=!0),this.sv||(this.hd.slice().forEach(t=>{try{t()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.sv=setTimeout(()=>{this.rv()},5)))}reloadFeatureFlagsAsync(){return!this.xa||this.md||this.Ar.featureFlagsDisabled||this.Ar.remoteRequestsDisabled||this.xd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.dd.add(t),this.reloadFeatureFlags()})}Gd(t,i){t.forEach(t=>t({status:i})),t.clear()}Qd(){clearTimeout(this.sv),this.sv=void 0}onReloading(t){return this.hd.push(t),()=>{this.hd=this.hd.filter(i=>i!==t)}}ensureFlagsLoaded(){this.fd||this.pd||this.sv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.md=t}resetFlagCallReported(){this.Pt(dn)}rv(t){var i;this.Qd();const e=this.xa;if(!e||this.Ar.remoteRequestsDisabled||this.xd())return void this.Gd(this.dd,"skipped");if(this.pd)return void(this.yd=!0);const s={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:wi(wi(wi({},e.initialPersonProperties),this.Zd("$stored_person_properties")||{}),{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Zd(un),timezone:Tl()};R(e.deviceId)||(s.$device_id=e.deviceId),((null==t?void 0:t.disableFlags)||this.Ar.featureFlagsDisabled)&&(s.disable_flags=!0);const n=this.ev();n.length&&(s.evaluation_contexts=n);const r=this.iv();R(r)||(s.flag_keys=r);const o=this.Ar.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),a=this.gd,u=this.dd;this.dd=new Set,this.vd=u,this.pd=!0;const h=()=>{this.yd&&(this.yd=!1,this.rv())},d=t=>{var i,e;const n=null!==(i=t.json)&&void 0!==i?i:{},r=200!==t.statusCode;if(this.pd=!1,a!==this.gd)return void h();if(this.ov(t.statusCode),r||this.yd||(this.$anon_distinct_id=void 0),s.disable_flags&&!this.yd)return void this.Gd(u,"skipped");this._d=!r;const l=[];t.error?l.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ed:"unknown_error"):200!==t.statusCode&&l.push(`api_error_${t.statusCode}`),n.errorsWhileComputingFlags&&l.push("errors_while_computing_flags");const d=!!(null===(e=n.quotaLimited)||void 0===e?void 0:e.includes("feature_flags"));d&&l.push("quota_limited"),this.At({[nn]:l}),d?this.$.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):s.disable_flags||this.nv(n,r,{partialResponse:o}),this.Gd(u,s.disable_flags?"skipped":l.length||!n.flags&&!n.featureFlags?"error":"loaded"),h()},c=t=>{this.pd=!1,a===this.gd?(this.At({[nn]:[Ed]}),this.$.error("Feature flag request failed",t),this.Kd()&&this.Hd(!0),this.Gd(u,"error"),h()):h()};let v=null!==(i=this.Ar.requestMaxRetries)&&void 0!==i?i:1;const f=()=>v>0&&a===this.gd,p=()=>{if(a!==this.gd||!this.xa||this.Ar.remoteRequestsDisabled)return this.pd=!1,this.Gd(u,"skipped"),void h();try{e.sendRequest(l,{target:"flags",method:"POST",body:s,compression:this.Ar.compression,sentAt:"body",timeoutMs:this.Ar.requestTimeoutMs}).then(t=>{if((t=>Sd.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&f())return v--,void setTimeout(p,500);d(t)}).catch(c)}catch(t){c(t)}};p()}xd(){return Cl(this.kd,3)}ov(t){this.kd=Rl(t,this.kd,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i={}){var e;if(i.fresh&&!this._d)return;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+t+$d);if(this.tv())return;const s=this.getFeatureFlagResult(t,i);return null!==(e=null==s?void 0:s.variant)&&void 0!==e?e:null==s?void 0:s.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i={}){if(i.fresh&&!this._d)return;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+t+$d);if(this.tv())return;const e=this.getFlagVariants(),s=t in e,n=e[t],r=this.getFlagPayloads()[t],o=String(n),l=this.Zd("$feature_flag_request_id")||void 0,a=this.Zd("$feature_flag_evaluated_at")||void 0;let u,h=this.Zd("$flag_call_reported")||{};if(this.Ar.deduplicateCallsPerSession){var d;const t=null===(d=this.xa)||void 0===d||null===(d=d.session)||void 0===d?void 0:d.sessionId,i=this.Zd(cn);t&&t!==i&&(h={},u=t)}if(!i.send_event&&"send_event"in i)u&&this.At({[dn]:h,[cn]:u});else{var c,v;const i=null===(c=this.xa)||void 0===c?void 0:c.canCapture;if(!i&&Object.keys(h).length>0&&(h={},this.At({[dn]:h})),i&&!(null===(v=h[t])||void 0===v?void 0:v.includes(o))){var f,p,_,g,m,y,b,w,S,x,E,T,P;k(h[t])?h[t].push(o):h[t]=[o],this.At(wi({[dn]:h},u?{[cn]:u}:{}));const i=this.getFeatureFlagDetails(t),e=[...null!==(f=this.Zd("$feature_flag_errors"))&&void 0!==f?f:[]];R(n)&&e.push("flag_missing");const s={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:null!==(p=null===(_=this.Ar.bootstrap)||void 0===_||null===(_=_.featureFlags)||void 0===_?void 0:_[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(g=null===(m=this.Ar.bootstrap)||void 0===m||null===(m=m.featureFlagPayloads)||void 0===m?void 0:m[t])&&void 0!==g?g:null,$used_bootstrap_value:!this._d};R(null==i||null===(y=i.metadata)||void 0===y?void 0:y.has_experiment)||(s.$feature_flag_has_experiment=i.metadata.has_experiment),R(null==i||null===(b=i.metadata)||void 0===b?void 0:b.version)||(s.$feature_flag_version=i.metadata.version);const d=null!==(w=null==i||null===(S=i.reason)||void 0===S?void 0:S.description)&&void 0!==w?w:null==i||null===(x=i.reason)||void 0===x?void 0:x.code;d&&(s.$feature_flag_reason=d),(null==i||null===(E=i.metadata)||void 0===E?void 0:E.id)&&(s.$feature_flag_id=i.metadata.id),R(null==i?void 0:i.original_variant)&&R(null==i?void 0:i.original_enabled)||(s.$feature_flag_original_response=R(i.original_variant)?i.original_enabled:i.original_variant),(null==i||null===(T=i.metadata)||void 0===T?void 0:T.original_payload)&&(s.$feature_flag_original_payload=null==i||null===(P=i.metadata)||void 0===P?void 0:P.original_payload),e.length&&(s.$feature_flag_error=e.join(",")),this.av(s)}else u&&this.At({[dn]:h,[cn]:u})}return s?{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:ve(r)}:void 0}av(t){try{var i;null===(i=this.xa)||void 0===i||i.capture("$feature_flag_called",t)}catch(t){this.$.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.lv(t,i)}lv(t,i){var e=this;return J(function*(){const s=e.xa;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=e.ev();r.length&&(n.evaluation_contexts=r);const o=e.iv();let l;R(o)||(n.flag_keys=o);try{var a;const i=null===(a=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:e.Ar.compression,sentAt:"body",timeoutMs:e.Ar.requestTimeoutMs})).json)||void 0===a?void 0:a.featureFlagPayloads;l=(null==i?void 0:i[t])||void 0}catch(t){return void e.$.error("Remote config feature flag request failed",t)}try{i(l)}catch(t){e.$.error("Remote config feature flag callback failed",t)}})()}isFeatureEnabled(t,i={}){if(i.fresh&&!this._d)return i.defaultValue;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+t+$d),i.defaultValue;const e=this.getFeatureFlag(t,i);return R(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.nv(t,i,e)}nv(t,i,e){if(!this.xa)return;this.fd=!0;const s=((t,i={},e={},s={},n,r=bd)=>{const o=((t,i)=>{const e=t.flags;if(e){const i=Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),s=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!R(null===(i=e[t].metadata)||void 0===i?void 0:i.payload)}).map(t=>{var i;return[t,null===(i=e[t].metadata)||void 0===i?void 0:i.payload]}));return wi(wi({},t),{},{featureFlags:i,featureFlagPayloads:s})}return t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t,r),l=o.flags,a=o.featureFlags,u=o.featureFlagPayloads;if(!a)return;const h=t.requestId,d=t.evaluatedAt;if(k(a)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const t={};if(a)for(let i=0;a.length>i;i++)t[a[i]]=!0;return{[en]:a,[an]:t,[ln]:!1}}let c=a,v=u,f=l;if(null==n?void 0:n.partialResponse){const t=Object.keys(c),n=v||{};c=wi(wi({},i),c),v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),f)}else if(t.errorsWhileComputingFlags)if(l){const t=new Set(Object.keys(l).filter(t=>{var i;return!(null===(i=l[t])||void 0===i?void 0:i.failed)}));c=wi(wi({},i),Object.fromEntries(Object.entries(c).filter(([i])=>t.has(i))));const n=Object.fromEntries(Object.entries(v||{}).filter(([i])=>t.has(i)));v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),Object.fromEntries(Object.entries(f||{}).filter(([i])=>t.has(i))))}else c=wi(wi({},i),c),v=wi(wi({},e),v),f=wi(wi({},s),f);return wi(wi({[en]:Object.keys(Td(c)),[an]:c||{},[vn]:v||{},[sn]:f||{},[ln]:!0===t.minimalFlagCalledEvents},h?{[on]:h}:{}),d?{[rn]:d}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.$);if(s)if(!1===(null==e?void 0:e.persist)){const t=!R(this.xa.kv.get(an));this.Jd=s,t||this.At(s)}else this.Bd(),this.Yd(s,t,!!(null==e?void 0:e.partialResponse)),this.At(s);else i&&this.Kd();i||(this.wd=!1),this.Hd(i)}override(t,i=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.uv(t)}uv(t){if(this.xa){if(!1===t)return this.Pt([fn,pn]),this.Hd(),void wd.info("All overrides cleared");if(k(t))return this.At({[fn]:kd(t)}),this.Hd(),void wd.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i;const e=t;this.ad=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);const s={},n=e.flags,r=e.payloads;return n&&(s[fn]=k(n)?kd(n):n),r&&(s[pn]=r),Object.keys(s).length&&this.At(s),!1===n&&!1===r?this.Pt([fn,pn]):!1===n?this.Pt(fn):!1===r&&this.Pt(pn),this.Hd(),!1===n?wd.info("Flag overrides cleared"):n&&wd.info("Flag overrides set",{flags:n}),void(!1===r?wd.info("Payload overrides cleared"):r&&wd.info("Payload overrides set",{payloads:r}))}if(t&&"object"==typeof t)return this.At({[fn]:t}),this.Hd(),void wd.info("Flag overrides set",{flags:t});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.fd){const{flags:i,flagVariants:e}=this.hv();try{t(i,e)}catch(t){this.$.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;const n=(this.Zd("$early_access_features")||[]).find(i=>i.flagKey===t),r={[`$feature_enrollment/${t}`]:i},o={$feature_flag:t,$feature_enrollment:i,$set:r};n&&(o.$early_access_feature_name=n.name),e&&(o.$feature_enrollment_stage=e);const l=wi(wi({},this.getFlagVariants()),{},{[t]:i});null===(s=this.Ad)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.At({[en]:Object.keys(Td(l)),[an]:l,[hn]:wi(wi({},this.Zd("$stored_person_properties")||{}),r)}),this.Hd();try{var a;null===(a=this.xa)||void 0===a||a.capture("$feature_enrollment_update",o)}catch(t){this.$.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i=!1,e){const s=this.Zd(tn);!s||i?this.dv(t,e):t(s)}dv(t,i){var e=this;return J(function*(){const s=e.xa;if(!s)return;const n=i?`&${i.map(t=>`stage=${t}`).join("&")}`:"";let r;try{const t=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!t.json)return;r=t.json.earlyAccessFeatures,e.At({[tn]:r})}catch(t){return void e.$.error("Early access feature request failed",t)}try{t(r)}catch(t){e.$.error("Early access feature callback failed",t)}})()}hv(){const t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}Hd(t){this.zd();const{flags:i,flagVariants:e}=this.hv(),s=this.bd;this.bd=!0,this.featureFlagEventHandlers.forEach(s=>{try{s(i,e,{errorsLoading:t})}catch(t){this.$.error("Error while running feature flags callback",t)}}),this.bd=s}setPersonPropertiesForFlags(t,i=!0){this.vv(t,i)}vv(t,i=!0){const e=this.Zd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||((null==t?void 0:t.$set_once)?{}:t),n=null==t?void 0:t.$set_once,r={};if(n)for(const t in n)({}).hasOwnProperty.call(n,t)&&(t in e||(r[t]=n[t]));this.At({[hn]:wi(wi(wi({},e),r),s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i=!0){const e=wi({},this.Zd("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.At({[hn]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Pt(hn),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i=!0){const e=this.Zd("$stored_group_properties")||{},s=wi({},e);for(const i of Object.keys(t))s[i]=wi(wi({},e[i]),t[i]);this.At({[un]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const i=this.Zd("$stored_group_properties")||{};this.At({[un]:wi(wi({},i),{},{[t]:{}})})}else this.Pt(un)}reset(){this.gd++,this.Gd(this.dd,"cancelled"),this.Gd(this.vd,"cancelled"),this.yd=!1,this.ld={},this.ud={},this.Jd=void 0,this.fd=!1,this.md=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Qd(),this.ad=!1,this.kd=0}};const Cd=Bs("[FeatureFlags]");var Rd=class{constructor(t,i=!1){this.fv=!1,this.update(t,i)}update(t,i){this.pv=((t,i)=>{var e,s,n,r,o,l,a,u;return{bootstrap:{featureFlags:null!==(e=null===(s=t.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(n=null===(r=t.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=t.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:R(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(l=t.feature_flag_request_max_retries)&&void 0!==l?l:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(u=t.evaluation_contexts)&&void 0!==u?u:t.evaluation_environments)&&void 0!==a?a:[],flagKeys:k(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.fv||(Cd.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.fv=!0),R(t.flag_keys)||k(t.flag_keys)||Cd.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.pv}};const Od=t=>z(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Ad=Bs("[Error tracking]"),Id="webkit-masked-url:",Fd=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Md=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Id],Dd=["__firefox__","__gCrWeb"],Nd="Refusing to render web experiment since the viewer is a likely bot",jd={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>qu(i,t),not_regex:(t,i)=>!qu(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},Ld=Bs("[Conversations]"),Ud="Conversations not available yet.";function Bd(t,i){var e,s,n,r,o,l,a;const u=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,h=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=(null==i?void 0:i.consoleCapture)?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=R(d)?Math.max(h,2048):Math.max(h,d),v=wi(wi({},function(){let t="",i="";try{var e;const s="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,n=null==s||null===(e=s.navigator)||void 0===e?void 0:e.userAgent;n&&([t,i]=Qt(n))}catch(t){}return function(t,i){const e=function(t){if(t)return{}.hasOwnProperty.call(ys,t)?ys[t]:t}(t);return wi(wi({},e?{"os.name":e}:{}),i?{"os.version":i}:{})}(t,i)}()),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==v?void 0:v["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==r?r:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==v?void 0:v["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(a=null==v?void 0:v["deployment.environment"])&&void 0!==a?a:null==t?void 0:t.environment,resourceAttributes:v,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const zd=["debug","log","warn","error","info"],Hd=t=>{for(;null==t?void 0:t.__rrweb_original__;)t=t.__rrweb_original__;return t},qd="console",Vd="__posthogHandledLogsRequestError",Wd=(t,i)=>{const e=t instanceof Error?t:new Error(i);return e[Vd]=!0,e},Gd=t=>!!t&&"object"==typeof t&&!0===t[Vd];var Kd=class{get gv(){return wi(wi({},this.$),{},{error:(...t)=>{t.some(Gd)||this.$.error(...t)}})}constructor(t,i){var e;this.Ta=t,this.mv=i,this.name="logs",this.yv=!1,this.bv=!1,this._v=!1,this.$=Bs("[logs]"),this.Bu=[],this.wv=[],this.kd=0,this.Sv=!1,this.Ci=!1,this.xv=[],this.$v=[],this.Cv=!1,this.Tv=!1,this.Iv=!1,this.Mv=()=>{var t,i;this.Ci||(this.kd=0,null===(t=this.Ev)||void 0===t||t.onReconnect(),null===(i=this.Pv)||void 0===i||i.onReconnect())},this.yv=!!(null===(e=t.get())||void 0===e?void 0:e.captureConsoleLogs)}get Rv(){return!0}Av(){}Fv(){if(!this.Iv){try{this.Dd=typeof window>"u"?void 0:window}catch(t){this.Dd=void 0}this.Dd&&(qr(this.Dd,"online",this.Mv),this.Iv=!0)}}Ov(t,i,e,s){this.Fv();const n=Bd(this.Ta.get(),e);return[new Cs(this.Dv(t,i),n,this.gv,()=>this.mv(),t=>t(),void 0,s),n]}Lv(){const t=this.Ta.get();var i;return this.Ev&&this.Nv===t||(null===(i=this.Ev)||void 0===i||i.reset(),this.Nv=t,[this.Ev,this.qv]=this.Ov(()=>this.Bu,t=>{this.Bu=t})),this.Ev}jv(){const t=this.Ta.get();var i;return this.Pv&&this.Bv===t||(null===(i=this.Pv)||void 0===i||i.reset(),this.Bv=t,[this.Pv,this.zv]=this.Ov(()=>this.wv,t=>{this.wv=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},qd)),this.Pv}setup(t){if(!this.Ci&&!this.Sv)return this.Sv=!0,this.xa=t,this.$=t.logger.createLogger("[logs]"),cd(t.kv.initialize(),()=>{this.Ci||this.Ld(t)})}Ld(t){var i;this.Fv(),(null===(i=this.Ta.get())||void 0===i?void 0:i.captureConsoleLogs)&&(this.yv=!0),(this.yv||this.Ta.remoteConfigWillArrive&&t.kv.get(this.Ta.captureHintKey))&&this.Hv();let e=!1;const s=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.Ci?s.dispose():(this.qa=s,e||this.loadIfEnabled())}dispose(){var t,i,e,s,n,r,o;this.Ci||(this.Ci=!0,this.Uv(),null===(t=this.qa)||void 0===t||t.dispose(),this.qa=void 0,this.xa=void 0,this._v=!1,null===(i=this.Dd)||void 0===i||i.removeEventListener("online",this.Mv),null===(e=this.Wv)||void 0===e||e.call(this),this.Wv=void 0,null===(s=this.Ev)||void 0===s||s.clearQueue(),null===(n=this.Pv)||void 0===n||n.clearQueue(),null===(r=this.Ev)||void 0===r||r.reset(),null===(o=this.Pv)||void 0===o||o.reset())}onRemoteConfig(t){var i,e;if(this.Ci)return;const s=t.ok?null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs:void 0;F(s)?this.Vv():(null===(e=this.xa)||void 0===e||e.kv.set(this.Ta.captureHintKey,!!s),s?(this.yv=!0,this.bv||this.Hv(),this.loadIfEnabled()):this.Vv())}reset(){var t,i,e,s;this.Uv(),null===(t=this.Ev)||void 0===t||t.clearQueue(),this.Bu=[],null===(i=this.Ev)||void 0===i||i.reset(),null===(e=this.Pv)||void 0===e||e.clearQueue(),this.wv=[],null===(s=this.Pv)||void 0===s||s.reset(),this.kd=0}captureLog(t){!this.Ci&&this.xa&&this.Lv().captureLog(t)}captureConsoleLog(t){!this.Ci&&this.xa&&this.jv().captureLog(t)}captureBufferedConsoleLog(t,i,e){!this.Ci&&this.xa&&this.jv().captureLog(t,{context:i,occurredAtMs:e})}od(){var t;this.Uv(),null===(t=this.Pv)||void 0===t||t.clearQueue(),this.wv=[]}Vv(){this.yv||this.Uv()}Hv(){var t;if(this.Cv||!(null===(t=this.Dd)||void 0===t?void 0:t.console))return;const i=Bd(this.Ta.get()).maxBufferSize;let e=!0;this.$v.push(()=>{e=!1});for(const t of zd){let s;try{s=Hd(this.Dd.console[t])}catch(t){continue}s&&this.$v.push(qh(this.Dd.console,t,n=>{const r=(...s)=>{try{e&&this.Gv(t,s,i)}catch(t){}return n.apply(this.Dd.console,s)};return r.__rrweb_original__=s,r}))}this.Cv=!0,this.Qv=setTimeout(()=>{this.Uv()},3e4)}Gv(t,i,e){var s;if(this.Cv&&!this.Tv&&0!==i.length)if(null===(s=this.xa)||void 0===s?void 0:s.canCapture){if(e>this.xv.length){this.Tv=!0;try{this.xv.push({level:t,args:i,occurredAtMs:Date.now(),context:this.mv()})}finally{this.Tv=!1}}}else this.Uv()}Uv(){if(this.xv=[],this.Cv){this.Cv=!1,this.Qv&&(clearTimeout(this.Qv),this.Qv=void 0);for(const t of this.$v)t();this.$v=[]}}Zv(){const t=this.xv;return this.Uv(),t}get logger(){return this.Jv||(this.Jv={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.Jv}flushLogs(t){this.xa&&(t?this.Kv(t):(this.Ev&&this.Ev.flush().catch(t=>this.Xv(t)),this.Pv&&this.Pv.flush().catch(t=>this.Xv(t))))}flush(){var t=this;return J(function*(){var i,e;const s=null===(i=t.Ev)||void 0===i?void 0:i.flush().catch(i=>t.Xv(i)),n=null===(e=t.Pv)||void 0===e?void 0:e.flush().catch(i=>t.Xv(i));yield s,yield n})()}Xv(t){Gd(t)||this.$.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.Ci||!this.yv||this.bv||this._v)return;const t=this.Av();if(t){this._v=!0;try{t((t,i)=>{if(this._v=!1,!this.Ci&&this.yv)if(t||!i)this.$.error("Could not load logs script",t),this.Uv();else{const t=this.Zv();this.Wv=i.initialize(this.xa),this.bv=!0,t.length>0&&i.replay(this.xa,t)}})}catch(t){throw this._v=!1,t}}else this.Uv()}Dv(t,i){const e=this.xa;return{get isDisabled(){return!1},get optedOut(){return!e.canCapture},getPersistedProperty:i=>i===f.LogsQueue?t():void 0,setPersistedProperty(t,e){t===f.LogsQueue&&i(null!=e?e:[])},js:t=>this.js(t),getLibraryId:()=>e.library.name,getLibraryVersion:()=>e.library.version}}js(t){return new Promise(i=>{if(Cl(this.kd,3))return void i({kind:"fatal",error:Wd(void 0,"logs endpoint is unreachable, dropping batch")});let e=!1;const s=t=>{e||(e=!0,clearTimeout(n),i(t))},n=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Wd(void 0,"logs request timed out")})},9e4),r=this.Rv;this.xa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.xa.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var i;const e=t.statusCode;this.Yv(e,r),e>=200&&300>e?s({kind:"ok"}):413===e?s({kind:"too-large"}):0!==e&&408!==e&&429!==e&&500>e?s({kind:"fatal",error:new Error(`logs request failed with status ${e}`)}):0===e?(t.error||this.$.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Wd(t.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error(`logs request failed with status ${e}`)})},t=>{s({kind:"retry-later",error:t})})})}Yv(t,i){(0!==t||i)&&(this.kd=Rl(t,this.kd,3,()=>this.$.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Kv(t){this.Bu.length>0&&this.tf(t,this.Bu,this.qv,this.xa.library.name,t=>{this.Bu=t}),this.wv.length>0&&this.tf(t,this.wv,this.zv,qd,t=>{this.wv=t})}tf(t,i,e,s,n){if(0===i.length)return;const r=i.map(t=>t.record);n([]);const o=Es(r,xs(e,this.xa.library.name,this.xa.library.version),s,this.xa.library.version);this.xa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.xa.projectToken},body:o,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Xv(t))}};const Jd=Bs("[NetworkMetrics]"),Yd=()=>{var i;return(null==t||null===(i=t.performance)||void 0===i?void 0:i.now)?t.performance.now():Date.now()},Zd={"http:":80,"https:":443},Xd=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Qd=(t,i)=>{var e;const s=String(i);return{method:String(t).toUpperCase(),url:(null===(e=Al(s))||void 0===e?void 0:e.href)||s}},tc=(t,i,e,s,n,r,o=!1)=>{try{var l,a;const u=n();if(!u)return;const h=e||void 0,d=Yd()-s,c=Al(i.url);if(c&&"http:"!==c.protocol&&"https:"!==c.protocol)return;const v={url:(null==c?void 0:c.href)||i.url,method:i.method},f=T(u.name)?u.name(v):O(u.name)?u.name:"http.client.request.duration";if(!f)return;const p=o&&!h?void 0:((t,i)=>t?400>t?void 0:String(t):(null==i?void 0:i.name)||"_OTHER")(h,r),_=wi(wi(wi(wi(wi({},(t=>{const i=Xd.has(t)?t:"_OTHER";return wi({"http.request.method":i},"_OTHER"===i&&t!==i?{"http.request.method_original":t}:{})})(v.method)),c?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Zd[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(i=t.pathname,i.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var i})(c):{}),h?{"http.response.status_code":h}:{}),p?{"error.type":p}:{}),null===(l=u.attributes)||void 0===l?void 0:l.call(u,v,{status:h,durationMs:d}));null===(a=t.metrics)||void 0===a||a.histogram(f,d,{unit:"ms",attributes:_})}catch(t){Jd.error("Failed to record network metric",t)}},ic=()=>{},ec=(i,e)=>T(null==t?void 0:t.fetch)?qh(t,"fetch",t=>function(...s){const n=Yd(),r=t.apply(this,s);if(!e())return r;try{var o,l,a;const[t,u]=s,h=Qd(null!==(o=null!==(l=null==u?void 0:u.method)&&void 0!==l?l:null==t?void 0:t.method)&&void 0!==o?o:"GET",null!==(a=null==t?void 0:t.url)&&void 0!==a?a:t);return r.then(t=>(tc(i,h,null==t?void 0:t.status,n,e,void 0,!0),t),t=>{throw tc(i,h,void 0,n,e,t),t})}catch(t){return Jd.error("Failed to observe fetch",t),r}}):ic,sc=(i,e)=>{var s;const n=null==t||null===(s=t.XMLHttpRequest)||void 0===s?void 0:s.prototype;if(!n)return ic;const r=new WeakMap,o=qh(n,"open",t=>function(...i){try{(()=>hu.has(this))()||r.set(this,Qd(i[0],i[1]))}catch(t){Jd.error("Failed to observe XHR open",t)}return t.apply(this,i)}),l=qh(n,"send",t=>function(...s){let n;try{const t=r.get(this);if(t&&e()){const s=Yd();n=()=>{this.removeEventListener("loadend",n),tc(i,t,this.status,s,e)},qr(this,"loadend",n)}}catch(t){Jd.error("Failed to observe XHR send",t)}try{return t.apply(this,s)}catch(t){throw n&&this.removeEventListener("loadend",n),t}});return()=>{o(),l()}},nc=new WeakMap,rc=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),oc={maxStringLength:2048,truncationSuffix:"..."},lc={maxStringLength:2048,truncationSuffix:"..."};function ac(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function uc(t,i){return{}.hasOwnProperty.call(t,i)}function hc(t,i){const e=Object.create(t);return i&&Object.defineProperty(e,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:i}),e}function dc(t,i,e=!1){if(!O(t))return;const s=t.trim();return s?(e?as(s,oc):s).slice(0,i):void 0}function cc(t){try{return P(t)&&!0===t.isError}catch(t){return!1}}function vc(t){return as(t||"Unknown error",lc).slice(0,2048)}function fc(t,i){try{return vc(i?function(t){try{if(!P(t)||!k(t.content))return;return t.content.filter(t=>P(t)&&"text"===t.type&&O(t.text)).map(t=>t.text).join(" ").trim()||void 0}catch(t){return}}(t):P(t)&&O(t.message)?t.message:O(t)?t:String(t))}catch(t){return"Unknown error"}}function pc(t,i,e){return i.errorResult?[{type:"Error",value:e,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:t.buildProperties(i.error,{handled:!0}).$exception_list.map(t=>wi(wi({},t),{},{value:vc(t.value)}))}function _c(t,i){if(i)return"Error";try{if(!P(t))return"Error";let i=O(t.name)?t.name.trim():"";const e=t.constructor;return i&&"Error"!==i||!T(e)||"Error"===e.name||(i=e.name),(i||"Error").slice(0,256)}catch(t){return"Error"}}function gc(t,i){return{message:fc(t,i),type:_c(t,i)}}const mc={featureFlags:class extends Pd{constructor(t){const i=new Rd(t.config,t.qu());super(i),this.name=ah,this._instance=t,this.ef=i}get Ad(){return this._instance.persistence}updateConfig(t,i){this.ef.update(t,i),this.Fd()}}},yc={sessionRecording:class{get Ar(){return this._instance.config}get cc(){return this._instance.persistence}get started(){var t;return!!(null===(t=this.if)||void 0===t?void 0:t.isStarted)}get status(){var t,i;return"awaiting_config"===this.nf||"missing_config"===this.nf?this.nf:null!==(t=null===(i=this.if)||void 0===i?void 0:i.status)&&void 0!==t?t:this.nf}constructor(i){if(this._instance=i,this._forceAllowLocalhostNetworkCapture=!1,this.nf=Zh,this.sf=void 0,this.rf=!1,this.Je=(()=>{var i,e;if(!(null==s?void 0:s.visibilityState)||"visible"===s.visibilityState)return!0;const n=null==t||null===(i=t.performance)||void 0===i||null===(e=i.getEntriesByType)||void 0===e?void 0:e.call(i,"visibility-state");return!(null==n?void 0:n.length)||n.some(t=>"visible"===t.name)})(),this.sn=()=>{var t,i;"visible"===(null==s?void 0:s.visibilityState)&&(this.Je=!0,null===(t=this.if)||void 0===t||null===(i=t.setDocumentWasEverVisible)||void 0===i||i.call(t,!0))},!this._instance.sessionManager)throw Qh.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Ar.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==s?void 0:s.addEventListener)&&qr(s,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var i;this.rf=!0,null==s||null===(i=s.removeEventListener)||void 0===i||i.call(s,"visibilitychange",this.sn),t?this.af(!0):this.stopRecording()}get lf(){var i;const e=!!(null===(i=this._instance.get_property("$session_recording_remote_config"))||void 0===i?void 0:i.enabled),s=!this.Ar.disable_session_recording,n=this.Ar.disable_session_recording||this._instance.consent.isOptedOut();return t&&e&&s&&!n}startIfEnabledOrStop(t){var i;if(this.rf)return;if(this.lf&&(null===(i=this.if)||void 0===i?void 0:i.isStarted))return;const e=!R(Object.assign)&&!R(Array.from);this.lf&&e?(this.uf(t),Qh.info("starting")):(this.nf=Zh,this.stopRecording())}uf(t){var i,e;if(this.lf)if("awaiting_config"!==this.nf&&"missing_config"!==this.nf&&(this.nf=Xh),(null==d||null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.rrweb)||void 0===i?void 0:i.record)&&(null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.initSessionRecording))this.cf(t);else{var s,n;const i=this._instance.sessionManager;null===(s=d.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.hf,e=>{if(!this.rf&&this.lf&&this._instance.sessionManager===i)return e?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Qh.error("could not load recorder",e)):void this.cf(t);this.nf="disabled"})}}stopRecording(){var t,i;null===(t=this.sf)||void 0===t||t.call(this),this.sf=void 0,null===(i=this.if)||void 0===i||i.stop()}af(t=!1){var i,e;null===(i=this.sf)||void 0===i||i.call(this),this.sf=void 0,null===(e=this.if)||void 0===e||e.discard({discardProducerEvents:t})}df(){var t,i;null===(t=this.cc)||void 0===t||t.unregister("$session_is_sampled"),null===(i=this.cc)||void 0===i||i.unregister("$replay_sample_rate")}vf(t,i){if(F(t))return null;const e=M(t)?t:parseFloat(t);return"number"!=typeof(s=e)||!Number.isFinite(s)||0>s||s>1?(Qh.warn(`${i} must be between 0 and 1. Ignoring invalid value:`,t),null):e;var s}ff(t){if(this.cc){var i,e;const s=this.cc,n=()=>{var i;const e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.vf(null===(i=this.Ar.session_recording)||void 0===i?void 0:i.sampleRate,"session_recording.sampleRate"),r=this.vf(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=n?n:r;F(o)&&this.df();const l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[jn]:wi(wi({cache_timestamp:Date.now(),enabled:!!e},e),{},{networkPayloadCapture:wi({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:R(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null===(i=this.sf)||void 0===i||i.call(this),this.sf=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(n)}}onRemoteConfig(t){const i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.ff(i),void this.af()):(this.ff(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.nf&&(this.nf="missing_config",this._instance.register_for_session({[mr]:!0}),Qh.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i="log"){var e;(null===(e=this.if)||void 0===e?void 0:e.log)?this.if.log(t,i):Qh.warn("log called before recorder was ready")}get hf(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.get_property(jn);return(null==e||null===(i=e.scriptConfig)||void 0===i?void 0:i.script)||"lazy-recorder"}pf(){const t=this._instance.get_property(jn);if(!t)return!1;let i;try{i="object"==typeof t?t:JSON.parse(t)}catch(t){return Qh.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!F(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}cf(t){var i,e,s;if(!this.rf&&this.lf&&this._instance.sessionManager){if(!(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))return Qh.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[gr]:!0});var n;if(this.if||(this.if=null===(n=d.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Je),this.if._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.pf()){if("missing_config"===this.nf||"awaiting_config"===this.nf)return;return this.nf="awaiting_config",Qh.info("persisted remote config is stale, requesting fresh config before starting"),void new Pa(this._instance).load()}this.nf=Xh,null===(e=(s=this.if).setDocumentWasEverVisible)||void 0===e||e.call(s,this.Je),this.if.start(t)}else this.nf=Zh}onRRwebEmit(t){var i,e;null===(i=this.if)||void 0===i||null===(e=i.onRRwebEmit)||void 0===e||e.call(i,t)}overrideLinkedFlag(){var t,i;this.if||null===(i=this.cc)||void 0===i||i.register({$replay_override_linked_flag:!0}),null===(t=this.if)||void 0===t||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.if||null===(i=this.cc)||void 0===i||i.register({$replay_override_sampling:!0}),null===(t=this.if)||void 0===t||t.overrideSampling()}overrideTrigger(t){var i,e;this.if||null===(e=this.cc)||void 0===e||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(i=this.if)||void 0===i||i.overrideTrigger(t)}get sdkDebugProperties(){var t;const i={};for(const t of td){var e;const s=null===(e=this._instance.sessionPersistence)||void 0===e?void 0:e.get_property(t);R(s)||(i[t]=s)}return wi(wi({},i),(null===(t=this.if)||void 0===t?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,i){var e;return!!(null===(e=this.if)||void 0===e?void 0:e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t,i;null===(t=this.if)||void 0===t||null===(i=t.flushBeforeIdentityReset)||void 0===i||i.call(t)}}},bc={autocapture:class extends Lh{constructor(t){super(new Uh(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.gf=!1,this._instance=t,this.mf=this.yf()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.bf();return!!(t.path||t.search||this._f(t))}startIfEnabled(){this.isEnabled&&(Us.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.mf=this.yf(),this.startIfEnabled()}stop(){this.wf&&this.wf(),this.wf=void 0,this.kf&&this.kf(),this.kf=void 0,Us.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Sf("pushState"),this.Sf("replaceState"),this.xf(),this._f()&&this.$f())}Sf(i){var e;if(!t||(null===(e=t.history[i])||void 0===e?void 0:e.__posthog_wrapped__))return;const s=this;qh(t.history,i,e=>function(n,r,o){var l;s.Cf(o)&&s.Tf(),e.call(this,n,r,o),s.If(i,!s.gf&&"popstate"!==(null==t||null===(l=t.event)||void 0===l?void 0:l.type))})}yf(){const i=null==t?void 0:t.location;if(null==i?void 0:i.pathname)return{pathname:i.pathname,search:i.search,hash:i.hash}}bf(){const t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:P(t)?t:{}}_f(t=this.bf()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Mf(t){const i=this.bf(),e=this.mf;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this._f(i)&&t.hash!==e.hash))}If(t,i=!1){try{i||this.Tf();const e=this.yf();if(!e)return;if(this.Mf(e)){const e=()=>this._instance.capture(Or,{navigation_type:t});i?(this.Ef=e,Promise.resolve().then(()=>this.Tf())):e()}this.mf=e}catch(i){Us.error(`Error capturing ${t} pageview`,i)}}Cf(i){var e,s;return!(F(i)||!t)&&(null===(e=Al(String(i)))||void 0===e?void 0:e.href)!==(null===(s=t.location)||void 0===s?void 0:s.href)}Tf(){const t=this.Ef;if(t){this.Ef=void 0,this.gf=!0;try{t()}catch(t){Us.error("Error capturing deferred pageview",t)}finally{this.gf=!1}this.mf=this.yf()}}xf(){if(this.wf)return;const i=()=>{this.If("popstate")};qr(t,"popstate",i),this.wf=()=>{t&&t.removeEventListener("popstate",i)}}$f(){if(this.kf)return;const i=()=>{this.If("hashchange")};qr(t,"hashchange",i),this.kf=()=>{t&&t.removeEventListener("hashchange",i)}}},heatmaps:class{get Ar(){return this.instance.config}constructor(t){var i;this.Pf=!1,this.al=!1,this.Rf=null,this.instance=t,this.Pf=!!(null===(i=this.instance.persistence)||void 0===i?void 0:i.props[Cn]),this.rageclicks=new Ih(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return P(this.Ar.capture_heatmaps)&&this.Ar.capture_heatmaps.flush_interval_milliseconds&&(t=this.Ar.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return F(this.Ar.capture_heatmaps)?F(this.Ar.enable_heatmaps)?this.Pf:this.Ar.enable_heatmaps:!1!==this.Ar.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.al)return;id.info("starting..."),this.Af(),this.sn()}else{var t;clearInterval(null!==(t=this.Rf)&&void 0!==t?t:void 0),this.Ff(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("heatmaps"in i))return;const e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Cn]:e}),this.Pf=e,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}Of(t){ed(t.originalEvent)&&this.$r(t.originalEvent,"deadclick")}sn(){this.Rf&&clearInterval(this.Rf),this.Rf="visible"===(null==s?void 0:s.visibilityState)?setInterval(this.Zu.bind(this),this.flushIntervalMilliseconds):null}Af(){t&&s&&(this.Df=this.Zu.bind(this),qr(t,Rr,this.Df),this.Lf=i=>this.$r(i||(null==t?void 0:t.event)),qr(s,"click",this.Lf,{capture:!0}),this.Nf=i=>this.qf(i||(null==t?void 0:t.event)),qr(s,"mousemove",this.Nf,{capture:!0}),this.jf=new _l(this.instance,fl,this.Of.bind(this)),this.jf.startIfEnabledOrStop(),this.Bf=this.sn.bind(this),qr(s,_n,this.Bf),this.al=!0)}Ff(){var i;t&&s&&(this.Df&&t.removeEventListener(Rr,this.Df),this.Lf&&s.removeEventListener("click",this.Lf,{capture:!0}),this.Nf&&s.removeEventListener("mousemove",this.Nf,{capture:!0}),this.Bf&&s.removeEventListener(_n,this.Bf),clearTimeout(this.zf),null===(i=this.jf)||void 0===i||i.stop(),this.al=!1)}Hf(i,e){const s=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(i,e,s){let n=i;for(;n&&Eo(n)&&!ko(n,"body");){if(n===s)return!1;let i;try{var r,o,l;i=null===(r=null!==(o=null===(l=n.ownerDocument)||void 0===l?void 0:l.defaultView)&&void 0!==o?o:t)||void 0===r?void 0:r.getComputedStyle(n).position}catch(t){return!1}if(m(e,i))return!0;n=jo(n)}return!1}(Fo(i),["fixed","sticky"],r);return{x:i.clientX+(o?0:n),y:i.clientY+(o?0:s),target_fixed:o,type:e}}$r(t,i="click"){var e;if(xo(t.target)||!ed(t))return;const s=this.Hf(t,i);(null===(e=this.rageclicks)||void 0===e?void 0:e.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&Yo(Fo(t),this.instance.config.rageclick)&&this.Qs(wi(wi({},s),{},{type:"rageclick"})),this.Qs(s)}qf(t){!xo(t.target)&&ed(t)&&(clearTimeout(this.zf),this.zf=setTimeout(()=>{this.Qs(this.Hf(t,"mousemove"))},500))}Qs(i){if(!t)return;const e=this.Ar.disable_capture_url_hashes?vi(t.location.href):t.location.href,s=this.Ar.custom_personal_data_properties,n=this.Ar.mask_personal_data_properties?[...Dl,...s||[]]:[],r=Fl(e,n,jl);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(i)}Zu(){this.Rt&&!C(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:_l,webVitalsAutocapture:class{constructor(i){var e;this._instance=i,this.Pf=!1,this.al=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Uf=(t=!1)=>{clearTimeout(this.Wf),this.Wf=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",wi({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>wi(wi({},t),{},{[`$web_vitals_${i.name}_event`]:wi({},i),[`$web_vitals_${i.name}_value`]:i.value}),{})),t?{transport:"sendBeacon",send_instantly:!0}:void 0),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Vf=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},F(null==t?void 0:t.name)||F(null==t?void 0:t.value))return void Wh.error("Invalid metric received",t);const e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Gf(e);if(R(s))return;const n=M(t.navigationId)||"string"==typeof t.navigationId?`navigation:${t.navigationId}`:`url:${s}`;if(this.Qf&&t.value>=this.Qf)return void Wh.error("Ignoring metric with value >= "+this.Qf,t);this.Rt.navigationKey!==n&&(this.Uf(),this.Wf=setTimeout(this.Uf,this.flushToCaptureTimeoutMs)),R(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=R(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0),o=wi(wi(wi({},t),e?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,P(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){const i={};for(const e of Yh){const s="url"===e&&"string"==typeof t.attribution[e]?this.Gf(t.attribution[e]):t.attribution[e];R(s)||(i[e]=s)}o.attribution=i}else delete o.attribution;R(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Uf()},this.Zf=()=>{if(this.al)return;let i,e,s,n,r=!1;const o=d.__PosthogExtensions__,l=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,a=(null==l?void 0:l[this.Jf])||("web-vitals"===this.Jf&&R(l)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!R(a)){const t=a.withoutAttribution,o=this.attributionMetrics;r=!R(t),i=o.indexOf("LCP")>-1?a.onLCP:(null==t?void 0:t.onLCP)||a.onLCP,e=o.indexOf("CLS")>-1?a.onCLS:(null==t?void 0:t.onCLS)||a.onCLS,s=o.indexOf("FCP")>-1?a.onFCP:(null==t?void 0:t.onFCP)||a.onFCP,n=o.indexOf("INP")>-1?a.onINP:(null==t?void 0:t.onINP)||a.onINP}if(!(i&&e&&s&&n))return void Wh.error("web vitals callbacks not loaded - not starting");const u={reportSoftNavs:this.useSoftNavs},h=r&&this.attributionMetrics.indexOf("INP")>-1?wi(wi({},u),{},{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&i(this.Vf.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&e(this.Vf.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&s(this.Vf.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&n(this.Vf.bind(this),h);const c=null==t?void 0:t.document;qr(c,_n,()=>{"hidden"===(null==c?void 0:c.visibilityState)&&this.Uf(!0)}),qr(t,"pagehide",()=>this.Uf(!0)),this.al=!0},this.Pf=!!(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[In]),this.startIfEnabled()}get Kf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i;const e=P(this.Kf)?null===(t=this.Kf)||void 0===t?void 0:t.web_vitals_allowed_metrics:void 0;return F(e)?(null===(i=this._instance.persistence)||void 0===i?void 0:i.props.$web_vitals_allowed_metrics)||Kh:e}get flushToCaptureTimeoutMs(){return(P(this.Kf)?this.Kf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=P(this.Kf)?this.Kf.web_vitals_attribution:void 0;return N(t)?t?Kh:[]:k(t)?t:Jh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=P(this.Kf)?this.Kf.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Qf(){const t=P(this.Kf)&&M(this.Kf.__web_vitals_max_value)?this.Kf.__web_vitals_max_value:Gh;return t>0&&6e4>=t?Gh:t}get isEnabled(){const t=null==n?void 0:n.protocol;if("http:"!==t&&"https:"!==t)return Wh.info("Web Vitals are disabled on non-http/https protocols"),!1;const i=P(this.Kf)?this.Kf.web_vitals:N(this.Kf)?this.Kf:void 0;return N(i)?i:this.Pf}startIfEnabled(){this.isEnabled&&!this.al&&(Wh.info("enabled, starting..."),this.$l(this.Zf))}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("capturePerformance"in i))return;const e=P(i.capturePerformance)&&!!i.capturePerformance.web_vitals,s=P(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[In]:e}),this._instance.persistence.register({[Nn]:s})),this.Pf=e,this.startIfEnabled()}get Jf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}$l(t){var i;const e=d.__PosthogExtensions__,s=this.Jf,n=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&R(n)&&(null==e?void 0:e.postHogWebVitalsCallbacks)?t():null==e||null===(i=e.loadExternalDependency)||void 0===i||i.call(e,this._instance,s,i=>{i?Wh.error("failed to load script",i):t()})}Gf(i){const e=i||(null==t?void 0:t.location.href);if(!e)return void Wh.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?vi(e):e,n=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Dl,...n||[]]:[];return Fl(s,r,jl)}}},wc={exceptionObserver:class{constructor(i){var e;this.Zf=()=>{var i;if(!t||!this.isEnabled||!(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions))return;const e=d.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=d.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=d.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Xf&&this.Ar.capture_unhandled_errors&&(this.Xf=e(this.captureException.bind(this))),!this.Yf&&this.Ar.capture_unhandled_rejections&&(this.Yf=s(this.captureException.bind(this))),!this.tp&&this.Ar.capture_console_errors&&(this.tp=n(this.captureException.bind(this)))}catch(t){Bh.error("failed to start",t),this.ep()}},this._instance=i,this.np=!!(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[Rn]),this.wt=new tt(wi(wi({},function(t={}){var i,e,s,n;return{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:Bh})),this.Ar=this.sp(),this.startIfEnabledOrStop()}sp(){const t=this._instance.config.capture_exceptions;let i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return P(t)?i=wi(wi({},i),t):(R(t)?this.np:t)&&(i=wi(wi({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Ar.capture_console_errors||this.Ar.capture_unhandled_errors||this.Ar.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Bh.info("enabled"),this.ep(),this.$l(this.Zf)):this.ep()}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"exception-autocapture",i=>{if(i)return Bh.error("failed to load script",i);t()})}ep(){var t,i,e;null===(t=this.Xf)||void 0===t||t.call(this),this.Xf=void 0,null===(i=this.Yf)||void 0===i||i.call(this),this.Yf=void 0,null===(e=this.tp)||void 0===e||e.call(this),this.tp=void 0}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"autocaptureExceptions"in i&&(this.np=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Rn]:this.np}),this.Ar=this.sp(),this.startIfEnabledOrStop())}onConfigChange(){this.Ar=this.sp()}captureException(t){try{var i,e,s;const n=null!==(i=null==t||null===(e=t.$exception_list)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(n))return void Bh.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.rp=[],this.op=new Pi([new Ji,new re,new Zi,new Yi,new se,new ee,new Qi,new ne],function(t,...i){return(e,s=0)=>{const n=[],r=e.split("\n"),o=Math.min(r.length,s+1e3),l=[];for(let e=s;o>e;e++){const s=r[e];if(s.length>1024)continue;const o=Bi.test(s)?s.replace(Bi,"$1"):s;if(!o.match(/\S*Error: /)){for(const e of i){const i=e(o,t);if(i){n.push(i);const t=Hi(n);if(t){for(let i=l.length-1;i>=0;i--){const e=l[i];if(t.start>=e.start+e.length)break;l.pop()}l.push(t)}break}}if(Gi(n,l)>=50)break}}const a=[...l].sort((t,i)=>i.start-t.start),u=a[a.length-1];if(u){const t=Vi(n,u);n.splice(u.start-t,t);for(const i of a)i.start-=t}for(const t of a)qi(n,t);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){const i=t.map(t=>`${t.function}|${t.filename}|${t.lineno}|${t.colno}|${t.module}`);let e=0;for(let t=1;i.length>t;t++)Ki(i,t,e)&&(e=t);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];const i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return wi(wi({},t),{},{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",Ni,Ui)),this._instance=t,this.rp=null!==(i=null===(e=this._instance.persistence)||void 0===e?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.ap=he(this.lp()),this.up=new de(this.ap)}onConfigChange(){this.ap=he(this.lp()),this.up.setConfig(this.ap)}onRemoteConfig(t){var i,e,s;if(!t.ok)return;const n=t.config;if(!("errorTracking"in n))return;const r=null!==(i=null===(e=n.errorTracking)||void 0===e?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.rp=r,this._instance.persistence&&this._instance.persistence.register({[On]:this.rp,[An]:o})}get cp(){var t;const i=!!this._instance.get_property(An),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.op.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.ap.enabled)try{if(!O(t)||0===t.trim().length)return void Ad.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:e,droppedKeys:s}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};const i=[];return{sanitizedProperties:Object.keys(t).reduce((e,s)=>ae.has(s)?(i.push(s),e):(e[s]=t[s],e),{}),droppedKeys:i}}(this.hp(i));s.length>0&&Ad.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.up.add(wi({[oe]:t,[le]:(new Date).toISOString()},e))}catch(t){Ad.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{const i=t.$exception_list;if(this.dp(i)){if(this.vp(i))return this.fp("Exception dropped: matched a suppression rule"),void Ad.info("Skipping exception capture because a suppression rule matched");if(!this.cp&&this.pp(i))return this.fp("Exception dropped: thrown by a browser extension"),void Ad.info("Skipping exception capture because it was thrown by an extension");if(!this.cp&&this.gp(i))return this.fp("Exception dropped: thrown by an injected browser script"),void Ad.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.mp(i))return this.fp("Exception dropped: thrown by the PostHog SDK"),void Ad.info("Skipping exception capture because it was thrown by the PostHog SDK")}const e=this.ap.enabled&&F(t.$exception_steps)?this.yp(t):t,s=function(){if("u">typeof process){var t;const i=null===(t=process.env.POSTHOG_RELEASE_ID)||void 0===t?void 0:t.trim();if(i)return i}const i=globalThis._posthogReleaseId;return"string"==typeof i&&i.length>0?i:void 0}();s&&(e.$release_id=s);try{const t=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",Vh:!0});return t&&this.up.clear(),t}catch(t){return Od(t)||Ad.error("Failed to capture exception event. Dropping this exception.",t),void this.up.clear()}}catch(t){return void(Od(t)||Ad.error("Failed to process exception event. Ignoring this exception.",t))}}yp(t){try{const i=this.up.getAttachable();return 0===i.length?t:wi(wi({},t),{},{$exception_steps:i})}catch(i){return Ad.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}fp(t){this.ap.enabled&&this.up.add({[oe]:t,[le]:(new Date).toISOString()})}hp(t){return P(t)?wi({},t):{}}lp(){var t,i;return null!==(t=null===(i=this._instance.config.error_tracking)||void 0===i?void 0:i.exception_steps)&&void 0!==t?t:{}}vp(t){if(0===t.length)return!1;try{const i=t.reduce((t,{type:i,value:e})=>(O(i)&&i.length>0&&t.$exception_types.push(i),O(e)&&e.length>0&&t.$exception_values.push(e),t),{$exception_types:[],$exception_values:[]});return this.rp.some(t=>{const e=t.values.map(t=>{const e=Wu[t.operator],s=i[t.key];if(!e||!s)return!1;const n=k(t.value)?t.value:[t.value];return n.length>0&&e(n,s)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return Ad.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}pp(t){const i=t.flatMap(t=>{var i,e;return null!==(i=null===(e=t.stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(({filename:t})=>!!t&&Md.some(i=>t.startsWith(i)));return 0!==e.length&&(!e.every(({filename:t})=>!!t&&t.startsWith(Id))||t.some(({type:t,value:i})=>"NoResponse"===t||O(i)&&Fd.some(({value:t,exact:e})=>e?i===t:i.includes(t)))&&!i.some(({in_app:t,filename:i})=>t&&!(null==i?void 0:i.startsWith(Id))))}gp(t){return t.some(({value:t})=>O(t)&&Dd.some(i=>t.includes(i)))}mp(t){if(t.length>0){var i,e,s,n;const r=null!==(i=null===(e=t[0].stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}dp(t){return!F(t)&&k(t)}}},$c=wi({productTours:class{get cc(){return this._instance.persistence}constructor(t){this.bp=null,this._p=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if("productTours"in i){var e,s;if(this.cc&&this.cc.register({[Mn]:!!i.productTours}),!nd(this._instance))return!this.bp&&F(null===(e=this.cc)||void 0===e?void 0:e.props.ph_product_tours)||sd.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.bp)||void 0===s||s.stop(),this.bp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.bp&&nd(this._instance)&&this.$l(()=>this.wp())}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.generateProductTours)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"product-tours",i=>{i?sd.error("Could not load product tours script",i):t()})}wp(){var t;!this.bp&&(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)&&(this.bp=d.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i=!1){if(k(this._p)&&!i)return void t(this._p,{isLoaded:!0});const e=this.cc;if(e){const s=e.props[Qn];if(k(s)&&!i)return this._p=s,void t(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!nd(this._instance))return void t([],{isLoaded:!0});const s=i.statusCode;if(200!==s||!i.json){const e=`Product Tours API could not be loaded, status: ${s}`;return 0===s?i.error||sd.warn(e):sd.error(e),void t([],{isLoaded:!1,error:e})}const n=k(i.json.product_tours)?i.json.product_tours:[];this._p=n,e&&e.register({[Qn]:n}),t(n,{isLoaded:!0})}})}getActiveProductTours(t){F(this.bp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.bp.getActiveProductTours(t)}showProductTour(t){var i;null===(i=this.bp)||void 0===i||i.showTourById(t)}previewTour(t){this.bp?this.bp.previewTour(t):this.$l(()=>{var i;this.wp(),null===(i=this.bp)||void 0===i||i.previewTour(t)})}dismissProductTour(){var t;null===(t=this.bp)||void 0===t||t.dismissTour("user_clicked_skip")}nextStep(){var t;null===(t=this.bp)||void 0===t||t.nextStep()}previousStep(){var t;null===(t=this.bp)||void 0===t||t.previousStep()}clearCache(){var t;this._p=null,null===(t=this.cc)||void 0===t||t.unregister("ph_product_tours")}resetTour(t){var i;null===(i=this.bp)||void 0===i||i.resetTour(t)}resetAllTours(){var t;null===(t=this.bp)||void 0===t||t.resetAllTours()}cancelPendingTour(t){var i;null===(i=this.bp)||void 0===i||i.cancelPendingTour(t)}}},mc),Sc={siteApps:class{constructor(t){this._instance=t,this.kp=0,this.Sp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}xp(t,i){if(!i)return;const e=this.globalsForEvent(i);this.Sp.push(e),this.Sp.length>1e3&&(this.Sp=this.Sp.slice(10))}get siteAppLoaders(){var t;return null===(t=d._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.xp.bind(this));this.$p=()=>{t(),this.Sp=[],this.$p=void 0}}}globalsForEvent(t){var i,e,s,n,r,o,l;if(!t)throw new Error("Event payload is required");const a={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(const[t,i]of Object.entries(h))a[t]={id:u[t],type:t,properties:i};const{$set_once:d,$set:c}=t;return{event:wi(wi({},ke(t,rd)),{},{properties:wi(wi(wi({},t.properties),c?{$set:wi(wi({},null!==(i=null===(e=t.properties)||void 0===e?void 0:e.$set)&&void 0!==i?i:{}),c)}:{}),d?{$set_once:wi(wi({},null!==(s=null===(n=t.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=t.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(l=t.properties)||void 0===l?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Cp(t){var i;const e=null===(i=t.tagName)||void 0===i?void 0:i.toLowerCase();if("style"===e&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(t)||(od.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===e&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(t)||(od.error("prepare_external_dependency_script returned null"),null)}return t}Tp(){var t,i,e,n,r,o,l,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const u=null==s?void 0:s.defaultView,h=null==u||null===(t=u.Node)||void 0===t?void 0:t.prototype;if(!u||!h)return()=>{};if(this.kp++,this.Ip)return this.Mp();const d=[],c=this,v=new WeakSet,f=(t,i,e)=>{if(!(null==t?void 0:t[i]))return;const s=t[i];t[i]=e(s),d.push(()=>{t[i]=s})},p=t=>{if(v.has(t))return t;const i=c.Cp(t);return i&&v.add(i),i},_=t=>t.map(t=>"string"==typeof t?t:p(t)).filter(t=>!I(t));return f(h,"appendChild",t=>function(i){const e=p(i);return e?t.call(this,e):i}),f(h,"insertBefore",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):i}),f(h,"replaceChild",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):e}),[null===(i=u.Element)||void 0===i?void 0:i.prototype,null===(e=u.Document)||void 0===e?void 0:e.prototype,null===(n=u.DocumentFragment)||void 0===n?void 0:n.prototype].forEach(t=>{f(t,"append",t=>function(...i){return t.apply(this,_(i))}),f(t,"prepend",t=>function(...i){return t.apply(this,_(i))})}),[null===(r=u.Element)||void 0===r?void 0:r.prototype,null===(o=u.CharacterData)||void 0===o?void 0:o.prototype,null===(l=u.DocumentType)||void 0===l?void 0:l.prototype].forEach(t=>{f(t,"before",t=>function(...i){return t.apply(this,_(i))}),f(t,"after",t=>function(...i){return t.apply(this,_(i))}),f(t,"replaceWith",t=>function(...i){const e=_(i);return i.length&&!e.length?void 0:t.apply(this,e)})}),f(null===(a=u.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",t=>function(i,e){const s=p(e);return s?t.call(this,i,s):null}),this.Ip=()=>{d.forEach(t=>t()),this.Ip=void 0},this.Mp()}Mp(){let t=!1;return()=>{var i;t||(t=!0,this.kp--,0===this.kp&&(null===(i=this.Ip)||void 0===i||i.call(this)))}}Ep(t,i=!0){const e=this.Tp();try{const s=t(e);return i&&e(),s}catch(t){throw e(),t}}setupSiteApp(t){const i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Sp.length&&(od.info(`Processing ${this.Sp.length} events for site app with id ${t.id}`),this.Sp.forEach(t=>this.Ep(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null===(e=this.$p)||void 0===e||e.call(this))};let s=!1;const n=n=>{i.errored=!n,i.loaded=!0,od.info(`Site app with id ${t.id} ${n?"loaded":"errored"}`),s&&e()};try{const{processEvent:e}=this.Ep(i=>t.init({posthog:this._instance,callback(t){i(),n(t)}}),!1);e&&(i.processEvent=e),s=!0}catch(i){od.error(ld+t.id,i),n(!1)}if(s&&i.loaded)try{e()}catch(e){od.error(`Error while processing buffered events PostHog app with config id ${t.id}`,e),i.errored=!0}}Pp(){const t=this.siteAppLoaders||[];for(const i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(const i of t)this.setupSiteApp(i)}Rp(t){if(0===Object.keys(this.apps).length)return;const i=this.globalsForEvent(t);for(const e of Object.values(this.apps))try{this.Ep(()=>{var t;return null===(t=e.processEvent)||void 0===t?void 0:t.call(e,i)})}catch(i){od.error(`Error while processing event ${t.event} for site app ${e.id}`,i)}}onRemoteConfig(t){var i,e,s;if(null===(i=this.siteAppLoaders)||void 0===i?void 0:i.length)return this.isEnabled?(this.Pp(),void this._instance.on("eventCaptured",t=>this.Rp(t))):void od.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(e=this.$p)||void 0===e||e.call(this),!t.ok)return;const n=t.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:t,url:i}of n.siteApps){var r,o;d[`__$$ph_site_app_${t}`]=this._instance,null===(r=d.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,i,i=>{if(i)return od.error(ld+t,i)})}else od.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},xc={tracingHeaders:class{constructor(t){this._instance=t,this.Ap=void 0,this.Fp=void 0,this.Op=void 0,this.Zf=()=>{const t=this.Dp();var i,e;t?(R(this.Ap)&&(this.Ap=null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),R(this.Fp)&&(this.Fp=null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.tracingHeadersPatchFns)||void 0===e?void 0:e._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.ep()}}initialize(){this.startIfEnabledOrStop()}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.tracingHeadersPatchFns)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"tracing-headers",i=>{if(i)return Vh.error("failed to load script",i);t()})}Lp(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Dp(){const t=this.Lp();return k(t)?(k(this.Op)?this.Op.splice(0,this.Op.length,...t):this.Op=[...t],t.length>0?this.Op:void 0):(k(this.Op)&&this.Op.splice(0),this.Op=t||void 0,this.Op)}ep(){var t,i;null===(t=this.Ap)||void 0===t||t.call(this),null===(i=this.Fp)||void 0===i||i.call(this),this.Ap=void 0,this.Fp=void 0}startIfEnabledOrStop(){this.Dp()?this.$l(this.Zf):this.ep()}}},Ec=wi({surveys:class extends pd{constructor(t){super(new _d(t))}}},mc),kc={toolbar:class{constructor(t){this.instance=t}Np(t){d.ph_toolbar_state=t}qp(){var t;return null!==(t=d.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i=void 0,e=void 0,n=void 0){var r,o;if(Vr(this.instance.config))return!1;if(!t||!s)return!1;i=null!==(r=i)&&void 0!==r?r:t.location,n=null!==(o=n)&&void 0!==o?o:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}e=null==t?void 0:t.localStorage}const s=gd||Ml(i.hash,"__posthog")||Ml(i.hash,"state");let r;const o=s?fi(()=>JSON.parse(atob(decodeURIComponent(s))))||fi(()=>JSON.parse(decodeURIComponent(s))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?i.hash=o.desiredHash:n?n.replaceState(n.state,"",i.pathname+i.search):i.hash="")):(r=JSON.parse(e.getItem(md)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}jp(t){const i=d.ph_load_toolbar||d.ph_load_editor;!F(i)&&T(i)?i(t,this.instance):yd.warn("No toolbar load function found")}loadToolbar(i){const e=!!(null==s?void 0:s.getElementById("__POSTHOG_TOOLBAR__"));if(!t||e)return!1;const n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=wi(wi({token:this.instance.config.token},i),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(t.localStorage.setItem(md,JSON.stringify(wi(wi({},r),{},{source:void 0}))),2===this.qp())this.jp(r);else if(0===this.qp()){var o,l;this.Np(1),null===(o=d.__PosthogExtensions__)||void 0===o||null===(l=o.loadExternalDependency)||void 0===l||l.call(o,this.instance,"toolbar",t=>{if(t)return yd.error("[Toolbar] Failed to load",t),void this.Np(0);this.Np(2),this.jp(r)}),qr(t,"turbolinks:load",()=>{this.Np(0),this.loadToolbar(r)})}return!0}Bp(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,i=void 0,e=void 0){return this.maybeLoadToolbar(t,i,e)}}},Tc=wi({experiments:class i{get Ar(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{i.zp("retrieved web experiments from the server"),this.Hp=new Map,t.forEach(t=>{if(t.feature_flag_key){var e;this.Hp&&(i.zp("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(e=this.Hp)||void 0===e||e.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);O(s)&&t.variants[s]&&this.Up(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const e in t.variants){const s=t.variants[e];i.Wp(s,this._instance)&&this.Up(t.name,e,s.transforms)}})},t)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(t){if(this._is_bot())i.zp(Nd);else if(!this.Ar.disable_web_experiments){if(F(this.Hp))return this.Hp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.zp("applying feature flags",t),t.forEach(t=>{var i;if(this.Hp&&(null===(i=this.Hp)||void 0===i?void 0:i.has(t))){var e;const i=this._instance.getFeatureFlag(t),s=null===(e=this.Hp)||void 0===e?void 0:e.get(t);i&&(null==s?void 0:s.variants[i])&&this.Up(s.name,i,s.variants[i].transforms)}})}}previewWebExperiment(){const t=i.getWindowLocation();if(null==t?void 0:t.search){const e=Il(null==t?void 0:t.search,"__experiment_id"),s=Il(null==t?void 0:t.search,"__experiment_variant");e&&s&&(i.zp(`previewing web experiments ${e} && ${s}`),this.getWebExperiments(t=>{this.Vp(parseInt(e),s,t)},!1,!0))}}loadIfEnabled(){this.Ar.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Ar.disable_web_experiments&&!e)return t([]);const s=this._instance.get_property("$web_experiments");if(s&&!i)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Ar.token}`),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}Vp(t,e,s){const n=s.filter(i=>i.id===t);n&&n.length>0&&(i.zp(`Previewing web experiment [${n[0].name}] with variant [${e}]`),this.Up(n[0].name,e,n[0].variants[e].transforms))}static Wp(t,e){return!F(t.conditions)&&i.Gp(t,e)&&i.Qp(t)}static Gp(t,e){var s;if(F(t.conditions)||F(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=i.getWindowLocation();if(n){var r,o,l;const i=So(e,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||jd[null!==(o=null===(l=t.conditions)||void 0===l?void 0:l.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,i)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static Qp(t){var i;if(F(t.conditions)||F(null===(i=t.conditions)||void 0===i?void 0:i.utm))return!0;const e=Ul();if(e.utm_source){var s,n,r,o,l,a,u,h;const i=!(null===(s=t.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=t.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==e.utm_campaign,d=!(null===(r=t.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=t.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==e.utm_source,c=!(null===(l=t.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)||(null===(a=t.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)==e.utm_medium,v=!(null===(u=t.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)||(null===(h=t.conditions)||void 0===h||null===(h=h.utm)||void 0===h?void 0:h.utm_term)==e.utm_term;return i&&c&&v&&d}return!1}static zp(t,...i){Us.info(`[WebExperiments] ${t}`,i)}Up(t,e,s){this._is_bot()?i.zp(Nd):"control"!==e?s.forEach(s=>{if(s.selector){var n;i.zp(`applying transform of variant ${e} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(t=>{const i=t;s.html&&(i.innerHTML=s.html),s.css&&i.setAttribute("style",s.css)})}}):i.zp("Control variants leave the page unmodified.")}_is_bot(){return e&&this._instance?Uu(e,this.Ar.custom_blocked_useragents):void 0}}},mc),Pc={conversations:class{constructor(t){this._instance=t,this.Zp=void 0,this._conversationsManager=null,this.Jp=!1,this.ne=null,this.Kp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)return;if(this.Xp=t.ok,!t.ok)return;const i=t.config.conversations;F(i)||(N(i)?this.Zp=i:(this.Zp=i.enabled,this.ne=i),this.loadIfEnabled())}reset(){var t;null===(t=this._conversationsManager)||void 0===t||t.reset(),this._conversationsManager=null,this.Zp=void 0,this.ne=null,this.Xp=void 0,this.Kp=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.Jp)return;if(this._instance.config.disable_conversations)return;if(Vr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=null==d?void 0:d.__PosthogExtensions__;if(t&&!R(this.Zp)&&this.Zp)if(this.ne&&this.ne.token){this.Jp=!0;try{const i=t.initConversations;if(i)return this.Yp(i),void(this.Jp=!1);const e=t.loadExternalDependency;if(!e)return void this.tg(Ys);e(this._instance,"conversations",i=>{i||!t.initConversations?this.tg("Could not load conversations script",i):this.Yp(t.initConversations),this.Jp=!1})}catch(t){this.tg("Error initializing conversations",t),this.Jp=!1}}else Ld.error("Conversations enabled but missing token in remote config.")}Yp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.Kp=!1,Ld.info("Conversations loaded successfully")}catch(t){this.tg("Error completing conversations initialization",t)}else Ld.error("Cannot complete initialization: remote config is null")}tg(t,i){Ld.error(t,i),this._conversationsManager=null,this.Jp=!1,this.Kp=!0}show(){this._conversationsManager?this._conversationsManager.show():Ld.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Zp&&!I(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Vr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Xp?"remote_config_failed":R(this.Zp)?this.Xp?"disabled_in_project":"remote_config_pending":this.Zp?F(this.ne)||!this.ne.token?"missing_token":(null==d?void 0:d.__PosthogExtensions__)?this.Jp?"initializing":this.Kp?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return J(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(Ld.warn(Ud),null)})()}getMessages(t,i){var e=this;return J(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Ld.warn(Ud),null)})()}markAsRead(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Ld.warn(Ud),null)})()}getTickets(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Ld.warn(Ud),null)})()}requestRestoreLink(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Ld.warn(Ud),null)})()}restoreFromToken(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Ld.warn(Ud),null)})()}restoreFromUrlToken(){var t=this;return J(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ld.warn(Ud),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}nd(){var t;null===(t=this._conversationsManager)||void 0===t||t.setIdentity()}sd(){var t;null===(t=this._conversationsManager)||void 0===t||t.clearIdentity()}}},Cc={logs:class extends Kd{constructor(t){super({get(){var i;return null==t||null===(i=t.config)||void 0===i?void 0:i.logs},captureHintKey:Dn,get remoteConfigWillArrive(){var i,e;return!(null===(i=t.qu)||void 0===i?void 0:i.call(t))||!!(null===(e=d._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[t.config.token])||void 0===e?void 0:e.config)}},()=>function(t){var i;const e={};if(e.distinctId=t.get_distinct_id(),t.sessionManager){const{sessionId:i,windowId:s,sessionStartTimestamp:n,lastActivityTimestamp:r}=t.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i,e.windowId=s,F(n)||(e.sessionStartTimestamp=n),F(r)||(e.lastActivityTimestamp=r)}if((null==d||null===(i=d.location)||void 0===i?void 0:i.href)&&(e.currentUrl=t.config.disable_capture_url_hashes?vi(d.location.href):d.location.href),t.featureFlags){const i=t.featureFlags.getFlags();i&&i.length>0&&(e.activeFeatureFlags=i)}return e}(t)),this._instance=t,this.name=uh,this.Fv()}get Rv(){return this._instance.__loaded}Av(){const t=Bs("[logs]"),i=null==d?void 0:d.__PosthogExtensions__;if(!i)return void t.error("PostHog Extensions not found.");const e=i.loadExternalDependency;if(e)return t=>{e(this._instance,"logs",e=>{const s=i.logs;t(e,(null==s?void 0:s.initializeLogs)?{initialize:t=>s.initializeLogs(t),replay(t,i){var e;return null===(e=s.replayConsoleBuffer)||void 0===e?void 0:e.call(s,t,i)}}:void 0)})};t.error(Ys)}}},Rc={metrics:class{constructor(t){this._instance=t,this.$=Bs("[metrics]"),this.Ci=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.Ci)return;const i=!!(null===(t=this._instance.config.metrics)||void 0===t?void 0:t.network);i&&!this.eg?this.eg=(t=>{let i=!0;const e=()=>i?(t=>{var i;const e=null===(i=t.config.metrics)||void 0===i?void 0:i.network;return!0===e?{}:e||void 0})(t):void 0,s=ec(t,e),n=sc(t,e);return()=>{i=!1,s(),n()}})(this._instance):!i&&this.eg&&(this.eg(),this.eg=void 0)}Lv(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.metrics;var e;return this.Ev&&this.Nv===i||(null===(e=this.Ev)||void 0===e||e.reset(),this.Nv=i,this.Ev=new Ns(this.Dv(),function(t){var i,e,s,n,r;const o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(i),this.$)),this.Ev}count(t,i=1,e){this.Lv().count(t,i,e)}gauge(t,i,e){this.Lv().gauge(t,i,e)}histogram(t,i,e){this.Lv().histogram(t,i,e)}flush(t){if(!this.Ev)return Promise.resolve();if(t){const i=this.Ev.drainWindow();return i&&this.po(i,t),Promise.resolve()}return this.Ev.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var t;null===(t=this.Ev)||void 0===t||t.reset()}dispose(){var t,i;this.Ci=!0,null===(t=this.eg)||void 0===t||t.call(this),this.eg=void 0,null===(i=this.Ev)||void 0===i||i.reset()}Dv(){const t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},po:t=>i.po(t),getLibraryId:()=>Gs.LIB_NAME,getLibraryVersion:()=>Gs.LIB_VERSION}}po(t,i){return new Promise(e=>{let s=!1;const n=t=>{s||(s=!0,clearTimeout(r),e(t))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(wi(wi({method:"POST",url:this.ig(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i}),{},{fireCallbackOnDrop:!0,callback(t){const i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error(`metrics request failed with status ${i}`)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`metrics request failed with status ${i}`)})}}}))})}ig(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Oc={webMCP:class{constructor(t){this._instance=t,this.ng=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.ng)return;const t=null==s?void 0:s.modelContext;if(!t||!T(t.registerTool))return;const i=nc.get(t);if(i)return i.instances.add(this._instance),void(this.ng=!0);const e={instances:new Set([this._instance])},n=t.registerTool,r=this;qh(t,"registerTool",t=>{const i=t;return function(t,...s){let n=t;try{n=r.sg(t,e)}catch(e){return i.call(this,t,...s)}return i.call(this,n,...s)}}),t.registerTool!==n&&(nc.set(t,e),this.ng=!0)}sg(t,i){if(!t||!T(t.execute))return t;const e=t.execute,s=this,{tool:n,injected:r}=function(t,i){const e={intent:!1,model:!1},s=t.inputSchema;if(!function(t){return!!R(t)||P(t)&&Object.keys(t).every(t=>rc.has(t)||t.startsWith("x-"))&&!0!==t.additionalProperties&&!P(t.additionalProperties)&&(!t.type||"object"===t.type)&&(!t.properties||P(t.properties))&&(!t.required||k(t.required))}(s))return{tool:hc(t),injected:e};const n=(null==s?void 0:s.properties)||{},r=t=>uc(n,t)||k(null==s?void 0:s.required)&&s.required.includes(t);if(e.intent=i.intent&&!r("context"),e.model=i.model&&!r("llm_model"),!e.intent&&!e.model)return{tool:hc(t),injected:e};const o=wi({},n),l=k(null==s?void 0:s.required)?[...s.required]:[];return e.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},l.includes("context")||l.push("context")),e.model&&(o.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},l.includes("llm_model")||l.push("llm_model")),{tool:hc(t,wi(wi({},s),{},{type:(null==s?void 0:s.type)||"object",properties:o,required:l})),injected:e}}(t,function(t){const i={intent:!1,model:!1};for(const e of t.instances){const t=ac(e.config.capture_webmcp);i.intent||(i.intent=!0===(null==t?void 0:t.intent)),i.model||(i.model=!0===(null==t?void 0:t.model))}return i}(i));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const l=new Date,a=function(t,i){if(!P(t))return{};try{const e=i.intent?dc(t.context,2048,!0):void 0,s=i.model?dc(t.llm_model,256):void 0;return wi(wi({},e&&"{}"!==e?{intent:e}:{}),s&&"unknown"!==s.toLowerCase()?{model:s}:{})}catch(t){return{}}}(o[0],r),u=function(t,i){const e=t[0];if(!P(e))return t;try{const s=i.intent&&uc(e,"context"),n=i.model&&uc(e,"llm_model");if(!s&&!n)return t;const r=wi({},e);return s&&delete r.context,n&&delete r.llm_model,[r,...t.slice(1)]}catch(i){return t}}(o,r);let h;try{h=e.apply(this===n?t:this,u)}catch(t){throw s.rg(i,n,l,{error:t,errorResult:!1},a),t}if((d=h)&&"function"==typeof d.then)return Promise.resolve(h).then(t=>{const e=cc(t)?{error:t,errorResult:!0}:void 0;return s.rg(i,n,l,e,a),t},t=>{throw s.rg(i,n,l,{error:t,errorResult:!1},a),t});var d;const c=cc(h)?{error:h,errorResult:!0}:void 0;return s.rg(i,n,l,c,a),h}}),n}rg(t,i,e,s,r){const o=Date.now()-e.getTime();let l;for(const u of t.instances){var a;const t=ac(u.config.capture_webmcp);if(t){s&&!l&&(l=gc(s.error,s.errorResult));try{u.capture("$mcp_tool_call",wi(wi(wi({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==n?void 0:n.hostname,$mcp_duration_ms:o,$mcp_is_error:!!s},l?{$mcp_error_type:l.type,$mcp_error_message:l.message}:{}),t.intent&&r.intent?{$mcp_intent:r.intent,$mcp_intent_source:"context_parameter"}:{}),t.model&&r.model?{$mcp_llm_model:r.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:e})}catch(t){continue}if(s&&l&&u.exceptions&&(null===(a=u.exceptionObserver)||void 0===a?void 0:a.isEnabled))try{const t={$exception_list:pc(u.exceptions,s,l.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==n?void 0:n.hostname};u.exceptionObserver.captureException(t)}catch(t){}}}}}};Ah.__defaultExtensionClasses=wi({},wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi({},mc),yc),bc),wc),$c),Sc),Ec),xc),kc),Tc),Pc),Cc),Rc),Oc));const Ac=function(){Gs.SDK_DIST_CHANNEL="npm";const i=ch[kh]=new Ah;return function(){function i(){i.done||(i.done=!0,Pu=!1,Dr(ch,function(t){t._dom_loaded()}))}(null==s?void 0:s.addEventListener)?"complete"===s.readyState?i():qr(s,"DOMContentLoaded",i,{capture:!1}):t&&Us.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),i}();var Ic=Ac;export{ua as Compression,$a as DEFAULT_PRODUCT_TOUR_APPEARANCE,ba as DisplaySurveyType,Ah as PostHog,Sa as ProductTourEventName,xa as ProductTourEventProperties,ma as SurveyEventName,ya as SurveyEventProperties,ha as SurveyEventType,ca as SurveyPosition,_a as SurveyQuestionBranchingType,pa as SurveyQuestionType,ga as SurveySchedule,va as SurveyTabPosition,fa as SurveyType,da as SurveyWidgetType,Ic as default,Ac as posthog,Ca as severityLevels};
1
+ const t="u">typeof window?window:void 0,i="u">typeof globalThis?globalThis:t,e=null==i?void 0:i.navigator,s=null==i?void 0:i.document,n=null==i?void 0:i.location,r=null==i?void 0:i.fetch,o=(null==i?void 0:i.XMLHttpRequest)&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,l=null==i?void 0:i.AbortController,a=null==i?void 0:i.CompressionStream,u=null==e?void 0:e.userAgent,h="undefined"!=typeof globalThis?globalThis:t;h&&"undefined"==typeof self&&(h.self=h),h&&"undefined"==typeof File&&(h.File=function(){});const d=null!=t?t:{},c="0.9.8",v={DEBUG:!1,LIB_VERSION:c,LIB_NAME:"browser-common",JS_SDK_VERSION:c};var f=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),p=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({});const _=["$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"],g=["token"];function m(t,i){return-1!==t.indexOf(i)}const y=function(t){return t.trim()},b=function(t){return t.replace(/^\$/,"")};function w(t){var i;const e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}const S=Object.prototype,x=S.hasOwnProperty,E=S.toString,k=Array.isArray||function(t){return"[object Array]"===E.call(t)},T=t=>"function"==typeof t,P=t=>t===Object(t)&&!k(t),C=t=>{if(P(t)){for(const i in t)if(x.call(t,i))return!1;return!0}return!1},R=t=>void 0===t,O=t=>"[object String]"==E.call(t),A=t=>O(t)&&0===t.trim().length,I=t=>null===t,F=t=>R(t)||I(t),M=t=>"[object Number]"==E.call(t)&&t==t,D=t=>M(t)&&t>0,N=t=>"[object Boolean]"===E.call(t),j=t=>m(_,t),L=t=>m(g,t);function U(t){return null===t||"object"!=typeof t}function B(t,i){return{}.toString.call(t)===`[object ${i}]`}function z(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return q(t,Error)}}function H(t){return"u">typeof Event&&q(t,Event)}function q(t,i){try{return t instanceof i}catch(t){return!1}}const V=[!0,"true",1,"1","yes"],W=t=>m(V,t),G=[!1,"false",0,"0","no"];function K(t,i,e,s,n,r,o){try{var l=t[r](o),a=l.value}catch(t){return void e(t)}l.done?i(a):Promise.resolve(a).then(s,n)}function J(t){return function(){var i=this,e=arguments;return new Promise(function(s,n){var r=t.apply(i,e);function o(t){K(r,s,n,o,l,"next",t)}function l(t){K(r,s,n,o,l,"throw",t)}o(void 0)})}}const Y=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Z=new Map,X=function(t,i=[]){if(!t)return!1;const e=function(t,i){let e="";for(let t=0;i.length>t;t++){const s=i[t];e+=s.length+":"+s}return t.length+":"+t+"|"+i.length+":"+e}(t,i),s=Z.get(e);if(void 0!==s)return s;const n=t.toLowerCase(),r=Y.concat(i).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>Z.size||Z.clear(),Z.set(e,r),r};function Q(t,i,e,s,n){return i>e&&(s.warn("min cannot be greater than max."),i=e),M(t)?t>e?(s.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(s.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(s.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+n),Q(null!=n?n:e,i,e,s))}var tt=class{constructor(t){this.C={},this.I=t.I,this.R=Q(t.bucketSize,0,100,t.$),this.A=Q(t.refillRate,0,this.R,t.$),this.O=Q(t.refillInterval,0,864e5,t.$)}F(t,i){const e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i;const e=Date.now(),s=String(t);let n=this.C[s];return n?this.F(n,e):(n={tokens:this.R,lastAccess:e},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(i=this.I)||void 0===i||i.call(this,t)),0===n.tokens)}stop(){this.C={}}};const it="Mobile",et="Android",st="Tablet",nt="Android Tablet",rt="iPad",ot="Apple Watch",lt="Safari",at="BlackBerry",ut="Samsung Internet",ht="Chrome",dt="Chrome iOS",ct="Internet Explorer",vt="Internet Explorer Mobile",ft="Opera",pt="Microsoft Edge",_t="Firefox",gt="Firefox iOS",mt="Nintendo",yt="PlayStation",bt="Xbox",wt="Android Mobile",$t="Mobile Safari",St="Windows",xt="Windows Phone",Et="Nokia",kt="Ouya",Tt="Generic "+it.toLowerCase(),Pt="Generic "+st.toLowerCase(),Ct="Konqueror",Rt="Oculus Browser",Ot="Vivaldi",At="Yandex",It="Whale",Ft="DuckDuckGo",Mt="Pale Moon",Dt="Waterfox",Nt="Brave",jt="Claude",Lt="Codex",Ut="ChatGPT",Bt="Google Search App",zt=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ht=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),qt=new RegExp(bt,"i"),Vt=new RegExp("PlayStation \\w+","i"),Wt=new RegExp("Nintendo \\w+","i"),Gt=new RegExp("BlackBerry|PlayBook|BB10","i"),Kt={"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"},Jt=function(t,i,e,s){i=i||"";const n=function(t){return(null==t?void 0:t.brave)?Nt:null}(e);return n||((null==s?void 0:s.detectGoogleSearchApp)&&m(t,"GSA/")?Bt:m(t," OPR/")&&m(t,"Mini")?"Opera Mini":m(t," OPR/")?ft:Gt.test(t)?at:m(t,"IEMobile")||m(t,"WPDesktop")?vt:m(t,"OculusBrowser")?Rt:m(t,"SamsungBrowser")?ut:m(t,"Edge")||m(t,"Edg/")?pt:m(t,"Vivaldi/")?Ot:m(t,"YaBrowser/")?At:m(t,"Whale/")?It:m(t,"DuckDuckGo/")||m(t,"Ddg/")?Ft:m(t,"Claude/")?jt:m(t,"Codex/")?Lt:m(t,"ChatGPT/")?Ut:m(t,"FBIOS")?"Facebook Mobile":m(t,"UCWEB")||m(t,"UCBrowser")?"UC Browser":m(t,"CriOS")?dt:m(t,"CrMo")||m(t,ht)?ht:m(t,et)&&m(t,lt)?wt:m(t,"FxiOS")?gt:m(t.toLowerCase(),Ct.toLowerCase())?Ct:m(t,"Brave/")?Nt:((t,i)=>i&&m(i,"Apple")||function(t){return m(t,lt)&&!m(t,ht)&&!m(t,et)}(t))(t,i)?m(t,it)?$t:lt:m(t,"PaleMoon/")?Mt:m(t,"Waterfox/")?Dt:m(t,_t)?_t:m(t,"MSIE")||m(t,"Trident/")?ct:m(t,"Gecko")?_t:"")},Yt={[vt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[pt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ht]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[dt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[lt]:[zt],[$t]:[zt],[ft]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[_t]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[gt]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ct]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[at]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),zt],[wt]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ut]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Rt]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Ot]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[At]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[It]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Nt]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[jt]:[Ht],[Lt]:[Ht],[Ut]:[Ht],[Ft]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Mt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Dt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Bt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ct]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Zt=function(t,i,e,s){const n=Jt(t,i,e,s),r=Yt[n];if(R(r))return null;for(let i=0;r.length>i;i++){const e=t.match(r[i]);if(e)return parseFloat(e[e.length-2])}return null},Xt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[bt,t&&t[1]||""]],[new RegExp(mt,"i"),[mt,""]],[new RegExp(yt,"i"),[yt,""]],[Gt,[at,""]],[new RegExp(St,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[xt,""];if(new RegExp(it).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];const e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){let t=Kt[e[1]]||"";return/arm/i.test(i)&&(t="RT"),[St,t]}return[St,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let i="";return t&&t.length>=3&&(i=R(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[et,[t[2],t[3],t[4]||"0"].join(".")]:[et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Qt=function(t){for(let i=0;Xt.length>i;i++){const[e,s]=Xt[i],n=e.exec(t),r=n&&(T(s)?s(n,t):s);if(r)return r}return["",""]},ti=function(t){return Wt.test(t)?mt:Vt.test(t)?yt:qt.test(t)?bt:new RegExp(kt,"i").test(t)?kt:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?xt:/iPad/.test(t)?rt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?ot:Gt.test(t)?at:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Et,"i").test(t)?Et:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(it).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?et:nt:new RegExp("(pda|Mobile)","i").test(t)?Tt:new RegExp(st,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?Pt:""},ii=function(t,i){var e;const s=ti(t);return s===rt||s===nt||"Kobo"===s||"Kindle Fire"===s||s===Pt?st:s===mt||s===bt||s===yt||s===kt?"Console":s===ot?"Wearable":s?it:"Android"===(null==i?void 0:i.userAgentDataPlatform)&&(null!==(e=null==i?void 0:i.maxTouchPoints)&&void 0!==e?e:0)>0?600>Math.min(null!==(n=null==i?void 0:i.screenWidth)&&void 0!==n?n:0,null!==(r=null==i?void 0:i.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==i?void 0:i.devicePixelRatio)&&void 0!==o?o:1)?it:st:"Desktop";var n,r,o},ei=/\bFBAV\/(\d+(?:\.\d+)*)/i,si=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ei],[/\bFBAN\/EMA\b/i,"Facebook Lite",ei],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ei],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],ni="[Truncated]",ri="[Unserializable]";function oi(t){let i="";for(let e=0;t.length>e;e++){const s=t.charCodeAt(e);if(55296>s||s>56319)i+=56320>s||s>57343?t[e]:"�";else{const s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}function li(t,i){if(!i)return t;let e=[];try{e=Object.keys(i)}catch(t){e=[]}for(const s of e){let e;try{e=i[s]}catch(t){e=ri}Object.defineProperty(t,s,{value:e,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;const ai=3e5;var ui=class{record(t){if("too-large"===t.kind)return;if("retry-later"!==t.kind)return void this.reset();if(!t.retryAfterMs)return;const i=this.isOpen(),e=Date.now(),s=Math.min(t.retryAfterMs,ai);if(!i)return this.ts=e,void(this.es=e+s);this.es=Math.max(this.es,Math.min(e+s,this.ts+ai))}remainingMs(){const t=Date.now();if(this.ts-5e3>t)return this.reset(),0;const i=Math.min(ai,Math.max(0,this.es-t));return 0===i&&this.reset(),i}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const hi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function di(t,i){return"string"==typeof(e=t)&&hi.test(e)?t:i();var e}function ci(t,i){const e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function vi(t){return t?t.split("#")[0]:t}function fi(t){try{return t()}catch(t){return}}function pi(t,i){const e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function _i(t,i,e){return gi.apply(this,arguments)}function gi(){return(gi=J(function*(t,i,e){let s;try{return yield Promise.race([t,new Promise((t,n)=>{s=pi(()=>{try{null==e||e(),t()}catch(t){n(t)}},i)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function mi(t){return mi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(t)}function yi(t,i,e){return(i=function(t){var i=function(t){if("object"!=mi(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var e=i.call(t,"string");if("object"!=mi(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mi(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function bi(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,s)}return e}function wi(t){for(var i=1;arguments.length>i;i++){var e=null!=arguments[i]?arguments[i]:{};i%2?bi(Object(e),!0).forEach(function(i){yi(t,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):bi(Object(e)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}return t}let $i,Si,xi,Ei;function ki(t){var i;const e=globalThis._posthogChunkIds,s=globalThis._debugIds;if(!e&&!s)return;const n=e?Object.keys(e):[],r=s?Object.keys(s):[];if(Ei&&Ti(e,n,Si)&&Ti(s,r,xi))return Ei;Si=e?wi({},e):void 0,xi=s?wi({},s):void 0,Ei={},null!==(i=$i)&&void 0!==i||($i={});const o=(i,e)=>{for(const n of i){const i=e[n];if(!i)continue;const r=null==$i?void 0:$i[n];if(r){Ei[r]=i;continue}const o=t(n);for(let t=o.length-1;t>=0;t--){var s;const e=null===(s=o[t])||void 0===s?void 0:s.filename;if(e){Ei[e]=i,$i[n]=e;break}}}};return s&&o(r,s),e&&o(n,e),Ei}function Ti(t,i,e){return t&&e?i.length===Object.keys(e).length&&i.every(i=>t[i]===e[i]):t===e}var Pi=class{constructor(t,i,e=[]){this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i={}){const e=i&&i.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(e,i,0).apply(t),n=this.buildParsingContext(i),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,e),$exception_level:"error"}}modifyFrames(t){var i=this;return J(function*(){for(const e of t)e.stacktrace&&e.stacktrace.frames&&k(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e;let s,n;if(null!=t.cause&&(s=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)}catch(t){}return wi(wi({},t),{},{cause:s,stack:n,errors:null===(e=t.errors)||void 0===e?void 0:e.map(t=>this.parseStacktrace(t,i))})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(const e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return J(function*(){let e=t;for(const t of i.modifiers)e=yield t(e);return e})()}convertToExceptionList(t,i){const e=[],s=(t,n,r)=>{var o;const l=e.length,a=void 0===n?wi(wi({type:"string"==typeof i.type&&i.type.length>0?i.type:"generic"},"boolean"==typeof i.handled?{handled:i.handled}:void 0===i.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof i.synthetic?i.synthetic:t.synthetic,exception_id:l}):{type:"chained",source:r,synthetic:t.synthetic,exception_id:l,parent_id:n},u={type:t.type,value:t.value,mechanism:a};t.stack&&(u.stacktrace={type:"raw",frames:t.stack}),e.push(u),t.cause&&s(t.cause,l,"cause");for(const i of null!==(o=t.errors)&&void 0!==o?o:[])s(i,l,"member")};return s(t),e}buildParsingContext(t){var i;return{chunkIdMap:ki(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}getAggregateErrors(t){try{if(z(t)){let e=Object.getPrototypeOf(t);for(let s=0;e&&100>s;s++){var i;const s=null===(i=Object.getOwnPropertyDescriptor(e,"constructor"))||void 0===i?void 0:i.value;if("function"==typeof s&&"AggregateError"===s.name){const i=t.errors;return k(i)?i:void 0}e=Object.getPrototypeOf(e)}}}catch(t){}}buildCoercingContext(t,i,e=0){let s=0,n=0,r=!1;const o=new Set,l=[],a={},u=(t,i,e=0)=>{const u=h(i,e),d=u.apply;if(u.apply=i=>{l.push(t);try{return d(i)}finally{l.pop()}},e>4||e>0&&-1!==l.indexOf(t))return this.coerceFallback(u);const c="object"==typeof t&&null!==t||"function"==typeof t;if(0===e&&s>=50||c&&o.has(t))return;c&&o.add(t),0===e&&s++;const v=this.getAggregateErrors(t);let f,p;r||(r=!!v);try{if(f=this.applyCoercers(t,u),!f)throw a}catch(t){if(t===a)return void(0===e&&s--);if(!r)throw t;f=this.coerceFallback(u)}if(!v||s>=50)return f;try{p=v.length}catch(t){return f}if(!Number.isInteger(p)||0>p||p>4294967295)return f;const _=[];for(let t=0;50>s&&1e3>n&&p>t;t++){let e;n++;try{e=u.next(v[t])}catch(t){s++,e=this.coerceFallback(h(i+1))}e&&_.push(e)}return wi(wi({},f),{},{errors:_})},h=(e,s=0)=>wi(wi({},i),{},{syntheticException:0==e?i.syntheticException:void 0,mechanism:0==e?t:{},apply(t){const i=u(t,e,s+1);if(!i)throw a;return i},next:t=>u(t,e+1)}),d=h(e);return wi(wi({},d),{},{apply:t=>{var i;return null!==(i=u(t,e))&&void 0!==i?i:this.coerceFallback(d)}})}};const Ci=/^([a-z][a-z0-9.+-]+):/i,Ri=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function Oi(t){if(!t||"<anonymous>"===t)return!1;const i=Ci.exec(t);return!i||Ri.includes(i[1].toLowerCase())}function Ai(t,i,e,s,n){const r={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:Oi(i)};return R(s)||(r.lineno=s),R(n)||(r.colno=n),r}const Ii=(t,i)=>{const e=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return e||s?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?`safari-extension:${i}`:`safari-web-extension:${i}`]:[t,i]},Fi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Mi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Di=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ni=(t,i)=>{const e=Fi.exec(t);if(e){const[,t,s,n]=e;return Ai(i,t,"?",+s,+n)}const s=Mi.exec(t);if(s){if(s[2]&&0===s[2].indexOf("eval")){const t=Di.exec(s[2]);t&&(s[2]=t[1],s[3]=t[2],s[4]=t[3])}const[t,e]=Ii(s[1]||"?",s[2]);return Ai(i,e,t,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},ji=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Li=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ui=(t,i)=>{const e=ji.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=Li.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],s=e[1]||"?";return[s,t]=Ii(s,t),Ai(i,t,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Bi=/\(error: (.*)\)/;function zi(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function Hi(t){for(let i=1;10>=i;i++){const e=t.length-2*i;if(0>e)break;let s=!0;for(let n=0;i>n;n++)if(!zi(t[e+n],t[e+i+n])){s=!1;break}if(s){for(let s=0;i>s;s++)t[e+s]=t[e+i+s];return t.length=e+i,{start:e,length:i}}}}function qi(t,i){const e=i.start+i.length,s=Wi(t,i);s&&t.splice(e+s===t.length?e:i.start,s)}function Vi(t,i){let e=i.start;for(;e>0&&zi(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function Wi(t,i){const e=i.start+i.length;let s=e;for(;t.length>s&&zi(t[s],t[s-i.length]);)s++;return s-e}function Gi(t,i){const e=i[0];let s=t.length-(e?Vi(t,e):0);for(const e of i)s-=Wi(t,e);return s}function Ki(t,i,e){for(let s=0;t.length>s;s++){const n=t[(i+s)%t.length],r=t[(e+s)%t.length];if(n!==r)return r>n}return!1}var Ji=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){const e=O(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){const i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${i}: ${t.message}`:i}isDOMException(t){return B(t,"DOMException")}isDOMError(t){return B(t,"DOMError")}},Yi=class{match(t){return z(t)}coerce(t,i){var e;const s=this.getStack(t),n=void 0===s?null===(e=i.syntheticException)||void 0===e?void 0:e.stack:void 0,r=!!n;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=s?s:n,cause:t.cause?i.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,i){const e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){try{const i=t.stacktrace;if("string"==typeof i&&i.length>0)return i;const e=t.stack;return"string"==typeof e&&e.length>0?e:void 0}catch(t){return}}},Zi=class{match(t){return!!B(t,"ErrorEvent")&&(null!=t.error||this.hr(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);const s=i.apply(t.message);return wi(wi({},s),{},{stack:null!==(e=this.vr(t))&&void 0!==e?e:s.stack,synthetic:!0})}hr(t){return O(t.message)&&t.message.length>0}vr(t){var i,e;const s=t,n=null!==(i=s.lineno)&&void 0!==i?i:0,r=null!==(e=s.colno)&&void 0!==e?e:0;if(O(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Xi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Qi=class{match(t){return"string"==typeof t}coerce(t,i){var e;const[s,n]=this.getInfos(t);return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}getInfos(t){let i="Error",e=t;const s=t.match(Xi);return s&&(i=s[1],e=s[2]),[i,e]}};const te=["fatal","error","warning","log","info","debug"];function ie(t,i=40){const e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(let t=e.length;t>0;t--){const s=e.slice(0,t).join(", ");if(i>=s.length)return t===e.length?s:s.length>i?`${s.slice(0,i)}...`:s}return""}var ee=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,s;const n=this.getErrorPropertyFromObject(t);return n?i.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null===(s=i.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(H(t))return t.constructor.name;const i="name"in t?t.name:void 0;return O(i)&&!A(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){let i=`'${t.name}' captured as exception`;return"message"in t&&"string"==typeof t.message&&(i+=` with message: '${t.message}'`),i}if("message"in t&&"string"==typeof t.message)return t.message;const i=this.getObjectClassName(t);return`${i&&"Object"!==i?`'${i}'`:"Object"} captured as exception with keys: ${ie(t)}`}isSeverityLevel(t){return O(t)&&!A(t)&&te.indexOf(t)>=0}getStack(t){try{return O(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:O(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(const i in t)if({}.hasOwnProperty.call(t,i)){const e=t[i];if(z(e))return e}}getObjectClassName(t){try{const i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},se=class{match(t){return H(t)}coerce(t,i){var e;const s=t.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${ie(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},ne=class{match(t){return U(t)}coerce(t,i){var e;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},re=class{match(t){return B(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!H(t))return!1;try{const i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e;const s=this.getUnhandledRejectionReason(t);return U(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}:i.apply(s)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}};const oe="$message",le="$timestamp",ae=new Set([oe,le]),ue={enabled:!0,max_bytes:32768};function he(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:ue.enabled,max_bytes:ce(t.max_bytes,ue.max_bytes)}:wi({},ue)}var de=class{constructor(t){this.ns=[],this.ss=0,this.Ar=he(t)}setConfig(t){this.Ar=he(t),this.rs()}add(t){const i=function(t){let i;try{i=w(t)}catch(t){return}try{const t=JSON.parse(i);if(!P(t))return;const e=t,s=e[oe],n=e[le];if(!O(s)||0===s.trim().length)return;if(!O(n)&&!M(n))return;return{step:e,json:i}}catch(t){return}}(t);if(!i)return;const e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;const i=encodeURIComponent(t);let e=0;for(let t=0;i.length>t;t++)"%"===i[t]?(e+=1,t+=2):e+=1;return e}(i.json);e>this.Ar.max_bytes||(this.ns.push({step:i.step,bytes:e}),this.ss+=e,this.rs())}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Ar.max_bytes&&this.ns.length>0;){const t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function ce(t,i){if(!M(t)||1/0===t||-1/0===t)return i;const e=Math.floor(t);return 0>e?i:e}const ve=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function fe(t){return"string"==typeof t||t}function pe(t){return"string"==typeof t?t:void 0}const _e=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],ge="NativeGzipValidationError",me=t=>t.length>=2&&31===t[0]&&139===t[1],ye=(t,i)=>t===p.GZipJS||i===p.GZipJS||"gzip"===i,be=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):"");let we;const $e=t=>{throw ci(ge,`Native gzip produced invalid output: ${t}`)},Se=(xe=J(function*(t,i){18>t.size&&$e("too-short");const e=new Uint8Array(yield t.slice(0,10).arrayBuffer());me(e)&&8===e[2]||$e("invalid-header");const s=new DataView(yield t.slice(t.size-8).arrayBuffer());s.getUint32(0,!0)!==(t=>{const i=(()=>{if(we)return we;we=[];for(let t=0;256>t;t++){let i=t;for(let t=0;8>t;t++)i=1&i?3988292384^i>>>1:i>>>1;we[t]=i>>>0}return we})();let e=4294967295;for(let s=0;t.length>s;s++)e=i[255&(e^t[s])]^e>>>8;return(4294967295^e)>>>0})(i)&&$e("invalid-crc");const n=i.length>>>0;s.getUint32(4,!0)!==n&&$e("invalid-size")}),function(t,i){return xe.apply(this,arguments)});var xe;function Ee(){return Ee=J(function*(t,i=!0,e){try{const i=(new TextEncoder).encode(t),e=new globalThis.CompressionStream("gzip"),n=e.writable.getWriter(),r=n.write(i).then(()=>n.close()).catch((s=J(function*(t){try{yield n.abort(t)}catch(t){}throw t}),function(t){return s.apply(this,arguments)})),o=new Response(e.readable).blob(),[l]=yield Promise.all([o,r]);return yield Se(l,i),l}catch(t){if(null==e?void 0:e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}var s}),Ee.apply(this,arguments)}function ke(t,i){if(null==t)return{};var e,s,n=function(t,i){if(null==t)return{};var e={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(i.includes(s))continue;e[s]=t[s]}return e}(t,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(s=0;r.length>s;s++)i.includes(e=r[s])||{}.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}const Te="[redacted]",Pe=/^[A-Za-z0-9+/\n\r]+=*$/,Ce=/^[A-Za-z0-9_-]+={0,2}$/,Re=/[-_]/,Oe=/^data:[^,\s]*;base64,/i,Ae=/^[A-Za-z0-9+/_-]+={0,2}$/,Ie=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Fe=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Me=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,De=/[\s<>"]/,Ne=new RegExp(Me.source,"i"),je=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Le=new RegExp(`^${je.source}`,"i"),Ue=new RegExp(je.source,"gi"),Be=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,ze=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,He=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,qe=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Ve=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,We=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,Ge=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Ke=/\b\d(?:[ ./-]?\d){12,}\b/g,Je=/\d+/g,Ye=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Ze=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function Xe(t){return function(t){return Fe.test(t)}(t)||Be.test(t)||ze.test(t)}function Qe(t){return t.split("&",129).length>128}function ts(t,i,e){return Xe(t)||i.includes(";")&&function(t){return t.split(";").some(t=>Xe(t.split("=",1)[0]))}(i)?Te:Ne.test(i)?e?os(i,{allowNestedUrls:!1,stripPunctuation:!0}):Te:i}function is(t,i){const e=new URLSearchParams;let s=!1,n=!1;for(const[r,o]of new URLSearchParams(t)){const t=ls(r),l=ls(o);s||(s=t!==r||l!==o);const a=ts(t,l,i);s||(s=a!==l),n=Xe(t)||a!==l,e.append(t,a)}return{changed:s,lastFieldSensitive:n,serialized:e.toString()}}function es(t,i){if(!t.includes("="))return{value:ss(t,i),lastFieldSensitive:!1};const e=is(t,i);return{value:e.changed?e.serialized:t,lastFieldSensitive:e.lastFieldSensitive}}function ss(t,i){return i?os(t,{allowNestedUrls:!1,stripPunctuation:!0}):Ne.test(t)?Te:t}function ns(t,i,e){return"#"===t?!i.fragment&&(i.fragment=!0):"?"===t&&(i.fragment?"="!==e&&!i.fragmentQuery&&(i.fragmentQuery=!0):!i.query&&(i.query=!0))}function rs(t,i){var e;if(t.length>8192&&Le.test(t))return Te;const{address:s,suffix:n}=i.stripPunctuation?function(t){let i=t.length;for(;i>0&&".,;:!?)]}'".includes(t[i-1]);)i--;return{address:t.slice(0,i),suffix:t.slice(i)}}(t):{address:t,suffix:""};let r;try{r=new URL(s)}catch(t){return Te+n}const o=r.search.slice(1),l=""!==r.hash,a=function(t){const i=t.slice(1),e=i.indexOf("?");return 0>e?{head:i,tail:null}:{head:i.slice(0,e),tail:i.slice(e+1)}}(r.hash);if(Qe(o)||Qe(a.head)||Qe(null!==(e=a.tail)&&void 0!==e?e:""))return Te+n;let u=!1;(r.username||r.password)&&(r.username=Te,r.password="",u=!0);const h=is(o,i.allowNestedUrls);h.changed&&(r.search=h.serialized,u=!0);const d=es(a.head,i.allowNestedUrls),c=null===a.tail?null:(v=a.tail,d.lastFieldSensitive?{value:""===v?"":Te,lastFieldSensitive:!0}:es(v,i.allowNestedUrls));var v;const f=null===c?d.value:`${d.value}?${c.value}`;f!==r.hash.slice(1)&&(r.hash=f,u=!0);const p=l?null!=c?c:d:h;return(u?ls(r.toString()):s)+(p.lastFieldSensitive?"":n)}function os(t,i){return t.replace(Me,e=>function(t,i){const e=function(t){if(!t.includes("://"))return[];const i=[...t.matchAll(Ue)].map(t=>t.index),e=[],s={query:!1,fragment:!1,fragmentQuery:!1};let n=0,r=!1,o="";for(let l=0;t.length>l&&i.length>n;l++){i[n]===l&&(l>0&&"="!==o&&e.push(l),n++);const a=t[l];ns(a,s,o)?(o=a,r=!0):r&&"=&".includes(a)&&(o=a)}return e}(t);if(0===e.length)return rs(t,i);let s="",n=0;for(const r of e)s+=rs(t.slice(n,r),wi(wi({},i),{},{stripPunctuation:!1})),n=r;return s+rs(t.slice(n),i)}(e,wi(wi({},i),{},{stripPunctuation:i.stripPunctuation&&e.length!==t.length})))}function ls(t){return t.replace(Ie,Te)}function as(t,i){return function(t){return t.length>=10240&&(Pe.test(t)||function(t){const i=Oe.exec(t);if(!i)return!1;let e;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Ae.test(e.replace(/[\r\n]/g,""))}(t)||Re.test(t)&&Ce.test(t))}(t)?"[binary data redacted - not supported by PostHog MCP analytics]":function(t,i,e){const s=4*e.maxStringLength;if(t.length>s){const n=i(t.slice(0,function(t,i){let e=i;for(;e>0&&!De.test(t[e-1]);)e--;return e}(t,s)));if(n.length>=2*e.maxStringLength)return n+e.truncationSuffix}return i(t)}(t,t=>function(t){return os(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){let i=t.replace(He," ");return i=i.replace(qe,Te),i=i.replace(Ve,Te),i=i.replace(We,`$1${Te}`),i=i.replace(Ke,hs),i=i.replace(Ge,Te),i=i.replace(Ye,`$1${Te}`),i=i.replace(Ze,`$1${Te}`),i}(ls(t))),i)}function us(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;if(0>n||n>9)return!1;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function hs(t){const i=[];for(let e=Je.exec(t);null!==e;e=Je.exec(t))i.push({digits:e[0],start:e.index,end:e.index+e[0].length});let e="",s=0,n=0;for(;i.length>n;){let r="",o=-1;for(let t=n;i.length>t&&(r+=i[t].digits,19>=r.length);t++)r.length>=13&&us(r)&&(o=t);0>o?n++:(e+=t.slice(s,i[n].start)+Te,s=i[o].end,n=o+1)}return e+t.slice(s)}const ds={}.propertyIsEnumerable;function cs(t,i){try{return ps(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function vs(t,i,e,s){if(0>=e.remainingNodes)return{stringValue:ni};if(e.remainingNodes--,N(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){const e=t.toString(),s=BigInt("9223372036854775808");return t>=s||-s>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const e=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:oi(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ni};if(t instanceof Date){const i=t.getTime(),e=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:"string"==typeof e?oi(e):String(e)}}e.ancestors.add(t);try{try{const n=t.toJSON;if("function"==typeof n)return vs(n.call(t),i,e,s+1)}catch(t){}return k(t)?{arrayValue:{values:fs(t,i,e,s+1)}}:{kvlistValue:{values:ps(t,i,e,s+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:oi(String(t))}}function fs(t,i,e,s){const n=[],r=Math.min(t.length,1e3);let o=0;for(;r>o&&e.remainingNodes>0;o++)try{const r=o in t?t[o]:void 0;if(F(r))continue;n.push(vs(r,i,e,s))}catch(t){n.push({stringValue:ri})}return t.length>o&&n.push({stringValue:ni}),n}function ps(t,i,e,s){const n=[];for(const r in t)if(ds.call(t,r)){if(!r){null==i||i.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=t[r];if(I(o)||R(o))continue;n.push({key:oi(r),value:vs(o,i,e,s)})}catch(t){n.push({key:oi(r),value:{stringValue:ri}})}}return n}function _s(t,i,e){return wi(wi(wi(wi({},li({},t.resourceAttributes)),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}const gs=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function ms(t,i){const e=li({},t),s={};for(const t of gs)({}).hasOwnProperty.call(e,t)&&(s[t]=e[t],delete e[t]);return[...cs(e,i),...cs(s,i)]}const ys={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const bs={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}},ws=bs.info;function $s(t){try{return oi(String(t))}catch(t){return ri}}function Ss(t,i,e,s){const n=t.level||"info",{text:r,number:o}=bs[n]||ws,l=function(t=Date.now()){return String(t)+"000000"}(M(s)?s:void 0),a={};i.distinctId&&(a.posthogDistinctId=i.distinctId),i.sessionId&&(a.sessionId=i.sessionId),i.windowId&&(a["window.id"]=i.windowId),F(i.sessionStartTimestamp)||(a.sessionStartTimestamp=String(i.sessionStartTimestamp)),F(i.lastActivityTimestamp)||(a.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(a["url.full"]=i.currentUrl),i.screenName&&(a["screen.name"]=i.screenName),i.appState&&(a["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(a.feature_flags=i.activeFeatureFlags);const u=wi({},a),h=t.attributes;if(h){let t=[];try{t=Object.keys(h)}catch(i){t=[]}for(const i of t){let t;try{t=h[i]}catch(i){t=ri}Object.defineProperty(u,i,{value:t,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:o,severityText:r,body:{stringValue:$s(t.body)},attributes:cs(u,e)};return t.trace_id&&(d.traceId=t.trace_id),t.span_id&&(d.spanId=t.span_id),R(t.trace_flags)||(d.flags=t.trace_flags),d}function xs(t,i,e){return _s(t,i,e)}function Es(t,i,e,s){return{resourceLogs:[{resource:{attributes:ms(i)},scopeLogs:[{scope:{name:e,version:s},logRecords:t}]}]}}var ks=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=pi(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Ts(){return.75+.5*Math.random()}function Ps(t,i,e,s){const n=Math.min(Math.max(0,i-1),6),r=t*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,t)))*e)}var Cs=class{constructor(t,i,e,s,n,r=()=>Promise.resolve(),o){var l;this._instance=t,this.Ar=i,this.$=e,this.hs=s,this.ds=n,this.vs=r,this.fs=o,this.ps=new ks(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new ui,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=i.maxBufferSize,this.Is=Math.max(null!==(l=i.maxQueueSize)&&void 0!==l?l:i.maxBufferSize,i.maxBufferSize),this.Ms=i.flushIntervalMs,this.Es=i.maxBatchRecordsPerPost,this.Ps=i.rateCapWindowMs,this.Rs=i.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(f.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Ar.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,i){var e;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==t?void 0:t.body))return;const s=this.Os(t);if(null===s)return;if(!s.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ds())return;const n={record:Ss(s,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.hs(),this.$,null==i?void 0:i.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(t){const i=this.Ar.beforeSend;if(!i)return t;const e=k(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Log was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for log:",t),null}return s}Ds(){if(void 0===this.Rs)return!0;const t=Date.now(),i=t-this.xs;return this.Ps>i&&i>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var t=this;return J(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return J(function*(){var i;t.ps.clear();let e=null!==(i=t._instance.getPersistedProperty(f.LogsQueue))&&void 0!==i?i:[];if(0===e.length)return;const s=e.length;let n=0;for(;e.length>0&&s>n;){var r,o;const i=t._s;t.bs=0;const s=Math.min(e.length,t.Es),l=e.slice(0,s),a=Es(l.map(t=>t.record),t.qs(),null!==(r=t.fs)&&void 0!==r?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),u=yield t._instance.js(a);if(t._s!==i)return;if("too-large"===u.kind&&l.length>1)t.Es=Math.max(1,Math.floor(l.length/2)),t.$.warn(`Logs batch of size ${l.length} was too large for the ingestion endpoint, reducing batch size to ${t.Es}`);else{if(t.ws.record(u),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),"retry-later"===u.kind)throw u.error;if("too-large"===u.kind?t.$.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===u.kind&&t.Ar.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Ar.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(l.length),e=null!==(o=t._instance.getPersistedProperty(f.LogsQueue))&&void 0!==o?o:[],n+=l.length,"fatal"===u.kind)throw u.error}}})()}Bs(t){var i=this;return J(function*(){var e;const s=Math.max(0,t-i.bs),n=null!==(e=i._instance.getPersistedProperty(f.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(f.LogsQueue,n.slice(s)),yield i.vs()})()}qs(){return xs(this.Ar,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var i;if(this._instance.optedOut)return;const e=null!==(i=this._instance.getPersistedProperty(f.LogsQueue))&&void 0!==i?i:[];this.Is>e.length||(e.shift(),this.bs++,this.$.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(f.LogsQueue,e),this.Ts>e.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Ps(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const t=this._instance.getPersistedProperty(f.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return J(function*(){i.ps.clear();const e=i.flush().catch(()=>{});void 0!==t?yield _i(e,t):yield e})()}flushWithTimeout(t){var i=this;return J(function*(){const e=i.flush();yield _i(e,t,()=>{e.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=Ts(),this.$.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}};const Rs=/^[0-9a-f]+$/;function Os(t,i,e){return"string"==typeof t&&t.length===i&&t!==e&&Rs.test(t)}const As=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;const Is="00",Fs=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ms(t){return String(t)+"000000"}function Ds(t,i,e,s){let n="";return s&&(n=Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${JSON.stringify(s[t])}`).join(",")),`${t}\0${i}\0${null!=e?e:""}\0${n}`}var Ns=class{constructor(t,i,e){this._instance=t,this.Ar=i,this.$=e,this.Hs=new Map,this.ps=new ks(()=>this.flush().catch(t=>{this.$.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new ui,this.ks=0,this.Ss=1,this.Gs=0}count(t,i=1,e){this.Qs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Qs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Qs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this;const i=this.ys,e=function(){var e=J(function*(){i&&(yield i.catch(()=>{})),yield t.Zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.ys===e&&(this.ys=null)});return this.ys=e,e}drainWindow(){if(0===this.Hs.size)return null;const t=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(t){if(this._instance.isDisabled||this._instance.optedOut)return;const i=this.Os(t);if(null===i)return;if(!i.name||"string"!=typeof i.name)return void this.$.warn("Dropping metric with empty name");if("number"!=typeof i.value||!Number.isFinite(i.value))return void this.$.warn(`Dropping metric '${i.name}': value must be a finite number`);if("count"===i.type&&0>i.value)return void this.$.warn(`Dropping count '${i.name}': counters are monotonic, value must be >= 0`);let e,s;try{e=i.attributes?wi({},i.attributes):void 0,s=Ds(i.type,i.name,i.unit,e)}catch(t){return void this.$.warn(`Dropping metric '${i.name}': attributes could not be serialized`,t)}let n=this.Hs.get(s);if(!n){if(!this.Ks())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Hs.set(s,n)}const r=this.Ws.get(i.name);void 0===r?this.Ws.set(i.name,i.type):r===i.type||this.Vs.has(i.name)||(this.Vs.add(i.name),this.$.warn(`Metric name '${i.name}' is already used as a ${r}; recording it as a ${i.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,i.value);const o=this.Ys();o&&(n.exemplar=wi(wi({},o),{},{value:i.value,timeMs:Date.now()})),this.Fs()}Ys(){try{var t,i;const e=function(t){const i=function(t){if("string"!=typeof t)return;const i=As.exec(t.trim());if(!i)return;const[,e,s,n,r,o]=i;return"ff"===e||"00"===e&&o||!function(t){return Os(t,32,"00000000000000000000000000000000")}(s)||!function(t){return Os(t,16,"0000000000000000")}(n)?void 0:{version:e,traceId:s,spanId:n,flags:r}}(t);return i&&{traceId:i.traceId,spanId:i.spanId,flags:(e=i.flags,1&parseInt(e,16)?"01":Is)};var e}(null===(t=(i=this._instance).getActiveSpan)||void 0===t||null===(t=t.call(i))||void 0===t?void 0:t.traceparent());if(e&&"01"===e.flags)return{traceId:e.traceId,spanId:e.spanId}}catch(t){}}Ks(){return this.Ar.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Ar.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(t,i){switch(t.type){case"count":var e;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Fs.length+1).fill(0)});const e=t.hist;e.count+=1,e.sum+=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.bucketCounts[function(t,i){for(let e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Fs)]+=1;break}}}Os(t){const i=this.Ar.beforeSend;if(!i)return t;const e=k(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Metric was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for metric:",t),null}return s}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Ps(this.Ar.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var t=this;return J(function*(){if(t.ps.clear(),0===t.Hs.size)return;const i=t.Hs;t.Hs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;const e=t.Gs,s=yield t._instance.po(t.Js(i));if(e===t.Gs)switch(t.ws.record(s),"retry-later"===s.kind?(t.ks++,t.Ss=Ts()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),s.kind){case"ok":return;case"retry-later":return t.mo(i),void t.ps.armNoEarlierThan(t.zs());case"too-large":return void t.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.$.error("Failed to send metrics batch:",s.error)}})()}Js(t){return i=this.yo(t),e=function(t,i,e){return _s(t,i,e)}(this.Ar,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:ms(e)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,e,s,n}yo(t){const i=Ms(Date.now()),e=new Map;for(const o of t.values()){var s;const t=Ds(o.type,o.name,o.unit,void 0);let l=e.get(t);l||(l=wi({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},e.set(t,l));const a=cs(null!==(s=o.attributes)&&void 0!==s?s:{},this.$),u=Ms(o.windowStartMs),h=js(o.exemplar);if("count"===o.type){var n;const t=wi({attributes:a,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(n=o.total)&&void 0!==n?n:0},h);l.sum.dataPoints.push(t)}else if("gauge"===o.type){var r;const t=wi({attributes:a,timeUnixNano:i,asDouble:null!==(r=o.last)&&void 0!==r?r:0},h);l.gauge.dataPoints.push(t)}else if(o.hist){const t=wi({attributes:a,startTimeUnixNano:u,timeUnixNano:i,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Fs},h);l.histogram.dataPoints.push(t)}}return Array.from(e.values())}mo(t){for(const[n,r]of t){var i;const t=this.Hs.get(n);if(t)switch(t.windowStartMs=Math.min(t.windowStartMs,r.windowStartMs),t.exemplar=null!==(i=t.exemplar)&&void 0!==i?i:r.exemplar,t.type){case"count":var e,s;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+(null!==(s=r.total)&&void 0!==s?s:0);break;case"gauge":break;case"histogram":if(r.hist)if(t.hist){t.hist.count+=r.hist.count,t.hist.sum+=r.hist.sum,t.hist.min=Math.min(t.hist.min,r.hist.min),t.hist.max=Math.max(t.hist.max,r.hist.max);for(let i=0;t.hist.bucketCounts.length>i;i++)t.hist.bucketCounts[i]+=r.hist.bucketCounts[i]}else t.hist=r.hist}else this.Ks()&&this.Hs.set(n,r)}}};function js(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:Ms(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}const Ls=(t,{debugEnabled:i}={})=>{const e={N(e,...s){let n;try{n=typeof window>"u"?void 0:window}catch(t){return}n&&(v.DEBUG||n.POSTHOG_DEBUG||i)&&!R(n.console)&&n.console&&("__rrweb_original__"in n.console[e]?n.console[e].__rrweb_original__:n.console[e])(t,...s)},debug(...t){e.N("debug",...t)},info(...t){e.N("log",...t)},warn(...t){e.N("warn",...t)},error(...t){e.N("error",...t)},critical(...i){console.error(t,...i)},uninitializedWarning(t){e.error(`You must initialize PostHog before calling ${t}`)},createLogger:(i,e)=>Ls(`${t} ${i}`,e)};return e},Us=Ls("[PostHog.js]"),Bs=Us.createLogger,zs=Bs("[ExternalScriptsLoader]"),Hs=t=>{const i=null==s?void 0:s.querySelectorAll("script");if(i)for(let e=0;i.length>e;e++)if(i[e].src===t||i[e].getAttribute("src")===t)return i[e]},qs=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return zs.warn(`${i} was requested but loading of external scripts is disabled.`),e("Loading of external scripts is disabled");const n=Hs(i);if(n){if(n.__posthog_loading_callback_fired)return e();const t=n.__posthog_loading_error;return t?e(t):(n.addEventListener("load",t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)}),void n.addEventListener("error",t=>{n.__posthog_loading_error=t,e(t)}))}const r=()=>{if(!s)return e("document not found");if(Hs(i))return qs(t,i,e);let n=s.createElement("script");if(n.type="text/javascript",n.crossOrigin="anonymous",n.src=i,n.onload=t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)},n.onerror=t=>{n.__posthog_loading_error=t,e(t)},t.config.prepare_external_dependency_script&&(n=t.config.prepare_external_dependency_script(n)),!n)return e("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)s.head.appendChild(n);else{const t=s.querySelectorAll("body > script");var r;t.length>0?null===(r=t[0].parentNode)||void 0===r||r.insertBefore(n,t[0]):s.body.appendChild(n)}};(null==s?void 0:s.body)?r():null==s||s.addEventListener("DOMContentLoaded",r)},Vs={},Ws=(t,i)=>{let e=`/static/${i}.js?v=${t.version}`;if("toolbar"===i){const t=3e5;e=`${e}&t=${Math.floor(Date.now()/t)*t}`}return t.requestRouter.endpointFor("assets",e)};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{if("remote-config"===i){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void qs(t,i,e)}const s=t.config.strict_script_versioning;if(s){const n=t.requestRouter.endpointFor("assets",`/static/${t.version}/${i}.js`),r=Vs[n];if("fallback"===s&&r){if(Hs(r))return void qs(t,r,e);delete Vs[n]}return void qs(t,n,"fallback"===s?(s,r)=>{if(s)if("string"==typeof s)e(s);else{var o;const s=Ws(t,i);Vs[n]=s;const r=Hs(n);null==r||null===(o=r.parentNode)||void 0===o||o.removeChild(r),qs(t,s,e)}else e(void 0,r)}:e)}qs(t,Ws(t,i),e)},d.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{const s=t.requestRouter.endpointFor("api",i);qs(t,s,e)},v.DEBUG=!1,v.LIB_VERSION="1.438.17",v.LIB_NAME="web";var Gs=v;const Ks="$surveys",Js="$surveys_loaded_at",Ys="PostHog loadExternalDependency extension not found.",Zs="$surveys_activated",Xs="$surveys_activated_session",Qs="$surveys_activated_timestamps",tn="$early_access_features",en="$active_feature_flags",sn="$feature_flag_details",nn="$feature_flag_errors",rn="$feature_flag_evaluated_at",on="$feature_flag_request_id",ln="$minimal_flag_called_events",an="$enabled_feature_flags",un="$stored_group_properties",hn="$stored_person_properties",dn="$flag_call_reported",cn="$flag_call_reported_session_id",vn="$feature_flag_payloads",fn="$override_feature_flags",pn="$override_feature_flag_payloads",_n="visibilitychange",gn="$people_distinct_id",mn="distinct_id",yn="$device_id",bn="$device_model",wn="__alias",$n="__cmpns",Sn="$fbc",xn="$fbc_persistence",En="$fbp",kn="$fbp_persistence",Tn="__timers",Pn="$autocapture_disabled_server_side",Cn="$heatmaps_enabled_server_side",Rn="$exception_capture_enabled_server_side",On="$error_tracking_suppression_rules",An="$error_tracking_capture_extension_exceptions",In="$web_vitals_enabled_server_side",Fn="$dead_clicks_enabled_server_side",Mn="$product_tours_enabled_server_side",Dn="$logs_capture_enabled_server_side",Nn="$web_vitals_allowed_metrics",jn="$session_recording_remote_config",Ln="$session_recording_enabled_server_side",Un="$replay_sample_rate",Bn="$replay_override_sampling",zn="$replay_override_linked_flag",Hn="$replay_override_url_trigger",qn="$replay_override_event_trigger",Vn="$sesid",Wn="$session_is_sampled",Gn="$session_past_minimum_duration",Kn="$session_recording_url_trigger_activated_session",Jn="$session_recording_event_trigger_activated_session",Yn="$debug_first_full_snapshot_timestamp",Zn="$sess_rec_flush_size",Xn="$groups",Qn="ph_product_tours",tr="$product_tours_activated",ir="$product_tours_activated_session",er="$conversations_widget_session_id",sr="$conversations_ticket_id",nr="$conversations_widget_state",rr="$conversations_user_traits",or="$user_state",lr="$client_session_props",ar="$capture_rate_limit",ur="$initial_campaign_params",hr="$initial_referrer_info",dr="$initial_person_info",cr="$epp",vr="$posthog_cookieless",fr="$cookieless_mode",pr="$sdk_debug_extensions_init_method",_r="$sdk_debug_extensions_init_time_ms",gr="$sdk_debug_recording_script_not_loaded",mr="$sdk_debug_replay_stale_config",yr="$sdk_debug_replay_event_trigger_status",br="$sdk_debug_replay_linked_flag_trigger_status",wr="$sdk_debug_replay_matched_recording_trigger_groups",$r="$sdk_debug_replay_pending_trigger_conditions",Sr="$sdk_debug_replay_remote_trigger_matching_config",xr="$sdk_debug_replay_trigger_groups_count",Er="$sdk_debug_replay_url_trigger_status",kr="$session_recording_start_reason",Tr="anonymous",Pr="identified",Cr="identified_only",Rr="beforeunload",Or="$pageview",Ar="$pageleave",Ir="$identify",Fr="$groupidentify";function Mr(t,i){k(t)&&t.forEach(i)}function Dr(t,i){if(!F(t))if(k(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(const e in t)x.call(t,e)&&i(t[e],e)}const Nr=function(t,...i){for(const e of i)for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t};function jr(t){const i=Object.keys(t);let e=i.length;const s=new Array(e);for(;e--;)s[e]=[i[e],t[i[e]]];return s}const Lr=function(t){return function(...i){try{return t.apply(this,i)}catch(t){Us.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Us.critical(t)}}},Ur=function(t){const i={};return Dr(t,function(t,e){(O(t)&&t.length>0||M(t))&&(i[e]=t)}),i};function Br(t){const i=wi({},t);for(const e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}const zr=["herokuapp.com","vercel.app","netlify.app"];function Hr(t){const i=null==t?void 0:t.hostname;if(!O(i))return!1;const e=i.split(".").slice(-2).join(".");for(const t of zr)if(e===t)return!1;return!0}function qr(t,i,e,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==t||t.addEventListener(i,e,{capture:n,passive:r})}function Vr(t){return"ph_toolbar_internal"===t.name}const Wr=t=>{if(s){try{const i=t+"=",e=s.cookie.split(";").filter(t=>t.length);for(let t=0;e.length>t;t++){let s=e[t];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return M(t)&&isFinite(t)&&Math.floor(t)===t});var Gr=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,s,n){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(n)||0>i||0>e||0>s||0>n||i>0xffffffffffff||e>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=i/Math.pow(2,40),r[1]=i/Math.pow(2,32),r[2]=i/Math.pow(2,24),r[3]=i/Math.pow(2,16),r[4]=i/256,r[5]=i,r[6]=112|e>>>8,r[7]=e,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new t(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(let i=0;16>i;i++){const e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Kr=class{generate(){const t=this.generateOrAbort();if(!R(t))return t;{this.Ct=0;const t=this.generateOrAbort();if(R(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const t=(()=>{const t=Date.now();return M(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.It();else{if(this.Ct>=t+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Gr.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Zr}};const Jr=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};let Yr;var Zr=class{nextUint32(){var t;return this.Rt.length>this.Et||((null!==(t=Yr)&&void 0!==t?t:Yr="u">typeof window&&!R(window.crypto)&&crypto.getRandomValues?t=>crypto.getRandomValues(t):Jr)(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let Xr;const Qr=()=>to().toString(),to=()=>(Xr||(Xr=new Kr)).generate();let io="";const eo=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let so=null;const no={$t(){if(!I(so))return so;if(so=!1,s)try{const t=`__ph_cookie_support_${Qr()}`;no.At(t,"xyz"),so='"xyz"'===Wr(t),no.Pt(t)}catch(t){so=!1}return so},Ft(t){Us.error("cookieStore error: "+t)},Ot:Wr,Lt(t){let i;try{i=JSON.parse(no.Ot(t))||{}}catch(t){}return i},At(t,i,e,n,r){if(!s)return!1;try{let o="",l="";const a=function(t,i){if(i){let i=function(t,i=s){if(io)return io;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";const e=t.split(".");let n=Math.min(e.length,8);const r="dmn_chk_"+Qr();for(;!io&&n--;){const t=e.slice(n).join("."),s=r+"=1;domain=."+t+";path=/";i.cookie=s+";max-age=3",i.cookie.includes(r)&&(i.cookie=s+";max-age=0",io=t)}return io}(t);if(!i){const e=(t=>{const i=t.match(eo);return i?i[0]:""})(t);e!==i&&Us.info("Warning: cookie subdomain discovery mismatch",e,i),i=e}return i?"; domain=."+i:""}return""}(s.location.hostname,n);if(e){const t=new Date;t.setTime(t.getTime()+864e5*e),o="; expires="+t.toUTCString()}r&&(l="; secure");const u=t+"="+encodeURIComponent(JSON.stringify(i))+o+"; SameSite=Lax; path=/"+a+l;return u.length>3686.4&&Us.warn("cookieStore warning: large cookie, len="+u.length),s.cookie=u,!0}catch(t){return!1}},Pt(t,i){if((null==s?void 0:s.cookie)&&(!i||!I(Wr(t))))try{no.At(t,"",-1,i)}catch(t){return}}};let ro=null;const oo={$t(){if(!I(ro))return ro;let i=!0;if(R(t))i=!1;else try{const t="__mplssupport__";oo.At(t,"xyz"),'"xyz"'!==oo.Ot(t)&&(i=!1),oo.Pt(t)}catch(t){i=!1}return i||Us.error("localStorage unsupported; falling back to cookie store"),ro=i,i},Ft(t){Us.error("localStorage error: "+t)},Ot(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){oo.Ft(t)}return null},Lt(t){try{return JSON.parse(oo.Ot(t))||{}}catch(t){}return null},At(i,e){try{return null==t||t.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){oo.Ft(t)}return!1},Pt(i){try{null==t||t.localStorage.removeItem(i)}catch(t){oo.Ft(t)}}},lo=[hn,en,an,sn,vn,on,rn,nn,dn],ao=[yn,mn,Vn,Wn,cr,dr,xn,or],uo=t=>t+"_cpm",ho=["__proto__","constructor","prototype"],co=t=>{if(!P(t))return{};const i={};return Object.keys(t).forEach(e=>{-1===ho.indexOf(e)&&(i[e]=t[e])}),i},vo=(t,i=[])=>{const e={};return[...ao,...i].forEach(i=>{const s=t[i];R(s)||I(s)||""===s||(e[i]=s)}),e},fo=t=>{let i=5381,e=2166136261;for(let s=0;t.length>s;s++){const n=t.charCodeAt(s);i=33*i^n,e=Math.imul(e^n,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},po=(t,i)=>({p:i,f:fo(JSON.stringify(t))}),_o=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{const e=no.Lt(uo(t)),s=(null==e?void 0:e.f)===fo(i)&&k(e.p);return{properties:s?e.p:[],isValid:s}}catch(t){return{properties:[],isValid:!1}}},go=(t,i)=>i+"|"+(no.Ot(uo(t))||""),mo={},yo={$t:()=>!0,Ft(t){Us.error("memoryStorage error: "+t)},Ot:t=>t in mo?mo[t]:null,Lt:t=>t in mo?mo[t]:null,At:(t,i)=>(mo[t]=i,!0),Pt(t){delete mo[t]}};let bo=null;const wo={$t(){if(!I(bo))return bo;if(bo=!0,R(t))bo=!1;else try{const t="__support__";wo.At(t,"xyz"),'"xyz"'!==wo.Ot(t)&&(bo=!1),wo.Pt(t)}catch(t){bo=!1}return bo},Ft(t){Us.error("sessionStorage error: ",t)},Ot(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){wo.Ft(t)}return null},Lt(t){try{return JSON.parse(wo.Ot(t))||null}catch(t){}return null},At(i,e){try{return null==t||t.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){wo.Ft(t)}return!1},Pt(i){try{null==t||t.sessionStorage.removeItem(i)}catch(t){wo.Ft(t)}}};var $o=class{constructor(t){this._instance=t}get Ar(){return this._instance.config}get consent(){return this.bl()?0:this._l}isOptedOut(){return"always"===this.Ar.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Ar.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Ar.opt_out_capturing_by_default}optInOut(t){this.wl.At(this.kl,t?1:0,this.Ar.cookie_expiration,this.Ar.cross_subdomain_cookie,this.Ar.secure_cookie)}reset(){this.wl.Pt(this.kl,this.Ar.cross_subdomain_cookie)}get kl(){const{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get _l(){const t=this.wl.Ot(this.kl);return W(t)?1:m(G,t)?0:-1}get wl(){const t=this.Ar.opt_out_capturing_persistence_type,i="localStorage"===t?oo:no,e=i.$t()?i:yo;if(!this.Sl||this.Sl!==e){this.Sl=e;const i="localStorage"===t?no:oo;i.Ot(this.kl)&&(this.Sl.Ot(this.kl)||this.optInOut(W(i.Ot(this.kl))),i.Pt(this.kl,this.Ar.cross_subdomain_cookie))}return this.Sl}bl(){return!!this.Ar.respect_dnt&&[null==e?void 0:e.doNotTrack,null==e?void 0:e.msDoNotTrack,d.doNotTrack,null==e?void 0:e.globalPrivacyControl].some(t=>W(t))}};function So(t,i){var e;const s=null==t||null===(e=t.config)||void 0===e?void 0:e.get_current_url;if(!T(s))return i;try{const t=s(i);return O(t)&&t?t:i}catch(t){return Us.error("Error in get_current_url, falling back to window.location.href",t),i}}function xo(t){var i;return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!!(null===(i=t.closest)||void 0===i?void 0:i.call(t,".toolbar-global-fade-container")))}function Eo(t){return!!t&&1===t.nodeType}function ko(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function To(t){return!!t&&3===t.nodeType}function Po(t){return!!t&&11===t.nodeType&&Eo(t.host)}function Co(t){return t?y(t).split(/\s+/):[]}function Ro(t,i){const e=function(t){var i;const e="u">typeof window?null===(i=window.location)||void 0===i?void 0:i.href:void 0;return R(e)?void 0:So(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Oo(t){let i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return Co(i)}function Ao(t){return F(t)?null:y(t).split(/(\s+)/).filter(t=>al(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Io(t){let i="";return Qo(t)&&!tl(t)&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,function(t){var e;To(t)&&t.textContent&&(i+=null!==(e=Ao(t.textContent))&&void 0!==e?e:"")}),y(i)}function Fo(t){var i;return R(t.target)?t.srcElement||null:(null===(i=t.target)||void 0===i?void 0:i.shadowRoot)?t.composedPath()[0]||null:t.target||null}const Mo=["a","button","form","input","select","textarea","label"];function Do(t,i){const e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function No(t,i){if(R(i))return!0;for(const e of t)if(i.some(t=>Do(e,t)))return!0;return!1}function jo(t){const i=t.parentNode;return!(!i||!Eo(i))&&i}const Lo=[".ph-no-autocapture","[data-ph-no-autocapture]"],Uo=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Bo=[...Uo,"+","-","−","–"],zo=Bo.length+10,Ho=["button","a","input","select","textarea","label"],qo=["button","link","tab","menuitem","option"],Vo=(t,i)=>/[a-z0-9]/i.test(i)?m(Bo,i)?new RegExp(`\\b${i}\\b`).test(t):t.includes(i):t===i,Wo=t=>m(Ho,t.tagName.toLowerCase())||m(qo,(t.getAttribute("role")||"").toLowerCase());function Go(t){let i="",e="";const s=t=>{Eo(t)&&Qo(t)&&!tl(t)&&(i+=` ${Io(t)}`,e=e||t.getAttribute("aria-label")||"",Dr(t.childNodes,s))};s(t),i=y(i.replace(/\s+/g," "));const n=(al(i)?i:"").toLowerCase(),r=t.getAttribute("aria-label")||(n?"":e);return{safeText:n,ariaLabel:y(r).toLowerCase()}}const Ko=[".ph-no-rageclick",".ph-no-capture"],Jo=["","text","search","email","password","url","tel","number"];function Yo(t,i){if(typeof window>"u"||Zo(t))return!1;let e,s,n;var r,o;if(N(i)?(e=!!i&&Ko,s=void 0,n=!1):(e=null!==(r=null==i?void 0:i.css_selector_ignorelist)&&void 0!==r?r:Ko,s=null==i?void 0:i.content_ignorelist,n=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(n&&function(t){return!(!t||!Eo(t))&&(!!ko(t,"textarea")||(ko(t,"input")?m(Jo,(t.getAttribute("type")||"").toLowerCase()):function(t){var i;if(t.isContentEditable)return!0;const e=null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"contenteditable");return"true"===e||""===e}(t)))}(t))return!1;const{targetElementList:l}=Xo(t,!1);return!(s&&function(t,{safeText:i,ariaLabel:e}){let s;if(!0===t)s=Uo;else{if(!k(t))return!1;if(t.length>zo)return Us.error(`[PostHog] content_ignorelist array cannot exceed ${zo} items. Use css_selector_ignorelist for more complex matching.`),!1;s=t.map(t=>t.toLowerCase())}return s.some(t=>Vo(i,t)||Vo(e,t))}(s,function(t,i){for(const t of i)if(Wo(t))return Go(t);for(const t of i){try{var e;if("pointer"!==(null===(e=window)||void 0===e?void 0:e.getComputedStyle(t).getPropertyValue("cursor")))break}catch(t){break}const i=Go(t);if(i.safeText||i.ariaLabel)return i}return Go(t)}(t,l))||No(l,e))}const Zo=t=>!t||ko(t,"html")||!Eo(t),Xo=(t,i)=>{if(typeof window>"u"||Zo(t))return{parentIsUsefulElement:!1,targetElementList:[]};let e=!1;const s=[t];let n=t;for(;n.parentNode&&!ko(n,"body");){if(Po(n.parentNode)){s.push(n.parentNode.host),n=n.parentNode.host;continue}const t=jo(n);if(!t)break;if(i||Mo.indexOf(t.tagName.toLowerCase())>-1)e=!0;else try{const i=window.getComputedStyle(t);i&&"pointer"===i.getPropertyValue("cursor")&&(e=!0)}catch(t){}s.push(t),n=t}return{parentIsUsefulElement:e,targetElementList:s}};function Qo(t){const i=new Set;let e=0;for(let s=t;s.parentNode&&!ko(s,"body");s=s.parentNode){if(e++>=1e3||i.has(s))return!1;i.add(s);const t=Oo(s);if(m(t,"ph-sensitive")||m(t,"ph-no-capture"))return!1}if(m(Oo(t),"ph-include"))return!0;const s=t.type||"";if(O(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=t.name||t.id||"";return!O(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function tl(t){return!!(ko(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ko(t,"select")||ko(t,"textarea")||"true"===t.getAttribute("contenteditable"))}const il=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),el=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,sl=[16,15,14,13],nl=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),rl=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ol=/[0-9A-Za-z_]/;function ll(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function al(t,i=!0){if(F(t))return!1;if(O(t)){if(t=y(t),i?il.test((t||"").replace(/[- ]/g,"")):function(t){let i;for(el.lastIndex=0;i=el.exec(t);){const t=i[2];if(!t)continue;const e=t.replace(/[- ]/g,"");for(let t=0;e.length>t;t++)for(const i of sl){const s=t+i;if(e.length>=s){const i=e.slice(t,s);if(il.test(i)&&ll(i))return!0}}}return!1}(t))return!1;if(i?nl.test(t):function(t){let i;for(rl.lastIndex=0;i=rl.exec(t);){const t=i[1],e=i[3];if(!(t&&e&&ol.test(t)&&ol.test(e)))return!0}return!1}(t))return!1}return!0}function ul(t){let i=Io(t);return i=`${i} ${hl(t)}`.trim(),al(i)?i:""}function hl(t){let i="";return t&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,function(t){var e;if(t&&"span"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()))try{const e=Io(t);i=`${i} ${e}`.trim(),t.childNodes&&t.childNodes.length&&(i=`${i} ${hl(t)}`.trim())}catch(t){Us.error("[AutoCapture]",t)}}),i}function dl(t){return t.replace(/"|\\"/g,'\\"')}function cl(t){const i=t.attr__class;if(i)return k(i)?i:Co(i)}const vl=Bs("[Dead Clicks]"),fl=()=>!0,pl=t=>{var i;const e=!!(null===(i=t.instance.persistence)||void 0===i?void 0:i.get_property(Fn)),s=t.instance.config.capture_dead_clicks;return N(s)?s:!!P(s)||e};var _l=class{get lazyLoadedDeadClicksAutocapture(){return this.xl}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[Fn]:i.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.$l(()=>{this.Cl()}):this.stop()}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.initDeadClicksAutocapture)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this.instance,"dead-clicks-autocapture",i=>{i?vl.error("failed to load script",i):t()})}Cl(){var t;if(s){if(!this.xl&&(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)){const t=P(this.instance.config.capture_dead_clicks)?wi({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.xl=d.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.xl.start(s),vl.info("starting...")}}else vl.error("`document` not found. Cannot start.")}stop(){this.xl&&(this.xl.stop(),this.xl=void 0,vl.info("stopping..."))}};const gl=Bs("[SegmentIntegration]");function ml(t,i,e=!0){const s=t.config.segment;if(!s)return i();const{analytics:n,filterProperties:r}=(t=>T(t.register))(o=s)?{analytics:o}:o;var o;!function(t,i,e,s){const n=i=>{const n=()=>i.anonymousId()||Qr();t.config.get_device_id=n,s&&i.id()&&(t.register({distinct_id:i.id(),$device_id:n()}),t.persistence.set_property(or,Pr)),e(s?void 0:i.anonymousId()||void 0)},r=i.user();"then"in r&&T(r.then)?r.then(n):n(r)}(t,n,e=>{n.register(((t,i,{filterProperties:e}={})=>{"undefined"!=typeof Promise&&Promise.resolve||gl.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!i&&s.event.anonymousId===i&&!s.event.userId;r||s.event.userId||s.event.anonymousId===t.get_distinct_id()||(gl.info("No userId set, resetting PostHog"),t.reset()),r||(i=void 0),s.event.userId&&s.event.userId!==t.get_distinct_id()&&(gl.info("UserId set, identifying with PostHog"),t.identify(s.event.userId));let o=t.calculateEventProperties(n,s.event.properties);if(!F(e)){const t=s.event.properties||{},i={};for(const e of Object.keys(o))x.call(t,e)||(i[e]=o[e]);const n=((t,i)=>{const e=k(t)?t:[t];let s=wi({},i);for(const t of e)try{if(s=t(s),F(s))return null}catch(t){return gl.error("Error in Segment filterProperties:",t),null}return s})(e,i);if(F(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return s(t,t.event.event)},page(t){return s(t,Or)},identify(t){return s(t,Ir)},screen(t){return s(t,"$screen")}}})(t,e,{filterProperties:r})).then(()=>{i()},t=>{gl.error("Failed to register the Segment integration",t),i()})},e)}const yl="posthog-js";function bl(t,{organization:i,projectId:e,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var l,a,u,h,d;if("*"!==n&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});const c=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=c,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const v=(null===(l=o.exception)||void 0===l?void 0:l.values)||[],f=v.map(t=>wi(wi({},t),{},{stacktrace:t.stacktrace?wi(wi({},t.stacktrace),{},{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>wi(wi({},t),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:(null===(a=v[0])||void 0===a?void 0:a.value)||o.message,$exception_type:null===(u=v[0])||void 0===u?void 0:u.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(h=v[0])||void 0===h?void 0:h.value)||o.message,$sentry_exception_type:null===(d=v[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var _;return i&&e&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+e+"&query="+o.event_id),r&&(null===(_=t.exceptions)||void 0===_||_.sendExceptionEvent(p)),o}}var wl=class{constructor(t,i,e,s,n,r){this.name=yl,this.setupOnce=function(o){o(bl(t,{organization:i,projectId:e,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},$l=class{constructor(t){this.Tl=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(Us.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Il=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Ml()}Ml(){var t;this.El=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.onSessionId(this.Tl)}destroy(){var t;null===(t=this.El)||void 0===t||t.call(this),this.El=void 0}doPageView(i,e){var s;const n=this.Pl(i,e);return this.Il={pathname:null!==(s=null==t?void 0:t.location.pathname)&&void 0!==s?s:"",pageViewId:e,timestamp:i},this._instance.scrollManager.resetContext(),n}doPageLeave(t){var i;return this.Pl(t,null===(i=this.Il)||void 0===i?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null===(t=this.Il)||void 0===t?void 0:t.pageViewId}}Pl(t,i){const e=this.Il;if(!e)return{$pageview_id:i};let s={$pageview_id:i,$prev_pageview_id:e.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:t,lastScrollY:i,maxScrollY:e,maxContentHeight:r,lastContentY:o,maxContentY:l}=n;if(!(R(t)||R(i)||R(e)||R(r)||R(o)||R(l))){t=Math.ceil(t),i=Math.ceil(i),e=Math.ceil(e),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l);const n=t>1?Q(i/t,0,1,Us):1,a=t>1?Q(e/t,0,1,Us):1,u=r>1?Q(o/r,0,1,Us):1,h=r>1?Q(l/r,0,1,Us):1;s=Nr(s,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:e,$prev_pageview_max_scroll_percentage:a,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:u,$prev_pageview_max_content:l,$prev_pageview_max_content_percentage:h})}}return e.pathname&&(s.$prev_pageview_pathname=e.pathname),e.timestamp&&(s.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),s}};const Sl=["flags","surveys"],xl={[gn]:{exposure:"hidden"},[wn]:{exposure:"hidden"},[$n]:{exposure:"hidden"},[Tn]:{exposure:"hidden"},[xn]:{exposure:"hidden"},[kn]:{exposure:"hidden"},[Pn]:{exposure:"event"},[Cn]:{exposure:"hidden"},[Dn]:{exposure:"hidden"},[Rn]:{exposure:"event"},[On]:{exposure:"hidden"},[An]:{exposure:"event"},[In]:{exposure:"event"},[Fn]:{exposure:"event"},[Mn]:{exposure:"hidden"},[Nn]:{exposure:"event"},[jn]:{exposure:"hidden"},[Ln]:{exposure:"hidden"},[Vn]:{exposure:"hidden"},[Wn]:{exposure:"event"},[Un]:{exposure:"event",shouldSkipFromEventProperties:t=>I(t)},[Gn]:{exposure:"event"},[Kn]:{exposure:"event"},[Jn]:{exposure:"event"},[Yn]:{exposure:"event"},[Zn]:{exposure:"hidden"},[an]:{exposure:"hidden",storageGroup:"flags"},[en]:{exposure:"hidden",storageGroup:"flags"},[tn]:{exposure:"hidden"},[sn]:{exposure:"hidden",storageGroup:"flags"},[vn]:{exposure:"hidden",storageGroup:"flags"},[on]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ln]:{exposure:"hidden",storageGroup:"flags"},[fn]:{exposure:"hidden"},[pn]:{exposure:"hidden"},[hn]:{exposure:"hidden"},[un]:{exposure:"hidden"},[Ks]:{exposure:"hidden",storageGroup:"surveys"},[Js]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Zs]:{exposure:"event"},[Xs]:{exposure:"hidden"},[Qs]:{exposure:"hidden"},[Qn]:{exposure:"hidden"},[tr]:{exposure:"hidden"},[ir]:{exposure:"hidden"},[er]:{exposure:"event"},[sr]:{exposure:"event"},[nr]:{exposure:"event"},[rr]:{exposure:"event"},[dn]:{exposure:"hidden"},[cn]:{exposure:"hidden"},[Xn]:{exposure:"event"},[nn]:{exposure:"hidden"},[rn]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[or]:{exposure:"hidden"},[lr]:{exposure:"hidden"},[ar]:{exposure:"hidden"},[ur]:{exposure:"hidden"},[hr]:{exposure:"hidden"},[dr]:{exposure:"hidden"},[cr]:{exposure:"hidden"},[Bn]:{exposure:"event"},[zn]:{exposure:"event"},[Hn]:{exposure:"event"},[qn]:{exposure:"event"},[pr]:{exposure:"event"},[_r]:{exposure:"event"},[gr]:{exposure:"hidden"},[mr]:{exposure:"hidden"},[yr]:{exposure:"hidden"},[br]:{exposure:"hidden"},[wr]:{exposure:"hidden"},[$r]:{exposure:"hidden"},[Sr]:{exposure:"hidden"},[xr]:{exposure:"hidden"},[Er]:{exposure:"hidden"},[kr]:{exposure:"event"}},El=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],kl=t=>{const i=xl[t];if(i)return i;for(const[i,e]of El)if(0===t.indexOf(i))return e};function Tl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}const Pl=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},Cl=(t,i)=>t>=i&&Pl(),Rl=(t,i,e,s)=>{if(0===t){if(Pl()){const t=i+1;return t===e&&s(),t}return i}return 0},Ol=(t,i)=>{try{let e;return JSON.stringify(t,(t,i)=>{var s;return z(i)?(null!==(s=e)&&void 0!==s||(e=new WeakMap),e.has(i)||e.set(i,Br(i)),e.get(i)):"bigint"==typeof i?i.toString():i},i)}catch(i){return w(t)}},Al=t=>{const i=null==s?void 0:s.createElement("a");return R(i)?null:(i.href=t,i)},Il=function(t,i){const e=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let t=0;e.length>t;t++){const n=e[t].split("=");if(n[0]===i){s=n;break}}if(!k(s)||2>s.length)return"";{let t=s[1];try{t=decodeURIComponent(t)}catch(i){Us.error("Skipping decoding for malformed query param: "+t)}return t.replace(/\+/g," ")}},Fl=function(t,i,e){if(!t||!i||!i.length)return t;const s=t.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],l=r[0],a=(o||"").split("&"),u=[];for(let t=0;a.length>t;t++){const s=a[t].split("=");k(s)&&(i.includes(s[0])?u.push(s[0]+"="+e):u.push(a[t]))}let h=l;return null!=o&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},Ml=function(t,i){const e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Dl=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Nl=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Dl],jl="<masked>",Ll=["li_fat_id"];function Ul(t,i,e){if(!s)return{};const n=i?[...Dl,...e||[]]:[],r=Bl(Fl(s.URL,n,jl),t),o=function(){const t={};return Dr(Ll,function(i){const e=Wr(i);t[i]=e||null}),t}();return Nr(o,r)}function Bl(t,i){const e=Nl.concat(i||[]),s={};return Dr(e,function(i){const e=Il(t,i);s[i]=e||null}),s}function zl(t){const i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",n={};if(!I(i)){n.$search_engine=i;const t=s?Il(s.referrer,e):"";t.length&&(n.ph_keyword=t)}return n}function Hl(){return navigator.language||navigator.userLanguage}function ql(){const t=Hl();return"string"==typeof t?t.split("-")[0]:void 0}const Vl="$direct";function Wl(){return(null==s?void 0:s.referrer)||Vl}function Gl(t,i,e=!1){const s=t?[...Dl,...i||[]]:[],r=e?vi(null==n?void 0:n.href):null==n?void 0:n.href,o=null==r?void 0:r.substring(0,1e3);return{r:Wl().substring(0,1e3),u:o?Fl(o,s,jl):void 0}}function Kl(t,i=!1){var e;const{r:s,u:n}=t,r=i?vi(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Vl?Vl:null===(e=Al(s))||void 0===e?void 0:e.host};if(r){o.$current_url=r;const t=Al(r);o.$host=null==t?void 0:t.host,o.$pathname=null==t?void 0:t.pathname;const i=Bl(r);Nr(o,i)}if(s){const t=zl(s);Nr(o,t)}return o}function Jl(){try{return(new Date).getTimezoneOffset()}catch(t){return}}const Yl={flags:rn,surveys:Js},Zl=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Xl=t=>`${t}_cookie_identity_change_pending`,Ql=t=>{let i="",e=0;for(const s of t){const t=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(e+t>1e3)break;i+=s,e+=t}return i},ta="main",ia=[an,en,sn,vn,on,rn,ln,hn],ea=t=>-1!==ia.indexOf(t),sa=[xn,kn],na=t=>-1!==sa.indexOf(t),ra=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},oa=t=>{if(!t)return{};const i=JSON.parse(t);return P(i)?i:{}},la=(t,i)=>{Dr(t,(e,s)=>{const n=kl(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(i,s)||delete t[s]})};var aa=class{constructor(i,e,s=!0,n=!i.cookieless_mode){if(this.Rl={},this.Al=!1,this.Fl=!1,this.Ol=!1,this.Dl=!1,this.Ll=!1,this.Nl=new Map,this.ql=!1,this.jl=!1,this.Bl=!1,this.zl=new Set,this.Hl=new Set,this.Ar=i,this.Ul=s,this.props={},this.Wl=void 0,this.Vl=(t=>{let i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(i),this.hi=i.disable_persistence||!!e,this.wl=this.Gl(i),this.Ol=this.Ql(i),this.load(n),this.Zl(),i.debug&&Us.info("Persistence loaded",i.persistence,wi({},this.props)),this.update_config(i,i,e),this.save(),t){const i=()=>this.flush();qr(t,"beforeunload",i,{capture:!1}),qr(t,"pagehide",i,{capture:!1}),this.Jl=i=>{if(this.Al&&(!i.storageArea||i.storageArea===(null==t?void 0:t.localStorage))&&i.key)if(i.key!==this.Vl){if(this.Ol){const t=Sl.find(t=>i.key===this.Kl(t));t&&this.Xl(i.key,t)}}else this.Xl(i.key,ta)},qr(t,"storage",this.Jl)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([t,i])=>{const e=this.Nl.get(t);if(!ea(t)||!0===e)return;if(!0===i)return void this.Yl(t,!0);const s=new Set(e||[]);i.forEach(t=>s.add(t)),s.size&&this.Yl(t,s)})}onCrossTabFeatureFlagChange(t){return this.Hl.add(t),()=>this.Hl.delete(t)}destroy(){this.Jl&&t&&(t.removeEventListener("storage",this.Jl),this.Jl=void 0),this.Hl.clear()}Xl(t,i,e=!0){if(this.hi)return!1;let s,n;try{if(n=oo.Ot(t),I(n)){const t=this.tu(i);return t.storageValue=null,i!==ta&&(t.persisted=!1),!1}s=oa(n)}catch(t){return!1}const r=i===ta?s:oo.Lt(this.Vl);if(r&&this.eu(r))return!1;const o=this.iu(s,i,e);return i===ta&&this.Ol&&!ra(this.nu().main,s)||this.su(s,i,!0,n),o}eu(t){const i=this.props[mn],e=t[mn];return!R(i)&&!R(e)&&i!==e}su(t,i,e,s){const n=this.tu(i);n.storageValue=s,i!==ta&&(n.persisted=e);try{n.fingerprint=this.ru(t,i)}catch(t){n.fingerprint=void 0}}iu(t,i,e){let s=!1;return ia.forEach(e=>{var n;const r=null===(n=kl(e))||void 0===n?void 0:n.storageGroup;if(i===ta&&this.Ol&&r||i!==ta&&r!==i)return;const o=e in t,l=this.ou(e,o?t[e]:void 0),a=this.Nl.has(e)?e in this.props:o;a===e in this.props&&ra(l,this.props[e])||(a?this.au(e,l,!1):this.lu(e,!1),s=!0)}),s&&e&&this.Hl.forEach(t=>t()),s}uu(){if(!this.Al)return!1;try{this.Bl=!1;const t=oo.Ot(this.Vl),i=this.tu(ta);let e,s=!1,n=!1;if(t!==i.storageValue)if(I(t))i.storageValue=null;else{if(e=oa(t),this.Bl=!this.jl&&this.eu(e),this.Bl)return!1;n=this.iu(e,ta,!1),!this.Ol||ra(this.nu().main,e)?this.su(e,ta,!0,t):i.storageValue=t,s=!0}return this.Ol&&Sl.forEach(t=>{const i=oo.Ot(this.Kl(t)),r=this.tu(t),o=e||{},l=s&&ia.some(i=>{var e;return(null===(e=kl(i))||void 0===e?void 0:e.storageGroup)===t&&i in o});if(i===r.storageValue&&!l)return;if(I(i))return r.storageValue=null,r.persisted=!1,void(l&&(n=this.iu(o,t,!1)||n));const a=oa(i);n=this.iu(a,t,!1)||n,this.su(a,t,!0,i)}),n}catch(t){return!1}}Yl(t,i){this.Nl.set(t,i);const e=kl(t);(null==e?void 0:e.volatile)||(this.tu((this.Ol?null==e?void 0:e.storageGroup:void 0)||ta).fingerprint=void 0,this.cu(t))}hu(){ia.forEach(t=>this.Nl.set(t,!0))}Zl(){if(this.Al)try{const t=oo.Ot(this.Vl),i=oa(t);this.tu(ta).storageValue=t,ia.forEach(t=>{var e;const s=this.Ol?null===(e=kl(t))||void 0===e?void 0:e.storageGroup:void 0,n=s?oo.Ot(this.Kl(s)):null;if(s){const t=this.tu(s);t.storageValue=n,t.persisted=!I(n)}const r=s&&!I(n)?oa(n):i;t in this.props?this.du(t,r[t],this.props[t]):t in r&&this.Yl(t,!0)})}catch(t){}}ou(t,i){const e=this.Nl.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){const s=new Set(k(i)?i:[]),n=new Set(k(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}const s=P(i)?wi({},i):{},n=P(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in n?s[t]=n[t]:delete s[t]}),s}du(t,i,e){if(!ea(t))return;const s=this.Nl.get(t);if(!0===s)return;let n=i;if(this.Al)try{var r;const i=this.Ol?null===(r=kl(t))||void 0===r?void 0:r.storageGroup:void 0,e=i?this.Kl(i):this.Vl;n=oa(oo.Ot(e))[t]}catch(t){}const o=new Set(s||[]);if("$active_feature_flags"===t){if(!R(i)&&!k(i)||!R(n)&&!k(n)||!k(e))return void this.Yl(t,!0);const s=new Set(i||[]),r=new Set(n||[]),l=new Set(e);new Set([...s,...l]).forEach(t=>{s.has(t)!==l.has(t)&&o.add(t)}),o.forEach(t=>{r.has(t)===l.has(t)&&o.delete(t)})}else{if(!P(e))return void(ra(n,e)?this.Nl.delete(t):this.Yl(t,!0));{if(!R(i)&&!P(i)||R(i)&&C(e)&&R(n))return void this.Yl(t,!0);const s=P(i)?i:{},r=P(n)?n:{};new Set([...Object.keys(s),...Object.keys(e)]).forEach(t=>{t in s==t in e&&ra(s[t],e[t])||o.add(t)}),o.forEach(t=>{t in r==t in e&&ra(r[t],e[t])&&o.delete(t)})}}o.size?this.Yl(t,o):this.Nl.delete(t)}vu(){var t;const i=null===(t=this.Ar)||void 0===t?void 0:t.persistence_save_debounce_ms;return M(i)&&i>0?i:0}fu(t){if(this.Ar.cookieWinsOnConflict&&"localstorage+cookie"===this.Ar.persistence.toLowerCase())if(t)try{const i=vo(t,this.Ar.cookie_persisted_properties||[]),e=po(i,this.Ar.cookie_persisted_properties||[]),s=JSON.stringify(i)+"|"+JSON.stringify(e),n=no.Ot(this.Vl)||void 0;n&&go(this.Vl,n)===s&&(this.pu=s,this.gu=n)}catch(t){}else try{const t=no.Ot(this.Vl)||void 0;this.pu=t?go(this.Vl,t):void 0,this.gu=t}catch(t){}}syncCookieProperties(){return this.mu(this.Ar)}mu(t,i=!1){if(this.hi&&!i||this.Ll||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;let e;try{e=no.Ot(this.Vl)||void 0}catch(t){}if(!e||e===this.gu)return!1;const s=go(this.Vl,e);let n;try{n=co(JSON.parse(e))}catch(t){return!1}if((no.Ot(this.Vl)||void 0)!==e)return!1;this.pu=s,this.gu=e;const r=_o(this.Vl,e),o=[...ao,...r.properties],l={};if(Object.keys(n).forEach(t=>{const i=n[t];(R(i)||I(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(l[t]=!0,delete n[t])}),C(n))return!1;const a="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,u=this.props,h=u[mn],d=u[or],c=Nr({},u);[...ao,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==o.indexOf(t)&&!(t in n)&&!l[t]&&(a||"distinct_id"!==t&&"$user_state"!==t)){const i=c[t];(r.isValid||-1===ao.indexOf(t)||!1!==i&&0!==i)&&delete c[t]}}),this.props=Nr(c,n),ia.forEach(t=>{const i=t in this.props;t in u===i&&ra(u[t],this.props[t])||(i?this.du(t,u[t],this.props[t]):this.Yl(t,!0))}),!a||"$user_state"in n||"$user_state"in this.props||this.au(or,Tr);const v=this.props[mn],f=this.props[or];return!a||v===h&&f===d||(this.jl=!0,this.Dl=!0,wo.At(Xl(this.Vl),!0),this.lu(hn),this.lu(en),this.lu(an),this.lu(sn),this.lu(vn),this.lu(on),this.lu(rn),this.lu(nn),this.lu(dn),"anonymous"!==f||"identified"!==d&&"anonymous"!==n.$user_state&&(R(h)||v===h)||(la(this.props,n),this.lu(un)),"identified"===f?this.props.$user_id=v:delete this.props.$user_id,this.lu(wn)),!0}consumeCookieIdentityChange(){const t=Xl(this.Vl),i=this.Dl||!!wo.Ot(t);return this.Dl=!1,i&&wo.Pt(t),i}yu(t=!1){return!(this.Ll||this.hi&&!t||!this.Ar.cookieWinsOnConflict||"localstorage+cookie"!==this.Ar.persistence.toLowerCase()||(this.Ll=!0,0))}bu(){this.Ll&&(R(this._u)||(clearTimeout(this._u),this._u=void 0),delete this.Rl[ta],this.wu(!0))}ku(t=!0){if(this.Ll)try{t?this.bu():R(this._u)||(clearTimeout(this._u),this._u=void 0)}finally{this.Ll=!1}}isDisabled(){return!!this.hi}Gl(i){-1===Zl.indexOf(i.persistence.toLowerCase())&&(Us.critical("Unknown persistence type "+i.persistence+"; falling back to localStorage+cookie"),i.persistence="localStorage+cookie");const e=((i=[],e=!1,s=()=>!1)=>{const n=[...ao,...i];return wi(wi({},oo),{},{Lt(t){try{let r,o={};try{r=no.Ot(t)||void 0,o=r?co(JSON.parse(r)):{}}catch(t){}const l=JSON.parse(oo.Ot(t)||"{}");let a;if(e){const e=_o(t,r),s=[...ao,...e.properties],u={};Object.keys(o).forEach(t=>{const i=o[t];I(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(u[t]=i)});const h="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var i;const t=l[mn],r=null!==(i=l.$user_state)&&void 0!==i?i:Tr;n.forEach(t=>{if(-1!==s.indexOf(t)&&!(t in o)&&(h||"distinct_id"!==t&&"$user_state"!==t)){const i=l[t];(e.isValid||-1===ao.indexOf(t)||!1!==i&&0!==i)&&delete l[t]}}),!h||"$user_state"in o||"$user_state"in l||(l[or]=Tr),!h||("distinct_id"in u?u[mn]:l[mn])===t&&("$user_state"in u?u[or]:l[or])===r||(lo.forEach(t=>delete l[t]),"identified"===u.$user_state&&"distinct_id"in u?l.$user_id=u[mn]:delete l.$user_id,"identified"!==u.$user_state&&(delete l[Xn],delete l[un]),delete l.__alias)}a=Nr(l,u)}else a=Nr(o,l);return s()||oo.At(t,a),a}catch(t){}return null},At(t,s,n,r,o,l){const a=oo.At(t,s,void 0,void 0,l);try{const u=vo(s,i);if(Object.keys(u).length){if(e){const e=uo(t),h=po(u,i);if(no.At(e,h,n,r,o,l),no.Ot(e)!==JSON.stringify(h)){no.Pt(e,r);const i=vo(s);return no.At(t,i,n,r,o,l),a}}no.At(t,u,n,r,o,l)}}catch(t){oo.Ft(t)}return a},Pt(i,e){try{null==t||t.localStorage.removeItem(i),no.Pt(i,e),no.Pt(uo(i),e)}catch(t){oo.Ft(t)}}})})(i.cookie_persisted_properties||[],i.cookieWinsOnConflict,()=>!!this.hi);let s,n=!1,r=!1;const o=i.persistence.toLowerCase();return"localstorage"===o&&oo.$t()?(s=oo,r=!0):"localstorage+cookie"===o&&e.$t()?(s=e,r=!0,n=!0):"sessionstorage"===o&&wo.$t()?s=wo:"memory"===o?s=yo:"cookie"===o&&no.$t()?(s=no,n=!0):e.$t()?(s=e,r=!0,n=!0):no.$t()?(s=no,n=!0):s=yo,this.Al=r,this.Fl=n,s}Kl(t){return`${this.Vl}__${t}`}Ql(t){return this.Al&&!!t.split_storage}properties(){const t={};return Dr(this.props,(i,e)=>{const s=kl(e);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,i))return;t[e]=i}}),t}load(t=!1){if(this.hi&&!t)return;const i=this.Ar.cookieWinsOnConflict&&"localstorage+cookie"===this.Ar.persistence.toLowerCase(),e=i?oo.Lt(this.Vl):null;let s={};if(i)try{s=co(no.Lt(this.Vl)),Dr(s,(t,i)=>{(R(t)||I(t)||""===t)&&delete s[i]})}catch(t){}const n=this.wl.Lt(this.Vl);if(n&&(this.props=Nr({},n)),this.Ol&&this.Su(),i&&n){var r,o;const t=null==e?void 0:e[mn],i=null!==(r=null==e?void 0:e.$user_state)&&void 0!==r?r:Tr,l=n[mn],a=null!==(o=n.$user_state)&&void 0!==o?o:Tr;if(l!==t||a!==i){this.Dl=!0,this.hi||wo.At(Xl(this.Vl),!0);const e=Nr({},this.props);lo.forEach(t=>delete e[t]),"anonymous"!==a||"identified"!==i&&"anonymous"!==s.$user_state&&(R(t)||l===t)||(la(e,s),delete e[un]),this.props=e;const n=new Set;lo.forEach(t=>{var i;const e=null===(i=kl(t))||void 0===i?void 0:i.storageGroup;e&&n.add(e)}),n.forEach(t=>{if(this.hi)return;const i={};Dr(this.props,(e,s)=>{var n;(null===(n=kl(s))||void 0===n?void 0:n.storageGroup)===t&&(i[s]=e)}),C(i)?(oo.Pt(this.Kl(t)),this.Rl[t]={}):oo.At(this.Kl(t),i)&&(this.Rl[t]={persisted:!0,fingerprint:this.ru(i,t)})})}}wo.Ot(Xl(this.Vl))&&(this.Dl=!0)}Su(){for(const t of Sl){const i=oo.Lt(this.Kl(t));if(i&&!C(i)){const e=this.tu(t);e.persisted=!0,this.xu(t)||(e.fingerprint=this.ru(i,t)),this.$u(t,i)||Nr(this.props,i)}}}xu(t){return Object.keys(this.props).some(i=>{var e;return(null===(e=kl(i))||void 0===e?void 0:e.storageGroup)===t})}$u(t,i){const e=Yl[t];if(!e)return!1;const s=i[e],n=this.props[e];return M(s)&&M(n)&&n>s}refreshKey(t){var i;if(this.hi)return;if(this.zl.has(t))return;const e=this.Ol?null===(i=kl(t))||void 0===i?void 0:i.storageGroup:void 0,s=e?oo.Lt(this.Kl(e)):this.wl.Lt(this.Vl);if(s&&t in s)this.au(t,s[t],!1);else{if(e){const i=this.wl.Lt(this.Vl);if(i&&t in i)return void this.au(t,i[t],!1)}this.lu(t,!1)}}save(){if(this.hi)return;const t=this.vu();t>0?R(this._u)&&(this._u=setTimeout(()=>{this._u=void 0,this.wu()},t)):this.wu()}flush(){R(this._u)||(clearTimeout(this._u),this._u=void 0,this.wu())}wu(t=!1){if(this.hi||this.Ll&&!t)return;t||(this.syncCookieProperties(),this.Ar.cookieWinsOnConflict&&"localstorage+cookie"===this.Ar.persistence.toLowerCase()||sa.forEach(t=>this.refreshKey(t)));const i=!t&&!this.ql;i||(this.Bl=!1);const e=!!i&&this.uu();if(this.Bl)return void(this.Ar.debug&&Us.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Ol)return this.Cu(),void(e&&this.Hl.forEach(t=>t()));const s=this.Tu(this.wl,this.Vl,this.props,ta);"written"===s&&this.fu(this.props),"failed"!==s&&(this.Nl.clear(),this.jl=!1,this.zl.clear()),e&&this.Hl.forEach(t=>t())}Cu(){const{main:t,groups:i}=this.nu(),e=this.Tu(this.wl,this.Vl,t,ta);"written"===e&&this.fu(t),"failed"!==e&&(this.jl=!1,this.zl.clear(),ia.forEach(t=>{var i;(null===(i=kl(t))||void 0===i?void 0:i.storageGroup)||this.Nl.delete(t)}));for(const t of Sl){var s;const e=i[t];if(C(e)&&!(null===(s=this.Rl[t])||void 0===s?void 0:s.persisted)){ia.forEach(i=>{var e;(null===(e=kl(i))||void 0===e?void 0:e.storageGroup)===t&&this.Nl.delete(i)});continue}const n=this.Tu(oo,this.Kl(t),e,t);"failed"!==n&&ia.forEach(i=>{const e=kl(i);(null==e?void 0:e.storageGroup)!==t||"written"!==n&&e.volatile||this.Nl.delete(i)})}}nu(){const t={},i={flags:{},surveys:{}};return Dr(this.props,(e,s)=>{var n;const r=null===(n=kl(s))||void 0===n?void 0:n.storageGroup;r?i[r][s]=e:t[s]=e}),{main:t,groups:i}}ru(t,i){if(i===ta)return JSON.stringify(t)+"|"+this.Iu+"|"+this.Mu+"|"+this.Eu;const e={};return Dr(t,(t,i)=>{var s;e[i]=(null===(s=kl(i))||void 0===s?void 0:s.volatile)?"__volatile__":t}),JSON.stringify(e)}Tu(t,i,e,s){const n=this.tu(s);if(s!==ta&&!n.dirty&&!R(n.fingerprint))return"skipped";let r;try{if(r=this.ru(e,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){r=void 0}return t.At(i,e,this.Iu,this.Mu,this.Eu,this.Ar.debug)?(n.dirty=!1,s!==ta&&(n.persisted=!0),R(r)||(n.fingerprint=r),this.Al&&(n.storageValue=oo.Ot(i)),"written"):(this.Ar.debug&&Us.warn(`failed to persist storage entry "${i}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.hu(),R(this._u)||(clearTimeout(this._u),this._u=void 0),this.wl.Pt(this.Vl,!1),this.wl.Pt(this.Vl,!0),!t&&this.Ul)for(const t of Sl)oo.Pt(this.Kl(t));t?delete this.Rl[ta]:this.Rl={},this.pu=void 0,this.gu=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(P(t)){this.syncCookieProperties(),R(i)&&(i="None"),this.Iu=R(e)?this.Pu:e;let s=!1;if(Dr(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.au(e,t),s=!0)}),s)return this.save(),!0}return!1}register(t,i){if(P(t)){this.syncCookieProperties(),this.Iu=R(i)?this.Pu:i;let e=!1;if(Dr(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||P(i)||k(i))&&(this.au(s,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();const i="string"==typeof t?[t]:t;let e=!1;for(const t of i)t in this.props&&(this.lu(t),e=!0);e&&this.save()}update_campaign_params(){const t=null==s?void 0:s.URL;if(t===this.Wl)return;const i=Ul(this.Ar.custom_campaign_params,this.Ar.mask_personal_data_properties,this.Ar.custom_personal_data_properties),e=!C(Ur(i));return e&&this.register(i),this.Wl=t,e?i:void 0}update_search_keyword(){this.register(function(){const t=null==s?void 0:s.referrer;return t?zl(t):{}}())}update_referrer_info(){var t;this.register_once({$referrer:Wl(),$referring_domain:(null==s?void 0:s.referrer)&&(null===(t=Al(s.referrer))||void 0===t?void 0:t.host)||Vl},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const t=Gl(this.Ar.mask_personal_data_properties,this.Ar.custom_personal_data_properties,this.Ar.disable_capture_url_hashes);this.register_once({[dr]:this.Fl?{r:Ql(t.r),u:t.u?Ql(t.u):void 0}:t},void 0)}get_initial_props(){const t={};Dr([hr,ur],i=>{const e=this.props[i];e&&Dr(e,function(i,e){t["$initial_"+b(e)]=i})});const i=this.props[dr];if(i){const e=function(t,i=!1){const e=Kl(t,i),s={};return Dr(e,function(t,i){s[`$initial_${b(i)}`]=t}),s}(i,this.Ar.disable_capture_url_hashes);Nr(t,e)}return t}safe_merge(t){return Dr(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){const s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;const e=[...t].sort(),s=[...i].sort();return e.every((t,i)=>t===s[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),r=s||n,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,a=!!this.hi&&!l;l||this.mu(i,a),this.Ar=t,!l&&(s||n||o)&&(this.pu=void 0,this.gu=void 0,this.mu(wi(wi({},t),{},{cookie_persisted_properties:i.cookie_persisted_properties}),a));const u=r||o?this.Gl(t):this.wl;this.Ru();const h=this.Ql(t),d=r||h!==this.Ol,c=!l&&(d||t.cross_subdomain_cookie!==this.Mu||t.secure_cookie!==this.Eu)&&this.yu(a);this.ql=d;try{if(this.Pu=this.Iu=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){const t=this.props;this.clear(),this.wl=u,this.Ol=h,this.props=t,this.save()}else o&&(this.wl=u,l||(delete this.Rl[ta],this.wu()))}finally{this.ql=!1,c&&this.ku()}}Ru(){const t=this.props[dr];if(!this.Fl||!P(t)||"string"!=typeof t.r)return;const i=Ql(t.r),e="string"==typeof t.u?Ql(t.u):t.u;i===t.r&&e===t.u||this.au(dr,wi(wi({},t),{},{r:i,u:e}))}set_disabled(t){this.hi=t,this.hi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Mu&&(this.Mu=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Eu&&(this.Eu=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){const e=this.props.__timers||{};e[t]=i,this.au(Tn,e),this.save()}remove_event_timer(t){const i=this.props.__timers||{},e=i[t];return R(e)||(delete i[t],this.au(Tn,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.au(t,i),this.save()}au(t,i,e=!0){var s;const n=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||n===i||(this.jl=!0),na(t)&&!ra(n,i)&&this.zl.add(t),this.du(t,n,i),(null===(s=kl(t))||void 0===s?void 0:s.volatile)||this.cu(t))}lu(t,i=!0){delete this.props[t],i&&(ea(t)&&this.Yl(t,!0),na(t)&&this.zl.add(t),this.cu(t))}cu(t){var i;const e=null===(i=kl(t))||void 0===i?void 0:i.storageGroup;e&&(this.tu(e).dirty=!0)}tu(t){return this.Rl[t]||(this.Rl[t]={})}};const ua={GZipJS:"gzip-js",Base64:"base64"},ha={Activation:"events",Cancellation:"cancelEvents"},da={Button:"button",Tab:"tab",Selector:"selector"},ca={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"},va={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},fa={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},pa={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},_a={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ga={Once:"once",Recurring:"recurring",Always:"always"},ma={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},ya={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"},ba={Popover:"popover",Inline:"inline"};function wa(t){let i=!0;return{dispose(){if(i){i=!1;const e=t();e&&T(e.then)&&e.then(void 0,()=>{})}}}}const $a={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},Sa={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"},xa={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"},Ea=Bs("[RateLimiter]");var ka=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{Ea.info(`${t||"events"} is quota limited.`),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void Ea.warn(`could not rate limit - continuing. Error: "${null==t?void 0:t.message}"`,{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var i,e,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),l=null!==(i=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:n,last:o};l.tokens+=Math.max(0,o-l.last)/1e3*r,l.last=Math.max(l.last,o),l.tokens>n&&(l.tokens=n);const a=1>l.tokens;if(a||t||(l.tokens=Math.max(0,l.tokens-1)),a&&!t){const t=(M(l.dropped)?l.dropped:0)+1;l.dropped=t,!this.lastEventRateLimited&&this.Au(t)&&(l.dropped=0)}return this.lastEventRateLimited=a,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",l),{isRateLimited:a,remainingTokens:l.tokens}}Fu(t){const i=this.instance.config.property_denylist;return!k(i)||!i.includes(t)}Ou(){var t;if(this.Fu("$current_url")&&this.Fu("$pathname")&&(null==n?void 0:n.pathname))return`${null!==(t=n.origin)&&void 0!==t?t:""}${n.pathname}`}Au(t){var i,e;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Ou(),o=this.Fu("$session_id")?null===(i=(e=this.instance).get_session_id)||void 0===i?void 0:i.call(e):void 0,l=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${l}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){const i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}};const Ta=Bs("[RemoteConfig]");var Pa=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null===(t=d._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.config}Du(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.loadExternalDependency)?null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Lu(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return Ta.info("Using preloaded remote config",this.remoteConfig),void this.Nu(this.remoteConfig);if(this._instance.qu())return void Ta.warn("Remote config is disabled. Falling back to local config.");this.Du(t=>{if(!t)return Ta.info("No config found after loading remote JS config. Falling back to JSON."),void this.Lu(t=>{this.Nu(t.json,t)});this.Nu(t)})}catch(t){Ta.error("Error loading remote config",t),this.Nu()}}Nu(t,i){!t&&i&&(0===i.statusCode?i.error||Ta.warn("Failed to fetch remote config from PostHog."):Ta.error("Failed to fetch remote config from PostHog."));try{this._instance.Nu(t?{ok:!0,config:t}:{ok:!1})}catch(t){Ta.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null===(e=this._instance.featureFlags)||void 0===e||e.ensureFlagsLoaded()}catch(t){Ta.error("Error loading feature flags",t)}}};const Ca=["fatal","error","warning","log","info","debug"];var Ra=Uint8Array,Oa=Uint16Array,Aa=Uint32Array,Ia=new Ra([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]),Fa=new Ra([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]),Ma=new Ra([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Da=function(t,i){for(var e=new Oa(31),s=0;31>s;++s)e[s]=i+=1<<t[s-1];var n=new Aa(e[30]);for(s=1;30>s;++s)for(var r=e[s];e[s+1]>r;++r)n[r]=r-e[s]<<5|s;return[e,n]},Na=Da(Ia,2),ja=Na[1];Na[0][28]=258,ja[258]=28;for(var La=Da(Fa,0)[1],Ua=new Oa(32768),Ba=0;32768>Ba;++Ba){var za=(43690&Ba)>>>1|(21845&Ba)<<1;Ua[Ba]=((65280&(za=(61680&(za=(52428&za)>>>2|(13107&za)<<2))>>>4|(3855&za)<<4))>>>8|(255&za)<<8)>>>1}var Ha=function(t,i,e){for(var s=t.length,n=0,r=new Oa(i);s>n;++n)++r[t[n]-1];var o,l=new Oa(i);for(n=0;i>n;++n)l[n]=l[n-1]+r[n-1]<<1;if(e){o=new Oa(1<<i);var a=15-i;for(n=0;s>n;++n)if(t[n])for(var u=n<<4|t[n],h=i-t[n],d=l[t[n]-1]++<<h,c=d|(1<<h)-1;c>=d;++d)o[Ua[d]>>>a]=u}else for(o=new Oa(s),n=0;s>n;++n)o[n]=Ua[l[t[n]-1]++]>>>15-t[n];return o},qa=new Ra(288);for(Ba=0;144>Ba;++Ba)qa[Ba]=8;for(Ba=144;256>Ba;++Ba)qa[Ba]=9;for(Ba=256;280>Ba;++Ba)qa[Ba]=7;for(Ba=280;288>Ba;++Ba)qa[Ba]=8;var Va=new Ra(32);for(Ba=0;32>Ba;++Ba)Va[Ba]=5;var Wa=Ha(qa,9,0),Ga=Ha(Va,5,0),Ka=function(t){return(t/8|0)+(7&t&&1)},Ja=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var s=new(t instanceof Oa?Oa:t instanceof Aa?Aa:Ra)(e-i);return s.set(t.subarray(i,e)),s},Ya=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8},Za=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8,t[s+2]|=e>>>16},Xa=function(t,i){for(var e=[],s=0;t.length>s;++s)t[s]&&e.push({s:s,f:t[s]});var n=e.length,r=e.slice();if(!n)return[new Ra(0),0];if(1==n){var o=new Ra(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var l=e[0],a=e[1],u=0,h=1,d=2;for(e[0]={s:-1,f:l.f+a.f,l:l,r:a};h!=n-1;)l=e[e[d].f>e[u].f?u++:d++],a=e[u!=h&&e[d].f>e[u].f?u++:d++],e[h++]={s:-1,f:l.f+a.f,l:l,r:a};var c=r[0].s;for(s=1;n>s;++s)r[s].s>c&&(c=r[s].s);var v=new Oa(c+1),f=Qa(e[h-1],v,0);if(f>i){s=0;var p=0,_=f-i,g=1<<_;for(r.sort(function(t,i){return v[i.s]-v[t.s]||t.f-i.f});n>s;++s){var m=r[s].s;if(i>=v[m])break;p+=g-(1<<f-v[m]),v[m]=i}for(p>>>=_;p>0;){var y=r[s].s;i>v[y]?p-=1<<i-v[y]++-1:++s}for(;s>=0&&p;--s){var b=r[s].s;v[b]==i&&(--v[b],++p)}f=i}return[new Ra(v),f]},Qa=function(t,i,e){return-1==t.s?Math.max(Qa(t.l,i,e+1),Qa(t.r,i,e+1)):i[t.s]=e},tu=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new Oa(++i),s=0,n=t[0],r=1,o=function(t){e[s++]=t},l=1;i>=l;++l)if(t[l]==n&&l!=i)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[l]}return[e.subarray(0,s),i]},iu=function(t,i){for(var e=0,s=0;i.length>s;++s)e+=t[s]*i[s];return e},eu=function(t,i,e){var s=e.length,n=Ka(i+2);t[n]=255&s,t[n+1]=s>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;s>r;++r)t[n+r+4]=e[r];return 8*(n+4+s)},su=function(t,i,e,s,n,r,o,l,a,u,h){Ya(i,h++,e),++n[256];for(var d=Xa(n,15),c=d[0],v=d[1],f=Xa(r,15),p=f[0],_=f[1],g=tu(c),m=g[0],y=g[1],b=tu(p),w=b[0],S=b[1],x=new Oa(19),E=0;m.length>E;++E)x[31&m[E]]++;for(E=0;w.length>E;++E)x[31&w[E]]++;for(var k=Xa(x,7),T=k[0],P=k[1],C=19;C>4&&!T[Ma[C-1]];--C);var R,O,A,I,F=u+5<<3,M=iu(n,qa)+iu(r,Va)+o,D=iu(n,c)+iu(r,p)+o+14+3*C+iu(x,T)+(2*x[16]+3*x[17]+7*x[18]);if(M>=F&&D>=F)return eu(i,h,t.subarray(a,a+u));if(Ya(i,h,1+(M>D)),h+=2,M>D){R=Ha(c,v,0),O=c,A=Ha(p,_,0),I=p;var N=Ha(T,P,0);for(Ya(i,h,y-257),Ya(i,h+5,S-1),Ya(i,h+10,C-4),h+=14,E=0;C>E;++E)Ya(i,h+3*E,T[Ma[E]]);h+=3*C;for(var j=[m,w],L=0;2>L;++L){var U=j[L];for(E=0;U.length>E;++E)Ya(i,h,N[B=31&U[E]]),h+=T[B],B>15&&(Ya(i,h,U[E]>>>5&127),h+=U[E]>>>12)}}else R=Wa,O=qa,A=Ga,I=Va;for(E=0;l>E;++E)if(s[E]>255){var B;Za(i,h,R[257+(B=s[E]>>>18&31)]),h+=O[B+257],B>7&&(Ya(i,h,s[E]>>>23&31),h+=Ia[B]);var z=31&s[E];Za(i,h,A[z]),h+=I[z],z>3&&(Za(i,h,s[E]>>>5&8191),h+=Fa[z])}else Za(i,h,R[s[E]]),h+=O[s[E]];return Za(i,h,R[256]),h+O[256]},nu=new Aa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ru=new Ra(0),ou=function(){for(var t=new Aa(256),i=0;256>i;++i){for(var e=i,s=9;--s;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),lu=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function au(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,s=0;i.length>s;++s)e=ou[255&e^i[s]]^e>>>8;t=e},d(){return 4294967295^t}}}(),s=t.length;e.p(t);var n,r,o,l,a,u,h=(l=10+((n=i).filename&&n.filename.length+1||0),a=8,function(t,i,e,s,n,r){var o=t.length,l=new Ra(s+o+5*(1+Math.floor(o/7e3))+n),a=l.subarray(s,l.length-n),u=0;if(!i||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=eu(a,u,t.subarray(h,d)):(a[h]=r,u=eu(a,u,t.subarray(h,o)))}else{for(var c=nu[i-1],v=c>>>13,f=8191&c,p=(1<<e)-1,_=new Oa(32768),g=new Oa(p+1),m=Math.ceil(e/3),y=2*m,b=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<y)&p},w=new Aa(25e3),S=new Oa(288),x=new Oa(32),E=0,k=0,T=(h=0,0),P=0,C=0;o>h;++h){var R=b(h),O=32767&h,A=g[R];if(_[O]=A,g[R]=O,h>=P){var I=o-h;if((E>7e3||T>24576)&&I>423){u=su(t,a,0,w,S,x,k,T,C,h-C,u),T=E=k=0,C=h;for(var F=0;286>F;++F)S[F]=0;for(F=0;30>F;++F)x[F]=0}var M=2,D=0,N=f,j=O-A&32767;if(I>2&&R==b(h-j))for(var L=Math.min(v,I)-1,U=Math.min(32767,h),B=Math.min(258,I);U>=j&&--N&&O!=A;){if(t[h+M]==t[h+M-j]){for(var z=0;B>z&&t[h+z]==t[h+z-j];++z);if(z>M){if(M=z,D=j,z>L)break;var H=Math.min(j,z-2),q=0;for(F=0;H>F;++F){var V=h-j+F+32768&32767,W=V-_[V]+32768&32767;W>q&&(q=W,A=V)}}}j+=(O=A)-(A=_[O])+32768&32767}if(D){w[T++]=268435456|ja[M]<<18|La[D];var G=31&ja[M],K=31&La[D];k+=Ia[G]+Fa[K],++S[257+G],++x[K],P=h+M,++E}else w[T++]=t[h],++S[t[h]]}}u=su(t,a,r,w,S,x,k,T,C,h-C,u),r||(u=eu(a,u,ru))}return Ja(l,0,s+Ka(u)+n)}(r=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,l,a,!u)),d=h.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&lu(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var s=0;e.length>=s;++s)t[s+10]=e.charCodeAt(s)}}(h,i),lu(h,d-8,e.d()),lu(h,d-4,s),h}const uu=!!o||!!r,hu=new WeakMap,du="text/plain";let cu=0,vu=!1;const fu=(t,i)=>{const[e,s]=t.split("#"),[n,r]=e.split("?");if(!r)return t;const o=r.split("&").filter(t=>t.split("=")[0]!==i).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},pu=(t,i,e=!0)=>{var s;const[n,r]=t.split("?"),o=wi({},i),l=null!==(s=null==r?void 0:r.split("&").map(t=>{var i;const[s,n]=t.split("="),r=e&&null!==(i=o[s])&&void 0!==i?i:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],a=function(t,i="&"){let e,s;const n=[];return Dr(t,function(t,i){R(t)||R(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),s=encodeURIComponent(i),n[n.length]=s+"="+e)}),n.join(i)}(o);return a&&l.push(a),l.length>0?`${n}?${l.join("&")}`:n},_u=t=>{if(t.lr)return t.lr;const{data:i,compression:e}=t;if(!i)return;if(e===ua.GZipJS){const t=au(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new Ra(t.length+(t.length>>>1)),s=0,n=function(t){e[s++]=t},r=0;i>r;++r){if(s+5>e.length){var o=new Ra(s+8+(i-r<<1));o.set(e),e=o}var l=t.charCodeAt(r);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Ja(e,0,s)}(Ol(i)),{mtime:0});return{contentType:du,body:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),estimatedSize:t.byteLength}}if(e===ua.Base64){const t=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(Ol(i)),e=(t=>"data="+encodeURIComponent("string"==typeof t?t:Ol(t)))(t);return{contentType:"application/x-www-form-urlencoded",body:e,estimatedSize:new Blob([e]).size}}const s=Ol(i);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},gu=t=>{const i=()=>"sendBeacon"===t.transport?{url:pu(t.url,{compression:ua.Base64}),encodedBody:_u(wi(wi({},t),{},{compression:ua.Base64,lr:void 0}))}:{url:fu(t.url,"compression"),encodedBody:_u(wi(wi({},t),{},{compression:void 0,lr:void 0}))};let e;try{e=_u(t)}catch(e){if(ye(t.compression,Il(t.url,"compression")))return Us.error("Failed to gzip request body, sending uncompressed payload",e),i();throw e}return e&&ye(t.compression,Il(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?me(new Uint8Array(s)):ArrayBuffer.isView(s)&&me(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(vu=!0,i()):{url:t.url,encodedBody:e};var s},mu=t=>{try{return gu(t)}catch(e){var i;return Us.error(e),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0,error:e}))}},yu=function(){var t=J(function*(t){const i=yield function(t){return Ee.apply(this,arguments)}(Ol(t.data),Gs.DEBUG,{rethrow:!0});if(!i)return t;const e=yield i.arrayBuffer();return wi(wi({},t),{},{lr:{contentType:du,body:e,estimatedSize:e.byteLength}})});return function(i){return t.apply(this,arguments)}}(),bu=/Failed to fetch|NetworkError|Load failed/i,wu=t=>"TypeError"===(null==t?void 0:t.name)&&bu.test((null==t?void 0:t.message)||""),$u=t=>{try{const i=function(t,i=Date.now()){if("string"!=typeof t||!t)return;const e=t.trim(),s=/^\d+\s*,/.test(e)?e.slice(0,e.indexOf(",")).trim():e;if(/^\d+$/.test(s)){const t=1e3*Math.min(Number(s),300);return t>0?t:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,r=Date.parse(n)-i;return Number.isFinite(r)&&r>0?Math.min(r,ai):void 0}(t());return R(i)?void 0:Math.min(i,3e4)}catch(t){return}},Su=t=>{const i=mu(t);if(!i)return;const e=new o;hu.set(e,!0);const{url:s,encodedBody:n}=i;e.open(t.method||"GET",s,!0);const{contentType:r,body:l}=null!=n?n:{};Dr(t.headers,function(t,i){e.setRequestHeader(i,t)}),r&&e.setRequestHeader("Content-Type",r),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i;const s={statusCode:e.status,text:e.responseText};if(200===e.status)try{s.json=JSON.parse(e.responseText)}catch(t){}null===(i=t.callback)||void 0===i||i.call(t,s,$u(()=>e.getResponseHeader("Retry-After")))}},e.send(l)},xu=t=>{const i=mu(t);if(!i)return;const{url:e,encodedBody:s}=i,{contentType:n,body:o,estimatedSize:a}=null!=s?s:{},u=new Headers;Dr(t.headers,function(t,i){u.append(i,t)}),n&&u.append("Content-Type",n);let h=null,d=!1;if(l){const i=new l;h={signal:i.signal,timeout:setTimeout(()=>{d=!0;try{i.abort(ci("AbortError","PostHog request timed out"+((e=t.timeout)?` after ${e}ms`:"")))}catch(t){v(t)}var e},t.timeout)}}let c=!1;const v=i=>{var e;c||(c=!0,d&&"AbortError"===(null==i?void 0:i.name)||wu(i)?Us.warn(i):Us.error(i),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0,error:i}))};let f=0;const p=()=>{cu-=f,f=0,h&&clearTimeout(h.timeout)};try{const i=wi({method:(null==t?void 0:t.method)||"GET",headers:u,referrerPolicy:"strict-origin",body:o,signal:null==h?void 0:h.signal},t.fetchOptions),s=null!=a?a:R(o)?0:void 0;i.keepalive="POST"===i.method&&!t.Ya&&!1!==i.keepalive&&i.body===o&&!R(s)&&s>=0&&52428.8>cu+s,i.keepalive&&(f=s,cu+=f),r(e,i).then(i=>i.text().then(e=>{var s;if(c)return;const n={statusCode:i.status,text:e};if(200===i.status)try{n.json=JSON.parse(e)}catch(t){Us.error(t)}c=!0,p(),null===(s=t.callback)||void 0===s||s.call(t,n,$u(()=>i.headers.get("Retry-After")))})).catch(t=>{p(),v(t)}).finally(p)}catch(t){p(),v(t)}},Eu=t=>{try{var i;const{url:s,encodedBody:n}=gu(t),{contentType:o,body:l,estimatedSize:a}=null!=n?n:{};if(!l)return;const u=l instanceof Blob?l:new Blob([l],{type:o});if(e.sendBeacon(s,u))return;const h=k(t.data)?t.data:null===(i=t.data)||void 0===i?void 0:i.batch;if(k(h)&&h.length>1&&(null!=a?a:0)>16384){const i=Math.ceil(h.length/2),e=i=>k(t.data)?i:wi(wi({},t.data),{},{batch:i});return Eu(wi(wi({},t),{},{data:e(h.slice(0,i))})),void Eu(wi(wi({},t),{},{data:e(h.slice(i))}))}Us.warn(`Beacon of ~${null!=a?a:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?xu(wi(wi({},t),{},{Ya:!0})):Su(t)}catch(t){Us.warn("Beacon send failed",t)}},ku=(t,i,e,s)=>{const n="query"===s?"POST"===i?"sent_at":"_":void 0;return pu(e===ua.GZipJS?fu(t,"compression"):t,wi(wi({},n?{[n]:Date.now().toString()}:{}),e===ua.GZipJS?{}:{compression:e}))},Tu=(()=>{const t=[];return r&&t.push({transport:"fetch",method:xu}),o&&t.push({transport:"XHR",method:Su}),(null==e?void 0:e.sendBeacon)&&t.push({transport:"sendBeacon",method:Eu}),t})();let Pu=!uu&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla"));function Cu(t,i,e){var s,n,r;e&&(i=wi(wi({},i),{},{callback:t=>e(t)})),t.__loaded?Pu?t.__request_queue.push(i):t.rateLimiter.isServerRateLimited(i.batchKey)?i.fireCallbackOnDrop&&(null===(n=i.callback)||void 0===n||n.call(i,{statusCode:429})):(i.transport=i.transport||t.config.api_transport,i.headers=wi(wi({},t.config.request_headers),i.headers),i.compression="best-available"===i.compression?null!==(s=t.compression)&&void 0!==s?s:i.compressionFallback:i.compression,(R(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(i.disableTransport=["sendBeacon"]),i.fetchOptions=i.fetchOptions||t.config.fetch_options,((t,i)=>{var e,s,n;const r=wi(wi({},t),{},{callback:null!=i?i:i=>{var e;return null===(e=t.callback)||void 0===e?void 0:e.call(t,i)}});r.timeout=r.timeout||6e4;const o=null!==(e=r.transport)&&void 0!==e?e:"fetch";"sendBeacon"===o&&R(r.compression)&&r.data&&(r.compression=ua.Base64),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(t=>{var i,e;const s=(k(t)?t:[t]).map(t=>wi(wi({},t),t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(i=null==n||null===(e=n.properties)||void 0===e?void 0:e.token)&&void 0!==i?i:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((t,i=(new Date).toISOString())=>k(t)?t.map(t=>wi(wi({},t),{},{sent_at:i})):wi(wi({},t),{},{sent_at:i}))(r.data))),r.url=ku(r.url,r.method,r.compression,r.timestampMode);const l=Tu.filter(t=>!r.disableTransport||!t.transport||!r.disableTransport.includes(t.transport)),u=null!==(s=null===(n=function(t,i){for(let e=0;t.length>e;e++)if(i(t[e]))return t[e]}(l,t=>t.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:l[0].method;if(!u)throw new Error("No available transport method");const h=t=>{try{u(t)}catch(t){var i;wu(t)?Us.warn(t):Us.error(t),null===(i=r.callback)||void 0===i||i.call(r,{statusCode:0,error:t})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===ua.GZipJS&&a&&"undefined"!=typeof Promise&&!vu?yu(r).then(t=>{h(t)}).catch(i=>{if(be(i))return vu=!0,void h(wi(wi({},r),{},{compression:void 0,url:ku(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;const i="name"in t?String(t.name):"";return be(t)||i===ge})(i)&&(vu=!0),h(r)}):h(r)})(i,(s,n)=>{var r,o,l;t.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=t.config).on_request_error)||void 0===r||r.call(o,s),e?e(s,n):null===(l=i.callback)||void 0===l||l.call(i,s)})):i.fireCallbackOnDrop&&(null===(r=i.callback)||void 0===r||r.call(i,{statusCode:0}))}var Ru=class{constructor(t,i){this.ju=!0,this.Bu=[],this.zu=Q((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,Us.createLogger("flush interval"),3e3),this.Hu=t}enqueue(t){this.Bu.push(t),this.Uu||this.Wu()}unload(){this.Vu();const t=this.Bu.length>0?this.Gu():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.Qu(wi(wi({},t),{},{callback:void 0}),"sendBeacon")})}enable(){this.ju=!1,this.Wu()}Wu(){this.ju||(this.Uu=setTimeout(()=>{this.Vu(),this.Zu()},this.zu))}Zu(){if(this.Bu.length>0){const t=this.Gu();for(const i in t)this.Qu(t[i])}}Qu(t,i){try{this.Hu(t,i)}catch(t){Us.error(t)}}Vu(){clearTimeout(this.Uu),this.Uu=void 0}Gu(){const t={},i={};Dr(this.Bu,e=>{var s;const n=e,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");R(t[r])&&(t[r]=wi(wi({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),i[r]=[]),null===(s=t[r].data)||void 0===s||s.push(n.data),n.callback&&i[r].push(n.callback)});for(const e in i){const s=i[e];s.length&&(t[e].callback=t=>{for(const i of s)i(t)})}return this.Bu=[],t}};const Ou=["retriesPerformedSoFar"];var Au=class{constructor(t){this._instance=t,this.Ju=!1,this.Ku=3e3,this.Bu=[],this.Bu=[],this.Xu=!0,this.resume()}resume(){if(!R(t)&&"onLine"in t.navigator){if(this.Xu=t.navigator.onLine,this.Yu)return;this.Yu=()=>{this.Xu=!0,this.Zu()},this.tc=()=>{this.Xu=!1},qr(t,"online",this.Yu),qr(t,"offline",this.tc)}}get length(){return this.Bu.length}retriableRequest(t,i){let{retriesPerformedSoFar:e}=t,s=ke(t,Ou);D(e)&&(s.url=pu(s.url,{retry_count:e})),Cu(this._instance,i?wi(wi({},s),{},{transport:i}):s,(t,i)=>{var n;if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.Ls(wi({retriesPerformedSoFar:e},s),i);0===t.statusCode&&Us.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=e?e:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,t)})}Ls(t,i){const e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;const s=Math.max(function(t){const i=3e3*Math.pow(2,t),e=i/2,s=Math.min(18e5,i),n=(Math.random()-.5)*(s-e);return Math.ceil(s+n)}(e),null!=i?i:0),n=Date.now()+s;this.Bu.push({retryAt:n,requestOptions:t});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),Us.warn(r),this.Ju||(this.Ju=!0,this.ec())}ec(){if(this.nc&&clearTimeout(this.nc),0===this.Bu.length)return this.Ju=!1,void(this.nc=void 0);this.nc=setTimeout(()=>{this.Xu&&this.Bu.length>0&&this.Zu(),this.ec()},this.Ku)}Zu(){const t=Date.now(),i=[],e=this.Bu.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.Bu=i,e.length>0)for(const{requestOptions:t}of e)this.retriableRequest(t)}unload(){this.nc&&(clearTimeout(this.nc),this.nc=void 0),this.Ju=!1,R(t)||(this.Yu&&(t.removeEventListener("online",this.Yu),this.Yu=void 0),this.tc&&(t.removeEventListener("offline",this.tc),this.tc=void 0));for(const{requestOptions:t}of this.Bu)try{this._instance._send_request(wi(wi({},t),{},{callback:k(t.data)?void 0:t.callback,transport:"sendBeacon"}))}catch(t){Us.error(t)}this.Bu=[]}},Iu=class{constructor(t){this._instance=t,this.sc=()=>{var t,i,e,s;this.rc||(this.rc={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=r+((null==n?void 0:n.clientHeight)||0),a=(null==n?void 0:n.scrollHeight)||0;this.rc.lastScrollY=Math.ceil(r),this.rc.maxScrollY=Math.max(r,null!==(t=this.rc.maxScrollY)&&void 0!==t?t:0),this.rc.maxScrollHeight=Math.max(o,null!==(i=this.rc.maxScrollHeight)&&void 0!==i?i:0),this.rc.lastContentY=l,this.rc.maxContentY=Math.max(l,null!==(e=this.rc.maxContentY)&&void 0!==e?e:0),this.rc.maxContentHeight=Math.max(a,null!==(s=this.rc.maxContentHeight)&&void 0!==s?s:0)}}get oc(){return this._instance.config.scroll_root_selector}getContext(){return this.rc}resetContext(){const t=this.rc;return this.rc=void 0,setTimeout(this.sc,0),t}startMeasuringScrollPosition(){qr(t,"scroll",this.sc,{capture:!0}),qr(t,"scrollend",this.sc,{capture:!0}),qr(t,"resize",this.sc)}scrollElement(){if(this.oc){const e=k(this.oc)?this.oc:[this.oc];for(const s of e){var i;const e=null==t||null===(i=t.document)||void 0===i?void 0:i.querySelector(s);if(e)return e}return}var e;return null==t||null===(e=t.document)||void 0===e?void 0:e.documentElement}ac(i){var e,s;const n="y"===i?"scrollTop":"scrollLeft";if(this.oc){const t=this.scrollElement();return t&&t[n]||0}return t?"y"===i?t.scrollY||t.pageYOffset||(null===(e=t.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.scrollTop)||0:t.scrollX||t.pageXOffset||(null===(s=t.document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.scrollLeft)||0:0}scrollY(){return this.ac("y")}scrollX(){return this.ac("x")}};const Fu=t=>Gl(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);var Mu=class{constructor(t,i,e,s){this.qe=t=>{const i=this.lc();if(i&&i.sessionId===t)return;const e={sessionId:t,props:this.uc(this._instance)};this.cc.register({[lr]:e})},this._instance=t,this.hc=i,this.cc=e,this.uc=s||Fu,this.hc.onSessionId(this.qe)}lc(){return this.cc.props[lr]}getSetOnceProps(){var t;const i=null===(t=this.lc())||void 0===t?void 0:t.props;return i?"r"in i?Kl(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){const t={};return Dr(Ur(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t[`$session_entry_${b(e)}`]=i}),t}},Du=class{on(t,i){return this.bo[t]||(this.bo[t]=[]),this.bo[t].push(i),()=>{this.bo[t]=this.bo[t].filter(t=>t!==i)}}emit(t,i){for(const e of this.bo[t]||[])e(i);for(const e of this.bo["*"]||[])e(t,i)}constructor(){this.bo={}}};const Nu=Bs("[SessionId]"),ju=864e5;var Lu=class{on(t,i){return this.dc.on(t,i)}constructor(t,i,e){var s;if(this.vc=null,this.fc=null,this.gc=[],this.mc=void 0,this.yc=!1,this.dc=new Du,this.bc=(t,i)=>!(!D(t)||!D(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Ar=t.config,this.cc=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this._c=void 0,this._sessionActivityTimestamp=null,this.wc=i||Qr,this.kc=e||Qr;const n=this.Ar.persistence_name||this.Ar.token;if(this._sessionTimeoutMs=1e3*Q(this.Ar.session_idle_timeout_seconds||1800,60,36e3,Nu.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Sc(),this.xc="ph_"+n+"_window_id",this.$c="ph_"+n+"_primary_window_exists",this.Cc()){const t=wo.Lt(this.xc),i=wo.Lt(this.$c);t&&!i?this.je=t:wo.Pt(this.xc),wo.At(this.$c,!0)}(null===(s=this.Ar.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Ar.bootstrap.sessionID),this.Tc()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return R(this.gc)&&(this.gc=[]),this.gc.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.gc=this.gc.filter(i=>i!==t)}}Cc(){return"memory"!==this.Ar.persistence&&!this.cc.hi&&wo.$t()}Ic(t){t!==this.je&&(this.je=t,this.Cc()&&wo.At(this.xc,t))}Mc(){return this.je?this.je:this.Cc()?wo.Lt(this.xc):null}Ec(t){const i=this.vc;return!I(i)&&!I(t)&&5e3>Math.abs(t-i)}Pc(t,i,e){const s=i!==this._sessionActivityTimestamp,n=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,n&&!s||n&&this.Ec(i)||(this.vc=i,this.cc.register({[Vn]:[i,t,e]}))}Rc(){var t;const i=null===(t=this.Ar)||void 0===t?void 0:t.persistence_save_debounce_ms;return D(i)&&i>0}Ac(){this.Rc()?this.cc.refreshKey(Vn):(this.cc.flush(),this.cc.load())}Fc(){var t;if(I(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.vc)return;this.Ac();const[,i,e]=this.Oc();i===this.Xt&&e===this._sessionStartTimestamp&&(this.vc=this._sessionActivityTimestamp,this.cc.register({[Vn]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.cc.flush())}Dc(){const[t]=this.Oc(),i=D(t)?t:0,e=D(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}Lc(t){return this.Ac(),this.bc(t,this.Dc())}Oc(){const t=this.cc.props[Vn];return k(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.vc=null,this._c=void 0,clearTimeout(this.Nc),this.Nc=void 0,this.Pc(null,null,null)}setBootstrapSessionId(t,i=!1){const e=((t,i=(new Date).getTime())=>{try{const e=(t=>{const i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void Nu.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void Nu.error("Invalid sessionID in bootstrap",t)}})(t);return!R(e)&&(i?this._c={sessionId:t,sessionStartTimestamp:e}:this.Pc(t,(new Date).getTime(),e),!0)}destroy(){this.yc=!0,this.Fc(),clearTimeout(this.Nc),this.Nc=void 0,this.mc&&t&&(t.removeEventListener(Rr,this.mc,{capture:!1}),this.mc=void 0),this.gc=[]}Tc(){this.mc=()=>{this.Fc(),this.Cc()&&wo.Pt(this.$c)},qr(t,Rr,this.mc,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,i=null,e=!1){if("always"===this.Ar.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=i||(new Date).getTime(),n=this.Xt;if(e)this.fc=s;else if(I(this.fc)||this.fc>s||s-this.fc>=1e3){var r,o;null===(r=(o=this.cc).syncCookieProperties)||void 0===r||r.call(o),this.fc=s}let[,l,a]=this.Oc();const u=!R(n)&&l!==n,h=this.Dc();let d=this.Mc();const c=this._c,v=!!c&&(c.sessionStartTimestamp>s+6e4||s-c.sessionStartTimestamp>ju),f=c?v:D(a)&&Math.abs(s-a)>ju;let p=!1,_=u,g=!l||!!c;const m=l;let y=!g&&!t&&this.bc(s,h);if(y&&(y=this.Lc(s),y||Nu.info("cross-tab refresh kept the session alive",{sessionId:l}),[,l,a]=this.Oc(),y||(g=!l||!!c)),g||y||f){_=!1;const t=c&&!v;l=t?c.sessionId:this.wc(),d=this.kc(),Nu.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!t,changeReason:{noSessionId:g,activityTimeout:y,sessionPastMaximumLength:f}}),a=t?c.sessionStartTimestamp:s,this._c=void 0,p=!0}else d||(d=this.kc(),p=!0),_=_||l!==m,_&&(Nu.info("adopted cross-tab session id",{sessionId:l,windowId:d}),p=!0);const b=D(h)&&t&&!f?h:s,w=D(a)?a:(new Date).getTime();this.Ic(d),this.Pc(l,b,w),t||this.Sc();const S={noSessionId:g,activityTimeout:y,sessionPastMaximumLength:f,crossTabAdoption:_};return p&&this.gc.forEach(t=>t(l,d,S)),{sessionId:l,windowId:d,sessionStartTimestamp:w,changeReason:p?S:void 0,lastActivityTimestamp:h}}Sc(){this.yc||(clearTimeout(this.Nc),this.Nc=setTimeout(()=>{if(!this.yc)if(this.Lc((new Date).getTime())){const t=this.Xt;this.resetSessionId(),this.dc.emit("forcedIdleReset",{idleSessionId:t})}else this.Sc()},1.1*this.sessionTimeoutMs))}};const Uu=function(t,i){if(!t)return!1;const e=t.userAgent;if(e&&X(e,i))return!0;try{const e=null==t?void 0:t.userAgentData;if((null==e?void 0:e.brands)&&e.brands.some(t=>X(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function Bu(){return(Bu=J(function*(){const t=null==e?void 0:e.userAgentData;if(null==t?void 0:t.getHighEntropyValues)try{const i=yield t.getHighEntropyValues(["model"]),e=null==i?void 0:i.model;return O(e)&&e.length>0?e:void 0}catch(t){return void Us.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function zu(t,i){let e=`$survey_${i}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(e=`$survey_${i}/${t.id}/${t.current_iteration}`),e}function Hu(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}const qu=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Vu=t=>t.toLowerCase(),Wu={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>qu(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!qu(i,t))),icontains:(t,i)=>i.map(Vu).some(i=>t.map(Vu).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Vu).every(i=>t.map(Vu).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function Gu(t,i){return!t||Object.entries(t).every(([t,e])=>{const s=null==i?void 0:i[t];if(null==s)return!1;const n=Wu[e.operator];return!!n&&n(e.values.map(String),[String(s)])})}function Ku(t,i,e){return Ol({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}const Ju="custom",Yu="i.posthog.com",Zu=/^\/static\//,Xu=["/s/","/e/","/i/"];var Qu=class{constructor(t){this.qc={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let i=null===(t=this.instance.config.ui_host)||void 0===t?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace(`.${Yu}`,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.qc[this.apiHost]||(this.qc[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":Ju),this.qc[this.apiHost]}jc(t){if(!Zu.test(t))return;const i=this.instance.config.asset_host;return"string"==typeof i&&i.trim().replace(/\/$/,"")||void 0}Bc(t){const i=Al(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}zc(t,i,e){if("ui"===t)return e;let s=e;const n=this.instance.config.rewriteRequestPath;if(n){var r;const t=(null===(r=Al(e))||void 0===r?void 0:r.href)||e;s=n(new URL(t)).toString()}if(n&&"api"===t&&Xu.some(t=>0===i.indexOf(t))){const t=this.Bc(s);if(t){const i=this.apiHost;let e=this.Hc;(null==e?void 0:e.apiHost)===i&&e.rewriteRequestPath===n||(e={apiHost:i,rewriteRequestPath:n,urls:new Set},this.Hc=e),e.urls.add(t)}}return s}isIngestionEndpoint(t){const i=this.Hc,e=this.Bc(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i=""){if(i&&(i="/"===i[0]?i:`/${i}`),"ui"===t)return this.zc(t,i,this.uiHost+i);if("flags"===t)return this.zc(t,i,this.flagsApiHost+i);if("assets"===t){const e=this.jc(i);if(e)return this.zc(t,i,`${e}${i}`)}if(this.region===Ju)return this.zc(t,i,this.apiHost+i);const e=Yu+i;switch(t){case"assets":return this.zc(t,i,`https://${this.region}-assets.${e}`);case"api":return this.zc(t,i,`https://${this.region}.${e}`)}}};const th=Bs("[Surveys]"),ih=t=>{try{const i=(t=>((t,i)=>`seenSurvey_${function(t){return t.current_iteration&&t.current_iteration>0?`${t.id}_${t.current_iteration}`:t.id}(i)}`)(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){th.error("Failed to persist survey seen state",t)}},eh=[fa.Popover,fa.Widget,fa.API],sh={ignoreConditions:!1,ignoreDelay:!1,displayType:ba.Popover},nh=Bs("[PostHog ExternalIntegrations]"),rh={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var oh=class{constructor(t){this._instance=t}$l(t,i){var e,s;null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,t,t=>{if(t)return nh.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t;for(const[n,r]of Object.entries(null!==(t=this._instance.config.integrations)&&void 0!==t?t:{})){var i,e,s;r&&!(null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&this.$l(rh[n],()=>{var t;null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t||null===(t=t[n])||void 0===t||t.start(this._instance)}),!r&&(null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e?void 0:e[n])&&(null===(s=d.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}};const lh="autocapture",ah="featureFlags",uh="logs";var hh=class{constructor(t){this._instance=t}initialize(){}get(t){const i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);const e={};for(const s of t){const t=null==i?void 0:i.get_property(s);R(t)||(e[s]=t)}return e}set(t,i){var e;null===(e=this._instance.persistence)||void 0===e||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null===(i=this._instance.persistence)||void 0===i||i.unregister(t)}},dh=class{constructor(t){this.instance=t,this.$=Us,this.kv=new hh(t),this.onSession=t=>wa(this.instance.onSessionId(i=>{try{t(i)}catch(t){this.$.error("Browser extension session listener failed",t)}})),this.onEvent=t=>wa(this.instance._addCaptureHook((i,e)=>{if(e)try{t({event:i,properties:e.properties})}catch(t){this.$.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{const i=i=>{try{t(i)}catch(t){this.$.error("Browser extension remote config listener failed",t)}},e=this.instance.ur.on("extensionsRemoteConfig",i);return this.instance.cr&&i(this.instance.cr),wa(e)}}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){const t=this.instance.get_property(yn);return"string"==typeof t?t:void 0}get library(){return{name:Gs.LIB_NAME,version:Gs.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,s,n;const r=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==r?void 0:r.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==r?void 0:r.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0,lastActivityTimestamp:null!==(n=null==r?void 0:r.lastActivityTimestamp)&&void 0!==n?n:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return T(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(t){let i;switch(t){case ah:case"featureFlagsCommon":i=this.instance.featureFlags;break;case uh:i=this.instance.logs;break;case"surveys":i=this.instance.surveys;break;case lh:i=this.instance.autocapture}return i}capture(t,i,e){if(!e)return void this.instance.capture(t,i);const s=wi({timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce},"unload"===e.delivery?{transport:"sendBeacon",send_instantly:!0}:{});this.instance.capture(t,i,s)}registerDynamicEventProperties(t){return wa(this.instance.dr(t))}sendRequest(t){var i=this;return J(function*(t,e={}){var s;const n=null!==(s=e.target)&&void 0!==s?s:"api",r=e.query?pu(t,e.query):t,o=i.instance.requestRouter.endpointFor(n,r),l={method:e.method,url:o,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:"flags"===e.target&&"best-available"===e.compression?p.Base64:void 0,timestampMode:e.sentAt};return"api"===n&&"/i/v1/logs"===t&&(l.batchKey="logs"),"sendBeacon"===e.transport?(i.instance._send_request(l),{statusCode:202}):new Promise(t=>{l.callback=t,i.instance._send_request(l)})}).apply(this,arguments)}};const ch={};let vh=0;const fh=()=>{},ph='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',_h="Surveys module not available",gh="sanitize_properties is deprecated. Use before_send instead",mh="Invalid value for property_denylist config: ",yh=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],bh=["$feature_flag_called","$$heatmap","$snapshot"],wh=t=>"$"===t.charAt(0)&&!m(bh,t),$h=/^[A-Za-z0-9_-]{1,400}$/,Sh=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,xh=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Eh=["token","distinct_id",fr],kh="posthog",Th=t=>{const i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},Ph=i=>{var e;return wi({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Hr(null==s?void 0:s.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=i?i:"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:n&&O(null==n?void 0:n.search)&&-1!==n.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==t||null===(e=t.location)||void 0===e?void 0:e.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(t){Us.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Cr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:fh},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Bo,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:Th(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(i))},Ch=[["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"]],Rh=t=>{const i={};for(const[e,s]of Ch)R(t[e])||(i[s]=t[e]);const e=Nr({},i,t),s=t.__preview_external_dependency_versioned_paths;return R(s)||(R(t.strict_script_versioning)&&(e.strict_script_versioning=!!s),O(s)&&R(t.asset_host)&&(e.asset_host=s)),k(t.property_blacklist)&&(R(t.property_denylist)?e.property_denylist=t.property_blacklist:k(t.property_denylist)?e.property_denylist=[...t.property_blacklist,...t.property_denylist]:Us.error(mh+t.property_denylist)),e};var Oh=class{constructor(){this.__forceAllowLocalhost=!1}get Uc(){return this.__forceAllowLocalhost}set Uc(t){Us.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},Ah=class i{Wc(t){if(!t)return;const i=this.Vc.indexOf(t);-1!==i&&this.Vc.splice(i,1)}Gc(t,i){var e;return this.Wc(t),this.Vc.push(i),null===(e=i.initialize)||void 0===e||e.call(i),i}Qc(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}Zc(){if(this.Jc)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.Qc())return;const t="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!t&&!this.config.disable_persistence)return;if(this.Kc)return;let i,e,s;t?(i=`persistence is set to '${this.config.persistence}'`,e="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(i="persistence is disabled (disable_persistence is true)",e="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.Jc=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${e}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}Xc(){const t=this.persistence;if(!t||this.Yc)return;if(this.Qc())return void("on_reject"===this.config.cookieless_mode&&"$posthog_cookieless"!==this.get_distinct_id()&&(this.th(),this.eh()));if("$posthog_cookieless"!==this.get_distinct_id())return;this.ih()||t.load(!0);const i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){const i=this.config.get_device_id(Qr());this.register({distinct_id:i,$device_id:i}),t.set_property(or,Tr)}this.th()}get decideEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.nh=!1,this.sh=!1,this.webPerformance=new Oh,this.rh=!1,this.version=Gs.LIB_VERSION,this.oh=new Set,this.ah="",this.ur=new Du,this.Vc=[],this.uh=[],this.hh=!1,this.Kc=!1,this.Jc=!1,this.Yc=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ph(),this.SentryIntegration=wl,this.sentryIntegration=t=>function(t,i){const e=bl(t,i);return{name:yl,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.dh=!1,this.fh=null,this.ph=null,this.gh=null,this.scrollManager=new Iu(this),this.pageViewManager=new $l(this),this.rateLimiter=new ka(this),this.requestRouter=new Qu(this),this.consent=new $o(this),this.externalIntegrations=new oh(this);const e=null!==(t=i.__defaultExtensionClasses)&&void 0!==t?t:{};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:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(s),null==e||e({})},set_once:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(void 0,s),null==e||e({})}},this.on("eventCaptured",t=>Us.info(`send "${null==t?void 0:t.event}"`,t))}init(t,e,s){if(s&&s!==kh){var n;const r=null!==(n=ch[s])&&void 0!==n?n:new i;return r._init(t,e,s),ch[s]=r,ch[kh][s]=r,r}return this._init(t,e,s)}_init(i,e={},s){var n,r,o;const l=O(i)?i.trim():"";if(!l)return Us.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var a;if(this.__loaded)return l!==(null===(a=this.config)||void 0===a?void 0:a.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${l}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ph(e.defaults),e.debug=this.mh(e.debug),this.yh=e,this.bh=[],e.person_profiles?this.ph=e.person_profiles:e.process_person&&(this.ph=e.process_person);const u=Ph(e.defaults),h=Rh(e),d=Nr({},u,h,{name:s,token:l});P(u.rageclick)&&P(h.rageclick)&&(d.rageclick=Nr({},u.rageclick,h.rageclick)),P(u.session_recording)&&P(h.session_recording)&&(d.session_recording=Nr({},u.session_recording,h.session_recording)),this.set_config(d),this.config.on_xhr_error&&Us.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=e.disable_compression?void 0:ua.GZipJS;const c=this.ih(),v=!this.Qc();if(this.persistence=new aa(this.config,c,!0,v),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new aa(wi(wi({},this.config),{},{persistence:"sessionStorage"}),c,!1,v),this.ah="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!c&&wo.$t()){const t=wo.Lt(this.ah);k(t)&&t.forEach(t=>{O(t)&&this.oh.add(t)})}else wo.Pt(this.ah);const f=wi({},this.persistence.props),p=wi({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._h=new Ru((t,i)=>this.wh(t,i),this.config.request_queue_config),this.kh=new Au(this),this.__request_queue=[];const _=this.Qc();_||(this.sessionManager=new Lu(this),this.sessionPropsManager=new Mu(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{((null==e?void 0:e.activityTimeout)||(null==e?void 0:e.sessionPastMaximumLength)||(null==e?void 0:e.crossTabAdoption))&&this.Sh()})),this.xh(),this.config.__preview_deferred_init_extensions?(Us.info("Deferring extension initialization to improve startup performance"),this.$h=setTimeout(()=>{this.$h=void 0,this.Ch(_)},0)):(Us.info("Initializing extensions synchronously"),this.Ch(_)),Gs.DEBUG=Gs.DEBUG||this.config.debug,Gs.DEBUG&&Us.info("Starting in debug mode",{this:this,config:e,thisC:wi({},this.config),p:f,s:p}),this.config.identity_distinct_id&&!(null===(n=e.bootstrap)||void 0===n?void 0:n.distinctID)&&(e.bootstrap=wi(wi({},e.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const g=null===(r=e.bootstrap)||void 0===r?void 0:r.distinctID;if(this.Kc=!!g&&!A(g),null===(o=e.bootstrap)||void 0===o?void 0:o.distinctID){const t=e.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(or);if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"anonymous"===s)this.identify(t);else if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"identified"===s)Us.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const i=this.config.get_device_id(Qr()),s=e.bootstrap.isIdentifiedID?i:t;this.persistence.set_property(or,e.bootstrap.isIdentifiedID?Pr:Tr),this.register({distinct_id:t,$device_id:s})}}if(_)this.register_once({distinct_id:vr,$device_id:null},"");else if(!this.get_distinct_id()){const t=this.config.get_device_id(Qr());this.register_once({distinct_id:t,$device_id:t},""),this.persistence.set_property(or,Tr)}return qr(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),qr(t,"pageshow",()=>{var t;this.nh=!1,this.sh||null===(t=this.kh)||void 0===t||t.resume()}),e.segment?ml(this,()=>this.Th()):this.Th(),T(this.config._onCapture)&&this.config._onCapture!==fh&&(Us.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&Us.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 Bu.apply(this,arguments)}().then(t=>{t&&this.register({[bn]:t})}).catch(fh),this}Ih(t){const i=t;return O(i.name)&&T(i.setup)}Mh(t,i){var e=this;this.Ih(t)?i.push(J(function*(){try{yield t.setup(e.Eh())}catch(e){Us.error(`Failed to set up extension "${t.name}"`,e);try{var i;yield null===(i=t.dispose)||void 0===i?void 0:i.call(t)}catch(i){Us.error(`Failed to dispose extension "${t.name}"`,i)}}})):this.Vc.push(t)}xh(){var t,e,s,n=this;const r=null!==(t=null===(e=this.config.__extensionClasses)||void 0===e?void 0:e.featureFlags)&&void 0!==t?t:null===(s=i.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var o,l,a;if(r)if(this.featureFlags&&this.featureFlags instanceof r||(null===(o=this.Ph)||void 0===o||o.call(this),this.Ph=void 0,this.featureFlags=new r(this)),T(this.featureFlags.onReloading)&&T(this.featureFlags.setup)){if(!this.Ph){this.Ph=this.featureFlags.onReloading(()=>{this.ur.emit("featureFlagsReloading",!0)});const t=this.featureFlags;J(function*(){try{yield t.setup(n.Eh())}catch(i){Us.error("Failed to set up feature flags",i);const e=n.Ph;n.Ph=void 0;try{null==e||e()}catch(t){Us.error("Failed to unsubscribe feature flag reloading",t)}try{yield t.dispose()}catch(t){Us.error("Failed to dispose feature flags",t)}}})()}}else null===(l=(a=this.featureFlags).initialize)||void 0===l||l.call(a)}Ch(t){const e=performance.now(),s=wi(wi({},i.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,l,a,u,h,d,c;s.exceptions&&this.Vc.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.Vc.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.Vc.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.Vc.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this.Vc.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Mh(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Mh(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Mh(this.logs=null!==(l=this.logs)&&void 0!==l?l:new s.logs(this),n),s.metrics&&this.Vc.push(this.metrics=null!==(a=this.metrics)&&void 0!==a?a:new s.metrics(this)),s.conversations&&this.Vc.push(this.conversations=null!==(u=this.conversations)&&void 0!==u?u:new s.conversations(this)),s.productTours&&this.Vc.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.Vc.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.Vc.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.Vc.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.Vc.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,pl)),s.toolbar&&this.Vc.push(this.toolbar=null!==(h=this.toolbar)&&void 0!==h?h:new s.toolbar(this)),s.experiments&&this.Vc.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),s.webMCP&&this.Vc.push(this.webMCP=null!==(c=this.webMCP)&&void 0!==c?c:new s.webMCP(this)),this.Vc.forEach(t=>{t.initialize&&n.push(()=>{var i;null===(i=t.initialize)||void 0===i||i.call(t)})}),n.push(()=>{if(this.Rh){const t=this.Rh;this.Rh=void 0,this.Vc.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}}),this.Ah(n,e)}Ah(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void(this.$h=setTimeout(()=>{this.$h=void 0,this.Ah(t,i)},0));const e=t.shift();if(e)try{e()}catch(t){Us.error("Error initializing extension:",t)}}const e=Math.round(performance.now()-i);this.register_for_session({[pr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[_r]:e}),this.config.__preview_deferred_init_extensions&&Us.info(`PostHog extensions initialized (${e}ms)`)}Nu(t){if(!s||!s.body)return Us.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Nu(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Rh=t),this.cr=t,this.compression=void 0,t.ok){var i;const e=t.config;e.supportedCompression&&!this.config.disable_compression&&(this.compression=m(e.supportedCompression,ua.GZipJS)?ua.GZipJS:m(e.supportedCompression,ua.Base64)?ua.Base64:void 0),(null===(i=e.analytics)||void 0===i?void 0:i.endpoint)&&(this.analyticsDefaultEndpoint=e.analytics.endpoint)}this.set_config({person_profiles:this.ph?this.ph:Cr}),this.ur.emit("extensionsRemoteConfig",t),this.Vc.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}Th(){try{this.config.loaded(this)}catch(t){Us.critical("`loaded` function failed",t)}if(this.Fh(),this.config.internal_or_test_user_hostname&&(null==n?void 0:n.hostname)){const t=n.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Qc())&&this.Oh()},1),this.Dh=new Pa(this),this.Dh.load()}Fh(){var t;this.is_capturing()&&this.config.request_batching&&(null===(t=this._h)||void 0===t||t.enable())}_dom_loaded(){this.is_capturing()&&Mr(this.__request_queue,t=>this.wh(t)),this.__request_queue=[],this.Fh()}_handle_unload(){var t,i,e,s,n,r;this.nh=!0,null===(t=this.surveys)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t),null===(e=this.metrics)||void 0===e||e.flush("sendBeacon"),this.config.request_batching?(this.Lh()&&this.capture(Ar),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this._h)||void 0===n||n.unload(),null===(r=this.kh)||void 0===r||r.unload()):this.Lh()&&this.capture(Ar,null,{transport:"sendBeacon"})}_send_request(t){Cu(this,t)}wh(t,i){this.kh?this.kh.retriableRequest(t,i):this._send_request(i?wi(wi({},t),{},{transport:i}):t)}_execute_array(t){vh++;try{let i;const e=[],s=[],n=[];Mr(t,t=>{if(t)if(i=t[0],k(i))n.push(t);else if(T(t))try{t.call(this)}catch(i){Us.error("Error executing queued PostHog call",t,i)}else k(t)&&"alias"===i?e.push(t):k(t)&&-1!==i.indexOf("capture")&&T(this[i])?n.push(t):s.push(t)});const r=function(t,i){Mr(t,function(t){try{if(k(t[0])){let e=i;Dr(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){Us.error("Error executing queued PostHog call",t,i)}})};r(e,this),r(s,this),r(n,this)}finally{vh--}}push(t){if(vh>0&&k(t)&&O(t[0])){const e=i.prototype[t[0]];return void(T(e)&&e.apply(this,t.slice(1)))}this._execute_array([t])}get Nh(){return{property:Sn,persistenceKey:xn,cookieName:"_fbc",pattern:Sh,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[xn]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(xn)}}}get qh(){return{property:En,persistenceKey:kn,cookieName:"_fbp",pattern:xh,register:(t,i)=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.register({[kn]:{value:t,delivered:i}})},unregister:()=>{var t;return null===(t=this.persistence)||void 0===t?void 0:t.unregister(kn)}}}jh(t){var i;const e=null===(i=this.persistence)||void 0===i?void 0:i.get_property(t.persistenceKey);return O(e)&&t.pattern.test(e)?{value:e,delivered:!1}:P(e)&&O(e.value)&&t.pattern.test(e.value)?{value:e.value,delivered:!0===e.delivered}:void 0}Bh(t,i,e){return i===(null==e?void 0:e.value)?{value:i,pending:!e.delivered}:(t.register(i,!1),{value:i,pending:!0})}zh(t){if(!this.config.save_campaign_params||this.Qc())return;const i=Wr(t.cookieName);return O(i)&&t.pattern.test(i)?i:void 0}Hh(t,i,e,s){if(!this.persistence)return;const n=this.Nh;this.persistence.refreshKey(n.persistenceKey);const r=this.jh(n);if(s)return void n.unregister();if(e)return O(i)&&Sh.test(i)?this.Bh(n,i,r):void n.unregister();const o=O(t)&&$h.test(t)?t:void 0,l=this.zh(n);return l&&((t,i,e)=>{const s=t.split(".");if(i)return s[3]===i;if(!e)return!0;const n=e.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(l,o,r)?this.Bh(n,l,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this.Bh(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}Uh(t,i,e){if(!this.persistence)return;const s=this.qh;this.persistence.refreshKey(s.persistenceKey);const n=this.jh(s);if(e)return void s.unregister();if(i)return O(t)&&xh.test(t)?this.Bh(s,t,n):void s.unregister();const r=this.zh(s);return r?this.Bh(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}Wh(t,i){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const e=this.jh(t);(null==e?void 0:e.value)!==i||e.delivered||t.register(i,!0)}capture(t,i,e){var s,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._h))return void Us.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(R(t)||!O(t))return void Us.error("No event name provided to posthog.capture");if(this.Xc(),"$snapshot"===t&&this.Qc())return;const r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;const o=(null==e?void 0:e.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==o?void 0:o.isRateLimited)return void Us.critical("This capture call is ignored due to client rate limiting.");let l;(null==i?void 0:i.$current_url)&&!O(null==i?void 0:i.$current_url)&&(Us.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||(null==e?void 0:e.Vh)||Us.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const a=new Date,u=(null==e?void 0:e.timestamp)||a,h=di(null==e?void 0:e.uuid,Qr);let d={uuid:h,event:t,properties:this.calculateEventProperties(t,i||{},u,h)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&r&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),o&&(d.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens);const c="$feature_flag_called"===t&&!1===d.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==e?void 0:e.$set)&&!c&&(d.$set=null==e?void 0:e.$set);const v=P(null==i?void 0:i.$set)?i.$set:void 0,f=k(null==i?void 0:i.$unset)?i.$unset:[],p=(null==e?void 0:e.$unset)||[],_=t=>{var i;const s=!!(null==e?void 0:e.$set)&&t in e.$set;return{hasProvided:s||!!v&&t in v,provided:s?null==e||null===(i=e.$set)||void 0===i?void 0:i[t]:null==v?void 0:v[t],unset:-1!==f.indexOf(t)||-1!==p.indexOf(t)}},g=_(Sn),m=_(En),y=[{channel:this.Nh,hasProvided:g.hasProvided,update:this.Hh(null==l?void 0:l.fbclid,g.provided,g.hasProvided,g.unset)},{channel:this.qh,hasProvided:m.hasProvided,update:this.Uh(m.provided,m.hasProvided,m.unset)}];for(const{channel:t,hasProvided:i,update:e}of y)e&&!0===d.properties.$process_person_profile&&e.pending&&!i&&!c&&(d.$set=wi({[t.property]:e.value},d.$set));const b=null==e?void 0:e.$unset;b&&(d.$unset=b);const w=c?void 0:this.Gh(null==e?void 0:e.$set_once,t!==Fr,t===Ir);if(w&&(d.$set_once=w),(null==e?void 0:e._noTruncate)||(S=this.config.properties_string_max_length,d=function(t,i){const e=new Set;return function t(s,n){if(s!==Object(s))return i?i(s):s;if(e.has(s))return;let r;if(e.add(s),k(s))r=[],Mr(s,i=>{r.push(t(i))});else{const i={};Dr(z(s)?Br(s):s,(s,n)=>{e.has(s)||(i[n]=t(s,n))}),r=i}return r}(t)}(d,t=>O(t)?t.slice(0,S):t)),d.timestamp=u,R(null==e?void 0:e.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=a),c&&(d.properties=((t,i=[])=>{const e={},s=i=>{void 0!==t[i]&&(e[i]=t[i])};return _e.forEach(s),i.forEach(s),e})(d.properties,Eh)),t===ma.DISMISSED||t===ma.SENT){const e=null==i?void 0:i[ya.SURVEY_ID],s=null==i?void 0:i[ya.SURVEY_ITERATION];ih({id:e,current_iteration:s}),d.$set=wi(wi({},d.$set),{},{[zu({id:e,current_iteration:s},t===ma.SENT?"responded":"dismissed")]:!0})}else t===ma.SHOWN&&(d.$set=wi(wi({},d.$set),{},{[ya.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var S;if(t===Sa.SHOWN){const t=null==i?void 0:i[xa.TOUR_TYPE];t&&(d.$set=wi(wi({},d.$set),{},{[`${xa.TOUR_LAST_SEEN_DATE}/${t}`]:(new Date).toISOString()}))}const x=wi(wi({},d.properties.$set),d.$set);if(C(x)||this.setPersonPropertiesForFlags(x),!F(this.config.before_send)){const t=this.Os(d);if(!t)return;d=t,d.uuid=di(d.uuid,Qr)}this.sessionRecording&&!this.hh&&wh(t)&&(this.hh=!0,setTimeout(()=>this.hh=!1,3e4));const E=y.filter(({channel:t,update:i})=>{var e,s,n;const r=null!==(e=null===(s=d.$set)||void 0===s?void 0:s[t.property])&&void 0!==e?e:P(null===(n=d.properties)||void 0===n?void 0:n.$set)?d.properties.$set[t.property]:void 0;return(null==i?void 0:i.pending)&&r===i.value});this.ur.emit("eventCaptured",d);const T=null!==(s=null==e?void 0:e._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),A="recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(T),I=wi(wi(wi({method:"POST",url:T,data:d,compression:"best-available",preferSyncCompression:null==e?void 0:e.send_instantly,timestampMode:A?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},A&&(null===(n=d.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),(null==e?void 0:e.transport)?{transport:e.transport}:{}),E.length?{fireCallbackOnDrop:!0,callback:t=>{if(t.statusCode>=200&&300>t.statusCode)for(const{channel:t,update:i}of E)this.Wh(t,i.value)}}:{});if(!this.config.request_batching||e&&!(null==e?void 0:e._batchKey)||(null==e?void 0:e.send_instantly)){var M;let t;!I.transport&&!I.callback&&C(null!==(M=this.config.request_headers)&&void 0!==M?M:{})&&this.nh&&(t="sendBeacon"),this.wh(I,t)}else this._h.enqueue(I);return d}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null===(i=this.Qh)||void 0===i?void 0:i.getExtension(t)}Eh(){var t;return null!==(t=this.Qh)&&void 0!==t?t:this.Qh=new dh(this)}dr(t){this.uh.push(t);let i=!0;return()=>{if(!i)return;i=!1;const e=this.uh.indexOf(t);-1!==e&&this.uh.splice(e,1)}}Zh(t=!0){var i,e,s;return!!(null===(i=this.persistence)||void 0===i?void 0:i.consumeCookieIdentityChange())&&(this.gh=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.oh.clear(),this.Jh()),null===(e=this.featureFlags)||void 0===e||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(i,e,r,o,l){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return e;this.Xc(),this.persistence.syncCookieProperties(),this.Zh();const a=l?void 0:this.persistence.remove_event_timer(i);let h=wi({},e);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.Qc()&&(h[fr]=!0),"$snapshot"===i){const t=wi(wi({},this.persistence.properties()),this.sessionPersistence.properties());return h.distinct_id=t.distinct_id,(!O(h.distinct_id)&&!M(h.distinct_id)||A(h.distinct_id))&&Us.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}const d=function(i,e,s,r=!1){var o,l,a,h;if(!u)return{};const d=i?[...Dl,...e||[]]:[],[c,f]=Qt(u),[p,_]=function(t){for(let i=0;si.length>i;i++){const[e,s,n]=si[i],r=t.match(e);if(r){const i=n&&t.match(n)||r;return[s,(null==i?void 0:i[1])||""]}}return["",""]}(u),g=function(){const t="u">typeof navigator?navigator:void 0;return(null==t?void 0:t.brave)?{brave:!0}:{}}(),m={};R(s)||(m.detectGoogleSearchApp=s);const y={},b=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,w=null===(l=navigator)||void 0===l?void 0:l.maxTouchPoints,S=null==t||null===(a=t.screen)||void 0===a?void 0:a.width,x=null==t||null===(h=t.screen)||void 0===h?void 0:h.height,E=null==t?void 0:t.devicePixelRatio;R(b)||(y.userAgentDataPlatform=b),R(w)||(y.maxTouchPoints=w),R(S)||(y.screenWidth=S),R(x)||(y.screenHeight=x),R(E)||(y.devicePixelRatio=E);const k=Nr(Ur({$os:c,$os_version:f,$browser:Jt(u,navigator.vendor,g,m),$webview_app:p,$webview_app_version:_,$device:ti(u),$device_type:ii(u,y),$timezone:Tl(),$timezone_offset:Jl()}),{$current_url:Fl(r?vi(null==n?void 0:n.href):null==n?void 0:n.href,d,jl),$host:null==n?void 0:n.host,$pathname:null==n?void 0:n.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:Zt(u,navigator.vendor,g,m),$browser_language:Hl(),$browser_language_prefix:ql(),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:v.LIB_NAME,$lib_version:v.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return v.SDK_DIST_CHANNEL&&(k.$sdk_dist_channel=v.SDK_DIST_CHANNEL),k}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId(l,r.getTime(),!0);h.$session_id=t,h.$window_id=i}this.sessionPropsManager&&Nr(h,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const t=this.sessionRecording.sdkDebugProperties,e=!this.hh&&wh(i);for(const i in t)(e||m(yh,i))&&(h[i]=t[i])}h.$sdk_debug_retry_queue_size=null===(c=this.kh)||void 0===c?void 0:c.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}let f;if(this.requestRouter.region===Ju&&(h.$lib_custom_api_host=this.config.api_host),f="$pageview"!==i||l?"$pageleave"!==i||l?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),h=Nr(h,f),"$pageview"===i&&s&&(h.title=s.title),!R(a)){const t=r.getTime()-a;h.$duration=parseFloat((t/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");const p=this.persistence.properties(),_=this.sessionPersistence.properties(),g=h.$groups,y=p.$groups;P(g)&&!C(g)&&(h.$groups=wi(wi({},P(y)?y:{}),g)),Dr(["$referrer","$referring_domain"],t=>{t in p&&delete _[t]});const b={};if(this.uh.length>0)for(const t of this.uh.slice())try{Nr(b,t())}catch(t){Us.error("Failed to produce browser extension event properties",t)}h=Nr({},d,p,_,wi(wi({},b),h)),h.$is_identified=this._isIdentified(),k(this.config.property_denylist)?Dr(this.config.property_denylist,function(t){delete h[t]}):Us.error(mh+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const w=this.config.sanitize_properties;w&&(Us.error(gh),h=w(h,i));const S=this.Kh();return h.$process_person_profile=S,S&&!l&&this.Xh("_calculate_event_properties"),h}Gh(t,i=!0,e=!1){var s;if(!this.persistence||!this.Kh())return t;if(this.rh&&!e)return t;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Nr({},n,r||{},t||{});const l=this.config.sanitize_properties;return l&&(Us.error(gh),o=l(o,"$set_once")),i&&(this.rh=!0),C(o)?void 0:o}register(t,i){var e;null===(e=this.persistence)||void 0===e||e.register(t,i)}register_once(t,i,e){var s;null===(s=this.persistence)||void 0===s||s.register_once(t,i,e)}register_for_session(t){var i,e;null===(i=this.persistence)||void 0===i||i.syncCookieProperties(),this.Zh(),null===(e=this.sessionPersistence)||void 0===e||e.register(t),Object.keys(t).forEach(t=>this.oh.add(t)),this.Jh()}unregister(t){var i;null===(i=this.persistence)||void 0===i||i.unregister(t)}unregister_for_session(t){var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t),this.oh.delete(t),this.Jh()}Yh(t,i){this.register({[t]:i})}Sh(){this.oh.forEach(t=>{var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t)}),this.oh.clear(),this.Jh()}Jh(){var t;if(!this.ah)return;if("memory"===this.config.persistence||(null===(t=this.sessionPersistence)||void 0===t?void 0:t.hi)||!wo.$t())return void wo.Pt(this.ah);const i=[];this.oh.forEach(t=>i.push(t)),i.length>0?wo.At(this.ah,i):wo.Pt(this.ah)}getFeatureFlag(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,s;return null!==(e=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null===(t=this.featureFlags)||void 0===t||t.reloadFeatureFlags()}updateFlags(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i=!1,e){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.ur.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:_h}),()=>{})}onSessionId(t){var i,e;return null!==(i=null===(e=this.sessionManager)||void 0===e?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:_h})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:_h})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:_h}),()=>{})}renderSurvey(t,i){var e;null===(e=this.surveys)||void 0===e||e.renderSurvey(t,i)}displaySurvey(t,i=sh){var e;null===(e=this.surveys)||void 0===e||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null===(i=this.surveys)||void 0===i||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null===(e=this.surveys)||void 0===e?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:_h}}canRenderSurveyAsync(t,i=!1){var e,s;return null!==(e=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:_h})}td(t){return!t||A(t)?(Us.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(Us.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Us.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return Us.uninitializedWarning("posthog.identify");if(M(t)&&(t=t.toString(),Us.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.td(t))return;if(!this.Xh("posthog.identify"))return;this.Xc();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.Zh(!1),o=this.persistence.yu();let l=!1;try{const s=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),t!==s&&t!==this.get_property("__alias")&&(this.unregister(wn),this.register({distinct_id:t}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Tr,u=t!==s,h=!u&&o;if(u&&o){var a;const n=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:s};this.persistence.set_property(or,Pr),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.bu(),this.capture("$identify",n,{$set:i||{},$set_once:e||{}})&&(this.gh=Ku(t,i,e)),null===(a=this.featureFlags)||void 0===a||a.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(h){this.persistence.set_property(or,Pr);const s=i||{},n=e||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.bu(),this.capture("$set",{$set:s,$set_once:n})&&(this.gh=Ku(t,i,e))}else(i||e)&&this.setPersonProperties(i,e);u||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(dn)):h&&(i||e)&&this.reloadFeatureFlags(),l=!0}finally{o&&this.persistence.ku(l)}}setPersonProperties(t,i){if(!t&&!i)return;if(!this.Xh("posthog.setPersonProperties"))return;const e=Ku(this.get_distinct_id(),t,i);this.gh!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}})&&(this.gh=e)):Us.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;const e=(k(t)?t:[t]).filter(t=>O(t)&&t.length>0);0!==e.length&&this.Xh("posthog.unsetPersonProperties")&&(null===(i=this.featureFlags)||void 0===i||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.gh=null)}group(t,i,e){var s;if(!t||!i)return void Us.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.Zh();const n=this.getGroups(),r=n[t]!==i;if(r&&this.resetGroupPropertiesForFlags(t),this.register({$groups:wi(wi({},n),{},{[t]:i})}),(r||e)&&this.Kh()){const s={$group_type:t,$group_key:i};e&&(s.$group_set=e),this.capture(Fr,s)}e&&this.setGroupPropertiesForFlags({[t]:e}),r&&!e&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var e;null===(e=this.featureFlags)||void 0===e||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var e;this.Xh("posthog.setGroupPropertiesForFlags")&&(null===(e=this.featureFlags)||void 0===e||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null===(i=this.featureFlags)||void 0===i||i.resetGroupPropertiesForFlags(t)}reset(t){const i=N(t)?t:null==t?void 0:t.resetDeviceID,e=N(t)||null==t?void 0:t.bootstrap;this.ed(i,!1,e)}ed(t,i=!1,e){var s,n,r,o,l,a;if(Us.info("reset"),!this.__loaded)return Us.uninitializedWarning("posthog.reset");const u=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null===(s=this.yh)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.qu());const h=this.get_property(yn),d=this.get_property(bn),c=this.get_property(jn);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const v=this.is_capturing();i||this.consent.reset(),i||!v||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const f=null===(l=this.persistence)||void 0===l||null===(a=l.yu)||void 0===a?void 0:a.call(l),p=this.Yc;this.Yc=p||i;let _=!1;try{var g,m,y,b,w,S,x,E,k,T,P,C,O;if(null===(g=this.persistence)||void 0===g||g.clear(),null===(m=this.sessionPersistence)||void 0===m||m.clear(),this.oh.clear(),this.Jh(),R(c)||null===(T=this.persistence)||void 0===T||T.register({$session_recording_remote_config:c}),null===(y=this.surveys)||void 0===y||y.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(w=this.conversations)||void 0===w||w.reset(),null===(S=this.logs)||void 0===S||S.reset(),null===(x=this.metrics)||void 0===x||x.reset(),null===(E=this.persistence)||void 0===E||E.set_property("$user_state","anonymous"),null===(k=this.sessionManager)||void 0===k||k.resetSessionId(),this.gh=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:vr,$device_id:null},"");else{const i=this.config.get_device_id(Qr());this.register_once({distinct_id:i,$device_id:t?i:h},""),t||R(d)||this.register({[bn]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(e.distinctID&&!this.Qc()&&(null===(O=this.persistence)||void 0===O||O.set_property("$user_state",e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:e.distinctID})),null===(P=this.featureFlags)||void 0===P||P.initialize(),!F(u)&&!(null===(C=this.sessionManager)||void 0===C?void 0:C.setBootstrapSessionId(u,!0))){const t=wi({},e);delete t.sessionID,this.config.bootstrap=t}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var A,I;this.Yc=p,f&&(null===(A=this.persistence)||void 0===A||null===(I=A.ku)||void 0===I||I.call(A,_))}this.reloadFeatureFlags()}shutdown(t){var i=this;return J(function*(){if(!i.__loaded)return void Us.uninitializedWarning("posthog.shutdown");i.sh=!0,clearTimeout(i.$h),i.$h=void 0;const t=i.Ph;i.Ph=void 0;for(const e of[()=>{var t;return null===(t=i.sessionRecording)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.logs)||void 0===t?void 0:t.flushLogs("sendBeacon")},()=>{var t;return null===(t=i.metrics)||void 0===t?void 0:t.flush("sendBeacon")},()=>{var t;return null===(t=i.metrics)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.logs)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.surveys)||void 0===t?void 0:t.dispose()},()=>{var t;return null===(t=i.autocapture)||void 0===t?void 0:t.dispose()},()=>null==t?void 0:t(),()=>{var t;return null===(t=i._h)||void 0===t?void 0:t.unload()},()=>{var t;return null===(t=i.kh)||void 0===t?void 0:t.unload()},()=>{var t;return null===(t=i.featureFlags)||void 0===t?void 0:t.destroy()},()=>{var t;return null===(t=i.persistence)||void 0===t?void 0:t.destroy()},()=>{var t;return null===(t=i.sessionPersistence)||void 0===t?void 0:t.destroy()}])try{const t=e();t&&T(t.then)&&t.then(void 0,t=>{Us.error("Error during shutdown",t)})}catch(t){Us.error("Error during shutdown",t)}})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null===(e=this.conversations)||void 0===e||e.nd()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(t=this.conversations)||void 0===t||t.sd()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:i,sessionStartTimestamp:e}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if((null==t?void 0:t.withTimestamp)&&e){var n;const i=null!==(n=t.timestampLookBack)&&void 0!==n?n:10;if(!e)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-e)/1e3)-i,0)}`}return s}alias(t,i){return t===this.get_property("$people_distinct_id")?(Us.critical("Attempting to create alias for existing People user - aborting."),-2):this.Xh("posthog.alias")?(R(i)&&(i=this.get_distinct_id()),t!==i?(this.Yh(wn,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(Us.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const i=wi({},this.config);if(P(t)){var e,s,n,r,o,l,a,u,h,d,c,v,f,p;Nr(this.config,Rh(t));const b=this.ih();if(this.persistence){const t="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;var _,g;if(t&&this.sessionPersistence!==this.persistence&&(null===(_=this.sessionPersistence)||void 0===_||_.remove(),null===(g=this.sessionPersistence)||void 0===g||g.destroy()),this.persistence.update_config(this.config,i,b),t)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new aa(wi(wi({},this.config),{},{persistence:"sessionStorage"}),b,!1);else{var m;null===(m=this.sessionPersistence)||void 0===m||m.update_config(wi(wi({},this.config),{},{persistence:"sessionStorage"}),wi(wi({},i),{},{persistence:"sessionStorage"}),b)}}const w=this.mh(this.config.debug);var y;N(w)&&(this.config.debug=w),N(this.config.debug)&&(this.config.debug?(Gs.DEBUG=!0,oo.$t()&&oo.At("ph_debug",!0),Us.info("set_config",{config:t,oldConfig:i,newConfig:wi({},this.config)})):(Gs.DEBUG=!1,oo.$t()&&oo.Pt("ph_debug"))),null===(e=this.featureFlags)||void 0===e||null===(s=e.updateConfig)||void 0===s||s.call(e,this.config,this.qu()),null===(n=this.exceptionObserver)||void 0===n||n.onConfigChange(),null===(r=this.exceptions)||void 0===r||r.onConfigChange(),null===(o=this.metrics)||void 0===o||o.onConfigChange(),null===(l=this.webMCP)||void 0===l||l.startIfEnabled(),null===(a=this.sessionRecording)||void 0===a||a.startIfEnabledOrStop(),null===(u=this.tracingHeaders)||void 0===u||u.startIfEnabledOrStop(),null===(h=this.autocapture)||void 0===h||h.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null===(y=this.historyAutocapture)||void 0===y||y.startIfEnabledOrStop()),null===(c=this.exceptionObserver)||void 0===c||c.startIfEnabledOrStop(),null===(v=this.deadClicksAutocapture)||void 0===v||v.startIfEnabledOrStop(),null===(f=this.surveys)||void 0===f||f.loadIfEnabled(),this.th(),null===(p=this.externalIntegrations)||void 0===p||p.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&ml(this,fh,!1)}}_overrideSDKInfo(t,i){Gs.LIB_NAME=t,Gs.LIB_VERSION=i}startSessionRecording(t){const i=!0===t,e={sampling:i||!!(null==t?void 0:t.sampling),linked_flag:i||!!(null==t?void 0:t.linked_flag),url_trigger:i||!!(null==t?void 0:t.url_trigger),event_trigger:i||!!(null==t?void 0:t.event_trigger)};var s,n,r,o,l;Object.values(e).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),e.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),e.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),e.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),e.event_trigger&&(null===(l=this.sessionRecording)||void 0===l||l.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(null===(t=this.sessionRecording)||void 0===t?void 0:t.started)}captureException(t,i){try{if(!this.exceptions)return;const e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(wi(wi({},e),i))}catch(t){return}}addExceptionStep(t,i){var e;null===(e=this.exceptions)||void 0===e||e.addExceptionStep(t,i)}captureLog(t){var i;null===(i=this.logs)||void 0===i||i.captureLog(t)}get logger(){var t,e;return null!==(t=null===(e=this.logs)||void 0===e?void 0:e.logger)&&void 0!==t?t:i.rd}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null===(e=this.toolbar)||void 0===e?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null===(i=this.persistence)||void 0===i?void 0:i.props[t]}getSessionProperty(t){var i;return null===(i=this.sessionPersistence)||void 0===i?void 0:i.props[t]}toString(){var t;let i=null!==(t=this.config.name)&&void 0!==t?t:kh;return i!==kh&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))||"identified"===(null===(i=this.sessionPersistence)||void 0===i?void 0:i.get_property("$user_state"))}Kh(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&C(this.getGroups())&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.__alias)&&!(null===(i=this.persistence)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.$epp))}Lh(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Kh()||this.Xh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Xh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Xh(t){return"never"===this.config.person_profiles?(Us.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Zc(),this.Yh(cr,!0),!0)}ih(){if("always"===this.config.cookieless_mode)return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}th(){var t,i;const e=this.ih();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.od(),(null===(t=this.persistence)||void 0===t?void 0:t.hi)!==e&&(null===(n=this.persistence)||void 0===n||n.set_disabled(e)),(null===(i=this.sessionPersistence)||void 0===i?void 0:i.hi)!==e&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(e)),this.Jh(),e}opt_in_capturing(t){var e;if("always"!==this.config.cookieless_mode){if(this.Qc()){var s,n,r,o,l,a;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.ed(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Lu(this),this.pageViewManager=new $l(this),this.persistence&&(this.sessionPropsManager=new Mu(this,this.sessionManager,this.persistence));const t=null!==(o=null===(l=this.config.__extensionClasses)||void 0===l?void 0:l.sessionRecording)&&void 0!==o?o:null===(a=i.__defaultExtensionClasses)||void 0===a?void 0:a.sessionRecording;var u,h;t&&(this.sessionRecording=this.Gc(this.sessionRecording,new t(this)),this.cr&&(null===(u=this.sessionRecording)||void 0===u||null===(h=u.onRemoteConfig)||void 0===h||h.call(u,this.cr)))}var d,c;this.consent.optInOut(!0),this.th(),this.Fh(),null===(e=this.sessionRecording)||void 0===e||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(R(null==t?void 0:t.captureEventName)||(null==t?void 0:t.captureEventName))&&this.capture(null!==(c=null==t?void 0:t.captureEventName)&&void 0!==c?c:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Oh()}else Us.warn(ph)}opt_out_capturing(){"always"!==this.config.cookieless_mode?(this.consent.optInOut(!1),this.th(),"on_reject"===this.config.cookieless_mode&&this.eh()):Us.warn(ph)}eh(){var t,i;const e=this.sessionRecording;null==e||e.dispose({discardBufferedEvents:!0}),"$posthog_cookieless"!==this.get_distinct_id()&&this.ed(!0,!0),this.register({distinct_id:vr,$device_id:null}),this.Wc(e),this.sessionRecording=void 0,null===(t=this.sessionManager)||void 0===t||t.destroy(),null===(i=this.pageViewManager)||void 0===i||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Oh(),this.Fh()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return!this.Yc&&("always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.th()}_is_bot(){return e?Uu(e,this.config.custom_blocked_useragents):void 0}Oh(){s&&("visible"===s.visibilityState?this.dh||(this.dh=!0,this.capture(Or,{title:s.title},{send_instantly:!0}),this.fh&&(s.removeEventListener(_n,this.fh),this.fh=null)):this.fh||(this.fh=this.Oh.bind(this),qr(s,_n,this.fh)))}debug(i){!1===i?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}qu(){const t=this.yh||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Us.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(t,i,e,s,n){const r=i in t&&!F(t[i]),o=e in t&&!F(t[e]);return r?t[i]:!!o&&(n&&n.warn(`Config field '${e}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,Us)}Os(t){var i;if(F(this.config.before_send))return t;const e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(L),s=k(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const i of s)try{if(n=i(n),F(n)){const i=`Event '${t.event}' was rejected in beforeSend function`;return j(t.event)?Us.warn(`${i}. This can cause unexpected behavior.`):Us.info(i),null}n.properties&&!C(n.properties)||Us.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(i){return Us.error(`Error in beforeSend function for event '${t.event}':`,i),null}for(const i of e)if(n.properties&&F(n.properties[i]))return Us.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return null===(t=this.pageViewManager.Il)||void 0===t?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}mh(t){const i=N(t)&&!t,e=oo.$t()&&"true"===oo.Ot("ph_debug");return!i&&(!!e||t)}};Ah.__defaultExtensionClasses={},Ah.rd=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(let e=0;i.length>e;e++)t.prototype[i[e]]=Lr(t.prototype[i[e]])}(Ah,["identify"]);var Ih=class{constructor(t){this.disabled=!1===t;const i=P(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(t-s.x)+Math.abs(i-s.y)<this.thresholdPx&&this.timeoutMs>e-s.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}};const Fh="$copy_autocapture",Mh=Bs("[AutoCapture]");function Dh(t,i){return i.length>t?i.slice(0,t)+"...":i}function Nh(t){if(t.previousElementSibling)return t.previousElementSibling;let i=t;do{i=i.previousSibling}while(i&&!Eo(i));return i}function jh(i,{e:e,maskAllElementAttributes:s,maskAllText:n,elementAttributeIgnoreList:r,elementsChainAsString:o,disableCaptureUrlHashes:l}){var a,u;if(!Eo(i))return{props:{}};const h=[i],d=new Set([i]);let c=i;for(;c.parentNode&&!ko(c,"body")&&1e3>h.length;){if(Po(c.parentNode)){const t=c.parentNode.host;if(d.has(t))break;d.add(t),h.push(t),c=t;continue}if(!Eo(c.parentNode))break;if(d.has(c.parentNode))break;d.add(c.parentNode),h.push(c.parentNode),c=c.parentNode}const v="click"===e.type&&"http://www.w3.org/2000/svg"===i.namespaceURI?h.findIndex(t=>ko(t,"button")||ko(t,"a")):-1;v>0&&(n=n||h.slice(0,v+1).some(t=>!Qo(t)||tl(t)));const f=[],p={};let _,g=!1,y=!1;if(Dr(h,t=>{const i=Qo(t);if(ko(t,"a")&&!s&&!(null==r?void 0:r.includes("href"))){const e=t.getAttribute("href");g=!!(i&&e&&al(e))&&(l?vi(e):e)}m(Oo(t),"ph-no-capture")&&(y=!0),f.push(function(t,i,e,s,n=!1){const r=t.tagName.toLowerCase(),o={tag_name:r};Mo.indexOf(r)>-1&&!e&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?Dh(1024,ul(t)):Dh(1024,Io(t)));const l=Oo(t);i||(null==s?void 0:s.includes("class"))||0>=l.length||(o.classes=l.filter(function(t){return""!==t})),Dr(t.attributes,function(e){var r;if((!tl(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&!(null==s?void 0:s.includes(e.name))&&!i&&al(e.value)&&(!O(r=e.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let t=e.value;"class"===e.name&&(t=Co(t).join(" ")),o["attr__"+e.name]=Dh(1024,"href"===e.name&&n?vi(t):t)}});let a=1,u=1,h=t;for(;h=Nh(h);)a++,h.tagName===t.tagName&&u++;return o.nth_child=a,o.nth_of_type=u,o}(t,s,n,r,l)),Dr(function(t){if(!Qo(t))return{};const i={};return Dr(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){const e=t.name.replace("data-ph-capture-attribute-",""),s=t.value;e&&s&&al(s)&&(i[e]=s)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(p,i)||(p[i]=t)})}),y)return{props:{},explicitNoCapture:y};if(v>0&&(i=h[v],f.splice(0,v)),n||(f[0].$el_text=ko(i,"a")||ko(i,"button")?ul(i):Io(i)),g){var b,w;f[0].attr__href=g;const i=null===(b=Al(g))||void 0===b?void 0:b.host,e=null==t||null===(w=t.location)||void 0===w?void 0:w.host;i&&e&&i!==e&&(_=g)}return{props:Nr((x=e.type,{$event_type:x,$ce_version:1}),o?{}:{$elements:f},{$elements_chain:(S=f,k(S)?function(t){return t.map(t=>{var i,e;let s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class){t.attr_class.sort();for(const i of t.attr_class)s+=`.${i.replace(/"/g,"")}`}const n=wi(wi(wi(wi({},t.text?{text:t.text}:{}),{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{}),t.attr_id?{attr_id:t.attr_id}:{}),t.attributes),r={};return jr(n).sort(([t],[i])=>function(t,i){return i>t?-1:t>i?1:0}(t,i)).forEach(([t,i])=>r[dl(t.toString())]=dl(i.toString())),s+=":",s+=jr(r).map(([t,i])=>`${t}="${i}"`).join(""),s}).join(";")}(function(t){return t.map(t=>{var i,e;const s={text:null===(i=t.$el_text)||void 0===i?void 0:i.slice(0,400),tag_name:t.tag_name,href:null===(e=t.attr__href)||void 0===e?void 0:e.slice(0,2048),attr_class:cl(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return jr(t).filter(([t])=>0===t.indexOf("attr__")).forEach(([t,i])=>s.attributes[t]=i),s})}(S)):"")},(null===(a=f[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(u=f[0])||void 0===u?void 0:u.$el_text}:{},_&&"click"===e.type?{$external_click_url:_}:{},p),target:i};var S,x}var Lh=class{tl(){this.el=void 0,clearTimeout(this.il),this.il=void 0}nl(t){var i;if(!Qo(t))return!0;const e=null!==(i=this.sl().css_selector_ignorelist)&&void 0!==i?i:Lo,s=new Set;let n=t;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const t=n,i=Oo(t);if(m(i,"ph-no-capture")||m(i,"ph-sensitive")||tl(t)||e.some(i=>Do(t,i)))return!0;const r=n.parentNode;n=Po(r)?r.host:r&&Eo(r)?r:null}return!1}rl(t){if(!this.isEnabled||"pointercancel"===t.type)return void this.tl();if("pointerdown"===t.type){this.tl();const e=Fo(t);var i;return void(t.isPrimary&&0===t.button&&!t.ctrlKey&&e&&Eo(e)&&(this.el={target:e,excluded:this.nl(e),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null===(i=this.xa)||void 0===i?void 0:i.distinctId}))}const e=this.el;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.tl():"pointerup"===t.type&&(e.released=!0,this.il=setTimeout(()=>this.tl(),0)))}ol(t){var i;const e=this.el;this.tl();const n=Fo(t);if((null==e?void 0:e.released)&&e.target.isConnected&&e.distinctId===(null===(i=this.xa)||void 0===i?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&n&&(ko(n,"html")||ko(n,"body"))){var r;if(e.excluded)return null;const t=null!==(r=this.sl().css_selector_ignorelist)&&void 0!==r?r:Lo;return[n,null==s?void 0:s.documentElement,null==s?void 0:s.body].some(i=>{if(!i)return!1;const e=Oo(i);return m(e,"ph-no-capture")||m(e,"ph-sensitive")||!Qo(i)||tl(i)||t.some(t=>Do(i,t))})?null:e.target}}constructor(t){this.Ta=t,this.name=lh,this.al=!1,this.ll=null,this.ul=!1,this.cl=new Map,this.hl=!1,this.Ar={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ci=!1,this.Ta.refresh(this.Ar),this.rageclicks=new Ih(this.Ar.rageclick),this.dl=null}setup(t){this.vl(),this.xa=t;const i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ci?i.dispose():(this.qa=i,this.startIfEnabled())}dispose(){var t;this.Ci||(this.Ci=!0,this.xa=void 0,null===(t=this.qa)||void 0===t||t.dispose(),this.qa=void 0,this.cl.clear(),this.dl=null,this.fl())}sl(){return this.Ta.refresh(this.Ar),this.Ar}vl(){var t,i;return this.sl(),this.Ar.url_allowlist=null===(t=this.Ar.url_allowlist)||void 0===t?void 0:t.map(t=>new RegExp(t)),this.Ar.url_ignorelist=null===(i=this.Ar.url_ignorelist)||void 0===i?void 0:i.map(t=>new RegExp(t)),this.Ar}pl(){if(!this.isBrowserSupported())return void Mh.info("Disabling Automatic Event Collection because this browser is not supported");if(!t||!s)return;const i=this.gl=i=>{i=i||(null==t?void 0:t.event);try{if("blur"===i.type)return void this.tl();if(0===i.type.indexOf("pointer"))return void this.rl(i);const t="click"===i.type?this.ol(i):void 0;if(I(t))return;this.ml(i,"$autocapture",t)}catch(t){Mh.error("Failed to capture event",t)}};if(qr(t,"blur",i),qr(s,"submit",i,{capture:!0}),qr(s,"change",i,{capture:!0}),qr(s,"click",i,{capture:!0}),Dr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{qr(s,t,i,{capture:!0})}),this.sl().capture_copied_text){const i=this.yl=i=>{i=i||(null==t?void 0:t.event);try{this.ml(i,Fh)}catch(t){Mh.error("Failed to capture clipboard event",t)}};qr(s,"copy",i,{capture:!0}),qr(s,"cut",i,{capture:!0}),qr(s,"paste",i,{capture:!0})}}fl(){this.tl(),this.gl&&(null==t||t.removeEventListener("blur",this.gl),Dr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==s||s.removeEventListener(t,this.gl,!0)}),null==s||s.removeEventListener("submit",this.gl,!0),null==s||s.removeEventListener("change",this.gl,!0),null==s||s.removeEventListener("click",this.gl,!0),this.gl=void 0),this.yl&&(null==s||s.removeEventListener("copy",this.yl,!0),null==s||s.removeEventListener("cut",this.yl,!0),null==s||s.removeEventListener("paste",this.yl,!0),this.yl=void 0),this.al=!1}startIfEnabled(){this.isEnabled||this.tl(),!this.Ci&&this.xa&&this.isEnabled&&!this.al&&(this.pl(),this.al=!0)}onRemoteConfig(t){if(this.Ci)return;if(this.ul=!0,!t.ok)return void this.startIfEnabled();const i=t.config;i.elementsChainAsString&&(this.hl=i.elementsChainAsString);const e=i.autocapture_opt_out;var s;N(e)&&(null===(s=this.xa)||void 0===s||s.kv.set("$autocapture_disabled_server_side",e),this.ll=e),this.startIfEnabled()}setElementSelectors(t,i=this){if(this.Ci)return;t.size?this.cl.set(i,new Set(t)):this.cl.delete(i);const e=new Set;this.cl.forEach(t=>{t.forEach(t=>e.add(t))}),this.dl=e}getElementSelectors(t,i){var e;const n=[];return null===(e=this.dl)||void 0===e||e.forEach(e=>{const r=null==s?void 0:s.querySelectorAll(e);null==r||r.forEach(s=>{t!==s&&i!==s||m(n,e)||n.push(e)})}),n}get isEnabled(){var t,i;if(this.Ci)return!1;const e=null===(t=this.xa)||void 0===t?void 0:t.kv.get(Pn),s=this.ll,n=this.sl();if(!n.remoteRequestsDisabled&&!this.ul)return!1;const r=n.remoteRequestsDisabled&&!this.ul;if(I(s)&&!N(e)&&!r)return!1;const o=null!==(i=this.ll)&&void 0!==i?i:!!e;return!!n.enabled&&!o}ml(i,e="$autocapture",s){if(!this.isEnabled)return void this.tl();let n=s||Fo(i);To(n)&&(n=n.parentNode||null);const r=this.vl();var o;"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent&&r.rageclick&&(null===(o=this.rageclicks)||void 0===o?void 0:o.isRageClick(i.clientX,i.clientY,i.timeStamp||(new Date).getTime()))&&Yo(n,r.rageclick)&&this.ml(i,"$rageclick",s);const l=e===Fh,a=l?wi(wi({},r),{},{dom_event_allowlist:void 0}):r;if(n&&function(t,i,e,s,n,r){var o;if(typeof window>"u"||Zo(t))return!1;if((null==e?void 0:e.url_allowlist)&&!Ro(e.url_allowlist,r))return!1;if((null==e?void 0:e.url_ignorelist)&&Ro(e.url_ignorelist,r))return!1;if(null==e?void 0:e.dom_event_allowlist){const t=e.dom_event_allowlist;if(t&&!t.some(t=>i.type===t))return!1}const{parentIsUsefulElement:l,targetElementList:a}=Xo(t,s);if(!function(t,i){const e=null==i?void 0:i.element_allowlist;if(R(e))return!0;for(const i of t)if(e.some(t=>i.tagName.toLowerCase()===t))return!0;return!1}(a,e))return!1;if(!No(a,null==e?void 0:e.css_selector_allowlist))return!1;if(No(a,null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:Lo))return!1;try{const e=window.getComputedStyle(t);if(e&&"pointer"===e.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}const u=t.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return l?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(Mo.indexOf(u)>-1||"true"===t.getAttribute("contenteditable"))}}(n,i,a,l,l?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var u;const{props:s,explicitNoCapture:o,target:l}=jh(n,{e:i,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.hl,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(o)return!1;const a=this.getElementSelectors(n,l);if(a&&a.length>0&&(s.$element_selectors=a),e===Fh){const e=i.type||"clipboard";if("paste"!==e){var h,d;const i=null==t||null===(h=t.getSelection())||void 0===h?void 0:h.toString(),e=Ao(i);if(!e)return!1;s.$selected_content=e,s.$clipboard_text_length=null!==(d=null==i?void 0:i.length)&&void 0!==d?d:0}s.$copy_type=e}return null===(u=this.xa)||void 0===u||u.capture(e,s),!0}}isBrowserSupported(){return T(null==s?void 0:s.querySelectorAll)}},Uh=class{constructor(t){this._instance=t}refresh(t){const i=this._instance.config,e=P(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.qu(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}};const Bh=Bs("[ExceptionAutocapture]"),zh=()=>{},Hh=t=>{var i;if(T(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function qh(t,i,e){try{if(!(i in t))return zh;const s={next:t[i]},n=e(function(...t){return s.next.apply(this,t)});return T(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),t[i]=n,()=>{if(t[i]===n)return void(t[i]=s.next);let e=t[i],r=Hh(e);for(;r;){if(r.next===n)return void(r.next=s.next);e=r.next,r=Hh(e)}}}catch(t){return zh}}const Vh=Bs("[TracingHeaders]"),Wh=Bs("[Web Vitals]"),Gh=9e5,Kh=["CLS","FCP","INP","LCP"],Jh=["INP","LCP"],Yh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Zh="disabled",Xh="lazy_loading",Qh=Bs("[SessionRecording]"),td=[gr,mr,yr,br,wr,$r,Sr,xr,Er],id=Bs("[Heatmaps]");function ed(t){return P(t)&&"clientX"in t&&"clientY"in t&&M(t.clientX)&&M(t.clientY)}const sd=Bs("[Product Tours]"),nd=t=>{var i;return!t.config.disable_product_tours&&!!(null===(i=t.persistence)||void 0===i?void 0:i.get_property(Mn))},rd=["$set_once","$set"],od=Bs("[SiteApps]"),ld="Error while initializing PostHog app with config id ";function ad(t,i,e){if(F(t))return!1;switch(e){case"exact":return t===i;case"contains":{const e=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(e,"i").test(t)}case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var ud=class{constructor(t){this.Ai=t,this._o=new Set,this.wo=new Set,this.ko=new Du,this.So=(t,i)=>this.xo(t,i)&&this.$o(t,i)&&this.Co(t,i)&&this.To(t,i),this.xo=(t,i)=>!(null==i?void 0:i.event)||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;R(null===(t=this.Ai)||void 0===t?void 0:t.subscribeCapture)||(this.Io=null===(i=this.Ai)||void 0===i?void 0:i.subscribeCapture((t,i)=>{this.on(t,i)}))}dispose(){var t,i,e;null===(t=this.Io)||void 0===t||t.call(this),this.Io=void 0,null===(i=this.Ai)||void 0===i||null===(e=i.setElementSelectors)||void 0===e||e.call(i,new Set,this),this.ko=new Du}register(t){var i,e;if(!R(null===(i=this.Ai)||void 0===i?void 0:i.subscribeCapture)&&(t.forEach(t=>{var i;this._o.add(t),null===(i=t.steps)||void 0===i||i.forEach(t=>{this.wo.add((null==t?void 0:t.event)||"")})}),null===(e=this.Ai)||void 0===e?void 0:e.setElementSelectors)){const t=new Set;this._o.forEach(i=>{var e;null===(e=i.steps)||void 0===e||e.forEach(i=>{(null==i?void 0:i.selector)&&t.add(i.selector)})}),this.Ai.setElementSelectors(t,this)}}replace(t){this._o.clear(),this.wo.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.wo.has(t)||this.wo.has(i.event))&&this._o.forEach(t=>{this.Mo(i,t)&&this.ko.emit("actionCaptured",t.name)})}Eo(t){this.onAction("actionCaptured",i=>t(i))}Mo(t,i){if(null==(null==i?void 0:i.steps))return!1;for(const e of i.steps)if(this.So(t,e))return!0;return!1}onAction(t,i){return this.ko.on(t,i)}$o(t,i){if(null==i?void 0:i.url){var e;const s=null==t||null===(e=t.properties)||void 0===e?void 0:e.$current_url;if(!s||"string"!=typeof s)return!1;if(!ad(s,i.url,i.url_matching||"contains"))return!1}return!0}Co(t,i){return!!this.Po(t,i)&&!!this.Ro(t,i)&&!!this.Ao(t,i)}Po(t,i){var e;if(!(null==i?void 0:i.href))return!0;const s=this.Fo(t);if(s.length>0)return s.some(t=>ad(t.href,i.href,i.href_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&ad(function(t){const i=t.match(/(?::|")href="(.*?)"/);return i?i[1]:""}(n),i.href,i.href_matching||"exact")}Ro(t,i){var e;if(!(null==i?void 0:i.text))return!0;const s=this.Fo(t);if(s.length>0)return s.some(t=>ad(t.text,i.text,i.text_matching||"exact")||ad(t.$el_text,i.text,i.text_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&(r=function(t){const i=[],e=/(?::|")text="(.*?)"/g;let s;for(;!F(s=e.exec(t));)i.includes(s[1])||i.push(s[1]);return i}(n),o=i.text,l=i.text_matching||"exact",r.some(t=>ad(t,o,l)));var r,o,l}Ao(t,i){var e,s;if(!(null==i?void 0:i.selector))return!0;const n=null==t||null===(e=t.properties)||void 0===e?void 0:e.$element_selectors;if(null==n?void 0:n.includes(i.selector))return!0;const r=(null==t||null===(s=t.properties)||void 0===s?void 0:s.$elements_chain)||"";if(i.selector_regex&&r)try{return new RegExp(i.selector_regex).test(r)}catch(t){}return!1}Fo(t){var i;return null==(null==t||null===(i=t.properties)||void 0===i?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}To(t,i){return!(null==i?void 0:i.properties)||0===i.properties.length||Gu(i.properties.reduce((t,i)=>{const e=k(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},hd=class{constructor(t,i){this.Oo=i,this.Do=[],this.Ai=t,this.Lo=new Map,this.No=new Map,this.qo=new Map}jo(){var t,i;this.Bo=null===(t=(i=this.Ai).subscribeSession)||void 0===t?void 0:t.call(i,t=>this.zo(t))}Ho(t){return!1}Uo(){return null}Wo(t){}Vo(){}Go(t,i){return!!t&&Gu(t.propertyFilters,null==i?void 0:i.properties)}Qo(t,i){const e=new Map;return t.forEach(t=>{var s;null===(s=t.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(i=>{if(null==i?void 0:i.name){const s=e.get(i.name)||[];s.push(t.id),e.set(i.name,s)}})}),e}Zo(t,i,e){const s=(e===ha.Activation?this.Lo:this.No).get(t);let n=[];return this.Jo(t=>{n=t.filter(t=>null==s?void 0:s.includes(t.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[e])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(i=>i.name===t);return this.Go(r,i)})}register(t){this.Ko(t,!1)}replace(t){this.Ko(t,!0)}Ko(t,i){R(this.Ai.subscribeCapture)||(this.Xo(t,i),this.Yo(t,i))}Yo(t,i){const e=t.filter(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length});var s;if(i&&this.qo.clear(),0===e.length)return void(i&&(null===(s=this.ta)||void 0===s||s.replace([])));this.ta||(this.ta=new ud(this.Ai),this.ta.init(),this.ta.Eo(t=>this.onAction(t)));const n=[];e.forEach(t=>{var i;null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||i.values.forEach(i=>{if(n.push(i),i.name){var e;const s=null!==(e=this.qo.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.qo.set(i.name,s)}})}),i?this.ta.replace(n):this.ta.register(n)}ea(t,i){i.forEach((i,e)=>{var s;const n=null!==(s=t.get(e))&&void 0!==s?s:[];i.forEach(t=>{n.includes(t)||n.push(t)}),t.set(e,n)})}Xo(t,i){var e,s,n;const r=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.events)&&(null===(e=t.conditions)||void 0===e||null===(e=e.events)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),o=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.cancelEvents)&&(null===(e=t.conditions)||void 0===e||null===(e=e.cancelEvents)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),l=this.Qo(t,ha.Activation),a=this.Qo(t,ha.Cancellation);i?(this.Lo=l,this.No=a):(this.ea(this.Lo,l),this.ea(this.No,a)),(0!==r.length||0!==o.length||t.some(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length}))&&(null!==(e=this.Io)&&void 0!==e||(this.Io=null===(s=(n=this.Ai).subscribeCapture)||void 0===s?void 0:s.call(n,(t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,s;const n=this.ia(),r=(null==i||null===(e=i.properties)||void 0===e?void 0:e.$survey_id)||(null==i||null===(s=i.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const e=this.na(t,r,i);if("consume"===e)return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.sa([r]);if("persist"===e)return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.ra(r),void this.oa([r])}if(this.No.has(t)){const e=this.Zo(t,i,ha.Cancellation);e.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:e.map(t=>t.id)}),this.sa(e.map(t=>t.id)),e.forEach(t=>this.aa(t.id)))}if(!this.Lo.has(t))return;n.info("event name matched",{event:t,eventPayload:i,items:this.Lo.get(t)});const o=this.Zo(t,i,ha.Activation);this.la(o.map(t=>t.id))}onAction(t){this.qo.has(t)&&this.la(this.qo.get(t)||[])}la(t){if(0===t.length)return;const i=!!this.Ai.getSessionId(),e=[];for(const s of t)i&&this.Ho(s)?this.ra(s)&&this.ua(s):e.push(s);e.length>0&&(this.Do=[...new Set([...this.Do,...e])]),this.ia().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.ca()}ra(t){this.Do=this.Do.filter(i=>i!==t);const i=this.ha();return!i.includes(t)&&(this.da([...i,t]),this.va(),!0)}sa(t){const i=new Set(t);this.Do=this.Do.filter(t=>!i.has(t));const e=this.fa(),s=e.filter(t=>!i.has(t));s.length!==e.length&&(this.da(s),0===s.length&&this.pa()),this.oa(t),this.ca()}ca(){try{var t;null===(t=this.Oo)||void 0===t||t.call(this)}catch(t){this.ia().error("Error while handling activated items change",t)}}ga(){const t=this.Uo();if(!t)return{};const i=this.Ai.getProperty(t);return i&&"object"==typeof i?i:{}}ua(t){if(!this.Uo())return;const i=this.ga();this.Wo(wi(wi({},i),{},{[t]:Date.now()}))}oa(t){if(!this.Uo())return;const i=this.ga(),e={};let s=!1;for(const[n,r]of Object.entries(i))t.includes(n)?s=!0:e[n]=r;s&&(C(e)?this.Vo():this.Wo(e))}ma(){this.Uo()&&this.Vo()}getActivationTimestamp(t){if(!this.ha().includes(t))return;const i=this.ga()[t];return M(i)?i:void 0}fa(){const t=this.ya();return this.Ai.getProperty(t)||[]}ha(){const t=this.fa();if(0===t.length)return[];const i=this.Ai.getProperty(this.ba()),e=this.Ai.getSessionId();return e&&i===e?t:[]}va(){const t=this.Ai.getSessionId();t&&this._a(t)}pa(){this.wa()}zo(t){const i=this.Ai.getProperty(this.ba());if(i&&i!==t){const t=this.fa(),i=this.ga();t.length>0&&(this.da([]),t.filter(t=>M(i[t])).forEach(t=>this.aa(t))),this.pa(),this.ma(),t.length>0&&this.ca()}}getActivatedIds(){return[...new Set([...this.ha(),...this.Do])].filter(t=>!this.ka(t))}dispose(){var t,i,e;null===(t=this.Bo)||void 0===t||t.call(this),this.Bo=void 0,null===(i=this.Io)||void 0===i||i.call(this),this.Io=void 0,null===(e=this.ta)||void 0===e||e.dispose(),this.ta=void 0}reset(){this.Do=[],this.fa().length>0&&this.da([]),this.pa(),this.ma(),this.ca()}getEventToItemsMap(){return this.Lo}Sa(){return this.ta}},dd=class extends hd{constructor(t,i,e){super({subscribeCapture(i){const e=t.onEvent(t=>i(t.event,t));return()=>e.dispose()},subscribeSession(i){const e=t.onSession(i);return()=>e.dispose()},getSessionId(){var i;return null===(i=t.session)||void 0===i?void 0:i.sessionId},getProperty:i=>t.kv.get(i),setElementSelectors(i,e){var s;return null===(s=t.getExtension("autocapture"))||void 0===s?void 0:s.setElementSelectors(i,e)}},e),this.xa=t,this.$a=i,this.jo()}ya(){return Zs}ba(){return Xs}Uo(){return Qs}Wo(t){this.xa.kv.set({[Qs]:t})}Vo(){this.xa.kv.remove(Qs)}Ho(t){var i;let e;this.Jo(i=>{e=i.find(i=>i.id===t)});const s=null==e||null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds;return M(s)&&s>0}Ca(){return ma.SHOWN}Jo(t){this.$a.getSurveys(t)}aa(t){this.$a.cancelPendingSurvey(t)}ia(){return th}da(t){this.xa.kv.set({[Zs]:t})}_a(t){this.xa.kv.set({[Xs]:t})}wa(){this.xa.kv.remove(Xs)}ka(){return!1}na(t,i,e){var s;if(t===ma.SENT&&!1===(null==e||null===(s=e.properties)||void 0===s?void 0:s.$survey_completed))return"ignore";let n;return this.Jo(t=>{n=t.find(t=>t.id===i)}),!n||function(t){var i;return Hu(t)&&!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i?void 0:i.repeatedActivation)||"always"===t.schedule}(n)?t===ma.SHOWN?"consume":"ignore":t===ma.SHOWN?"persist":t===ma.DISMISSED||t===ma.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const cd=(t,i)=>(null==t?void 0:t.then)?t.then(i):i(t),vd="SDK is not enabled or survey functionality is not yet loaded",fd="Disabled. Not loading surveys.";var pd=class{constructor(t){this.Ta=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Ia=!1,this.Ma=!1,this.Ea=[],this.Pa=[],this.Ra=null,this.Aa=null,this.Ci=!1,this.Fa=new Set,this.onRemoteConfig=t=>{if(this.Ci)return;if(this.Ar.disableSurveys)return;if(!t.ok)return this.Ma=!0,this.Oa({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),th.warn("Remote config unavailable. Not loading surveys.");const i=t.config.surveys;if(F(i))return th.warn("Flags not loaded yet. Not loading surveys.");this.Da=N(i)?i:i.length>0,th.info(`flags response received, isSurveysEnabled: ${this.Da}`),this.loadIfEnabled()},this.Oa=t=>{this.Pa.slice().forEach(i=>this.La(i,t))}}setup(t){if(!this.Ci)return this.Na=t,cd(t.kv.initialize(),()=>{if(this.Na!==t||this.Ci)return;this.Na=void 0,this.xa=t;const i=t.onRemoteConfig(this.onRemoteConfig);this.Ci?i.dispose():(this.qa=i,this.loadIfEnabled())})}dispose(){var t,i,e,s,n;this.Ci||(this.Ci=!0,this.Na=void 0,this.xa=void 0,null===(t=this.qa)||void 0===t||t.dispose(),this.qa=void 0,null===(i=this._surveyEventReceiver)||void 0===i||i.dispose(),this._surveyEventReceiver=null,null===(e=this._surveyManager)||void 0===e||null===(s=e.dispose)||void 0===s||s.call(e),this._surveyManager=null,this.Ea=[],this.Pa.forEach(t=>{t.active=!1}),this.Pa=[],null===(n=this.ja)||void 0===n||n.call(this),this.ja=void 0,this.Ra=null,this.Fa.forEach(t=>clearTimeout(t)),this.Fa.clear())}get Ar(){return this.Ta.get()}getRenderContext(){if(!this.xa)return;const t=this;return{client:this.xa,get config(){return t.Ar},surveys:t}}initialize(){this.loadIfEnabled()}reset(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.clearInMemoryInProgressSurveyState)||void 0===i||i.call(t);try{var e;null===(e=this._surveyEventReceiver)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let i=0;i<localStorage.length;i++){const e=localStorage.key(i);((null==e?void 0:e.startsWith("seenSurvey_"))||(null==e?void 0:e.startsWith("inProgressSurvey_")))&&t.push(e)}t.forEach(t=>localStorage.removeItem(t))}catch(t){}this.Oa()}loadIfEnabled(){if(this.Ci||!this.xa)return;const t=this.Ar;if(this._surveyManager)return;if(this.Ia)return void th.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void th.info(fd);if(t.cookielessMode&&this.xa.isOptedOut)return void th.info("Not loading surveys in cookieless mode without consent.");const i=this.Ta.getExtensions();if(!i)return void this.Ba("PostHog Extensions not found.");if(R(this.Da)&&!t.advancedEnableSurveys)return;const e=this.Da||t.advancedEnableSurveys;this.Ia=!0,this.Ma=!1;try{const t=i.generateSurveys;if(t)return this.za(t,e),void(this.Ia=!1);const s=i.loadExternalDependency;if(!s)return this.Ba(Ys),void(this.Ia=!1);s(t=>{try{if(this.Ci)return;const i=this.Ta.getExtensions();t||!(null==i?void 0:i.generateSurveys)?this.Ba("Could not load surveys script",t):this.za(i.generateSurveys,e)}finally{this.Ia=!1}})}catch(t){throw this.Ia=!1,this.Ba("Error initializing surveys",t),t}}za(t,i){var e;if(this.Ci)return;this._surveyManager=t(i),this._surveyEventReceiver=new dd(this.xa,this,this.Oa);const s=null===(e=this.xa)||void 0===e?void 0:e.kv.get(Ks);s&&this.Ha(s),th.info("Surveys loaded successfully"),this.Ua(),this.Oa(),this.Wa({isLoaded:!0})}Ba(t,i){this.Ma=!0,th.error(t,i),this.Oa({isLoaded:!1,error:t}),this.Wa({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ea.push(t),this._surveyManager&&this.Wa({isLoaded:!0}),()=>{this.Ea=this.Ea.filter(i=>i!==t)}}getSurveys(t,i=!1){if(this.Ci)return;const e=this.xa;if(!e)return t([],{isLoaded:!1,error:vd});if(this.Ar.disableSurveys)return th.info(fd),t([]);const s=e.kv.get(Ks);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Va()&&this.getSurveys(()=>{},!0));if(this.Ra)return void this.Ra.then(({surveys:i,context:e})=>{this.Ci||t(i,e)}).catch(t=>th.error("Error in survey callback",t));const n=e.sendRequest("/api/surveys/",{method:"GET",query:{token:e.projectToken},sentAt:"query",timeoutMs:this.Ar.requestTimeoutMs}).then(t=>{try{return this.Ga(e,t)}catch(t){return th.error("Error processing surveys response",t),this.Ga(e,{statusCode:0,error:t})}},t=>this.Ga(e,{statusCode:0,error:t}));this.Ra=n;const r=()=>{this.Ra===n&&(this.Ra=null)};n.then(i=>{r(),this.Ci||(this.Oa(i.context),t(i.surveys,i.context))},r).catch(t=>th.error("Error in survey callback",t))}Ga(t,i){if(this.Ci)return{surveys:[],context:{isLoaded:!1,error:vd}};const e=i.statusCode;if(200!==e||!i.json){const t=`Surveys API could not be loaded, status: ${e}`;return 0!==e?th.error(t):i.error||th.warn(t),this.Aa=Date.now(),{surveys:[],context:{isLoaded:!1,error:t}}}this.Aa=null;const s=i.json.surveys||[];return t.kv.set({[Ks]:s,[Js]:Date.now()}),this.Ha(s),{surveys:s,context:{isLoaded:!0}}}Ha(t){var i;const e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Hu(t)||function(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}(t)));null===(i=this._surveyEventReceiver)||void 0===i||i.replace(e)}Va(){return this.Qa()&&!this.Ra&&!this.Za()}Qa(){var t;const i=null===(t=this.xa)||void 0===t?void 0:t.kv.get(Js);return M(i)&&Date.now()-i>3e5}Za(){return M(this.Aa)&&3e5>Date.now()-this.Aa}markSurveyAsSeen(t,i){var e;const s={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};ih(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Oa()}Wa(t){for(const i of this.Ea){if(this.Ci)return;try{t.isLoaded?this.getSurveys(i):i([],t)}catch(t){th.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,i=!1){if(!F(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);th.warn("init was not called")}onActiveMatchingSurveysChanged(t){var i;if(this.Ci)return()=>{};const e={callback:t,active:!0,revision:0};this.Pa.push(e),this.Ua();const s=null===(i=this.xa)||void 0===i?void 0:i.kv.get(Ks);return this.Ar.disableSurveys||!this._surveyManager&&this.Ma&&!this.Ia||!s&&!F(this.Aa)&&!this.Ra?this.La(e,{isLoaded:!1}):this._surveyManager&&this.La(e),()=>{var t;e.active=!1,this.Pa=this.Pa.filter(t=>t!==e),0===this.Pa.length&&(null===(t=this.ja)||void 0===t||t.call(this),this.ja=void 0)}}Ua(){var t,i,e;this._surveyManager&&this.Pa.length>0&&(null!==(t=this.ja)&&void 0!==t||(this.ja=null===(i=(e=this.Ta).onMatchingConditionsChanged)||void 0===i?void 0:i.call(e,this.Oa)))}La(t,i){if(this.Ci||!t.active)return;const e=++t.revision,s=s=>{if(!this.Ci&&t.active&&e===t.revision)try{const e=null!=i?i:{isLoaded:!0},n=JSON.stringify([s,e]);if(n===t.lastResult)return;t.lastResult=n,t.callback(s,e)}catch(t){th.error("Error in active matching surveys callback",t)}};try{i&&!i.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(t){th.error("Error in active matching surveys callback",t)}}Ja(t){let i=null;return this.getSurveys(e=>{var s;i=null!==(s=e.find(i=>i.id===t))&&void 0!==s?s:null}),i}Ka(t){if(F(this._surveyManager))return{eligible:!1,reason:vd};const i="string"==typeof t?this.Ja(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Xa(t){var i;if(!(null===(i=this.xa)||void 0===i?void 0:i.canCapture))return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(F(this._surveyManager))return{eligible:!1,reason:vd};const e="string"==typeof t?this.Ja(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(F(this._surveyManager))return th.warn("init was not called"),{visible:!1,disabledReason:vd};const i=this.Xa(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return F(this._surveyManager)?(th.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:vd})):new Promise(e=>{this.getSurveys(i=>{var s;const n=null!==(s=i.find(i=>i.id===t))&&void 0!==s?s:null;if(n){const t=this.Xa(n);e({visible:t.eligible,disabledReason:t.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var s,n,r;if(!(null===(s=this.xa)||void 0===s?void 0:s.canCapture))return;if(F(this._surveyManager))return void th.warn("init was not called");const o="string"==typeof t?this.Ja(t):t;if(!(null==o?void 0:o.id))return void th.warn("Survey not found");if(!eh.includes(o.type))return void th.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const l=null===(n=typeof document>"u"?void 0:document)||void 0===n?void 0:n.querySelector(i);if(l){if(null===(r=o.appearance)||void 0===r?void 0:r.surveyPopupDelaySeconds){th.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const t=setTimeout(()=>{var i,s,n;this.Fa.delete(t),!this.Ci&&(null===(i=this.xa)||void 0===i?void 0:i.canCapture)&&(th.info(`Rendering survey ${o.id} with delay of ${null===(s=o.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds} seconds`),null===(n=this._surveyManager)||void 0===n||n.renderSurvey(o,l,e),th.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this.Fa.add(t)}this._surveyManager.renderSurvey(o,l,e)}else th.warn("Survey element not found")}displaySurvey(t,i){var e,s;if(!(null===(e=this.xa)||void 0===e?void 0:e.canCapture))return;if(F(this._surveyManager))return void th.warn("init was not called");const n=this.Ja(t);if(!n)return void th.warn("Survey not found");let r=n;if((null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds)&&i.ignoreDelay&&(r=wi(wi({},n),{},{appearance:wi(wi({},n.appearance),{},{surveyPopupDelaySeconds:0})})),i.displayType!==ba.Popover&&i.initialResponses&&th.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){const t=this.Ka(n);if(!t.eligible)return void th.warn("Survey is not eligible to be displayed: ",t.reason)}i.displayType!==ba.Inline?this._surveyManager.handlePopoverSurvey(r,i):this.renderSurvey(r,i.selector,i.properties)}cancelPendingSurvey(t){F(this._surveyManager)?th.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t)}},_d=class{constructor(t){this._instance=t}get(){var t,i,e,s;const n=null===(t=this._instance)||void 0===t?void 0:t.config;return{disableSurveys:!!(null==n?void 0:n.disable_surveys),cookielessMode:!!(null==n?void 0:n.cookieless_mode),advancedEnableSurveys:!!(null==n?void 0:n.advanced_enable_surveys),requestTimeoutMs:null!==(i=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==i?i:1e4,prefillFromUrl:!!(null==n||null===(e=n.surveys)||void 0===e?void 0:e.prefillFromUrl),automaticDisplay:!(null==n?void 0:n.disable_surveys_automatic_display),featureFlagEvaluation:!(null==n?void 0:n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null===(s=this._instance)||void 0===s||null===(s=s.requestRouter)||void 0===s?void 0:s.endpointFor("ui","")}}getExtensions(){const t=null==d?void 0:d.__PosthogExtensions__;if(!t||!this._instance)return;const i=this._instance,{generateSurveys:e,loadExternalDependency:s}=t;return{generateSurveys:e?t=>e(i,t):void 0,loadExternalDependency:s?t=>s(i,"surveys",t):void 0}}onMatchingConditionsChanged(i){var e,s;const n=null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook(t=>{"$pageview"!==t&&t!==ma.SHOWN&&t!==ma.DISMISSED&&t!==ma.SENT||i()}),r=()=>i();qr(t,"PHSurveyShown",r);let o=!1;const l=null===(s=this._instance)||void 0===s?void 0:s.onFeatureFlags(()=>{o&&i()});return o=!0,()=>{o=!1,null==n||n(),null==l||l(),null==t||t.removeEventListener("PHSurveyShown",r)}}};const gd=(null==t?void 0:t.location)?Ml(t.location.hash,"__posthog")||Ml(location.hash,"state"):null,md="_postHogToolbarParams",yd=Bs("[Toolbar]"),bd=Bs("[FeatureFlags]"),wd=Bs("[FeatureFlags]",{debugEnabled:!0}),$d="\" failed. Feature flags didn't load in time.",Sd=[502,504],xd=["click","keydown","wheel","touchstart","pointerdown"],Ed="connection_error",kd=t=>{const i={};for(let e=0;t.length>e;e++)i[t[e]]=!0;return i},Td=t=>{const i={};for(const[e,s]of jr(t||{}))s&&(i[e]=s);return i};var Pd=class{constructor(t){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.$=bd,this.ld={},this.ud={},this.hd=[],this.dd=new Set,this.vd=new Set,this.fd=!1,this.pd=!1,this.gd=0,this.md=!1,this.yd=!1,this.bd=!1,this._d=!1,this.wd=!1,this.kd=0,this.Sd=!1,this.rn=()=>{const t=this.xd();this.kd=0,t&&this.reloadFeatureFlags()},this.$d=()=>{var t,i;const e=this.Cd,s=null!==(t=this.Td)&&void 0!==t?t:e;R(e)||R(s)||this.Ar.remoteRequestsDisabled||!this.Id||"hidden"===this.Id.visibilityState||Date.now()-(null!==(i=this.Md)&&void 0!==i?i:0)<s||(this.Td=this.Sd||!this.Ar.idleRefreshBackoff?e:Math.min(2*s,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Ed())},this.Pd=()=>{this.Sd&&this.Td===this.Cd||this.Rd()},this.sn=()=>{var t;"visible"===(null===(t=this.Id)||void 0===t?void 0:t.visibilityState)&&this.Rd()},this.Ta=t}get Ad(){}Fd(){this.xa&&this.Od()}setup(t){try{this.Dd=typeof window>"u"?void 0:window,this.Id=typeof document>"u"?void 0:document}catch(t){this.Dd=void 0,this.Id=void 0}return this.Na=t,this.$=t.logger.createLogger("[FeatureFlags]"),cd(t.kv.initialize(),()=>{this.Na===t&&(this.Na=void 0,this.xa=t,this.Ld(t))})}Ld(t){var i;if(this.xa===t)return this.Dd&&qr(this.Dd,"online",this.rn),this.Od(),this.Nd=t.registerDynamicEventProperties(()=>this.qd()?this.ld:this.ud),this.jd=null===(i=this.Ad)||void 0===i?void 0:i.onCrossTabFeatureFlagChange(()=>{this.Bd(),this.zd(),this.Hd()}),this.zd(),this.initialize()}Rd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Od(){var t;const i=this.Ar.refreshIntervalMs,e=!this.Ar.remoteRequestsDisabled&&this.Id&&!R(i)&&i>0?i:void 0;this.Ar.idleRefreshBackoff||(this.Td=e),e!==this.Cd&&(this.Ud(),R(e)||(this.Cd=e,this.Td=e,this.Ed(),(null===(t=this.Id)||void 0===t?void 0:t.addEventListener)&&(qr(this.Id,_n,this.sn),Mr(xd,t=>{qr(this.Id,t,this.Pd,{capture:!0})}))))}Ed(){R(this.Cd)||(R(this.Wd)||clearInterval(this.Wd),this.Md=Date.now(),this.Wd=setInterval(this.$d,this.Cd))}Ud(){var t,i;R(this.Wd)||(clearInterval(this.Wd),this.Wd=void 0,null===(t=this.Id)||void 0===t||null===(i=t.removeEventListener)||void 0===i||i.call(t,"visibilitychange",this.sn),Mr(xd,t=>{var i,e;null===(i=this.Id)||void 0===i||null===(e=i.removeEventListener)||void 0===e||e.call(i,t,this.Pd,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Md=void 0}destroy(){this.Vd()}dispose(){this.Vd()}Vd(){var t,i,e;this.Ud(),this.gd++,this.yd=!1,this.Na=void 0,this.Gd(this.dd,"cancelled"),this.Gd(this.vd,"cancelled"),this.xa&&(this.Qd(),null===(t=this.Nd)||void 0===t||t.dispose(),this.Nd=void 0,null===(i=this.jd)||void 0===i||i.call(this),this.jd=void 0,this.hd=[],null===(e=this.Dd)||void 0===e||e.removeEventListener("online",this.rn),this.xa=void 0)}get Ar(){return this.Ta.get()}Zd(t){var i;return this.Jd&&t in this.Jd?this.Jd[t]:null===(i=this.xa)||void 0===i?void 0:i.kv.get(t)}Bd(){return!!this.Jd&&(this.Jd=void 0,!0)}Kd(){var t;return!R(null===(t=this.xa)||void 0===t?void 0:t.kv.get("$enabled_feature_flags"))&&this.Bd()}At(t){this.Xd(()=>{var i;return null===(i=this.xa)||void 0===i?void 0:i.kv.set(t)})}Yd(t,i,e){if(!this.Ad||!t.$enabled_feature_flags)return;const s=this.Zd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},r=i.flags||i.featureFlags,o=i.flags?Object.entries(i.flags).filter(([,t])=>!(null==t?void 0:t.failed)).map(([t])=>t):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,a=l?o:e&&!k(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),u=this.Zd("$feature_flag_payloads")||{},h=t.$feature_flag_payloads||{},d=l||e?a:Array.from(new Set([...Object.keys(u),...Object.keys(h)])),c=!l&&!e,v=!!c||a,f=!!c||d,p={[en]:v,[an]:v,[vn]:f};t.$feature_flag_details&&(p[sn]=v);for(const i of[on,rn,ln])R(t[i])||(p[i]=!0);this.Ad.markCrossTabFeatureFlagChanges(p)}Pt(t){this.Xd(()=>{var i;return null===(i=this.xa)||void 0===i?void 0:i.kv.remove(t)})}Xd(t){try{t()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}zd(){const t={};for(const i of[en,vn,on,fn]){const e=this.Zd(i);R(e)||(t[i]=e)}this.ld=t;const i=wi({},t),e=this.Zd(an);if(e)for(const[t,s]of Object.entries(e))i[`$feature/${t}`]=s;this.ud=i}qd(){const t=this.Ar.cacheTtlMs;if(!t||0>=t)return!1;const i=this.Zd(rn);return"number"!=typeof i||Date.now()-i>t}tv(){return!!this.qd()&&(this.wd||this.pd||(this.wd=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ev(){const t=this.Ar.evaluationContexts;return(null==t?void 0:t.length)?t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}iv(){const t=this.Ar.flagKeys;if(!R(t))return t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i;const e=this.Ar,s=null!==(t=null===(i=e.bootstrap)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(s).length){var n,r;const t=null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},i=Object.keys(s).filter(t=>!R(s[t])).reduce((t,i)=>(t[i]=s[i],t),{}),o=Object.keys(t).filter(t=>i[t]).reduce((i,e)=>(i[e]=t[e],i),{});return this.nv({featureFlags:i,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n;const r=(null==e?void 0:e.merge)&&null!==(s=this.Zd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==e?void 0:e.merge)&&null!==(n=this.Zd("$feature_flag_payloads"))&&void 0!==n?n:{},l=wi(wi({},r),t),a=wi(wi({},o),i),u={};for(const[t,i]of Object.entries(l))u[t]={key:t,enabled:fe(i),variant:pe(i),reason:void 0,metadata:R(null==a?void 0:a[t])?void 0:{id:0,version:void 0,description:void 0,payload:a[t]}};this.nv({flags:u})}get hasLoadedFlags(){return this.fd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.Zd(sn),i=this.Zd(fn),e=this.Zd(pn);if(!e&&!i)return t||{};const s=Nr({},t||{}),n=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(const t of n){var r,o;const n=s[t],l=null==i?void 0:i[t],a=R(l)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!l,u=R(l)?null==n?void 0:n.variant:"string"==typeof l?l:void 0,h=null==e?void 0:e[t],d=wi(wi({},n),{},{enabled:a,variant:a?null!=u?u:null==n?void 0:n.variant:void 0});a!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),u!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),h&&(d.metadata=wi(wi({},null==n?void 0:n.metadata),{},{payload:h,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[t]=d}return this.ad||(this.$.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.ad=!0),s}getAllFeatureFlags(){const t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{const s=t[e];return{key:e,enabled:fe(s),variant:pe(s),payload:ve(i[e])}})}getFlagVariants(){const t=this.Zd(an),i=this.Zd(fn);if(!i)return t||{};const e=Nr({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ad||(this.$.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.ad=!0),e}getFlagPayloads(){const t=this.Zd(vn),i=this.Zd(pn);if(!i)return t||{};const e=Nr({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.ad||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.ad=!0),e}reloadFeatureFlags(){this.md||this.Ar.featureFlagsDisabled||this.xd()||(this.bd&&this.$.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this.pd&&(this.yd=!0),this.sv||(this.hd.slice().forEach(t=>{try{t()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.sv=setTimeout(()=>{this.rv()},5)))}reloadFeatureFlagsAsync(){return!this.xa||this.md||this.Ar.featureFlagsDisabled||this.Ar.remoteRequestsDisabled||this.xd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.dd.add(t),this.reloadFeatureFlags()})}Gd(t,i){t.forEach(t=>t({status:i})),t.clear()}Qd(){clearTimeout(this.sv),this.sv=void 0}onReloading(t){return this.hd.push(t),()=>{this.hd=this.hd.filter(i=>i!==t)}}ensureFlagsLoaded(){this.fd||this.pd||this.sv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.md=t}resetFlagCallReported(){this.Pt(dn)}rv(t){var i;this.Qd();const e=this.xa;if(!e||this.Ar.remoteRequestsDisabled||this.xd())return void this.Gd(this.dd,"skipped");if(this.pd)return void(this.yd=!0);const s={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:wi(wi(wi({},e.initialPersonProperties),this.Zd("$stored_person_properties")||{}),{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Zd(un),timezone:Tl()};R(e.deviceId)||(s.$device_id=e.deviceId),((null==t?void 0:t.disableFlags)||this.Ar.featureFlagsDisabled)&&(s.disable_flags=!0);const n=this.ev();n.length&&(s.evaluation_contexts=n);const r=this.iv();R(r)||(s.flag_keys=r);const o=this.Ar.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),a=this.gd,u=this.dd;this.dd=new Set,this.vd=u,this.pd=!0;const h=()=>{this.yd&&(this.yd=!1,this.rv())},d=t=>{var i,e;const n=null!==(i=t.json)&&void 0!==i?i:{},r=200!==t.statusCode;if(this.pd=!1,a!==this.gd)return void h();if(this.ov(t.statusCode),r||this.yd||(this.$anon_distinct_id=void 0),s.disable_flags&&!this.yd)return void this.Gd(u,"skipped");this._d=!r;const l=[];t.error?l.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ed:"unknown_error"):200!==t.statusCode&&l.push(`api_error_${t.statusCode}`),n.errorsWhileComputingFlags&&l.push("errors_while_computing_flags");const d=!!(null===(e=n.quotaLimited)||void 0===e?void 0:e.includes("feature_flags"));d&&l.push("quota_limited"),this.At({[nn]:l}),d?this.$.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):s.disable_flags||this.nv(n,r,{partialResponse:o}),this.Gd(u,s.disable_flags?"skipped":l.length||!n.flags&&!n.featureFlags?"error":"loaded"),h()},c=t=>{this.pd=!1,a===this.gd?(this.At({[nn]:[Ed]}),this.$.error("Feature flag request failed",t),this.Kd()&&this.Hd(!0),this.Gd(u,"error"),h()):h()};let v=null!==(i=this.Ar.requestMaxRetries)&&void 0!==i?i:1;const f=()=>v>0&&a===this.gd,p=()=>{if(a!==this.gd||!this.xa||this.Ar.remoteRequestsDisabled)return this.pd=!1,this.Gd(u,"skipped"),void h();try{e.sendRequest(l,{target:"flags",method:"POST",body:s,compression:this.Ar.compression,sentAt:"body",timeoutMs:this.Ar.requestTimeoutMs}).then(t=>{if((t=>Sd.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&f())return v--,void setTimeout(p,500);d(t)}).catch(c)}catch(t){c(t)}};p()}xd(){return Cl(this.kd,3)}ov(t){this.kd=Rl(t,this.kd,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i={}){var e;if(i.fresh&&!this._d)return;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+t+$d);if(this.tv())return;const s=this.getFeatureFlagResult(t,i);return null!==(e=null==s?void 0:s.variant)&&void 0!==e?e:null==s?void 0:s.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i={}){if(i.fresh&&!this._d)return;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+t+$d);if(this.tv())return;const e=this.getFlagVariants(),s=t in e,n=e[t],r=this.getFlagPayloads()[t],o=String(n),l=this.Zd("$feature_flag_request_id")||void 0,a=this.Zd("$feature_flag_evaluated_at")||void 0;let u,h=this.Zd("$flag_call_reported")||{};if(this.Ar.deduplicateCallsPerSession){var d;const t=null===(d=this.xa)||void 0===d||null===(d=d.session)||void 0===d?void 0:d.sessionId,i=this.Zd(cn);t&&t!==i&&(h={},u=t)}if(!i.send_event&&"send_event"in i)u&&this.At({[dn]:h,[cn]:u});else{var c,v;const i=null===(c=this.xa)||void 0===c?void 0:c.canCapture;if(!i&&Object.keys(h).length>0&&(h={},this.At({[dn]:h})),i&&!(null===(v=h[t])||void 0===v?void 0:v.includes(o))){var f,p,_,g,m,y,b,w,S,x,E,T,P;k(h[t])?h[t].push(o):h[t]=[o],this.At(wi({[dn]:h},u?{[cn]:u}:{}));const i=this.getFeatureFlagDetails(t),e=[...null!==(f=this.Zd("$feature_flag_errors"))&&void 0!==f?f:[]];R(n)&&e.push("flag_missing");const s={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:null!==(p=null===(_=this.Ar.bootstrap)||void 0===_||null===(_=_.featureFlags)||void 0===_?void 0:_[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(g=null===(m=this.Ar.bootstrap)||void 0===m||null===(m=m.featureFlagPayloads)||void 0===m?void 0:m[t])&&void 0!==g?g:null,$used_bootstrap_value:!this._d};R(null==i||null===(y=i.metadata)||void 0===y?void 0:y.has_experiment)||(s.$feature_flag_has_experiment=i.metadata.has_experiment),R(null==i||null===(b=i.metadata)||void 0===b?void 0:b.version)||(s.$feature_flag_version=i.metadata.version);const d=null!==(w=null==i||null===(S=i.reason)||void 0===S?void 0:S.description)&&void 0!==w?w:null==i||null===(x=i.reason)||void 0===x?void 0:x.code;d&&(s.$feature_flag_reason=d),(null==i||null===(E=i.metadata)||void 0===E?void 0:E.id)&&(s.$feature_flag_id=i.metadata.id),R(null==i?void 0:i.original_variant)&&R(null==i?void 0:i.original_enabled)||(s.$feature_flag_original_response=R(i.original_variant)?i.original_enabled:i.original_variant),(null==i||null===(T=i.metadata)||void 0===T?void 0:T.original_payload)&&(s.$feature_flag_original_payload=null==i||null===(P=i.metadata)||void 0===P?void 0:P.original_payload),e.length&&(s.$feature_flag_error=e.join(",")),this.av(s)}else u&&this.At({[dn]:h,[cn]:u})}return s?{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:ve(r)}:void 0}av(t){try{var i;null===(i=this.xa)||void 0===i||i.capture("$feature_flag_called",t)}catch(t){this.$.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.lv(t,i)}lv(t,i){var e=this;return J(function*(){const s=e.xa;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=e.ev();r.length&&(n.evaluation_contexts=r);const o=e.iv();let l;R(o)||(n.flag_keys=o);try{var a;const i=null===(a=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:e.Ar.compression,sentAt:"body",timeoutMs:e.Ar.requestTimeoutMs})).json)||void 0===a?void 0:a.featureFlagPayloads;l=(null==i?void 0:i[t])||void 0}catch(t){return void e.$.error("Remote config feature flag request failed",t)}try{i(l)}catch(t){e.$.error("Remote config feature flag callback failed",t)}})()}isFeatureEnabled(t,i={}){if(i.fresh&&!this._d)return i.defaultValue;if(!(this.fd||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+t+$d),i.defaultValue;const e=this.getFeatureFlag(t,i);return R(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.nv(t,i,e)}nv(t,i,e){if(!this.xa)return;this.fd=!0;const s=((t,i={},e={},s={},n,r=bd)=>{const o=((t,i)=>{const e=t.flags;if(e){const i=Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),s=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!R(null===(i=e[t].metadata)||void 0===i?void 0:i.payload)}).map(t=>{var i;return[t,null===(i=e[t].metadata)||void 0===i?void 0:i.payload]}));return wi(wi({},t),{},{featureFlags:i,featureFlagPayloads:s})}return t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t,r),l=o.flags,a=o.featureFlags,u=o.featureFlagPayloads;if(!a)return;const h=t.requestId,d=t.evaluatedAt;if(k(a)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const t={};if(a)for(let i=0;a.length>i;i++)t[a[i]]=!0;return{[en]:a,[an]:t,[ln]:!1}}let c=a,v=u,f=l;if(null==n?void 0:n.partialResponse){const t=Object.keys(c),n=v||{};c=wi(wi({},i),c),v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),f)}else if(t.errorsWhileComputingFlags)if(l){const t=new Set(Object.keys(l).filter(t=>{var i;return!(null===(i=l[t])||void 0===i?void 0:i.failed)}));c=wi(wi({},i),Object.fromEntries(Object.entries(c).filter(([i])=>t.has(i))));const n=Object.fromEntries(Object.entries(v||{}).filter(([i])=>t.has(i)));v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),Object.fromEntries(Object.entries(f||{}).filter(([i])=>t.has(i))))}else c=wi(wi({},i),c),v=wi(wi({},e),v),f=wi(wi({},s),f);return wi(wi({[en]:Object.keys(Td(c)),[an]:c||{},[vn]:v||{},[sn]:f||{},[ln]:!0===t.minimalFlagCalledEvents},h?{[on]:h}:{}),d?{[rn]:d}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.$);if(s)if(!1===(null==e?void 0:e.persist)){const t=!R(this.xa.kv.get(an));this.Jd=s,t||this.At(s)}else this.Bd(),this.Yd(s,t,!!(null==e?void 0:e.partialResponse)),this.At(s);else i&&this.Kd();i||(this.wd=!1),this.Hd(i)}override(t,i=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.uv(t)}uv(t){if(this.xa){if(!1===t)return this.Pt([fn,pn]),this.Hd(),void wd.info("All overrides cleared");if(k(t))return this.At({[fn]:kd(t)}),this.Hd(),void wd.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i;const e=t;this.ad=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);const s={},n=e.flags,r=e.payloads;return n&&(s[fn]=k(n)?kd(n):n),r&&(s[pn]=r),Object.keys(s).length&&this.At(s),!1===n&&!1===r?this.Pt([fn,pn]):!1===n?this.Pt(fn):!1===r&&this.Pt(pn),this.Hd(),!1===n?wd.info("Flag overrides cleared"):n&&wd.info("Flag overrides set",{flags:n}),void(!1===r?wd.info("Payload overrides cleared"):r&&wd.info("Payload overrides set",{payloads:r}))}if(t&&"object"==typeof t)return this.At({[fn]:t}),this.Hd(),void wd.info("Flag overrides set",{flags:t});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.fd){const{flags:i,flagVariants:e}=this.hv();try{t(i,e)}catch(t){this.$.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;const n=(this.Zd("$early_access_features")||[]).find(i=>i.flagKey===t),r={[`$feature_enrollment/${t}`]:i},o={$feature_flag:t,$feature_enrollment:i,$set:r};n&&(o.$early_access_feature_name=n.name),e&&(o.$feature_enrollment_stage=e);const l=wi(wi({},this.getFlagVariants()),{},{[t]:i});null===(s=this.Ad)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.At({[en]:Object.keys(Td(l)),[an]:l,[hn]:wi(wi({},this.Zd("$stored_person_properties")||{}),r)}),this.Hd();try{var a;null===(a=this.xa)||void 0===a||a.capture("$feature_enrollment_update",o)}catch(t){this.$.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i=!1,e){const s=this.Zd(tn);!s||i?this.dv(t,e):t(s)}dv(t,i){var e=this;return J(function*(){const s=e.xa;if(!s)return;const n=i?`&${i.map(t=>`stage=${t}`).join("&")}`:"";let r;try{const t=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!t.json)return;r=t.json.earlyAccessFeatures,e.At({[tn]:r})}catch(t){return void e.$.error("Early access feature request failed",t)}try{t(r)}catch(t){e.$.error("Early access feature callback failed",t)}})()}hv(){const t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}Hd(t){this.zd();const{flags:i,flagVariants:e}=this.hv(),s=this.bd;this.bd=!0,this.featureFlagEventHandlers.forEach(s=>{try{s(i,e,{errorsLoading:t})}catch(t){this.$.error("Error while running feature flags callback",t)}}),this.bd=s}setPersonPropertiesForFlags(t,i=!0){this.vv(t,i)}vv(t,i=!0){const e=this.Zd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||((null==t?void 0:t.$set_once)?{}:t),n=null==t?void 0:t.$set_once,r={};if(n)for(const t in n)({}).hasOwnProperty.call(n,t)&&(t in e||(r[t]=n[t]));this.At({[hn]:wi(wi(wi({},e),r),s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i=!0){const e=wi({},this.Zd("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.At({[hn]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Pt(hn),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i=!0){const e=this.Zd("$stored_group_properties")||{},s=wi({},e);for(const i of Object.keys(t))s[i]=wi(wi({},e[i]),t[i]);this.At({[un]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const i=this.Zd("$stored_group_properties")||{};this.At({[un]:wi(wi({},i),{},{[t]:{}})})}else this.Pt(un)}reset(){this.gd++,this.Gd(this.dd,"cancelled"),this.Gd(this.vd,"cancelled"),this.yd=!1,this.ld={},this.ud={},this.Jd=void 0,this.fd=!1,this.md=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Qd(),this.ad=!1,this.kd=0}};const Cd=Bs("[FeatureFlags]");var Rd=class{constructor(t,i=!1){this.fv=!1,this.update(t,i)}update(t,i){this.pv=((t,i)=>{var e,s,n,r,o,l,a,u;return{bootstrap:{featureFlags:null!==(e=null===(s=t.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(n=null===(r=t.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=t.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:R(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(l=t.feature_flag_request_max_retries)&&void 0!==l?l:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(u=t.evaluation_contexts)&&void 0!==u?u:t.evaluation_environments)&&void 0!==a?a:[],flagKeys:k(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.fv||(Cd.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.fv=!0),R(t.flag_keys)||k(t.flag_keys)||Cd.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.pv}};const Od=t=>z(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Ad=Bs("[Error tracking]"),Id="webkit-masked-url:",Fd=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Md=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Id],Dd=["__firefox__","__gCrWeb"],Nd="Refusing to render web experiment since the viewer is a likely bot",jd={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>qu(i,t),not_regex:(t,i)=>!qu(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},Ld=Bs("[Conversations]"),Ud="Conversations not available yet.";function Bd(t,i){var e,s,n,r,o,l,a;const u=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,h=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=(null==i?void 0:i.consoleCapture)?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=R(d)?Math.max(h,2048):Math.max(h,d),v=wi(wi({},function(){let t="",i="";try{var e;const s="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,n=null==s||null===(e=s.navigator)||void 0===e?void 0:e.userAgent;n&&([t,i]=Qt(n))}catch(t){}return function(t,i){const e=function(t){if(t)return{}.hasOwnProperty.call(ys,t)?ys[t]:t}(t);return wi(wi({},e?{"os.name":e}:{}),i?{"os.version":i}:{})}(t,i)}()),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==v?void 0:v["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==r?r:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==v?void 0:v["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(a=null==v?void 0:v["deployment.environment"])&&void 0!==a?a:null==t?void 0:t.environment,resourceAttributes:v,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const zd=["debug","log","warn","error","info"],Hd=t=>{for(;null==t?void 0:t.__rrweb_original__;)t=t.__rrweb_original__;return t},qd="console",Vd="__posthogHandledLogsRequestError",Wd=(t,i)=>{const e=t instanceof Error?t:new Error(i);return e[Vd]=!0,e},Gd=t=>!!t&&"object"==typeof t&&!0===t[Vd];var Kd=class{get gv(){return wi(wi({},this.$),{},{error:(...t)=>{t.some(Gd)||this.$.error(...t)}})}constructor(t,i){var e;this.Ta=t,this.mv=i,this.name="logs",this.yv=!1,this.bv=!1,this._v=!1,this.$=Bs("[logs]"),this.Bu=[],this.wv=[],this.kd=0,this.Sv=!1,this.Ci=!1,this.xv=[],this.$v=[],this.Cv=!1,this.Tv=!1,this.Iv=!1,this.Mv=()=>{var t,i;this.Ci||(this.kd=0,null===(t=this.Ev)||void 0===t||t.onReconnect(),null===(i=this.Pv)||void 0===i||i.onReconnect())},this.yv=!!(null===(e=t.get())||void 0===e?void 0:e.captureConsoleLogs)}get Rv(){return!0}Av(){}Fv(){if(!this.Iv){try{this.Dd=typeof window>"u"?void 0:window}catch(t){this.Dd=void 0}this.Dd&&(qr(this.Dd,"online",this.Mv),this.Iv=!0)}}Ov(t,i,e,s){this.Fv();const n=Bd(this.Ta.get(),e);return[new Cs(this.Dv(t,i),n,this.gv,()=>this.mv(),t=>t(),void 0,s),n]}Lv(){const t=this.Ta.get();var i;return this.Ev&&this.Nv===t||(null===(i=this.Ev)||void 0===i||i.reset(),this.Nv=t,[this.Ev,this.qv]=this.Ov(()=>this.Bu,t=>{this.Bu=t})),this.Ev}jv(){const t=this.Ta.get();var i;return this.Pv&&this.Bv===t||(null===(i=this.Pv)||void 0===i||i.reset(),this.Bv=t,[this.Pv,this.zv]=this.Ov(()=>this.wv,t=>{this.wv=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},qd)),this.Pv}setup(t){if(!this.Ci&&!this.Sv)return this.Sv=!0,this.xa=t,this.$=t.logger.createLogger("[logs]"),cd(t.kv.initialize(),()=>{this.Ci||this.Ld(t)})}Ld(t){var i;this.Fv(),(null===(i=this.Ta.get())||void 0===i?void 0:i.captureConsoleLogs)&&(this.yv=!0),(this.yv||this.Ta.remoteConfigWillArrive&&t.kv.get(this.Ta.captureHintKey))&&this.Hv();let e=!1;const s=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.Ci?s.dispose():(this.qa=s,e||this.loadIfEnabled())}dispose(){var t,i,e,s,n,r,o;this.Ci||(this.Ci=!0,this.Uv(),null===(t=this.qa)||void 0===t||t.dispose(),this.qa=void 0,this.xa=void 0,this._v=!1,null===(i=this.Dd)||void 0===i||i.removeEventListener("online",this.Mv),null===(e=this.Wv)||void 0===e||e.call(this),this.Wv=void 0,null===(s=this.Ev)||void 0===s||s.clearQueue(),null===(n=this.Pv)||void 0===n||n.clearQueue(),null===(r=this.Ev)||void 0===r||r.reset(),null===(o=this.Pv)||void 0===o||o.reset())}onRemoteConfig(t){var i,e;if(this.Ci)return;const s=t.ok?null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs:void 0;F(s)?this.Vv():(null===(e=this.xa)||void 0===e||e.kv.set(this.Ta.captureHintKey,!!s),s?(this.yv=!0,this.bv||this.Hv(),this.loadIfEnabled()):this.Vv())}reset(){var t,i,e,s;this.Uv(),null===(t=this.Ev)||void 0===t||t.clearQueue(),this.Bu=[],null===(i=this.Ev)||void 0===i||i.reset(),null===(e=this.Pv)||void 0===e||e.clearQueue(),this.wv=[],null===(s=this.Pv)||void 0===s||s.reset(),this.kd=0}captureLog(t){!this.Ci&&this.xa&&this.Lv().captureLog(t)}captureConsoleLog(t){!this.Ci&&this.xa&&this.jv().captureLog(t)}captureBufferedConsoleLog(t,i,e){!this.Ci&&this.xa&&this.jv().captureLog(t,{context:i,occurredAtMs:e})}od(){var t;this.Uv(),null===(t=this.Pv)||void 0===t||t.clearQueue(),this.wv=[]}Vv(){this.yv||this.Uv()}Hv(){var t;if(this.Cv||!(null===(t=this.Dd)||void 0===t?void 0:t.console))return;const i=Bd(this.Ta.get()).maxBufferSize;let e=!0;this.$v.push(()=>{e=!1});for(const t of zd){let s;try{s=Hd(this.Dd.console[t])}catch(t){continue}s&&this.$v.push(qh(this.Dd.console,t,n=>{const r=(...s)=>{try{e&&this.Gv(t,s,i)}catch(t){}return n.apply(this.Dd.console,s)};return r.__rrweb_original__=s,r}))}this.Cv=!0,this.Qv=setTimeout(()=>{this.Uv()},3e4)}Gv(t,i,e){var s;if(this.Cv&&!this.Tv&&0!==i.length)if(null===(s=this.xa)||void 0===s?void 0:s.canCapture){if(e>this.xv.length){this.Tv=!0;try{this.xv.push({level:t,args:i,occurredAtMs:Date.now(),context:this.mv()})}finally{this.Tv=!1}}}else this.Uv()}Uv(){if(this.xv=[],this.Cv){this.Cv=!1,this.Qv&&(clearTimeout(this.Qv),this.Qv=void 0);for(const t of this.$v)t();this.$v=[]}}Zv(){const t=this.xv;return this.Uv(),t}get logger(){return this.Jv||(this.Jv={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.Jv}flushLogs(t){this.xa&&(t?this.Kv(t):(this.Ev&&this.Ev.flush().catch(t=>this.Xv(t)),this.Pv&&this.Pv.flush().catch(t=>this.Xv(t))))}flush(){var t=this;return J(function*(){var i,e;const s=null===(i=t.Ev)||void 0===i?void 0:i.flush().catch(i=>t.Xv(i)),n=null===(e=t.Pv)||void 0===e?void 0:e.flush().catch(i=>t.Xv(i));yield s,yield n})()}Xv(t){Gd(t)||this.$.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.Ci||!this.yv||this.bv||this._v)return;const t=this.Av();if(t){this._v=!0;try{t((t,i)=>{if(this._v=!1,!this.Ci&&this.yv)if(t||!i)this.$.error("Could not load logs script",t),this.Uv();else{const t=this.Zv();this.Wv=i.initialize(this.xa),this.bv=!0,t.length>0&&i.replay(this.xa,t)}})}catch(t){throw this._v=!1,t}}else this.Uv()}Dv(t,i){const e=this.xa;return{get isDisabled(){return!1},get optedOut(){return!e.canCapture},getPersistedProperty:i=>i===f.LogsQueue?t():void 0,setPersistedProperty(t,e){t===f.LogsQueue&&i(null!=e?e:[])},js:t=>this.js(t),getLibraryId:()=>e.library.name,getLibraryVersion:()=>e.library.version}}js(t){return new Promise(i=>{if(Cl(this.kd,3))return void i({kind:"fatal",error:Wd(void 0,"logs endpoint is unreachable, dropping batch")});let e=!1;const s=t=>{e||(e=!0,clearTimeout(n),i(t))},n=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Wd(void 0,"logs request timed out")})},9e4),r=this.Rv;this.xa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.xa.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var i;const e=t.statusCode;this.Yv(e,r),e>=200&&300>e?s({kind:"ok"}):413===e?s({kind:"too-large"}):0!==e&&408!==e&&429!==e&&500>e?s({kind:"fatal",error:new Error(`logs request failed with status ${e}`)}):0===e?(t.error||this.$.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Wd(t.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error(`logs request failed with status ${e}`)})},t=>{s({kind:"retry-later",error:t})})})}Yv(t,i){(0!==t||i)&&(this.kd=Rl(t,this.kd,3,()=>this.$.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Kv(t){this.Bu.length>0&&this.tf(t,this.Bu,this.qv,this.xa.library.name,t=>{this.Bu=t}),this.wv.length>0&&this.tf(t,this.wv,this.zv,qd,t=>{this.wv=t})}tf(t,i,e,s,n){if(0===i.length)return;const r=i.map(t=>t.record);n([]);const o=Es(r,xs(e,this.xa.library.name,this.xa.library.version),s,this.xa.library.version);this.xa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.xa.projectToken},body:o,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Xv(t))}};const Jd=Bs("[NetworkMetrics]"),Yd=()=>{var i;return(null==t||null===(i=t.performance)||void 0===i?void 0:i.now)?t.performance.now():Date.now()},Zd={"http:":80,"https:":443},Xd=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Qd=(t,i)=>{var e;const s=String(i);return{method:String(t).toUpperCase(),url:(null===(e=Al(s))||void 0===e?void 0:e.href)||s}},tc=(t,i,e,s,n,r,o=!1)=>{try{var l,a;const u=n();if(!u)return;const h=e||void 0,d=Yd()-s,c=Al(i.url);if(c&&"http:"!==c.protocol&&"https:"!==c.protocol)return;const v={url:(null==c?void 0:c.href)||i.url,method:i.method},f=T(u.name)?u.name(v):O(u.name)?u.name:"http.client.request.duration";if(!f)return;const p=o&&!h?void 0:((t,i)=>t?400>t?void 0:String(t):(null==i?void 0:i.name)||"_OTHER")(h,r),_=wi(wi(wi(wi(wi({},(t=>{const i=Xd.has(t)?t:"_OTHER";return wi({"http.request.method":i},"_OTHER"===i&&t!==i?{"http.request.method_original":t}:{})})(v.method)),c?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Zd[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(i=t.pathname,i.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var i})(c):{}),h?{"http.response.status_code":h}:{}),p?{"error.type":p}:{}),null===(l=u.attributes)||void 0===l?void 0:l.call(u,v,{status:h,durationMs:d}));null===(a=t.metrics)||void 0===a||a.histogram(f,d,{unit:"ms",attributes:_})}catch(t){Jd.error("Failed to record network metric",t)}},ic=()=>{},ec=(i,e)=>T(null==t?void 0:t.fetch)?qh(t,"fetch",t=>function(...s){const n=Yd(),r=t.apply(this,s);if(!e())return r;try{var o,l,a;const[t,u]=s,h=Qd(null!==(o=null!==(l=null==u?void 0:u.method)&&void 0!==l?l:null==t?void 0:t.method)&&void 0!==o?o:"GET",null!==(a=null==t?void 0:t.url)&&void 0!==a?a:t);return r.then(t=>(tc(i,h,null==t?void 0:t.status,n,e,void 0,!0),t),t=>{throw tc(i,h,void 0,n,e,t),t})}catch(t){return Jd.error("Failed to observe fetch",t),r}}):ic,sc=(i,e)=>{var s;const n=null==t||null===(s=t.XMLHttpRequest)||void 0===s?void 0:s.prototype;if(!n)return ic;const r=new WeakMap,o=qh(n,"open",t=>function(...i){try{(()=>hu.has(this))()||r.set(this,Qd(i[0],i[1]))}catch(t){Jd.error("Failed to observe XHR open",t)}return t.apply(this,i)}),l=qh(n,"send",t=>function(...s){let n;try{const t=r.get(this);if(t&&e()){const s=Yd();n=()=>{this.removeEventListener("loadend",n),tc(i,t,this.status,s,e)},qr(this,"loadend",n)}}catch(t){Jd.error("Failed to observe XHR send",t)}try{return t.apply(this,s)}catch(t){throw n&&this.removeEventListener("loadend",n),t}});return()=>{o(),l()}},nc=new WeakMap,rc=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),oc={maxStringLength:2048,truncationSuffix:"..."},lc={maxStringLength:2048,truncationSuffix:"..."};function ac(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function uc(t,i){return{}.hasOwnProperty.call(t,i)}function hc(t,i){const e=Object.create(t);return i&&Object.defineProperty(e,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:i}),e}function dc(t,i,e=!1){if(!O(t))return;const s=t.trim();return s?(e?as(s,oc):s).slice(0,i):void 0}function cc(t){try{return P(t)&&!0===t.isError}catch(t){return!1}}function vc(t){return as(t||"Unknown error",lc).slice(0,2048)}function fc(t,i){try{return vc(i?function(t){try{if(!P(t)||!k(t.content))return;return t.content.filter(t=>P(t)&&"text"===t.type&&O(t.text)).map(t=>t.text).join(" ").trim()||void 0}catch(t){return}}(t):P(t)&&O(t.message)?t.message:O(t)?t:String(t))}catch(t){return"Unknown error"}}function pc(t,i,e){return i.errorResult?[{type:"Error",value:e,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:t.buildProperties(i.error,{handled:!0}).$exception_list.map(t=>wi(wi({},t),{},{value:vc(t.value)}))}function _c(t,i){if(i)return"Error";try{if(!P(t))return"Error";let i=O(t.name)?t.name.trim():"";const e=t.constructor;return i&&"Error"!==i||!T(e)||"Error"===e.name||(i=e.name),(i||"Error").slice(0,256)}catch(t){return"Error"}}function gc(t,i){return{message:fc(t,i),type:_c(t,i)}}const mc={featureFlags:class extends Pd{constructor(t){const i=new Rd(t.config,t.qu());super(i),this.name=ah,this._instance=t,this.ef=i}get Ad(){return this._instance.persistence}updateConfig(t,i){this.ef.update(t,i),this.Fd()}}},yc={sessionRecording:class{get Ar(){return this._instance.config}get cc(){return this._instance.persistence}get started(){var t;return!!(null===(t=this.if)||void 0===t?void 0:t.isStarted)}get status(){var t,i;return"awaiting_config"===this.nf||"missing_config"===this.nf?this.nf:null!==(t=null===(i=this.if)||void 0===i?void 0:i.status)&&void 0!==t?t:this.nf}constructor(i){if(this._instance=i,this._forceAllowLocalhostNetworkCapture=!1,this.nf=Zh,this.sf=void 0,this.rf=!1,this.Je=(()=>{var i,e;if(!(null==s?void 0:s.visibilityState)||"visible"===s.visibilityState)return!0;const n=null==t||null===(i=t.performance)||void 0===i||null===(e=i.getEntriesByType)||void 0===e?void 0:e.call(i,"visibility-state");return!(null==n?void 0:n.length)||n.some(t=>"visible"===t.name)})(),this.sn=()=>{var t,i;"visible"===(null==s?void 0:s.visibilityState)&&(this.Je=!0,null===(t=this.if)||void 0===t||null===(i=t.setDocumentWasEverVisible)||void 0===i||i.call(t,!0))},!this._instance.sessionManager)throw Qh.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Ar.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==s?void 0:s.addEventListener)&&qr(s,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var i;this.rf=!0,null==s||null===(i=s.removeEventListener)||void 0===i||i.call(s,"visibilitychange",this.sn),t?this.af(!0):this.stopRecording()}get lf(){var i;const e=!!(null===(i=this._instance.get_property("$session_recording_remote_config"))||void 0===i?void 0:i.enabled),s=!this.Ar.disable_session_recording,n=this.Ar.disable_session_recording||this._instance.consent.isOptedOut();return t&&e&&s&&!n}startIfEnabledOrStop(t){var i;if(this.rf)return;if(this.lf&&(null===(i=this.if)||void 0===i?void 0:i.isStarted))return;const e=!R(Object.assign)&&!R(Array.from);this.lf&&e?(this.uf(t),Qh.info("starting")):(this.nf=Zh,this.stopRecording())}uf(t){var i,e;if(this.lf)if("awaiting_config"!==this.nf&&"missing_config"!==this.nf&&(this.nf=Xh),(null==d||null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.rrweb)||void 0===i?void 0:i.record)&&(null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.initSessionRecording))this.cf(t);else{var s,n;const i=this._instance.sessionManager;null===(s=d.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.hf,e=>{if(!this.rf&&this.lf&&this._instance.sessionManager===i)return e?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Qh.error("could not load recorder",e)):void this.cf(t);this.nf="disabled"})}}stopRecording(){var t,i;null===(t=this.sf)||void 0===t||t.call(this),this.sf=void 0,null===(i=this.if)||void 0===i||i.stop()}af(t=!1){var i,e;null===(i=this.sf)||void 0===i||i.call(this),this.sf=void 0,null===(e=this.if)||void 0===e||e.discard({discardProducerEvents:t})}df(){var t,i;null===(t=this.cc)||void 0===t||t.unregister("$session_is_sampled"),null===(i=this.cc)||void 0===i||i.unregister("$replay_sample_rate")}vf(t,i){if(F(t))return null;const e=M(t)?t:parseFloat(t);return"number"!=typeof(s=e)||!Number.isFinite(s)||0>s||s>1?(Qh.warn(`${i} must be between 0 and 1. Ignoring invalid value:`,t),null):e;var s}ff(t){if(this.cc){var i,e;const s=this.cc,n=()=>{var i;const e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.vf(null===(i=this.Ar.session_recording)||void 0===i?void 0:i.sampleRate,"session_recording.sampleRate"),r=this.vf(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=n?n:r;F(o)&&this.df();const l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[jn]:wi(wi({cache_timestamp:Date.now(),enabled:!!e},e),{},{networkPayloadCapture:wi({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:R(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null===(i=this.sf)||void 0===i||i.call(this),this.sf=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(n)}}onRemoteConfig(t){const i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.ff(i),void this.af()):(this.ff(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.nf&&(this.nf="missing_config",this._instance.register_for_session({[mr]:!0}),Qh.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i="log"){var e;(null===(e=this.if)||void 0===e?void 0:e.log)?this.if.log(t,i):Qh.warn("log called before recorder was ready")}get hf(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.get_property(jn);return(null==e||null===(i=e.scriptConfig)||void 0===i?void 0:i.script)||"lazy-recorder"}pf(){const t=this._instance.get_property(jn);if(!t)return!1;let i;try{i="object"==typeof t?t:JSON.parse(t)}catch(t){return Qh.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!F(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}cf(t){var i,e,s;if(!this.rf&&this.lf&&this._instance.sessionManager){if(!(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))return Qh.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[gr]:!0});var n;if(this.if||(this.if=null===(n=d.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Je),this.if._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.pf()){if("missing_config"===this.nf||"awaiting_config"===this.nf)return;return this.nf="awaiting_config",Qh.info("persisted remote config is stale, requesting fresh config before starting"),void new Pa(this._instance).load()}this.nf=Xh,null===(e=(s=this.if).setDocumentWasEverVisible)||void 0===e||e.call(s,this.Je),this.if.start(t)}else this.nf=Zh}onRRwebEmit(t){var i,e;null===(i=this.if)||void 0===i||null===(e=i.onRRwebEmit)||void 0===e||e.call(i,t)}overrideLinkedFlag(){var t,i;this.if||null===(i=this.cc)||void 0===i||i.register({$replay_override_linked_flag:!0}),null===(t=this.if)||void 0===t||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.if||null===(i=this.cc)||void 0===i||i.register({$replay_override_sampling:!0}),null===(t=this.if)||void 0===t||t.overrideSampling()}overrideTrigger(t){var i,e;this.if||null===(e=this.cc)||void 0===e||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(i=this.if)||void 0===i||i.overrideTrigger(t)}get sdkDebugProperties(){var t;const i={};for(const t of td){var e;const s=null===(e=this._instance.sessionPersistence)||void 0===e?void 0:e.get_property(t);R(s)||(i[t]=s)}return wi(wi({},i),(null===(t=this.if)||void 0===t?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,i){var e;return!!(null===(e=this.if)||void 0===e?void 0:e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t,i;null===(t=this.if)||void 0===t||null===(i=t.flushBeforeIdentityReset)||void 0===i||i.call(t)}}},bc={autocapture:class extends Lh{constructor(t){super(new Uh(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.gf=!1,this._instance=t,this.mf=this.yf()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.bf();return!!(t.path||t.search||this._f(t))}startIfEnabled(){this.isEnabled&&(Us.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.mf=this.yf(),this.startIfEnabled()}stop(){this.wf&&this.wf(),this.wf=void 0,this.kf&&this.kf(),this.kf=void 0,Us.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Sf("pushState"),this.Sf("replaceState"),this.xf(),this._f()&&this.$f())}Sf(i){var e;if(!t||(null===(e=t.history[i])||void 0===e?void 0:e.__posthog_wrapped__))return;const s=this;qh(t.history,i,e=>function(n,r,o){var l;s.Cf(o)&&s.Tf(),e.call(this,n,r,o),s.If(i,!s.gf&&"popstate"!==(null==t||null===(l=t.event)||void 0===l?void 0:l.type))})}yf(){const i=null==t?void 0:t.location;if(null==i?void 0:i.pathname)return{pathname:i.pathname,search:i.search,hash:i.hash}}bf(){const t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:P(t)?t:{}}_f(t=this.bf()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Mf(t){const i=this.bf(),e=this.mf;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this._f(i)&&t.hash!==e.hash))}If(t,i=!1){try{i||this.Tf();const e=this.yf();if(!e)return;if(this.Mf(e)){const e=()=>this._instance.capture(Or,{navigation_type:t});i?(this.Ef=e,Promise.resolve().then(()=>this.Tf())):e()}this.mf=e}catch(i){Us.error(`Error capturing ${t} pageview`,i)}}Cf(i){var e,s;return!(F(i)||!t)&&(null===(e=Al(String(i)))||void 0===e?void 0:e.href)!==(null===(s=t.location)||void 0===s?void 0:s.href)}Tf(){const t=this.Ef;if(t){this.Ef=void 0,this.gf=!0;try{t()}catch(t){Us.error("Error capturing deferred pageview",t)}finally{this.gf=!1}this.mf=this.yf()}}xf(){if(this.wf)return;const i=()=>{this.If("popstate")};qr(t,"popstate",i),this.wf=()=>{t&&t.removeEventListener("popstate",i)}}$f(){if(this.kf)return;const i=()=>{this.If("hashchange")};qr(t,"hashchange",i),this.kf=()=>{t&&t.removeEventListener("hashchange",i)}}},heatmaps:class{get Ar(){return this.instance.config}constructor(t){var i;this.Pf=!1,this.al=!1,this.Rf=null,this.instance=t,this.Pf=!!(null===(i=this.instance.persistence)||void 0===i?void 0:i.props[Cn]),this.rageclicks=new Ih(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return P(this.Ar.capture_heatmaps)&&this.Ar.capture_heatmaps.flush_interval_milliseconds&&(t=this.Ar.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return F(this.Ar.capture_heatmaps)?F(this.Ar.enable_heatmaps)?this.Pf:this.Ar.enable_heatmaps:!1!==this.Ar.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.al)return;id.info("starting..."),this.Af(),this.sn()}else{var t;clearInterval(null!==(t=this.Rf)&&void 0!==t?t:void 0),this.Ff(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("heatmaps"in i))return;const e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Cn]:e}),this.Pf=e,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}Of(t){ed(t.originalEvent)&&this.$r(t.originalEvent,"deadclick")}sn(){this.Rf&&clearInterval(this.Rf),this.Rf="visible"===(null==s?void 0:s.visibilityState)?setInterval(this.Zu.bind(this),this.flushIntervalMilliseconds):null}Af(){t&&s&&(this.Df=this.Zu.bind(this),qr(t,Rr,this.Df),this.Lf=i=>this.$r(i||(null==t?void 0:t.event)),qr(s,"click",this.Lf,{capture:!0}),this.Nf=i=>this.qf(i||(null==t?void 0:t.event)),qr(s,"mousemove",this.Nf,{capture:!0}),this.jf=new _l(this.instance,fl,this.Of.bind(this)),this.jf.startIfEnabledOrStop(),this.Bf=this.sn.bind(this),qr(s,_n,this.Bf),this.al=!0)}Ff(){var i;t&&s&&(this.Df&&t.removeEventListener(Rr,this.Df),this.Lf&&s.removeEventListener("click",this.Lf,{capture:!0}),this.Nf&&s.removeEventListener("mousemove",this.Nf,{capture:!0}),this.Bf&&s.removeEventListener(_n,this.Bf),clearTimeout(this.zf),null===(i=this.jf)||void 0===i||i.stop(),this.al=!1)}Hf(i,e){const s=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(i,e,s){let n=i;for(;n&&Eo(n)&&!ko(n,"body");){if(n===s)return!1;let i;try{var r,o,l;i=null===(r=null!==(o=null===(l=n.ownerDocument)||void 0===l?void 0:l.defaultView)&&void 0!==o?o:t)||void 0===r?void 0:r.getComputedStyle(n).position}catch(t){return!1}if(m(e,i))return!0;n=jo(n)}return!1}(Fo(i),["fixed","sticky"],r);return{x:i.clientX+(o?0:n),y:i.clientY+(o?0:s),target_fixed:o,type:e}}$r(t,i="click"){var e;if(xo(t.target)||!ed(t))return;const s=this.Hf(t,i);(null===(e=this.rageclicks)||void 0===e?void 0:e.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&Yo(Fo(t),this.instance.config.rageclick)&&this.Qs(wi(wi({},s),{},{type:"rageclick"})),this.Qs(s)}qf(t){!xo(t.target)&&ed(t)&&(clearTimeout(this.zf),this.zf=setTimeout(()=>{this.Qs(this.Hf(t,"mousemove"))},500))}Qs(i){if(!t)return;const e=this.Ar.disable_capture_url_hashes?vi(t.location.href):t.location.href,s=this.Ar.custom_personal_data_properties,n=this.Ar.mask_personal_data_properties?[...Dl,...s||[]]:[],r=Fl(e,n,jl);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(i)}Zu(){this.Rt&&!C(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:_l,webVitalsAutocapture:class{constructor(i){var e;this._instance=i,this.Pf=!1,this.al=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Uf=(t=!1)=>{clearTimeout(this.Wf),this.Wf=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",wi({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>wi(wi({},t),{},{[`$web_vitals_${i.name}_event`]:wi({},i),[`$web_vitals_${i.name}_value`]:i.value}),{})),t?{transport:"sendBeacon",send_instantly:!0}:void 0),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Vf=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},F(null==t?void 0:t.name)||F(null==t?void 0:t.value))return void Wh.error("Invalid metric received",t);const e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Gf(e);if(R(s))return;const n=M(t.navigationId)||"string"==typeof t.navigationId?`navigation:${t.navigationId}`:`url:${s}`;if(this.Qf&&t.value>=this.Qf)return void Wh.error("Ignoring metric with value >= "+this.Qf,t);this.Rt.navigationKey!==n&&(this.Uf(),this.Wf=setTimeout(this.Uf,this.flushToCaptureTimeoutMs)),R(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=R(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0),o=wi(wi(wi({},t),e?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,P(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){const i={};for(const e of Yh){const s="url"===e&&"string"==typeof t.attribution[e]?this.Gf(t.attribution[e]):t.attribution[e];R(s)||(i[e]=s)}o.attribution=i}else delete o.attribution;R(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Uf()},this.Zf=()=>{if(this.al)return;let i,e,s,n,r=!1;const o=d.__PosthogExtensions__,l=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,a=(null==l?void 0:l[this.Jf])||("web-vitals"===this.Jf&&R(l)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!R(a)){const t=a.withoutAttribution,o=this.attributionMetrics;r=!R(t),i=o.indexOf("LCP")>-1?a.onLCP:(null==t?void 0:t.onLCP)||a.onLCP,e=o.indexOf("CLS")>-1?a.onCLS:(null==t?void 0:t.onCLS)||a.onCLS,s=o.indexOf("FCP")>-1?a.onFCP:(null==t?void 0:t.onFCP)||a.onFCP,n=o.indexOf("INP")>-1?a.onINP:(null==t?void 0:t.onINP)||a.onINP}if(!(i&&e&&s&&n))return void Wh.error("web vitals callbacks not loaded - not starting");const u={reportSoftNavs:this.useSoftNavs},h=r&&this.attributionMetrics.indexOf("INP")>-1?wi(wi({},u),{},{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&i(this.Vf.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&e(this.Vf.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&s(this.Vf.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&n(this.Vf.bind(this),h);const c=null==t?void 0:t.document;qr(c,_n,()=>{"hidden"===(null==c?void 0:c.visibilityState)&&this.Uf(!0)}),qr(t,"pagehide",()=>this.Uf(!0)),this.al=!0},this.Pf=!!(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[In]),this.startIfEnabled()}get Kf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i;const e=P(this.Kf)?null===(t=this.Kf)||void 0===t?void 0:t.web_vitals_allowed_metrics:void 0;return F(e)?(null===(i=this._instance.persistence)||void 0===i?void 0:i.props.$web_vitals_allowed_metrics)||Kh:e}get flushToCaptureTimeoutMs(){return(P(this.Kf)?this.Kf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=P(this.Kf)?this.Kf.web_vitals_attribution:void 0;return N(t)?t?Kh:[]:k(t)?t:Jh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=P(this.Kf)?this.Kf.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Qf(){const t=P(this.Kf)&&M(this.Kf.__web_vitals_max_value)?this.Kf.__web_vitals_max_value:Gh;return t>0&&6e4>=t?Gh:t}get isEnabled(){const t=null==n?void 0:n.protocol;if("http:"!==t&&"https:"!==t)return Wh.info("Web Vitals are disabled on non-http/https protocols"),!1;const i=P(this.Kf)?this.Kf.web_vitals:N(this.Kf)?this.Kf:void 0;return N(i)?i:this.Pf}startIfEnabled(){this.isEnabled&&!this.al&&(Wh.info("enabled, starting..."),this.$l(this.Zf))}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("capturePerformance"in i))return;const e=P(i.capturePerformance)&&!!i.capturePerformance.web_vitals,s=P(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[In]:e}),this._instance.persistence.register({[Nn]:s})),this.Pf=e,this.startIfEnabled()}get Jf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}$l(t){var i;const e=d.__PosthogExtensions__,s=this.Jf,n=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&R(n)&&(null==e?void 0:e.postHogWebVitalsCallbacks)?t():null==e||null===(i=e.loadExternalDependency)||void 0===i||i.call(e,this._instance,s,i=>{i?Wh.error("failed to load script",i):t()})}Gf(i){const e=i||(null==t?void 0:t.location.href);if(!e)return void Wh.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?vi(e):e,n=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Dl,...n||[]]:[];return Fl(s,r,jl)}}},wc={exceptionObserver:class{constructor(i){var e;this.Zf=()=>{var i;if(!t||!this.isEnabled||!(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions))return;const e=d.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=d.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=d.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Xf&&this.Ar.capture_unhandled_errors&&(this.Xf=e(this.captureException.bind(this))),!this.Yf&&this.Ar.capture_unhandled_rejections&&(this.Yf=s(this.captureException.bind(this))),!this.tp&&this.Ar.capture_console_errors&&(this.tp=n(this.captureException.bind(this)))}catch(t){Bh.error("failed to start",t),this.ep()}},this._instance=i,this.np=!!(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[Rn]),this.wt=new tt(wi(wi({},function(t={}){var i,e,s,n;return{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:Bh})),this.Ar=this.sp(),this.startIfEnabledOrStop()}sp(){const t=this._instance.config.capture_exceptions;let i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return P(t)?i=wi(wi({},i),t):(R(t)?this.np:t)&&(i=wi(wi({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Ar.capture_console_errors||this.Ar.capture_unhandled_errors||this.Ar.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Bh.info("enabled"),this.ep(),this.$l(this.Zf)):this.ep()}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"exception-autocapture",i=>{if(i)return Bh.error("failed to load script",i);t()})}ep(){var t,i,e;null===(t=this.Xf)||void 0===t||t.call(this),this.Xf=void 0,null===(i=this.Yf)||void 0===i||i.call(this),this.Yf=void 0,null===(e=this.tp)||void 0===e||e.call(this),this.tp=void 0}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"autocaptureExceptions"in i&&(this.np=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Rn]:this.np}),this.Ar=this.sp(),this.startIfEnabledOrStop())}onConfigChange(){this.Ar=this.sp()}captureException(t){try{var i,e,s;const n=null!==(i=null==t||null===(e=t.$exception_list)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(n))return void Bh.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.rp=[],this.op=new Pi([new Ji,new re,new Zi,new Yi,new se,new ee,new Qi,new ne],function(t,...i){return(e,s=0)=>{const n=[],r=e.split("\n"),o=Math.min(r.length,s+1e3),l=[];for(let e=s;o>e;e++){const s=r[e];if(s.length>1024)continue;const o=Bi.test(s)?s.replace(Bi,"$1"):s;if(!o.match(/\S*Error: /)){for(const e of i){const i=e(o,t);if(i){n.push(i);const t=Hi(n);if(t){for(let i=l.length-1;i>=0;i--){const e=l[i];if(t.start>=e.start+e.length)break;l.pop()}l.push(t)}break}}if(Gi(n,l)>=50)break}}const a=[...l].sort((t,i)=>i.start-t.start),u=a[a.length-1];if(u){const t=Vi(n,u);n.splice(u.start-t,t);for(const i of a)i.start-=t}for(const t of a)qi(n,t);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){const i=t.map(t=>`${t.function}|${t.filename}|${t.lineno}|${t.colno}|${t.module}`);let e=0;for(let t=1;i.length>t;t++)Ki(i,t,e)&&(e=t);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];const i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return wi(wi({},t),{},{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",Ni,Ui)),this._instance=t,this.rp=null!==(i=null===(e=this._instance.persistence)||void 0===e?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.ap=he(this.lp()),this.up=new de(this.ap)}onConfigChange(){this.ap=he(this.lp()),this.up.setConfig(this.ap)}onRemoteConfig(t){var i,e,s;if(!t.ok)return;const n=t.config;if(!("errorTracking"in n))return;const r=null!==(i=null===(e=n.errorTracking)||void 0===e?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.rp=r,this._instance.persistence&&this._instance.persistence.register({[On]:this.rp,[An]:o})}get cp(){var t;const i=!!this._instance.get_property(An),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.op.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.ap.enabled)try{if(!O(t)||0===t.trim().length)return void Ad.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:e,droppedKeys:s}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};const i=[];return{sanitizedProperties:Object.keys(t).reduce((e,s)=>ae.has(s)?(i.push(s),e):(e[s]=t[s],e),{}),droppedKeys:i}}(this.hp(i));s.length>0&&Ad.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.up.add(wi({[oe]:t,[le]:(new Date).toISOString()},e))}catch(t){Ad.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{const i=t.$exception_list;if(this.dp(i)){if(this.vp(i))return this.fp("Exception dropped: matched a suppression rule"),void Ad.info("Skipping exception capture because a suppression rule matched");if(!this.cp&&this.pp(i))return this.fp("Exception dropped: thrown by a browser extension"),void Ad.info("Skipping exception capture because it was thrown by an extension");if(!this.cp&&this.gp(i))return this.fp("Exception dropped: thrown by an injected browser script"),void Ad.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.mp(i))return this.fp("Exception dropped: thrown by the PostHog SDK"),void Ad.info("Skipping exception capture because it was thrown by the PostHog SDK")}const e=this.ap.enabled&&F(t.$exception_steps)?this.yp(t):t,s=function(){if("u">typeof process){var t;const i=null===(t=process.env.POSTHOG_RELEASE_ID)||void 0===t?void 0:t.trim();if(i)return i}const i=globalThis._posthogReleaseId;return"string"==typeof i&&i.length>0?i:void 0}();s&&(e.$release_id=s);try{const t=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",Vh:!0});return t&&this.up.clear(),t}catch(t){return Od(t)||Ad.error("Failed to capture exception event. Dropping this exception.",t),void this.up.clear()}}catch(t){return void(Od(t)||Ad.error("Failed to process exception event. Ignoring this exception.",t))}}yp(t){try{const i=this.up.getAttachable();return 0===i.length?t:wi(wi({},t),{},{$exception_steps:i})}catch(i){return Ad.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}fp(t){this.ap.enabled&&this.up.add({[oe]:t,[le]:(new Date).toISOString()})}hp(t){return P(t)?wi({},t):{}}lp(){var t,i;return null!==(t=null===(i=this._instance.config.error_tracking)||void 0===i?void 0:i.exception_steps)&&void 0!==t?t:{}}vp(t){if(0===t.length)return!1;try{const i=t.reduce((t,{type:i,value:e})=>(O(i)&&i.length>0&&t.$exception_types.push(i),O(e)&&e.length>0&&t.$exception_values.push(e),t),{$exception_types:[],$exception_values:[]});return this.rp.some(t=>{const e=t.values.map(t=>{const e=Wu[t.operator],s=i[t.key];if(!e||!s)return!1;const n=k(t.value)?t.value:[t.value];return n.length>0&&e(n,s)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return Ad.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}pp(t){const i=t.flatMap(t=>{var i,e;return null!==(i=null===(e=t.stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(({filename:t})=>!!t&&Md.some(i=>t.startsWith(i)));return 0!==e.length&&(!e.every(({filename:t})=>!!t&&t.startsWith(Id))||t.some(({type:t,value:i})=>"NoResponse"===t||O(i)&&Fd.some(({value:t,exact:e})=>e?i===t:i.includes(t)))&&!i.some(({in_app:t,filename:i})=>t&&!(null==i?void 0:i.startsWith(Id))))}gp(t){return t.some(({value:t})=>O(t)&&Dd.some(i=>t.includes(i)))}mp(t){if(t.length>0){var i,e,s,n;const r=null!==(i=null===(e=t[0].stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}dp(t){return!F(t)&&k(t)}}},$c=wi({productTours:class{get cc(){return this._instance.persistence}constructor(t){this.bp=null,this._p=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if("productTours"in i){var e,s;if(this.cc&&this.cc.register({[Mn]:!!i.productTours}),!nd(this._instance))return!this.bp&&F(null===(e=this.cc)||void 0===e?void 0:e.props.ph_product_tours)||sd.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.bp)||void 0===s||s.stop(),this.bp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.bp&&nd(this._instance)&&this.$l(()=>this.wp())}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.generateProductTours)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"product-tours",i=>{i?sd.error("Could not load product tours script",i):t()})}wp(){var t;!this.bp&&(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)&&(this.bp=d.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i=!1){if(k(this._p)&&!i)return void t(this._p,{isLoaded:!0});const e=this.cc;if(e){const s=e.props[Qn];if(k(s)&&!i)return this._p=s,void t(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!nd(this._instance))return void t([],{isLoaded:!0});const s=i.statusCode;if(200!==s||!i.json){const e=`Product Tours API could not be loaded, status: ${s}`;return 0===s?i.error||sd.warn(e):sd.error(e),void t([],{isLoaded:!1,error:e})}const n=k(i.json.product_tours)?i.json.product_tours:[];this._p=n,e&&e.register({[Qn]:n}),t(n,{isLoaded:!0})}})}getActiveProductTours(t){F(this.bp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.bp.getActiveProductTours(t)}showProductTour(t){var i;null===(i=this.bp)||void 0===i||i.showTourById(t)}previewTour(t){this.bp?this.bp.previewTour(t):this.$l(()=>{var i;this.wp(),null===(i=this.bp)||void 0===i||i.previewTour(t)})}dismissProductTour(){var t;null===(t=this.bp)||void 0===t||t.dismissTour("user_clicked_skip")}nextStep(){var t;null===(t=this.bp)||void 0===t||t.nextStep()}previousStep(){var t;null===(t=this.bp)||void 0===t||t.previousStep()}clearCache(){var t;this._p=null,null===(t=this.cc)||void 0===t||t.unregister("ph_product_tours")}resetTour(t){var i;null===(i=this.bp)||void 0===i||i.resetTour(t)}resetAllTours(){var t;null===(t=this.bp)||void 0===t||t.resetAllTours()}cancelPendingTour(t){var i;null===(i=this.bp)||void 0===i||i.cancelPendingTour(t)}}},mc),Sc={siteApps:class{constructor(t){this._instance=t,this.kp=0,this.Sp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}xp(t,i){if(!i)return;const e=this.globalsForEvent(i);this.Sp.push(e),this.Sp.length>1e3&&(this.Sp=this.Sp.slice(10))}get siteAppLoaders(){var t;return null===(t=d._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.xp.bind(this));this.$p=()=>{t(),this.Sp=[],this.$p=void 0}}}globalsForEvent(t){var i,e,s,n,r,o,l;if(!t)throw new Error("Event payload is required");const a={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(const[t,i]of Object.entries(h))a[t]={id:u[t],type:t,properties:i};const{$set_once:d,$set:c}=t;return{event:wi(wi({},ke(t,rd)),{},{properties:wi(wi(wi({},t.properties),c?{$set:wi(wi({},null!==(i=null===(e=t.properties)||void 0===e?void 0:e.$set)&&void 0!==i?i:{}),c)}:{}),d?{$set_once:wi(wi({},null!==(s=null===(n=t.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=t.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(l=t.properties)||void 0===l?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Cp(t){var i;const e=null===(i=t.tagName)||void 0===i?void 0:i.toLowerCase();if("style"===e&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(t)||(od.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===e&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(t)||(od.error("prepare_external_dependency_script returned null"),null)}return t}Tp(){var t,i,e,n,r,o,l,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const u=null==s?void 0:s.defaultView,h=null==u||null===(t=u.Node)||void 0===t?void 0:t.prototype;if(!u||!h)return()=>{};if(this.kp++,this.Ip)return this.Mp();const d=[],c=this,v=new WeakSet,f=(t,i,e)=>{if(!(null==t?void 0:t[i]))return;const s=t[i];t[i]=e(s),d.push(()=>{t[i]=s})},p=t=>{if(v.has(t))return t;const i=c.Cp(t);return i&&v.add(i),i},_=t=>t.map(t=>"string"==typeof t?t:p(t)).filter(t=>!I(t));return f(h,"appendChild",t=>function(i){const e=p(i);return e?t.call(this,e):i}),f(h,"insertBefore",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):i}),f(h,"replaceChild",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):e}),[null===(i=u.Element)||void 0===i?void 0:i.prototype,null===(e=u.Document)||void 0===e?void 0:e.prototype,null===(n=u.DocumentFragment)||void 0===n?void 0:n.prototype].forEach(t=>{f(t,"append",t=>function(...i){return t.apply(this,_(i))}),f(t,"prepend",t=>function(...i){return t.apply(this,_(i))})}),[null===(r=u.Element)||void 0===r?void 0:r.prototype,null===(o=u.CharacterData)||void 0===o?void 0:o.prototype,null===(l=u.DocumentType)||void 0===l?void 0:l.prototype].forEach(t=>{f(t,"before",t=>function(...i){return t.apply(this,_(i))}),f(t,"after",t=>function(...i){return t.apply(this,_(i))}),f(t,"replaceWith",t=>function(...i){const e=_(i);return i.length&&!e.length?void 0:t.apply(this,e)})}),f(null===(a=u.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",t=>function(i,e){const s=p(e);return s?t.call(this,i,s):null}),this.Ip=()=>{d.forEach(t=>t()),this.Ip=void 0},this.Mp()}Mp(){let t=!1;return()=>{var i;t||(t=!0,this.kp--,0===this.kp&&(null===(i=this.Ip)||void 0===i||i.call(this)))}}Ep(t,i=!0){const e=this.Tp();try{const s=t(e);return i&&e(),s}catch(t){throw e(),t}}setupSiteApp(t){const i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Sp.length&&(od.info(`Processing ${this.Sp.length} events for site app with id ${t.id}`),this.Sp.forEach(t=>this.Ep(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null===(e=this.$p)||void 0===e||e.call(this))};let s=!1;const n=n=>{i.errored=!n,i.loaded=!0,od.info(`Site app with id ${t.id} ${n?"loaded":"errored"}`),s&&e()};try{const{processEvent:e}=this.Ep(i=>t.init({posthog:this._instance,callback(t){i(),n(t)}}),!1);e&&(i.processEvent=e),s=!0}catch(i){od.error(ld+t.id,i),n(!1)}if(s&&i.loaded)try{e()}catch(e){od.error(`Error while processing buffered events PostHog app with config id ${t.id}`,e),i.errored=!0}}Pp(){const t=this.siteAppLoaders||[];for(const i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(const i of t)this.setupSiteApp(i)}Rp(t){if(0===Object.keys(this.apps).length)return;const i=this.globalsForEvent(t);for(const e of Object.values(this.apps))try{this.Ep(()=>{var t;return null===(t=e.processEvent)||void 0===t?void 0:t.call(e,i)})}catch(i){od.error(`Error while processing event ${t.event} for site app ${e.id}`,i)}}onRemoteConfig(t){var i,e,s;if(null===(i=this.siteAppLoaders)||void 0===i?void 0:i.length)return this.isEnabled?(this.Pp(),void this._instance.on("eventCaptured",t=>this.Rp(t))):void od.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(e=this.$p)||void 0===e||e.call(this),!t.ok)return;const n=t.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:t,url:i}of n.siteApps){var r,o;d[`__$$ph_site_app_${t}`]=this._instance,null===(r=d.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,i,i=>{if(i)return od.error(ld+t,i)})}else od.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},xc={tracingHeaders:class{constructor(t){this._instance=t,this.Ap=void 0,this.Fp=void 0,this.Op=void 0,this.Zf=()=>{const t=this.Dp();var i,e;t?(R(this.Ap)&&(this.Ap=null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),R(this.Fp)&&(this.Fp=null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.tracingHeadersPatchFns)||void 0===e?void 0:e._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.ep()}}initialize(){this.startIfEnabledOrStop()}$l(t){var i,e,s;(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.tracingHeadersPatchFns)?t():null===(e=d.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"tracing-headers",i=>{if(i)return Vh.error("failed to load script",i);t()})}Lp(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Dp(){const t=this.Lp();return k(t)?(k(this.Op)?this.Op.splice(0,this.Op.length,...t):this.Op=[...t],t.length>0?this.Op:void 0):(k(this.Op)&&this.Op.splice(0),this.Op=t||void 0,this.Op)}ep(){var t,i;null===(t=this.Ap)||void 0===t||t.call(this),null===(i=this.Fp)||void 0===i||i.call(this),this.Ap=void 0,this.Fp=void 0}startIfEnabledOrStop(){this.Dp()?this.$l(this.Zf):this.ep()}}},Ec=wi({surveys:class extends pd{constructor(t){super(new _d(t))}}},mc),kc={toolbar:class{constructor(t){this.instance=t}Np(t){d.ph_toolbar_state=t}qp(){var t;return null!==(t=d.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i=void 0,e=void 0,n=void 0){var r,o;if(Vr(this.instance.config))return!1;if(!t||!s)return!1;i=null!==(r=i)&&void 0!==r?r:t.location,n=null!==(o=n)&&void 0!==o?o:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}e=null==t?void 0:t.localStorage}const s=gd||Ml(i.hash,"__posthog")||Ml(i.hash,"state");let r;const o=s?fi(()=>JSON.parse(atob(decodeURIComponent(s))))||fi(()=>JSON.parse(decodeURIComponent(s))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?i.hash=o.desiredHash:n?n.replaceState(n.state,"",i.pathname+i.search):i.hash="")):(r=JSON.parse(e.getItem(md)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}jp(t){const i=d.ph_load_toolbar||d.ph_load_editor;!F(i)&&T(i)?i(t,this.instance):yd.warn("No toolbar load function found")}loadToolbar(i){const e=!!(null==s?void 0:s.getElementById("__POSTHOG_TOOLBAR__"));if(!t||e)return!1;const n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=wi(wi({token:this.instance.config.token},i),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(t.localStorage.setItem(md,JSON.stringify(wi(wi({},r),{},{source:void 0}))),2===this.qp())this.jp(r);else if(0===this.qp()){var o,l;this.Np(1),null===(o=d.__PosthogExtensions__)||void 0===o||null===(l=o.loadExternalDependency)||void 0===l||l.call(o,this.instance,"toolbar",t=>{if(t)return yd.error("[Toolbar] Failed to load",t),void this.Np(0);this.Np(2),this.jp(r)}),qr(t,"turbolinks:load",()=>{this.Np(0),this.loadToolbar(r)})}return!0}Bp(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,i=void 0,e=void 0){return this.maybeLoadToolbar(t,i,e)}}},Tc=wi({experiments:class i{get Ar(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{i.zp("retrieved web experiments from the server"),this.Hp=new Map,t.forEach(t=>{if(t.feature_flag_key){var e;this.Hp&&(i.zp("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(e=this.Hp)||void 0===e||e.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);O(s)&&t.variants[s]&&this.Up(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const e in t.variants){const s=t.variants[e];i.Wp(s,this._instance)&&this.Up(t.name,e,s.transforms)}})},t)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(t){if(this._is_bot())i.zp(Nd);else if(!this.Ar.disable_web_experiments){if(F(this.Hp))return this.Hp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.zp("applying feature flags",t),t.forEach(t=>{var i;if(this.Hp&&(null===(i=this.Hp)||void 0===i?void 0:i.has(t))){var e;const i=this._instance.getFeatureFlag(t),s=null===(e=this.Hp)||void 0===e?void 0:e.get(t);i&&(null==s?void 0:s.variants[i])&&this.Up(s.name,i,s.variants[i].transforms)}})}}previewWebExperiment(){const t=i.getWindowLocation();if(null==t?void 0:t.search){const e=Il(null==t?void 0:t.search,"__experiment_id"),s=Il(null==t?void 0:t.search,"__experiment_variant");e&&s&&(i.zp(`previewing web experiments ${e} && ${s}`),this.getWebExperiments(t=>{this.Vp(parseInt(e),s,t)},!1,!0))}}loadIfEnabled(){this.Ar.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Ar.disable_web_experiments&&!e)return t([]);const s=this._instance.get_property("$web_experiments");if(s&&!i)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Ar.token}`),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}Vp(t,e,s){const n=s.filter(i=>i.id===t);n&&n.length>0&&(i.zp(`Previewing web experiment [${n[0].name}] with variant [${e}]`),this.Up(n[0].name,e,n[0].variants[e].transforms))}static Wp(t,e){return!F(t.conditions)&&i.Gp(t,e)&&i.Qp(t)}static Gp(t,e){var s;if(F(t.conditions)||F(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=i.getWindowLocation();if(n){var r,o,l;const i=So(e,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||jd[null!==(o=null===(l=t.conditions)||void 0===l?void 0:l.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,i)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static Qp(t){var i;if(F(t.conditions)||F(null===(i=t.conditions)||void 0===i?void 0:i.utm))return!0;const e=Ul();if(e.utm_source){var s,n,r,o,l,a,u,h;const i=!(null===(s=t.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=t.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==e.utm_campaign,d=!(null===(r=t.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=t.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==e.utm_source,c=!(null===(l=t.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)||(null===(a=t.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)==e.utm_medium,v=!(null===(u=t.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)||(null===(h=t.conditions)||void 0===h||null===(h=h.utm)||void 0===h?void 0:h.utm_term)==e.utm_term;return i&&c&&v&&d}return!1}static zp(t,...i){Us.info(`[WebExperiments] ${t}`,i)}Up(t,e,s){this._is_bot()?i.zp(Nd):"control"!==e?s.forEach(s=>{if(s.selector){var n;i.zp(`applying transform of variant ${e} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(t=>{const i=t;s.html&&(i.innerHTML=s.html),s.css&&i.setAttribute("style",s.css)})}}):i.zp("Control variants leave the page unmodified.")}_is_bot(){return e&&this._instance?Uu(e,this.Ar.custom_blocked_useragents):void 0}}},mc),Pc={conversations:class{constructor(t){this._instance=t,this.Zp=void 0,this._conversationsManager=null,this.Jp=!1,this.ne=null,this.Kp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)return;if(this.Xp=t.ok,!t.ok)return;const i=t.config.conversations;F(i)||(N(i)?this.Zp=i:(this.Zp=i.enabled,this.ne=i),this.loadIfEnabled())}reset(){var t;null===(t=this._conversationsManager)||void 0===t||t.reset(),this._conversationsManager=null,this.Zp=void 0,this.ne=null,this.Xp=void 0,this.Kp=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.Jp)return;if(this._instance.config.disable_conversations)return;if(Vr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=null==d?void 0:d.__PosthogExtensions__;if(t&&!R(this.Zp)&&this.Zp)if(this.ne&&this.ne.token){this.Jp=!0;try{const i=t.initConversations;if(i)return this.Yp(i),void(this.Jp=!1);const e=t.loadExternalDependency;if(!e)return void this.tg(Ys);e(this._instance,"conversations",i=>{i||!t.initConversations?this.tg("Could not load conversations script",i):this.Yp(t.initConversations),this.Jp=!1})}catch(t){this.tg("Error initializing conversations",t),this.Jp=!1}}else Ld.error("Conversations enabled but missing token in remote config.")}Yp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.Kp=!1,Ld.info("Conversations loaded successfully")}catch(t){this.tg("Error completing conversations initialization",t)}else Ld.error("Cannot complete initialization: remote config is null")}tg(t,i){Ld.error(t,i),this._conversationsManager=null,this.Jp=!1,this.Kp=!0}show(){this._conversationsManager?this._conversationsManager.show():Ld.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Zp&&!I(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Vr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Xp?"remote_config_failed":R(this.Zp)?this.Xp?"disabled_in_project":"remote_config_pending":this.Zp?F(this.ne)||!this.ne.token?"missing_token":(null==d?void 0:d.__PosthogExtensions__)?this.Jp?"initializing":this.Kp?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return J(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(Ld.warn(Ud),null)})()}getMessages(t,i){var e=this;return J(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Ld.warn(Ud),null)})()}markAsRead(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Ld.warn(Ud),null)})()}getTickets(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Ld.warn(Ud),null)})()}requestRestoreLink(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Ld.warn(Ud),null)})()}restoreFromToken(t){var i=this;return J(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Ld.warn(Ud),null)})()}restoreFromUrlToken(){var t=this;return J(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ld.warn(Ud),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}nd(){var t;null===(t=this._conversationsManager)||void 0===t||t.setIdentity()}sd(){var t;null===(t=this._conversationsManager)||void 0===t||t.clearIdentity()}}},Cc={logs:class extends Kd{constructor(t){super({get(){var i;return null==t||null===(i=t.config)||void 0===i?void 0:i.logs},captureHintKey:Dn,get remoteConfigWillArrive(){var i,e;return!(null===(i=t.qu)||void 0===i?void 0:i.call(t))||!!(null===(e=d._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[t.config.token])||void 0===e?void 0:e.config)}},()=>function(t){var i;const e={};if(e.distinctId=t.get_distinct_id(),t.sessionManager){const{sessionId:i,windowId:s,sessionStartTimestamp:n,lastActivityTimestamp:r}=t.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i,e.windowId=s,F(n)||(e.sessionStartTimestamp=n),F(r)||(e.lastActivityTimestamp=r)}if((null==d||null===(i=d.location)||void 0===i?void 0:i.href)&&(e.currentUrl=t.config.disable_capture_url_hashes?vi(d.location.href):d.location.href),t.featureFlags){const i=t.featureFlags.getFlags();i&&i.length>0&&(e.activeFeatureFlags=i)}return e}(t)),this._instance=t,this.name=uh,this.Fv()}get Rv(){return this._instance.__loaded}Av(){const t=Bs("[logs]"),i=null==d?void 0:d.__PosthogExtensions__;if(!i)return void t.error("PostHog Extensions not found.");const e=i.loadExternalDependency;if(e)return t=>{e(this._instance,"logs",e=>{const s=i.logs;t(e,(null==s?void 0:s.initializeLogs)?{initialize:t=>s.initializeLogs(t),replay(t,i){var e;return null===(e=s.replayConsoleBuffer)||void 0===e?void 0:e.call(s,t,i)}}:void 0)})};t.error(Ys)}}},Rc={metrics:class{constructor(t){this._instance=t,this.$=Bs("[metrics]"),this.Ci=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.Ci)return;const i=!!(null===(t=this._instance.config.metrics)||void 0===t?void 0:t.network);i&&!this.eg?this.eg=(t=>{let i=!0;const e=()=>i?(t=>{var i;const e=null===(i=t.config.metrics)||void 0===i?void 0:i.network;return!0===e?{}:e||void 0})(t):void 0,s=ec(t,e),n=sc(t,e);return()=>{i=!1,s(),n()}})(this._instance):!i&&this.eg&&(this.eg(),this.eg=void 0)}Lv(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.metrics;var e;return this.Ev&&this.Nv===i||(null===(e=this.Ev)||void 0===e||e.reset(),this.Nv=i,this.Ev=new Ns(this.Dv(),function(t){var i,e,s,n,r;const o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(i),this.$)),this.Ev}count(t,i=1,e){this.Lv().count(t,i,e)}gauge(t,i,e){this.Lv().gauge(t,i,e)}histogram(t,i,e){this.Lv().histogram(t,i,e)}flush(t){if(!this.Ev)return Promise.resolve();if(t){const i=this.Ev.drainWindow();return i&&this.po(i,t),Promise.resolve()}return this.Ev.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var t;null===(t=this.Ev)||void 0===t||t.reset()}dispose(){var t,i;this.Ci=!0,null===(t=this.eg)||void 0===t||t.call(this),this.eg=void 0,null===(i=this.Ev)||void 0===i||i.reset()}Dv(){const t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},po:t=>i.po(t),getLibraryId:()=>Gs.LIB_NAME,getLibraryVersion:()=>Gs.LIB_VERSION}}po(t,i){return new Promise(e=>{let s=!1;const n=t=>{s||(s=!0,clearTimeout(r),e(t))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(wi(wi({method:"POST",url:this.ig(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i}),{},{fireCallbackOnDrop:!0,callback(t){const i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error(`metrics request failed with status ${i}`)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`metrics request failed with status ${i}`)})}}}))})}ig(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Oc={webMCP:class{constructor(t){this._instance=t,this.ng=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.ng)return;const t=null==s?void 0:s.modelContext;if(!t||!T(t.registerTool))return;const i=nc.get(t);if(i)return i.instances.add(this._instance),void(this.ng=!0);const e={instances:new Set([this._instance])},n=t.registerTool,r=this;qh(t,"registerTool",t=>{const i=t;return function(t,...s){let n=t;try{n=r.sg(t,e)}catch(e){return i.call(this,t,...s)}return i.call(this,n,...s)}}),t.registerTool!==n&&(nc.set(t,e),this.ng=!0)}sg(t,i){if(!t||!T(t.execute))return t;const e=t.execute,s=this,{tool:n,injected:r}=function(t,i){const e={intent:!1,model:!1},s=t.inputSchema;if(!function(t){return!!R(t)||P(t)&&Object.keys(t).every(t=>rc.has(t)||t.startsWith("x-"))&&!0!==t.additionalProperties&&!P(t.additionalProperties)&&(!t.type||"object"===t.type)&&(!t.properties||P(t.properties))&&(!t.required||k(t.required))}(s))return{tool:hc(t),injected:e};const n=(null==s?void 0:s.properties)||{},r=t=>uc(n,t)||k(null==s?void 0:s.required)&&s.required.includes(t);if(e.intent=i.intent&&!r("context"),e.model=i.model&&!r("llm_model"),!e.intent&&!e.model)return{tool:hc(t),injected:e};const o=wi({},n),l=k(null==s?void 0:s.required)?[...s.required]:[];return e.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},l.includes("context")||l.push("context")),e.model&&(o.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},l.includes("llm_model")||l.push("llm_model")),{tool:hc(t,wi(wi({},s),{},{type:(null==s?void 0:s.type)||"object",properties:o,required:l})),injected:e}}(t,function(t){const i={intent:!1,model:!1};for(const e of t.instances){const t=ac(e.config.capture_webmcp);i.intent||(i.intent=!0===(null==t?void 0:t.intent)),i.model||(i.model=!0===(null==t?void 0:t.model))}return i}(i));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const l=new Date,a=function(t,i){if(!P(t))return{};try{const e=i.intent?dc(t.context,2048,!0):void 0,s=i.model?dc(t.llm_model,256):void 0;return wi(wi({},e&&"{}"!==e?{intent:e}:{}),s&&"unknown"!==s.toLowerCase()?{model:s}:{})}catch(t){return{}}}(o[0],r),u=function(t,i){const e=t[0];if(!P(e))return t;try{const s=i.intent&&uc(e,"context"),n=i.model&&uc(e,"llm_model");if(!s&&!n)return t;const r=wi({},e);return s&&delete r.context,n&&delete r.llm_model,[r,...t.slice(1)]}catch(i){return t}}(o,r);let h;try{h=e.apply(this===n?t:this,u)}catch(t){throw s.rg(i,n,l,{error:t,errorResult:!1},a),t}if((d=h)&&"function"==typeof d.then)return Promise.resolve(h).then(t=>{const e=cc(t)?{error:t,errorResult:!0}:void 0;return s.rg(i,n,l,e,a),t},t=>{throw s.rg(i,n,l,{error:t,errorResult:!1},a),t});var d;const c=cc(h)?{error:h,errorResult:!0}:void 0;return s.rg(i,n,l,c,a),h}}),n}rg(t,i,e,s,r){const o=Date.now()-e.getTime();let l;for(const u of t.instances){var a;const t=ac(u.config.capture_webmcp);if(t){s&&!l&&(l=gc(s.error,s.errorResult));try{u.capture("$mcp_tool_call",wi(wi(wi({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==n?void 0:n.hostname,$mcp_duration_ms:o,$mcp_is_error:!!s},l?{$mcp_error_type:l.type,$mcp_error_message:l.message}:{}),t.intent&&r.intent?{$mcp_intent:r.intent,$mcp_intent_source:"context_parameter"}:{}),t.model&&r.model?{$mcp_llm_model:r.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:e})}catch(t){continue}if(s&&l&&u.exceptions&&(null===(a=u.exceptionObserver)||void 0===a?void 0:a.isEnabled))try{const t={$exception_list:pc(u.exceptions,s,l.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==n?void 0:n.hostname};u.exceptionObserver.captureException(t)}catch(t){}}}}}};Ah.__defaultExtensionClasses=wi({},wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi({},mc),yc),bc),wc),$c),Sc),Ec),xc),kc),Tc),Pc),Cc),Rc),Oc));const Ac=function(){Gs.SDK_DIST_CHANNEL="npm";const i=ch[kh]=new Ah;return function(){function i(){i.done||(i.done=!0,Pu=!1,Dr(ch,function(t){t._dom_loaded()}))}(null==s?void 0:s.addEventListener)?"complete"===s.readyState?i():qr(s,"DOMContentLoaded",i,{capture:!1}):t&&Us.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),i}();var Ic=Ac;export{ua as Compression,$a as DEFAULT_PRODUCT_TOUR_APPEARANCE,ba as DisplaySurveyType,Ah as PostHog,Sa as ProductTourEventName,xa as ProductTourEventProperties,ma as SurveyEventName,ya as SurveyEventProperties,ha as SurveyEventType,ca as SurveyPosition,_a as SurveyQuestionBranchingType,pa as SurveyQuestionType,ga as SurveySchedule,va as SurveyTabPosition,fa as SurveyType,da as SurveyWidgetType,Ic as default,Ac as posthog,Ca as severityLevels};
2
2
  //# sourceMappingURL=module.js.map