@maxceem/agw 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +63 -0
- package/dist/agw.mjs +18815 -0
- package/dist/release/0.1.0/console/.assetsignore +1 -0
- package/dist/release/0.1.0/console/assets/endpoints-zOm2MGG0.js +12 -0
- package/dist/release/0.1.0/console/assets/index-CZYi3Ga7.js +98 -0
- package/dist/release/0.1.0/console/assets/index-CsWBdB28.css +2 -0
- package/dist/release/0.1.0/console/assets/module-DY58MOwM.js +2 -0
- package/dist/release/0.1.0/console/assets/usage-x48kOqlj.js +42 -0
- package/dist/release/0.1.0/console/favicon.svg +22 -0
- package/dist/release/0.1.0/console/index.html +34 -0
- package/dist/release/0.1.0/manifest.json +23 -0
- package/dist/release/0.1.0/migrations/0000_initial.sql +315 -0
- package/dist/release/0.1.0/worker/index.js +86772 -0
- package/dist/release/0.1.0/wrangler.json +82 -0
- package/dist/release-integrity.json +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=`u`>typeof window?window:void 0,t=`u`>typeof globalThis?globalThis:e,n=t?.navigator,r=t?.document,i=t?.location,a=t?.fetch,o=t?.XMLHttpRequest&&`withCredentials`in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,s=t?.AbortController,c=t?.CompressionStream,l=n?.userAgent;function u(){return!(!e||!1===e.navigator.onLine)}var d=typeof globalThis<`u`?globalThis:e;d&&typeof self>`u`&&(d.self=d),d&&typeof File>`u`&&(d.File=function(){});var f=e??{},p=`0.8.2`,m={DEBUG:!1,LIB_VERSION:p,LIB_NAME:`browser-common`,JS_SDK_VERSION:p},h=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.AiQueue=`ai_queue`,e.AiCaptureQueue=`ai_capture_queue`,e.LogsQueue=`logs_queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.PushRegistered=`push_registered`,e.SessionReplayEventTriggerActivatedSession=`session_replay_event_trigger_activated_session`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e.DeviceId=`device_id`,e}({}),g=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),_=[`$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`],v=[`token`];function y(e,t){return e.indexOf(t)!==-1}var b=function(e){return e.trim()},x=function(e){return e.replace(/^\$/,``)};function S(e){let t=[];return JSON.stringify(e,function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n}})??`null`}var C=Object.prototype,w=C.hasOwnProperty,ee=C.toString,T=Array.isArray||function(e){return ee.call(e)===`[object Array]`},E=e=>typeof e==`function`,D=e=>e===Object(e)&&!T(e),O=e=>{if(D(e)){for(let t in e)if(w.call(e,t))return!1;return!0}return!1},k=e=>e===void 0,A=e=>ee.call(e)==`[object String]`,j=e=>A(e)&&e.trim().length===0,M=e=>e===null,N=e=>k(e)||M(e),P=e=>ee.call(e)==`[object Number]`&&e==e,te=e=>P(e)&&e>0,F=e=>ee.call(e)===`[object Boolean]`,ne=e=>y(_,e),re=e=>y(v,e);function ie(e){return typeof e!=`object`||!e}function I(e,t){return{}.toString.call(e)===`[object ${t}]`}function ae(e){switch({}.toString.call(e)){case`[object Error]`:case`[object Exception]`:case`[object DOMException]`:case`[object DOMError]`:case`[object WebAssembly.Exception]`:return!0;default:return se(e,Error)}}function oe(e){return`u`>typeof Event&&se(e,Event)}function se(e,t){try{return e instanceof t}catch{return!1}}var ce=[!0,`true`,1,`1`,`yes`],le=e=>y(ce,e),ue=[!1,`false`,0,`0`,`no`];function de(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function L(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){de(a,r,i,o,s,`next`,e)}function s(e){de(a,r,i,o,s,`throw`,e)}o(void 0)})}}var fe=`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`.split(`,`),pe=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return fe.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})};function me(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),P(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),me(i??n,t,n,r))}var he=class{constructor(e){this.C={},this.I=e.I,this.R=me(e.bucketSize,0,100,e.$),this.A=me(e.refillRate,0,this.R,e.$),this.O=me(e.refillInterval,0,864e5,e.$)}F(e,t){let n=Math.floor((t-e.lastAccess)/this.O);n>0&&(e.tokens=Math.min(e.tokens+n*this.A,this.R),e.lastAccess+=n*this.O)}consumeRateLimit(e){var t;let n=Date.now(),r=String(e),i=this.C[r];return i?this.F(i,n):(i={tokens:this.R,lastAccess:n},this.C[r]=i),i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.I)==null||t.call(this,e)),i.tokens===0)}stop(){this.C={}}},ge=`Mobile`,_e=`Android`,ve=`Tablet`,ye=`Android Tablet`,be=`iPad`,xe=`Apple Watch`,Se=`Safari`,Ce=`BlackBerry`,we=`Samsung Internet`,Te=`Chrome`,Ee=`Chrome iOS`,De=`Internet Explorer`,Oe=`Internet Explorer Mobile`,ke=`Opera`,Ae=`Microsoft Edge`,je=`Firefox`,Me=`Firefox iOS`,Ne=`Nintendo`,Pe=`PlayStation`,Fe=`Xbox`,Ie=`Android Mobile`,Le=`Mobile Safari`,Re=`Windows`,ze=`Windows Phone`,Be=`Nokia`,Ve=`Ouya`,He=`Generic `+ge.toLowerCase(),Ue=`Generic `+ve.toLowerCase(),We=`Konqueror`,Ge=`Oculus Browser`,Ke=`Vivaldi`,qe=`Yandex`,Je=`Whale`,Ye=`DuckDuckGo`,Xe=`Pale Moon`,Ze=`Waterfox`,Qe=`Brave`,$e=`Claude`,et=`Codex`,tt=`ChatGPT`,nt=`Google Search App`,rt=RegExp(`Version/(\\d+(\\.\\d+)?)`),it=RegExp(`(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)`),at=new RegExp(Fe,`i`),ot=RegExp(`PlayStation \\w+`,`i`),st=RegExp(`Nintendo \\w+`,`i`),ct=RegExp(`BlackBerry|PlayBook|BB10`,`i`),lt={"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`},ut=function(e,t,n,r){return t||=``,function(e){return e?.brave?Qe:null}(n)||(r?.detectGoogleSearchApp&&y(e,`GSA/`)?nt:y(e,` OPR/`)&&y(e,`Mini`)?`Opera Mini`:y(e,` OPR/`)?ke:ct.test(e)?Ce:y(e,`IEMobile`)||y(e,`WPDesktop`)?Oe:y(e,`OculusBrowser`)?Ge:y(e,`SamsungBrowser`)?we:y(e,`Edge`)||y(e,`Edg/`)?Ae:y(e,`Vivaldi/`)?Ke:y(e,`YaBrowser/`)?qe:y(e,`Whale/`)?Je:y(e,`DuckDuckGo/`)||y(e,`Ddg/`)?Ye:y(e,`Claude/`)?$e:y(e,`Codex/`)?et:y(e,`ChatGPT/`)?tt:y(e,`FBIOS`)?`Facebook Mobile`:y(e,`UCWEB`)||y(e,`UCBrowser`)?`UC Browser`:y(e,`CriOS`)?Ee:y(e,`CrMo`)||y(e,Te)?Te:y(e,_e)&&y(e,Se)?Ie:y(e,`FxiOS`)?Me:y(e.toLowerCase(),We.toLowerCase())?We:y(e,`Brave/`)?Qe:((e,t)=>t&&y(t,`Apple`)||function(e){return y(e,Se)&&!y(e,Te)&&!y(e,_e)}(e))(e,t)?y(e,ge)?Le:Se:y(e,`PaleMoon/`)?Xe:y(e,`Waterfox/`)?Ze:y(e,je)?je:y(e,`MSIE`)||y(e,`Trident/`)?De:y(e,`Gecko`)?je:``)},dt={[Oe]:[RegExp(`rv:(\\d+(\\.\\d+)?)`)],[Ae]:[RegExp(`Edge?\\/(\\d+(\\.\\d+)?)`)],[Te]:[RegExp(`(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)`)],[Ee]:[RegExp(`CriOS\\/(\\d+(\\.\\d+)?)`)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)`)],[Se]:[rt],[Le]:[rt],[ke]:[RegExp(`(Opera|OPR)\\/(\\d+(\\.\\d+)?)`)],[je]:[RegExp(`Firefox\\/(\\d+(\\.\\d+)?)`)],[Me]:[RegExp(`FxiOS\\/(\\d+(\\.\\d+)?)`)],[We]:[RegExp(`Konqueror[:/]?(\\d+(\\.\\d+)?)`,`i`)],[Ce]:[RegExp(`BlackBerry (\\d+(\\.\\d+)?)`),rt],[Ie]:[RegExp(`android\\s(\\d+(\\.\\d+)?)`,`i`)],[we]:[RegExp(`SamsungBrowser\\/(\\d+(\\.\\d+)?)`)],[Ge]:[RegExp(`OculusBrowser\\/(\\d+(\\.\\d+)?)`)],[Ke]:[RegExp(`Vivaldi\\/(\\d+(\\.\\d+)?)`)],[qe]:[RegExp(`YaBrowser\\/(\\d+(\\.\\d+)?)`)],[Je]:[RegExp(`Whale\\/(\\d+(\\.\\d+)?)`)],[Qe]:[RegExp(`Brave\\/(\\d+(\\.\\d+)?)`)],[$e]:[it],[et]:[it],[tt]:[it],[Ye]:[RegExp(`(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)`)],[Xe]:[RegExp(`PaleMoon\\/(\\d+(\\.\\d+)?)`)],[Ze]:[RegExp(`Waterfox\\/(\\d+(\\.\\d+)?)`)],[nt]:[RegExp(`GSA\\/(\\d+(\\.\\d+)?)`)],[De]:[RegExp(`(rv:|MSIE )(\\d+(\\.\\d+)?)`)],Mozilla:[RegExp(`rv:(\\d+(\\.\\d+)?)`)]},ft=function(e,t,n,r){let i=dt[ut(e,t,n,r)];if(k(i))return null;for(let t=0;i.length>t;t++){let n=e.match(i[t]);if(n)return parseFloat(n[n.length-2])}return null},pt=[[RegExp(`Xbox; Xbox (.*?)[);]`,`i`),e=>[Fe,e&&e[1]||``]],[new RegExp(Ne,`i`),[Ne,``]],[new RegExp(Pe,`i`),[Pe,``]],[ct,[Ce,``]],[new RegExp(Re,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ze,``];if(new RegExp(ge).test(t)&&!/IEMobile\b/.test(t))return[`Windows Mobile`,``];let n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let e=lt[n[1]]||``;return/arm/i.test(t)&&(e=`RT`),[Re,e]}return[Re,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[`iOS`,[e[3],e[4],e[5]||`0`].join(`.`)]:[`iOS`,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t=``;return e&&e.length>=3&&(t=k(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`),e=>e&&e[2]?[_e,[e[2],e[3],e[4]||`0`].join(`.`)]:[_e,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[`Chrome OS`,``]],[/Linux|debian/i,[`Linux`,``]]],mt=function(e){for(let t=0;pt.length>t;t++){let[n,r]=pt[t],i=n.exec(e),a=i&&(E(r)?r(i,e):r);if(a)return a}return[``,``]},ht=function(e){return st.test(e)?Ne:ot.test(e)?Pe:at.test(e)?Fe:new RegExp(Ve,`i`).test(e)?Ve:RegExp(`(Windows Phone|WPDesktop)`,`i`).test(e)?ze:/iPad/.test(e)?be:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?xe:ct.test(e)?Ce:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Be,`i`).test(e)?Be:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(ge).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?_e:ye:RegExp(`(pda|Mobile)`,`i`).test(e)?He:new RegExp(ve,`i`).test(e)&&!RegExp(`Tablet pc`,`i`).test(e)?Ue:``},gt=function(e,t){let n=ht(e);return n===be||n===ye||n===`Kobo`||n===`Kindle Fire`||n===Ue?ve:n===Ne||n===Fe||n===Pe||n===Ve?`Console`:n===xe?`Wearable`:n?ge:t?.userAgentDataPlatform===`Android`&&(t?.maxTouchPoints??0)>0?600>Math.min((r=t?.screenWidth)??0,(i=t?.screenHeight)??0)/((a=t?.devicePixelRatio)??1)?ge:ve:`Desktop`;var r,i,a},_t=/\bFBAV\/(\d+(?:\.\d+)*)/i,vt=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,`Instagram`],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,`Threads`],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,`Messenger`,_t],[/\bFBAN\/EMA\b/i,`Facebook Lite`,_t],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,`Facebook`,_t],[/\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`]],yt=`[Truncated]`,bt=`[Unserializable]`;function xt(e){let t=``;for(let n=0;e.length>n;n++){let r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:`�`;else{let r=e.charCodeAt(n+1);56320>r||r>57343?t+=`�`:(t+=e[n]+e[n+1],n++)}}return t}function St(e,t){if(!t)return e;let n=[];try{n=Object.keys(t)}catch{n=[]}for(let r of n){let n;try{n=t[r]}catch{n=bt}Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return e}var Ct=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function wt(e,t){return typeof(n=e)==`string`&&Ct.test(n)?e:t();var n}function Tt(e,t){let n=Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function Et(e){return e&&e.split(`#`)[0]}function Dt(e,t){let n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}function Ot(e,t,n){return kt.apply(this,arguments)}function kt(){return(kt=L(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((e,i)=>{r=Dt(()=>{try{n?.(),e()}catch(e){i(e)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}var At,jt,Mt;function Nt(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return Mt&&n.length===jt||(jt=n.length,Mt=n.reduce((n,r)=>{At||={};let i=At[r];if(i)n[i[0]]=i[1];else{let i=e(r);for(let e=i.length-1;e>=0;e--){let a=i[e]?.filename,o=t[r];if(a&&o){n[a]=o,At[r]=[a,o];break}}}return n},{})),Mt}function Pt(e){return Pt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Pt(e)}function Ft(e,t,n){return(t=function(e){var t=function(e){if(Pt(e)!=`object`||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,`string`);if(Pt(n)!=`object`)return n;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}(e);return Pt(t)==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;arguments.length>t;t++){var n=arguments[t]==null?{}:arguments[t];t%2?It(Object(n),!0).forEach(function(t){Ft(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):It(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Lt=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){let n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return L(function*(){for(let n of e)n.stacktrace&&n.stacktrace.frames&&T(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e})()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){let n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),R(R({},e),{},{cause:n,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(let n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return L(function*(){let n=e;for(let e of t.modifiers)n=yield e(n);return n})()}convertToExceptionList(e,t){var n,r;let i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});let a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,R(R({},t),{},{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:Nt(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n=0){let r=(n,r)=>{if(4>=r){let i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return R(R({},t),{},{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},Rt=/^([a-z][a-z0-9.+-]+):/i,zt=[`http`,`https`,`file`,`blob`,`app`,`capacitor`,`ionic`,`webpack`,`webpack-internal`,`ng`];function Bt(e){if(!e||e===`<anonymous>`)return!1;let t=Rt.exec(e);return!t||zt.includes(t[1].toLowerCase())}function Vt(e,t,n,r,i){let a={platform:e,filename:t,function:n===`<anonymous>`?`?`:n,in_app:Bt(t)};return k(r)||(a.lineno=r),k(i)||(a.colno=i),a}var Ht=(e,t)=>{let n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?`?`:e.split(`@`)[0],n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Ut=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Gt=/\((\S*)(?::(\d+))(?::(\d+))\)/,Kt=(e,t)=>{let n=Ut.exec(e);if(n){let[,e,r,i]=n;return Vt(t,e,`?`,+r,+i)}let r=Wt.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){let e=Gt.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}let[e,n]=Ht(r[1]||`?`,r[2]);return Vt(t,n,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},qt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Jt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Yt=(e,t)=>{let n=qt.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){let e=Jt.exec(n[3]);e&&(n[1]=n[1]||`eval`,n[3]=e[1],n[4]=e[2],n[5]=``)}let e=n[3],r=n[1]||`?`;return[r,e]=Ht(r,e),Vt(t,e,r,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Xt=/\(error: (.*)\)/;function Zt(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Qt(e){for(let t=1;10>=t;t++){let n=e.length-2*t;if(0>n)break;let r=!0;for(let i=0;t>i;i++)if(!Zt(e[n+i],e[n+t+i])){r=!1;break}if(r){for(let r=0;t>r;r++)e[n+r]=e[n+t+r];return e.length=n+t,{start:n,length:t}}}}function $t(e,t){let n=t.start+t.length,r=tn(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function en(e,t){let n=t.start;for(;n>0&&Zt(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function tn(e,t){let n=t.start+t.length,r=n;for(;e.length>r&&Zt(e[r],e[r-t.length]);)r++;return r-n}function nn(e,t){let n=t[0],r=e.length-(n?en(e,n):0);for(let n of t)r-=tn(e,n);return r}function rn(e,t,n){for(let r=0;e.length>r;r++){let i=e[(t+r)%e.length],a=e[(n+r)%e.length];if(i!==a)return a>i}return!1}var an=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){let n=A(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){let t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?`${t}: ${e.message}`:t}isDOMException(e){return I(e,`DOMException`)}isDOMError(e){return I(e,`DOMError`)}},on=class{match(e){return ae(e)}coerce(e,t){let n=this.getStack(e),r=n===void 0;return{type:this.getType(e),value:this.getMessage(e,t),stack:n??t.syntheticException?.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},sn=class{match(e){return!!I(e,`ErrorEvent`)&&(e.error!=null||this.lr(e))}coerce(e,t){if(e.error!=null)return t.apply(e.error);let n=t.apply(e.message);return R(R({},n),{},{stack:this.ur(e)??n.stack,synthetic:!0})}lr(e){return A(e.message)&&e.message.length>0}ur(e){let t=e,n=t.lineno??0,r=t.colno??0;if(A(t.filename)&&t.filename.length!==0&&n!==0)return`Error\n at ${t.filename}:${n}:${r}`}},cn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ln=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(cn);return r&&(t=r[1],n=r[2]),[t,n]}},un=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function dn(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(t>=r.length)return e===n.length?r:r.length>t?`${r.slice(0,t)}...`:r}return``}var fn=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:this.getStack(e)??t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){if(oe(e))return e.constructor.name;let t=`name`in e?e.name:void 0;return A(t)&&!j(t)?t:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${dn(e)}`}isSeverityLevel(e){return A(e)&&!j(e)&&un.indexOf(e)>=0}getStack(e){try{return A(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:A(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(let t in e)if({}.hasOwnProperty.call(e,t)){let n=e[t];if(ae(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},pn=class{match(e){return oe(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${dn(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},mn=class{match(e){return ie(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},hn=class{match(e){return I(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!oe(e))return!1;try{let t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){let n=this.getUnhandledRejectionReason(e);return ie(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},gn=`$message`,_n=`$timestamp`,vn=new Set([gn,_n]),yn={enabled:!0,max_bytes:32768};function bn(e){return e?{enabled:e.enabled??yn.enabled,max_bytes:Sn(e.max_bytes,yn.max_bytes)}:R({},yn)}var xn=class{constructor(e){this.ts=[],this.es=0,this.Mr=bn(e)}setConfig(e){this.Mr=bn(e),this.ns()}add(e){let t=function(e){let t;try{t=S(e)}catch{return}try{let e=JSON.parse(t);if(!D(e))return;let n=e,r=n[gn],i=n[_n];return!A(r)||r.trim().length===0||!A(i)&&!P(i)?void 0:{step:n,json:t}}catch{return}}(e);if(!t)return;let n=function(e){if(`u`>typeof TextEncoder)return new TextEncoder().encode(e).length;let t=encodeURIComponent(e),n=0;for(let e=0;t.length>e;e++)t[e]===`%`?(n+=1,e+=2):n+=1;return n}(t.json);n>this.Mr.max_bytes||(this.ts.push({step:t.step,bytes:n}),this.es+=n,this.ns())}getAttachable(){return this.ts.map(e=>e.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Mr.max_bytes&&this.ts.length>0;){let e=this.ts.shift();e&&(this.es-=e.bytes)}}};function Sn(e,t){if(!P(e)||e===1/0||e===-1/0)return t;let n=Math.floor(e);return 0>n?t:n}var Cn=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function wn(e){return typeof e==`string`||e}function Tn(e){return typeof e==`string`?e:void 0}var En=`$feature_flag.$feature_flag_response.$feature_flag_has_experiment.$feature_flag_id.$feature_flag_version.$feature_flag_reason.$feature_flag_request_id.$feature_flag_evaluated_at.$feature_flag_error.locally_evaluated.$groups.$process_person_profile.$geoip_disable.$current_url.$pathname.$referring_domain.utm_source.utm_medium.utm_campaign.utm_content.utm_term.gad_source.mc_cid.gclid.gclsrc.dclid.gbraid.wbraid.fbclid.msclkid.twclid.li_fat_id.igshid.ttclid.rdt_cid.epik.qclid.sccid.irclid._kx.$session_id.$window_id.$lib.$lib_version.$device_id.$is_server`.split(`.`),Dn=`NativeGzipValidationError`,On=e=>e.length>=2&&e[0]===31&&e[1]===139,kn=(e,t)=>e===g.GZipJS||t===g.GZipJS||t===`gzip`,An=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,jn,Mn=e=>{throw Tt(Dn,`Native gzip produced invalid output: ${e}`)},Nn=(Pn=L(function*(e,t){18>e.size&&Mn(`too-short`);let n=new Uint8Array(yield e.slice(0,10).arrayBuffer());On(n)&&n[2]===8||Mn(`invalid-header`);let r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{let t=(()=>{if(jn)return jn;jn=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;jn[e]=t>>>0}return jn})(),n=4294967295;for(let r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&Mn(`invalid-crc`);let i=t.length>>>0;r.getUint32(4,!0)!==i&&Mn(`invalid-size`)}),function(e,t){return Pn.apply(this,arguments)}),Pn;function Fn(){return Fn=L(function*(e,t=!0,n){try{let t=new TextEncoder().encode(e),n=new globalThis.CompressionStream(`gzip`),i=n.writable.getWriter(),a=i.write(t).then(()=>i.close()).catch((r=L(function*(e){try{yield i.abort(e)}catch{}throw e}),function(e){return r.apply(this,arguments)})),o=new Response(n.readable).blob(),[s]=yield Promise.all([o,a]);return yield Nn(s,t),s}catch(e){if(n?.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}var r}),Fn.apply(this,arguments)}var In=3e5,Ln=class{record(e){if(e.kind===`too-large`)return;if(e.kind!==`retry-later`)return void this.reset();if(!e.retryAfterMs)return;let t=this.isOpen(),n=Date.now(),r=Math.min(e.retryAfterMs,In);if(!t)return this.ss=n,void(this.rs=n+r);this.rs=Math.max(this.rs,Math.min(n+r,this.ss+In))}remainingMs(){let e=Date.now();if(this.ss-5e3>e)return this.reset(),0;let t=Math.min(In,Math.max(0,this.rs-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.rs=0,this.ss=0}constructor(){this.rs=0,this.ss=0}};function Rn(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;a.length>r;r++)t.includes(n=a[r])||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var zn={}.propertyIsEnumerable;function Bn(e,t){try{return Un(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Vn(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:yt};if(n.remainingNodes--,F(e))return{boolValue:e};if(typeof e==`bigint`)return function(e,t){let n=e.toString(),r=BigInt(`9223372036854775808`);return e>=r||-r>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}(e,t);if(typeof e==`number`){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>`u`)return{stringValue:String(e)};let n=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:e}}if(typeof e==`string`)return{stringValue:xt(e)};if(typeof e==`function`)return{stringValue:`[Function]`};if(typeof e==`symbol`)return{stringValue:String(e)};if(typeof e==`object`&&e){if(n.ancestors.has(e))return{stringValue:`[Circular]`};if(r>=20)return{stringValue:yt};if(e instanceof Date){let t=e.getTime(),n=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:typeof n==`string`?xt(n):String(n)}}n.ancestors.add(e);try{try{let i=e.toJSON;if(typeof i==`function`)return Vn(i.call(e),t,n,r+1)}catch{}return T(e)?{arrayValue:{values:Hn(e,t,n,r+1)}}:{kvlistValue:{values:Un(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:xt(String(e))}}function Hn(e,t,n,r){let i=[],a=Math.min(e.length,1e3),o=0;for(;a>o&&n.remainingNodes>0;o++)try{let a=o in e?e[o]:void 0;if(N(a))continue;i.push(Vn(a,t,n,r))}catch{i.push({stringValue:bt})}return e.length>o&&i.push({stringValue:yt}),i}function Un(e,t,n,r){let i=[];for(let a in e)if(zn.call(e,a)){if(!a){t?.debug(`Dropping an attribute with an empty key`);continue}if(i.length>=1e3||0>=n.remainingNodes){t?.debug(`Attributes truncated: the value exceeds the OTLP encoder budget`);break}try{let o=e[a];if(M(o)||k(o))continue;i.push({key:xt(a),value:Vn(o,t,n,r)})}catch{i.push({key:xt(a),value:{stringValue:bt}})}}return i}function Wn(e,t,n){return R(R(R(R({},St({},e.resourceAttributes)),{},{"service.name":e.serviceName||`unknown_service`},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}var Gn=[`service.name`,`deployment.environment`,`service.version`,`telemetry.sdk.name`,`telemetry.sdk.version`];function Kn(e,t){let n=St({},e),r={};for(let e of Gn)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e],delete n[e]);return[...Bn(n,t),...Bn(r,t)]}var qn={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`},Jn={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}},Yn=Jn.info;function Xn(e){try{return xt(String(e))}catch{return bt}}function Zn(e,t,n,r){let{text:i,number:a}=Jn[e.level||`info`]||Yn,o=function(e=Date.now()){return String(e)+`000000`}(P(r)?r:void 0),s={};t.distinctId&&(s.posthogDistinctId=t.distinctId),t.sessionId&&(s.sessionId=t.sessionId),t.windowId&&(s[`window.id`]=t.windowId),N(t.sessionStartTimestamp)||(s.sessionStartTimestamp=String(t.sessionStartTimestamp)),N(t.lastActivityTimestamp)||(s.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(s[`url.full`]=t.currentUrl),t.screenName&&(s[`screen.name`]=t.screenName),t.appState&&(s[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(s.feature_flags=t.activeFeatureFlags);let c=R({},s),l=e.attributes;if(l){let e=[];try{e=Object.keys(l)}catch{e=[]}for(let t of e){let e;try{e=l[t]}catch{e=bt}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}let u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:a,severityText:i,body:{stringValue:Xn(e.body)},attributes:Bn(c,n)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),k(e.trace_flags)||(u.flags=e.trace_flags),u}function Qn(e,t,n){return Wn(e,t,n)}function $n(e,t,n,r){return{resourceLogs:[{resource:{attributes:Kn(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var er=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=Dt(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&=(clearTimeout(this.hs),void 0)}};function tr(){return .75+.5*Math.random()}function nr(e,t,n,r){let i=e*2**Math.min(Math.max(0,t-1),6);return Math.round((r===void 0?i:Math.min(i,Math.max(r,e)))*n)}var rr=class{constructor(e,t,n,r,i,a=()=>Promise.resolve(),o){this._instance=e,this.Mr=t,this.$=n,this.cs=r,this.ds=i,this.vs=a,this.fs=o,this.ps=new er(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Ln,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=t.maxBufferSize,this.Is=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(h.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;let n=this.Os(e);if(n===null)return;if(!n.body)return void this.$.info(`Log was rejected in beforeSend function`);if(!this.Ds())return;let r={record:Zn(n,t?.context??this.cs(),this.$,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){let t=this.Mr.beforeSend;if(!t)return e;let n=T(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this.$.info(`Log was rejected in beforeSend function`),null;r=t}catch(e){return this.$.error(`Error in beforeSend function for log:`,e),null}return r}Ds(){if(this.Rs===void 0)return!0;let e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||=(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),!0),!1)}flush(){var e=this;return L(function*(){if(!e._instance.isDisabled)return e.ys||=e.Ns().finally(()=>{e.ys=null}),e.ys})()}Ns(){var e=this;return L(function*(){e.ps.clear();let t=e._instance.getPersistedProperty(h.LogsQueue)??[];if(t.length===0)return;let n=t.length,r=0;for(;t.length>0&&n>r;){let n=e._s;e.bs=0;let i=Math.min(t.length,e.Es),a=t.slice(0,i),o=$n(a.map(e=>e.record),e.qs(),e.fs??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance.js(o);if(e._s!==n)return;if(s.kind===`too-large`&&a.length>1)e.Es=Math.max(1,Math.floor(a.length/2)),e.$.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(s),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),s.kind===`retry-later`||(s.kind===`too-large`?e.$.warn(`Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further.`):s.kind===`ok`&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(a.length),t=e._instance.getPersistedProperty(h.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}})()}Bs(e){var t=this;return L(function*(){let n=Math.max(0,e-t.bs),r=t._instance.getPersistedProperty(h.LogsQueue)??[];t._instance.setPersistedProperty(h.LogsQueue,r.slice(n)),yield t.vs()})()}qs(){return Qn(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){if(this._instance.optedOut)return;let t=this._instance.getPersistedProperty(h.LogsQueue)??[];this.Is>t.length||(t.shift(),this.bs++,this.$.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(h.LogsQueue,t),this.Ts>t.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(nr(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){let e=this._instance.getPersistedProperty(h.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return L(function*(){t.ps.clear();let n=t.flush().catch(()=>{});e===void 0?yield n:yield Ot(n,e)})()}flushWithTimeout(e){var t=this;return L(function*(){let n=t.flush();yield Ot(n,e,()=>{n.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=tr(),this.$.error(`PostHog logs flush failed:`,e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}},ir=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ar(e){return String(e)+`000000`}function or(e,t,n,r){let i=``;return r&&(i=Object.keys(r).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(r[e])}`).join(`,`)),`${e}\0${t}\0${n??``}\0${i}`}var sr=class{constructor(e,t,n){this._instance=e,this.Mr=t,this.$=n,this.zs=new Map,this.ps=new er(()=>this.flush().catch(e=>{this.$.error(`Metrics flush failed:`,e)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Ln,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,n){this.Zs({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this.Zs({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this.Zs({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this;let t=this.ys,n=function(){var n=L(function*(){t&&(yield t.catch(()=>{})),yield e.Qs()});return function(){return n.apply(this,arguments)}}()().finally(()=>{this.ys===n&&(this.ys=null)});return this.ys=n,n}drainWindow(){if(this.zs.size===0)return null;let e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(e){if(this._instance.isDisabled||this._instance.optedOut)return;let t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!=`string`)return void this.$.warn(`Dropping metric with empty name`);if(typeof t.value!=`number`||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type===`count`&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let n,r;try{n=t.attributes?R({},t.attributes):void 0,r=or(t.type,t.name,t.unit,n)}catch(e){this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e);return}let i=this.zs.get(r);if(!i){if(!this.Ks())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.zs.set(r,i)}let a=this.Ws.get(t.name);a===void 0?this.Ws.set(t.name,t.type):a===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.$.warn(`Metric name '${t.name}' is already used as a ${a}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Ys(i,t.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Ys(e,t){switch(e.type){case`count`:e.total=(e.total??0)+t;break;case`gauge`:e.last=t;break;case`histogram`:{e.hist||={count:0,sum:0,min:t,max:t,bucketCounts:Array(ir.length+1).fill(0)};let n=e.hist;n.count+=1,n.sum+=t,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.bucketCounts[function(e,t){for(let n=0;t.length>n;n++)if(t[n]>=e)return n;return t.length}(t,ir)]+=1;break}}}Os(e){let t=this.Mr.beforeSend;if(!t)return e;let n=T(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this.$.info(`Metric was rejected in beforeSend function`),null;r=t}catch(e){return this.$.error(`Error in beforeSend function for metric:`,e),null}return r}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(nr(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return L(function*(){if(e.ps.clear(),e.zs.size===0)return;let t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;let n=e.Gs,r=yield e._instance.Xs(e.Js(t));if(n===e.Gs)switch(e.ws.record(r),r.kind===`retry-later`?(e.ks++,e.Ss=tr()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),r.kind){case`ok`:return;case`retry-later`:e.lo(t),e.ps.armNoEarlierThan(e.Hs());return;case`too-large`:e.$.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e.$.error(`Failed to send metrics batch:`,r.error);return}})()}Js(e){return t=this.ao(e),n=function(e,t,n){return Wn(e,t,n)}(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Kn(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}ao(e){let t=ar(Date.now()),n=new Map;for(let r of e.values()){let e=or(r.type,r.name,r.unit,void 0),i=n.get(e);i||(i=R({name:r.name},r.unit&&{unit:r.unit}),r.type===`count`?i.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type===`gauge`?i.gauge={dataPoints:[]}:i.histogram={aggregationTemporality:1,dataPoints:[]},n.set(e,i));let a=Bn(r.attributes??{},this.$),o=ar(r.windowStartMs);if(r.type===`count`){let e={attributes:a,startTimeUnixNano:o,timeUnixNano:t,asDouble:r.total??0};i.sum.dataPoints.push(e)}else if(r.type===`gauge`){let e={attributes:a,timeUnixNano:t,asDouble:r.last??0};i.gauge.dataPoints.push(e)}else r.hist&&i.histogram.dataPoints.push({attributes:a,startTimeUnixNano:o,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:ir})}return Array.from(n.values())}lo(e){for(let[t,n]of e){let e=this.zs.get(t);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,n.windowStartMs),e.type){case`count`:e.total=(e.total??0)+(n.total??0);break;case`gauge`:break;case`histogram`:if(n.hist)if(e.hist){e.hist.count+=n.hist.count,e.hist.sum+=n.hist.sum,e.hist.min=Math.min(e.hist.min,n.hist.min),e.hist.max=Math.max(e.hist.max,n.hist.max);for(let t=0;e.hist.bucketCounts.length>t;t++)e.hist.bucketCounts[t]+=n.hist.bucketCounts[t]}else e.hist=n.hist}else this.Ks()&&this.zs.set(t,n)}}},cr=(t,{debugEnabled:n}={})=>{let r={N(r,...i){e&&(m.DEBUG||e.POSTHOG_DEBUG||n)&&!k(e.console)&&e.console&&(`__rrweb_original__`in e.console[r]?e.console[r].__rrweb_original__:e.console[r])(t,...i)},debug(...e){r.N(`debug`,...e)},info(...e){r.N(`log`,...e)},warn(...e){r.N(`warn`,...e)},error(...e){r.N(`error`,...e)},critical(...e){console.error(t,...e)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling ${e}`)},createLogger:(e,n)=>cr(`${t} ${e}`,n)};return r},z=cr(`[PostHog.js]`),B=z.createLogger,lr=B(`[ExternalScriptsLoader]`),ur=e=>{let t=r?.querySelectorAll(`script`);if(t){for(let n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute(`src`)===e)return t[n]}},dr=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return lr.warn(`${t} was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);let i=ur(t);if(i){if(i.__posthog_loading_callback_fired)return n();let e=i.__posthog_loading_error;return e?n(e):(i.addEventListener(`load`,e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)}),void i.addEventListener(`error`,e=>{i.__posthog_loading_error=e,n(e)}))}let a=()=>{if(!r)return n(`document not found`);if(ur(t))return dr(e,t,n);let i=r.createElement(`script`);if(i.type=`text/javascript`,i.crossOrigin=`anonymous`,i.src=t,i.onload=e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)},i.onerror=e=>{i.__posthog_loading_error=e,n(e)},e.config.prepare_external_dependency_script&&(i=e.config.prepare_external_dependency_script(i)),!i)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)r.head.appendChild(i);else{let e=r.querySelectorAll(`body > script`);var a;e.length>0?(a=e[0].parentNode)==null||a.insertBefore(i,e[0]):r.body.appendChild(i)}};r?.body?a():r?.addEventListener(`DOMContentLoaded`,a)},fr={},pr=(e,t)=>{let n=`/static/${t}.js?v=${e.version}`;if(t===`toolbar`){let e=3e5;n=`${n}&t=${Math.floor(Date.now()/e)*e}`}return e.requestRouter.endpointFor(`assets`,n)};f.__PosthogExtensions__=f.__PosthogExtensions__||{},f.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t===`remote-config`){dr(e,e.requestRouter.endpointFor(`assets`,`/array/${e.config.token}/config.js`),n);return}let r=e.config.strict_script_versioning;if(r){let i=e.requestRouter.endpointFor(`assets`,`/static/${e.version}/${t}.js`),a=fr[i];if(r===`fallback`&&a){if(ur(a))return void dr(e,a,n);delete fr[i]}dr(e,i,r===`fallback`?(r,a)=>{if(r)if(typeof r==`string`)n(r);else{var o;let r=pr(e,t);fr[i]=r;let a=ur(i);a==null||(o=a.parentNode)==null||o.removeChild(a),dr(e,r,n)}else n(void 0,a)}:n);return}dr(e,pr(e,t),n)},f.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{dr(e,e.requestRouter.endpointFor(`api`,t),n)},m.DEBUG=!1,m.LIB_VERSION=`1.429.5`,m.LIB_NAME=`web`;var V=m,mr=`$people_distinct_id`,hr=`distinct_id`,gr=`$device_id`,_r=`$device_model`,vr=`__alias`,yr=`__cmpns`,br=`$fbc`,xr=`$fbc_persistence`,Sr=`__timers`,Cr=`$autocapture_disabled_server_side`,wr=`$heatmaps_enabled_server_side`,Tr=`$exception_capture_enabled_server_side`,Er=`$error_tracking_suppression_rules`,Dr=`$error_tracking_capture_extension_exceptions`,Or=`$web_vitals_enabled_server_side`,kr=`$dead_clicks_enabled_server_side`,Ar=`$product_tours_enabled_server_side`,jr=`$logs_capture_enabled_server_side`,Mr=`$web_vitals_allowed_metrics`,Nr=`$session_recording_remote_config`,Pr=`$session_recording_enabled_server_side`,Fr=`$replay_sample_rate`,Ir=`$replay_override_sampling`,Lr=`$replay_override_linked_flag`,Rr=`$replay_override_url_trigger`,zr=`$replay_override_event_trigger`,Br=`$sesid`,Vr=`$session_is_sampled`,Hr=`$session_past_minimum_duration`,Ur=`$session_recording_url_trigger_activated_session`,Wr=`$session_recording_event_trigger_activated_session`,Gr=`$debug_first_full_snapshot_timestamp`,Kr=`$sess_rec_flush_size`,qr=`$enabled_feature_flags`,Jr=`$active_feature_flags`,Yr=`$early_access_features`,Xr=`$feature_flag_details`,Zr=`$feature_flag_payloads`,Qr=`$feature_flag_request_id`,$r=`$minimal_flag_called_events`,ei=`$override_feature_flags`,ti=`$override_feature_flag_payloads`,ni=`$stored_person_properties`,ri=`$stored_group_properties`,ii=`$groups`,ai=`$surveys`,oi=`$surveys_loaded_at`,si=`$surveys_activated`,ci=`$surveys_activated_session`,li=`$surveys_activated_timestamps`,ui=`ph_product_tours`,di=`$product_tours_activated`,fi=`$product_tours_activated_session`,pi=`$conversations_widget_session_id`,mi=`$conversations_ticket_id`,hi=`$conversations_widget_state`,gi=`$conversations_user_traits`,_i=`$flag_call_reported`,vi=`$flag_call_reported_session_id`,yi=`$feature_flag_errors`,bi=`$feature_flag_evaluated_at`,H=`$user_state`,xi=`$client_session_props`,Si=`$capture_rate_limit`,Ci=`$initial_campaign_params`,wi=`$initial_referrer_info`,Ti=`$initial_person_info`,Ei=`$epp`,Di=`$posthog_cookieless`,Oi=`$cookieless_mode`,ki=`$sdk_debug_extensions_init_method`,Ai=`$sdk_debug_extensions_init_time_ms`,ji=`$sdk_debug_recording_script_not_loaded`,Mi=`$sdk_debug_replay_event_trigger_status`,Ni=`$sdk_debug_replay_linked_flag_trigger_status`,Pi=`$sdk_debug_replay_matched_recording_trigger_groups`,Fi=`$sdk_debug_replay_pending_trigger_conditions`,Ii=`$sdk_debug_replay_remote_trigger_matching_config`,Li=`$sdk_debug_replay_trigger_groups_count`,Ri=`$sdk_debug_replay_url_trigger_status`,zi=`$session_recording_start_reason`,Bi=`PostHog loadExternalDependency extension not found.`,Vi=`anonymous`,Hi=`identified`,Ui=`identified_only`,Wi=`visibilitychange`,Gi=`beforeunload`,Ki=`$pageview`,qi=`$pageleave`,Ji=`$identify`,Yi=`$groupidentify`;function Xi(e,t){T(e)&&e.forEach(t)}function U(e,t){if(!N(e))if(T(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,n)=>t(e,n));else for(let n in e)w.call(e,n)&&t(e[n],n)}var W=function(e,...t){for(let n of t)for(let t in n)n[t]!==void 0&&(e[t]=n[t]);return e};function Zi(e){let t=Object.keys(e),n=t.length,r=Array(n);for(;n--;)r[n]=[t[n],e[t[n]]];return r}var Qi=function(e){try{return e()}catch{return}},$i=function(e){return function(...t){try{return e.apply(this,t)}catch(e){z.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),z.critical(e)}}},ea=function(e){let t={};return U(e,function(e,n){(A(e)&&e.length>0||P(e))&&(t[n]=e)}),t};function ta(e){let t=R({},e);for(let n of[`name`,`message`,`stack`,`cause`,`errors`])try{n in e&&(t[n]=e[n])}catch{}return t}var na=[`herokuapp.com`,`vercel.app`,`netlify.app`];function ra(e){let t=e?.hostname;if(!A(t))return!1;let n=t.split(`.`).slice(-2).join(`.`);for(let e of na)if(n===e)return!1;return!0}function G(e,t,n,r){let{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function ia(e){return e.name===`ph_toolbar_internal`}var aa=e=>{if(r){try{let t=e+`=`,n=r.cookie.split(`;`).filter(e=>e.length);for(let e=0;n.length>e;e++){let r=n[e];for(;r.charAt(0)==` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return P(e)&&isFinite(e)&&Math.floor(e)===e});var oa=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){let e=``;for(let t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let t=0;16>t;t++){let n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},sa=class{generate(){let e=this.generateOrAbort();if(!k(e))return e;{this.Ct=0;let e=this.generateOrAbort();if(k(e))throw Error(`Could not generate UUID after timestamp reset`);return e}}generateOrAbort(){let e=(()=>{let e=Date.now();return P(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return oa.fromFieldsV7(this.Ct,Math.trunc(this.It/2**30),this.It&2**30-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new la}},ca=e=>{if(`u`>typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!k(e.crypto)&&crypto.getRandomValues&&(ca=e=>crypto.getRandomValues(e));var la=class{nextUint32(){return this.Rt.length>this.$t||(ca(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}},ua,da=()=>fa().toString(),fa=()=>(ua||=new sa).generate(),pa=``,ma=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ha=null,K={Et(){if(!M(ha))return ha;if(ha=!1,r)try{let e=`__ph_cookie_support_${da()}`;K.At(e,`xyz`),ha=aa(e)===`"xyz"`,K.Lt(e)}catch{ha=!1}return ha},Pt(e){z.error(`cookieStore error: `+e)},Ot:aa,Dt(e){let t;try{t=JSON.parse(K.Ot(e))||{}}catch{}return t},At(e,t,n,i,a){if(!r)return!1;try{let o=``,s=``,c=function(e,t){if(t){let t=function(e,t=r){if(pa)return pa;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;let n=e.split(`.`),i=Math.min(n.length,8),a=`dmn_chk_`+da();for(;!pa&&i--;){let e=n.slice(i).join(`.`),r=a+`=1;domain=.`+e+`;path=/`;t.cookie=r+`;max-age=3`,t.cookie.includes(a)&&(t.cookie=r+`;max-age=0`,pa=e)}return pa}(e);if(!t){let n=(e=>{let t=e.match(ma);return t?t[0]:``})(e);n!==t&&z.info(`Warning: cookie subdomain discovery mismatch`,n,t),t=n}return t?`; domain=.`+t:``}return``}(r.location.hostname,i);if(n){let e=new Date;e.setTime(e.getTime()+864e5*n),o=`; expires=`+e.toUTCString()}a&&(s=`; secure`);let l=e+`=`+encodeURIComponent(JSON.stringify(t))+o+`; SameSite=Lax; path=/`+c+s;return l.length>3686.4&&z.warn(`cookieStore warning: large cookie, len=`+l.length),r.cookie=l,!0}catch{return!1}},Lt(e,t){if(r?.cookie)try{K.At(e,``,-1,t)}catch{return}}},ga=null,q={Et(){if(!M(ga))return ga;let t=!0;if(k(e))t=!1;else try{let e=`__mplssupport__`;q.At(e,`xyz`),q.Ot(e)!==`"xyz"`&&(t=!1),q.Lt(e)}catch{t=!1}return t||z.error(`localStorage unsupported; falling back to cookie store`),ga=t,t},Pt(e){z.error(`localStorage error: `+e)},Ot(t){try{return e?.localStorage.getItem(t)}catch(e){q.Pt(e)}return null},Dt(e){try{return JSON.parse(q.Ot(e))||{}}catch{}return null},At(t,n){try{return e?.localStorage.setItem(t,JSON.stringify(n)),!0}catch(e){q.Pt(e)}return!1},Lt(t){try{e?.localStorage.removeItem(t)}catch(e){q.Pt(e)}}},_a=[ni,Jr,qr,Xr,Zr,Qr,bi,yi,_i],va=[gr,hr,Br,Vr,Ei,Ti,xr,H],ya=e=>e+`_cpm`,ba=[`__proto__`,`constructor`,`prototype`],xa=e=>{if(!D(e))return{};let t={};return Object.keys(e).forEach(n=>{ba.indexOf(n)===-1&&(t[n]=e[n])}),t},Sa=(e,t=[])=>{let n={};return[...va,...t].forEach(t=>{let r=e[t];k(r)||M(r)||r===``||(n[t]=r)}),n},Ca=e=>{let t=5381,n=2166136261;for(let r=0;e.length>r;r++){let i=e.charCodeAt(r);t=33*t^i,n=Math.imul(n^i,16777619)}return e.length.toString(36)+`.`+(t>>>0).toString(36)+`.`+(n>>>0).toString(36)},wa=(e,t)=>({p:t,f:Ca(JSON.stringify(e))}),Ta=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{let n=K.Dt(ya(e)),r=n?.f===Ca(t)&&T(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},Ea=(e,t)=>t+`|`+(K.Ot(ya(e))||``),Da={},Oa={Et:()=>!0,Pt(e){z.error(`memoryStorage error: `+e)},Ot:e=>e in Da?Da[e]:null,Dt:e=>e in Da?Da[e]:null,At:(e,t)=>(Da[e]=t,!0),Lt(e){delete Da[e]}},ka=null,J={Et(){if(!M(ka))return ka;if(ka=!0,k(e))ka=!1;else try{let e=`__support__`;J.At(e,`xyz`),J.Ot(e)!==`"xyz"`&&(ka=!1),J.Lt(e)}catch{ka=!1}return ka},Pt(e){z.error(`sessionStorage error: `,e)},Ot(t){try{return e?.sessionStorage.getItem(t)}catch(e){J.Pt(e)}return null},Dt(e){try{return JSON.parse(J.Ot(e))||null}catch{}return null},At(t,n){try{return e?.sessionStorage.setItem(t,JSON.stringify(n)),!0}catch(e){J.Pt(e)}return!1},Lt(t){try{e?.sessionStorage.removeItem(t)}catch(e){J.Pt(e)}}},Aa=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Ro()?0:this.Ao}isOptedOut(){return this.Mr.cookieless_mode===`always`||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode===`on_reject`}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.Fo.At(this.Oo,+!!e,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.Fo.Lt(this.Oo,this.Mr.cross_subdomain_cookie)}get Oo(){let{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get Ao(){let e=this.Fo.Ot(this.Oo);return le(e)?1:y(ue,e)?0:-1}get Fo(){let e=this.Mr.opt_out_capturing_persistence_type,t=e===`localStorage`?q:K,n=t.Et()?t:Oa;if(!this.Do||this.Do!==n){this.Do=n;let t=e===`localStorage`?K:q;t.Ot(this.Oo)&&(this.Do.Ot(this.Oo)||this.optInOut(le(t.Ot(this.Oo))),t.Lt(this.Oo,this.Mr.cross_subdomain_cookie))}return this.Do}Ro(){return!!this.Mr.respect_dnt&&[n?.doNotTrack,n?.msDoNotTrack,f.doNotTrack,n?.globalPrivacyControl].some(e=>le(e))}};function ja(e,t){var n;let r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!E(r))return t;try{let e=r(t);return A(e)&&e?e:t}catch(e){return z.error(`Error in get_current_url, falling back to window.location.href`,e),t}}function Ma(e){return e instanceof Element&&(e.id===`__POSTHOG_TOOLBAR__`||!!e.closest?.call(e,`.toolbar-global-fade-container`))}function Na(e){return!!e&&e.nodeType===1}function Y(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Pa(e){return!!e&&e.nodeType===3}function Fa(e){return!!e&&e.nodeType===11&&Na(e.host)}function Ia(e){return e?b(e).split(/\s+/):[]}function La(t,n){let r=function(t){var n;let r=e==null||(n=e.location)==null?void 0:n.href;return k(r)?void 0:ja(t,r)}(n);return!!(r&&t&&t.some(e=>r.match(e)))}function Ra(e){let t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return Ia(t)}function za(e){return N(e)?null:b(e).split(/(\s+)/).filter(e=>uo(e)).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Ba(e){let t=``;return to(e)&&!no(e)&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(e){Pa(e)&&e.textContent&&(t+=za(e.textContent)??``)}),b(t)}function Va(e){return k(e.target)?e.srcElement||null:e.target?.shadowRoot?e.composedPath()[0]||null:e.target||null}var Ha=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Ua(e,t){let n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}function Wa(e,t){if(k(t))return!0;for(let n of e)if(t.some(e=>Ua(n,e)))return!0;return!1}function Ga(e){let t=e.parentNode;return!(!t||!Na(t))&&t}var Ka=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],qa=[`next`,`previous`,`prev`,`>`,`<`],Ja=[...qa,`+`,`-`,`−`,`–`],Ya=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Xa=[`.ph-no-rageclick`,`.ph-no-capture`],Za=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function Qa(t,n){if(!e||$a(t))return!1;let r,i,a;var o;if(F(n)?(r=!!n&&Xa,i=void 0,a=!1):(r=n?.css_selector_ignorelist??Xa,i=n?.content_ignorelist,a=(o=n?.ignore_text_selection)!=null&&o),!1===r||a&&function(e){return!(!e||!Na(e))&&(!!Y(e,`textarea`)||(Y(e,`input`)?y(Za,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;let t=e.getAttribute?.call(e,`contenteditable`);return t===`true`||t===``}(e)))}(t))return!1;let{targetElementList:s}=eo(t,!1);return!function(e,t){if(!1===e||k(e))return!1;let n;if(!0===e)n=qa;else{if(!T(e))return!1;if(e.length>10)return z.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map(e=>e.toLowerCase())}return t.some(({safeText:e,ariaLabel:t})=>n.some(n=>Ya(e,n)||Ya(t,n)))}(i,s.map(e=>({safeText:Ba(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``})))&&!Wa(s,r)}var $a=e=>!e||Y(e,`html`)||!Na(e),eo=(t,n)=>{if(!e||$a(t))return{parentIsUsefulElement:!1,targetElementList:[]};let r=!1,i=[t],a=t;for(;a.parentNode&&!Y(a,`body`);){if(Fa(a.parentNode)){i.push(a.parentNode.host),a=a.parentNode.host;continue}let t=Ga(a);if(!t)break;if(n||Ha.indexOf(t.tagName.toLowerCase())>-1)r=!0;else try{let n=e.getComputedStyle(t);n&&n.getPropertyValue(`cursor`)===`pointer`&&(r=!0)}catch{}i.push(t),a=t}return{parentIsUsefulElement:r,targetElementList:i}};function to(e){let t=new Set,n=0;for(let r=e;r.parentNode&&!Y(r,`body`);r=r.parentNode){if(n++>=1e3||t.has(r))return!1;t.add(r);let e=Ra(r);if(y(e,`ph-sensitive`)||y(e,`ph-no-capture`))return!1}if(y(Ra(e),`ph-include`))return!0;let r=e.type||``;if(A(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}let i=e.name||e.id||``;return!A(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function no(e){return!!(Y(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Y(e,`select`)||Y(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var ro=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}))$`),io=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,ao=[16,15,14,13],oo=RegExp(`^(\\d{3}-?\\d{2}-?\\d{4})$`),so=RegExp(`(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))`,`g`),co=/[0-9A-Za-z_]/;function lo(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e.charCodeAt(r)-48;n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}function uo(e,t=!0){return!(N(e)||A(e)&&(e=b(e),(t?ro.test((e||``).replace(/[- ]/g,``)):function(e){let t;for(io.lastIndex=0;t=io.exec(e);){let e=t[2];if(!e)continue;let n=e.replace(/[- ]/g,``);for(let e=0;n.length>e;e++)for(let t of ao){let r=e+t;if(n.length>=r){let t=n.slice(e,r);if(ro.test(t)&&lo(t))return!0}}}return!1}(e))||(t?oo.test(e):function(e){let t;for(so.lastIndex=0;t=so.exec(e);){let e=t[1],n=t[3];if(!(e&&n&&co.test(e)&&co.test(n)))return!0}return!1}(e))))}function fo(e){let t=Ba(e);return t=`${t} ${po(e)}`.trim(),uo(t)?t:``}function po(e){let t=``;return e&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{let n=Ba(e);t=`${t} ${n}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${po(e)}`.trim())}catch(e){z.error(`[AutoCapture]`,e)}}),t}function mo(e){return e.replace(/"|\\"/g,`\\"`)}function ho(e){let t=e.attr__class;if(t)return T(t)?t:Ia(t)}var go=B(`[Dead Clicks]`),_o=()=>!0,vo=e=>{let t=!!e.instance.persistence?.get_property(kr),n=e.instance.config.capture_dead_clicks;return F(n)?n:!!D(n)||t},yo=class{get lazyLoadedDeadClicksAutocapture(){return this.Lo}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`captureDeadClicks`in t&&(this.instance.persistence&&this.instance.persistence.register({[kr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.No(()=>{this.qo()}):this.stop()}No(e){var t,n;f.__PosthogExtensions__?.initDeadClicksAutocapture?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this.instance,`dead-clicks-autocapture`,t=>{t?go.error(`failed to load script`,t):e()})}qo(){if(r){if(!this.Lo&&f.__PosthogExtensions__?.initDeadClicksAutocapture){let e=D(this.instance.config.capture_dead_clicks)?R({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Lo=f.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Lo.start(r),go.info(`starting...`)}}else go.error("`document` not found. Cannot start.")}stop(){this.Lo&&(this.Lo.stop(),this.Lo=void 0,go.info(`stopping...`))}},bo=B(`[SegmentIntegration]`);function xo(e,t,n=!0){let r=e.config.segment;if(!r)return t();let{analytics:i,filterProperties:a}=(e=>E(e.register))(o=r)?{analytics:o}:o;var o;(function(e,t,n,r){let i=t=>{let i=()=>t.anonymousId()||da();e.config.get_device_id=i,r&&t.id()&&(e.register({distinct_id:t.id(),$device_id:i()}),e.persistence.set_property(H,Hi)),n(r?void 0:t.anonymousId()||void 0)},a=t.user();`then`in a&&E(a.then)?a.then(i):i(a)})(e,i,n=>{i.register(((e,t,{filterProperties:n}={})=>{typeof Promise<`u`&&Promise.resolve||bo.warn(`This browser does not have Promise support, and can not use the segment integration`);let r=(r,i)=>{if(!i)return r;let a=!!t&&r.event.anonymousId===t&&!r.event.userId;a||r.event.userId||r.event.anonymousId===e.get_distinct_id()||(bo.info(`No userId set, resetting PostHog`),e.reset()),a||(t=void 0),r.event.userId&&r.event.userId!==e.get_distinct_id()&&(bo.info(`UserId set, identifying with PostHog`),e.identify(r.event.userId));let o=e.calculateEventProperties(i,r.event.properties);if(!N(n)){let e=r.event.properties||{},t={};for(let n of Object.keys(o))w.call(e,n)||(t[n]=o[n]);let i=((e,t)=>{let n=T(e)?e:[e],r=R({},t);for(let e of n)try{if(r=e(r),N(r))return null}catch(e){return bo.error(`Error in Segment filterProperties:`,e),null}return r})(n,t);if(N(i))return r;o=i}return r.event.properties=Object.assign({},o,r.event.properties),r};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded(){return!0},load(){return Promise.resolve()},track(e){return r(e,e.event.event)},page(e){return r(e,Ki)},identify(e){return r(e,Ji)},screen(e){return r(e,`$screen`)}}})(e,n,{filterProperties:a})).then(()=>{t()},e=>{bo.error(`Failed to register the Segment integration`,e),t()})},n)}var So=`posthog-js`;function Co(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(i!==`*`&&!i.includes(o.level)||!e.__loaded)return o;o.tags||={};let s=e.requestRouter.endpointFor(`ui`,`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(o.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));let c=o.exception?.values||[],l=c.map(e=>R(R({},e),{},{stacktrace:e.stacktrace?R(R({},e.stacktrace),{},{type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>R(R({},e),{},{platform:`web:javascript`}))}):void 0})),u={$exception_message:c[0]?.value||o.message,$exception_type:c[0]?.type,$exception_level:o.level,$exception_list:l,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:c[0]?.value||o.message,$sentry_exception_type:c[0]?.type,$sentry_tags:o.tags};var d;return t&&n&&(u.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&((d=e.exceptions)==null||d.sendExceptionEvent(u)),o}}var wo=class{constructor(e,t,n,r,i,a){this.name=So,this.setupOnce=function(o){o(Co(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},To=class{constructor(e){this.jo=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(z.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.Bo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Ho()}Ho(){this.zo=this._instance.sessionManager?.onSessionId(this.jo)}destroy(){var e;(e=this.zo)==null||e.call(this),this.zo=void 0}doPageView(t,n){let r=this.Uo(t,n);return this.Bo={pathname:e?.location.pathname??``,pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(e){return this.Uo(e,this.Bo?.pageViewId)}doEvent(){return{$pageview_id:this.Bo?.pageViewId}}Uo(e,t){let n=this.Bo;if(!n)return{$pageview_id:t};let r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:n,maxContentHeight:a,lastContentY:o,maxContentY:s}=i;if(!(k(e)||k(t)||k(n)||k(a)||k(o)||k(s))){e=Math.ceil(e),t=Math.ceil(t),n=Math.ceil(n),a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s);let i=e>1?me(t/e,0,1,z):1,c=e>1?me(n/e,0,1,z):1,l=a>1?me(o/a,0,1,z):1,u=a>1?me(s/a,0,1,z):1;r=W(r,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:i,$prev_pageview_max_scroll:n,$prev_pageview_max_scroll_percentage:c,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:l,$prev_pageview_max_content:s,$prev_pageview_max_content_percentage:u})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},Eo=[`flags`,`surveys`],Do={[mr]:{exposure:`hidden`},[vr]:{exposure:`hidden`},[yr]:{exposure:`hidden`},[Sr]:{exposure:`hidden`},[xr]:{exposure:`hidden`},[Cr]:{exposure:`event`},[wr]:{exposure:`hidden`},[jr]:{exposure:`hidden`},[Tr]:{exposure:`event`},[Er]:{exposure:`hidden`},[Dr]:{exposure:`event`},[Or]:{exposure:`event`},[kr]:{exposure:`event`},[Ar]:{exposure:`hidden`},[Mr]:{exposure:`event`},[Nr]:{exposure:`hidden`},[Pr]:{exposure:`hidden`},[Br]:{exposure:`hidden`},[Vr]:{exposure:`event`},[Fr]:{exposure:`event`,shouldSkipFromEventProperties:e=>M(e)},[Hr]:{exposure:`event`},[Ur]:{exposure:`event`},[Wr]:{exposure:`event`},[Gr]:{exposure:`event`},[Kr]:{exposure:`hidden`},[qr]:{exposure:`hidden`,storageGroup:`flags`},[Jr]:{exposure:`hidden`,storageGroup:`flags`},[Yr]:{exposure:`hidden`},[Xr]:{exposure:`hidden`,storageGroup:`flags`},[Zr]:{exposure:`hidden`,storageGroup:`flags`},[Qr]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[$r]:{exposure:`hidden`,storageGroup:`flags`},[ei]:{exposure:`hidden`},[ti]:{exposure:`hidden`},[ni]:{exposure:`hidden`},[ri]:{exposure:`hidden`},[ai]:{exposure:`hidden`,storageGroup:`surveys`},[oi]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[si]:{exposure:`event`},[ci]:{exposure:`hidden`},[li]:{exposure:`hidden`},[ui]:{exposure:`hidden`},[di]:{exposure:`hidden`},[fi]:{exposure:`hidden`},[pi]:{exposure:`event`},[mi]:{exposure:`event`},[hi]:{exposure:`event`},[gi]:{exposure:`event`},[_i]:{exposure:`hidden`},[vi]:{exposure:`hidden`},[ii]:{exposure:`event`},[yi]:{exposure:`hidden`},[bi]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[H]:{exposure:`hidden`},[xi]:{exposure:`hidden`},[Si]:{exposure:`hidden`},[Ci]:{exposure:`hidden`},[wi]:{exposure:`hidden`},[Ti]:{exposure:`hidden`},[Ei]:{exposure:`hidden`},[Ir]:{exposure:`event`},[Lr]:{exposure:`event`},[Rr]:{exposure:`event`},[zr]:{exposure:`event`},[ki]:{exposure:`event`},[Ai]:{exposure:`event`},[ji]:{exposure:`event`},[Mi]:{exposure:`event`},[Ni]:{exposure:`event`},[Pi]:{exposure:`event`},[Fi]:{exposure:`event`},[Ii]:{exposure:`event`},[Li]:{exposure:`event`},[Ri]:{exposure:`event`},[zi]:{exposure:`event`}},Oo=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],X=e=>{let t=Do[e];if(t)return t;for(let[t,n]of Oo)if(e.indexOf(t)===0)return n},ko=(e,t)=>{try{let n;return JSON.stringify(e,(e,t)=>ae(t)?(n??=new WeakMap,n.has(t)||n.set(t,ta(t)),n.get(t)):typeof t==`bigint`?t.toString():t,t)}catch{return S(e)}},Ao=e=>{let t=r?.createElement(`a`);return k(t)?null:(t.href=e,t)},jo=function(e,t){let n=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),r;for(let e=0;n.length>e;e++){let i=n[e].split(`=`);if(i[0]===t){r=i;break}}if(!T(r)||2>r.length)return``;{let e=r[1];try{e=decodeURIComponent(e)}catch{z.error(`Skipping decoding for malformed query param: `+e)}return e.replace(/\+/g,` `)}},Mo=function(e,t,n){if(!e||!t||!t.length)return e;let r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[];for(let e=0;c.length>e;e++){let r=c[e].split(`=`);T(r)&&(t.includes(r[0])?l.push(r[0]+`=`+n):l.push(c[e]))}let u=s;return o!=null&&(u+=`?`+l.join(`&`)),i!=null&&(u+=`#`+i),u},No=function(e,t){let n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},Po=(e,t)=>e>=t&&u(),Fo=(e,t,n,r)=>{if(e===0){if(u()){let e=t+1;return e===n&&r(),e}return t}return 0},Io=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Lo=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Io],Ro=`<masked>`,zo=[`li_fat_id`];function Bo(e,t,n){if(!r)return{};let i=t?[...Io,...n||[]]:[],a=Vo(Mo(r.URL,i,Ro),e);return W(function(){let e={};return U(zo,function(t){let n=aa(t);e[t]=n||null}),e}(),a)}function Vo(e,t){let n=Lo.concat(t||[]),r={};return U(n,function(t){let n=jo(e,t);r[t]=n||null}),r}function Ho(e){let t=function(e){return e?e.search(`https?://(.*)google.([^/?]*)`)===0?`google`:e.search(`https?://(.*)bing.com`)===0?`bing`:e.search(`https?://(.*)yahoo.com`)===0?`yahoo`:e.search(`https?://(.*)duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,i={};if(!M(t)){i.$search_engine=t;let e=r?jo(r.referrer,n):``;e.length&&(i.ph_keyword=e)}return i}function Uo(){return navigator.language||navigator.userLanguage}function Wo(){let e=Uo();return typeof e==`string`?e.split(`-`)[0]:void 0}var Go=`$direct`;function Ko(){return r?.referrer||Go}function qo(e,t,n=!1){let r=e?[...Io,...t||[]]:[],a=(n?Et(i?.href):i?.href)?.substring(0,1e3);return{r:Ko().substring(0,1e3),u:a?Mo(a,r,Ro):void 0}}function Jo(e,t=!1){let{r:n,u:r}=e,i=t?Et(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==Go?Go:Ao(n)?.host};if(i){a.$current_url=i;let e=Ao(i);a.$host=e?.host,a.$pathname=e?.pathname,W(a,Vo(i))}return n&&W(a,Ho(n)),a}function Yo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Xo(){try{return new Date().getTimezoneOffset()}catch{return}}var Zo={flags:bi,surveys:oi},Qo=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],$o=e=>`${e}_cookie_identity_change_pending`,es=e=>{let t=``,n=0;for(let r of e){let e=encodeURIComponent(JSON.stringify(r).slice(1,-1)).length;if(n+e>1e3)break;t+=r,n+=e}return t},Z=`main`,ts=[qr,Jr,Xr,Zr,Qr,bi,$r,ni],ns=e=>ts.indexOf(e)!==-1,rs=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},is=e=>{if(!e)return{};let t=JSON.parse(e);return D(t)?t:{}},as=(e,t)=>{U(e,(n,r)=>{let i=X(r);i&&i.exposure!==`event`||{}.hasOwnProperty.call(t,r)||delete e[r]})},os=class{constructor(t,n,r=!0){if(this.Wo={},this.Vo=!1,this.Go=!1,this.Zo=!1,this.Qo=!1,this.Jo=!1,this.Ko=new Map,this.Yo=!1,this.Xo=!1,this.tl=!1,this.el=!1,this.il=new Set,this.Mr=t,this.nl=r,this.props={},this.sl=void 0,this.rl=(e=>{let t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(t),this.Fo=this.ol(t),this.Zo=this.ll(t),this.load(),this.al(),t.debug&&z.info(`Persistence loaded`,t.persistence,R({},this.props)),this.update_config(t,t,n),this.save(),e){let t=()=>this.flush();G(e,`beforeunload`,t,{capture:!1}),G(e,`pagehide`,t,{capture:!1}),this.ul=t=>{if(this.Vo&&(!t.storageArea||t.storageArea===e?.localStorage)&&t.key)if(t.key!==this.rl){if(this.Zo){let e=Eo.find(e=>t.key===this.hl(e));e&&this.cl(t.key,e)}}else this.cl(t.key,Z)},G(e,`storage`,this.ul)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{let n=this.Ko.get(e);if(!ns(e)||!0===n)return;if(!0===t)return void this.dl(e,!0);let r=new Set(n||[]);t.forEach(e=>r.add(e)),r.size&&this.dl(e,r)})}onCrossTabFeatureFlagChange(e){return this.il.add(e),()=>this.il.delete(e)}destroy(){this.ul&&e&&(e.removeEventListener(`storage`,this.ul),this.ul=void 0),this.il.clear()}cl(e,t,n=!0){if(this.pi)return!1;let r,i;try{if(i=q.Ot(e),M(i)){let e=this.vl(t);return e.storageValue=null,t!==Z&&(e.persisted=!1),!1}r=is(i)}catch{return!1}let a=t===Z?r:q.Dt(this.rl);if(a&&this.fl(a))return!1;let o=this.pl(r,t,n);return t===Z&&this.Zo&&!rs(this.gl().main,r)||this.ml(r,t,!0,i),o}fl(e){let t=this.props[hr],n=e[hr];return!k(t)&&!k(n)&&t!==n}ml(e,t,n,r){let i=this.vl(t);i.storageValue=r,t!==Z&&(i.persisted=n);try{i.fingerprint=this.yl(e,t)}catch{i.fingerprint=void 0}}pl(e,t,n){let r=!1;return ts.forEach(n=>{let i=X(n)?.storageGroup;if(t===Z&&this.Zo&&i||t!==Z&&i!==t)return;let a=n in e,o=this.bl(n,a?e[n]:void 0),s=this.Ko.has(n)?n in this.props:a;s===n in this.props&&rs(o,this.props[n])||(s?this._l(n,o,!1):this.wl(n,!1),r=!0)}),r&&n&&this.il.forEach(e=>e()),r}kl(){if(!this.Vo)return!1;try{this.tl=!1;let e=q.Ot(this.rl),t=this.vl(Z),n,r=!1,i=!1;if(e!==t.storageValue)if(M(e))t.storageValue=null;else{if(n=is(e),this.tl=!this.Xo&&this.fl(n),this.tl)return!1;i=this.pl(n,Z,!1),!this.Zo||rs(this.gl().main,n)?this.ml(n,Z,!0,e):t.storageValue=e,r=!0}return this.Zo&&Eo.forEach(e=>{let t=q.Ot(this.hl(e)),a=this.vl(e),o=n||{},s=r&&ts.some(t=>X(t)?.storageGroup===e&&t in o);if(t===a.storageValue&&!s)return;if(M(t))return a.storageValue=null,a.persisted=!1,void(s&&(i=this.pl(o,e,!1)||i));let c=is(t);i=this.pl(c,e,!1)||i,this.ml(c,e,!0,t)}),i}catch{return!1}}dl(e,t){this.Ko.set(e,t);let n=X(e);n!=null&&n.volatile||(this.vl((this.Zo?n?.storageGroup:void 0)||Z).fingerprint=void 0,this.Sl(e))}xl(){ts.forEach(e=>this.Ko.set(e,!0))}al(){if(this.Vo)try{let e=q.Ot(this.rl),t=is(e);this.vl(Z).storageValue=e,ts.forEach(e=>{let n=this.Zo?X(e)?.storageGroup:void 0,r=n?q.Ot(this.hl(n)):null;if(n){let e=this.vl(n);e.storageValue=r,e.persisted=!M(r)}let i=n&&!M(r)?is(r):t;e in this.props?this.Cl(e,i[e],this.props[e]):e in i&&this.dl(e,!0)})}catch{}}bl(e,t){let n=this.Ko.get(e);if(!n)return t;if(!0===n)return this.props[e];if(e===`$active_feature_flags`){let r=new Set(T(t)?t:[]),i=new Set(T(this.props[e])?this.props[e]:[]);return n.forEach(e=>i.has(e)?r.add(e):r.delete(e)),Array.from(r)}let r=D(t)?R({},t):{},i=D(this.props[e])?this.props[e]:{};return n.forEach(e=>{e in i?r[e]=i[e]:delete r[e]}),r}Cl(e,t,n){if(!ns(e))return;let r=this.Ko.get(e);if(!0===r)return;let i=t;if(this.Vo)try{let t=this.Zo?X(e)?.storageGroup:void 0,n=t?this.hl(t):this.rl;i=is(q.Ot(n))[e]}catch{}let a=new Set(r||[]);if(e===`$active_feature_flags`){if(!k(t)&&!T(t)||!k(i)&&!T(i)||!T(n))return void this.dl(e,!0);let r=new Set(t||[]),o=new Set(i||[]),s=new Set(n);new Set([...r,...s]).forEach(e=>{r.has(e)!==s.has(e)&&a.add(e)}),a.forEach(e=>{o.has(e)===s.has(e)&&a.delete(e)})}else{if(!D(n))return void(rs(i,n)?this.Ko.delete(e):this.dl(e,!0));{if(!k(t)&&!D(t)||k(t)&&O(n)&&k(i))return void this.dl(e,!0);let r=D(t)?t:{},o=D(i)?i:{};new Set([...Object.keys(r),...Object.keys(n)]).forEach(e=>{e in r==e in n&&rs(r[e],n[e])||a.add(e)}),a.forEach(e=>{e in o==e in n&&rs(o[e],n[e])&&a.delete(e)})}}a.size?this.dl(e,a):this.Ko.delete(e)}$l(){let e=this.Mr?.persistence_save_debounce_ms;return P(e)&&e>0?e:0}Tl(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()===`localstorage+cookie`)if(e)try{let t=Sa(e,this.Mr.cookie_persisted_properties||[]),n=wa(t,this.Mr.cookie_persisted_properties||[]),r=JSON.stringify(t)+`|`+JSON.stringify(n),i=K.Ot(this.rl)||void 0;i&&Ea(this.rl,i)===r&&(this.Il=r,this.Ml=i)}catch{}else try{let e=K.Ot(this.rl)||void 0;this.Il=e?Ea(this.rl,e):void 0,this.Ml=e}catch{}}syncCookieProperties(){return this.El(this.Mr)}El(e,t=!1){if(this.pi&&!t||this.Jo||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!==`localstorage+cookie`)return!1;let n;try{n=K.Ot(this.rl)||void 0}catch{}if(!n||n===this.Ml)return!1;let r=Ea(this.rl,n),i;try{i=xa(JSON.parse(n))}catch{return!1}if((K.Ot(this.rl)||void 0)!==n)return!1;this.Il=r,this.Ml=n;let a=Ta(this.rl,n),o=[...va,...a.properties],s={};if(Object.keys(i).forEach(e=>{let t=i[e];(k(t)||M(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`)&&(s[e]=!0,delete i[e])}),O(i))return!1;let c=`distinct_id`in i||i.$user_state===`anonymous`||i.$user_state===`identified`,l=this.props,u=l[hr],d=l[H],f=W({},l);[...va,...e.cookie_persisted_properties||[]].forEach(e=>{if(o.indexOf(e)!==-1&&!(e in i)&&!s[e]&&(c||e!==`distinct_id`&&e!==`$user_state`)){let t=f[e];(a.isValid||va.indexOf(e)===-1||!1!==t&&t!==0)&&delete f[e]}}),this.props=W(f,i),ts.forEach(e=>{let t=e in this.props;e in l===t&&rs(l[e],this.props[e])||(t?this.Cl(e,l[e],this.props[e]):this.dl(e,!0))}),!c||`$user_state`in i||`$user_state`in this.props||this._l(H,Vi);let p=this.props[hr],m=this.props[H];return!c||p===u&&m===d||(this.Xo=!0,this.Qo=!0,J.At($o(this.rl),!0),this.wl(ni),this.wl(Jr),this.wl(qr),this.wl(Xr),this.wl(Zr),this.wl(Qr),this.wl(bi),this.wl(yi),this.wl(_i),m!==`anonymous`||d!==`identified`&&i.$user_state!==`anonymous`&&(k(u)||p===u)||(as(this.props,i),this.wl(ri)),m===`identified`?this.props.$user_id=p:delete this.props.$user_id,this.wl(vr)),!0}consumeCookieIdentityChange(){let e=$o(this.rl),t=this.Qo||!!J.Ot(e);return this.Qo=!1,t&&J.Lt(e),t}Pl(e=!1){return!(this.Jo||this.pi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!==`localstorage+cookie`||(this.Jo=!0,0))}Rl(){this.Jo&&(k(this.Al)||(clearTimeout(this.Al),this.Al=void 0),delete this.Wo[Z],this.Fl(!0))}Ol(e=!0){if(this.Jo)try{e?this.Rl():k(this.Al)||(clearTimeout(this.Al),this.Al=void 0)}finally{this.Jo=!1}}isDisabled(){return!!this.pi}ol(t){Qo.indexOf(t.persistence.toLowerCase())===-1&&(z.critical(`Unknown persistence type `+t.persistence+`; falling back to localStorage+cookie`),t.persistence=`localStorage+cookie`);let n=((t=[],n=!1)=>{let r=[...va,...t];return R(R({},q),{},{Dt(e){try{let t,i={};try{t=K.Ot(e)||void 0,i=t?xa(JSON.parse(t)):{}}catch{}let a=JSON.parse(q.Ot(e)||`{}`),o;if(n){let n=Ta(e,t),s=[...va,...n.properties],c={};Object.keys(i).forEach(e=>{let t=i[e];M(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`||(c[e]=t)});let l=`distinct_id`in c||c.$user_state===`anonymous`||c.$user_state===`identified`;if(Object.keys(c).length>0){let e=a[hr],t=a.$user_state??Vi;r.forEach(e=>{if(s.indexOf(e)!==-1&&!(e in i)&&(l||e!==`distinct_id`&&e!==`$user_state`)){let t=a[e];(n.isValid||va.indexOf(e)===-1||!1!==t&&t!==0)&&delete a[e]}}),!l||`$user_state`in i||`$user_state`in a||(a[H]=Vi),!l||(`distinct_id`in c?c[hr]:a[hr])===e&&(`$user_state`in c?c[H]:a[H])===t||(_a.forEach(e=>delete a[e]),c.$user_state===`identified`&&`distinct_id`in c?a.$user_id=c[hr]:delete a.$user_id,c.$user_state!==`identified`&&(delete a[ii],delete a[ri]),delete a.__alias)}o=W(a,c)}else o=W(i,a);return q.At(e,o),o}catch{}return null},At(e,r,i,a,o,s){let c=q.At(e,r,void 0,void 0,s);try{let l=Sa(r,t);if(Object.keys(l).length){if(n){let n=ya(e),u=wa(l,t);if(K.At(n,u,i,a,o,s),K.Ot(n)!==JSON.stringify(u)){K.Lt(n,a);let t=Sa(r);return K.At(e,t,i,a,o,s),c}}K.At(e,l,i,a,o,s)}}catch(e){q.Pt(e)}return c},Lt(t,n){try{e?.localStorage.removeItem(t),K.Lt(t,n),K.Lt(ya(t),n)}catch(e){q.Pt(e)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),r,i=!1,a=!1,o=t.persistence.toLowerCase();return o===`localstorage`&&q.Et()?(r=q,a=!0):o===`localstorage+cookie`&&n.Et()?(r=n,a=!0,i=!0):o===`sessionstorage`&&J.Et()?r=J:o===`memory`?r=Oa:o===`cookie`&&K.Et()?(r=K,i=!0):n.Et()?(r=n,a=!0,i=!0):K.Et()?(r=K,i=!0):r=Oa,this.Vo=a,this.Go=i,r}hl(e){return`${this.rl}__${e}`}ll(e){return this.Vo&&!!e.split_storage}properties(){let e={};return U(this.props,(t,n)=>{let r=X(n);if(!r||r.exposure===`event`){var i;if(!(r==null||(i=r.shouldSkipFromEventProperties)==null)&&i.call(r,t))return;e[n]=t}}),e}load(e=!1){if(this.pi&&!e)return;let t=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()===`localstorage+cookie`,n=t?q.Dt(this.rl):null,r={};if(t)try{r=xa(K.Dt(this.rl)),U(r,(e,t)=>{(k(e)||M(e)||e===``)&&delete r[t]})}catch{}let i=this.Fo.Dt(this.rl);if(i&&(this.props=W({},i)),this.Zo&&this.Dl(),t&&i){let e=n?.[hr],t=n?.$user_state??Vi,a=i[hr],o=i.$user_state??Vi;if(a!==e||o!==t){this.Qo=!0,J.At($o(this.rl),!0);let n=W({},this.props);_a.forEach(e=>delete n[e]),o!==`anonymous`||t!==`identified`&&r.$user_state!==`anonymous`&&(k(e)||a===e)||(as(n,r),delete n[ri]),this.props=n;let i=new Set;_a.forEach(e=>{let t=X(e)?.storageGroup;t&&i.add(t)}),i.forEach(e=>{let t={};U(this.props,(n,r)=>{X(r)?.storageGroup===e&&(t[r]=n)}),O(t)?(q.Lt(this.hl(e)),this.Wo[e]={}):q.At(this.hl(e),t)&&(this.Wo[e]={persisted:!0,fingerprint:this.yl(t,e)})})}}J.Ot($o(this.rl))&&(this.Qo=!0)}Dl(){for(let e of Eo){let t=q.Dt(this.hl(e));if(t&&!O(t)){let n=this.vl(e);n.persisted=!0,this.Ll(e)||(n.fingerprint=this.yl(t,e)),this.Nl(e,t)||W(this.props,t)}}}Ll(e){return Object.keys(this.props).some(t=>X(t)?.storageGroup===e)}Nl(e,t){let n=Zo[e];if(!n)return!1;let r=t[n],i=this.props[n];return P(r)&&P(i)&&i>r}refreshKey(e){if(this.pi||e===`$fbc_persistence`&&this.el)return;let t=this.Zo?X(e)?.storageGroup:void 0,n=t?q.Dt(this.hl(t)):this.Fo.Dt(this.rl);if(n&&e in n)this._l(e,n[e],!1);else{if(t){let t=this.Fo.Dt(this.rl);if(t&&e in t)return void this._l(e,t[e],!1)}this.wl(e,!1)}}save(){if(this.pi)return;let e=this.$l();e>0?k(this.Al)&&(this.Al=setTimeout(()=>{this.Al=void 0,this.Fl()},e)):this.Fl()}flush(){k(this.Al)||(clearTimeout(this.Al),this.Al=void 0,this.Fl())}Fl(e=!1){if(this.pi||this.Jo&&!e)return;e||(this.syncCookieProperties(),this.el||this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()===`localstorage+cookie`||this.refreshKey(xr));let t=!e&&!this.Yo;t||(this.tl=!1);let n=!!t&&this.kl();if(this.tl)return void(this.Mr.debug&&z.warn(`skipping persistence write because storage belongs to a different distinct ID`));if(this.Zo)return this.ql(),void(n&&this.il.forEach(e=>e()));let r=this.jl(this.Fo,this.rl,this.props,Z);r===`written`&&this.Tl(this.props),r!==`failed`&&(this.Ko.clear(),this.Xo=!1,this.el=!1),n&&this.il.forEach(e=>e())}ql(){let{main:e,groups:t}=this.gl(),n=this.jl(this.Fo,this.rl,e,Z);n===`written`&&this.Tl(e),n!==`failed`&&(this.Xo=!1,this.el=!1,ts.forEach(e=>{var t;(t=X(e))!=null&&t.storageGroup||this.Ko.delete(e)}));for(let e of Eo){let n=t[e];if(O(n)&&!this.Wo[e]?.persisted){ts.forEach(t=>{X(t)?.storageGroup===e&&this.Ko.delete(t)});continue}let r=this.jl(q,this.hl(e),n,e);r!==`failed`&&ts.forEach(t=>{let n=X(t);n?.storageGroup!==e||r!==`written`&&n.volatile||this.Ko.delete(t)})}}gl(){let e={},t={flags:{},surveys:{}};return U(this.props,(n,r)=>{let i=X(r)?.storageGroup;i?t[i][r]=n:e[r]=n}),{main:e,groups:t}}yl(e,t){if(t===Z)return JSON.stringify(e)+`|`+this.Bl+`|`+this.Hl+`|`+this.zl;let n={};return U(e,(e,t)=>{n[t]=X(t)?.volatile?`__volatile__`:e}),JSON.stringify(n)}jl(e,t,n,r){let i=this.vl(r);if(r!==Z&&!i.dirty&&!k(i.fingerprint))return`skipped`;let a;try{if(a=this.yl(n,r),a===i.fingerprint)return i.dirty=!1,`skipped`}catch{a=void 0}return e.At(t,n,this.Bl,this.Hl,this.zl,this.Mr.debug)?(i.dirty=!1,r!==Z&&(i.persisted=!0),k(a)||(i.fingerprint=a),this.Vo&&(i.storageValue=q.Ot(t)),`written`):(this.Mr.debug&&z.warn(`failed to persist storage entry "${t}"; will retry on next save`),`failed`)}remove({keepGroupEntries:e=!1}={}){if(this.xl(),k(this.Al)||(clearTimeout(this.Al),this.Al=void 0),this.Fo.Lt(this.rl,!1),this.Fo.Lt(this.rl,!0),!e&&this.nl)for(let e of Eo)q.Lt(this.hl(e));e?delete this.Wo[Z]:this.Wo={},this.Il=void 0,this.Ml=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(D(e)){this.syncCookieProperties(),k(t)&&(t=`None`),this.Bl=k(n)?this.Ul:n;let r=!1;if(U(e,(e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this._l(n,e),r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(D(e)){this.syncCookieProperties(),this.Bl=k(t)?this.Ul:t;let n=!1;if(U(e,(t,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==t||D(t)||T(t))&&(this._l(r,t),n=!0)}),n)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();let t=typeof e==`string`?[e]:e,n=!1;for(let e of t)e in this.props&&(this.wl(e),n=!0);n&&this.save()}update_campaign_params(){let e=r?.URL;if(e===this.sl)return;let t=Bo(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),n=!O(ea(t));return n&&this.register(t),this.sl=e,n?t:void 0}update_search_keyword(){this.register(function(){let e=r?.referrer;return e?Ho(e):{}}())}update_referrer_info(){this.register_once({$referrer:Ko(),$referring_domain:r?.referrer&&Ao(r.referrer)?.host||Go},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let e=qo(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[Ti]:this.Go?{r:es(e.r),u:e.u?es(e.u):void 0}:e},void 0)}get_initial_props(){let e={};U([wi,Ci],t=>{let n=this.props[t];n&&U(n,function(t,n){e[`$initial_`+x(n)]=t})});let t=this.props[Ti];return t&&W(e,function(e,t=!1){let n=Jo(e,t),r={};return U(n,function(e,t){r[`$initial_${x(t)}`]=e}),r}(t,this.Mr.disable_capture_url_hashes)),e}safe_merge(e){return U(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){let r=e.persistence!==t.persistence,i=!((e,t)=>{if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||i,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,s=e.disable_persistence||!!n,c=!!this.pi&&!s;s||this.El(t,c),this.Mr=e,!s&&(r||i||o)&&(this.Il=void 0,this.Ml=void 0,this.El(R(R({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),c));let l=a||o?this.ol(e):this.Fo;this.Wl();let u=this.ll(e),d=a||u!==this.Zo,f=!s&&(d||e.cross_subdomain_cookie!==this.Hl||e.secure_cookie!==this.zl)&&this.Pl(c);this.Yo=d;try{if(this.Ul=this.Bl=e.cookie_expiration,this.set_disabled(s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){let e=this.props;this.clear(),this.Fo=l,this.Zo=u,this.props=e,this.save()}else o&&(this.Fo=l,s||(delete this.Wo[Z],this.Fl()))}finally{this.Yo=!1,f&&this.Ol()}}Wl(){let e=this.props[Ti];if(!this.Go||!D(e)||typeof e.r!=`string`)return;let t=es(e.r),n=typeof e.u==`string`?es(e.u):e.u;t===e.r&&n===e.u||this._l(Ti,R(R({},e),{},{r:t,u:n}))}set_disabled(e){this.pi=e,this.pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Hl&&(this.Hl=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.zl&&(this.zl=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){let n=this.props.__timers||{};n[e]=t,this._l(Sr,n),this.save()}remove_event_timer(e){let t=this.props.__timers||{},n=t[e];return k(n)||(delete t[e],this._l(Sr,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this._l(e,t),this.save()}_l(e,t,n=!0){var r;let i=this.props[e];this.props[e]=t,n&&(e!==`distinct_id`&&e!==`$user_state`||i===t||(this.Xo=!0),e!==`$fbc_persistence`||rs(i,t)||(this.el=!0),this.Cl(e,i,t),(r=X(e))!=null&&r.volatile||this.Sl(e))}wl(e,t=!0){delete this.props[e],t&&(ns(e)&&this.dl(e,!0),e===`$fbc_persistence`&&(this.el=!0),this.Sl(e))}Sl(e){let t=X(e)?.storageGroup;t&&(this.vl(t).dirty=!0)}vl(e){return this.Wo[e]||(this.Wo[e]={})}},ss={GZipJS:`gzip-js`,Base64:`base64`},cs={Activation:`events`,Cancellation:`cancelEvents`},ls={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},us={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},ds={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`},fs={Popover:`popover`,Inline:`inline`};function ps(e){let t=!0;return{dispose(){if(t){t=!1;let n=e();n&&E(n.then)&&n.then(void 0,()=>{})}}}}var ms={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`},hs={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`},gs=B(`[RateLimiter]`),_s=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{let t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{gs.info(`${e||`events`} is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4})}catch(e){gs.warn(`could not rate limit - continuing. Error: "${e?.message}"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(`$capture_rate_limit`)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);let o=1>a.tokens;if(o||e||(a.tokens=Math.max(0,a.tokens-1)),o&&!e){let e=(P(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this.Vl(e)&&(a.dropped=0)}return this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(`$capture_rate_limit`,a),{isRateLimited:o,remainingTokens:a.tokens}}Gl(e){let t=this.instance.config.property_denylist;return!T(t)||!t.includes(e)}Zl(){if(this.Gl(`$current_url`)&&this.Gl(`$pathname`)&&i?.pathname)return`${i.origin??``}${i.pathname}`}Vl(e){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=this.Zl(),a=this.Gl(`$session_id`)?(t=this.instance).get_session_id?.call(t):void 0,o=[`${e} event(s) dropped since the last warning`,i?`triggered on ${i}`:void 0,a?`session ${a}`:void 0].filter(Boolean).join(`, `);return!!this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited: ${o}. Config is set to ${r} events per second and ${n} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){let t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},vs=B(`[RemoteConfig]`),ys=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ql(e){var t,n;f.__PosthogExtensions__?.loadExternalDependency?(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`remote-config`,()=>e(this.remoteConfig)):e()}Jl(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return vs.info(`Using preloaded remote config`,this.remoteConfig),void this.Kl(this.remoteConfig);if(this._instance.Yl())return void vs.warn(`Remote config is disabled. Falling back to local config.`);this.Ql(e=>{if(!e)return vs.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Jl(e=>{this.Kl(e.json,e)});this.Kl(e)})}catch(e){vs.error(`Error loading remote config`,e),this.Kl()}}Kl(e,t){!e&&t&&(t.statusCode===0?t.error||vs.warn(`Failed to fetch remote config from PostHog.`):vs.error(`Failed to fetch remote config from PostHog.`));try{this._instance.Kl(e?{ok:!0,config:e}:{ok:!1})}catch(e){vs.error(`Error applying remote config`,e)}if(!1!==e?.hasFeatureFlags&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var n;(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded()}catch(e){vs.error(`Error loading feature flags`,e)}}},bs=Uint8Array,xs=Uint16Array,Ss=Uint32Array,Cs=new bs([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]),ws=new bs([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]),Ts=new bs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Es=function(e,t){for(var n=new xs(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Ss(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},Ds=Es(Cs,2),Os=Ds[1];Ds[0][28]=258,Os[258]=28;for(var ks=Es(ws,0)[1],As=new xs(32768),Q=0;32768>Q;++Q){var js=(43690&Q)>>>1|(21845&Q)<<1;As[Q]=((65280&(js=(61680&(js=(52428&js)>>>2|(13107&js)<<2))>>>4|(3855&js)<<4))>>>8|(255&js)<<8)>>>1}var Ms=function(e,t,n){for(var r=e.length,i=0,a=new xs(t);r>i;++i)++a[e[i]-1];var o,s=new xs(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new xs(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[As[d]>>>c]=l}else for(o=new xs(r),i=0;r>i;++i)o[i]=As[s[e[i]-1]++]>>>15-e[i];return o},Ns=new bs(288);for(Q=0;144>Q;++Q)Ns[Q]=8;for(Q=144;256>Q;++Q)Ns[Q]=9;for(Q=256;280>Q;++Q)Ns[Q]=7;for(Q=280;288>Q;++Q)Ns[Q]=8;var Ps=new bs(32);for(Q=0;32>Q;++Q)Ps[Q]=5;var Fs=Ms(Ns,9,0),Is=Ms(Ps,5,0),Ls=function(e){return(e/8|0)+(7&e&&1)},Rs=function(e,t,n){(t==null||0>t)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof xs?xs:e instanceof Ss?Ss:bs)(n-t);return r.set(e.subarray(t,n)),r},zs=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Bs=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Vs=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new bs(0),0];if(i==1){var o=new bs(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new xs(f+1),m=Hs(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new bs(p),m]},Hs=function(e,t,n){return e.s==-1?Math.max(Hs(e.l,t,n+1),Hs(e.r,t,n+1)):t[e.s]=n},Us=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new xs(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},Ws=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Gs=function(e,t,n){var r=n.length,i=Ls(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},Ks=function(e,t,n,r,i,a,o,s,c,l,u){zs(t,u++,n),++i[256];for(var d=Vs(i,15),f=d[0],p=d[1],m=Vs(a,15),h=m[0],g=m[1],_=Us(f),v=_[0],y=_[1],b=Us(h),x=b[0],S=b[1],C=new xs(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var ee=Vs(C,7),T=ee[0],E=ee[1],D=19;D>4&&!T[Ts[D-1]];--D);var O,k,A,j,M=l+5<<3,N=Ws(i,Ns)+Ws(a,Ps)+o,P=Ws(i,f)+Ws(a,h)+o+14+3*D+Ws(C,T)+(2*C[16]+3*C[17]+7*C[18]);if(N>=M&&P>=M)return Gs(t,u,e.subarray(c,c+l));if(zs(t,u,1+(N>P)),u+=2,N>P){O=Ms(f,p,0),k=f,A=Ms(h,g,0),j=h;var te=Ms(T,E,0);for(zs(t,u,y-257),zs(t,u+5,S-1),zs(t,u+10,D-4),u+=14,w=0;D>w;++w)zs(t,u+3*w,T[Ts[w]]);u+=3*D;for(var F=[v,x],ne=0;2>ne;++ne){var re=F[ne];for(w=0;re.length>w;++w)zs(t,u,te[ie=31&re[w]]),u+=T[ie],ie>15&&(zs(t,u,re[w]>>>5&127),u+=re[w]>>>12)}}else O=Fs,k=Ns,A=Is,j=Ps;for(w=0;s>w;++w)if(r[w]>255){var ie;Bs(t,u,O[257+(ie=r[w]>>>18&31)]),u+=k[ie+257],ie>7&&(zs(t,u,r[w]>>>23&31),u+=Cs[ie]);var I=31&r[w];Bs(t,u,A[I]),u+=j[I],I>3&&(Bs(t,u,r[w]>>>5&8191),u+=ws[I])}else Bs(t,u,O[r[w]]),u+=k[r[w]];return Bs(t,u,O[256]),u+k[256]},qs=new Ss([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Js=new bs(0),Ys=function(){for(var e=new Ss(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Xs=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Zs(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=Ys[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l,u=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new bs(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Gs(c,l,e.subarray(u,d)):(c[u]=a,l=Gs(c,l,e.subarray(u,o)))}else{for(var f=qs[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new xs(32768),_=new xs(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new Ss(25e3),S=new xs(288),C=new xs(32),w=0,ee=0,T=(u=0,0),E=0,D=0;o>u;++u){var O=b(u),k=32767&u,A=_[O];if(g[k]=A,_[O]=k,u>=E){var j=o-u;if((w>7e3||T>24576)&&j>423){l=Ks(e,c,0,x,S,C,ee,T,D,u-D,l),T=w=ee=0,D=u;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)C[M]=0}var N=2,P=0,te=m,F=k-A&32767;if(j>2&&O==b(u-F))for(var ne=Math.min(p,j)-1,re=Math.min(32767,u),ie=Math.min(258,j);re>=F&&--te&&k!=A;){if(e[u+N]==e[u+N-F]){for(var I=0;ie>I&&e[u+I]==e[u+I-F];++I);if(I>N){if(N=I,P=F,I>ne)break;var ae=Math.min(F,I-2),oe=0;for(M=0;ae>M;++M){var se=u-F+M+32768&32767,ce=se-g[se]+32768&32767;ce>oe&&(oe=ce,A=se)}}}F+=(k=A)-(A=g[k])+32768&32767}if(P){x[T++]=268435456|Os[N]<<18|ks[P];var le=31&Os[N],ue=31&ks[P];ee+=Cs[le]+ws[ue],++S[257+le],++C[ue],E=u+N,++w}else x[T++]=e[u],++S[e[u]]}}l=Ks(e,c,a,x,S,C,ee,T,D,u-D,l),a||(l=Gs(c,l,Js))}return Rs(s,0,r+Ls(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c,!l)),d=u.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Xs(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(u,t),Xs(u,d-8,n.d()),Xs(u,d-4,r),u}var Qs=!!o||!!a,$s=`text/plain`,ec=!1,tc=(e,t)=>{let[n,r]=e.split(`#`),[i,a]=n.split(`?`);if(!a)return e;let o=a.split(`&`).filter(e=>e.split(`=`)[0]!==t).join(`&`);return`${i}${o?`?${o}`:``}${r?`#${r}`:``}`},nc=(e,t,n=!0)=>{let[r,i]=e.split(`?`),a=R({},t),o=i?.split(`&`).map(e=>{var t;let[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],`${r}=${o}`})??[],s=function(e,t=`&`){let n,r,i=[];return U(e,function(e,t){k(e)||k(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)}),i.join(t)}(a);return s&&o.push(s),o.length>0?`${r}?${o.join(`&`)}`:r},rc=e=>{if(e.Xl)return e.Xl;let{data:t,compression:n}=e;if(!t)return;if(n===ss.GZipJS){let e=Zs(function(e){var t=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var n=new bs(e.length+(e.length>>>1)),r=0,i=function(e){n[r++]=e},a=0;t>a;++a){if(r+5>n.length){var o=new bs(r+8+(t-a<<1));o.set(n),n=o}var s=e.charCodeAt(a);128>s?i(s):2048>s?(i(192|s>>>6),i(128|63&s)):s>55295&&57344>s?(i(240|(s=65536+(1047552&s)|1023&e.charCodeAt(++a))>>>18),i(128|s>>>12&63),i(128|s>>>6&63),i(128|63&s)):(i(224|s>>>12),i(128|s>>>6&63),i(128|63&s))}return Rs(n,0,r)}(ko(t)),{mtime:0});return{contentType:$s,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(n===ss.Base64){let e=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:ko(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))))}(ko(t)));return{contentType:`application/x-www-form-urlencoded`,body:e,estimatedSize:new Blob([e]).size}}let r=ko(t);return{contentType:`application/json`,body:r,estimatedSize:new Blob([r]).size}},ic=e=>{let t=()=>e.transport===`sendBeacon`?{url:nc(e.url,{compression:ss.Base64}),encodedBody:rc(R(R({},e),{},{compression:ss.Base64,Xl:void 0}))}:{url:tc(e.url,`compression`),encodedBody:rc(R(R({},e),{},{compression:void 0,Xl:void 0}))},n;try{n=rc(e)}catch(n){if(kn(e.compression,jo(e.url,`compression`)))return z.error(`Failed to gzip request body, sending uncompressed payload`,n),t();throw n}return n&&kn(e.compression,jo(e.url,`compression`))&&!((r=n.body)instanceof ArrayBuffer?On(new Uint8Array(r)):ArrayBuffer.isView(r)&&On(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(ec=!0,t()):{url:e.url,encodedBody:n};var r},ac=e=>{try{return ic(e)}catch(n){var t;z.error(n),(t=e.callback)==null||t.call(e,{statusCode:0,error:n});return}},oc=function(){var e=L(function*(e){let t=yield function(e){return Fn.apply(this,arguments)}(ko(e.data),V.DEBUG,{rethrow:!0});if(!t)return e;let n=yield t.arrayBuffer();return R(R({},e),{},{Xl:{contentType:$s,body:n,estimatedSize:n.byteLength}})});return function(t){return e.apply(this,arguments)}}(),sc=/Failed to fetch|NetworkError|Load failed/i,cc=e=>e?.name===`TypeError`&&sc.test(e?.message||``),lc=e=>{let t=ac(e);if(!t)return;let n=new o,{url:r,encodedBody:i}=t;n.open(e.method||`GET`,r,!0);let{contentType:a,body:s}=i??{};U(e.headers,function(e,t){n.setRequestHeader(t,e)}),a&&n.setRequestHeader(`Content-Type`,a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var t;let r={statusCode:n.status,text:n.responseText};if(n.status===200)try{r.json=JSON.parse(n.responseText)}catch{}(t=e.callback)==null||t.call(e,r)}},n.send(s)},uc=e=>{let t=ac(e);if(!t)return;let{url:n,encodedBody:r}=t,{contentType:i,body:o,estimatedSize:c}=r??{},l=new Headers;U(e.headers,function(e,t){l.append(t,e)}),i&&l.append(`Content-Type`,i);let u=null,d=!1;if(s){let t=new s;u={signal:t.signal,timeout:setTimeout(()=>{var n;d=!0,t.abort(Tt(`AbortError`,`PostHog request timed out`+((n=e.timeout)?` after ${n}ms`:``)))},e.timeout)}}let f=t=>{var n;d&&t?.name===`AbortError`||cc(t)?z.warn(t):z.error(t),(n=e.callback)==null||n.call(e,{statusCode:0,error:t})};try{a(n,R({method:e?.method||`GET`,headers:l,keepalive:e.method===`POST`&&!e.ta&&52428.8>(c||0),body:o,signal:u?.signal},e.fetchOptions)).then(t=>t.text().then(n=>{var r;let i={statusCode:t.status,text:n};if(t.status===200)try{i.json=JSON.parse(n)}catch(e){z.error(e)}(r=e.callback)==null||r.call(e,i)})).catch(f).finally(()=>u?clearTimeout(u.timeout):null)}catch(e){u&&clearTimeout(u.timeout),f(e)}},dc=e=>{try{let{url:t,encodedBody:r}=ic(e),{contentType:i,body:o,estimatedSize:s}=r??{};if(!o)return;let c=o instanceof Blob?o:new Blob([o],{type:i});if(n.sendBeacon(t,c))return;let l=T(e.data)?e.data:e.data?.batch;if(T(l)&&l.length>1&&(s??0)>16384){let t=Math.ceil(l.length/2),n=t=>T(e.data)?t:R(R({},e.data),{},{batch:t});dc(R(R({},e),{},{data:n(l.slice(0,t))})),dc(R(R({},e),{},{data:n(l.slice(t))}));return}z.warn(`Beacon of ~${s??0} bytes was rejected by the browser, falling back to ${a?`fetch`:`XHR`}`),a?uc(R(R({},e),{},{ta:!0})):lc(e)}catch(e){z.warn(`Beacon send failed`,e)}},fc=(e,t,n,r)=>{let i=r===`query`?t===`POST`?`sent_at`:`_`:void 0;return nc(n===ss.GZipJS?tc(e,`compression`):e,R(R({},i?{[i]:Date.now().toString()}:{}),n===ss.GZipJS?{}:{compression:n}))},pc=(()=>{let e=[];return a&&e.push({transport:`fetch`,method:uc}),o&&e.push({transport:`XHR`,method:lc}),n!=null&&n.sendBeacon&&e.push({transport:`sendBeacon`,method:dc}),e})(),mc=class{constructor(e,t){this.ea=!0,this.ia=[],this.na=me(t?.flush_interval_ms||3e3,250,5e3,z.createLogger(`flush interval`),3e3),this.sa=e}enqueue(e){this.ia.push(e),this.ra||this.oa()}unload(){this.la();let e=this.ia.length>0?this.aa():{},t=Object.values(e);[...t.filter(e=>e.url.indexOf(`/e`)===0),...t.filter(e=>e.url.indexOf(`/e`)!==0)].map(e=>{this.ua(R(R({},e),{},{transport:`sendBeacon`}))})}enable(){this.ea=!1,this.oa()}oa(){this.ea||(this.ra=setTimeout(()=>{if(this.la(),this.ia.length>0){let e=this.aa();for(let t in e){let n=e[t],r=new Date().getTime();n.data&&T(n.data)&&U(n.data,e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp}),this.ua(n)}}},this.na))}ua(e){try{this.sa(e)}catch(e){z.error(e)}}la(){clearTimeout(this.ra),this.ra=void 0}aa(){let e={};return U(this.ia,t=>{var n;let r=t,i=(r?r.batchKey:null)||r.url;k(e[i])&&(e[i]=R(R({},r),{},{data:[]})),(n=e[i].data)==null||n.push(r.data)}),this.ia=[],e}},hc=[`retriesPerformedSoFar`],gc=class{constructor(e){this._instance=e,this.ha=!1,this.ca=3e3,this.ia=[],this.ia=[],this.da=!0,this.resume()}resume(){if(!k(e)&&`onLine`in e.navigator){if(this.da=e.navigator.onLine,this.va)return;this.va=()=>{this.da=!0,this.fa()},this.pa=()=>{this.da=!1},G(e,`online`,this.va),G(e,`offline`,this.pa)}}get length(){return this.ia.length}retriableRequest(e){let{retriesPerformedSoFar:t}=e,n=Rn(e,hc);te(t)&&(n.url=nc(n.url,{retry_count:t})),this._instance._send_request(R(R({},n),{},{callback:e=>{var r;if(e.statusCode!==200&&(400>e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(t??0))return void this.Ls(R({retriesPerformedSoFar:t},n));e.statusCode===0&&z.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${t??0} retries.`)}(r=n.callback)==null||r.call(n,e)}}))}Ls(e){let t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;let n=function(e){let t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=(Math.random()-.5)*(r-n);return Math.ceil(r+i)}(t),r=Date.now()+n;this.ia.push({retryAt:r,requestOptions:e});let i=`Enqueued failed request for retry in ${n}`;navigator.onLine||(i+=` (Browser is offline)`),z.warn(i),this.ha||(this.ha=!0,this.ga())}ga(){if(this.ma&&clearTimeout(this.ma),this.ia.length===0)return this.ha=!1,void(this.ma=void 0);this.ma=setTimeout(()=>{this.da&&this.ia.length>0&&this.fa(),this.ga()},this.ca)}fa(){let e=Date.now(),t=[],n=this.ia.filter(n=>e>n.retryAt||(t.push(n),!1));if(this.ia=t,n.length>0)for(let{requestOptions:e}of n)this.retriableRequest(e)}unload(){this.ma&&=(clearTimeout(this.ma),void 0),this.ha=!1,k(e)||(this.va&&=(e.removeEventListener(`online`,this.va),void 0),this.pa&&=(e.removeEventListener(`offline`,this.pa),void 0));for(let{requestOptions:e}of this.ia)try{this._instance._send_request(R(R({},e),{},{transport:`sendBeacon`}))}catch(e){z.error(e)}this.ia=[]}},_c=class{constructor(e){this._instance=e,this.ya=()=>{this.ba||={};let e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.ba.lastScrollY=Math.ceil(t),this.ba.maxScrollY=Math.max(t,this.ba.maxScrollY??0),this.ba.maxScrollHeight=Math.max(n,this.ba.maxScrollHeight??0),this.ba.lastContentY=r,this.ba.maxContentY=Math.max(r,this.ba.maxContentY??0),this.ba.maxContentHeight=Math.max(i,this.ba.maxContentHeight??0)}}get _a(){return this._instance.config.scroll_root_selector}getContext(){return this.ba}resetContext(){let e=this.ba;return setTimeout(this.ya,0),e}startMeasuringScrollPosition(){G(e,`scroll`,this.ya,{capture:!0}),G(e,`scrollend`,this.ya,{capture:!0}),G(e,`resize`,this.ya)}scrollElement(){if(this._a){let n=T(this._a)?this._a:[this._a];for(let r of n){var t;let n=e==null||(t=e.document)==null?void 0:t.querySelector(r);if(n)return n}return}var n;return e==null||(n=e.document)==null?void 0:n.documentElement}wa(t){var n,r;let i=t===`y`?`scrollTop`:`scrollLeft`;if(this._a){let e=this.scrollElement();return e&&e[i]||0}return e?t===`y`?e.scrollY||e.pageYOffset||((n=e.document)==null||(n=n.documentElement)==null?void 0:n.scrollTop)||0:e.scrollX||e.pageXOffset||((r=e.document)==null||(r=r.documentElement)==null?void 0:r.scrollLeft)||0:0}scrollY(){return this.wa(`y`)}scrollX(){return this.wa(`x`)}},vc=e=>qo(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),yc=class{constructor(e,t,n,r){this.je=e=>{let t=this.ka();if(t&&t.sessionId===e)return;let n={sessionId:e,props:this.Sa(this._instance)};this.xa.register({[xi]:n})},this._instance=e,this.Ca=t,this.xa=n,this.Sa=r||vc,this.Ca.onSessionId(this.je)}ka(){return this.xa.props[xi]}getSetOnceProps(){let e=this.ka()?.props;return e?`r`in e?Jo(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){let e={};return U(ea(this.getSetOnceProps()),(t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_${x(n)}`]=t}),e}},bc=class{on(e,t){return this.$a[e]||(this.$a[e]=[]),this.$a[e].push(t),()=>{this.$a[e]=this.$a[e].filter(e=>e!==t)}}emit(e,t){for(let n of this.$a[e]||[])n(t);for(let n of this.$a[`*`]||[])n(e,t)}constructor(){this.$a={}}},xc=B(`[SessionId]`),Sc=864e5,Cc=class{on(e,t){return this.Ta.on(e,t)}constructor(e,t,n){var r;if(this.Ia=null,this.Ma=null,this.Ea=[],this.Pa=void 0,this.Ra=!1,this.Ta=new bc,this.Aa=(e,t)=>!(!te(e)||!te(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===`always`)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Mr=e.config,this.xa=e.persistence,this.Be=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Fa=void 0,this._sessionActivityTimestamp=null,this.Oa=t||da,this.Da=n||da;let i=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*me(this.Mr.session_idle_timeout_seconds||1800,60,36e3,xc.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.La(),this.Na=`ph_`+i+`_window_id`,this.qa=`ph_`+i+`_primary_window_exists`,this.ja()){let e=J.Dt(this.Na),t=J.Dt(this.qa);e&&!t?this.Be=e:J.Lt(this.Na),J.At(this.qa,!0)}(r=this.Mr.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Ba()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return k(this.Ea)&&(this.Ea=[]),this.Ea.push(e),this.Xt&&e(this.Xt,this.Be),()=>{this.Ea=this.Ea.filter(t=>t!==e)}}ja(){return this.Mr.persistence!==`memory`&&!this.xa.pi&&J.Et()}Ha(e){e!==this.Be&&(this.Be=e,this.ja()&&J.At(this.Na,e))}za(){return this.Be?this.Be:this.ja()?J.Dt(this.Na):null}Ua(e){let t=this.Ia;return!M(t)&&!M(e)&&5e3>Math.abs(e-t)}Wa(e,t,n){let r=t!==this._sessionActivityTimestamp,i=!(e!==this.Xt||n!==this._sessionStartTimestamp);this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Xt=e,i&&!r||i&&this.Ua(t)||(this.Ia=t,this.xa.register({[Br]:[t,e,n]}))}Va(){let e=this.Mr?.persistence_save_debounce_ms;return te(e)&&e>0}Ga(){this.Va()?this.xa.refreshKey(Br):(this.xa.flush(),this.xa.load())}Za(){if(M(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Ia)return;this.Ga();let[,e,t]=this.Qa();e===this.Xt&&t===this._sessionStartTimestamp&&(this.Ia=this._sessionActivityTimestamp,this.xa.register({[Br]:[this._sessionActivityTimestamp,this.Xt??null,this._sessionStartTimestamp]}),this.xa.flush())}Ja(){let[e]=this.Qa(),t=te(e)?e:0,n=te(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}Ka(e){return this.Ga(),this.Aa(e,this.Ja())}Qa(){let e=this.xa.props[Br];return T(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Ia=null,this.Fa=void 0,clearTimeout(this.Ya),this.Ya=void 0,this.Wa(null,null,null)}setBootstrapSessionId(e,t=!1){let n=((e,t=new Date().getTime())=>{try{let n=(e=>{let t=e.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})(e);return n>t+6e4?void xc.error(`Bootstrap sessionID cannot be in the future`):n}catch(e){xc.error(`Invalid sessionID in bootstrap`,e);return}})(e);return!k(n)&&(t?this.Fa={sessionId:e,sessionStartTimestamp:n}:this.Wa(e,new Date().getTime(),n),!0)}destroy(){this.Ra=!0,this.Za(),clearTimeout(this.Ya),this.Ya=void 0,this.Pa&&e&&(e.removeEventListener(Gi,this.Pa,{capture:!1}),this.Pa=void 0),this.Ea=[]}Ba(){this.Pa=()=>{this.Za(),this.ja()&&J.Lt(this.qa)},G(e,Gi,this.Pa,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,n=!1){if(this.Mr.cookieless_mode===`always`)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);let r=t||new Date().getTime(),i=this.Xt;if(n)this.Ma=r;else if(M(this.Ma)||this.Ma>r||r-this.Ma>=1e3){var a,o;(a=(o=this.xa).syncCookieProperties)==null||a.call(o),this.Ma=r}let[,s,c]=this.Qa(),l=!k(i)&&s!==i,u=this.Ja(),d=this.za(),f=this.Fa,p=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>Sc),m=f?p:te(c)&&Math.abs(r-c)>Sc,h=!1,g=l,_=!s||!!f,v=s,y=!_&&!e&&this.Aa(r,u);if(y&&(y=this.Ka(r),y||xc.info(`cross-tab refresh kept the session alive`,{sessionId:s}),[,s,c]=this.Qa()),_||y||m){g=!1;let e=f&&!p;s=e?f.sessionId:this.Oa(),d=this.Da(),xc.info(`new session ID assigned`,{sessionId:s,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m}}),c=e?f.sessionStartTimestamp:r,this.Fa=void 0,h=!0}else d||(d=this.Da(),h=!0),g||=s!==v,g&&(xc.info(`adopted cross-tab session id`,{sessionId:s,windowId:d}),h=!0);let b=te(u)&&e&&!m?u:r,x=te(c)?c:new Date().getTime();this.Ha(d),this.Wa(s,b,x),e||this.La();let S={noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m,crossTabAdoption:g};return h&&this.Ea.forEach(e=>e(s,d,S)),{sessionId:s,windowId:d,sessionStartTimestamp:x,changeReason:h?S:void 0,lastActivityTimestamp:u}}La(){this.Ra||(clearTimeout(this.Ya),this.Ya=setTimeout(()=>{if(!this.Ra)if(this.Ka(new Date().getTime())){let e=this.Xt;this.resetSessionId(),this.Ta.emit(`forcedIdleReset`,{idleSessionId:e})}else this.La()},1.1*this.sessionTimeoutMs))}},wc=function(e,t){if(!e)return!1;let n=e.userAgent;if(n&&pe(n,t))return!0;try{let n=e?.userAgentData;if(n?.brands&&n.brands.some(e=>pe(e?.brand,t)))return!0}catch{}return!!e.webdriver};function Tc(){return(Tc=L(function*(){let e=n?.userAgentData;if(e?.getHighEntropyValues)try{let t=(yield e.getHighEntropyValues([`model`]))?.model;return A(t)&&t.length>0?t:void 0}catch(e){z.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}})).apply(this,arguments)}function Ec(e,t){let n=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_${t}/${e.id}/${e.current_iteration}`),n}function Dc(e){var t;return!!(!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null)&&t.length)}var Oc=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},kc=e=>e.toLowerCase(),Ac={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Oc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Oc(t,e))),icontains:(e,t)=>t.map(kc).some(t=>e.map(kc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(kc).every(t=>e.map(kc).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{let n=parseFloat(t);return!isNaN(n)&&e.some(e=>n>parseFloat(e))}),lt:(e,t)=>t.some(t=>{let n=parseFloat(t);return!isNaN(n)&&e.some(e=>n<parseFloat(e))})};function jc(e,t){return!e||Object.entries(e).every(([e,n])=>{let r=t?.[e];if(r==null)return!1;let i=Ac[n.operator];return!!i&&i(n.values,[String(r)])})}function Mc(e,t,n){return ko({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Nc=`custom`,Pc=`i.posthog.com`,Fc=/^\/static\//,Ic=[`/s/`,`/e/`,`/i/`],Lc=class{constructor(e){this.Xa={},this.instance=e}get apiHost(){let e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){let e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){let e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.${Pc}`,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.Xa[this.apiHost]||(this.Xa[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`:Nc),this.Xa[this.apiHost]}tu(e){if(!Fc.test(e))return;let t=this.instance.config.asset_host;return typeof t==`string`&&t.trim().replace(/\/$/,``)||void 0}eu(e){let t=Ao(e);return t?t.protocol+`//`+t.host+t.pathname:void 0}iu(e,t,n){if(e===`ui`)return n;let r=n,i=this.instance.config.rewriteRequestPath;if(i){let e=Ao(n)?.href||n;r=i(new URL(e)).toString()}if(i&&e===`api`&&Ic.some(e=>t.indexOf(e)===0)){let e=this.eu(r);if(e){let t=this.apiHost,n=this.nu;n?.apiHost===t&&n.rewriteRequestPath===i||(n={apiHost:t,rewriteRequestPath:i,urls:new Set},this.nu=n),n.urls.add(e)}}return r}isIngestionEndpoint(e){let t=this.nu,n=this.eu(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&t.urls.has(n)}endpointFor(e,t=``){if(t&&=t[0]===`/`?t:`/${t}`,e===`ui`)return this.iu(e,t,this.uiHost+t);if(e===`flags`)return this.iu(e,t,this.flagsApiHost+t);if(e===`assets`){let n=this.tu(t);if(n)return this.iu(e,t,`${n}${t}`)}if(this.region===Nc)return this.iu(e,t,this.apiHost+t);let n=Pc+t;switch(e){case`assets`:return this.iu(e,t,`https://${this.region}-assets.${n}`);case`api`:return this.iu(e,t,`https://${this.region}.${n}`)}}},$=B(`[Surveys]`),Rc=e=>{try{let t=(e=>((e,t)=>`seenSurvey_${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`)(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){$.error(`Failed to persist survey seen state`,e)}},zc=[ls.Popover,ls.Widget,ls.API],Bc={ignoreConditions:!1,ignoreDelay:!1,displayType:fs.Popover},Vc=B(`[PostHog ExternalIntegrations]`),Hc={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},Uc=class{constructor(e){this._instance=e}No(e,t){var n,r;(n=f.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,e,e=>{if(e)return Vc.error(`failed to load script`,e);t()})}startIfEnabledOrStop(){for(let[r,i]of Object.entries(this._instance.config.integrations??{})){var e,t,n;i&&!(!((e=f.__PosthogExtensions__)==null||(e=e.integrations)==null)&&e[r])&&this.No(Hc[r],()=>{var e;(e=f.__PosthogExtensions__)==null||(e=e.integrations)==null||(e=e[r])==null||e.start(this._instance)}),!i&&!((t=f.__PosthogExtensions__)==null||(t=t.integrations)==null)&&t[r]&&((n=f.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[r])==null||n.stop())}}},Wc=class{constructor(e,t){this.$=e,this.po=t,this.su=new Map,this.So=!1}add(e){var t=this;return L(function*(){if(t.So)throw Error(`Cannot add an extension to a disposed ExtensionRuntime`);if(t.su.has(e.name))throw Error(`Browser extension "${e.name}" is already registered`);t.su.set(e.name,e);try{let n=e.setup(t.po);n&&(yield n)}catch(n){let r=t.su.get(e.name)===e;r&&t.su.delete(e.name),t.$.error(`Failed to set up browser extension "${e.name}"`,n),r&&t.ru(e)}})()}getExtension(e){return this.su.get(e)}dispose(){if(this.So)return;this.So=!0;let e=Array.from(this.su.values()).reverse();this.su.clear();for(let t of e)this.ru(t)}ru(e){try{let t=e.dispose?.call(e);t&&E(t.then)&&t.then(void 0,t=>{this.$.error(`Failed to dispose browser extension "${e.name}"`,t)})}catch(t){this.$.error(`Failed to dispose browser extension "${e.name}"`,t)}}},Gc=class{constructor(e){this._instance=e}initialize(){}get(e){let t=this._instance.persistence;if(typeof e==`string`)return t?.get_property(e);let n={};for(let r of e){let e=t?.get_property(r);k(e)||(n[r]=e)}return n}set(e,t){var n;(n=this._instance.persistence)==null||n.register(typeof e==`string`?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}},Kc=`extensionsRemoteConfig`,qc=class{constructor(e){this.instance=e,this.So=!1,this.$=z,this.ou=e.lu,this.kv=new Gc(e),this.onEvent=e=>ps(this.instance.on(`eventCaptured`,t=>{try{e({event:t.event,properties:t.properties})}catch(e){this.$.error(`Browser extension event listener failed`,e)}})),this.onRemoteConfig=e=>{if(this.So)return ps(()=>{});let t=t=>{try{e(t)}catch(e){this.$.error(`Browser extension remote config listener failed`,e)}},n=this.instance.au.on(Kc,t);return this.ou&&t(this.ou),ps(n)},this.uu=new Wc(z.createLogger(`[BrowserExtensions]`),this)}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){return this.instance.get_property(`$device_id`)??this.distinctId}get deviceId(){let e=this.instance.get_property(gr);return typeof e==`string`?e:void 0}get library(){return{name:V.LIB_NAME,version:V.LIB_VERSION}}get initialPersonProperties(){return this.instance.persistence?.get_initial_props()??{}}get groups(){return this.instance.getGroups()}get session(){try{let e=this.instance.sessionManager?.checkAndGetSessionAndWindowId(!0);return{sessionId:e?.sessionId??``,windowId:e?.windowId??``,sessionStartTimestamp:e?.sessionStartTimestamp??0}}catch{return{sessionId:``,windowId:``,sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.uu.add(e)}getExtension(e){return this.uu.getExtension(e)}capture(e,t,n){var r=this;return L(function*(){n?r.instance.capture(e,t,{timestamp:n.timestamp,uuid:n.uuid,$set:n.set,$set_once:n.setOnce}):r.instance.capture(e,t)})()}registerDynamicEventProperties(e){return ps(this.instance.hu(e))}handleRemoteConfig(e){this.So||(this.ou=e,this.instance.au.emit(Kc,e))}sendRequest(e){var t=this;return L(function*(e,n={}){let r=t.instance.requestRouter.endpointFor(n.target??`api`,e),i={method:n.method,url:n.query?nc(r,n.query):r,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport,compression:n.compression,compressionFallback:n.target===`flags`&&n.compression===`best-available`?g.Base64:void 0,timestampMode:n.sentAt};return n.transport===`sendBeacon`?(t.instance._send_request(i),{statusCode:202}):new Promise(e=>{i.callback=e,t.instance._send_request(i)})}).apply(this,arguments)}dispose(){this.So||(this.So=!0,this.uu.dispose())}},Jc={},Yc=0,Xc=()=>{},Zc=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,Qc=`Surveys module not available`,$c=`sanitize_properties is deprecated. Use before_send instead`,el=`Invalid value for property_denylist config: `,tl=/^[A-Za-z0-9_-]{1,400}$/,nl=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,rl=[`token`,`distinct_id`,Oi],il=`posthog`,al=!Qs&&l?.indexOf(`MSIE`)===-1&&l?.indexOf(`Mozilla`)===-1,ol=e=>{let t={};return e&&e!==`unset`?(`2025-11-30`>e||(t.strictMinimumDuration=!0),`2026-05-30`>e||(t.canvasCapture={resolutionScale:.6}),`2026-06-25`>e||(t.streamNetworkBody=!0),`2026-08-30`>e||(t.captureJsonLd=!0),t):t},sl=t=>{var n;return R({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:ra(r?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:Xc,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:t??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:i&&A(i?.search)&&i.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:`fallback`,enable_recording_console_log:void 0,secure_cookie:(e==null||(n=e.location)==null?void 0:n.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){z.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ui,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:Xc},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:Ja,ignore_text_selection:!0}:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:ol(e),external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>=`2026-05-30`?250:0,split_storage:!(!e||`2026-05-30`>e),detect_google_search_app:!(!e||`2026-05-30`>e),disable_capture_url_hashes:!(!e||`2026-06-25`>e),cookieWinsOnConflict:!(!e||e===`unset`||`2026-08-29`>e)}))(t))},cl=[[`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`]],ll=e=>{let t={};for(let[n,r]of cl)k(e[n])||(t[r]=e[n]);let n=W({},t,e),r=e.__preview_external_dependency_versioned_paths;return k(r)||(k(e.strict_script_versioning)&&(n.strict_script_versioning=!!r),A(r)&&k(e.asset_host)&&(n.asset_host=r)),T(e.property_blacklist)&&(k(e.property_denylist)?n.property_denylist=e.property_blacklist:T(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:z.error(el+e.property_denylist)),n},ul=class{constructor(){this.__forceAllowLocalhost=!1}get cu(){return this.__forceAllowLocalhost}set cu(e){z.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},dl=class t{du(e){if(!e)return;let t=this.su.indexOf(e);t!==-1&&this.su.splice(t,1)}vu(e,t){var n;return this.du(e),this.su.push(t),(n=t.initialize)==null||n.call(t),t}fu(){return this.config.cookieless_mode===`always`||this.config.cookieless_mode===`on_reject`&&this.consent.isRejected()}pu(){if(this.gu||this.config.reuseAnonymousId||this.config.segment||this.fu())return;let e=this.config.persistence===`memory`||this.config.persistence===`sessionStorage`;if(!e&&!this.config.disable_persistence||this.mu)return;let t,n,r;e?(t=`persistence is set to '${this.config.persistence}'`,n=this.config.persistence===`memory`?`on every page load`:`for every new browser tab or window`,r=`Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId.`):(t=`persistence is disabled (disable_persistence is true)`,n=`on every page load`,r=`Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId.`),this.gu=!0,console.warn(`[PostHog.js]`,`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${n}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${r}`)}yu(){if(this.fu()||this.get_distinct_id()!==`$posthog_cookieless`)return;let e=this.persistence;if(!e)return;this.bu()||e.load(!0);let t=this.get_distinct_id();if(!t||t===`$posthog_cookieless`){let t=this.config.get_device_id(da());this.register({distinct_id:t,$device_id:t}),e.set_property(H,Vi)}this._u()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.wu=!1,this.ku=!1,this.webPerformance=new ul,this.Su=!1,this.version=V.LIB_VERSION,this.xu=new Set,this.Cu=``,this.au=new bc,this.su=[],this.$u=[],this.mu=!1,this.gu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=sl(),this.SentryIntegration=wo,this.sentryIntegration=e=>function(e,t){let n=Co(e,t);return{name:So,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Tu=!1,this.Iu=null,this.Mu=null,this.Eu=null,this.scrollManager=new _c(this),this.pageViewManager=new To(this),this.rateLimiter=new _s(this),this.requestRouter=new Lc(this),this.consent=new Aa(this),this.externalIntegrations=new Uc(this);let e=t.__defaultExtensionClasses??{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(e,t,n)=>{let r=A(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{let r=A(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,e=>z.info(`send "${e?.event}"`,e))}init(e,n,r){if(r&&r!==il){let i=Jc[r]??new t;return i._init(e,n,r),Jc[r]=i,Jc[il][r]=i,i}return this._init(e,n,r)}_init(t,n={},r){let i=A(t)?t.trim():``;if(!i)return z.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return i===this.config?.token?console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`):console.warn(`[PostHog.js]`,`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${i}', { ... }, 'project2')`),this;this.__loaded=!0,this.config=sl(n.defaults),n.debug=this.Pu(n.debug),this.Ru=n,this.Au=[],n.person_profiles?this.Mu=n.person_profiles:n.process_person&&(this.Mu=n.process_person);let a=sl(n.defaults),o=ll(n),s=W({},a,o,{name:r,token:i});D(a.rageclick)&&D(o.rageclick)&&(s.rageclick=W({},a.rageclick,o.rageclick)),D(a.session_recording)&&D(o.session_recording)&&(s.session_recording=W({},a.session_recording,o.session_recording)),this.set_config(s),this.config.on_xhr_error&&z.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=n.disable_compression?void 0:ss.GZipJS;let c=this.bu();if(this.persistence=new os(this.config,c),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new os(R(R({},this.config),{},{persistence:`sessionStorage`}),c,!1),this.Cu=`ph_`+(this.config.persistence_name||this.config.token)+`_session_registered_properties`,this.config.persistence!==`memory`&&!c&&J.Et()){let e=J.Dt(this.Cu);T(e)&&e.forEach(e=>{A(e)&&this.xu.add(e)})}else J.Lt(this.Cu);let l=R({},this.persistence.props),u=R({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Fu=new mc(e=>this.Ou(e),this.config.request_queue_config),this.Du=new gc(this),this.__request_queue=[];let d=this.fu();d||(this.sessionManager=new Cc(this),this.sessionPropsManager=new yc(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,n)=>{(n!=null&&n.activityTimeout||n!=null&&n.sessionPastMaximumLength||n!=null&&n.crossTabAdoption)&&this.Lu()})),this.Nu(),this.config.__preview_deferred_init_extensions?(z.info(`Deferring extension initialization to improve startup performance`),setTimeout(()=>{this.qu(d)},0)):(z.info(`Initializing extensions synchronously`),this.qu(d)),V.DEBUG=V.DEBUG||this.config.debug,V.DEBUG&&z.info(`Starting in debug mode`,{this:this,config:n,thisC:R({},this.config),p:l,s:u}),this.config.identity_distinct_id&&!n.bootstrap?.distinctID&&(n.bootstrap=R(R({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let f=n.bootstrap?.distinctID;if(this.mu=!!f&&!j(f),n.bootstrap?.distinctID){let e=n.bootstrap.distinctID,t=this.get_distinct_id(),r=this.persistence.get_property(H);if(n.bootstrap.isIdentifiedID&&t!=null&&t!==e&&r===`anonymous`)this.identify(e);else if(n.bootstrap.isIdentifiedID&&t!=null&&t!==e&&r===`identified`)z.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{let t=this.config.get_device_id(da()),r=n.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(H,n.bootstrap.isIdentifiedID?Hi:Vi),this.register({distinct_id:e,$device_id:r})}}if(d)this.register_once({distinct_id:Di,$device_id:null},``);else if(!this.get_distinct_id()){let e=this.config.get_device_id(da());this.register_once({distinct_id:e,$device_id:e},``),this.persistence.set_property(H,Vi)}return G(e,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),G(e,`pageshow`,()=>{var e;this.wu=!1,this.ku||(e=this.Du)==null||e.resume()}),n.segment?xo(this,()=>this.ju()):this.ju(),E(this.config._onCapture)&&this.config._onCapture!==Xc&&(z.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,e=>this.config._onCapture(e.event,e))),this.config.ip&&z.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 Tc.apply(this,arguments)}().then(e=>{e&&this.register({[_r]:e})}).catch(Xc),this}Bu(e){let t=e;return A(t.name)&&E(t.setup)}Hu(e,t){this.Bu(e)?t.push(()=>{this.zu().add(e).catch(()=>e.dispose?.call(e)).catch(t=>{z.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this.su.push(e)}Nu(){let e=this.config.__extensionClasses?.featureFlags??t.__defaultExtensionClasses?.featureFlags;var n,r,i;e&&(this.featureFlags&&this.featureFlags instanceof e||((n=this.Uu)==null||n.call(this),this.Uu=void 0,this.featureFlags=new e(this)),E(this.featureFlags.onReloading)&&E(this.featureFlags.setup)?this.Uu||(this.Uu=this.featureFlags.onReloading(()=>{this.au.emit(`featureFlagsReloading`,!0)}),this.zu().add(this.featureFlags)):(r=(i=this.featureFlags).initialize)==null||r.call(i))}qu(e){let n=performance.now(),r=R(R({},t.__defaultExtensionClasses),this.config.__extensionClasses),i=[];r.exceptions&&this.su.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.su.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.su.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.su.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!e&&this.su.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.autocapture&&this.Hu(this.autocapture=new r.autocapture(this),i),r.surveys&&this.Hu(this.surveys=this.surveys??new r.surveys(this),i),r.logs&&this.Hu(this.logs=this.logs??new r.logs(this),i),r.metrics&&this.su.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this.su.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.su.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.su.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.su.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.su.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.su.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,vo)),r.toolbar&&this.su.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.su.push(this.experiments=this.experiments??new r.experiments(this)),this.su.forEach(e=>{e.initialize&&i.push(()=>{var t;(t=e.initialize)==null||t.call(e)})}),i.push(()=>{if(this.Wu){let e=this.Wu;this.Wu=void 0,this.su.forEach(t=>t.onRemoteConfig?.call(t,e))}}),this.Vu(i,n)}Vu(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.Vu(e,t)},0);let n=e.shift();if(n)try{n()}catch(e){z.error(`Error initializing extension:`,e)}}let n=Math.round(performance.now()-t);this.register_for_session({[ki]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Ai]:n}),this.config.__preview_deferred_init_extensions&&z.info(`PostHog extensions initialized (${n}ms)`)}Kl(e){var t;if(!r||!r.body)return z.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout(()=>{this.Kl(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Wu=e),this.lu=e,this.compression=void 0,e.ok){var n;let t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=y(t.supportedCompression,ss.GZipJS)?ss.GZipJS:y(t.supportedCompression,ss.Base64)?ss.Base64:void 0),(n=t.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this.Mu?this.Mu:Ui}),(t=this.Gu)==null||t.handleRemoteConfig(e),this.su.forEach(t=>t.onRemoteConfig?.call(t,e))}ju(){try{this.config.loaded(this)}catch(e){z.critical("`loaded` function failed",e)}if(this.Zu(),this.config.internal_or_test_user_hostname&&i?.hostname){let e=i.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.fu())&&this.Qu()},1),this.Ju=new ys(this),this.Ju.load()}Zu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Fu)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Xi(this.__request_queue,e=>this.Ou(e)),this.__request_queue=[],this.Zu()}_handle_unload(){var e,t,n,r,i,a;this.wu=!0,(e=this.surveys)==null||(t=e.handlePageUnload)==null||t.call(e),(n=this.metrics)==null||n.flush(`sendBeacon`),this.config.request_batching?(this.Ku()&&this.capture(qi),(r=this.logs)==null||r.flushLogs(`sendBeacon`),(i=this.Fu)==null||i.unload(),(a=this.Du)==null||a.unload()):this.Ku()&&this.capture(qi,null,{transport:`sendBeacon`})}_send_request(e){var t,n;this.__loaded?al?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&((t=e.callback)==null||t.call(e,{statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=R(R({},this.config.request_headers),e.headers),e.compression=e.compression===`best-available`?this.compression??e.compressionFallback:e.compression,(k(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{let t=R({},e);t.timeout=t.timeout||6e4;let n=t.transport??`fetch`;n===`sendBeacon`&&k(t.compression)&&t.data&&(t.compression=ss.Base64),t.method===`POST`&&t.data&&(t.timestampMode===`capture-body`?t.data=(e=>{var t;let n=(T(e)?e:[e]).map(e=>R(R({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),r=n[0];return{api_key:(r==null||(t=r.properties)==null?void 0:t.token)??r?.token,batch:n,sent_at:new Date().toISOString()}})(t.data):t.timestampMode===`body`&&(t.data=((e,t=new Date().toISOString())=>T(e)?e.map(e=>R(R({},e),{},{sent_at:t})):R(R({},e),{},{sent_at:t}))(t.data))),t.url=fc(t.url,t.method,t.compression,t.timestampMode);let r=pc.filter(e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport)),i=function(e,t){for(let n=0;e.length>n;n++)if(t(e[n]))return e[n]}(r,e=>e.transport===n)?.method??r[0].method;if(!i)throw Error(`No available transport method`);let a=e=>{try{i(e)}catch(e){var n;cc(e)?z.warn(e):z.error(e),(n=t.callback)==null||n.call(t,{statusCode:0,error:e})}};n!==`sendBeacon`&&t.data&&t.compression===ss.GZipJS&&c&&typeof Promise<`u`&&!ec?oc(t).then(e=>{a(e)}).catch(n=>{if(An(n))return ec=!0,void a(R(R({},t),{},{compression:void 0,url:fc(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return An(e)||t===Dn})(n)&&(ec=!0),a(t)}):i(t)})(R(R({},e),{},{callback:t=>{var n,r,i;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(r=(i=this.config).on_request_error)==null||r.call(i,t),(n=e.callback)==null||n.call(e,t)}}))):e.fireCallbackOnDrop&&((n=e.callback)==null||n.call(e,{statusCode:0}))}Ou(e){this.Du?this.Du.retriableRequest(e):this._send_request(e)}_execute_array(e){Yc++;try{let t,n=[],r=[],i=[];Xi(e,e=>{if(e)if(t=e[0],T(t))i.push(e);else if(E(e))try{e.call(this)}catch(t){z.error(`Error executing queued PostHog call`,e,t)}else T(e)&&t===`alias`?n.push(e):T(e)&&t.indexOf(`capture`)!==-1&&E(this[t])?i.push(e):r.push(e)});let a=function(e,t){Xi(e,function(e){try{if(T(e[0])){let n=t;U(e,function(e){n=n[e[0]].apply(n,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){z.error(`Error executing queued PostHog call`,e,t)}})};a(n,this),a(r,this),a(i,this)}finally{Yc--}}push(e){if(Yc>0&&T(e)&&A(e[0])){let n=t.prototype[e[0]];E(n)&&n.apply(this,e.slice(1));return}this._execute_array([e])}Yu(){let e=this.persistence?.get_property(xr);return A(e)&&nl.test(e)?{value:e,delivered:!1}:D(e)&&A(e.value)&&nl.test(e.value)?{value:e.value,delivered:!0===e.delivered}:void 0}Xu(e,t,n,r){if(!this.persistence)return;this.persistence.refreshKey(xr);let i=this.Yu();if(!r){if(n)return A(t)&&nl.test(t)?(t!==i?.value&&this.persistence.register({[xr]:{value:t,delivered:!1}}),{value:t,pending:t!==i?.value||!i.delivered}):void this.persistence.unregister(xr);if(A(e)&&tl.test(e)){if(i?.value.split(`.`)[3]===e)return{value:i.value,pending:!i.delivered};let t=`fb.1.${Date.now()}.${e}`;return this.persistence.register({[xr]:{value:t,delivered:!1}}),{value:t,pending:!0}}return i?{value:i.value,pending:!i.delivered}:void 0}this.persistence.unregister(xr)}th(e){if(!this.persistence)return;this.persistence.refreshKey(xr);let t=this.Yu();t?.value!==e||t.delivered||this.persistence.register({[xr]:{value:e,delivered:!0}})}capture(e,t,n){var r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Fu))return void z.uninitializedWarning(`posthog.capture`);if(!this.is_capturing())return;if(k(e)||!A(e))return void z.error(`No event name provided to posthog.capture`);this.yu();let i=!this.config.opt_out_useragent_filter&&this._is_bot();if(i&&!this.config.__preview_capture_bot_pageviews)return;let a=n?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void z.critical(`This capture call is ignored due to client rate limiting.`);let o;t!=null&&t.$current_url&&!A(t?.$current_url)&&(z.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.eh||z.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&&(o=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();let s=new Date,c=n?.timestamp||s,l=wt(n?.uuid,da),u={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},c,l)};e===`$pageview`&&this.config.__preview_capture_bot_pageviews&&i&&(u.event=`$bot_pageview`,u.properties.$browser_type=`bot`),a&&(u.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);let d=e===`$feature_flag_called`&&!1===u.properties.$feature_flag_has_experiment&&!0===this.get_property(`$minimal_flag_called_events`);n!=null&&n.$set&&!d&&(u.$set=n?.$set);let f=D(t?.$set)?t.$set:void 0,p=!!n?.$set&&`$fbc`in n.$set,m=p||!!f&&`$fbc`in f,h=p?n==null||(r=n.$set)==null?void 0:r[br]:f?.[br],g=T(t?.$unset)?t.$unset:[],_=n?.$unset||[],v=g.indexOf(`$fbc`)!==-1||_.indexOf(`$fbc`)!==-1,y=this.Xu(o?.fbclid,h,m,v);y&&!0===u.properties.$process_person_profile&&y.pending&&!m&&!d&&(u.$set=R({[br]:y.value},u.$set));let b=n?.$unset;b&&(u.$unset=b);let x=d?void 0:this.ih(n?.$set_once,e!==Yi,e===Ji);if(x&&(u.$set_once=x),n!=null&&n._noTruncate||(S=this.config.properties_string_max_length,u=function(e,t){let n=new Set;return function e(r,i){if(r!==Object(r))return t?t(r):r;if(n.has(r))return;let a;if(n.add(r),T(r))a=[],Xi(r,t=>{a.push(e(t))});else{let t={};U(ae(r)?ta(r):r,(r,i)=>{n.has(r)||(t[i]=e(r,i))}),a=t}return a}(e)}(u,e=>A(e)?e.slice(0,S):e)),u.timestamp=c,k(n?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=s),d&&(u.properties=((e,t=[])=>{let n={},r=t=>{e[t]!==void 0&&(n[t]=e[t])};return En.forEach(r),t.forEach(r),n})(u.properties,rl)),e===us.DISMISSED||e===us.SENT){let n=t?.[ds.SURVEY_ID],r=t?.[ds.SURVEY_ITERATION];Rc({id:n,current_iteration:r}),u.$set=R(R({},u.$set),{},{[Ec({id:n,current_iteration:r},e===us.SENT?`responded`:`dismissed`)]:!0})}else e===us.SHOWN&&(u.$set=R(R({},u.$set),{},{[ds.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var S;if(e===ms.SHOWN){let e=t?.[hs.TOUR_TYPE];e&&(u.$set=R(R({},u.$set),{},{[`${hs.TOUR_LAST_SEEN_DATE}/${e}`]:new Date().toISOString()}))}let C=R(R({},u.properties.$set),u.$set);if(O(C)||this.setPersonPropertiesForFlags(C),!N(this.config.before_send)){let e=this.Os(u);if(!e)return;u=e,u.uuid=wt(u.uuid,da)}let w=u.$set?.$fbc??(D(u.properties?.$set)?u.properties.$set[br]:void 0),ee=y?.pending&&w===y.value?y.value:void 0;this.au.emit(`eventCaptured`,u);let E=n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),j=R(R({method:`POST`,url:E,data:u,compression:`best-available`,timestampMode:n?._batchKey===`recordings`||/\/s\/(?:\?|$)/.test(E)?`body`:`capture-body`,batchKey:n?._batchKey},n?.transport?{transport:n.transport}:{}),ee?{fireCallbackOnDrop:!0,callback:e=>{e.statusCode>=200&&300>e.statusCode&&this.th(ee)}}:{});return!this.config.request_batching||n&&!n?._batchKey||n?.send_instantly||ee?(!j.transport&&!j.callback&&O(this.config.request_headers??{})&&this.wu&&(j.transport=`sendBeacon`),this.Ou(j)):this.Fu.enqueue(j),u}_addCaptureHook(e){return this.on(`eventCaptured`,t=>e(t.event,t))}getExtension(e){return this.Gu?.getExtension(e)}zu(){return this.Gu??=new qc(this)}hu(e){this.$u.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.$u.indexOf(e);n!==-1&&this.$u.splice(n,1)}}nh(e=!0){var t,n;return!!this.persistence?.consumeCookieIdentityChange()&&(this.Eu=null,this.persistence.get_property(`$user_state`)===`anonymous`&&((n=this.sessionPersistence)==null||n.clear(),this.xu.clear(),this.sh()),(t=this.featureFlags)==null||t.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,a,o,s){if(a||=new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.nh();let c=s?void 0:this.persistence.remove_event_timer(t),u=R({},n);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this.fu()&&(u[Oi]=!0),t===`$snapshot`){let e=R(R({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=e.distinct_id,(!A(u.distinct_id)&&!P(u.distinct_id)||j(u.distinct_id))&&z.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),u}let d=function(t,n,r,a=!1){var o,s,c;if(!l)return{};let u=t?[...Io,...n||[]]:[],[d,f]=mt(l),[p,h]=function(e){for(let t=0;vt.length>t;t++){let[n,r,i]=vt[t],a=e.match(n);if(a)return[r,(i&&e.match(i)||a)?.[1]||``]}return[``,``]}(l),g=function(){return(`u`>typeof navigator?navigator:void 0)?.brave?{brave:!0}:{}}(),_={};k(r)||(_.detectGoogleSearchApp=r);let v={},y=(o=navigator)==null||(o=o.userAgentData)==null?void 0:o.platform,b=navigator?.maxTouchPoints,x=e==null||(s=e.screen)==null?void 0:s.width,S=e==null||(c=e.screen)==null?void 0:c.height,C=e?.devicePixelRatio;k(y)||(v.userAgentDataPlatform=y),k(b)||(v.maxTouchPoints=b),k(x)||(v.screenWidth=x),k(S)||(v.screenHeight=S),k(C)||(v.devicePixelRatio=C);let w=W(ea({$os:d,$os_version:f,$browser:ut(l,navigator.vendor,g,_),$webview_app:p,$webview_app_version:h,$device:ht(l),$device_type:gt(l,v),$timezone:Yo(),$timezone_offset:Xo()}),{$current_url:Mo(a?Et(i?.href):i?.href,u,Ro),$host:i?.host,$pathname:i?.pathname,$raw_user_agent:l.length>1e3?l.substring(0,997)+`...`:l,$browser_version:ft(l,navigator.vendor,g,_),$browser_language:Uo(),$browser_language_prefix:Wo(),$screen_height:e?.screen.height,$screen_width:e?.screen.width,$viewport_height:e?.innerHeight,$viewport_width:e?.innerWidth,$lib:m.LIB_NAME,$lib_version:m.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return m.SDK_DIST_CHANNEL&&(w.$sdk_dist_channel=m.SDK_DIST_CHANNEL),w}(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){let{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(s,a.getTime(),!0);u.$session_id=e,u.$window_id=t}this.sessionPropsManager&&W(u,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&W(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=this.Du?.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}let f;if(this.requestRouter.region===Nc&&(u.$lib_custom_api_host=this.config.api_host),f=t!==`$pageview`||s?t!==`$pageleave`||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(a):this.pageViewManager.doPageView(a,o),u=W(u,f),t===`$pageview`&&r&&(u.title=r.title),!k(c)){let e=a.getTime()-c;u.$duration=parseFloat((e/1e3).toFixed(3))}l&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?`bot`:`browser`);let p=this.persistence.properties(),h=this.sessionPersistence.properties(),g=u.$groups,_=p.$groups;D(g)&&!O(g)&&(u.$groups=R(R({},D(_)?_:{}),g)),U([`$referrer`,`$referring_domain`],e=>{e in p&&delete h[e]});let v={};if(this.$u.length>0)for(let e of this.$u.slice())try{W(v,e())}catch(e){z.error(`Failed to produce browser extension event properties`,e)}u=W({},d,p,h,R(R({},v),u)),u.$is_identified=this._isIdentified(),T(this.config.property_denylist)?U(this.config.property_denylist,function(e){delete u[e]}):z.error(el+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);let y=this.config.sanitize_properties;y&&(z.error($c),u=y(u,t));let b=this.rh();return u.$process_person_profile=b,b&&!s&&this.oh(`_calculate_event_properties`),u}ih(e,t=!0,n=!1){if(!this.persistence||!this.rh()||this.Su&&!n)return e;let r=this.persistence.get_initial_props(),i=this.sessionPropsManager?.getSetOnceProps(),a=W({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(z.error($c),a=o(a,`$set_once`)),t&&(this.Su=!0),O(a)?void 0:a}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t,n;(t=this.persistence)==null||t.syncCookieProperties(),this.nh(),(n=this.sessionPersistence)==null||n.register(e),Object.keys(e).forEach(e=>this.xu.add(e)),this.sh()}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e),this.xu.delete(e),this.sh()}ah(e,t){this.register({[e]:t})}Lu(){this.xu.forEach(e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)}),this.xu.clear(),this.sh()}sh(){if(!this.Cu)return;if(this.config.persistence===`memory`||this.sessionPersistence?.pi||!J.Et())return void J.Lt(this.Cu);let e=[];this.xu.forEach(t=>e.push(t)),e.length>0?J.At(this.Cu,e):J.Lt(this.Cu)}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}getAllFeatureFlags(){return this.featureFlags?.getAllFeatureFlags()??[]}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)??t?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t=!1,n){return this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.au.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Qc}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Qc})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Qc})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t=Bc){var n;(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:Qc}}canRenderSurveyAsync(e,t=!1){return this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:Qc})}uh(e){return!e||j(e)?(z.critical(`Unique user id has not been set in posthog.identify`),!1):e===`$posthog_cookieless`?(z.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(z.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return z.uninitializedWarning(`posthog.identify`);if(P(e)&&(e=e.toString(),z.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),!this.uh(e)||!this.oh(`posthog.identify`))return;this.yu();let r=this.get_distinct_id(),i=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this.nh(!1),o=this.persistence.Pl(),s=!1;try{let r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(`$device_id`)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(`__alias`)&&(this.unregister(vr),this.register({distinct_id:e}));let o=(this.persistence.get_property(`$user_state`)||`anonymous`)===Vi,l=e!==r,u=!l&&o;if(l&&o){var c;let i=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:r};this.persistence.set_property(H,Hi),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Rl(),this.capture(Ji,i,{$set:t||{},$set_once:n||{}}),this.Eu=Mc(e,t,n),(c=this.featureFlags)==null||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:r)}else if(u){this.persistence.set_property(H,Hi);let r=t||{},i=n||{};this.setPersonPropertiesForFlags({$set:r,$set_once:i},!1),this.config.cookieWinsOnConflict&&this.persistence.Rl(),this.capture(`$set`,{$set:r,$set_once:i}),this.Eu=Mc(e,t,n)}else(t||n)&&this.setPersonProperties(t,n);l||i||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(_i)):u&&(t||n)&&this.reloadFeatureFlags(),s=!0}finally{o&&this.persistence.Ol(s)}}setPersonProperties(e,t){if(!e&&!t||!this.oh(`posthog.setPersonProperties`))return;let n=Mc(this.get_distinct_id(),e,t);this.Eu===n?z.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Eu=n)}unsetPersonProperties(e){var t;let n=(T(e)?e:[e]).filter(e=>A(e)&&e.length>0);n.length!==0&&this.oh(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this.Eu=null)}group(e,t,n){var r;if(!e||!t)return void z.error(`posthog.group requires a group type and group key`);(r=this.persistence)==null||r.syncCookieProperties(),this.nh();let i=this.getGroups(),a=i[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:R(R({},i),{},{[e]:t})}),(a||n)&&this.rh()){let r={$group_type:e,$group_key:t};n&&(r.$group_set=n),this.capture(Yi,r)}n&&this.setGroupPropertiesForFlags({[e]:n}),a&&!n&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var n;(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var n;this.oh(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){let t=F(e)?e:e?.resetDeviceID,n=F(e)||e==null?void 0:e.bootstrap;this.hh(t,!1,n)}hh(e,t=!1,n){var r,i,a,o,s;if(z.info(`reset`),!this.__loaded)return z.uninitializedWarning(`posthog.reset`);let c=n?.sessionID;this.config.bootstrap=n||this.Ru?.bootstrap||{},(r=this.featureFlags)==null||(i=r.updateConfig)==null||i.call(r,this.config,this.Yl());let l=this.get_property(gr),u=this.get_property(_r),d=this.get_property(Nr);(a=this.sessionRecording)==null||a.flushBeforeIdentityReset();let f=this.is_capturing();this.consent.reset(),t||!f||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.");let p=(o=this.persistence)==null||(s=o.Pl)==null?void 0:s.call(o),m=!1;try{var h,g,_,v,y,b,x,S,C,w,ee,T;if((h=this.persistence)==null||h.clear(),(g=this.sessionPersistence)==null||g.clear(),this.xu.clear(),this.sh(),k(d)||(w=this.persistence)==null||w.register({$session_recording_remote_config:d}),(_=this.surveys)==null||_.reset(),(v=this.featureFlags)==null||v.reset(),(y=this.conversations)==null||y.reset(),(b=this.logs)==null||b.reset(),(x=this.metrics)==null||x.reset(),(S=this.persistence)==null||S.set_property(`$user_state`,`anonymous`),(C=this.sessionManager)==null||C.resetSessionId(),this.Eu=null,this.config.cookieless_mode===`always`)this.register_once({distinct_id:Di,$device_id:null},``);else{let t=this.config.get_device_id(da());this.register_once({distinct_id:t,$device_id:e?t:l},``),e||k(u)||this.register({[_r]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),n&&(n.distinctID&&!this.fu()&&((T=this.persistence)==null||T.set_property(`$user_state`,n.isIdentifiedID?`identified`:`anonymous`),this.register({distinct_id:n.distinctID})),(ee=this.featureFlags)==null||ee.initialize(),!N(c)&&!this.sessionManager?.setBootstrapSessionId(c,!0))){let e=R({},n);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,m=!0}finally{var E,D;p&&((E=this.persistence)==null||(D=E.Ol)==null||D.call(E,m))}this.reloadFeatureFlags()}shutdown(e){var t=this;return L(function*(){var e,n,r,i,a,o,s;if(t.__loaded){t.ku=!0,t.zu().dispose(),(e=t.sessionRecording)==null||e.dispose(),(n=t.logs)==null||n.flushLogs(`sendBeacon`),(r=t.metrics)==null||r.flush(`sendBeacon`),(i=t.Fu)==null||i.unload(),(a=t.Du)==null||a.unload();try{var c;(c=t.featureFlags)==null||c.destroy()}catch(e){z.error(`Error while destroying feature flags`,e)}(o=t.persistence)==null||o.destroy(),(s=t.sessionPersistence)==null||s.destroy()}else z.uninitializedWarning(`posthog.shutdown`)})()}setIdentity(e,t){var n;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.dh()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)==null||e.fh()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;let{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/${this.config.token}/replay/${t}`);if(e?.withTimestamp&&n){let t=e.timestampLookBack??10;if(!n)return r;r+=`?t=${Math.max(Math.floor((new Date().getTime()-n)/1e3)-t,0)}`}return r}alias(e,t){return e===this.get_property(`$people_distinct_id`)?(z.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.oh(`posthog.alias`)?(k(t)&&(t=this.get_distinct_id()),e===t?(z.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.ah(vr,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){let t=R({},this.config);if(D(e)){var n,r,i,a,o,s,c,l,u,d,f,p,m;W(this.config,ll(e));let g=this.bu();(n=this.persistence)==null||n.update_config(this.config,t,g),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new os(R(R({},this.config),{},{persistence:`sessionStorage`}),g,!1);let _=this.Pu(this.config.debug);var h;F(_)&&(this.config.debug=_),F(this.config.debug)&&(this.config.debug?(V.DEBUG=!0,q.Et()&&q.At(`ph_debug`,!0),z.info(`set_config`,{config:e,oldConfig:t,newConfig:R({},this.config)})):(V.DEBUG=!1,q.Et()&&q.Lt(`ph_debug`))),(r=this.featureFlags)==null||(i=r.updateConfig)==null||i.call(r,this.config,this.Yl()),(a=this.exceptionObserver)==null||a.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(c=this.tracingHeaders)==null||c.startIfEnabledOrStop(),(l=this.autocapture)==null||l.startIfEnabled(),(u=this.heatmaps)==null||u.startIfEnabled(),(`capture_pageview`in e||`disable_capture_url_hashes`in e)&&((h=this.historyAutocapture)==null||h.startIfEnabledOrStop()),(d=this.exceptionObserver)==null||d.startIfEnabledOrStop(),(f=this.deadClicksAutocapture)==null||f.startIfEnabledOrStop(),(p=this.surveys)==null||p.loadIfEnabled(),this._u(),(m=this.externalIntegrations)==null||m.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&xo(this,Xc,!1)}}_overrideSDKInfo(e,t){V.LIB_NAME=e,V.LIB_VERSION=t}startSessionRecording(e){let t=!0===e,n={sampling:t||!!e?.sampling,linked_flag:t||!!e?.linked_flag,url_trigger:t||!!e?.url_trigger,event_trigger:t||!!e?.event_trigger};var r,i,a,o,s;Object.values(n).some(Boolean)&&((r=this.sessionManager)==null||r.checkAndGetSessionAndWindowId(),n.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),n.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),n.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger(`url`)),n.event_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){return!!this.sessionRecording?.started}captureException(e,t){try{if(!this.exceptions)return;let n=this.exceptions.buildProperties(e,{handled:!0,syntheticException:Error(`PostHog syntheticException`)});return this.exceptions.sendExceptionEvent(R(R({},n),t))}catch{return}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??t.ph}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){let e=this.config.name??il;return e!==il&&(e=`posthog.`+e),e}_isIdentified(){return this.persistence?.get_property(`$user_state`)===`identified`||this.sessionPersistence?.get_property(`$user_state`)===`identified`}rh(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===`identified_only`&&!this._isIdentified()&&O(this.getGroups())&&!(!((e=this.persistence)==null||(e=e.props)==null)&&e.__alias)&&!(!((t=this.persistence)==null||(t=t.props)==null)&&t.$epp))}Ku(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&!!this.config.capture_pageview}createPersonProfile(){this.rh()||this.oh(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.oh(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}oh(e){return this.config.person_profiles===`never`?(z.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.pu(),this.ah(Ei,!0),!0)}bu(){if(this.config.cookieless_mode===`always`)return!0;let e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==`on_reject`)}_u(){let e=this.bu();var t,n,r;return this.is_capturing()||(t=this.logs)==null||t.gh(),this.persistence?.pi!==e&&((n=this.persistence)==null||n.set_disabled(e)),this.sessionPersistence?.pi!==e&&((r=this.sessionPersistence)==null||r.set_disabled(e)),e&&(this.xu.clear(),this.sh()),e}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==`always`){if(this.fu()){var r,i,a;(r=this.sessionRecording)==null||r.dispose({discardBufferedEvents:!0}),this.hh(!0,!0),(i=this.sessionManager)==null||i.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new Cc(this),this.pageViewManager=new To(this),this.persistence&&(this.sessionPropsManager=new yc(this,this.sessionManager,this.persistence));let e=this.config.__extensionClasses?.sessionRecording??t.__defaultExtensionClasses?.sessionRecording;var o,s;e&&(this.sessionRecording=this.vu(this.sessionRecording,new e(this)),this.lu&&((o=this.sessionRecording)==null||(s=o.onRemoteConfig)==null||s.call(o,this.lu)))}var c;this.consent.optInOut(!0),this._u(),this.Zu(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==`on_reject`&&((c=this.surveys)==null||c.loadIfEnabled()),(k(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture(e?.captureEventName??`$opt_in`,e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Qu()}else z.warn(Zc)}opt_out_capturing(){if(this.config.cookieless_mode===`always`)return void z.warn(Zc);let e=this.config.cookieless_mode===`on_reject`?this.sessionRecording:void 0;var t,n;e?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode===`on_reject`&&this.consent.isOptedIn()&&this.hh(!0,!0),this.consent.optInOut(!1),this._u(),this.config.cookieless_mode===`on_reject`&&(this.register({distinct_id:Di,$device_id:null}),this.du(e),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Qu(),this.Zu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){let e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===`always`||(this.config.cookieless_mode===`on_reject`?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._u()}_is_bot(){return n?wc(n,this.config.custom_blocked_useragents):void 0}Qu(){r&&(r.visibilityState===`visible`?this.Tu||(this.Tu=!0,this.capture(Ki,{title:r.title},{send_instantly:!0}),this.Iu&&=(r.removeEventListener(Wi,this.Iu),null)):this.Iu||(this.Iu=this.Qu.bind(this),G(r,Wi,this.Iu)))}debug(t){!1===t?(e?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(e?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Yl(){let e=this.Ru||{};return`advanced_disable_flags`in e?!!e.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(z.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):function(e,t,n,r,i){let a=t in e&&!N(e[t]),o=n in e&&!N(e[n]);return a?e[t]:!!o&&(i&&i.warn(`Config field '${n}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[n])}(e,`advanced_disable_flags`,`advanced_disable_decide`,0,z):!!this.config.advanced_disable_flags}Os(e){if(N(this.config.before_send))return e;let t=Object.keys(e.properties??{}).filter(re),n=T(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(let t of n)try{if(r=t(r),N(r)){let t=`Event '${e.event}' was rejected in beforeSend function`;return ne(e.event)?z.warn(`${t}. This can cause unexpected behavior.`):z.info(t),null}r.properties&&!O(r.properties)||z.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return z.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(let n of t)if(r.properties&&N(r.properties[n]))return z.warn(`Event '${e.event}' had its '${n}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){return this.pageViewManager.Bo?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Pu(e){let t=F(e)&&!e,n=q.Et()&&q.Ot(`ph_debug`)===`true`;return!t&&(!!n||e)}};dl.__defaultExtensionClasses={},dl.ph=(()=>{let e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let n=0;t.length>n;n++)e.prototype[t[n]]=$i(e.prototype[t[n]])}(dl,[`identify`]);var fl=class{constructor(e){this.disabled=!1===e;let t=D(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;let r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},pl=`$copy_autocapture`,ml=B(`[AutoCapture]`);function hl(e,t){return t.length>e?t.slice(0,e)+`...`:t}function gl(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Na(t));return t}function _l(t,{e:n,maskAllElementAttributes:r,maskAllText:i,elementAttributeIgnoreList:a,elementsChainAsString:o,disableCaptureUrlHashes:s}){if(!Na(t))return{props:{}};let c=[t],l=new Set([t]),u=t;for(;u.parentNode&&!Y(u,`body`)&&1e3>c.length;){if(Fa(u.parentNode)){let e=u.parentNode.host;if(l.has(e))break;l.add(e),c.push(e),u=e;continue}if(!Na(u.parentNode)||l.has(u.parentNode))break;l.add(u.parentNode),c.push(u.parentNode),u=u.parentNode}let d=n.type===`click`&&t.namespaceURI===`http://www.w3.org/2000/svg`?c.findIndex(e=>Y(e,`button`)||Y(e,`a`)):-1;d>0&&(i||=c.slice(0,d+1).some(e=>!to(e)||no(e)));let f=[],p={},m,h=!1,g=!1;if(U(c,e=>{let t=to(e);if(Y(e,`a`)){let n=e.getAttribute(`href`);h=!!(t&&n&&uo(n))&&(s?Et(n):n)}y(Ra(e),`ph-no-capture`)&&(g=!0),f.push(function(e,t,n,r,i=!1){let a=e.tagName.toLowerCase(),o={tag_name:a};Ha.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?hl(1024,fo(e)):hl(1024,Ba(e)));let s=Ra(e);s.length>0&&(o.classes=s.filter(function(e){return e!==``})),U(e.attributes,function(n){var a;if((!no(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&!r?.includes(n.name)&&!t&&uo(n.value)&&(!A(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){let e=n.value;n.name===`class`&&(e=Ia(e).join(` `)),o[`attr__`+n.name]=hl(1024,n.name===`href`&&i?Et(e):e)}});let c=1,l=1,u=e;for(;u=gl(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,r,i,a,s)),U(function(e){if(!to(e))return{};let t={};return U(e.attributes,function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){let n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&uo(r)&&(t[n]=r)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(p,t)||(p[t]=e)})}),g)return{props:{},explicitNoCapture:g};if(d>0&&(t=c[d],f.splice(0,d)),i||(f[0].$el_text=Y(t,`a`)||Y(t,`button`)?fo(t):Ba(t)),h){var _;f[0].attr__href=h;let t=Ao(h)?.host,n=e==null||(_=e.location)==null?void 0:_.host;t&&n&&t!==n&&(m=h)}return{props:W((b=n.type,{$event_type:b,$ce_version:1}),o?{}:{$elements:f},{$elements_chain:(v=f,T(v)?function(e){return e.map(e=>{let t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class){e.attr_class.sort();for(let n of e.attr_class)t+=`.${n.replace(/"/g,``)}`}let n=R(R(R(R({},e.text?{text:e.text}:{}),{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return Zi(n).sort(([e],[t])=>function(e,t){return t>e?-1:+(e>t)}(e,t)).forEach(([e,t])=>r[mo(e.toString())]=mo(t.toString())),t+=`:`,t+=Zi(r).map(([e,t])=>`${e}="${t}"`).join(``),t}).join(`;`)}(function(e){return e.map(e=>{let t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:ho(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Zi(e).filter(([e])=>e.indexOf(`attr__`)===0).forEach(([e,n])=>t.attributes[e]=n),t})}(v)):``)},f[0]?.$el_text?{$el_text:f[0]?.$el_text}:{},m&&n.type===`click`?{$external_click_url:m}:{},p),target:t};var v,b}var vl=class{uo(){this.ho=void 0,clearTimeout(this.co),this.co=void 0}do(e){if(!to(e))return!0;let t=this.vo().css_selector_ignorelist??Ka,n=new Set,r=e;for(;r;){if(n.size>=1e3||n.has(r))return!0;n.add(r);let e=r,i=Ra(e);if(y(i,`ph-no-capture`)||y(i,`ph-sensitive`)||no(e)||t.some(t=>Ua(e,t)))return!0;let a=r.parentNode;r=Fa(a)?a.host:a&&Na(a)?a:null}return!1}fo(e){if(!this.isEnabled||e.type===`pointercancel`)return void this.uo();if(e.type===`pointerdown`){this.uo();let t=Va(e);e.isPrimary&&e.button===0&&!e.ctrlKey&&t&&Na(t)&&(this.ho={target:t,excluded:this.do(t),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:this.po?.distinctId});return}let t=this.ho;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this.uo():e.type===`pointerup`&&(t.released=!0,this.co=setTimeout(()=>this.uo(),0)))}mo(e){let t=this.ho;this.uo();let n=Va(e);if(t?.released&&t.target.isConnected&&t.distinctId===this.po?.distinctId&&e.pointerId===t.id&&(e.detail>0||e.pointerType===`touch`||e.pointerType===`pen`)&&e.button===0&&5>=Math.abs(e.clientX-t.x)&&5>=Math.abs(e.clientY-t.y)&&n&&(Y(n,`html`)||Y(n,`body`))){if(t.excluded)return null;let e=this.vo().css_selector_ignorelist??Ka;return[n,r?.documentElement,r?.body].some(t=>{if(!t)return!1;let n=Ra(t);return y(n,`ph-no-capture`)||y(n,`ph-sensitive`)||!to(t)||no(t)||e.some(e=>Ua(t,e))})?null:t.target}}constructor(e){this.yo=e,this.name=`autocapture`,this.bo=!1,this._o=null,this.wo=!1,this.ko=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.So=!1,this.yo.refresh(this.Mr),this.rageclicks=new fl(this.Mr.rageclick),this.xo=null}setup(e){this.Co(),this.po=e;let t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.So?t.dispose():(this.$o=t,this.startIfEnabled())}dispose(){var e;this.So||(this.So=!0,this.po=void 0,(e=this.$o)==null||e.dispose(),this.$o=void 0,this.To())}vo(){return this.yo.refresh(this.Mr),this.Mr}Co(){return this.vo(),this.Mr.url_allowlist=this.Mr.url_allowlist?.map(e=>new RegExp(e)),this.Mr.url_ignorelist=this.Mr.url_ignorelist?.map(e=>new RegExp(e)),this.Mr}Io(){if(!this.isBrowserSupported())return void ml.info(`Disabling Automatic Event Collection because this browser is not supported`);if(!e||!r)return;let t=this.Mo=t=>{t||=e?.event;try{if(t.type===`blur`)return void this.uo();if(t.type.indexOf(`pointer`)===0)return void this.fo(t);let e=t.type===`click`?this.mo(t):void 0;if(M(e))return;this.Eo(t,`$autocapture`,e)}catch(e){ml.error(`Failed to capture event`,e)}};if(G(e,`blur`,t),G(r,`submit`,t,{capture:!0}),G(r,`change`,t,{capture:!0}),G(r,`click`,t,{capture:!0}),U([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],e=>{G(r,e,t,{capture:!0})}),this.vo().capture_copied_text){let t=this.Po=t=>{t||=e?.event;try{this.Eo(t,pl)}catch(e){ml.error(`Failed to capture clipboard event`,e)}};G(r,`copy`,t,{capture:!0}),G(r,`cut`,t,{capture:!0}),G(r,`paste`,t,{capture:!0})}}To(){this.uo(),this.Mo&&=(e?.removeEventListener(`blur`,this.Mo),U([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],e=>{r?.removeEventListener(e,this.Mo,!0)}),r?.removeEventListener(`submit`,this.Mo,!0),r?.removeEventListener(`change`,this.Mo,!0),r?.removeEventListener(`click`,this.Mo,!0),void 0),this.Po&&=(r?.removeEventListener(`copy`,this.Po,!0),r?.removeEventListener(`cut`,this.Po,!0),r?.removeEventListener(`paste`,this.Po,!0),void 0),this.bo=!1}startIfEnabled(){this.isEnabled||this.uo(),!this.So&&this.po&&this.isEnabled&&!this.bo&&(this.Io(),this.bo=!0)}onRemoteConfig(e){if(this.So)return;if(this.wo=!0,!e.ok)return void this.startIfEnabled();let t=e.config;t.elementsChainAsString&&(this.ko=t.elementsChainAsString);let n=t.autocapture_opt_out;var r;F(n)&&((r=this.po)==null||r.kv.set(`$autocapture_disabled_server_side`,n),this._o=n),this.startIfEnabled()}setElementSelectors(e){this.xo=e}getElementSelectors(e,t){var n;let i=[];return(n=this.xo)==null||n.forEach(n=>{(r?.querySelectorAll(n))?.forEach(r=>{e!==r&&t!==r||y(i,n)||i.push(n)})}),i}get isEnabled(){if(this.So)return!1;let e=this.po?.kv.get(Cr),t=this._o,n=this.vo();if(!n.remoteRequestsDisabled&&!this.wo)return!1;let r=n.remoteRequestsDisabled&&!this.wo;if(M(t)&&!F(e)&&!r)return!1;let i=this._o??!!e;return!!n.enabled&&!i}Eo(t,n=`$autocapture`,r){if(!this.isEnabled)return void this.uo();let i=r||Va(t);Pa(i)&&(i=i.parentNode||null);let a=this.Co();var o;n===`$autocapture`&&t.type===`click`&&t instanceof MouseEvent&&a.rageclick&&(o=this.rageclicks)!=null&&o.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&Qa(i,a.rageclick)&&this.Eo(t,`$rageclick`,r);let s=n===pl,c=s?R(R({},a),{},{dom_event_allowlist:void 0}):a;if(i&&function(t,n,r,i,a,o){if(!e||$a(t)||r?.url_allowlist&&!La(r.url_allowlist,o)||r?.url_ignorelist&&La(r.url_ignorelist,o))return!1;if(r?.dom_event_allowlist){let e=r.dom_event_allowlist;if(e&&!e.some(e=>n.type===e))return!1}let{parentIsUsefulElement:s,targetElementList:c}=eo(t,i);if(!function(e,t){let n=t?.element_allowlist;if(k(n))return!0;for(let t of e)if(n.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,r)||!Wa(c,r?.css_selector_allowlist)||Wa(c,r?.css_selector_ignorelist??Ka))return!1;try{let r=e.getComputedStyle(t);if(r&&r.getPropertyValue(`cursor`)===`pointer`&&n.type===`click`)return!0}catch{}let l=t.tagName.toLowerCase();switch(l){case`html`:return!1;case`form`:return(a||[`submit`]).indexOf(n.type)>=0;case`input`:case`select`:case`textarea`:return(a||[`change`,`click`]).indexOf(n.type)>=0;default:return s?(a||[`click`]).indexOf(n.type)>=0:(a||[`click`]).indexOf(n.type)>=0&&(Ha.indexOf(l)>-1||t.getAttribute(`contenteditable`)===`true`)}}(i,t,c,s,s?[`copy`,`cut`,`paste`]:void 0,{config:{get_current_url:a.getCurrentUrl}})){var l;let{props:r,explicitNoCapture:o,target:s}=_l(i,{e:t,maskAllElementAttributes:a.maskAllElementAttributes,maskAllText:a.maskAllText,elementAttributeIgnoreList:a.element_attribute_ignorelist,elementsChainAsString:this.ko,disableCaptureUrlHashes:a.disableCaptureUrlHashes});if(o)return!1;let c=this.getElementSelectors(i,s);if(c&&c.length>0&&(r.$element_selectors=c),n===pl){let n=t.type||`clipboard`;if(n!==`paste`){var u;let t=e==null||(u=e.getSelection())==null?void 0:u.toString(),n=za(t);if(!n)return!1;r.$selected_content=n,r.$clipboard_text_length=t?.length??0}r.$copy_type=n}return(l=this.po)==null||l.capture(n,r).catch(e=>ml.error(`Failed to capture event`,e)),!0}}isBrowserSupported(){return E(r?.querySelectorAll)}},yl=class{constructor(e){this._instance=e}refresh(e){let t=this._instance.config,n=D(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance.Yl(),e.url_allowlist=n?.url_allowlist,e.url_ignorelist=n?.url_ignorelist,e.dom_event_allowlist=n?.dom_event_allowlist,e.element_allowlist=n?.element_allowlist,e.css_selector_allowlist=n?.css_selector_allowlist,e.css_selector_ignorelist=n?.css_selector_ignorelist,e.element_attribute_ignorelist=n?.element_attribute_ignorelist,e.capture_copied_text=n?.capture_copied_text}},bl=B(`[ExceptionAutocapture]`),xl=()=>{},Sl=e=>{if(E(e))return e.__posthog_layer__??e.__rrweb_layer__};function Cl(e,t,n){try{if(!(t in e))return xl;let r={next:e[t]},i=n(function(...e){return r.next.apply(this,e)});return E(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=i,()=>{if(e[t]===i)return void(e[t]=r.next);let n=e[t],a=Sl(n);for(;a;){if(a.next===i)return void(a.next=r.next);n=a.next,a=Sl(n)}}}catch{return xl}}var wl=B(`[TracingHeaders]`),Tl=B(`[Web Vitals]`),El=9e5,Dl=[`CLS`,`FCP`,`INP`,`LCP`],Ol=[`INP`,`LCP`],kl=[`interactionTarget`,`interactionType`,`inputDelay`,`processingDuration`,`presentationDelay`,`loadState`,`target`,`url`,`timeToFirstByte`,`resourceLoadDelay`,`resourceLoadDuration`,`elementRenderDelay`,`largestShiftTarget`,`largestShiftTime`,`largestShiftValue`,`firstByteToFCP`],Al=`disabled`,jl=`lazy_loading`,Ml=B(`[SessionRecording]`),Nl=B(`[Heatmaps]`);function Pl(e){return D(e)&&`clientX`in e&&`clientY`in e&&P(e.clientX)&&P(e.clientY)}var Fl=B(`[Product Tours]`),Il=e=>!e.config.disable_product_tours&&!!e.persistence?.get_property(Ar),Ll=[`$set_once`,`$set`],Rl=B(`[SiteApps]`),zl=`Error while initializing PostHog app with config id `,Bl=(e,t)=>e?.then?e.then(t):t(e),Vl=`SDK is not enabled or survey functionality is not yet loaded`,Hl=`Disabled. Not loading surveys.`,Ul=class{constructor(e,t){this.yo=e,this.mh=t,this.name=`surveys`,this._surveyEventReceiver=null,this._surveyManager=null,this.yh=!1,this.bh=[],this._h=null,this.wh=null,this.So=!1,this.kh=new Set,this.onRemoteConfig=e=>{if(this.So||this.Mr.disableSurveys)return;if(!e.ok)return $.warn(`Remote config unavailable. Not loading surveys.`);let t=e.config.surveys;if(N(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);this.Sh=F(t)?t:t.length>0,$.info(`flags response received, isSurveysEnabled: ${this.Sh}`),this.loadIfEnabled()}}setup(e){if(!this.So)return this.xh=e,Bl(e.kv.initialize(),()=>{if(this.xh!==e||this.So)return;this.xh=void 0,this.po=e;let t=e.onRemoteConfig(this.onRemoteConfig);this.So?t.dispose():(this.$o=t,this.loadIfEnabled())})}dispose(){var e,t,n,r;this.So||(this.So=!0,this.xh=void 0,this.po=void 0,(e=this.$o)==null||e.dispose(),this.$o=void 0,(t=this._surveyEventReceiver)==null||t.dispose(),this._surveyEventReceiver=null,(n=this._surveyManager)==null||(r=n.dispose)==null||r.call(n),this._surveyManager=null,this.bh=[],this._h=null,this.kh.forEach(e=>clearTimeout(e)),this.kh.clear())}get Mr(){return this.yo.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem(`lastSeenSurveyDate`);let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);(n!=null&&n.startsWith(`seenSurvey_`)||n!=null&&n.startsWith(`inProgressSurvey_`))&&t.push(n)}t.forEach(e=>localStorage.removeItem(e))}catch{}}loadIfEnabled(){if(this.So||!this.po)return;let e=this.Mr;if(this._surveyManager)return;if(this.yh)return void $.info(`Already initializing surveys, skipping...`);if(e.disableSurveys)return void $.info(Hl);if(e.cookielessMode&&this.yo.isOptedOut())return void $.info(`Not loading surveys in cookieless mode without consent.`);let t=this.yo.getExtensions();if(!t)return void $.error(`PostHog Extensions not found.`);if(k(this.Sh)&&!e.advancedEnableSurveys)return;let n=this.Sh||e.advancedEnableSurveys;this.yh=!0;try{let e=t.generateSurveys;if(e)return this.Ch(e,n),void(this.yh=!1);let r=t.loadExternalDependency;if(!r)return this.$h(Bi),void(this.yh=!1);r(e=>{try{if(this.So)return;let t=this.yo.getExtensions();e||!t?.generateSurveys?this.$h(`Could not load surveys script`,e):this.Ch(t.generateSurveys,n)}finally{this.yh=!1}})}catch(e){throw this.yh=!1,this.$h(`Error initializing surveys`,e),e}}Ch(e,t){this.So||(this._surveyManager=e(t),this._surveyEventReceiver=this.yo.createEventReceiver(),$.info(`Surveys loaded successfully`),this.Th({isLoaded:!0}))}$h(e,t){$.error(e,t),this.Th({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.bh.push(e),this._surveyManager&&this.Th({isLoaded:!0}),()=>{this.bh=this.bh.filter(t=>t!==e)}}getSurveys(e,t=!1){let n=this.po??this.mh;if(!n||this.So)return;if(this.Mr.disableSurveys)return $.info(Hl),e([]);let r=n.kv.get(ai);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Ih()&&this.getSurveys(()=>{},!0));if(this._h)return void this._h.then(({surveys:t,context:n})=>{this.So||e(t,n)}).catch(e=>$.error(`Error in survey callback`,e));let i=this.Mh(`/api/surveys/`,{method:`GET`,query:{token:n.projectToken},sentAt:`query`,timeoutMs:this.Mr.requestTimeoutMs}).then(e=>{try{return this.Eh(n,e)}catch(e){return $.error(`Error processing surveys response`,e),this.Eh(n,{statusCode:0,error:e})}},e=>this.Eh(n,{statusCode:0,error:e}));this._h=i;let a=()=>{this._h===i&&(this._h=null)};i.then(t=>{a(),this.So||e(t.surveys,t.context)},a).catch(e=>$.error(`Error in survey callback`,e))}Mh(e,t){let n=this.po;return n?n.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:Error(Vl)}))}Eh(e,t){if(this.So)return{surveys:[],context:{isLoaded:!1,error:Vl}};let n=t.statusCode;if(n!==200||!t.json){let e=`Surveys API could not be loaded, status: ${n}`;return n===0?t.error||$.warn(e):$.error(e),this.wh=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this.wh=null;let r=t.json.surveys||[],i=r.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(Dc(e)||function(e){var t;return!!(!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null)&&t.length)}(e)));var a;return i.length>0&&((a=this._surveyEventReceiver)==null||a.register(i)),e.kv.set({[ai]:r,[oi]:Date.now()}),{surveys:r,context:{isLoaded:!0}}}Ih(){return this.Ph()&&!this._h&&!this.Rh()}Ph(){let e=(this.po??this.mh)?.kv.get(oi);return P(e)&&Date.now()-e>3e5}Rh(){return P(this.wh)&&3e5>Date.now()-this.wh}markSurveyAsSeen(e,t){Rc({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}Th(e){for(let t of this.bh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t=!1){if(!N(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}Ah(e){let t=null;return this.getSurveys(n=>{t=n.find(t=>t.id===e)??null}),t}Fh(e){if(N(this._surveyManager))return{eligible:!1,reason:Vl};let t=typeof e==`string`?this.Ah(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}Oh(e){if(!this.yo.isCapturing())return{eligible:!1,reason:`PostHog is not capturing, so a survey response cannot be recorded`};if(N(this._surveyManager))return{eligible:!1,reason:Vl};let t=typeof e==`string`?this.Ah(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(N(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:Vl};let t=this.Oh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return N(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Vl})):new Promise(n=>{this.getSurveys(t=>{let r=t.find(t=>t.id===e)??null;if(r){let e=this.Oh(r);n({visible:e.eligible,disabledReason:e.reason})}else n({visible:!1,disabledReason:`Survey not found`})},t)})}renderSurvey(e,t,n){if(!this.yo.isCapturing())return;if(N(this._surveyManager))return void $.warn(`init was not called`);let i=typeof e==`string`?this.Ah(e):e;if(!i?.id)return void $.warn(`Survey not found`);if(!zc.includes(i.type))return void $.warn(`Surveys of type ${i.type} cannot be rendered in the app`);let a=r?.querySelector(t);if(a){if(i.appearance?.surveyPopupDelaySeconds){$.info(`Rendering survey ${i.id} with delay of ${i.appearance.surveyPopupDelaySeconds} seconds`);let e=setTimeout(()=>{var t;this.kh.delete(e),!this.So&&this.yo.isCapturing()&&($.info(`Rendering survey ${i.id} with delay of ${i.appearance?.surveyPopupDelaySeconds} seconds`),(t=this._surveyManager)==null||t.renderSurvey(i,a,n),$.info(`Survey ${i.id} rendered`))},1e3*i.appearance.surveyPopupDelaySeconds);this.kh.add(e);return}this._surveyManager.renderSurvey(i,a,n)}else $.warn(`Survey element not found`)}displaySurvey(e,t){var n;if(!this.yo.isCapturing())return;if(N(this._surveyManager))return void $.warn(`init was not called`);let r=this.Ah(e);if(!r)return void $.warn(`Survey not found`);let i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=R(R({},r),{},{appearance:R(R({},r.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==fs.Popover&&t.initialResponses&&$.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){let e=this.Fh(r);if(!e.eligible)return void $.warn(`Survey is not eligible to be displayed: `,e.reason)}t.displayType===fs.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}cancelPendingSurvey(e){N(this._surveyManager)?$.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)==null||(t=e.handlePageUnload)==null||t.call(e)}};function Wl(e,t,n){if(N(e))return!1;switch(n){case`exact`:return e===t;case`contains`:{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(n,`i`).test(e)}case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Gl=class{constructor(e){this._instance=e,this.Dh=new Set,this.Lh=new Set,this.Nh=new bc,this.qh=(e,t)=>this.jh(e,t)&&this.Bh(e,t)&&this.Hh(e,t)&&this.zh(e,t),this.jh=(e,t)=>!t?.event||e?.event===t?.event}init(){k(this._instance?._addCaptureHook)||(this.Uh=this._instance?._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;(e=this.Uh)==null||e.call(this),this.Uh=void 0,this.Nh=new bc}register(e){if(!k(this._instance?._addCaptureHook)&&(e.forEach(e=>{var t;this.Dh.add(e),(t=e.steps)==null||t.forEach(e=>{this.Lh.add(e?.event||``)})}),this._instance?.autocapture)){let e=new Set;this.Dh.forEach(t=>{var n;(n=t.steps)==null||n.forEach(t=>{t!=null&&t.selector&&e.add(t.selector)})}),this._instance.autocapture.setElementSelectors(e)}}replace(e){this.Dh.clear(),this.Lh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Lh.has(e)||this.Lh.has(t.event))&&this.Dh.forEach(e=>{this.Wh(t,e)&&this.Nh.emit(`actionCaptured`,e.name)})}Vh(e){this.onAction(`actionCaptured`,t=>e(t))}Wh(e,t){if(t?.steps==null)return!1;for(let n of t.steps)if(this.qh(e,n))return!0;return!1}onAction(e,t){return this.Nh.on(e,t)}Bh(e,t){if(t?.url){var n;let r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!Wl(r,t.url,t.url_matching||`contains`))return!1}return!0}Hh(e,t){return!!this.Gh(e,t)&&!!this.Zh(e,t)&&!!this.Qh(e,t)}Gh(e,t){var n;if(!t?.href)return!0;let r=this.Jh(e);if(r.length>0)return r.some(e=>Wl(e.href,t.href,t.href_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&Wl(function(e){let t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:``}(i),t.href,t.href_matching||`exact`)}Zh(e,t){var n;if(!t?.text)return!0;let r=this.Jh(e);if(r.length>0)return r.some(e=>Wl(e.text,t.text,t.text_matching||`exact`)||Wl(e.$el_text,t.text,t.text_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&(a=function(e){let t=[],n=/(?::|")text="(.*?)"/g,r;for(;!N(r=n.exec(e));)t.includes(r[1])||t.push(r[1]);return t}(i),o=t.text,s=t.text_matching||`exact`,a.some(e=>Wl(e,o,s)));var a,o,s}Qh(e,t){var n,r;if(!t?.selector||(e==null||(n=e.properties)==null?void 0:n.$element_selectors)?.includes(t.selector))return!0;let i=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&i)try{return new RegExp(t.selector_regex).test(i)}catch{return!1}return!1}Jh(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}zh(e,t){return!t?.properties||t.properties.length===0||jc(t.properties.reduce((e,t)=>{let n=T(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e},{}),e?.properties)}},Kl=class{constructor(e){var t,n;this.Kh=[],this._instance=e,this.Yh=new Map,this.Xh=new Map,this.tc=new Map,this.ec=(t=this._instance)==null||(n=t.onSessionId)==null?void 0:n.call(t,e=>this.nc(e))}sc(e){return!1}rc(){return null}oc(e){}lc(){}ac(e,t){return!!e&&jc(e.propertyFilters,t?.properties)}uc(e,t){let n=new Map;return e.forEach(e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach(t=>{if(t?.name){let r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}})}),n}hc(e,t,n){let r=(n===cs.Activation?this.Yh:this.Xh).get(e),i=[];return this.cc(e=>{i=e.filter(e=>r?.includes(e.id))}),i.filter(r=>{var i;let a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find(t=>t.name===e);return this.ac(a,t)})}register(e){this.dc(e,!1)}replace(e){this.dc(e,!0)}dc(e,t){k(this._instance?._addCaptureHook)||(this.vc(e,t),this.fc(e,t))}fc(e,t){let n=e.filter(e=>{var t;return(t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length});var r;if(t&&this.tc.clear(),n.length===0)return void(t&&((r=this.gc)==null||r.replace([])));this.gc||(this.gc=new Gl(this._instance),this.gc.init(),this.gc.Vh(e=>this.onAction(e)));let i=[];n.forEach(e=>{var t;(t=e.conditions)==null||(t=t.actions)==null||t.values.forEach(t=>{if(i.push(t),t.name){let n=this.tc.get(t.name)??[];n.includes(e.id)||n.push(e.id),this.tc.set(t.name,n)}})}),t?this.gc.replace(i):this.gc.register(i)}mc(e,t){t.forEach((t,n)=>{let r=e.get(n)??[];t.forEach(e=>{r.includes(e)||r.push(e)}),e.set(n,r)})}vc(e,t){let n=e.filter(e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0}),r=e.filter(e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}),i=this.uc(e,cs.Activation),a=this.uc(e,cs.Cancellation);t?(this.Yh=i,this.Xh=a):(this.mc(this.Yh,i),this.mc(this.Xh,a)),(n.length!==0||r.length!==0)&&(this.Uh??=this._instance?._addCaptureHook((e,t)=>{this.onEvent(e,t)}))}onEvent(e,t){var n,r;let i=this.yc(),a=(t==null||(n=t.properties)==null?void 0:n.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){let t=this.bc(e,a);if(t===`consume`)return i.info(`event consumed activated item, removing it`,{event:e,itemId:a}),void this._c([a]);if(t===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),this.wc(a),void this.kc([a])}if(this.Xh.has(e)){let n=this.hc(e,t,cs.Cancellation);n.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:n.map(e=>e.id)}),this._c(n.map(e=>e.id)),n.forEach(e=>this.Sc(e.id)))}if(!this.Yh.has(e))return;i.info(`event name matched`,{event:e,eventPayload:t,items:this.Yh.get(e)});let o=this.hc(e,t,cs.Activation);this.xc(o.map(e=>e.id))}onAction(e){this.tc.has(e)&&this.xc(this.tc.get(e)||[])}xc(e){var t,n;if(e.length===0)return;let r=!!(!((t=this._instance)==null||(n=t.get_session_id)==null)&&n.call(t)),i=[];for(let t of e)r&&this.sc(t)?this.wc(t)&&this.Cc(t):i.push(t);i.length>0&&(this.Kh=[...new Set([...this.Kh,...i])]),this.yc().info(`updating activated items`,{activatedItems:this.getActivatedIds()})}wc(e){this.Kh=this.Kh.filter(t=>t!==e);let t=this.$c();return!t.includes(e)&&(this.Tc([...t,e]),this.Ic(),!0)}_c(e){let t=new Set(e);this.Kh=this.Kh.filter(e=>!t.has(e));let n=this.Mc(),r=n.filter(e=>!t.has(e));r.length!==n.length&&(this.Tc(r),r.length===0&&this.Ec()),this.kc(e)}Pc(){var e;let t=this.rc();if(!t)return{};let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return n&&typeof n==`object`?n:{}}Cc(e){if(!this.rc())return;let t=this.Pc();this.oc(R(R({},t),{},{[e]:Date.now()}))}kc(e){if(!this.rc())return;let t=this.Pc(),n={},r=!1;for(let[i,a]of Object.entries(t))e.includes(i)?r=!0:n[i]=a;r&&(O(n)?this.lc():this.oc(n))}Rc(){this.rc()&&this.lc()}getActivationTimestamp(e){if(!this.$c().includes(e))return;let t=this.Pc()[e];return P(t)?t:void 0}Mc(){var e;let t=this.Ac();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}$c(){var e,t,n;let r=this.Mc();if(r.length===0)return[];let i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.Fc()],a=(t=this._instance)==null||(n=t.get_session_id)==null?void 0:n.call(t);return a&&i===a?r:[]}Ic(){var e,t;let n=(e=this._instance)==null||(t=e.get_session_id)==null?void 0:t.call(e);n&&this.Oc(n)}Ec(){this.Dc()}nc(e){var t;let n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Fc()];if(n&&n!==e){let e=this.Mc(),t=this.Pc();e.length>0&&(this.Tc([]),e.filter(e=>P(t[e])).forEach(e=>this.Sc(e))),this.Ec(),this.Rc()}}getActivatedIds(){return[...new Set([...this.$c(),...this.Kh])].filter(e=>!this.Lc(e))}dispose(){var e,t,n;(e=this.ec)==null||e.call(this),this.ec=void 0,(t=this.Uh)==null||t.call(this),this.Uh=void 0,(n=this.gc)==null||n.dispose(),this.gc=void 0}reset(){this.Kh=[],this.Mc().length>0&&this.Tc([]),this.Ec(),this.Rc()}getEventToItemsMap(){return this.Yh}Nc(){return this.gc}},ql=class extends Kl{constructor(e){super(e)}Ac(){return si}Fc(){return ci}rc(){return li}oc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_timestamps:e})}lc(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_timestamps`)}sc(e){var t;let n;this.cc(t=>{n=t.find(t=>t.id===e)});let r=n==null||(t=n.appearance)==null?void 0:t.surveyPopupDelaySeconds;return P(r)&&r>0}qc(){return us.SHOWN}cc(e){var t;(t=this._instance)==null||t.getSurveys(e)}Sc(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}yc(){return $}Tc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated:e})}Oc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_session:e})}Dc(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_session`)}Lc(){return!1}bc(e,t){let n;return this.cc(e=>{n=e.find(e=>e.id===t)}),!n||function(e){var t;return Dc(e)&&!!(!((t=e.conditions)==null||(t=t.events)==null)&&t.repeatedActivation)||e.schedule===`always`}(n)?e===us.SHOWN?`consume`:`ignore`:e===us.SHOWN?`persist`:e===us.DISMISSED||e===us.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Jl=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e==`string`)return this._instance.get_property(e);let t={};for(let n of e){let e=this._instance.get_property(n);k(e)||(t[n]=e)}return t}set(e,t){this._instance.register(typeof e==`string`?{[e]:t}:e)}remove(e){typeof e==`string`?this._instance.unregister(e):e.forEach(e=>this._instance.unregister(e))}},Yl=class{constructor(e){this._instance=e}get(){let e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){let e=f?.__PosthogExtensions__;if(!e)return;let{generateSurveys:t,loadExternalDependency:n}=e;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:n?e=>n(this._instance,`surveys`,e):void 0}}createEventReceiver(){return new ql(this._instance)}},Xl=e?.location?No(e.location.hash,`__posthog`)||No(location.hash,`state`):null,Zl=`_postHogToolbarParams`,Ql=B(`[Toolbar]`),$l=B(`[FeatureFlags]`),eu=class{constructor(e,t=!1){this.jc=!1,this.update(e,t)}update(e,t){this.Bc=((e,t)=>({bootstrap:{featureFlags:e.bootstrap?.featureFlags??void 0,featureFlagPayloads:e.bootstrap?.featureFlagPayloads??void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:e.remote_config_refresh_interval_ms??3e5,requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:`best-available`,evaluationContexts:e.evaluation_contexts??e.evaluation_environments??[],flagKeys:T(e.flag_keys)?e.flag_keys:void 0}))(e,t),!e.evaluation_environments||e.evaluation_contexts||this.jc||($l.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.jc=!0),k(e.flag_keys)||T(e.flag_keys)||$l.error(`Invalid flag_keys found:`,e.flag_keys,`Expected array of non-empty strings`)}get(){return this.Bc}},tu=B(`[FeatureFlags]`),nu=B(`[FeatureFlags]`,{debugEnabled:!0}),ru=`" failed. Feature flags didn't load in time.`,iu=`connection_error`,au=e=>{let t={};for(let n=0;e.length>n;n++)t[e[n]]=!0;return t},ou=e=>{let t={};for(let[n,r]of Zi(e||{}))r&&(t[n]=r);return t},su=e=>ae(e)&&(e.name===`RangeError`&&e.message.indexOf(`Maximum call stack size exceeded`)===0||e.name===`InternalError`&&e.message===`too much recursion`),cu=B(`[Error tracking]`),lu=`webkit-masked-url:`,uu=[{value:`isolatedAPI.contexts.topHostname`,exact:!1},{value:`No response from target`,exact:!0}],du=[`chrome-extension://`,`moz-extension://`,`safari-extension:`,`safari-web-extension:`,lu],fu=[`__firefox__`,`__gCrWeb`],pu=`Refusing to render web experiment since the viewer is a likely bot`,mu={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Oc(t,e),not_regex:(e,t)=>!Oc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},hu=B(`[Conversations]`),gu=`Conversations not available yet.`;function _u(e,t){let r=e?.flushIntervalMs??3e3,i=e?.maxBufferSize??100,a=t?.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,o=k(a)?Math.max(i,2048):Math.max(i,a),s=R(R({},function(){let e=``,t=``;try{let r=n?.userAgent;r&&([e,t]=mt(r))}catch{}return function(e,t){let n=function(e){if(e)return{}.hasOwnProperty.call(qn,e)?qn[e]:e}(e);return R(R({},n?{"os.name":n}:{}),t?{"os.version":t}:{})}(e,t)}()),e?.resourceAttributes);return{serviceName:s?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:s?.[`service.version`]??e?.serviceVersion,environment:s?.[`deployment.environment`]??e?.environment,resourceAttributes:s,beforeSend:e?.beforeSend,flushIntervalMs:r,maxBufferSize:i,maxQueueSize:o,maxBatchRecordsPerPost:100,rateCapWindowMs:r,maxLogsPerInterval:a,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var vu=[`debug`,`log`,`warn`,`error`,`info`],yu=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},bu=`console`,xu=`__posthogHandledLogsRequestError`,Su=(e,t)=>{let n=e instanceof Error?e:Error(t);return n[xu]=!0,n},Cu=e=>!!e&&typeof e==`object`&&!0===e[xu],wu={featureFlags:class{constructor(e){this.name=`featureFlags`,this.Hc=!1,this.featureFlagEventHandlers=[],this.$=tu,this.zc={},this.Uc={},this.Wc=[],this.Vc=!1,this.Gc=!1,this.Zc=0,this.Qc=!1,this.Jc=!1,this.Kc=!1,this.Yc=!1,this.Xc=0,this.sn=()=>{let e=this.td();this.Xc=0,e&&this.reloadFeatureFlags()},this.ed=()=>{let e=this.nd;k(e)||this.Mr.remoteRequestsDisabled||!r||r.visibilityState===`hidden`||Date.now()-(this.sd??0)<e||(this.reloadFeatureFlags(),this.rd())},this.an=()=>{r?.visibilityState===`visible`&&this.ed()},`get`in e?this.yo=e:(this._instance=e,this.od=new eu(e.config,e.Yl()),this.yo=this.od)}updateConfig(e,t){var n;(n=this.od)==null||n.update(e,t),this.po&&this.ld()}setup(e){return this.xh=e,this.$=e.logger.createLogger(`[FeatureFlags]`),Bl(e.kv.initialize(),()=>{this.xh===e&&(this.xh=void 0,this.po=e,this.ad(e))})}ad(t){var n;if(this.po===t)return e&&G(e,`online`,this.sn),this.ld(),this.ud=t.registerDynamicEventProperties(()=>this.hd()?this.zc:this.Uc),this.dd=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.onCrossTabFeatureFlagChange(()=>{this.vd(),this.fd(),this.pd()}),this.fd(),this.initialize()}ld(){let e=this.Mr.refreshIntervalMs,t=!this.Mr.remoteRequestsDisabled&&r&&!k(e)&&e>0?e:void 0;t!==this.nd&&(this.gd(),k(t)||(this.nd=t,this.rd(),r!=null&&r.addEventListener&&G(r,Wi,this.an)))}rd(){k(this.nd)||(k(this.md)||clearInterval(this.md),this.sd=Date.now(),this.md=setInterval(this.ed,this.nd))}gd(){var e;k(this.md)||(clearInterval(this.md),this.md=void 0,r==null||(e=r.removeEventListener)==null||e.call(r,`visibilitychange`,this.an)),this.nd=void 0,this.sd=void 0}destroy(){this.yd()}dispose(){this.yd()}yd(){var t,n;this.gd(),this.Zc++,this.Jc=!1,this.xh=void 0,this.po&&=(this.bd(),(t=this.ud)==null||t.dispose(),this.ud=void 0,(n=this.dd)==null||n.call(this),this.dd=void 0,this.Wc=[],e?.removeEventListener(`online`,this.sn),void 0)}get Mr(){return this.yo.get()}_d(e){return this.wd&&e in this.wd?this.wd[e]:this.po?.kv.get(e)}vd(){return!!this.wd&&(this.wd=void 0,!0)}kd(){return!k(this.po?.kv.get(`$enabled_feature_flags`))&&this.vd()}At(e){this.Sd(()=>this.po?.kv.set(e))}xd(e,t,n){if(!this._instance?.persistence||!e.$enabled_feature_flags)return;let r=this._d(`$enabled_feature_flags`)||{},i=e.$enabled_feature_flags||{},a=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,e])=>!e?.failed).map(([e])=>e):[],s=!!t.errorsWhileComputingFlags&&!!t.flags,c=s?o:n&&!T(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(r),...Object.keys(i)])),l=this._d(`$feature_flag_payloads`)||{},u=e.$feature_flag_payloads||{},d=s||n?c:Array.from(new Set([...Object.keys(l),...Object.keys(u)])),f=!s&&!n,p=!!f||c,m=!!f||d,h={[Jr]:p,[qr]:p,[Zr]:m};e.$feature_flag_details&&(h[Xr]=p);for(let t of[Qr,bi,$r])k(e[t])||(h[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(h)}Lt(e){this.Sd(()=>this.po?.kv.remove(e))}Sd(e){try{e()}catch(e){this.$.error(`Failed to update feature flag persistence`,e)}}fd(){let e={};for(let t of[Jr,Zr,Qr,ei]){let n=this._d(t);k(n)||(e[t]=n)}this.zc=e;let t=R({},e),n=this._d(qr);if(n)for(let[e,r]of Object.entries(n))t[`$feature/${e}`]=r;this.Uc=t}hd(){let e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;let t=this._d(bi);return typeof t!=`number`||Date.now()-t>e}Cd(){return!!this.hd()&&(this.Yc||this.Gc||(this.Yc=!0,this.$.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}$d(){let e=this.Mr.evaluationContexts;return e?.length?e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this.$.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t}):[]}Td(){let e=this.Mr.flagKeys;if(!k(e))return e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this.$.error(`Invalid flag key found:`,e,`Expected non-empty string`),t})}initialize(){let e=this.Mr,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){let n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter(e=>!k(t[e])).reduce((e,n)=>(e[n]=t[n],e),{}),i=Object.keys(n).filter(e=>r[e]).reduce((e,t)=>(e[t]=n[t],e),{});return this.Id({featureFlags:r,featureFlagPayloads:i},void 0,{persist:!1})}}updateFlags(e,t,n){var r,i;let a=n?.merge&&(r=this._d(`$enabled_feature_flags`))!=null?r:{},o=n?.merge&&(i=this._d(`$feature_flag_payloads`))!=null?i:{},s=R(R({},a),e),c=R(R({},o),t),l={};for(let[e,t]of Object.entries(s))l[e]={key:e,enabled:wn(t),variant:Tn(t),reason:void 0,metadata:k(c?.[e])?void 0:{id:0,version:void 0,description:void 0,payload:c[e]}};this.Id({flags:l})}get hasLoadedFlags(){return this.Vc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let e=this._d(Xr),t=this._d(ei),n=this._d(ti);if(!n&&!t)return e||{};let r=W({},e||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(let e of i){var a;let i=r[e],s=t?.[e],c=k(s)?(a=i?.enabled)!=null&&a:!!s,l=k(s)?i?.variant:typeof s==`string`?s:void 0,u=n?.[e],d=R(R({},i),{},{enabled:c,variant:c?l??i?.variant:void 0});var o;c!==i?.enabled&&(d.original_enabled=i?.enabled),l!==i?.variant&&(d.original_variant=i?.variant),u&&(d.metadata=R(R({},i?.metadata),{},{payload:u,original_payload:i==null||(o=i.metadata)==null?void 0:o.payload})),r[e]=d}return this.Hc||=(this.$.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getAllFeatureFlags(){let e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(n=>{let r=e[n];return{key:n,enabled:wn(r),variant:Tn(r),payload:Cn(t[n])}})}getFlagVariants(){let e=this._d(qr),t=this._d(ei);if(!t)return e||{};let n=W({},e||{}),r=Object.keys(t);for(let e=0;r.length>e;e++)n[r[e]]=t[r[e]];return this.Hc||=(this.$.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){let e=this._d(Zr),t=this._d(ti);if(!t)return e||{};let n=W({},e||{}),r=Object.keys(t);for(let e=0;r.length>e;e++)n[r[e]]=t[r[e]];return this.Hc||=(this.$.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.Qc||this.Mr.featureFlagsDisabled||this.td()||(this.Gc&&(this.Jc=!0),this.Md||=(this.Wc.slice().forEach(e=>{try{e()}catch(e){this.$.error(`Error while running feature flags reloading callback`,e)}}),setTimeout(()=>{this.Ed()},5)))}bd(){clearTimeout(this.Md),this.Md=void 0}onReloading(e){return this.Wc.push(e),()=>{this.Wc=this.Wc.filter(t=>t!==e)}}ensureFlagsLoaded(){this.Vc||this.Gc||this.Md||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Qc=e}resetFlagCallReported(){this.Lt(_i)}Ed(e){this.bd();let t=this.po;if(!t||this.Mr.remoteRequestsDisabled||this.td())return;if(this.Gc)return void(this.Jc=!0);let n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:R(R(R({},t.initialPersonProperties),this._d(`$stored_person_properties`)||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this._d(ri),timezone:Yo()};k(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Mr.featureFlagsDisabled)&&(n.disable_flags=!0);let r=this.$d();r.length&&(n.evaluation_contexts=r);let i=this.Td();k(i)||(n.flag_keys=i);let a=this.Mr.onlyEvaluateSurveyFeatureFlags,o=`/flags/?v=2`+(a?`&only_evaluate_survey_feature_flags=true`:``),s=this.Zc;this.Gc=!0;let c=()=>{this.Jc&&(this.Jc=!1,this.Ed())},l=e=>{let t=e.json??{},r=e.statusCode!==200;if(this.Gc=!1,s!==this.Zc)return void c();if(this.Pd(e.statusCode),r||this.Jc||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.Jc)return;this.Kc=!r;let i=[];e.error?i.push(e.error instanceof Error&&e.error.name===`AbortError`?`timeout`:e.error instanceof Error?iu:`unknown_error`):e.statusCode!==200&&i.push(`api_error_${e.statusCode}`),t.errorsWhileComputingFlags&&i.push(`errors_while_computing_flags`);let o=!!t.quotaLimited?.includes(`feature_flags`);o&&i.push(`quota_limited`),this.At({[yi]:i}),o?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.`):n.disable_flags||this.Id(t,r,{partialResponse:a}),c()},u=e=>{this.Gc=!1,s===this.Zc?(this.At({[yi]:[iu]}),this.$.error(`Feature flag request failed`,e),this.kd()&&this.pd(!0),c()):c()};try{t.sendRequest(o,{target:`flags`,method:`POST`,body:n,compression:this.Mr.compression,sentAt:`body`,timeoutMs:this.Mr.requestTimeoutMs}).then(l).catch(u)}catch(e){u(e)}}td(){return Po(this.Xc,3)}Pd(e){this.Xc=Fo(e,this.Xc,3,()=>this.$.warn(`Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.`))}getFeatureFlag(e,t={}){if(t.fresh&&!this.Kc)return;if(!(this.Vc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn(`getFeatureFlag for key "`+e+ru);if(this.Cd())return;let n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.Kc)return;if(!(this.Vc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn(`getFeatureFlagResult for key "`+e+ru);if(this.Cd())return;let n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this._d(`$feature_flag_request_id`)||void 0,c=this._d(`$feature_flag_evaluated_at`)||void 0,l,u=this._d(`$flag_call_reported`)||{};if(this.Mr.deduplicateCallsPerSession){let e=this.po?.session.sessionId,t=this._d(vi);e&&e!==t&&(u={},l=e)}if(t.send_event||!(`send_event`in t))if(e in u&&u[e].includes(o))l&&this.At({[_i]:u,[vi]:l});else{var d,f,p,m,h,g,_,v;T(u[e])?u[e].push(o):u[e]=[o],this.At(R({[_i]:u},l?{[vi]:l}:{}));let t=this.getFeatureFlagDetails(e),n=[...this._d(`$feature_flag_errors`)??[]];k(i)&&n.push(`flag_missing`);let r={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a??null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((d=this.Mr.bootstrap)==null||(d=d.featureFlags)==null?void 0:d[e])??null,$feature_flag_bootstrapped_payload:((f=this.Mr.bootstrap)==null||(f=f.featureFlagPayloads)==null?void 0:f[e])??null,$used_bootstrap_value:!this.Kc};k(t==null||(p=t.metadata)==null?void 0:p.has_experiment)||(r.$feature_flag_has_experiment=t.metadata.has_experiment),k(t==null||(m=t.metadata)==null?void 0:m.version)||(r.$feature_flag_version=t.metadata.version);let b=(t==null||(h=t.reason)==null?void 0:h.description)??(t==null||(g=t.reason)==null?void 0:g.code);var y;b&&(r.$feature_flag_reason=b),!(t==null||(_=t.metadata)==null)&&_.id&&(r.$feature_flag_id=t.metadata.id),k(t?.original_variant)&&k(t?.original_enabled)||(r.$feature_flag_original_response=k(t.original_variant)?t.original_enabled:t.original_variant),!(t==null||(v=t.metadata)==null)&&v.original_payload&&(r.$feature_flag_original_payload=t==null||(y=t.metadata)==null?void 0:y.original_payload),n.length&&(r.$feature_flag_error=n.join(`,`)),this.Rd(r)}else l&&this.At({[_i]:u,[vi]:l});return r?{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:Cn(a)}:void 0}Rd(e){try{var t;(t=this.po)==null||t.capture(`$feature_flag_called`,e).catch(e=>{this.$.error(`Failed to capture feature flag call`,e)})}catch(e){this.$.error(`Failed to capture feature flag call`,e)}}getRemoteConfigPayload(e,t){this.Ad(e,t)}Ad(e,t){var n=this;return L(function*(){let r=n.po;if(!r)return;let i={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},a=n.$d();a.length&&(i.evaluation_contexts=a);let o=n.Td(),s;k(o)||(i.flag_keys=o);try{s=(yield r.sendRequest(`/flags/?v=2`,{target:`flags`,method:`POST`,body:i,compression:n.Mr.compression,sentAt:`body`,timeoutMs:n.Mr.requestTimeoutMs})).json?.featureFlagPayloads?.[e]||void 0}catch(e){n.$.error(`Remote config feature flag request failed`,e);return}try{t(s)}catch(e){n.$.error(`Remote config feature flag callback failed`,e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.Kc)return t.defaultValue;if(!(this.Vc||this.getFlags()&&this.getFlags().length>0))return this.$.warn(`isFeatureEnabled for key "`+e+ru),t.defaultValue;let n=this.getFeatureFlag(e,t);return k(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this.Id(e,t,n)}Id(e,t,n){if(!this.po)return;this.Vc=!0;let r=((e,t={},n={},r={},i,a=tu)=>{let o=((e,t)=>{let n=e.flags;if(n){let t=Object.fromEntries(Object.keys(n).map(e=>[e,n[e].variant??n[e].enabled])),r=Object.fromEntries(Object.keys(n).filter(e=>n[e].enabled).filter(e=>!k(n[e].metadata?.payload)).map(e=>[e,n[e].metadata?.payload]));return R(R({},e),{},{featureFlags:t,featureFlagPayloads:r})}return e.featureFlags&&t.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e,a),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(!c)return;let u=e.requestId,d=e.evaluatedAt;if(T(c)){a.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);let e={};if(c)for(let t=0;c.length>t;t++)e[c[t]]=!0;return{[Jr]:c,[qr]:e,[$r]:!1}}let f=c,p=l,m=s;if(i?.partialResponse){let e=Object.keys(f),i=p||{};f=R(R({},t),f),p=R(R({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=R(R({},r),m)}else if(e.errorsWhileComputingFlags)if(s){let e=new Set(Object.keys(s).filter(e=>!s[e]?.failed));f=R(R({},t),Object.fromEntries(Object.entries(f).filter(([t])=>e.has(t))));let i=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=R(R({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=R(R({},r),Object.fromEntries(Object.entries(m||{}).filter(([t])=>e.has(t))))}else f=R(R({},t),f),p=R(R({},n),p),m=R(R({},r),m);return R(R({[Jr]:Object.keys(ou(f)),[qr]:f||{},[Zr]:p||{},[Xr]:m||{},[$r]:!0===e.minimalFlagCalledEvents},u?{[Qr]:u}:{}),d?{[bi]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.$);if(r)if(!1===n?.persist){let e=!k(this.po.kv.get(qr));this.wd=r,e||this.At(r)}else this.vd(),this.xd(r,e,!!n?.partialResponse),this.At(r);else t&&this.kd();t||(this.Yc=!1),this.pd(t)}override(e,t=!1){this.$.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Fd(e)}Fd(e){if(this.po){if(!1===e)return this.Lt([ei,ti]),this.pd(),void nu.info(`All overrides cleared`);if(T(e))return this.At({[ei]:au(e)}),this.pd(),void nu.info(`Flag overrides set`,{flags:e});if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var t;let n=e;this.Hc=!!((t=n.suppressWarning)!=null&&t);let r={},i=n.flags,a=n.payloads;i&&(r[ei]=T(i)?au(i):i),a&&(r[ti]=a),Object.keys(r).length&&this.At(r),!1===i&&!1===a?this.Lt([ei,ti]):!1===i?this.Lt(ei):!1===a&&this.Lt(ti),this.pd(),!1===i?nu.info(`Flag overrides cleared`):i&&nu.info(`Flag overrides set`,{flags:i}),!1===a?nu.info(`Payload overrides cleared`):a&&nu.info(`Payload overrides set`,{payloads:a});return}if(e&&typeof e==`object`)return this.At({[ei]:e}),this.pd(),void nu.info(`Flag overrides set`,{flags:e});this.$.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}else this.$.warn(`posthog.featureFlags.overrideFeatureFlags called before feature flags were ready`)}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Vc){let{flags:t,flagVariants:n}=this.Od();try{e(t,n)}catch(e){this.$.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;let i=(this._d(`$early_access_features`)||[]).find(t=>t.flagKey===e),a={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n);let s=R(R({},this.getFlagVariants()),{},{[e]:t});(r=this._instance)==null||(r=r.persistence)==null||r.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(a)}),this.At({[Jr]:Object.keys(ou(s)),[qr]:s,[ni]:R(R({},this._d(`$stored_person_properties`)||{}),a)}),this.pd();try{var c;(c=this.po)==null||c.capture(`$feature_enrollment_update`,o).catch(e=>{this.$.error(`Failed to capture early access feature enrollment`,e)})}catch(e){this.$.error(`Failed to capture early access feature enrollment`,e)}}getEarlyAccessFeatures(e,t=!1,n){let r=this._d(Yr);!r||t?this.Dd(e,n):e(r)}Dd(e,t){var n=this;return L(function*(){let r=n.po;if(!r)return;let i=t?`&${t.map(e=>`stage=${e}`).join(`&`)}`:``,a;try{let e=yield r.sendRequest(`/api/early_access_features/?token=${r.projectToken}${i}`,{target:`api`,method:`GET`,sentAt:`query`});if(!e.json)return;a=e.json.earlyAccessFeatures,n.At({[Yr]:a})}catch(e){n.$.error(`Early access feature request failed`,e);return}try{e(a)}catch(e){n.$.error(`Early access feature callback failed`,e)}})()}Od(){let e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,n)=>(e[n]=t[n],e),{})}}pd(e){this.fd();let{flags:t,flagVariants:n}=this.Od();this.featureFlagEventHandlers.forEach(r=>{try{r(t,n,{errorsLoading:e})}catch(e){this.$.error(`Error while running feature flags callback`,e)}})}setPersonPropertiesForFlags(e,t=!0){this.Ld(e,t)}Ld(e,t=!0){let n=this._d(`$stored_person_properties`)||{},r=e?.$set||(e?.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(let e in i)({}).hasOwnProperty.call(i,e)&&(e in n||(a[e]=i[e]));this.At({[ni]:R(R(R({},n),a),r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){let n=R({},this._d(`$stored_person_properties`)||{});e.forEach(e=>{delete n[e]}),this.At({[ni]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(ni),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){let n=this._d(`$stored_group_properties`)||{},r=R({},n);for(let t of Object.keys(e))r[t]=R(R({},n[t]),e[t]);this.At({[ri]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){let t=this._d(`$stored_group_properties`)||{};this.At({[ri]:R(R({},t),{},{[e]:{}})})}else this.Lt(ri)}reset(){this.Zc++,this.Jc=!1,this.zc={},this.Uc={},this.wd=void 0,this.Vc=!1,this.Qc=!1,this.Kc=!1,this.$anon_distinct_id=void 0,this.bd(),this.Hc=!1,this.Xc=0}}},Tu={sessionRecording:class{get Mr(){return this._instance.config}get xa(){return this._instance.persistence}get started(){return!!this.Nd?.isStarted}get status(){return this.qd===`awaiting_config`||this.qd===`missing_config`?this.qd:this.Nd?.status??this.qd}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.qd=Al,this.jd=void 0,this.Bd=!1,this.Ke=(()=>{var t,n;if(!r?.visibilityState||r.visibilityState===`visible`)return!0;let i=e==null||(t=e.performance)==null||(n=t.getEntriesByType)==null?void 0:n.call(t,`visibility-state`);return!i?.length||i.some(e=>e.name===`visible`)})(),this.an=()=>{var e,t;r?.visibilityState===`visible`&&(this.Ke=!0,(e=this.Nd)==null||(t=e.setDocumentWasEverVisible)==null||t.call(e,!0))},!this._instance.sessionManager)throw Ml.error(`started without valid sessionManager`),Error(`[SessionRecording] started without valid sessionManager. This is a bug.`);if(this.Mr.cookieless_mode===`always`)throw Error(`[SessionRecording] cannot be used with cookieless_mode="always"`);r!=null&&r.addEventListener&&G(r,`visibilitychange`,this.an)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.Bd=!0,r==null||(t=r.removeEventListener)==null||t.call(r,`visibilitychange`,this.an),e?this.Hd(!0):this.stopRecording()}get zd(){let t=!!this._instance.get_property(`$session_recording_remote_config`)?.enabled,n=!this.Mr.disable_session_recording,r=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return e&&t&&n&&!r}startIfEnabledOrStop(e){if(this.Bd||this.zd&&this.Nd?.isStarted)return;let t=!k(Object.assign)&&!k(Array.from);this.zd&&t?(this.Ud(e),Ml.info(`starting`)):(this.qd=Al,this.stopRecording())}Ud(e){var t;if(this.zd)if(this.qd!==`awaiting_config`&&this.qd!==`missing_config`&&(this.qd=jl),!(f==null||(t=f.__PosthogExtensions__)==null||(t=t.rrweb)==null)&&t.record&&f.__PosthogExtensions__?.initSessionRecording)this.Wd(e);else{var n,r;let t=this._instance.sessionManager;(n=f.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,this.Vd,n=>{if(!this.Bd&&this.zd&&this._instance.sessionManager===t)return n?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Ml.error(`could not load recorder`,n)):void this.Wd(e);this.qd=`disabled`})}}stopRecording(){var e,t;(e=this.jd)==null||e.call(this),this.jd=void 0,(t=this.Nd)==null||t.stop()}Hd(e=!1){var t,n;(t=this.jd)==null||t.call(this),this.jd=void 0,(n=this.Nd)==null||n.discard({discardProducerEvents:e})}Gd(){var e,t;(e=this.xa)==null||e.unregister(`$session_is_sampled`),(t=this.xa)==null||t.unregister(`$replay_sample_rate`)}Zd(e,t){if(N(e))return null;let n=P(e)?e:parseFloat(e);return typeof(r=n)!=`number`||!Number.isFinite(r)||0>r||r>1?(Ml.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):n;var r}Qd(e){if(this.xa){var t;let n=this.xa,r=()=>{let t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.Zd(this.Mr.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.Zd(t?.sampleRate,`remote config sampleRate`),a=r??i;N(a)&&this.Gd();let o=t?.minimumDurationMilliseconds;n.register({[Nr]:R(R({cache_timestamp:Date.now(),enabled:!!t},t),{},{networkPayloadCapture:R({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:k(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.jd)==null||t.call(this),this.jd=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){let t=e.ok?e.config:void 0;t&&`sessionRecording`in t?!1===t.sessionRecording?(this.Qd(t),this.Hd()):(this.Qd(t),this.startIfEnabledOrStop()):(this.qd===`awaiting_config`&&(this.qd=`missing_config`,Ml.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t=`log`){this.Nd?.log?this.Nd.log(e,t):Ml.warn(`log called before recorder was ready`)}get Vd(){var e,t;let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Nr);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Jd(){let e=this._instance.get_property(Nr);if(!e)return!1;let t;try{t=typeof e==`object`?e:JSON.parse(e)}catch(e){return Ml.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}return!N(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Wd(e){var t,n;if(!this.Bd&&this.zd&&this._instance.sessionManager){if(!f.__PosthogExtensions__?.initSessionRecording)return Ml.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[ji]:!0});if(this.Nd||(this.Nd=f.__PosthogExtensions__?.initSessionRecording(this._instance,this.Ke),this.Nd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Jd()){if(this.qd===`missing_config`||this.qd===`awaiting_config`)return;this.qd=`awaiting_config`,Ml.info(`persisted remote config is stale, requesting fresh config before starting`),new ys(this._instance).load();return}this.qd=jl,(t=(n=this.Nd).setDocumentWasEverVisible)==null||t.call(n,this.Ke),this.Nd.start(e)}else this.qd=Al}onRRwebEmit(e){var t,n;(t=this.Nd)==null||(n=t.onRRwebEmit)==null||n.call(t,e)}overrideLinkedFlag(){var e,t;this.Nd||(t=this.xa)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Nd)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Nd||(t=this.xa)==null||t.register({$replay_override_sampling:!0}),(e=this.Nd)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.Nd||(n=this.xa)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.Nd)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.Nd?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){return!!this.Nd?.tryAddCustomEvent(e,t)}flushBeforeIdentityReset(){var e,t;(e=this.Nd)==null||(t=e.flushBeforeIdentityReset)==null||t.call(e)}}},Eu={autocapture:class extends vl{constructor(e){super(new yl(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.Kd=this.Yd()}initialize(){this.startIfEnabled()}get isEnabled(){let e=this.Xd();return!!(e.path||e.search||this.tv(e))}startIfEnabled(){this.isEnabled&&(z.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Kd=this.Yd(),this.startIfEnabled()}stop(){this.ev&&this.ev(),this.ev=void 0,this.iv&&this.iv(),this.iv=void 0,z.info(`History API monitoring stopped`)}monitorHistoryChanges(){e&&e.history&&(this.nv(`pushState`),this.nv(`replaceState`),this.sv(),this.tv()&&this.rv())}nv(t){if(!e||e.history[t]?.__posthog_wrapped__)return;let n=this;Cl(e.history,t,e=>function(r,i,a){e.call(this,r,i,a),n.ov(t)})}Yd(){let t=e?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Xd(){let e=this._instance.config.capture_pageview;return e===`history_change`?{path:!0}:D(e)?e:{}}tv(e=this.Xd()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}lv(e){let t=this.Xd(),n=this.Kd;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this.tv(t)&&e.hash!==n.hash))}ov(e){try{let t=this.Yd();if(!t)return;this.lv(t)&&this._instance.capture(Ki,{navigation_type:e}),this.Kd=t}catch(t){z.error(`Error capturing ${e} pageview`,t)}}sv(){if(this.ev)return;let t=()=>{this.ov(`popstate`)};G(e,`popstate`,t),this.ev=()=>{e&&e.removeEventListener(`popstate`,t)}}rv(){if(this.iv)return;let t=()=>{this.ov(`hashchange`)};G(e,`hashchange`,t),this.iv=()=>{e&&e.removeEventListener(`hashchange`,t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(e){this.av=!1,this.bo=!1,this.uv=null,this.instance=e,this.av=!!this.instance.persistence?.props[wr],this.rageclicks=new fl(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return D(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return N(this.Mr.capture_heatmaps)?N(this.Mr.enable_heatmaps)?this.av:this.Mr.enable_heatmaps:!1!==this.Mr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.bo)return;Nl.info(`starting...`),this.hv(),this.an()}else clearInterval(this.uv??void 0),this.dv(),this.getAndClearBuffer()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`heatmaps`in t))return;let n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[wr]:n}),this.av=n,this.startIfEnabled()}getAndClearBuffer(){let e=this.Rt;return this.Rt=void 0,e}vv(e){Pl(e.originalEvent)&&this.Cr(e.originalEvent,`deadclick`)}an(){this.uv&&clearInterval(this.uv),this.uv=r?.visibilityState===`visible`?setInterval(this.fa.bind(this),this.flushIntervalMilliseconds):null}hv(){e&&r&&(this.fv=this.fa.bind(this),G(e,Gi,this.fv),this.pv=t=>this.Cr(t||e?.event),G(r,`click`,this.pv,{capture:!0}),this.gv=t=>this.mv(t||e?.event),G(r,`mousemove`,this.gv,{capture:!0}),this.yv=new yo(this.instance,_o,this.vv.bind(this)),this.yv.startIfEnabledOrStop(),this.bv=this.an.bind(this),G(r,Wi,this.bv),this.bo=!0)}dv(){var t;e&&r&&(this.fv&&e.removeEventListener(Gi,this.fv),this.pv&&r.removeEventListener(`click`,this.pv,{capture:!0}),this.gv&&r.removeEventListener(`mousemove`,this.gv,{capture:!0}),this.bv&&r.removeEventListener(Wi,this.bv),clearTimeout(this._v),(t=this.yv)==null||t.stop(),this.bo=!1)}wv(t,n){let r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),a=this.instance.scrollManager.scrollElement(),o=function(t,n,r){let i=t;for(;i&&Na(i)&&!Y(i,`body`);){if(i===r)return!1;let t;try{t=(i.ownerDocument?.defaultView??e)?.getComputedStyle(i).position}catch{return!1}if(y(n,t))return!0;i=Ga(i)}return!1}(Va(t),[`fixed`,`sticky`],a);return{x:t.clientX+(o?0:i),y:t.clientY+(o?0:r),target_fixed:o,type:n}}Cr(e,t=`click`){var n;if(Ma(e.target)||!Pl(e))return;let r=this.wv(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Qa(Va(e),this.instance.config.rageclick)&&this.Zs(R(R({},r),{},{type:`rageclick`})),this.Zs(r)}mv(e){!Ma(e.target)&&Pl(e)&&(clearTimeout(this._v),this._v=setTimeout(()=>{this.Zs(this.wv(e,`mousemove`))},500))}Zs(t){if(!e)return;let n=this.Mr.disable_capture_url_hashes?Et(e.location.href):e.location.href,r=this.Mr.custom_personal_data_properties,i=Mo(n,this.Mr.mask_personal_data_properties?[...Io,...r||[]]:[],Ro);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}fa(){this.Rt&&!O(this.Rt)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:yo,webVitalsAutocapture:class{constructor(e){this._instance=e,this.av=!1,this.bo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Sv=()=>{clearTimeout(this.xv),this.xv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture(`$web_vitals`,R({$current_url:this.Rt.url},this.Rt.metrics.reduce((e,t)=>R(R({},e),{},{[`$web_vitals_${t.name}_event`]:R({},t),[`$web_vitals_${t.name}_value`]:t.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Cv=e=>{if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},N(e?.name)||N(e?.value))return void Tl.error(`Invalid metric received`,e);let t=typeof e.navigationURL==`string`?e.navigationURL:void 0,n=this.$v(t);if(k(n))return;let r=P(e.navigationId)||typeof e.navigationId==`string`?`navigation:${e.navigationId}`:`url:${n}`;if(this.Tv&&e.value>=this.Tv)return void Tl.error(`Ignoring metric with value >= `+this.Tv,e);this.Rt.navigationKey!==r&&(this.Sv(),this.xv=setTimeout(this.Sv,this.flushToCaptureTimeoutMs)),k(this.Rt.navigationKey)&&(this.Rt.navigationKey=r,this.Rt.url=n),this.Rt.firstMetricTimestamp=k(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;let i=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),a=R(R(R({},e),t?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete a.entries,D(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){let t={};for(let n of kl){let r=n===`url`&&typeof e.attribution[n]==`string`?this.$v(e.attribution[n]):e.attribution[n];k(r)||(t[n]=r)}a.attribution=t}else delete a.attribution;k(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this.Rt.metrics.push(a),this.Rt.metrics.length===this.allowedMetrics.length&&this.Sv()},this.Iv=()=>{if(this.bo)return;let e,t,n,r,i=!1,a=f.__PosthogExtensions__,o=a?.postHogWebVitalsCallbacksByFlavor,s=o?.[this.Mv]||(this.Mv===`web-vitals`&&k(o)?a?.postHogWebVitalsCallbacks:void 0);if(!k(s)){let a=s.withoutAttribution,o=this.attributionMetrics;i=!k(a),e=o.indexOf(`LCP`)>-1?s.onLCP:a?.onLCP||s.onLCP,t=o.indexOf(`CLS`)>-1?s.onCLS:a?.onCLS||s.onCLS,n=o.indexOf(`FCP`)>-1?s.onFCP:a?.onFCP||s.onFCP,r=o.indexOf(`INP`)>-1?s.onINP:a?.onINP||s.onINP}if(!(e&&t&&n&&r))return void Tl.error(`web vitals callbacks not loaded - not starting`);let c={reportSoftNavs:this.useSoftNavs},l=i&&this.attributionMetrics.indexOf(`INP`)>-1?R(R({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.Cv.bind(this),c),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.Cv.bind(this),c),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.Cv.bind(this),c),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.Cv.bind(this),l),this.bo=!0},this.av=!!this._instance.persistence?.props[Or],this.startIfEnabled()}get Ev(){return this._instance.config.capture_performance}get allowedMetrics(){let e=D(this.Ev)?this.Ev?.web_vitals_allowed_metrics:void 0;return N(e)?this._instance.persistence?.props.$web_vitals_allowed_metrics||Dl:e}get flushToCaptureTimeoutMs(){return(D(this.Ev)?this.Ev.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let e=D(this.Ev)?this.Ev.web_vitals_attribution:void 0;return F(e)?e?Dl:[]:T(e)?e:Ol}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let e=D(this.Ev)?this.Ev.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Tv(){let e=D(this.Ev)&&P(this.Ev.__web_vitals_max_value)?this.Ev.__web_vitals_max_value:El;return e>0&&6e4>=e?El:e}get isEnabled(){let e=i?.protocol;if(e!==`http:`&&e!==`https:`)return Tl.info(`Web Vitals are disabled on non-http/https protocols`),!1;let t=D(this.Ev)?this.Ev.web_vitals:F(this.Ev)?this.Ev:void 0;return F(t)?t:this.av}startIfEnabled(){this.isEnabled&&!this.bo&&(Tl.info(`enabled, starting...`),this.No(this.Iv))}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`capturePerformance`in t))return;let n=D(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=D(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Or]:n}),this._instance.persistence.register({[Mr]:r})),this.av=n,this.startIfEnabled()}get Mv(){return this.useSoftNavs?this.useAttribution?`web-vitals-with-attribution-soft-navs`:`web-vitals-soft-navs`:this.useAttribution?`web-vitals-with-attribution`:`web-vitals`}No(e){var t;let n=f.__PosthogExtensions__,r=this.Mv,i=n?.postHogWebVitalsCallbacksByFlavor;i?.[r]||r===`web-vitals`&&k(i)&&n?.postHogWebVitalsCallbacks?e():n==null||(t=n.loadExternalDependency)==null||t.call(n,this._instance,r,t=>{t?Tl.error(`failed to load script`,t):e()})}$v(t){let n=t||e?.location.href;if(!n)return void Tl.error(`Could not determine current URL`);let r=this._instance.config.disable_capture_url_hashes?Et(n):n,i=this._instance.config.custom_personal_data_properties;return Mo(r,this._instance.config.mask_personal_data_properties?[...Io,...i||[]]:[],Ro)}}},Du={exceptionObserver:class{constructor(t){this.Iv=()=>{if(!e||!this.isEnabled||!f.__PosthogExtensions__?.errorWrappingFunctions)return;let t=f.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=f.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=f.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Pv&&this.Mr.capture_unhandled_errors&&(this.Pv=t(this.captureException.bind(this))),!this.Rv&&this.Mr.capture_unhandled_rejections&&(this.Rv=n(this.captureException.bind(this))),!this.Av&&this.Mr.capture_console_errors&&(this.Av=r(this.captureException.bind(this)))}catch(e){bl.error(`failed to start`,e),this.Fv()}},this._instance=t,this.Ov=!!this._instance.persistence?.props[Tr],this.wt=new he(R(R({},function(e={}){return{refillRate:e.exceptionRateLimiterRefillRate??e.__exceptionRateLimiterRefillRate??1,bucketSize:e.exceptionRateLimiterBucketSize??e.__exceptionRateLimiterBucketSize??10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:bl})),this.Mr=this.Dv(),this.startIfEnabledOrStop()}Dv(){let e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return D(e)?t=R(R({},t),e):(k(e)?this.Ov:e)&&(t=R(R({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(bl.info(`enabled`),this.Fv(),this.No(this.Iv)):this.Fv()}No(e){var t,n;f.__PosthogExtensions__?.errorWrappingFunctions?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`exception-autocapture`,t=>{if(t)return bl.error(`failed to load script`,t);e()})}Fv(){var e,t,n;(e=this.Pv)==null||e.call(this),this.Pv=void 0,(t=this.Rv)==null||t.call(this),this.Rv=void 0,(n=this.Av)==null||n.call(this),this.Av=void 0}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`autocaptureExceptions`in t&&(this.Ov=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Tr]:this.Ov}),this.Mr=this.Dv(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.Dv()}captureException(e){try{var t,n;let r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;if(this.wt.consumeRateLimit(r))return void bl.info(`Skipping exception capture because of client rate limiting.`,{exception:r});(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){this.Lv=[],this.Nv=new Lt([new an,new hn,new sn,new on,new pn,new fn,new ln,new mn],function(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
|
|
2
|
+
`),o=Math.min(a.length,r+1e3),s=[];for(let n=r;o>n;n++){let r=a[n];if(r.length>1024)continue;let o=Xt.test(r)?r.replace(Xt,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);let e=Qt(i);if(e){for(let t=s.length-1;t>=0;t--){let n=s[t];if(e.start>=n.start+n.length)break;s.pop()}s.push(e)}break}}if(nn(i,s)>=50)break}}let c=[...s].sort((e,t)=>t.start-e.start),l=c[c.length-1];if(l){let e=en(i,l);i.splice(l.start-e,e);for(let t of c)t.start-=e}for(let e of c)$t(i,e);return s.some(e=>e.start===0&&i.length===e.length)&&function(e){let t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`),n=0;for(let e=1;t.length>e;e++)rn(t,e,n)&&(n=e);e.push(...e.splice(0,n))}(i),function(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return R(R({},e),{},{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||`?`});var n})}(i)}}(`web:javascript`,Kt,Yt)),this._instance=e,this.Lv=this._instance.persistence?.get_property(`$error_tracking_suppression_rules`)??[],this.qv=bn(this.jv()),this.Bv=new xn(this.qv)}onConfigChange(){this.qv=bn(this.jv()),this.Bv.setConfig(this.qv)}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`errorTracking`in t))return;let n=t.errorTracking?.suppressionRules??[],r=t.errorTracking?.captureExtensionExceptions;this.Lv=n,this._instance.persistence&&this._instance.persistence.register({[Er]:this.Lv,[Dr]:r})}get Hv(){var e;let t=!!this._instance.get_property(Dr);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.Nv.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.qv.enabled)try{if(!A(e)||e.trim().length===0)return void cu.warn(`Ignoring exception step because message must be a non-empty string`);let{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};let t=[];return{sanitizedProperties:Object.keys(e).reduce((n,r)=>vn.has(r)?(t.push(r),n):(n[r]=e[r],n),{}),droppedKeys:t}}(this.zv(t));r.length>0&&cu.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this.Bv.add(R({[gn]:e,[_n]:new Date().toISOString()},n))}catch(e){cu.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{let t=e.$exception_list;if(this.Uv(t)){if(this.Wv(t))return this.Vv(`Exception dropped: matched a suppression rule`),void cu.info(`Skipping exception capture because a suppression rule matched`);if(!this.Hv&&this.Gv(t))return this.Vv(`Exception dropped: thrown by a browser extension`),void cu.info(`Skipping exception capture because it was thrown by an extension`);if(!this.Hv&&this.Zv(t))return this.Vv(`Exception dropped: thrown by an injected browser script`),void cu.info(`Skipping exception capture because it was thrown by an injected browser script`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Qv(t))return this.Vv(`Exception dropped: thrown by the PostHog SDK`),void cu.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}let n=this.qv.enabled&&N(e.$exception_steps)?this.Jv(e):e,r=function(){let e=globalThis._posthogReleaseId;return typeof e==`string`&&e.length>0?e:void 0}();r&&(n.$release_id=r);try{let e=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,eh:!0});return e&&this.Bv.clear(),e}catch(e){su(e)||cu.error(`Failed to capture exception event. Dropping this exception.`,e),this.Bv.clear();return}}catch(e){su(e)||cu.error(`Failed to process exception event. Ignoring this exception.`,e);return}}Jv(e){try{let t=this.Bv.getAttachable();return t.length===0?e:R(R({},e),{},{$exception_steps:t})}catch(t){return cu.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}Vv(e){this.qv.enabled&&this.Bv.add({[gn]:e,[_n]:new Date().toISOString()})}zv(e){return D(e)?R({},e):{}}jv(){return this._instance.config.error_tracking?.exception_steps??{}}Wv(e){if(e.length===0)return!1;try{let t=e.reduce((e,{type:t,value:n})=>(A(t)&&t.length>0&&e.$exception_types.push(t),A(n)&&n.length>0&&e.$exception_values.push(n),e),{$exception_types:[],$exception_values:[]});return this.Lv.some(e=>{let n=e.values.map(e=>{let n=Ac[e.operator],r=t[e.key];if(!n||!r)return!1;let i=T(e.value)?e.value:[e.value];return i.length>0&&n(i,r)});return e.type===`OR`?n.some(Boolean):n.every(Boolean)})}catch(e){return cu.warn(`Failed to evaluate suppression rules. Capturing the exception.`,e),!1}}Gv(e){let t=e.flatMap(e=>e.stacktrace?.frames??[]),n=t.filter(({filename:e})=>!!e&&du.some(t=>e.startsWith(t)));return n.length!==0&&(!n.every(({filename:e})=>!!e&&e.startsWith(lu))||e.some(({type:e,value:t})=>e===`NoResponse`||A(t)&&uu.some(({value:e,exact:n})=>n?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!t?.startsWith(lu)))}Zv(e){return e.some(({value:e})=>A(e)&&fu.some(t=>e.includes(t)))}Qv(e){if(e.length>0){var t,n;let r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}Uv(e){return!N(e)&&T(e)}}},Ou=R({productTours:class{get xa(){return this._instance.persistence}constructor(e){this.Kv=null,this.Yv=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(`productTours`in t){var n;if(this.xa&&this.xa.register({[Ar]:!!t.productTours}),!Il(this._instance))return!this.Kv&&N(this.xa?.props.ph_product_tours)||Fl.info(`product tours disabled; stopping and clearing cached tours`),(n=this.Kv)==null||n.stop(),this.Kv=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Kv&&Il(this._instance)&&this.No(()=>this.Xv())}No(e){var t,n;f.__PosthogExtensions__?.generateProductTours?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`product-tours`,t=>{t?Fl.error(`Could not load product tours script`,t):e()})}Xv(){var e;!this.Kv&&(e=f.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Kv=f.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(T(this.Yv)&&!t)return void e(this.Yv,{isLoaded:!0});let n=this.xa;if(n){let r=n.props[ui];if(T(r)&&!t)return this.Yv=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=${this._instance.config.token}`),method:`GET`,timestampMode:`query`,callback:t=>{if(!Il(this._instance))return void e([],{isLoaded:!0});let r=t.statusCode;if(r!==200||!t.json){let n=`Product Tours API could not be loaded, status: ${r}`;r===0?t.error||Fl.warn(n):Fl.error(n),e([],{isLoaded:!1,error:n});return}let i=T(t.json.product_tours)?t.json.product_tours:[];this.Yv=i,n&&n.register({[ui]:i}),e(i,{isLoaded:!0})}})}getActiveProductTours(e){N(this.Kv)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.Kv.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Kv)==null||t.showTourById(e)}previewTour(e){this.Kv?this.Kv.previewTour(e):this.No(()=>{var t;this.Xv(),(t=this.Kv)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Kv)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.Kv)==null||e.nextStep()}previousStep(){var e;(e=this.Kv)==null||e.previousStep()}clearCache(){var e;this.Yv=null,(e=this.xa)==null||e.unregister(`ph_product_tours`)}resetTour(e){var t;(t=this.Kv)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Kv)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Kv)==null||t.cancelPendingTour(e)}}},wu),ku={siteApps:class{constructor(e){this._instance=e,this.tf=0,this.ef=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}if(e,t){if(!t)return;let n=this.globalsForEvent(t);this.ef.push(n),this.ef.length>1e3&&(this.ef=this.ef.slice(10))}get siteAppLoaders(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){let e=this._instance._addCaptureHook(this.if.bind(this));this.nf=()=>{e(),this.ef=[],this.nf=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);let t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(let[e,i]of Object.entries(r))t[e]={id:n[e],type:e,properties:i};let{$set_once:i,$set:a}=e;return{event:R(R({},Rn(e,Ll)),{},{properties:R(R(R({},e.properties),a?{$set:R(R({},e.properties?.$set??{}),a)}:{}),i?{$set_once:R(R({},e.properties?.$set_once??{}),i)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}sf(e){let t=e.tagName?.toLowerCase();return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Rl.error(`prepare_external_dependency_stylesheet returned null`),null):t===`script`&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Rl.error(`prepare_external_dependency_script returned null`),null):e}rf(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let t=r?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this.tf++,this.lf)return this.af();let i=[],a=this,o=new WeakSet,s=(e,t,n)=>{if(!e?.[t])return;let r=e[t];e[t]=n(r),i.push(()=>{e[t]=r})},c=e=>{if(o.has(e))return e;let t=a.sf(e);return t&&o.add(t),t},l=e=>e.map(e=>typeof e==`string`?e:c(e)).filter(e=>!M(e));return s(n,`appendChild`,e=>function(t){let n=c(t);return n?e.call(this,n):t}),s(n,`insertBefore`,e=>function(t,n){let r=c(t);return r?e.call(this,r,n):t}),s(n,`replaceChild`,e=>function(t,n){let r=c(t);return r?e.call(this,r,n):n}),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach(e=>{s(e,`append`,e=>function(...t){return e.apply(this,l(t))}),s(e,`prepend`,e=>function(...t){return e.apply(this,l(t))})}),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach(e=>{s(e,`before`,e=>function(...t){return e.apply(this,l(t))}),s(e,`after`,e=>function(...t){return e.apply(this,l(t))}),s(e,`replaceWith`,e=>function(...t){let n=l(t);return t.length&&!n.length?void 0:e.apply(this,n)})}),s(t.Element?.prototype,`insertAdjacentElement`,e=>function(t,n){let r=c(n);return r?e.call(this,t,r):null}),this.lf=()=>{i.forEach(e=>e()),this.lf=void 0},this.af()}af(){let e=!1;return()=>{var t;e||(e=!0,this.tf--,this.tf===0&&((t=this.lf)==null||t.call(this)))}}uf(e,t=!0){let n=this.rf();try{let r=e(n);return t&&n(),r}catch(e){throw n(),e}}setupSiteApp(e){let t=this.apps[e.id],n=()=>{var n;!t.errored&&this.ef.length&&(Rl.info(`Processing ${this.ef.length} events for site app with id ${e.id}`),this.ef.forEach(e=>this.uf(()=>t.processEvent?.call(t,e))),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&((n=this.nf)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Rl.info(`Site app with id ${e.id} ${i?`loaded`:`errored`}`),r&&n()};try{let{processEvent:n}=this.uf(t=>e.init({posthog:this._instance,callback(e){t(),i(e)}}),!1);n&&(t.processEvent=n),r=!0}catch(t){Rl.error(zl+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Rl.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}hf(){let e=this.siteAppLoaders||[];for(let t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(let t of e)this.setupSiteApp(t)}cf(e){if(Object.keys(this.apps).length===0)return;let t=this.globalsForEvent(e);for(let n of Object.values(this.apps))try{this.uf(()=>n.processEvent?.call(n,t))}catch(t){Rl.error(`Error while processing event ${e.event} for site app ${n.id}`,t)}}onRemoteConfig(e){var t;if(this.siteAppLoaders?.length)return this.isEnabled?(this.hf(),void this._instance.on(`eventCaptured`,e=>this.cf(e))):void Rl.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((t=this.nf)==null||t.call(this),!e.ok)return;let n=e.config;if(n.siteApps?.length)if(this.isEnabled)for(let{id:e,url:t}of n.siteApps){var r,i;f[`__$$ph_site_app_${e}`]=this._instance,(r=f.__PosthogExtensions__)==null||(i=r.loadSiteApp)==null||i.call(r,this._instance,t,t=>{if(t)return Rl.error(zl+e,t)})}else Rl.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},Au={tracingHeaders:class{constructor(e){this._instance=e,this.df=void 0,this.vf=void 0,this.ff=void 0,this.Iv=()=>{let e=this.pf();var t,n;e?(k(this.df)&&(this.df=(t=f.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),k(this.vf)&&(this.vf=(n=f.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Fv()}}initialize(){this.startIfEnabledOrStop()}No(e){var t,n;f.__PosthogExtensions__?.tracingHeadersPatchFns?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`tracing-headers`,t=>{if(t)return wl.error(`failed to load script`,t);e()})}gf(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}pf(){let e=this.gf();return T(e)?(T(this.ff)?this.ff.splice(0,this.ff.length,...e):this.ff=[...e],e.length>0?this.ff:void 0):(T(this.ff)&&this.ff.splice(0),this.ff=e||void 0,this.ff)}Fv(){var e,t;(e=this.df)==null||e.call(this),(t=this.vf)==null||t.call(this),this.df=void 0,this.vf=void 0}startIfEnabledOrStop(){this.pf()?this.No(this.Iv):this.Fv()}}},ju=R({surveys:class extends Ul{constructor(e){var t;super(new Yl(e),(t=e,{get projectToken(){return t.config.token},kv:new Jl(t)})),this._instance=e}Mh(e,t){let n=t.query?nc(e,t.query):e;return new Promise(e=>{this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor(t.target??`api`,n),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:e})})}}},wu),Mu={toolbar:class{constructor(e){this.instance=e}mf(e){f.ph_toolbar_state=e}yf(){return f.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,n=void 0,i=void 0){if(ia(this.instance.config)||!e||!r)return!1;t??=e.location,i??=e.history;try{if(!n){try{e.localStorage.setItem(`test`,`test`),e.localStorage.removeItem(`test`)}catch{return!1}n=e?.localStorage}let r=Xl||No(t.hash,`__posthog`)||No(t.hash,`state`),a,o=r?Qi(()=>JSON.parse(atob(decodeURIComponent(r))))||Qi(()=>JSON.parse(decodeURIComponent(r))):null;return o&&o.action===`ph_authorize`?(a=o,a.source=`url`,a&&Object.keys(a).length>0&&(o.desiredHash?t.hash=o.desiredHash:i?i.replaceState(i.state,``,t.pathname+t.search):t.hash=``)):(a=JSON.parse(n.getItem(Zl)||`{}`),a.source=`localstorage`,delete a.userIntent),!(!a.token||this.instance.config.token!==a.token||(this.loadToolbar(a),0))}catch{return!1}}bf(e){let t=f.ph_load_toolbar||f.ph_load_editor;!N(t)&&E(t)?t(e,this.instance):Ql.warn(`No toolbar load function found`)}loadToolbar(t){let n=!!r?.getElementById(`__POSTHOG_TOOLBAR__`);if(!e||n)return!1;let i=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,a=R(R({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor(`ui`)},i?{instrument:!1}:{});if(e.localStorage.setItem(Zl,JSON.stringify(R(R({},a),{},{source:void 0}))),this.yf()===2)this.bf(a);else if(this.yf()===0){var o,s;this.mf(1),(o=f.__PosthogExtensions__)==null||(s=o.loadExternalDependency)==null||s.call(o,this.instance,`toolbar`,e=>{if(e)return Ql.error(`[Toolbar] Failed to load`,e),void this.mf(0);this.mf(2),this.bf(a)}),G(e,`turbolinks:load`,()=>{this.mf(0),this.loadToolbar(a)})}return!0}_f(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,n=void 0){return this.maybeLoadToolbar(e,t,n)}}},Nu=R({experiments:class t{get Mr(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(e=!1)=>{this.getWebExperiments(e=>{t.wf(`retrieved web experiments from the server`),this.kf=new Map,e.forEach(e=>{if(e.feature_flag_key){var n;this.kf&&(t.wf(`setting flag key `,e.feature_flag_key,` to web experiment `,e),(n=this.kf)==null||n.set(e.feature_flag_key,e));let r=this._instance.getFeatureFlag(e.feature_flag_key);A(r)&&e.variants[r]&&this.Sf(e.name,r,e.variants[r].transforms)}else if(e.variants)for(let n in e.variants){let r=e.variants[n];t.xf(r,this._instance)&&this.Sf(e.name,n,r.transforms)}})},e)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.wf(pu);else if(!this.Mr.disable_web_experiments){if(N(this.kf))return this.kf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.wf(`applying feature flags`,e),e.forEach(e=>{if(this.kf&&this.kf?.has(e)){let t=this._instance.getFeatureFlag(e),n=this.kf?.get(e);t&&n!=null&&n.variants[t]&&this.Sf(n.name,t,n.variants[t].transforms)}})}}previewWebExperiment(){let e=t.getWindowLocation();if(e?.search){let n=jo(e?.search,`__experiment_id`),r=jo(e?.search,`__experiment_variant`);n&&r&&(t.wf(`previewing web experiments ${n} && ${r}`),this.getWebExperiments(e=>{this.Cf(parseInt(n),r,e)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Mr.disable_web_experiments&&!n)return e([]);let r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=${this.Mr.token}`),method:`GET`,timestampMode:`query`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Cf(e,n,r){let i=r.filter(t=>t.id===e);i&&i.length>0&&(t.wf(`Previewing web experiment [${i[0].name}] with variant [${n}]`),this.Sf(i[0].name,n,i[0].variants[n].transforms))}static xf(e,n){return!N(e.conditions)&&t.$f(e,n)&&t.Tf(e)}static $f(e,n){if(N(e.conditions)||N(e.conditions?.url))return!0;let r=t.getWindowLocation();if(r){let t=ja(n,r.href);return!e.conditions?.url||mu[e.conditions?.urlMatchType??`icontains`](e.conditions.url,t)}return!1}static getWindowLocation(){return e?.location}static Tf(e){if(N(e.conditions)||N(e.conditions?.utm))return!0;let t=Bo();if(t.utm_source){var n,r,i,a,o,s,c,l;let u=!(!((n=e.conditions)==null||(n=n.utm)==null)&&n.utm_campaign)||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=!(!((i=e.conditions)==null||(i=i.utm)==null)&&i.utm_source)||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=!(!((o=e.conditions)==null||(o=o.utm)==null)&&o.utm_medium)||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=!(!((c=e.conditions)==null||(c=c.utm)==null)&&c.utm_term)||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static wf(e,...t){z.info(`[WebExperiments] ${e}`,t)}Sf(e,n,r){this._is_bot()?t.wf(pu):n===`control`?t.wf(`Control variants leave the page unmodified.`):r.forEach(r=>{r.selector&&(t.wf(`applying transform of variant ${n} for experiment ${e} `,r),(document?.querySelectorAll(r.selector))?.forEach(e=>{let t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)}))})}_is_bot(){return n&&this._instance?wc(n,this.Mr.custom_blocked_useragents):void 0}}},wu),Pu={conversations:class{constructor(e){this._instance=e,this.If=void 0,this._conversationsManager=null,this.Mf=!1,this.ne=null,this.Ef=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Pf=e.ok,!e.ok))return;let t=e.config.conversations;N(t)||(F(t)?this.If=t:(this.If=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.If=void 0,this.ne=null,this.Pf=void 0,this.Ef=!1}loadIfEnabled(){if(this._conversationsManager||this.Mf||this._instance.config.disable_conversations||ia(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let e=f?.__PosthogExtensions__;if(e&&!k(this.If)&&this.If)if(this.ne&&this.ne.token){this.Mf=!0;try{let t=e.initConversations;if(t)return this.Rf(t),void(this.Mf=!1);let n=e.loadExternalDependency;if(!n)return void this.Af(Bi);n(this._instance,`conversations`,t=>{t||!e.initConversations?this.Af(`Could not load conversations script`,t):this.Rf(e.initConversations),this.Mf=!1})}catch(e){this.Af(`Error initializing conversations`,e),this.Mf=!1}}else hu.error(`Conversations enabled but missing token in remote config.`)}Rf(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.Ef=!1,hu.info(`Conversations loaded successfully`)}catch(e){this.Af(`Error completing conversations initialization`,e)}else hu.error(`Cannot complete initialization: remote config is null`)}Af(e,t){hu.error(e,t),this._conversationsManager=null,this.Mf=!1,this.Ef=!0}show(){this._conversationsManager?this._conversationsManager.show():hu.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.If&&!M(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?`disabled_by_config`:ia(this._instance.config)?`disabled_for_toolbar`:this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?`consent_opted_out`:!1===this.Pf?`remote_config_failed`:k(this.If)?this.Pf?`disabled_in_project`:`remote_config_pending`:this.If?N(this.ne)||!this.ne.token?`missing_token`:f?.__PosthogExtensions__?this.Mf?`initializing`:this.Ef?`load_failed`:`not_loaded`:`extensions_unavailable`:`disabled_in_project`}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return L(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(hu.warn(gu),null)})()}getMessages(e,t){var n=this;return L(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(hu.warn(gu),null)})()}markAsRead(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(hu.warn(gu),null)})()}getTickets(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(hu.warn(gu),null)})()}requestRestoreLink(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(hu.warn(gu),null)})()}restoreFromToken(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(hu.warn(gu),null)})()}restoreFromUrlToken(){var e=this;return L(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(hu.warn(gu),null)})()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}dh(){var e;(e=this._conversationsManager)==null||e.setIdentity()}fh(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},Fu={logs:class{constructor(t){var n;this._instance=t,this.name=`logs`,this.Ff=!1,this.Of=!1,this.Df=!1,this.$=B(`[logs]`),this.Lf=R(R({},this.$),{},{error:(...e)=>{e.some(Cu)||this.$.error(...e)}}),this.ia=[],this.Nf=[],this.Xc=0,this.So=!1,this.qf=[],this.jf=[],this.Bf=!1,this.Hf=!1,this.zf=()=>{var e,t;this.So||(this.Xc=0,(e=this.Uf)==null||e.onReconnect(),(t=this.Wf)==null||t.onReconnect())},this._instance&&(n=this._instance.config.logs)!=null&&n.captureConsoleLogs&&(this.Ff=!0),e&&G(e,`online`,this.zf)}Vf(e,t,n,r){var i;let a=_u((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new rr(this.Gf(e,t),a,this.Lf,()=>this.Zf(),e=>e(),void 0,r),a]}Qf(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this.Uf&&this.Jf===t||((n=this.Uf)==null||n.reset(),this.Jf=t,[this.Uf,this.Kf]=this.Vf(()=>this.ia,e=>{this.ia=e})),this.Uf}Yf(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this.Wf&&this.Xf===t||((n=this.Wf)==null||n.reset(),this.Xf=t,[this.Wf,this.tp]=this.Vf(()=>this.Nf,e=>{this.Nf=e},{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},bu)),this.Wf}setup(e){var t;if(this.So)return;this.po=e,!((t=this._instance)==null||(t=t.config)==null||(t=t.logs)==null)&&t.captureConsoleLogs&&(this.Ff=!0),(this.Ff||this.ep()&&this.np())&&this.sp();let n=!1,r=e.onRemoteConfig(e=>{n=e.ok&&!0===e.config.logs?.captureConsoleLogs,this.onRemoteConfig(e)});this.So?r.dispose():(this.$o=r,n||this.loadIfEnabled())}dispose(){var t,n,r,i;this.So||(this.So=!0,this.rp(),(t=this.$o)==null||t.dispose(),this.$o=void 0,this.po=void 0,this.Df=!1,e?.removeEventListener(`online`,this.zf),(n=this.op)==null||n.call(this),this.op=void 0,(r=this.Uf)==null||r.reset(),(i=this.Wf)==null||i.reset())}onRemoteConfig(e){var t;if(this.So)return;let n=e.ok?e.config.logs?.captureConsoleLogs:void 0;N(n)?this.lp():((t=this._instance)==null||(t=t.persistence)==null||t.register({$logs_capture_enabled_server_side:!!n}),n?(this.Ff=!0,this.Of||this.sp(),this.loadIfEnabled()):this.lp())}reset(){var e,t,n,r;this.rp(),(e=this.Uf)==null||e.clearQueue(),this.ia=[],(t=this.Uf)==null||t.reset(),(n=this.Wf)==null||n.clearQueue(),this.Nf=[],(r=this.Wf)==null||r.reset(),this.Xc=0}captureLog(e){this.So||this.Qf().captureLog(e)}captureConsoleLog(e){this.So||this.Yf().captureLog(e)}captureBufferedConsoleLog(e,t,n){this.So||this.Yf().captureLog(e,{context:t,occurredAtMs:n})}np(){var e;return!!(!((e=this._instance)==null||(e=e.persistence)==null||(e=e.props)==null)&&e[jr])}ep(){var e,t,n;return!(!((e=this._instance)==null||(t=e.Yl)==null)&&t.call(e))||!!(!((n=f._POSTHOG_REMOTE_CONFIG)==null||(n=n[this._instance.config.token])==null)&&n.config)}gh(){var e;this.rp(),(e=this.Wf)==null||e.clearQueue(),this.Nf=[]}lp(){this.Ff||this.rp()}sp(){var e;if(this.Bf||!f?.console)return;let t=_u((e=this._instance)==null||(e=e.config)==null?void 0:e.logs).maxBufferSize;for(let e of vu){let n;try{n=yu(f.console[e])}catch{continue}n&&this.jf.push(Cl(f.console,e,r=>{let i=(...n)=>{try{this.ap(e,n,t)}catch{}return r.apply(f.console,n)};return i.__rrweb_original__=n,i}))}this.Bf=!0,this.up=setTimeout(()=>{this.rp()},3e4)}ap(e,t,n){if(this.Bf&&!this.Hf&&t.length!==0)if(this._instance?.is_capturing()){if(n>this.qf.length){this.Hf=!0;try{this.qf.push({level:e,args:t,occurredAtMs:Date.now(),context:this.Zf()})}finally{this.Hf=!1}}}else this.rp()}rp(){if(this.qf=[],this.Bf){this.Bf=!1,this.up&&=(clearTimeout(this.up),void 0);for(let e of this.jf)e();this.jf=[]}}hp(){let e=this.qf;return this.rp(),e}get logger(){return this.cp||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.cp}flushLogs(e){e?this.dp(e):(this.Uf&&this.Uf.flush().catch(e=>this.vp(e)),this.Wf&&this.Wf.flush().catch(e=>this.vp(e)))}vp(e){Cu(e)||this.$.error(`PostHog logs flush failed:`,e)}loadIfEnabled(){if(this.So||!this.Ff||this.Of||this.Df)return;let e=f?.__PosthogExtensions__;if(!e)return this.$.error(`PostHog Extensions not found.`),void this.rp();let t=e.loadExternalDependency;if(!t)return this.$.error(Bi),void this.rp();this.Df=!0;try{t(this._instance,`logs`,t=>{if(this.Df=!1,this.So||!this.Ff)return;let n=e.logs;if(t||!n?.initializeLogs)this.$.error(`Could not load logs script`,t),this.rp();else{let e=this.hp();var r;this.op=n.initializeLogs(this.po??this._instance),this.Of=!0,e.length>0&&((r=n.replayConsoleBuffer)==null||r.call(n,this.po??this._instance,e))}})}catch(e){throw this.Df=!1,e}}Gf(e,t){let n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:t=>t===h.LogsQueue?e():void 0,setPersistedProperty(e,n){e===h.LogsQueue&&t(n??[])},js:e=>this.js(e),getLibraryId:()=>V.LIB_NAME,getLibraryVersion:()=>V.LIB_VERSION}}js(e){return new Promise(t=>{if(Po(this.Xc,3))return void t({kind:`fatal`,error:Su(void 0,`logs endpoint is unreachable, dropping batch`)});let n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout(()=>{this.$.warn(`Logs request timed out before receiving a response`),r({kind:`retry-later`,error:Su(void 0,`logs request timed out`)})},9e4);this._instance._send_request({method:`POST`,url:this.fp(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{let t=e.statusCode;this.pp(t),t>=200&&300>t?r({kind:`ok`}):t===413?r({kind:`too-large`}):t!==0&&t!==408&&t!==429&&500>t?r({kind:`fatal`,error:Error(`logs request failed with status ${t}`)}):t===0?(e.error||this.$.warn(`Logs request failed before receiving an HTTP response`),r({kind:`retry-later`,error:Su(e.error,`logs request failed before receiving an HTTP response`)})):r({kind:`retry-later`,error:e.error??Error(`logs request failed with status ${t}`)})}})})}pp(e){(e!==0||this._instance.__loaded)&&(this.Xc=Fo(e,this.Xc,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.`)))}dp(e){this.ia.length>0&&this.gp(e,this.ia,this.Kf,V.LIB_NAME,e=>{this.ia=e}),this.Nf.length>0&&this.gp(e,this.Nf,this.tp,bu,e=>{this.Nf=e})}gp(e,t,n,r,i){if(t.length===0)return;let a=t.map(e=>e.record);i([]);let o=$n(a,Qn(n,V.LIB_NAME,V.LIB_VERSION),r,V.LIB_VERSION);this._instance._send_request({method:`POST`,url:this.fp(),data:o,compression:`best-available`,batchKey:`logs`,transport:e})}fp(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}Zf(){var e;let t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){let{sessionId:e,windowId:n,sessionStartTimestamp:r,lastActivityTimestamp:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=e,t.windowId=n,N(r)||(t.sessionStartTimestamp=r),N(i)||(t.lastActivityTimestamp=i)}if(!(f==null||(e=f.location)==null)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Et(f.location.href):f.location.href),this._instance.featureFlags){let e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},Iu={metrics:class{constructor(e){this._instance=e,this.$=B(`[metrics]`)}initialize(){}Qf(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;var n;return this.Uf&&this.Jf===t||((n=this.Uf)==null||n.reset(),this.Jf=t,this.Uf=new sr(this.Gf(),function(e){let t=e?.resourceAttributes;return{serviceName:t?.[`service.name`]??e?.serviceName,serviceVersion:t?.[`service.version`]??e?.serviceVersion,environment:t?.[`deployment.environment`]??e?.environment,resourceAttributes:t,beforeSend:e?.beforeSend,flushIntervalMs:e?.flushIntervalMs??1e4,maxSeriesPerFlush:e?.maxSeriesPerFlush??1e3}}(t),this.$)),this.Uf}count(e,t=1,n){this.Qf().count(e,t,n)}gauge(e,t,n){this.Qf().gauge(e,t,n)}histogram(e,t,n){this.Qf().histogram(e,t,n)}flush(e){if(!this.Uf)return Promise.resolve();if(e){let t=this.Uf.drainWindow();return t&&this.Xs(t,e),Promise.resolve()}return this.Uf.flush().catch(e=>this.$.error(`PostHog metrics flush failed:`,e))}reset(){var e;(e=this.Uf)==null||e.reset()}Gf(){let e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Xs:e=>t.Xs(e),getLibraryId:()=>V.LIB_NAME,getLibraryVersion:()=>V.LIB_VERSION}}Xs(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,clearTimeout(a),n(e))},a=setTimeout(()=>i({kind:`retry-later`,error:Error(`metrics request timed out`)}),9e4);this._instance._send_request(R(R({method:`POST`,url:this.mp(),data:e,compression:`best-available`,batchKey:`metrics`},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){let t=e.statusCode;i(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==408&&t!==429&&500>t?{kind:`fatal`,error:Error(`metrics request failed with status ${t}`)}:{kind:`retry-later`,error:e.error??Error(`metrics request failed with status ${t}`)})}}))})}mp(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}};dl.__defaultExtensionClasses=R({},R(R(R(R(R(R(R(R(R(R(R(R(R({},wu),Tu),Eu),Du),Ou),ku),ju),Au),Mu),Nu),Pu),Fu),Iu));var Lu=function(){V.SDK_DIST_CHANNEL=`npm`;let t=Jc[il]=new dl;return function(){function t(){t.done||(t.done=!0,al=!1,U(Jc,function(e){e._dom_loaded()}))}r?.addEventListener?r.readyState===`complete`?t():G(r,`DOMContentLoaded`,t,{capture:!1}):e&&z.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();export{Lu as default};
|