PageSourceSearch

https://docs.arcjet.com/_astro/PageFrame.astro_astro_type_script_index_0_lang.BYMaWrhX.js

js arcjet.com collected 2026-10-01 12:29:59 UTC 330,158 bytes, 2 lines download raw bytes

1var e={DEBUG:!1,LIB_VERSION:`1.433.5`,LIB_NAME:`web`,JS_SDK_VERSION:`0.8.3`},t=e,n=`$people_distinct_id`,r=`distinct_id`,i=`$device_id`,a=`$device_model`,o=`__alias`,s=`__cmpns`,c=`$fbc`,l=`$fbc_persistence`,u=`$fbp`,d=`$fbp_persistence`,f=`__timers`,p=`$autocapture_disabled_server_side`,m=`$heatmaps_enabled_server_side`,h=`$exception_capture_enabled_server_side`,g=`$error_tracking_suppression_rules`,_=`$error_tracking_capture_extension_exceptions`,v=`$web_vitals_enabled_server_side`,y=`$dead_clicks_enabled_server_side`,b=`$product_tours_enabled_server_side`,x=`$logs_capture_enabled_server_side`,ee=`$web_vitals_allowed_metrics`,S=`$session_recording_remote_config`,C=`$session_recording_enabled_server_side`,te=`$replay_sample_rate`,ne=`$replay_override_sampling`,re=`$replay_override_linked_flag`,ie=`$replay_override_url_trigger`,ae=`$replay_override_event_trigger`,w=`$sesid`,oe=`$session_is_sampled`,se=`$session_past_minimum_duration`,ce=`$session_recording_url_trigger_activated_session`,le=`$session_recording_event_trigger_activated_session`,ue=`$debug_first_full_snapshot_timestamp`,de=`$sess_rec_flush_size`,T=`$enabled_feature_flags`,fe=`$active_feature_flags`,pe=`$early_access_features`,me=`$feature_flag_details`,E=`$feature_flag_payloads`,he=`$feature_flag_request_id`,ge=`$minimal_flag_called_events`,_e=`$override_feature_flags`,ve=`$override_feature_flag_payloads`,ye=`$stored_person_properties`,be=`$stored_group_properties`,xe=`$groups`,Se=`$surveys`,Ce=`$surveys_loaded_at`,we=`$surveys_activated`,Te=`$surveys_activated_session`,Ee=`$surveys_activated_timestamps`,De=`ph_product_tours`,Oe=`$product_tours_activated`,ke=`$product_tours_activated_session`,Ae=`$conversations_widget_session_id`,je=`$conversations_ticket_id`,Me=`$conversations_widget_state`,Ne=`$conversations_user_traits`,Pe=`$flag_call_reported`,Fe=`$flag_call_reported_session_id`,Ie=`$feature_flag_errors`,Le=`$feature_flag_evaluated_at`,Re=`$user_state`,ze=`$client_session_props`,Be=`$capture_rate_limit`,Ve=`$initial_campaign_params`,He=`$initial_referrer_info`,Ue=`$initial_person_info`,We=`$epp`,Ge=`$posthog_cookieless`,Ke=`$cookieless_mode`,qe=`$sdk_debug_extensions_init_method`,Je=`$sdk_debug_extensions_init_time_ms`,Ye=`$sdk_debug_recording_script_not_loaded`,Xe=`$sdk_debug_replay_event_trigger_status`,Ze=`$sdk_debug_replay_linked_flag_trigger_status`,Qe=`$sdk_debug_replay_matched_recording_trigger_groups`,$e=`$sdk_debug_replay_pen
1ding_trigger_conditions`,et=`$sdk_debug_replay_remote_trigger_matching_config`,tt=`$sdk_debug_replay_trigger_groups_count`,nt=`$sdk_debug_replay_url_trigger_status`,rt=`$session_recording_start_reason`,it=`PostHog loadExternalDependency extension not found.`,at=`anonymous`,ot=`identified`,st=`identified_only`,ct=`visibilitychange`,lt=`beforeunload`,ut=`$pageview`,dt=`$pageleave`,ft=`$identify`,pt=`$groupidentify`,D=`u`>typeof window?window:void 0,mt=`u`>typeof globalThis?globalThis:D,ht=mt?.navigator,O=mt?.document,gt=mt?.location,_t=mt?.fetch,vt=mt?.XMLHttpRequest&&`withCredentials`in new mt.XMLHttpRequest?mt.XMLHttpRequest:void 0,yt=mt?.AbortController,bt=mt?.CompressionStream,xt=ht?.userAgent;function St(){return!(!D||!1===D.navigator.onLine)}var Ct=typeof globalThis<`u`?globalThis:D;Ct&&typeof self>`u`&&(Ct.self=Ct),Ct&&typeof File>`u`&&(Ct.File=function(){});var k=D??{},wt=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}({}),Tt=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),Et=[`$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`],Dt=[`token`];function A(e,t){return e.indexOf(t)!==-1}var Ot=function(e){return e.trim()},kt=function(e){return e.replace(/^\$/,``)};function At(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 jt=Object.prototype,Mt=jt.hasOwnProperty,Nt=jt.toString,j=Array.isArray||function(e){return Nt.call(e)===`[object Array]`},M=e=>typeof e==`function`,N=e=>e===Object(e)&&!j(e),Pt=e=>{if(N(e)){for(let t in e)if(Mt.call(e,t))return!1;return!0}return!1},P=e=>e===void 0,F=e=>Nt.call(e)==`[object String]`,Ft=e=>F(e)&&e.trim().length===0,I=e=>e===null,L=e=>P(e)||I(e),R=e=>Nt.call(e)==`[object Number]`&&e==e,It=e=>R(e)&&e>0,Lt=e=>Nt.call(e)===`[object Boolean]`,Rt=e=>A(Et,e),zt=e=>A(Dt,e);function Bt(e){return typeof e!=`object`||!e}function Vt(e,t){return{}.toString.call(e)===`[object ${t}]`}function Ht(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 Wt(e,Error)}}function Ut(e){return`u`>typeof Event&&Wt(e,Event)}function Wt(e,t){try{return e instanceof t}catch{return!1}}var Gt=[!0,`true`,1,`1`,`yes`],Kt=e=>A(Gt,e),qt=[!1,`false`,0,`0`,`no`];function Jt(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 z(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Jt(a,r,i,o,s,`next`,e)}function s(e){Jt(a,r,i,o,s,`throw`,e)}o(void 0)})}}var Yt=`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(`,`),Xt=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return Yt.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})};function Zt(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),R(e)?e>n?(r.warn(` cannot be  greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),Zt(i??n,t,n,r))}var Qt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Zt(e.bucketSize,0,100,e._logger),this._refillRate=Zt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Zt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){let n=Math.floor((t-e.lastAccess)/this._refillInterval);n>0&&(e.tokens=Math.min(e.tokens+n*this._refillRate,this._bucketSize),e.lastAccess+=n*this._refillInterval)}consumeRateLimit(e){var t;let n=Date.now(),r=String(e),i=this._buckets[r];return i?this._applyRefill(i,n):(i={tokens:this._bucketSize,lastAccess:n},this._buckets[r]=i),i.tokens===0||(i.tokens--,i.tokens===0&&((t=this._onBucketRateLimited)==null||t.call(this,e)),i.tokens===0)}stop(){this._buckets={}}},$t=`Mobile`,en=`Android`,tn=`Tablet`,nn=`Android Tablet`,rn=`iPad`,an=`Apple Watch`,on=`Safari`,sn=`BlackBerry`,cn=`Samsung Internet`,ln=`Chrome`,un=`Chrome iOS`,dn=`Internet Explorer`,fn=`Internet Explorer Mobile`,pn=`Opera`,mn=`Microsoft Edge`,hn=`Firefox`,gn=`Firefox iOS`,_n=`Nintendo`,vn=`PlayStation`,yn=`Xbox`,bn=`Android Mobile`,xn=`Mobile Safari`,Sn=`Windows`,Cn=`Windows Phone`,wn=`Nokia`,Tn=`Ouya`,En=`Generic `+$t.toLowerCase(),Dn=`Generic `+tn.toLowerCase(),On=`Konqueror`,kn=`Oculus Browser`,An=`Vivaldi`,jn=`Yandex`,Mn=`Whale`,Nn=`DuckDuckGo`,Pn=`Pale Moon`,Fn=`Waterfox`,In=`Brave`,Ln=`Claude`,Rn=`Codex`,zn=`ChatGPT`,Bn=`Google Search App`,Vn=RegExp(`Version/(\\d+(\\.\\d+)?)`),Hn=RegExp(`(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)`),Un=new RegExp(yn,`i`),Wn=RegExp(`PlayStation \\w+`,`i`),Gn=RegExp(`Nintendo \\w+`,`i`),Kn=RegExp(`BlackBerry|PlayBook|BB10`,`i`),qn={"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`},Jn=function(e,t,n,r){return t||=``,function(e){return e?.brave?In:null}(n)||(r?.detectGoogleSearchApp&&A(e,`GSA/`)?Bn:A(e,` OPR/`)&&A(e,`Mini`)?`Opera Mini`:A(e,` OPR/`)?pn:Kn.test(e)?sn:A(e,`IEMobile`)||A(e,`WPDesktop`)?fn:A(e,`OculusBrowser`)?kn:A(e,`SamsungBrowser`)?cn:A(e,`Edge`)||A(e,`Edg/`)?mn:A(e,`Vivaldi/`)?An:A(e,`YaBrowser/`)?jn:A(e,`Whale/`)?Mn:A(e,`DuckDuckGo/`)||A(e,`Ddg/`)?Nn:A(e,`Claude/`)?Ln:A(e,`Codex/`)?Rn:A(e,`ChatGPT/`)?zn:A(e,`FBIOS`)?`Facebook Mobile`:A(e,`UCWEB`)||A(e,`UCBrowser`)?`UC Browser`:A(e,`CriOS`)?un:A(e,`CrMo`)||A(e,ln)?ln:A(e,en)&&A(e,on)?bn:A(e,`FxiOS`)?gn:A(e.toLowerCase(),On.toLowerCase())?On:A(e,`Brave/`)?In:((e,t)=>t&&A(t,`Apple`)||function(e){return A(e,on)&&!A(e,ln)&&!A(e,en)}(e))(e,t)?A(e,$t)?xn:on:A(e,`PaleMoon/`)?Pn:A(e,`Waterfox/`)?Fn:A(e,hn)?hn:A(e,`MSIE`)||A(e,`Trident/`)?dn:A(e,`Gecko`)?hn:``)},Yn={[fn]:[RegExp(`rv:(\\d+(\\.\\d+)?)`)],[mn]:[RegExp(`Edge?\\/(\\d+(\\.\\d+)?)`)],[ln]:[RegExp(`(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)`)],[un]:[RegExp(`CriOS\\/(\\d+(\\.\\d+)?)`)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)`)],[on]:[Vn],[xn]:[Vn],[pn]:[RegExp(`(Opera|OPR)\\/(\\d+(\\.\\d+)?)`)],[hn]:[RegExp(`Firefox\\/(\\d+(\\.\\d+)?)`)],[gn]:[RegExp(`FxiOS\\/(\\d+(\\.\\d+)?)`)],[On]:[RegExp(`Konqueror[:/]?(\\d+(\\.\\d+)?)`,`i`)],[sn]:[RegExp(`BlackBerry (\\d+(\\.\\d+)?)`),Vn],[bn]:[RegExp(`android\\s(\\d+(\\.\\d+)?)`,`i`)],[cn]:[RegExp(`SamsungBrowser\\/(\\d+(\\.\\d+)?)`)],[kn]:[RegExp(`OculusBrowser\\/(\\d+(\\.\\d+)?)`)],[An]:[RegExp(`Vivaldi\\/(\\d+(\\.\\d+)?)`)],[jn]:[RegExp(`YaBrowser\\/(\\d+(\\.\\d+)?)`)],[Mn]:[RegExp(`Whale\\/(\\d+(\\.\\d+)?)`)],[In]:[RegExp(`Brave\\/(\\d+(\\.\\d+)?)`)],[Ln]:[Hn],[Rn]:[Hn],[zn]:[Hn],[Nn]:[RegExp(`(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)`)],[P
1n]:[RegExp(`PaleMoon\\/(\\d+(\\.\\d+)?)`)],[Fn]:[RegExp(`Waterfox\\/(\\d+(\\.\\d+)?)`)],[Bn]:[RegExp(`GSA\\/(\\d+(\\.\\d+)?)`)],[dn]:[RegExp(`(rv:|MSIE )(\\d+(\\.\\d+)?)`)],Mozilla:[RegExp(`rv:(\\d+(\\.\\d+)?)`)]},Xn=function(e,t,n,r){let i=Yn[Jn(e,t,n,r)];if(P(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},Zn=[[RegExp(`Xbox; Xbox (.*?)[);]`,`i`),e=>[yn,e&&e[1]||``]],[new RegExp(_n,`i`),[_n,``]],[new RegExp(vn,`i`),[vn,``]],[Kn,[sn,``]],[new RegExp(Sn,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Cn,``];if(new RegExp($t).test(t)&&!/IEMobile\b/.test(t))return[`Windows Mobile`,``];let n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let e=qn[n[1]]||``;return/arm/i.test(t)&&(e=`RT`),[Sn,e]}return[Sn,``]}],[/((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=P(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`),e=>e&&e[2]?[en,[e[2],e[3],e[4]||`0`].join(`.`)]:[en,``]],[/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`,``]]],Qn=function(e){for(let t=0;Zn.length>t;t++){let[n,r]=Zn[t],i=n.exec(e),a=i&&(M(r)?r(i,e):r);if(a)return a}return[``,``]},$n=function(e){return Gn.test(e)?_n:Wn.test(e)?vn:Un.test(e)?yn:new RegExp(Tn,`i`).test(e)?Tn:RegExp(`(Windows Phone|WPDesktop)`,`i`).test(e)?Cn:/iPad/.test(e)?rn:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?an:Kn.test(e)?sn:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(wn,`i`).test(e)?wn:/(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($t).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)?en:nn:RegExp(`(pda|Mobile)`,`i`).test(e)?En:new RegExp(tn,`i`).test(e)&&!RegExp(`Tablet pc`,`i`).test(e)?Dn:``},er=function(e,t){let n=$n(e);return n===rn||n===nn||n===`Kobo`||n===`Kindle Fire`||n===Dn?tn:n===_n||n===yn||n===vn||n===Tn?`Console`:n===an?`Wearable`:n?$t:t?.userAgentDataPlatform===`Android`&&(t?.maxTouchPoints??0)>0?600>Math.min((r=t?.screenWidth)??0,(i=t?.screenHeight)??0)/((a=t?.devicePixelRatio)??1)?$t:tn:`Desktop`;var r,i,a},tr=/\bFBAV\/(\d+(?:\.\d+)*)/i,nr=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,`Instagram`],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,`Threads`],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,`Messenger`,tr],[/\bFBAN\/EMA\b/i,`Facebook Lite`,tr],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,`Facebook`,tr],[/\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`]],rr=`[Truncated]`,ir=`[Unserializable]`;function ar(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 or(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=ir}Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return e}var sr=3e5,cr=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,sr);if(!t)return this._installedAt=n,void(this._until=n+r);this._until=Math.max(this._until,Math.min(n+r,this._installedAt+sr))}remainingMs(){let e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;let t=Math.min(sr,Math.max(0,this._until-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}},lr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ur(e,t){return typeof(n=e)==`string`&&lr.test(n)?e:t();var n}function dr(e,t){let n=Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function fr(e){return e&&e.split(`#`)[0]}function pr(e){try{return e()}catch{return}}function mr(e,t){let n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}function hr(e,t,n){return gr.apply(this,arguments)}
1function gr(){return(gr=z(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((e,i)=>{r=mr(()=>{try{n?.(),e()}catch(e){i(e)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}var _r,vr,yr;function br(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return yr&&n.length===vr||(vr=n.length,yr=n.reduce((n,r)=>{_r||={};let i=_r[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,_r[r]=[a,o];break}}}return n},{})),yr}function xr(e){return xr=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},xr(e)}function Sr(e,t,n){return(t=function(e){var t=function(e){if(xr(e)!=`object`||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,`string`);if(xr(n)!=`object`)return n;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}(e);return xr(t)==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cr(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 B(e){for(var t=1;arguments.length>t;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Cr(Object(n),!0).forEach(function(t){Sr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var wr=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 z(function*(){for(let n of e)n.stacktrace&&n.stacktrace.frames&&j(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;if(e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null)try{r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return B(B({},e),{},{cause:n,stack:r,errors:e.errors?.map(e=>this.parseStacktrace(e,t))})}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 z(function*(){let n=e;for(let e of t.modifiers)n=yield e(n);return n})()}convertToExceptionList(e,t){let n=[],r=(e,i,a)=>{let o=n.length,s=i===void 0?B(B({type:typeof t.type==`string`&&t.type.length>0?t.type:`generic`},typeof t.handled==`boolean`?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic==`boolean`?t.synthetic:e.synthetic,exception_id:o}):{type:`chained`,source:a,synthetic:e.synthetic,exception_id:o,parent_id:i},c={type:e.type,value:e.value,mechanism:s};e.stack&&(c.stacktrace={type:`raw`,frames:e.stack}),n.push(c),e.cause&&r(e.cause,o,`cause`);for(let t of e.errors??[])r(t,o,`member`)};return r(e),n}buildParsingContext(e){return{chunkIdMap:br(this.stackParser),skipFirstLines:e.skipFirstLines??1}}getAggregateErrors(e){try{if(Ht(e)){let t=Object.getPrototypeOf(e);for(let n=0;t&&100>n;n++){let n=Object.getOwnPropertyDescriptor(t,`constructor`)?.value;if(typeof n==`function`&&n.name===`AggregateError`){let t=e.errors;return j(t)?t:void 0}t=Object.getPrototypeOf(t)}}}catch{}}buildCoercingContext(e,t,n=0){let r=0,i=0,a=!1,o=new Set,s=[],c={},l=(e,t,n=0)=>{let l=u(t,n),d=l.apply;if(l.apply=t=>{s.push(e);try{return d(t)}finally{s.pop()}},n>4||n>0&&s.indexOf(e)!==-1)return this.coerceFallback(l);let f=typeof e==`object`&&!!e||typeof e==`function`;if(n===0&&r>=50||f&&o.has(e))return;f&&o.add(e),n===0&&r++;let p=this.getAggregateErrors(e),m,h;a||=!!p;try{if(m=this.applyCoercers(e,l),!m)throw c}catch(e){if(e===c)return void(n===0&&r--);if(!a)throw e;m=this.coerceFallback(l)}if(!p||r>=50)return m;try{h=p.length}catch{return m}if(!Number.isInteger(h)||0>h||h>4294967295)return m;let g=[];for(let e=0;50>r&&1e3>i&&h>e;e++){let n;i++;try{n=l.next(p[e])}catch{r++,n=this.coerceFallback(u(t+1))}n&&g.push(n)}return B(B({},m),{},{errors:g})},u=(n,r=0)=>B(B({},t),{},{syntheticException:n==0?t.syntheticException:void 0,mechanism:n==0?e:{},apply(e){let t=l(e,n,r+1);if(!t)throw c;return t},next:e=>l(e,n+1)}),d=u(n);return B(B({},d),{},{apply:e=>l(e,n)??this.coerceFallback(d)})}},Tr=/^([a-z][a-z0-9.+-]+):/i,Er=[`http`,`https`,`file`,`blob`,`app`,`capacitor`,`ionic`,`webpack`,`webpack-internal`,`ng`];function Dr(e){if(!e||e===`<anonymous>`)return!1;let t=Tr.exec(e);return!t||Er.includes(t[1].toLowerCase())}function Or(e,t,n,r,i){let a={platform:e,filename:t,function:n===`<anonymous>`?`?`:n,in_app:Dr(t)}
1;return P(r)||(a.lineno=r),P(i)||(a.colno=i),a}var kr=(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]},Ar=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,jr=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Mr=/\((\S*)(?::(\d+))(?::(\d+))\)/,Nr=(e,t)=>{let n=Ar.exec(e);if(n){let[,e,r,i]=n;return Or(t,e,`?`,+r,+i)}let r=jr.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){let e=Mr.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}let[e,n]=kr(r[1]||`?`,r[2]);return Or(t,n,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Pr=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Fr=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ir=(e,t)=>{let n=Pr.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){let e=Fr.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]=kr(r,e),Or(t,e,r,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Lr=/\(error: (.*)\)/;function Rr(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function zr(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(!Rr(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 Br(e,t){let n=t.start+t.length,r=Hr(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function Vr(e,t){let n=t.start;for(;n>0&&Rr(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function Hr(e,t){let n=t.start+t.length,r=n;for(;e.length>r&&Rr(e[r],e[r-t.length]);)r++;return r-n}function Ur(e,t){let n=t[0],r=e.length-(n?Vr(e,n):0);for(let n of t)r-=Hr(e,n);return r}function Wr(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 Gr=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){let n=F(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){let t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Vt(e,`DOMException`)}isDOMError(e){return Vt(e,`DOMError`)}},Kr=class{match(e){return Ht(e)}coerce(e,t){let n=this.getStack(e),r=n===void 0?t.syntheticException?.stack:void 0,i=!!r;return{type:this.getType(e),value:this.getMessage(e,t),stack:n??r,cause:e.cause?t.next(e.cause):void 0,synthetic:i}}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){try{let t=e.stacktrace;if(typeof t==`string`&&t.length>0)return t;let n=e.stack;return typeof n==`string`&&n.length>0?n:void 0}catch{return}}},qr=class{match(e){return!!Vt(e,`ErrorEvent`)&&(e.error!=null||this._hasUsableMessage(e))}coerce(e,t){if(e.error!=null)return t.apply(e.error);let n=t.apply(e.message);return B(B({},n),{},{stack:this._buildLocationStack(e)??n.stack,synthetic:!0})}_hasUsableMessage(e){return F(e.message)&&e.message.length>0}_buildLocationStack(e){let t=e,n=t.lineno??0,r=t.colno??0;if(F(t.filename)&&t.filename.length!==0&&n!==0)return`Error\n    at ${t.filename}:${n}:${r}`}},Jr=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Yr=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(Jr);return r&&(t=r[1],n=r[2]),[t,n]}},Xr=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Zr(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 Qr=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(Ut(e))return e.constructor.name;let t=`name`in e?e.name:void 0;return F(t)&&!Ft(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: ${Zr(e)}`}isSeverityLevel(e){return F(e)&&!Ft(e)&&Xr.indexOf(e)>=0}getStack(e){try{return F(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:F(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(let t in e)if({}.hasOwnProperty.call(e,t)){let n=e[t];if(Ht(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},$r=class{match(e){return Ut(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Zr(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},ei=class{match(e){return Bt(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},ti=class{match(e){return Vt(e,`PromiseRejectionEvent`)||this.isCu
1stomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ut(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 Bt(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}},ni=`$message`,ri=`$timestamp`,ii=new Set([ni,ri]),ai={enabled:!0,max_bytes:32768};function oi(e){return e?{enabled:e.enabled??ai.enabled,max_bytes:ci(e.max_bytes,ai.max_bytes)}:B({},ai)}var si=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=oi(e)}setConfig(e){this._config=oi(e),this._trimToMaxBytes()}add(e){let t=function(e){let t;try{t=At(e)}catch{return}try{let e=JSON.parse(t);if(!N(e))return;let n=e,r=n[ni],i=n[ri];return!F(r)||r.trim().length===0||!F(i)&&!R(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._config.max_bytes||(this._entries.push({step:t.step,bytes:n}),this._totalBytes+=n,this._trimToMaxBytes())}getAttachable(){return this._entries.map(e=>e.step)}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){let e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function ci(e,t){if(!R(e)||1/0===e||-1/0===e)return t;let n=Math.floor(e);return 0>n?t:n}var li=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function ui(e){return typeof e==`string`||e}function di(e){return typeof e==`string`?e:void 0}var fi=`$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(`.`),pi=`NativeGzipValidationError`,mi=e=>e.length>=2&&e[0]===31&&e[1]===139,hi=(e,t)=>e===Tt.GZipJS||t===Tt.GZipJS||t===`gzip`,gi=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,_i,vi=e=>{throw dr(pi,`Native gzip produced invalid output: ${e}`)},yi=(bi=z(function*(e,t){18>e.size&&vi(`too-short`);let n=new Uint8Array(yield e.slice(0,10).arrayBuffer());mi(n)&&n[2]===8||vi(`invalid-header`);let r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{let t=(()=>{if(_i)return _i;_i=[];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;_i[e]=t>>>0}return _i})(),n=4294967295;for(let r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&vi(`invalid-crc`);let i=t.length>>>0;r.getUint32(4,!0)!==i&&vi(`invalid-size`)}),function(e,t){return bi.apply(this,arguments)}),bi;function xi(){return xi=z(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=z(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 yi(s,t),s}catch(e){if(n?.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}var r}),xi.apply(this,arguments)}function Si(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 Ci={}.propertyIsEnumerable;function wi(e,t){try{return Di(e,t,{ancestors:new WeakSet,remainingNodes:1e4}
1,0)}catch{return[]}}function Ti(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:rr};if(n.remainingNodes--,Lt(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:ar(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:rr};if(e instanceof Date){let t=e.getTime(),n=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:typeof n==`string`?ar(n):String(n)}}n.ancestors.add(e);try{try{let i=e.toJSON;if(typeof i==`function`)return Ti(i.call(e),t,n,r+1)}catch{}return j(e)?{arrayValue:{values:Ei(e,t,n,r+1)}}:{kvlistValue:{values:Di(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:ar(String(e))}}function Ei(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(L(a))continue;i.push(Ti(a,t,n,r))}catch{i.push({stringValue:ir})}return e.length>o&&i.push({stringValue:rr}),i}function Di(e,t,n,r){let i=[];for(let a in e)if(Ci.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(I(o)||P(o))continue;i.push({key:ar(a),value:Ti(o,t,n,r)})}catch{i.push({key:ar(a),value:{stringValue:ir}})}}return i}function Oi(e,t,n){return B(B(B(B({},or({},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 ki=[`service.name`,`deployment.environment`,`service.version`,`telemetry.sdk.name`,`telemetry.sdk.version`];function Ai(e,t){let n=or({},e),r={};for(let e of ki)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e],delete n[e]);return[...wi(n,t),...wi(r,t)]}var ji={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`},Mi={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}},Ni=Mi.info;function Pi(e){try{return ar(String(e))}catch{return ir}}function Fi(e,t,n,r){let{text:i,number:a}=Mi[e.level||`info`]||Ni,o=function(e=Date.now()){return String(e)+`000000`}(R(r)?r:void 0),s={};t.distinctId&&(s.posthogDistinctId=t.distinctId),t.sessionId&&(s.sessionId=t.sessionId),t.windowId&&(s[`window.id`]=t.windowId),L(t.sessionStartTimestamp)||(s.sessionStartTimestamp=String(t.sessionStartTimestamp)),L(t.lastActivityTimestamp)||(s.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(s[`url.full`]=t.currentUrl),t.screenName&&(s[`screen.name`]=t.screenName),t.appState&&(s[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(s.feature_flags=t.activeFeatureFlags);let c=B({},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=ir}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}let u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:a,severityText:i,body:{stringValue:Pi(e.body)},attributes:wi(c,n)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),P(e.trace_flags)||(u.flags=e.trace_flags),u}function Ii(e,t,n){return Oi(e,t,n)}function Li(e,t,n,r){return{resourceLogs:[{resource:{attributes:Ai(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var Ri=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=mr(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&=(clearTimeout(this._timer),void 0)}};function zi(){return .75+.5*Math.random()}function Bi(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 Vi=class{constructor(e,t,n,r,i,a=()=>Promise.resolve(),o){this._instance=e,this._config=t,this._logger=n,this._getContext=r,this._onReady=i,this._waitForStoragePersist=a,this._scopeName=o,this._flushTimer=new Ri(()=>
1this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new cr,this._consecutiveFlushFailures=0,this._flushJitter=1,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(wt.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;let n=this._runBeforeSend(e);if(n===null)return;if(!n.body)return void this._logger.info(`Log was rejected in beforeSend function`);if(!this._checkRateLimit())return;let r={record:Fi(n,t?.context??this._getContext(),this._logger,t?.occurredAtMs)};this._onReady(()=>this._enqueue(r))}_runBeforeSend(e){let t=this._config.beforeSend;if(!t)return e;let n=j(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this._logger.info(`Log was rejected in beforeSend function`),null;r=t}catch(e){return this._logger.error(`Error in beforeSend function for log:`,e),null}return r}_checkRateLimit(){if(this._maxLogsPerInterval===void 0)return!0;let e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||=(this._logger.warn(`captureLog dropping logs: exceeded ${this._maxLogsPerInterval} logs per ${this._rateCapWindowMs}ms`),!0),!1)}flush(){var e=this;return z(function*(){if(!e._instance.isDisabled)return e._flushPromise||=e._flushInner().finally(()=>{e._flushPromise=null}),e._flushPromise})()}_flushInner(){var e=this;return z(function*(){e._flushTimer.clear();let t=e._instance.getPersistedProperty(wt.LogsQueue)??[];if(t.length===0)return;let n=t.length,r=0;for(;t.length>0&&n>r;){let n=e._queueGeneration;e._evictedSinceAdvance=0;let i=Math.min(t.length,e._maxBatchRecordsPerPost),a=t.slice(0,i),o=Li(a.map(e=>e.record),e._buildResourceAttributes(),e._scopeName??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance._sendLogsBatch(o);if(e._queueGeneration!==n)return;if(s.kind===`too-large`&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else if(e._retryAfter.record(s),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),s.kind===`retry-later`||(s.kind===`too-large`?e._logger.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._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),t=e._instance.getPersistedProperty(wt.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}})()}_persistQueueAdvance(e){var t=this;return z(function*(){let n=Math.max(0,e-t._evictedSinceAdvance),r=t._instance.getPersistedProperty(wt.LogsQueue)??[];t._instance.setPersistedProperty(wt.LogsQueue,r.slice(n)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return Ii(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){if(this._instance.optedOut)return;let t=this._instance.getPersistedProperty(wt.LogsQueue)??[];this._maxQueueSize>t.length||(t.shift(),this._evictedSinceAdvance++,this._logger.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(wt.LogsQueue,t),this._maxBufferSize>t.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackgroun
1d()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(Bi(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){let e=this._instance.getPersistedProperty(wt.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return z(function*(){t._flushTimer.clear();let n=t.flush().catch(()=>{});e===void 0?yield n:yield hr(n,e)})()}flushWithTimeout(e){var t=this;return z(function*(){let n=t.flush();yield hr(n,e,()=>{n.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=zi(),this._logger.error(`PostHog logs flush failed:`,e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}},Hi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ui(e){return String(e)+`000000`}function Wi(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 Gi=class{constructor(e,t,n){this._instance=e,this._config=t,this._logger=n,this._series=new Map,this._flushTimer=new Ri(()=>this.flush().catch(e=>{this._logger.error(`Metrics flush failed:`,e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._retryAfter=new cr,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,n){this._capture({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this._capture({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this._capture({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this;let t=this._flushPromise,n=function(){var n=z(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return n.apply(this,arguments)}}()().finally(()=>{this._flushPromise===n&&(this._flushPromise=null)});return this._flushPromise=n,n}drainWindow(){if(this._series.size===0)return null;let e=this._series;return this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._buildPayload(e)}reset(){this._generation++,this._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set}_capture(e){if(this._instance.isDisabled||this._instance.optedOut)return;let t=this._runBeforeSend(e);if(t===null)return;if(!t.name||typeof t.name!=`string`)return void this._logger.warn(`Dropping metric with empty name`);if(typeof t.value!=`number`||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type===`count`&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let n,r;try{n=t.attributes?B({},t.attributes):void 0,r=Wi(t.type,t.name,t.unit,n)}catch(e){this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e);return}let i=this._series.get(r);if(!i){if(!this._admitNewSeries())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this._series.set(r,i)}let a=this._typeByName.get(t.name);a===void 0?this._typeByName.set(t.name,t.type):a===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.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._fold(i,t.value),this._armFlushTimer()}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}_fold(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(Hi.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,Hi)]+=1;break}}}_runBeforeSend(e){let t=this._config.beforeSend;if(!t)return e;let n=j(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this._logger.info(`Metric was rejected in beforeSend function`),null;r=t}catch(e){return this._logger.error(`Error in beforeSend function for metric:`,e),null}return r}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(Bi(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return z(function*(){if(e._flushTimer.clear(),e._series.size===0)return;let t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;let n=e._generation,r=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(n===e._generation)switch(e._retryAfter.record(r),r.kind===`retry-later`?(e._consecutiveFlushFailures++,e._flushJitter=zi()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),r.kind){case`ok`:return;case`retry-later`:e._mergeWindowBack(t),e._flushTimer.armNoEarlierThan(e._nextFlushDelay());return;case`too-large`:e._logger.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e._logger.error(`Failed to send metrics batch:`,r.error);return}})()}_buildPayload(e){return t=this._buildMetrics(e),n=function(e,t,n){return Oi(e,t,n)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r
1=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ai(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}_buildMetrics(e){let t=Ui(Date.now()),n=new Map;for(let r of e.values()){let e=Wi(r.type,r.name,r.unit,void 0),i=n.get(e);i||(i=B({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=wi(r.attributes??{},this._logger),o=Ui(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:Hi})}return Array.from(n.values())}_mergeWindowBack(e){for(let[t,n]of e){let e=this._series.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._admitNewSeries()&&this._series.set(t,n)}}},Ki=(t,{debugEnabled:n}={})=>{let r={_log(r,...i){D&&(e.DEBUG||D.POSTHOG_DEBUG||n)&&!P(D.console)&&D.console&&(`__rrweb_original__`in D.console[r]?D.console[r].__rrweb_original__:D.console[r])(t,...i)},debug(...e){r._log(`debug`,...e)},info(...e){r._log(`log`,...e)},warn(...e){r._log(`warn`,...e)},error(...e){r._log(`error`,...e)},critical(...e){console.error(t,...e)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling ${e}`)},createLogger:(e,n)=>Ki(`${t} ${e}`,n)};return r},V=Ki(`[PostHog.js]`),H=V.createLogger;function qi(e,t){j(e)&&e.forEach(t)}function U(e,t){if(!L(e)){if(j(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,n)=>t(e,n));else for(let n in e)Mt.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 Ji(e){let t=Object.keys(e),n=t.length,r=Array(n);for(;n--;)r[n]=[t[n],e[t[n]]];return r}var Yi=function(e){return function(...t){try{return e.apply(this,t)}catch(e){V.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),V.critical(e)}}},Xi=function(e){let t={};return U(e,function(e,n){(F(e)&&e.length>0||R(e))&&(t[n]=e)}),t};function Zi(e){let t=B({},e);for(let n of[`name`,`message`,`stack`,`cause`,`errors`])try{n in e&&(t[n]=e[n])}catch{}return t}var Qi=[`herokuapp.com`,`vercel.app`,`netlify.app`];function $i(e){let t=e?.hostname;if(!F(t))return!1;let n=t.split(`.`).slice(-2).join(`.`);for(let e of Qi)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 ea(e){return e.name===`ph_toolbar_internal`}var ta=e=>{if(O){try{let t=e+`=`,n=O.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 R(e)&&isFinite(e)&&Math.floor(e)===e});var na=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+=`-`);
1if(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}},ra=class{generate(){let e=this.generateOrAbort();if(!P(e))return e;{this._timestamp=0;let e=this.generateOrAbort();if(P(e))throw Error(`Could not generate UUID after timestamp reset`);return e}}generateOrAbort(){let e=(()=>{let e=Date.now();return R(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return na.fromFieldsV7(this._timestamp,Math.trunc(this._counter/2**30),this._counter&2**30-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new aa}},ia=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};D&&!P(D.crypto)&&crypto.getRandomValues&&(ia=e=>crypto.getRandomValues(e));var aa=class{nextUint32(){return this._buffer.length>this._cursor||(ia(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}},oa,sa=()=>ca().toString(),ca=()=>(oa||=new ra).generate(),la=``,ua=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,da=null,K={_is_supported(){if(!I(da))return da;if(da=!1,O)try{let e=`__ph_cookie_support_${sa()}`;K._set(e,`xyz`),da=ta(e)===`"xyz"`,K._remove(e)}catch{da=!1}return da},_error(e){V.error(`cookieStore error: `+e)},_get:ta,_parse(e){let t;try{t=JSON.parse(K._get(e))||{}}catch{}return t},_set(e,t,n,r,i){if(!O)return!1;try{let a=``,o=``,s=function(e,t){if(t){let t=function(e,t=O){if(la)return la;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;let n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+sa();for(;!la&&r--;){let e=n.slice(r).join(`.`),a=i+`=1;domain=.`+e+`;path=/`;t.cookie=a+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=a+`;max-age=0`,la=e)}return la}(e);if(!t){let n=(e=>{let t=e.match(ua);return t?t[0]:``})(e);n!==t&&V.info(`Warning: cookie subdomain discovery mismatch`,n,t),t=n}return t?`; domain=.`+t:``}return``}(O.location.hostname,r);if(n){let e=new Date;e.setTime(e.getTime()+864e5*n),a=`; expires=`+e.toUTCString()}i&&(o=`; secure`);let c=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return c.length>3686.4&&V.warn(`cookieStore warning: large cookie, len=`+c.length),O.cookie=c,!0}catch{return!1}},_remove(e,t){if(O?.cookie)try{K._set(e,``,-1,t)}catch{return}}},fa=null,q={_is_supported(){if(!I(fa))return fa;let e=!0;if(P(D))e=!1;else try{let t=`__mplssupport__`;q._set(t,`xyz`),q._get(t)!==`"xyz"`&&(e=!1),q._remove(t)}catch{e=!1}return e||V.error(`localStorage unsupported; falling back to cookie store`),fa=e,e},_error(e){V.error(`localStorage error: `+e)},_get(e){try{return D?.localStorage.getItem(e)}catch(e){q._error(e)}return null},_parse(e){try{return JSON.parse(q._get(e))||{}}catch{}return null},_set(e,t){try{return D?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){q._error(e)}return!1},_remove(e){try{D?.localStorage.removeItem(e)}catch(e){q._error(e)}}},pa=[ye,fe,T,me,E,he,Le,Ie,Pe],ma=[i,r,w,oe,We,Ue,l,Re],ha=e=>e+`_cpm`,ga=[`__proto__`,`constructor`,`prototype`],_a=e=>{if(!N(e))return{};let t={};return Object.keys(e).forEach(n=>{ga.indexOf(n)===-1&&(t[n]=e[n])}),t},va=(e,t=[])=>{let n={};return[...ma,...t].forEach(t=>{let r=e[t];P(r)||I(r)||r===``||(n[t]=r)}),n},ya=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)},ba=(e,t)=>({p:t,f:ya(JSON.stringify(e))}),xa=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{let n=K._parse(ha(e)),r=n?.f===ya(t)&&j(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},Sa=(e,t)=>t+`|`+(K._get(ha(e))||``),Ca={},wa={_is_supported:()=>!0,_error(e){V.error(`memoryStorage error: `+e)},_get:e=>e in Ca?Ca[e]:null,_parse:e=>e in Ca?Ca[e]:null,_set:(e,t)=>(Ca[e]=t,!0),_remove(e){delete Ca[e]}},Ta=null,J={_is_supported(){if(!I(Ta))return Ta;if(Ta=!0,P(D))Ta=!1;else try{let e=`__support__`;J._set(e,`xyz`),J._get(e)!==`"xyz"`&&(Ta=!1),J._remove(e)}catch{Ta=!1}return Ta},_error(e){V.error(`sessionStorage error: `,e)},_get(e){try{return D?.sessionStorage.getItem(e)}catch(e){J._error(e)}return null},_parse(e){try{return JSON.parse(J._get(e))||null}catch{}return null},_set(e,t){try{return D?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){J._error(e)}return!1},_remove(e){try{D?.sessionStorage.removeItem(e)}catch(e){J._error(e)}}},Ea=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===`always`||this.isRejected()||this.consent===-1&&this._config.cookieless_mode===`on_reject`}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,+!!e,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){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 _storedConsent(){let e=this._storage._get(this._storageKey);return Kt(e)?1:A(qt,e)?0:-1}get _storage(){let e=this._config.opt_out_capturing_persistence_type,t=e===`localStorage`?q:K,n=t._is_supported()?t:wa;if(!this._persistentStore||this._persistentStore!==n){this._persistentStore=n;let t=e===`localStorage`?K:q;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Kt(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[ht?.doNotTrack,ht?.msDoNotTrack,k.doNotTrack,ht?.globalPrivacyControl].some(e=>Kt(e))}};function Da(e,t){var n;let r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!M(r))return t;try{let e=r(t);return F(e)&&e?e:t}catch(e){return V.error(`Error in get_current_url, falling back to window.location.href`,e),t}}function Oa(e){return e instanceof Element&&(e.id===`__POSTHOG_TOOLBAR__`||!!e.closest?.call(e,`.toolbar-global-fade-container`))}function ka(e){return!!e&&e.nodeType===1}function Y(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Aa(e){return!!e&&e.nodeType===3}function ja(e){return!!e&&e.nodeType===11&&ka(e.host)}function Ma(e){return e?Ot(e).split(/\s+/):[]}function Na(e,t){let n=function(e){var t;let n=D==null||(t=D.location)==null?void 0:t.href;return P(n)?void 0:Da(e,n)}(t);return!!(n&&e&&e.some(e=>n.match(e)))}function Pa(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 Ma(t)}function Fa(e){return L(e)?null:Ot(e).split(/(\s+)/).filter(e=>oo(e)).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Ia(e){let t=``;return Za(e)&&!Qa(e)&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(e){Aa(e)&&e.textContent&&(t+=Fa(e.textContent)??``)}),Ot(t)}function La(e){return P(e.target)?e.srcElement||null:e.target?.shadowRoot?e.composedPath()[0]||null:e.target||null}var Ra=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function za(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 Ba(e,t){if(P(t))return!0;for(let n of e)if(t.some(e=>za(n,e)))return!0;return!1}function Va(e){let t=e.parentNode;return!(!t||!ka(t))&&t}var Ha=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],Ua=[`next`,`previous`,`prev`,`>`,`<`],Wa=[...Ua,`+`,`-`,`−`,`–`],Ga=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Ka=[`.ph-no-rageclick`,`.ph-no-capture`],qa=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function Ja(e,t){if(!D||Ya(e))return!1;let n,r,i;var a;if(Lt(t)?(n=!!t&&Ka,r=void 0,i=!1):(n=t?.css_selector_ignorelist??Ka,r
1=t?.content_ignorelist,i=(a=t?.ignore_text_selection)!=null&&a),!1===n||i&&function(e){return!(!e||!ka(e))&&(!!Y(e,`textarea`)||(Y(e,`input`)?A(qa,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;let t=e.getAttribute?.call(e,`contenteditable`);return t===`true`||t===``}(e)))}(e))return!1;let{targetElementList:o}=Xa(e,!1);return!function(e,t){if(!1===e||P(e))return!1;let n;if(!0===e)n=Ua;else{if(!j(e))return!1;if(e.length>10)return V.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=>Ga(e,n)||Ga(t,n)))}(r,o.map(e=>({safeText:Ia(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``})))&&!Ba(o,n)}var Ya=e=>!e||Y(e,`html`)||!ka(e),Xa=(e,t)=>{if(!D||Ya(e))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1,r=[e],i=e;for(;i.parentNode&&!Y(i,`body`);){if(ja(i.parentNode)){r.push(i.parentNode.host),i=i.parentNode.host;continue}let e=Va(i);if(!e)break;if(t||Ra.indexOf(e.tagName.toLowerCase())>-1)n=!0;else try{let t=D.getComputedStyle(e);t&&t.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}catch{}r.push(e),i=e}return{parentIsUsefulElement:n,targetElementList:r}};function Za(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=Pa(r);if(A(e,`ph-sensitive`)||A(e,`ph-no-capture`))return!1}if(A(Pa(e),`ph-include`))return!0;let r=e.type||``;if(F(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}let i=e.name||e.id||``;return!F(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 Qa(e){return!!(Y(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Y(e,`select`)||Y(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var $a=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}))$`),eo=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,to=[16,15,14,13],no=RegExp(`^(\\d{3}-?\\d{2}-?\\d{4})$`),ro=RegExp(`(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))`,`g`),io=/[0-9A-Za-z_]/;function ao(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 oo(e,t=!0){return!(L(e)||F(e)&&(e=Ot(e),(t?$a.test((e||``).replace(/[- ]/g,``)):function(e){let t;for(eo.lastIndex=0;t=eo.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 to){let r=e+t;if(n.length>=r){let t=n.slice(e,r);if($a.test(t)&&ao(t))return!0}}}return!1}(e))||(t?no.test(e):function(e){let t;for(ro.lastIndex=0;t=ro.exec(e);){let e=t[1],n=t[3];if(!(e&&n&&io.test(e)&&io.test(n)))return!0}return!1}(e))))}function so(e){let t=Ia(e);return t=`${t} ${co(e)}`.trim(),oo(t)?t:``}function co(e){let t=``;return e&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{let n=Ia(e);t=`${t} ${n}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${co(e)}`.trim())}catch(e){V.error(`[AutoCapture]`,e)}}),t}function lo(e){return e.replace(/"|\\"/g,`\\"`)}function uo(e){let t=e.attr__class;if(t)return j(t)?t:Ma(t)}var fo=H(`[Dead Clicks]`),po=()=>!0,mo=e=>{let t=!!e.instance.persistence?.get_property(y),n=e.instance.config.capture_dead_clicks;return Lt(n)?n:!!N(n)||t},ho=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}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({[y]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,n;k.__PosthogExtensions__?.initDeadClicksAutocapture?e():(t=k.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this.instance,`dead-clicks-autocapture`,t=>{t?fo.error(`failed to load script`,t):e()})}
1_start(){if(O){if(!this._lazyLoadedDeadClicksAutocapture&&k.__PosthogExtensions__?.initDeadClicksAutocapture){let e=N(this.instance.config.capture_dead_clicks)?B({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=k.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(O),fo.info(`starting...`)}}else fo.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,fo.info(`stopping...`))}},go=H(`[SegmentIntegration]`);function _o(e,t,n=!0){let r=e.config.segment;if(!r)return t();let{analytics:i,filterProperties:a}=(e=>M(e.register))(o=r)?{analytics:o}:o;var o;(function(e,t,n,r){let i=t=>{let i=()=>t.anonymousId()||sa();e.config.get_device_id=i,r&&t.id()&&(e.register({distinct_id:t.id(),$device_id:i()}),e.persistence.set_property(Re,ot)),n(r?void 0:t.anonymousId()||void 0)},a=t.user();`then`in a&&M(a.then)?a.then(i):i(a)})(e,i,n=>{i.register(((e,t,{filterProperties:n}={})=>{typeof Promise<`u`&&Promise.resolve||go.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()||(go.info(`No userId set, resetting PostHog`),e.reset()),a||(t=void 0),r.event.userId&&r.event.userId!==e.get_distinct_id()&&(go.info(`UserId set, identifying with PostHog`),e.identify(r.event.userId));let o=e.calculateEventProperties(i,r.event.properties);if(!L(n)){let e=r.event.properties||{},t={};for(let n of Object.keys(o))Mt.call(e,n)||(t[n]=o[n]);let i=((e,t)=>{let n=j(e)?e:[e],r=B({},t);for(let e of n)try{if(r=e(r),L(r))return null}catch(e){return go.error(`Error in Segment filterProperties:`,e),null}return r})(n,t);if(L(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,ut)},identify(e){return r(e,ft)},screen(e){return r(e,`$screen`)}}})(e,n,{filterProperties:a})).then(()=>{t()},e=>{go.error(`Failed to register the Segment integration`,e),t()})},n)}var vo=`posthog-js`;function yo(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=>B(B({},e),{},{stacktrace:e.stacktrace?B(B({},e.stacktrace),{},{type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>B(B({},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 bo=class{constructor(e,t,n,r,i,a){this.name=vo,this.setupOnce=function(o){o(yo(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},xo=class{constructor(e){this._onSessionIdChange=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(V.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){this._unsubscribeSessionId=this._instance.sessionManager?.onSessionId(this._onSessionIdChange)}destroy(){var e;(e=this._unsubscribeSessionId)==null||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){let n=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:D?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this._previousPageViewProperties(e,this._currentPageview?.pageViewId)}doEvent(){return{$pageview_id:this._currentPageview?.pageViewId}}_previousPageViewProperties(e,t){let n=this._currentPageview;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(!(P(e)||P(t)||P(n)||P(a)||P(o)||P(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?Zt(t/e,0,1,V):1,c=e>1?Zt(n/e,0,1,V):1,l=a>1?Zt(o/a,0,1,V):1,u=a>1?Zt(s/a,0,1,V):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}},So=[`flags`,`surveys`],Co={[n]:{exposure:`hidden`},[o]:{exposure:`hidden`},[s]:{exposure:`hidden`},[f]:{exposure:`hidden`},[l]:{exposure:`hidden`}
1,[d]:{exposure:`hidden`},[p]:{exposure:`event`},[m]:{exposure:`hidden`},[x]:{exposure:`hidden`},[h]:{exposure:`event`},[g]:{exposure:`hidden`},[_]:{exposure:`event`},[v]:{exposure:`event`},[y]:{exposure:`event`},[b]:{exposure:`hidden`},[ee]:{exposure:`event`},[S]:{exposure:`hidden`},[C]:{exposure:`hidden`},[w]:{exposure:`hidden`},[oe]:{exposure:`event`},[te]:{exposure:`event`,shouldSkipFromEventProperties:e=>I(e)},[se]:{exposure:`event`},[ce]:{exposure:`event`},[le]:{exposure:`event`},[ue]:{exposure:`event`},[de]:{exposure:`hidden`},[T]:{exposure:`hidden`,storageGroup:`flags`},[fe]:{exposure:`hidden`,storageGroup:`flags`},[pe]:{exposure:`hidden`},[me]:{exposure:`hidden`,storageGroup:`flags`},[E]:{exposure:`hidden`,storageGroup:`flags`},[he]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[ge]:{exposure:`hidden`,storageGroup:`flags`},[_e]:{exposure:`hidden`},[ve]:{exposure:`hidden`},[ye]:{exposure:`hidden`},[be]:{exposure:`hidden`},[Se]:{exposure:`hidden`,storageGroup:`surveys`},[Ce]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[we]:{exposure:`event`},[Te]:{exposure:`hidden`},[Ee]:{exposure:`hidden`},[De]:{exposure:`hidden`},[Oe]:{exposure:`hidden`},[ke]:{exposure:`hidden`},[Ae]:{exposure:`event`},[je]:{exposure:`event`},[Me]:{exposure:`event`},[Ne]:{exposure:`event`},[Pe]:{exposure:`hidden`},[Fe]:{exposure:`hidden`},[xe]:{exposure:`event`},[Ie]:{exposure:`hidden`},[Le]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[Re]:{exposure:`hidden`},[ze]:{exposure:`hidden`},[Be]:{exposure:`hidden`},[Ve]:{exposure:`hidden`},[He]:{exposure:`hidden`},[Ue]:{exposure:`hidden`},[We]:{exposure:`hidden`},[ne]:{exposure:`event`},[re]:{exposure:`event`},[ie]:{exposure:`event`},[ae]:{exposure:`event`},[qe]:{exposure:`event`},[Je]:{exposure:`event`},[Ye]:{exposure:`event`},[Xe]:{exposure:`event`},[Ze]:{exposure:`event`},[Qe]:{exposure:`event`},[$e]:{exposure:`event`},[et]:{exposure:`event`},[tt]:{exposure:`event`},[nt]:{exposure:`event`},[rt]:{exposure:`event`}},wo=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],X=e=>{let t=Co[e];if(t)return t;for(let[t,n]of wo)if(e.indexOf(t)===0)return n},To=(e,t)=>{try{let n;return JSON.stringify(e,(e,t)=>Ht(t)?(n??=new WeakMap,n.has(t)||n.set(t,Zi(t)),n.get(t)):typeof t==`bigint`?t.toString():t,t)}catch{return At(e)}},Eo=e=>{let t=O?.createElement(`a`);return P(t)?null:(t.href=e,t)},Do=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(`=`);
1if(i[0]===t){r=i;break}}if(!j(r)||2>r.length)return``;{let e=r[1];try{e=decodeURIComponent(e)}catch{V.error(`Skipping decoding for malformed query param: `+e)}return e.replace(/\+/g,` `)}},Oo=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(`=`);j(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},ko=function(e,t){let n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},Ao=(e,t)=>e>=t&&St(),jo=(e,t,n,r)=>{if(e===0){if(St()){let e=t+1;return e===n&&r(),e}return t}return 0},Mo=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],No=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Mo],Po=`<masked>`,Fo=[`li_fat_id`];function Io(e,t,n){if(!O)return{};let r=t?[...Mo,...n||[]]:[],i=Lo(Oo(O.URL,r,Po),e);return W(function(){let e={};return U(Fo,function(t){let n=ta(t);e[t]=n||null}),e}(),i)}function Lo(e,t){let n=No.concat(t||[]),r={};return U(n,function(t){let n=Do(e,t);r[t]=n||null}),r}function Ro(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`,r={};if(!I(t)){r.$search_engine=t;let e=O?Do(O.referrer,n):``;e.length&&(r.ph_keyword=e)}return r}function zo(){return navigator.language||navigator.userLanguage}function Bo(){let e=zo();return typeof e==`string`?e.split(`-`)[0]:void 0}var Vo=`$direct`;function Ho(){return O?.referrer||Vo}function Uo(e,t,n=!1){let r=e?[...Mo,...t||[]]:[],i=(n?fr(gt?.href):gt?.href)?.substring(0,1e3);return{r:Ho().substring(0,1e3),u:i?Oo(i,r,Po):void 0}}function Wo(e,t=!1){let{r:n,u:r}=e,i=t?fr(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==Vo?Vo:Eo(n)?.host};if(i){a.$current_url=i;let e=Eo(i);a.$host=e?.host,a.$pathname=e?.pathname,W(a,Lo(i))}return n&&W(a,Ro(n)),a}function Go(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ko(){try{return new Date().getTimezoneOffset()}catch{return}}var qo={flags:Le,surveys:Ce},Jo=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Yo=e=>`${e}_cookie_identity_change_pending`,Xo=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`,Zo=[T,fe,me,E,he,Le,ge,ye],Qo=e=>Zo.indexOf(e)!==-1,$o=[l,d],es=e=>$o.indexOf(e)!==-1,ts=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},ns=e=>{if(!e)return{};let t=JSON.parse(e);return N(t)?t:{}},rs=(e,t)=>{U(e,(n,r)=>{let i=X(r);i&&i.exposure!==`event`||{}.hasOwnProperty.call(t,r)||delete e[r]})},is=class{constructor(e,t,n=!0){if(this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=n,this.props={},this._campaign_params_url=void 0,this._name=(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`})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&V.info(`Persistence loaded`,e.persistence,B({},this.props)),this.update_config(e,e,t),this.save(),D){let e=()=>this.flush();G(D,`beforeunload`,e,{capture:!1}),G(D,`pagehide`,e,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===D?.localStorage)&&e.key){if(e.key!==this._name){if(this._splitStorage){let t=So.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,Z)}},G(D,`storage`,this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>
1{let n=this._pendingCrossTabFeatureFlagChanges.get(e);if(!Qo(e)||!0===n)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);let r=new Set(n||[]);t.forEach(e=>r.add(e)),r.size&&this._setCrossTabFeatureFlagChangesPending(e,r)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&D&&(D.removeEventListener(`storage`,this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,n=!0){if(this._disabled)return!1;let r,i;try{if(i=q._get(e),I(i)){let e=this._slotWriteState(t);return e.storageValue=null,t!==Z&&(e.persisted=!1),!1}r=ns(i)}catch{return!1}let a=t===Z?r:q._parse(this._name);if(a&&this._hasCrossTabFeatureFlagIdentityMismatch(a))return!1;let o=this._mergeCrossTabFeatureFlagProperties(r,t,n);return t===Z&&this._splitStorage&&!ts(this._partitionProps().main,r)||this._rememberCrossTabStorageFingerprint(r,t,!0,i),o}_hasCrossTabFeatureFlagIdentityMismatch(e){let t=this.props[r],n=e[r];return!P(t)&&!P(n)&&t!==n}_rememberCrossTabStorageFingerprint(e,t,n,r){let i=this._slotWriteState(t);i.storageValue=r,t!==Z&&(i.persisted=n);try{i.fingerprint=this._entryFingerprint(e,t)}catch{i.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,n){let r=!1;return Zo.forEach(n=>{let i=X(n)?.storageGroup;if(t===Z&&this._splitStorage&&i||t!==Z&&i!==t)return;let a=n in e,o=this._mergePendingCrossTabFeatureFlagChanges(n,a?e[n]:void 0),s=this._pendingCrossTabFeatureFlagChanges.has(n)?n in this.props:a;s===n in this.props&&ts(o,this.props[n])||(s?this._setProp(n,o,!1):this._deleteProp(n,!1),r=!0)}),r&&n&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),r}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;let e=q._get(this._name),t=this._slotWriteState(Z),n,r=!1,i=!1;if(e!==t.storageValue){if(I(e))t.storageValue=null;else{if(n=ns(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(n),this._crossTabFeatureFlagIdentityMismatch)return!1;i=this._mergeCrossTabFeatureFlagProperties(n,Z,!1),!this._splitStorage||ts(this._partitionProps().main,n)?this._rememberCrossTabStorageFingerprint(n,Z,!0,e):t.storageValue=e,r=!0}}return this._splitStorage&&So.forEach(e=>{let t=q._get(this._groupEntryName(e)),a=this._slotWriteState(e),o=n||{},s=r&&Zo.some(t=>X(t)?.storageGroup===e&&t in o);if(t===a.storageValue&&!s)return;if(I(t))return a.storageValue=null,a.persisted=!1,void(s&&(i=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||i));let c=ns(t);i=this._mergeCrossTabFeatureFlagProperties(c,e,!1)||i,this._rememberCrossTabStorageFingerprint(c,e,!0,t)}),i}catch{return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);let n=X(e);n!=null&&n.volatile||(this._slotWriteState((this._splitStorage?n?.storageGroup:void 0)||Z).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){Zo.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{let e=q._get(this._name),t=ns(e);this._slotWriteState(Z).storageValue=e,Zo.forEach(e=>{let n=this._splitStorage?X(e)?.storageGroup:void 0,r=n?q._get(this._groupEntryName(n)):null;if(n){let e=this._slotWriteState(n);e.storageValue=r,e.persisted=!I(r)}let i=n&&!I(r)?ns(r):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,i[e],this.props[e]):e in i&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch{}}_mergePendingCrossTabFeatureFlagChanges(e,t){let n=this._pendingCrossTabFeatureFlagChanges.get(e);if(!n)return t;if(!0===n)return this.props[e];if(e===`$active_feature_flags`){let r=new Set(j(t)?t:[]),i=new Set(j(this.props[e])?this.props[e]:[]);return n.forEach(e=>i.has(e)?r.add(e):r.delete(e)),Array.from(r)}let r=N(t)?B({},t):{},i=N(this.props[e])?this.props[e]:{};return n.forEach(e=>{e in i?r[e]=i[e]:delete r[e]}),r}
1_markPendingCrossTabFeatureFlagChanges(e,t,n){if(!Qo(e))return;let r=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===r)return;let i=t;if(this._splitStorageEligible)try{let t=this._splitStorage?X(e)?.storageGroup:void 0,n=t?this._groupEntryName(t):this._name;i=ns(q._get(n))[e]}catch{}let a=new Set(r||[]);if(e===`$active_feature_flags`){if(!P(t)&&!j(t)||!P(i)&&!j(i)||!j(n))return void this._setCrossTabFeatureFlagChangesPending(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(!N(n))return void(ts(i,n)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!P(t)&&!N(t)||P(t)&&Pt(n)&&P(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);let r=N(t)?t:{},o=N(i)?i:{};new Set([...Object.keys(r),...Object.keys(n)]).forEach(e=>{e in r==e in n&&ts(r[e],n[e])||a.add(e)}),a.forEach(e=>{e in o==e in n&&ts(o[e],n[e])&&a.delete(e)})}}a.size?this._setCrossTabFeatureFlagChangesPending(e,a):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){let e=this._config?.persistence_save_debounce_ms;return R(e)&&e>0?e:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&this._config.persistence.toLowerCase()===`localstorage+cookie`){if(e)try{let t=va(e,this._config.cookie_persisted_properties||[]),n=ba(t,this._config.cookie_persisted_properties||[]),r=JSON.stringify(t)+`|`+JSON.stringify(n),i=K._get(this._name)||void 0;i&&Sa(this._name,i)===r&&(this._lastSeenCookiePropertiesFingerprint=r,this._lastSeenMainCookieValue=i)}catch{}else try{let e=K._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?Sa(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch{}}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!==`localstorage+cookie`)return!1;let n;try{n=K._get(this._name)||void 0}catch{}if(!n||n===this._lastSeenMainCookieValue)return!1;let i=Sa(this._name,n),a;try{a=_a(JSON.parse(n))}catch{return!1}if((K._get(this._name)||void 0)!==n)return!1;this._lastSeenCookiePropertiesFingerprint=i,this._lastSeenMainCookieValue=n;let s=xa(this._name,n),c=[...ma,...s.properties],l={};if(Object.keys(a).forEach(e=>{let t=a[e];(P(t)||I(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`)&&(l[e]=!0,delete a[e])}),Pt(a))return!1;let u=`distinct_id`in a||a.$user_state===`anonymous`||a.$user_state===`identified`,d=this.props,f=d[r],p=d[Re],m=W({},d);[...ma,...e.cookie_persisted_properties||[]].forEach(e=>{if(c.indexOf(e)!==-1&&!(e in a)&&!l[e]&&(u||e!==`distinct_id`&&e!==`$user_state`)){let t=m[e];(s.isValid||ma.indexOf(e)===-1||!1!==t&&t!==0)&&delete m[e]}}),this.props=W(m,a),Zo.forEach(e=>{let t=e in this.props;e in d===t&&ts(d[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,d[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!u||`$user_state`in a||`$user_state`in this.props||this._setProp(Re,at);let h=this.props[r],g=this.props[Re];return!u||h===f&&g===p||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,J._set(Yo(this._name),!0),this._deleteProp(ye),this._deleteProp(fe),this._deleteProp(T),this._deleteProp(me),this._deleteProp(E),this._deleteProp(he),this._deleteProp(Le),this._deleteProp(Ie),this._deleteProp(Pe),g!==`anonymous`||p!==`identified`&&a.$user_state!==`anonymous`&&(P(f)||h===f)||(rs(this.props,a),this._deleteProp(be)),g===`identified`?this.props.$user_id=h:delete this.props.$user_id,this._deleteProp(o)),!0}
1consumeCookieIdentityChange(){let e=Yo(this._name),t=this._cookieIdentityChangePending||!!J._get(e);return this._cookieIdentityChangePending=!1,t&&J._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||this._config.persistence.toLowerCase()!==`localstorage+cookie`||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(P(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Z],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():P(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){Jo.indexOf(e.persistence.toLowerCase())===-1&&(V.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);let t=((e=[],t=!1)=>{let n=[...ma,...e];return B(B({},q),{},{_parse(e){try{let i,a={};try{i=K._get(e)||void 0,a=i?_a(JSON.parse(i)):{}}catch{}let o=JSON.parse(q._get(e)||`{}`),s;if(t){let t=xa(e,i),c=[...ma,...t.properties],l={};Object.keys(a).forEach(e=>{let t=a[e];I(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`||(l[e]=t)});let u=`distinct_id`in l||l.$user_state===`anonymous`||l.$user_state===`identified`;if(Object.keys(l).length>0){let e=o[r],i=o.$user_state??at;n.forEach(e=>{if(c.indexOf(e)!==-1&&!(e in a)&&(u||e!==`distinct_id`&&e!==`$user_state`)){let n=o[e];(t.isValid||ma.indexOf(e)===-1||!1!==n&&n!==0)&&delete o[e]}}),!u||`$user_state`in a||`$user_state`in o||(o[Re]=at),!u||(`distinct_id`in l?l[r]:o[r])===e&&(`$user_state`in l?l[Re]:o[Re])===i||(pa.forEach(e=>delete o[e]),l.$user_state===`identified`&&`distinct_id`in l?o.$user_id=l[r]:delete o.$user_id,l.$user_state!==`identified`&&(delete o[xe],delete o[be]),delete o.__al
1ias)}s=W(o,l)}else s=W(a,o);return q._set(e,s),s}catch{}return null},_set(n,r,i,a,o,s){let c=q._set(n,r,void 0,void 0,s);try{let l=va(r,e);if(Object.keys(l).length){if(t){let t=ha(n),u=ba(l,e);if(K._set(t,u,i,a,o,s),K._get(t)!==JSON.stringify(u)){K._remove(t,a);let e=va(r);return K._set(n,e,i,a,o,s),c}}K._set(n,l,i,a,o,s)}}catch(e){q._error(e)}return c},_remove(e,t){try{D?.localStorage.removeItem(e),K._remove(e,t),K._remove(ha(e),t)}catch(e){q._error(e)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),n,i=!1,a=!1,o=e.persistence.toLowerCase();return o===`localstorage`&&q._is_supported()?(n=q,a=!0):o===`localstorage+cookie`&&t._is_supported()?(n=t,a=!0,i=!0):o===`sessionstorage`&&J._is_supported()?n=J:o===`memory`?n=wa:o===`cookie`&&K._is_supported()?(n=K,i=!0):t._is_supported()?(n=t,a=!0,i=!0):K._is_supported()?(n=K,i=!0):n=wa,this._splitStorageEligible=a,this._storesIdentityInCookie=i,n}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!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._disabled&&!e)return;let t=this._config.cookieWinsOnConflict&&this._config.persistence.toLowerCase()===`localstorage+cookie`,n=t?q._parse(this._name):null,i={};if(t)try{i=_a(K._parse(this._name)),U(i,(e,t)=>{(P(e)||I(e)||e===``)&&delete i[t]})}catch{}let a=this._storage._parse(this._name);if(a&&(this.props=W({},a)),this._splitStorage&&this._loadGroupEntries(),t&&a){let e=n?.[r],t=n?.$user_state??at,o=a[r],s=a.$user_state??at;if(o!==e||s!==t){this._cookieIdentityChangePending=!0,J._set(Yo(this._name),!0);let n=W({},this.props);pa.forEach(e=>delete n[e]),s!==`anonymous`||t!==`identified`&&i.$user_state!==`anonymous`&&(P(e)||o===e)||(rs(n,i),delete n[be]),this.props=n;let r=new Set;pa.forEach(e=>{let t=X(e)?.storageGroup;t&&r.add(t)}),r.forEach(e=>{let t={};U(this.props,(n,r)=>{X(r)?.storageGroup===e&&(t[r]=n)}),Pt(t)?(q._remove(this._groupEntryName(e)),this._slotState[e]={}):q._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}J._get(Yo(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(let e of So){let t=q._parse(this._groupEntryName(e));if(t&&!Pt(t)){let n=this._slotWriteState(e);n.persisted=!0,this._mainCarriesGroupKey(e)||(n.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||W(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>X(t)?.storageGroup===e)}_groupEntryIsStale(e,t){let n=qo[e];if(!n)return!1;let r=t[n],i=this.props[n];return R(r)&&R(i)&&i>r}refreshKey(e){if(this._disabled||this._metaIdentifierChangePending.has(e))return;let t=this._splitStorage?X(e)?.storageGroup:void 0,n=t?q._parse(this._groupEntryName(t)):this._storage._parse(this._name);if(n&&e in n)this._setProp(e,n[e],!1);else{if(t){let t=this._storage._parse(this._name);if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}}save(){if(this._disabled)return;let e=this._saveDebounceMs();e>0?P(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){P(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&this._config.persistence.toLowerCase()===`localstorage+cookie`||$o.forEach(e=>this.refreshKey(e)));let t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);let n=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&V.warn(`skipping persistence write because storage belongs to a different distinct ID`));if(this._splitStorage)return this._writeNowSplit(),void(n&&this._crossTabFeatureFlagHandlers.forEac
1h(e=>e()));let r=this._writeEntry(this._storage,this._name,this.props,Z);r===`written`&&this._rememberCurrentCookieProperties(this.props),r!==`failed`&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),n&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){let{main:e,groups:t}=this._partitionProps(),n=this._writeEntry(this._storage,this._name,e,Z);n===`written`&&this._rememberCurrentCookieProperties(e),n!==`failed`&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),Zo.forEach(e=>{var t;(t=X(e))!=null&&t.storageGroup||this._pendingCrossTabFeatureFlagChanges.delete(e)}));for(let e of So){let n=t[e];if(Pt(n)&&!this._slotState[e]?.persisted){Zo.forEach(t=>{X(t)?.storageGroup===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}let r=this._writeEntry(q,this._groupEntryName(e),n,e);r!==`failed`&&Zo.forEach(t=>{let n=X(t);n?.storageGroup!==e||r!==`written`&&n.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){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}}_entryFingerprint(e,t){if(t===Z)return JSON.stringify(e)+`|`+this._expire_days+`|`+this._cross_subdomain+`|`+this._secure;let n={};return U(e,(e,t)=>{n[t]=X(t)?.volatile?`__volatile__`:e}),JSON.stringify(n)}_writeEntry(e,t,n,r){let i=this._slotWriteState(r);if(r!==Z&&!i.dirty&&!P(i.fingerprint))return`skipped`;let a;try{if(a=this._entryFingerprint(n,r),a===i.fingerprint)return i.dirty=!1,`skipped`}catch{a=void 0}return e._set(t,n,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(i.dirty=!1,r!==Z&&
1(i.persisted=!0),P(a)||(i.fingerprint=a),this._splitStorageEligible&&(i.storageValue=q._get(t)),`written`):(this._config.debug&&V.warn(`failed to persist storage entry "${t}"; will retry on next save`),`failed`)}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),P(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(let e of So)q._remove(this._groupEntryName(e));e?delete this._slotState[Z]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(N(e)){this.syncCookieProperties(),P(t)&&(t=`None`),this._expire_days=P(n)?this._default_expiry:n;let r=!1;if(U(e,(e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this._setProp(n,e),r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(N(e)){this.syncCookieProperties(),this._expire_days=P(t)?this._default_expiry:t;let n=!1;if(U(e,(t,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==t||N(t)||j(t))&&(this._setProp(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._deleteProp(e),n=!0);n&&this.save()}update_campaign_params(){let e=O?.URL;if(e===this._campaign_params_url)return;let t=Io(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),n=!Pt(Xi(t));return n&&this.register(t),this._campaign_params_url=e,n?t:void 0}update_search_keyword(){this.register(function(){let e=O?.referrer;return e?Ro(e):{}}())}update_referrer_info(){this.register_once({$referrer:Ho(),$referring_domain:O?.referrer&&Eo(O.referrer)?.host||Vo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let e=Uo(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Ue]:this._storesIdentityInCookie?{r:Xo(e.r),u:e.u?Xo(e.u):void 0}:e},void 0)}get_initial_props(){let e={};U([He,Ve],t=>{let n=this.props[t];n&&U(n,function(t,n){e[`$initial_`+kt(n)]=t})});let t=this.props[Ue];return t&&W(e,function(e,t=!1){let n=Wo(e,t),r={};return U(n,function(e,t){r[`$initial_${kt(t)}`]=e}),r}(t,this._config.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._disabled&&!s;s||this._syncCookieProperties(t,c),this._config=e,!s&&(r||i||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(B(B({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),c));let l=a||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();let u=this._resolveSplitStorage(e),d=a||u!==this._splitStorage,f=!s&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(c);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=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._storage=l,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=l,s||(delete this._slotState[Z],this._writeNow()))}finally{this._storageMigrationInProgress=!1,f&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){let e=this.props[Ue];if(!this._storesIdentityInCookie||!N(e)||typeof e.r!=`string`)return;let t=Xo(e.r),n=typeof e.u==`string`?Xo(e.u):e.u;t===e.r&&n===e.u||this._setProp(Ue,B(B({},e),{},{r:t,u:n}))}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){let n=this.props.__timers||{};n[e]=t,this._setProp(f,n),this.save()}remove_event_timer(e){let t=this.props.__timers||{},n=t[e];return P(n)||(delete t[e],this._setProp(f,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(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._localIdentityChangePending=!0),es(e)&&!ts(i,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,i,t),(r=X(e))!=null&&r.volatile||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(Qo(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),es(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){let t=X(e)?.storageGroup;t&&(this._slotWriteState(t).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}},as={GZipJS:`gzip-js`,Base64:`base64`},os={Activation:`events`,Cancellation:`cancelEvents`},ss={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},cs={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},ls={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_
1START_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`},us={Popover:`popover`,Inline:`inline`};function ds(e){let t=!0;return{dispose(){if(t){t=!1;let n=e();n&&M(n.then)&&n.then(void 0,()=>{})}}}}var fs={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`},ps={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`},ms=H(`[RateLimiter]`),hs=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=>{ms.info(`${e||`events`} is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4})}catch(e){ms.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=(R(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this._captureWarning(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}}_isPropertyAllowed(e){let t=this.instance.config.property_denylist;return!j(t)||!t.includes(e)}_triggeringPage(){if(this._isPropertyAllowed(`$current_url`)&&this._isPropertyAllowed(`$pathname`)&&gt?.pathname)return`${gt.origin??``}${gt.pathname}`}_captureWarning(e){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=this._triggeringPage(),a=this._isPropertyAllowed(`$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}
1`: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}},gs=H(`[RemoteConfig]`),_s=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=k._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}_loadRemoteConfigJs(e){var t,n;k.__PosthogExtensions__?.loadExternalDependency?(t=k.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`remote-config`,()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(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 gs.info(`Using preloaded remote config`,this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void gs.warn(`Remote config is disabled. Falling back to local config.`);this._loadRemoteConfigJs(e=>{if(!e)return gs.info(`No config found after loading remote JS config. Falling back to JSON.`),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){gs.error(`Error loading remote config`,e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(t.statusCode===0?t.error||gs.warn(`Failed to fetch remote config from PostHog.`):gs.error(`Failed to fetch remote config from PostHog.`));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){gs.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){gs.error(`Error loading feature flags`,e)}}},vs=Uint8Array,ys=Uint16Array,bs=Uint32Array,xs=new vs([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]),Ss=new vs([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]),Cs=new vs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ws=function(e,t){for(var n=new ys(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new bs(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]},Ts=ws(xs,2),Es=Ts[1];Ts[0][28]=258,Es[258]=28;for(var Ds=ws(Ss,0)[1],Os=new ys(32768),Q=0;32768>Q;++Q){var ks=(43690&Q)>>>1|(21845&Q)<<1;Os[Q]=((65280&(ks=(61680&(ks=(52428&ks)>>>2|(13107&ks)<<2))>>>4|(3855&ks)<<4))>>>8|(255&ks)<<8)>>>1}var As=function(e,t,n){for(var r=e.length,i=0,a=new ys(t);r>i;++i)++a[e[i]-1];var o,s=new ys(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new ys(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[Os[d]>>>c]=l}else for(o=new ys(r),i=0;r>i;++i)o[i]=Os[s[e[i]-1]++]>>>15-e[i];return o},js=new vs(288);for(Q=0;144>Q;++Q)js[Q]=8;for(Q=144;256>Q;++Q)js[Q]=9;for(Q=256;280>Q;++Q)js[Q]=7;for(Q=280;288>Q;++Q)js[Q]=8;var Ms=new vs(32);for(Q=0;32>Q;++Q)Ms[Q]=5;var Ns=As(js,9,0),Ps=As(Ms,5,0),Fs=function(e){return(e/8|0)+(7&e&&1)},Is=function(e,t,n){(t==null||0>t)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof ys?ys:e instanceof bs?bs:vs)(n-t);return r.set(e.subarray(t,n)),r},Ls=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Rs=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},zs=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 vs(0),0];if(i==1){var o=new vs(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 ys(f+1),m=Bs(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;
vendor: 4,232 bytes, line 1
1++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 vs(p),m]},Bs=function(e,t,n){return e.s==-1?Math.max(Bs(e.l,t,n+1),Bs(e.r,t,n+1)):t[e.s]=n},Vs=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ys(++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]},Hs=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Us=function(e,t,n){var r=n.length,i=Fs(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)},Ws=function(e,t,n,r,i,a,o,s,c,l,u){Ls(t,u++,n),++i[256];for(var d=zs(i,15),f=d[0],p=d[1],m=zs(a,15),h=m[0],g=m[1],_=Vs(f),v=_[0],y=_[1],b=Vs(h),x=b[0],ee=b[1],S=new ys(19),C=0;v.length>C;++C)S[31&v[C]]++;for(C=0;x.length>C;++C)S[31&x[C]]++;for(var te=zs(S,7),ne=te[0],re=te[1],ie=19;ie>4&&!ne[Cs[ie-1]];--ie);var ae,w,oe,se,ce=l+5<<3,le=Hs(i,js)+Hs(a,Ms)+o,ue=Hs(i,f)+Hs(a,h)+o+14+3*ie+Hs(S,ne)+(2*S[16]+3*S[17]+7*S[18]);if(le>=ce&&ue>=ce)return Us(t,u,e.subarray(c,c+l));if(Ls(t,u,1+(le>ue)),u+=2,le>ue){ae=As(f,p,0),w=f,oe=As(h,g,0),se=h;var de=As(ne,re,0);for(Ls(t,u,y-257),Ls(t,u+5,ee-1),Ls(t,u+10,ie-4),u+=14,C=0;ie>C;++C)Ls(t,u+3*C,ne[Cs[C]]);u+=3*ie;for(var T=[v,x],fe=0;2>fe;++fe){var pe=T[fe];for(C=0;pe.length>C;++C)Ls(t,u,de[me=31&pe[C]]),u+=ne[me],me>15&&(Ls(t,u,pe[C]>>>5&127),u+=pe[C]>>>12)}}else ae=Ns,w=js,oe=Ps,se=Ms;for(C=0;s>C;++C)if(r[C]>255){var me;Rs(t,u,ae[257+(me=r[C]>>>18&31)]),u+=w[me+257],me>7&&(Ls(t,u,r[C]>>>23&31),u+=xs[me]);var E=31&r[C];Rs(t,u,oe[E]),u+=se[E],E>3&&(Rs(t,u,r[C]>>>5&8191),u+=Ss[E])}else Rs(t,u,ae[r[C]]),u+=w[r[C]];return Rs(t,u,ae[256]),u+w[256]},Gs=new bs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ks=new vs(0),qs=function(){for(var e=new bs(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Js=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Ys(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=qs[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 vs(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=Us(c,l,e.subarray(u,d)):(c[u]=a,l=Us(c,l,e.subarray(u,o)))}else{for(var f=Gs[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new ys(32768),_=new ys(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 bs(25e3),ee=new ys(288),S=new ys(32),C=0,te=0,ne=(u=0,0),re=0,ie=0;o>u;++u){var ae=b(u),w=32767&u,oe=_[ae];if(g[w]=oe,_[ae]=w,u>=re){var se=o-u;if((C>7e3||ne>24576)&&se>423){l=Ws(e,c,0,x,ee,S,te,ne,ie,u-ie,l),ne=C=te=0,ie=u;for(var ce=0;286>ce;++ce)ee[ce]=0;for(ce=0;30>ce;++ce)S[ce]=0}var le=2,ue=0,de=m,T=w-oe&32767;if(se>2&&ae==b(u-T))for(var fe=Math.min(p,se)-1,pe=Math.min(32767,u),me=Math.min(258,se);pe>=T&&--de&&w!=oe;){if(e[u+le]==e[u+le-T]){for(var E=0;me>E&&e[u+E]==e[u+E-T];++E);if(E>le){if(le=E,ue=T,E>fe)break;var he=Math.min(T,E-2),ge=0;for(ce=0;he>ce;++ce){var _e=u-T+ce+32768&32767,ve=_e-g[_e]+32768&32767;ve>ge&&(ge=ve,oe=_e)}}}T+=(w=oe)-(oe=g[w])+32768&32767}if(ue){x[ne++]=268435456|Es[le]<<18|Ds[ue];var ye=31&Es[le],be=31&Ds[ue];te+=xs[ye]+Ss[be],++ee[257+ye],++S[be],re=u+le,++C}else x[ne++]=e[u],++ee[e[u]]}}l=Ws(e,c,a,x,ee,S,te,ne,ie,u-ie,l),a||(l=Us(c,l,Ks))}return Is(s,0,r+Fs(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&&Js(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),Js(u,d-8,n.d()),Js(u,d-4,r),u}var Xs=!!vt||!!_t,Zs=new WeakMap,Qs=`text/plain`,$s=0,ec=!1,tc=(e,t)=>
1{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=B({},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){P(e)||P(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)}),i.join(t)}(a);return s&&o.push(s),o.length>0?`${r}?${o.join(`&`)}`:r},rc=e=>{if(e._encodedBody)return e._encodedBody;let{data:t,compression:n}=e;if(!t)return;if(n===as.GZipJS){let e=Ys(function(e){var t=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var n=new vs(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 vs(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 Is(n,0,r)}(To(t)),{mtime:0});return{contentType:Qs,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(n===as.Base64){let e=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:To(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))))}(To(t)));return{contentType:`application/x-www-form-urlencoded`,body:e,estimatedSize:new Blob([e]).size}}let r=To(t);return{contentType:`application/json`,body:r,estimatedSize:new Blob([r]).size}},ic=e=>{let t=()=>e.transport===`sendBeacon`?{url:nc(e.url,{compression:as.Base64}),encodedBody:rc(B(B({},e),{},{compression:as.Base64,_encodedBody:void 0}))}:{url:tc(e.url,`compression`),encodedBody:rc(B(B({},e),{},{compression:void 0,_encodedBody:void 0}))},n;try{n=rc(e)}catch(n){if(hi(e.compression,Do(e.url,`compression`)))return V.error(`Failed to gzip request body, sending uncompressed payload`,n),t();throw n}return n&&hi(e.compression,Do(e.url,`compression`))&&!((r=n.body)instanceof ArrayBuffer?mi(new Uint8Array(r)):ArrayBuffer.isView(r)&&mi(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;V.error(n),(t=e.callback)==null||t.call(e,{statusCode:0,error:n});return}},oc=function(){var e=z(function*(e){let n=yield function(e){return xi.apply(this,arguments)}(To(e.data),t.DEBUG,{rethrow:!0});if(!n)return e;let r=yield n.arrayBuffer();return B(B({},e),{},{_encodedBody:{contentType:Qs,body:r,estimatedSize:r.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=>{try{let t=function(e,t=Date.now()){if(typeof e!=`string`||!e)return;let n=e.trim(),r=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(`,`)).trim():n;if(/^\d+$/.test(r)){let e=1e3*Math.min(Number(r),300);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;let i=/^\w{3} \w{3} /.test(r)?r+` GMT`:r,a=Date.parse(i)-t;return Number.isFinite(a)&&a>0?Math.min(a,sr):void 0}(e());return P(t)?void 0:Math.min(t,3e4)}catch{return}},uc=e=>{let t=ac(e);if(!t)return;let n=new vt;Zs.set(n,!0);let{url:r,encodedBody:i}=t;n.open(e.method||`GET`,r,!0);let{contentType:a,body:o}=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,lc(()=>n.getResponseHeader(`Retry-After`)))}},n.send(o)},dc=e=>{let t=ac(e);if(!t)return;let{url:n,encodedBody:r}=t,{contentType:i,body:a,estimatedSize:o}=r??{},s=new Headers;U(e.headers,function(e,t){s.append(t,e)}),i&&s.append(`Content-Type`,i);let c=null,l=!1;if(yt){let t=new yt;c={signal:t.signal,timeout:setTimeout(()=>{l=!0;try{t.abort(dr(`AbortError`,`PostHog request timed out`+((n=e.timeout)?` after ${n}ms`:``)))}catch(e){d(e)}var n},e.timeout)}}let u=!1,d=t=>{var n;u||(u=!0,l&&t?.name===`AbortError`||cc(t)?V.warn(t):V.error(t),(n=e.callback)==null||n.call(e,{statusCode:0,error:t}))},f=0,p=()=>{$s-=f,f=0,c&&clearTimeout(c.timeout)};try{let t=B({method:e?.method||`GET`,headers:s,referrerPolicy:`strict-origin`,body:a,signal:c?.signal},e.fetchOptions),r=o??(P(a)?0:void 0);t.keepalive=t.method===`POST`&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===a&&!P(r)&&r>=0&&52428.8>$s+r,t.keepalive&&(f=r,$s+=f),_t(n,t).then(t=>t.text().then(n=>{var r;if(u)return;let i={statusCode:t.status,text:n};if(t.status===200)try{i.json=JSON.parse(n)}catch(e){V.error(e)}u=!0,p(),(r=e.callback)==null||r.call(e,i,lc(()=>t.headers.get(`Retry-After`)))})).catch(e=>{p(),d(e)}).finally(p)}catch(e){p(),d(e)}},fc=e=>{try{let{url:t,encodedBody:n}=ic(e),{contentType:r,body:i,estimatedSize:a}=n??{};if(!i)return;let o=i instanceof Blob?i:new Blob([i],{type:r});if(ht.sendBeacon(t,o))return;let s=j(e.data)?e.data:e.data?.batch;if(j(s)&&s.length>1&&(a??0)>16384){let t=Math.ceil(s.length/2),n=t=>j(e.data)?t:B(B({},e.data),{},{batch:t});fc(B(B({},e),{},{data:n(s.slice(0,t))})),fc(B(B({},e),{},{data:n(s.slice(t))}));return}V.warn(`Beacon of ~${a??0} bytes was rejected by the browser, falling back to ${_t?`fetch`:`XHR`}`),_t?dc(B(B({},e),{},{_keepaliveDisabled:!0})):uc(e)}catch(e){V.warn(`Beacon send failed`,e)}},pc=(e,t,n,r)=>{let i=r===`query`?t===`POST`?`sent_at`:`_`:void 0;return nc(n===as.GZipJS?tc(e,`compression`):e,B(B({},i?{[i]:Date.now().toString()}:{}),n===as.GZipJS?{}:{compression:n}))},mc=(()=>{let e=[];return _t&&e.push({transport:`fetch`,method:dc}),vt&&e.push({transport:`XHR`,method:uc}),ht!=null&&ht.sendBeacon&&e.push({transport:`sendBeacon`,method:fc}),e})(),hc=!Xs&&xt?.indexOf(`MSIE`)===-1&&xt?.indexOf(`Mozilla`)===-1;
1function gc(e,t,n){var r,i;n&&(t=B(B({},t),{},{callback:e=>n(e)})),e.__loaded?hc?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((r=t.callback)==null||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=B(B({},e.config.request_headers),t.headers),t.compression=t.compression===`best-available`?e.compression??t.compressionFallback:t.compression,(P(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=[`sendBeacon`]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{let n=B(B({},e),{},{callback:t??(t=>e.callback?.call(e,t))});n.timeout=n.timeout||6e4;let r=n.transport??`fetch`;r===`sendBeacon`&&P(n.compression)&&n.data&&(n.compression=as.Base64),n.method===`POST`&&n.data&&(n.timestampMode===`capture-body`?n.data=(e=>{var t;let n=(j(e)?e:[e]).map(e=>B(B({},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()}})(n.data):n.timestampMode===`body`&&(n.data=((e,t=new Date().toISOString())=>j(e)?e.map(e=>B(B({},e),{},{sent_at:t})):B(B({},e),{},{sent_at:t}))(n.data))),n.url=pc(n.url,n.method,n.compression,n.timestampMode);let i=mc.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),a=function(e,t){for(let n=0;e.length>n;n++)if(t(e[n]))return e[n]}(i,e=>e.transport===r)?.method??i[0].method;if(!a)throw Error(`No available transport method`);let o=e=>{try{a(e)}catch(e){var t;cc(e)?V.warn(e):V.error(e),(t=n.callback)==null||t.call(n,{statusCode:0,error:e})}};r!==`sendBeacon`&&n.data&&n.compression===as.GZipJS&&bt&&typeof Promise<`u`&&!ec?oc(n).then(e=>{o(e)}).catch(t=>{if(gi(t))return ec=!0,void o(B(B({},n),{},{compression:void 0,url:pc(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 gi(e)||t===pi})(t)&&(ec=!0),o(n)}):a(n)})(t,(r,i)=>{var a,o,s;e.rateLimiter.checkForLimiting(r),400>r.statusCode||(a=(o=e.config).on_request_error)==null||a.call(o,r),n?n(r,i):(s=t.callback)==null||s.call(t,r)})):t.fireCallbackOnDrop&&((i=t.callback)==null||i.call(t,{statusCode:0}))}var _c=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Zt(t?.flush_interval_ms||3e3,250,5e3,V.createLogger(`flush interval`),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();let e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>e.url.indexOf(`/e`)===0),...t.filter(e=>e.url.indexOf(`/e`)!==0)].map(e=>{this._sendRequestSafely(e,`sendBeacon`)})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){let e=this._formatQueue();for(let t in e)this._sendRequestSafely(e[t])}},this._flushTimeoutMs))}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){V.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){let e={};return U(this._queue,t=>{var n;let r=t,i=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:``);P(e[i])&&(e[i]=B(B({},r),{},{data:[]})),(n=e[i].data)==null||n.push(r.data)}),this._queue=[],e}},vc=[`retriesPerformedSoFar`],yc=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!P(D)&&`onLine`in D.navigator){if(this._areWeOnline=D.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},G(D,`online`,this._onlineListener),G(D,`offline`,this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:n}=e,r=Si(e,vc);It(n)&&(r.url=nc(r.url,{retry_count:n})),gc(this._instance,t?B(B({},r),{},{transport:t}):r,(e,t)=>{var i;if(e.statusCode!==200&&(400>
1e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(n??0))return void this._enqueue(B({retriesPerformedSoFar:n},r),t);e.statusCode===0&&V.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${n??0} retries.`)}(i=r.callback)==null||i.call(r,e)})}_enqueue(e,t){let n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;let r=Math.max(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)}(n),t??0),i=Date.now()+r;this._queue.push({retryAt:i,requestOptions:e});let a=`Enqueued failed request for retry in ${r}`;navigator.onLine||(a+=` (Browser is offline)`),V.warn(a),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),this._queue.length===0)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){let e=Date.now(),t=[],n=this._queue.filter(n=>e>n.retryAt||(t.push(n),!1));if(this._queue=t,n.length>0)for(let{requestOptions:e}of n)this.retriableRequest(e)}unload(){this._poller&&=(clearTimeout(this._poller),void 0),this._isPolling=!1,P(D)||(this._onlineListener&&=(D.removeEventListener(`online`,this._onlineListener),void 0),this._offlineListener&&=(D.removeEventListener(`offline`,this._offlineListener),void 0));for(let{requestOptions:e}of this._queue)try{this._instance._send_request(B(B({},e),{},{transport:`sendBeacon`}))}catch(e){V.error(e)}this._queue=[]}},bc=class{constructor(e){this._instance=e,this._updateScrollData=()=>{this._context||={};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._context.lastScrollY=Math.ceil(t),this._context.maxScrollY=Math.max(t,this._context.maxScrollY??0),this._context.maxScrollHeight=Math.max(n,this._context.maxScrollHeight??0),this._context.lastContentY=r,this._context.maxContentY=Math.max(r,this._context.maxContentY??0),this._context.maxContentHeight=Math.max(i,this._context.maxContentHeight??0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){let e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){G(D,`scroll`,this._updateScrollData,{capture:!0}),G(D,`scrollend`,this._updateScrollData,{capture:!0}),G(D,`resize`,this._updateScrollData)}scrollElement(){if(this._scrollRoot){let t=j(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(let n of t){var e;let t=D==null||(e=D.document)==null?void 0:e.querySelector(n);if(t)return t}return}var t;return D==null||(t=D.document)==null?void 0:t.documentElement}_scrollPosition(e){var t,n;let r=e===`y`?`scrollTop`:`scrollLeft`;if(this._scrollRoot){let e=this.scrollElement();return e&&e[r]||0}return D?e===`y`?D.scrollY||D.pageYOffset||((t=D.document)==null||(t=t.documentElement)==null?void 0:t.scrollTop)||0:D.scrollX||D.pageXOffset||((n=D.document)==null||(n=n.documentElement)==null?void 0:n.scrollLeft)||0:0}scrollY(){return this._scrollPosition(`y`)}scrollX(){return this._scrollPosition(`x`)}},xc=e=>Uo(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),Sc=class{constructor(e,t,n,r){this._onSessionIdCallback=e=>{let t=this._getStored();if(t&&t.sessionId===e)return;let n={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[ze]:n})},this._instance=e,this._sessionIdManager=t,this._persistence=n,this._sessionSourceParamGenerator=r||xc,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[ze]}getSetOnceProps(){let e=this._getStored()?.props;return e?`r`in e?Wo(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(Xi(this.getSetOnceProps()),(t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_${kt(n)}`]=t}),e}},Cc=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(let n of this._events[e]||[])n(t);for(let n of this._events[`*`]||[])n(e,t)}constructor(){this._events={}}},wc=H(`[SessionId]`),Tc=864e5,Ec=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,n){var r;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedH
1andlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Cc,this._sessionHasBeenIdleTooLong=(e,t)=>!(!It(e)||!It(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._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||sa,this._windowIdGenerator=n||sa;let i=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Zt(this._config.session_idle_timeout_seconds||1800,60,36e3,wc.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key=`ph_`+i+`_window_id`,this._primary_window_exists_storage_key=`ph_`+i+`_primary_window_exists`,this._canUseSessionStorage()){let e=J._parse(this._window_id_storage_key),t=J._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:J._remove(this._window_id_storage_key),J._set(this._primary_window_exists_storage_key,!0)}(r=this._config.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return this._config.persistence!==`memory`&&!this._persistence._disabled&&J._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&J._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?J._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){let t=this._lastPersistedActivityTimestamp;return!I(t)&&!I(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,n){let r=t!==this._sessionActivityTimestamp,i=e===this._sessionId&&n===this._sessionStartTimestamp;this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this._sessionId=e,i&&!r||i&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[w]:[t,e,n]}))}_useCrossTabRefreshHardening(){let e=this._config?.persistence_save_debounce_ms;return It(e)&&e>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(w):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){if(I(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();let[,e,t]=this._getSessionId();e===this._sessionId&&t===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[w]:[this._sessionActivityTimestamp,this._sessionId??null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){let[e]=this._getSessionId(),t=It(e)?e:0,n=It(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){let e=this._persistence.props[w];return j(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(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 wc.error(`Bootstrap sessionID cannot be in the future`):n}catch(e){wc.error(`Invalid sessionID in bootstrap`,e);return}})(e);return!P(n)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:n}:this._setSessionId(e,new Date().getTime(),n),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&D&&(D.removeEventListener(lt,this._beforeUnloadListener,{capture:!1}
1),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&J._remove(this._primary_window_exists_storage_key)},G(D,lt,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,n=!1){if(this._config.cookieless_mode===`always`)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);let r=t||new Date().getTime(),i=this._sessionId;if(n)this._lastCookieSyncTimestamp=r;else if(I(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>r||r-this._lastCookieSyncTimestamp>=1e3){var a,o;(a=(o=this._persistence).syncCookieProperties)==null||a.call(o),this._lastCookieSyncTimestamp=r}let[,s,c]=this._getSessionId(),l=!P(i)&&s!==i,u=this._freshestActivityTimestamp(),d=this._getWindowId(),f=this._pendingBootstrapSession,p=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>Tc),m=f?p:It(c)&&Math.abs(r-c)>Tc,h=!1,g=l,_=!s||!!f,v=s,y=!_&&!e&&this._sessionHasBeenIdleTooLong(r,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(r),y||wc.info(`cross-tab refresh kept the session alive`,{sessionId:s}),[,s,c]=this._getSessionId()),_||y||m){g=!1;let e=f&&!p;s=e?f.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),wc.info(`new session ID assigned`,{sessionId:s,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m}}),c=e?f.sessionStartTimestamp:r,this._pendingBootstrapSession=void 0,h=!0}else d||(d=this._windowIdGenerator(),h=!0),g||=s!==v,g&&(wc.info(`adopted cross-tab session id`,{sessionId:s,windowId:d}),h=!0);let b=It(u)&&e&&!m?u:r,x=It(c)?c:new Date().getTime();this._setWindowId(d),this._setSessionId(s,b,x),e||this._resetIdleTimer();let ee={noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m,crossTabAdoption:g};return h&&this._sessionIdChangedHandlers.forEach(e=>e(s,d,ee)),{sessionId:s,windowId:d,sessionStartTimestamp:x,changeReason:h?ee:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed){if(this._isSessionIdleAfterCrossTabRefresh(new Date().getTime())){let e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit(`forcedIdleReset`,{idleSessionId:e})}else this._resetIdleTimer()}},1.1*this.sessionTimeoutMs))}},Dc=function(e,t){if(!e)return!1;let n=e.userAgent;if(n&&Xt(n,t))return!0;try{let n=e?.userAgentData;if(n?.brands&&n.brands.some(e=>Xt(e?.brand,t)))return!0}catch{}return!!e.webdriver};function Oc(){return(Oc=z(function*(){let e=ht?.userAgentData;if(e?.getHighEntropyValues)try{let t=(yield e.getHighEntropyValues([`model`]))?.model;return F(t)&&t.length>0?t:void 0}catch(e){V.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}})).apply(this,arguments)}function kc(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 Ac(e){var t;return!!((t=e.conditions)!=null&&(t=t.events)!=null&&(t=t.values)!=null&&t.length)}var jc=(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}},Mc=e=>e.toLowerCase(),Nc={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=>jc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!jc(t,e))),icontains:(e,t)=>t.map(Mc).some(t=>e.map(Mc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(Mc).every(t=>e.map(Mc).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 Pc(e,t){return!e||Object.entries(e).every(([e,n])=>{let r=t?.[e];if(r==null)return!1;let i=Nc[n.operator];return!!i&&i(n.values,[String(r)])})}function Fc(e,t,n){return To({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Ic=`custom`,Lc=`i.posthog.com`,Rc=/^\/static\//,zc=[`/s/`,`/e/`,`/i/`],Bc=class{constructor(e){this._regionCache={},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(`.${Lc}`,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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`:Ic),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!Rc.test(e))return;let t=this.instance.config.asset_host;return typeof t==`string`&&t.trim().replace(/\/$/,``)||void 0}_urlKey(e){let t=Eo(e);return t?t.protocol+`//`+t.host+t.pathname:void 0}_prepareEndpoint(e,t,n){if(e===`ui`)return n;let r=n,i=this.instance.config.rewriteRequestPath;if(i){let e=Eo(n)?.href||n;r=i(new URL(e)).toString()}if(i&&e===`api`&&zc.some(e=>t.indexOf(e)===0)){let e=this._urlKey(r);if(e){let t=this.apiHost,n=this._ingestionEndpoints;n?.apiHost===t&&n.rewriteRequestPath===i||(n={apiHost:t,rewriteRequestPath:i,urls:new Set},this._ingestionEndpoints=n),n.urls.add(e)}}return r}isIngestionEndpoint(e){let t=this._ingestionEndpoints,n=this._urlKey(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._prepareEndpoint(e,t,this.uiHost+t);if(e===`flags`)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if(e===`assets`){let n=this._staticAssetHostOverride(t);if(n)return this._prepareEndpoint(e,t,`${n}${t}`)}if(this.region===Ic)return this._prepareEndpoint(e,t,this.apiHost+t);let n=Lc+t;switch(e){case`assets`:return this._prepareEndpoint(e,t,`https://${this.region}-assets.${n}`);case`api`:return this._prepareEndpoint(e,t,`https://${this.region}.${n}`)}}},$=H(`[Surveys]`),Vc=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)}},Hc=[ss.Popover,ss.Widget,ss.API],Uc={ignoreConditions:!1,ignoreDelay:!1,displayType:us.Popover}
1,Wc=H(`[PostHog ExternalIntegrations]`),Gc={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},Kc=class{constructor(e){this._instance=e}_loadScript(e,t){var n,r;(n=k.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,e,e=>{if(e)return Wc.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=k.__PosthogExtensions__)!=null&&(e=e.integrations)!=null&&e[r])&&this._loadScript(Gc[r],()=>{var e;(e=k.__PosthogExtensions__)==null||(e=e.integrations)==null||(e=e[r])==null||e.start(this._instance)}),!i&&(t=k.__PosthogExtensions__)!=null&&(t=t.integrations)!=null&&t[r]&&((n=k.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[r])==null||n.stop())}}},qc=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return z(function*(){if(t._disposed)throw Error(`Cannot add an extension to a disposed ExtensionRuntime`);if(t._extensions.has(e.name))throw Error(`Browser extension "${e.name}" is already registered`);t._extensions.set(e.name,e);try{let n=e.setup(t._client);n&&(yield n)}catch(n){let r=t._extensions.get(e.name)===e;r&&t._extensions.delete(e.name),t._logger.error(`Failed to set up browser extension "${e.name}"`,n),r&&t._disposeExtension(e)}})()}getExtension(e){return this._extensions.get(e)}dispose(){if(this._disposed)return;this._disposed=!0;let e=Array.from(this._extensions.values()).reverse();this._extensions.clear();for(let t of e)this._disposeExtension(t)}_disposeExtension(e){try{let t=e.dispose?.call(e);t&&M(t.then)&&t.then(void 0,t=>{this._logger.error(`Failed to dispose browser extension "${e.name}"`,t)})}catch(t){this._logger.error(`Failed to dispose browser extension "${e.name}"`,t)}}},Jc=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);P(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)}},Yc=`extensionsRemoteConfig`,Xc=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=V,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new Jc(e),this.onEvent=e=>ds(this.instance.on(`eventCaptured`,t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error(`Browser extension event listener failed`,e)}})),this.onRemoteConfig=e=>{if(this._disposed)return ds(()=>{});let t=t=>{try{e(t)}catch(e){this._logger.error(`Browser extension remote config listener failed`,e)}},n=this.instance._internalEventEmitter.on(Yc,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),ds(n)},this._runtime=new qc(V.createLogger(`[BrowserExtensions]`),this)}get logger(){return this._logger}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(i);return typeof e==`string`?e:void 0}get library(){return{name:t.LIB_NAME,version:t.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._runtime.add(e)}getExtension(e){return this._runtime.getExtension(e)}capture(e,t,n){var r=this;return z(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 ds(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(Yc,e))}sendRequest(e){var t=this;return z(function*(e,n={}){let r=t.instance.requestRouter.endpointFor(n.target??`api`,e),i={method:n.method,url:n.query?nc(r,n.query
1):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`?Tt.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._disposed||(this._disposed=!0,this._runtime.dispose())}},Zc={},Qc=0,$c=()=>{},el=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,tl=`Surveys module not available`,nl=`sanitize_properties is deprecated. Use before_send instead`,rl=`Invalid value for property_denylist config: `,il=/^[A-Za-z0-9_-]{1,400}$/,al=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,ol=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,sl=[`token`,`distinct_id`,Ke],cl=`posthog`,ll=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},ul=e=>{var t;return B({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:$i(O?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:$c,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:gt&&F(gt?.search)&&gt.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:(D==null||(t=D.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){V.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:st,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:$c},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:Wa,ignore_text_selection:!0}
1:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:ll(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)}))(e))},dl=[[`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`]],fl=e=>{let t={};for(let[n,r]of dl)P(e[n])||(t[r]=e[n]);let n=W({},t,e),r=e.__preview_external_dependency_versioned_paths;return P(r)||(P(e.strict_script_versioning)&&(n.strict_script_versioning=!!r),F(r)&&P(e.asset_host)&&(n.asset_host=r)),j(e.property_blacklist)&&(P(e.property_denylist)?n.property_denylist=e.property_blacklist:j(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:V.error(rl+e.property_denylist)),n},pl=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ml=class n{_removeExtension(e){if(!e)return;let t=this._extensions.indexOf(e);t!==-1&&this._extensions.splice(t,1)}_replaceExtension(e,t){var n;return this._removeExtension(e),this._extensions.push(t),(n=t.initialize)==null||n.call(t),t}_inCookielessMode(){return this.config.cookieless_mode===`always`||this.config.cookieless_mode===`on_reject`&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity||this.config.reuseAnonymousId||this.config.segment||this._inCookielessMode())return;let e=this.config.persistence===`memory`||this.config.persistence===`sessionStorage`;if(!e&&!this.config.disable_persistence||this._hasStableInitialDistinctId)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._hasWarnedAboutVolatileIdentity=!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}`)}_healCookielessSentinelDistinctId(){if(this._inCookielessMode()||this.get_distinct_id()!==`$posthog_cookieless`)return;let e=this.persistence;if(!e)return;this._is_persistence_disabled()||e.load(!0);let t=this.get_distinct_id();if(!t||t===`$posthog_cookieless`){let t=this.config.get_device_id(sa());this.register({distinct_id:t,$device_id:t}),e.set_property(Re,at)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new pl,this._personProcessingSetOncePropertiesSent=!1,this.version=t.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey=``,this._internalEventEmitter=new Cc,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ul(),this.SentryIntegration=bo,this.sentryIntegration=e=>function(e,t){let n=yo(e,t);return{name:vo,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new bc(this),this.pageViewM
1anager=new xo(this),this.rateLimiter=new hs(this),this.requestRouter=new Bc(this),this.consent=new Ea(this),this.externalIntegrations=new Kc(this);let e=n.__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=F(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{let r=F(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,e=>V.info(`send "${e?.event}"`,e))}init(e,t,r){if(r&&r!==cl){let i=Zc[r]??new n;return i._init(e,t,r),Zc[r]=i,Zc[cl][r]=i,i}return this._init(e,t,r)}_init(e,n={},r){var i;let o=F(e)?e.trim():``;if(!o)return V.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 o===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('${o}', { ... }, 'project2')`),this;this.__loaded=!0,this.config=ul(n.defaults),n.debug=this._checkLocalStorageForDebug(n.debug),this._originalUserConfig=n,this._triggered_notifs=[],n.person_profiles?this._initialPersonProfilesConfig=n.person_profiles:n.process_person&&(this._initialPersonProfilesConfig=n.process_person);let s=ul(n.defaults),c=fl(n),l=W({},s,c,{name:r,token:o});N(s.rageclick)&&N(c.rageclick)&&(l.rageclick=W({},s.rageclick,c.rageclick)),N(s.session_recording)&&N(c.session_recording)&&(l.session_recording=W({},s.session_recording,c.session_recording)),this.set_config(l),this.config.on_xhr_error&&V.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=n.disable_compression?void 0:as.GZipJS;let u=this._is_persistence_disabled();if(this.persistence=new is(this.config,u),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new is(B(B({},this.config),{},{persistence:`sessionStorage`}),u,!1),this._sessionRegisteredPropertiesStorageKey=`ph_`+(this.config.persistence_name||this.config.token)+`_session_registered_properties`,this.config.persistence!==`memory`&&!u&&J._is_supported()){let e=J._parse(this._sessionRegisteredPropertiesStorageKey);j(e)&&e.forEach(e=>{F(e)&&this._sessionRegisteredPropKeys.add(e)})}else J._remove(this._sessionRegisteredPropertiesStorageKey);let d=B({},this.persistence.props),f=B({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this._requestQueue=new _c((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new yc(this),this.__request_queue=[];let p=this._inCookielessMode();p||(this.sessionManager=new Ec(this),this.sessionPropsManager=new Sc(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,n)=>{(n!=null&&n.activityTimeout||n!=null&&n.sessionPastMaximumLength||n!=null&&n.crossTabAdoption)&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(V.info(`Deferring extension initialization to improve startup performance`),setTimeout(()=>{this._initExtensions(p)},0)):(V.info(`Initializing extensions synchronously`),this._initExtensions(p)),t.DEBUG=t.DEBUG||this.config.debug,t.DEBUG&&V.info(`Starting in debug mode`,{this:this,config:n,thisC:B({},this.config),p:d,s:f}),this.config.identity_distinct_id&&!((i=n.bootstrap)!=null&&i.distinctID)&&(n.bootstrap=B(B({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let m=n.bootstrap?.distinctID;if(this._hasStableInitialDistinctId=!!m&&!Ft(m),n.bootstrap?.distinctID){let e=n.bootstrap.distinctID,t=this.get_distinct_id(),r=this.persistence.get_property(Re);if(n.bootstrap.isIdentifiedID&&t!=null&&t!==e&&r===`anonymous`)this.identify(e);else if(n.bootstrap.isIdentifiedID&&t!=null&&t!==e&&r===`identified`)V.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(sa()),r=n.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(Re,n.bootstrap.isIdentifiedID?ot:at),this.register({distinct_id:e,$device_id:r})}}if(p)this.register_once({distinct_id:Ge,$device_id:null},``);else if(!this.get_distinct_id()){let e=this.config.get_device_id(sa());this.register_once({distinct_id:e,$device_id:e},``),this.persistence.set_property(Re,at)}return G(D,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),G(D,`pageshow`,()=>{var e;this._isPageUnloading=!1,this._isShutdown||(e=this._retryQueue)==null||e.resume()}),n.segment?_o(this,()=>this._loaded()):this._loaded(),M(this.config._onCapture)&&this.config._onCapture!==$c&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,e=>this.config._onCapture(e.event,e))),this.config.ip&&V.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 Oc.apply(this,arguments)}().then(e=>{e&&this.register({[a]:e})}).catch($c),this}_isSharedExtension(e){let t=e;return F(t.name)&&M(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>
1e.dispose?.call(e)).catch(t=>{V.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this._extensions.push(e)}_enrollFeatureFlags(){let e=this.config.__extensionClasses?.featureFlags??n.__defaultExtensionClasses?.featureFlags;var t,r,i;e&&(this.featureFlags&&this.featureFlags instanceof e||((t=this._featureFlagsReloadingUnsubscribe)==null||t.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new e(this)),M(this.featureFlags.onReloading)&&M(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit(`featureFlagsReloading`,!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):(r=(i=this.featureFlags).initialize)==null||r.call(i))}_initExtensions(e){let t=performance.now(),r=B(B({},n.__defaultExtensionClasses),this.config.__extensionClasses),i=[];r.exceptions&&this._extensions.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this._extensions.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this._extensions.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this._extensions.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.autocapture&&this._enrollExtension(this.autocapture=new r.autocapture(this),i),r.surveys&&this._enrollExtension(this.surveys=this.surveys??new r.surveys(this),i),r.logs&&this._enrollExtension(this.logs=this.logs??new r.logs(this),i),r.metrics&&this._extensions.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this._extensions.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this._extensions.push(this.productTours=new r.productTours(this)),r.heatmaps&&this._extensions.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this._extensions.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,mo)),r.toolbar&&this._extensions.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this._extensions.push(this.experiments=this.experiments??new r.experiments(this)),this._extensions.forEach(e=>{e.initialize&&i.push(()=>{var t;(t=e.initialize)==null||t.call(e)})}),i.push(()=>{if(this._pendingRemoteConfig){let e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>t.onRemoteConfig?.call(t,e))}}),this._processInitTaskQueue(i,t)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this._processInitTaskQueue(e,t)},0);let n=e.shift();if(n)try{n()}catch(e){V.error(`Error initializing extension:`,e)}}let n=Math.round(performance.now()-t);this.register_for_session({[qe]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Je]:n}),this.config.__preview_deferred_init_extensions&&V.info(`PostHog extensions initialized (${n}ms)`)}_onRemoteConfig(e){var t;if(!O||!O.body)return V.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var n;let t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=A(t.supportedCompression,as.GZipJS)?as.GZipJS:A(t.supportedCompression,as.Base64)?as.Base64:void 0),(n=t.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:st}),(t=this._browserClientAdapter)==null||t.handleRemoteConfig(e),this._extensions.forEach(t=>t.onRemoteConfig?.call(t,e))}_loaded(){try{this.config.loaded(this)}catch(e){V.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&gt?.hostname){let e=gt.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._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new _s(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&((e=this._requestQueue)==null||e.enable())}_dom_loaded(){this.is_capturing()&&qi(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,n,r,i,a;this._isPageUnloading=!0,(e=this.surveys)==null||(t=e.handlePageUnload)==null||t.call(e),(n=this.metrics)==null||n.flush(`sendBeacon`),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(dt),(r=this.logs)==null||r.flushLogs(`sendBeacon`),(i=this._requestQueue)==null||i.unload(),(a=this._retryQueue)==null||a.unload()):this._shouldCapturePageleave()&&this.capture(dt,null,{transport:`sendBeacon`})}_send_request(e){gc(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?B(B({},e),{},{transport:t}):e)}_execute_array(e){Qc++;try{let t,n=[],r=[],i=[];qi(e,e=>{if(e){if(t=e[0],j(t))i.push(e);else if(M(e))try{e.call(this)}catch(t){V.error(`Error executing queued PostHog call`,e,t)}else j(e)&&t===`alias`?n.push(e):j(e)&&t.indexOf(`capture`)!==-1&&M(this[t])?i.push(e):r.push(e)}});let a=function(e,t){qi(e,function(e){try{if(j(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){V.error(`Error executing queued PostHog call`,e,t)}})};a(n,this),a(r,this),a(i,this)}finally{Qc--}}push(e){if(Qc>0&&j(e)&&F(e[0])){let t=n.prototype[e[0]];M(t)&&t.apply(this,e.slice(1));return}this._execute_array([e])}get _facebookClickIdChannel(){return{property:c,persistenceKey:l,cookieName:`_fbc`,pattern:al,register:(e,t)=>this.persistence?.register({[l]:{value:e,delivered:t}}),unregister:()=>this.persistence?.unregister(l)}}get _facebookBrowserIdChannel(){return{property:u,persistenceKey:d,cookieName:`_fbp`,pattern:ol,register:(e,t)=>this.persistence?.register({[d]:{value:e,delivered:t}}),unregister:()=>this.persistence?.unregister(d)}}_getPersistedMetaIdentifier(e){let t=this.persistence?.get_property(e.persistenceKey);return F(t)&&e.pattern.test(t)?{value:t,delivered:!1}:N(t)&&F(t.value)&&e.pattern.test(t.value)?{value:t.value,delivered:!0===t.delivered}:void 0}_storeMetaIdentifier(e,t,n){return t===n?.value?{value:t,pending:!n.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;let t=ta(e.cookieName);return F(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,n,r){if(!this.persistence)return;let i=this._facebookClickIdChannel;this.persistence.refreshKey(i.persistenceKey);let a=this._getPersistedMetaIdentifier(i);if(r)return void i.unregister();if(n)return F(t)&&al.test(t)?this._storeMetaIdentifier(i,t,a):void i.unregister();let o=F(e)&&il.test(e)?e:void 0,s=this._readMetaCookie(i);return s&&((e,t,n)=>{let r=e.split(`.`);if(t)return r[3]===t;if(!n)return!0;let i=n.value.split(`.`);return r[3]===i[3]||Number(r[2])>Number(i[2])})(s,o,a)?this._storeMetaIdentifier(i,s,a):o?a?.value.split(`.`)[3]===o?{value:a.value,pending:!a.delivered}:this._storeMetaIdentifier(i,`fb.1.${Date.now()}.${o}`,a):a?{value:a.value,pending:!a.delivered}:void 0}
1_updateFacebookBrowserId(e,t,n){if(!this.persistence)return;let r=this._facebookBrowserIdChannel;this.persistence.refreshKey(r.persistenceKey);let i=this._getPersistedMetaIdentifier(r);if(n)return void r.unregister();if(t)return F(e)&&ol.test(e)?this._storeMetaIdentifier(r,e,i):void r.unregister();let a=this._readMetaCookie(r);return a?this._storeMetaIdentifier(r,a,i):i?{value:i.value,pending:!i.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);let n=this._getPersistedMetaIdentifier(e);n?.value!==t||n.delivered||e.register(t,!0)}capture(e,t,n){if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void V.uninitializedWarning(`posthog.capture`);if(!this.is_capturing())return;if(P(e)||!F(e))return void V.error(`No event name provided to posthog.capture`);this._healCookielessSentinelDistinctId();let r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;let i=n?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(i?.isRateLimited)return void V.critical(`This capture call is ignored due to client rate limiting.`);let a;t!=null&&t.$current_url&&!F(t?.$current_url)&&(V.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._originatedFromCaptureException||V.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&&(a=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 o=new Date,s=n?.timestamp||o,l=ur(n?.uuid,sa),d={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},s,l)};e===`$pageview`&&this.config.__preview_capture_bot_pageviews&&r&&(d.event=`$bot_pageview`,d.properties.$browser_type=`bot`),i&&(d.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens);let f=e===`$feature_flag_called`&&!1===d.properties.$feature_flag_has_experiment&&!0===this.get_property(`$minimal_flag_called_events`);n!=null&&n.$set&&!f&&(d.$set=n?.$set);let p=N(t?.$set)?t.$set:void 0,m=j(t?.$unset)?t.$unset:[],h=n?.$unset||[],g=e=>{var t;let r=!!n?.$set&&e in n.$set;return{hasProvided:r||!!p&&e in p,provided:r?n==null||(t=n.$set)==null?void 0:t[e]:p?.[e],unset:m.indexOf(e)!==-1||h.indexOf(e)!==-1}},_=g(c),v=g(u),y=[{channel:this._facebookClickIdChannel,hasProvided:_.hasProvided,update:this._updateFacebookClickId(a?.fbclid,_.provided,_.hasProvided,_.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:v.hasProvided,update:this._updateFacebookBrowserId(v.provided,v.hasProvided,v.unset)}];for(let{channel:e,hasProvided:t,update:n}of y)n&&!0===d.properties.$process_person_profile&&n.pending&&!t&&!f&&(d.$set=B({[e.property]:n.value},d.$set));let b=n?.$unset;b&&(d.$unset=b);let x=f?void 0:this._calculate_set_once_properties(n?.$set_once,e!==pt,e===ft);if(x&&(d.$set_once=x),n!=null&&n._noTruncate||(ee=this.config.properties_string_max_length,d=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),j(r))a=[],qi(r,t=>{a.push(e(t))});else{let t={};U(Ht(r)?Zi(r):r,(r,i)=>{n.has(r)||(t[i]=e(r,i))}),a=t}return a}(e)}(d,e=>F(e)?e.slice(0,ee):e)),d.timestamp=s,P(n?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=o),f&&(d.properties=((e,t=[])=>{let n={},r=t=>{e[t]!==void 0&&(n[t]=e[t])};return fi.forEach(r),t.forEach(r),n})(d.properties,sl)),e===cs.DISMISSED||e===cs.SENT){let n=t?.[ls.SURVEY_ID],r=t?.[ls.SURVEY_ITERATION];Vc({id:n,current_iteration:r}),d.$set=B(B({},d.$set),{},{[kc({id:n,current_iteration:r},e===cs.SENT?`responded`:`dismissed`)]:!0})}else e===cs.SHOWN&&(d.$set=B(B({},d.$set),{},{[ls.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var ee;if(e===fs.SHOWN){let e=t?.[ps.TOUR_TYPE];e&&(d.$set=B(B({},d.$set),{},{[`${ps.TOUR_LAST_SEEN_DATE}/${e}`]:new Date().toISOString()}))}let S=B(B({},d.properties.$set),d.$set);if(Pt(S)||this.setPersonPropertiesForFlags(S),!L(this.config.before_send)){let e=this._runBeforeSend(d);if(!e)return;d=e,d.uuid=ur(d.uuid,sa)}let C=y.filter(({channel:e,update:t})=>{let n=d.$set?.[e.property]??(N(d.properties?.$set)?d.properties.$set[e.property]:void 0);return t?.pending&&n===t.value});this._internalEventEmitter.emit(`eventCaptured`,d);let te=n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),ne=n?._batchKey===`recordings`||/\/s\/(?:\?|$)/.test(te),re=B(B(B({method:`POST`,url:te,data:d,compression:`best-available`,timestampMode:ne?`body`:`capture-body`,batchKey:n?._batchKey},ne&&d.properties?.$session_id?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:``)}
1:{}),n?.transport?{transport:n.transport}:{}),C.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(let{channel:e,update:t}of C)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||n&&!n?._batchKey||n?.send_instantly||C.length){let e;!re.transport&&!re.callback&&Pt(this.config.request_headers??{})&&this._isPageUnloading&&(e=`sendBeacon`),this._send_retriable_request(re,e)}else this._requestQueue.enqueue(re);return d}_addCaptureHook(e){return this.on(`eventCaptured`,t=>e(t.event,t))}getExtension(e){return this._browserClientAdapter?.getExtension(e)}_getBrowserClientAdapter(){return this._browserClientAdapter??=new Xc(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this._extensionEventPropertyProducers.indexOf(e);n!==-1&&this._extensionEventPropertyProducers.splice(n,1)}}_processCookieIdentityChange(e=!0){var t,n;return!!this.persistence?.consumeCookieIdentityChange()&&(this._cachedPersonProperties=null,this.persistence.get_property(`$user_state`)===`anonymous`&&((n=this.sessionPersistence)==null||n.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),(t=this.featureFlags)==null||t.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,r,i,a){if(r||=new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this._processCookieIdentityChange();let o=a?void 0:this.persistence.remove_event_timer(t),s=B({},n);if(s.token=this.config.token,s.$config_defaults=this.config.defaults,this._inCookielessMode()&&(s[Ke]=!0),t===`$snapshot`){let e=B(B({},this.persistence.properties()),this.sessionPersistence.properties());return s.distinct_id=e.distinct_id,(!F(s.distinct_id)&&!R(s.distinct_id)||Ft(s.distinct_id))&&V.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),s}let c=function(t,n,r,i=!1){var a,o,s;if(!xt)return{};let c=t?[...Mo,...n||[]]:[],[l,u]=Qn(xt),[d,f]=function(e){for(let t=0;nr.length>t;t++){let[n,r,i]=nr[t],a=e.match(n);if(a)return[r,(i&&e.match(i)||a)?.[1]||``]}return[``,``]}(xt),p=function(){return(`u`>typeof navigator?navigator:void 0)?.brave?{brave:!0}:{}}(),m={};P(r)||(m.detectGoogleSearchApp=r);let h={},g=(a=navigator)==null||(a=a.userAgentData)==null?void 0:a.platform,_=navigator?.maxTouchPoints,v=D==null||(o=D.screen)==null?void 0:o.width,y=D==null||(s=D.screen)==null?void 0:s.height,b=D?.devicePixelRatio;P(g)||(h.userAgentDataPlatform=g),P(_)||(h.maxTouchPoints=_),P(v)||(h.screenWidth=v),P(y)||(h.screenHeight=y),P(b)||(h.devicePixelRatio=b);let x=W(Xi({$os:l,$os_version:u,$browser:Jn(xt,navigator.vendor,p,m),$webview_app:d,$webview_app_version:f,$device:$n(xt),$device_type:er(xt,h),$timezone:Go(),$timezone_offset:Ko()}),{$current_url:Oo(i?fr(gt?.href):gt?.href,c,Po),$host:gt?.host,$pathname:gt?.pathname,$raw_user_agent:xt.length>1e3?xt.substring(0,997)+`...`:xt,$browser_version:Xn(xt,navigator.vendor,p,m),$browser_language:zo(),$browser_language_prefix:Bo(),$screen_height:D?.screen.height,$screen_width:D?.screen.width,$viewport_height:D?.innerHeight,$viewport_width:D?.innerWidth,$lib:e.LIB_NAME,$lib_version:e.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return e.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=e.SDK_DIST_CHANNEL),x}(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(a,r.getTime(),!0);s.$session_id=e,s.$window_id=t}this.sessionPropsManager&&W(s,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&W(s,this.sessionRecording.sdkDebugProperties),s.$sdk_debug_retry_queue_size=this._retryQueue?.length}catch(e){s.$sdk_debug_error_capturing_properties=String(e)}let l;if(this.requestRouter.region===Ic&&(s.$lib_custom_api_host=this.config.api_host),l=t!==`$pageview`||a?t!==`$pageleave`||a?this.pageViewM
1anager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),s=W(s,l),t===`$pageview`&&O&&(s.title=O.title),!P(o)){let e=r.getTime()-o;s.$duration=parseFloat((e/1e3).toFixed(3))}xt&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?`bot`:`browser`);let u=this.persistence.properties(),d=this.sessionPersistence.properties(),f=s.$groups,p=u.$groups;N(f)&&!Pt(f)&&(s.$groups=B(B({},N(p)?p:{}),f)),U([`$referrer`,`$referring_domain`],e=>{e in u&&delete d[e]});let m={};if(this._extensionEventPropertyProducers.length>0)for(let e of this._extensionEventPropertyProducers.slice())try{W(m,e())}catch(e){V.error(`Failed to produce browser extension event properties`,e)}s=W({},c,u,d,B(B({},m),s)),s.$is_identified=this._isIdentified(),j(this.config.property_denylist)?U(this.config.property_denylist,function(e){delete s[e]}):V.error(rl+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);let h=this.config.sanitize_properties;h&&(V.error(nl),s=h(s,t));let g=this._hasPersonProcessing();return s.$process_person_profile=g,g&&!a&&this._requirePersonProcessing(`_calculate_event_properties`),s}_calculate_set_once_properties(e,t=!0,n=!1){if(!this.persistence||!this._hasPersonProcessing()||this._personProcessingSetOncePropertiesSent&&!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&&(V.error(nl),a=o(a,`$set_once`)),t&&(this._personProcessingSetOncePropertiesSent=!0),Pt(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._processCookieIdentityChange(),(n=this.sessionPersistence)==null||n.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}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._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){if(!this._sessionRegisteredPropertiesStorageKey)return;if(this.config.persistence===`memory`||this.sessionPersistence?._disabled||!J._is_supported())return void J._remove(this._sessionRegisteredPropertiesStorageKey);let e=[];this._sessionRegisteredPropKeys.forEach(t=>e.push(t)),e.length>0?J._set(this._sessionRegisteredPropertiesStorageKey,e):J._remove(this._sessionRegisteredPropertiesStorageKey)}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._internalEventEmitter.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:tl}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:tl})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:tl})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t=Uc){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:tl}}canRenderSurveyAsync(e,t=!1){return this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:tl})}_validateIdentifyId(e){return!e||Ft(e)?(V.critical(`Unique user id has not been set in posthog.identify`),!1):e===`$posthog_cookieless`?(V.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())||(V.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID should be unique to the user and n
1ot a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return V.uninitializedWarning(`posthog.identify`);if(R(e)&&(e=e.toString(),V.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),!this._validateIdentifyId(e)||!this._requirePersonProcessing(`posthog.identify`))return;this._healCookielessSentinelDistinctId();let r=this.get_distinct_id(),i=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this._processCookieIdentityChange(!1),s=this.persistence._beginCookieSyncSuppression(),c=!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(o),this.register({distinct_id:e}));let s=(this.persistence.get_property(`$user_state`)||`anonymous`)===at,u=e!==r,d=!u&&s;if(u&&s){var l;let i=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:r};this.persistence.set_property(Re,ot),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture(`$identify`,i,{$set:t||{},$set_once:n||{}})&&(this._cachedPersonProperties=Fc(e,t,n)),(l=this.featureFlags)==null||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:r)}else if(d){this.persistence.set_property(Re,ot);let r=t||{},i=n||{};this.setPersonPropertiesForFlags({$set:r,$set_once:i},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture(`$set`,{$set:r,$set_once:i})&&(this._cachedPersonProperties=Fc(e,t,n))}else(t||n)&&this.setPersonProperties(t,n);u||i||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Pe)):d&&(t||n)&&this.reloadFeatureFlags(),c=!0}finally{s&&this.persistence._endCookieSyncSuppression(c)}}setPersonProperties(e,t){if(!e&&!t||!this._requirePersonProcessing(`posthog.setPersonProperties`))return;let n=Fc(this.get_distinct_id(),e,t);this._cachedPersonProperties===n?V.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._cachedPersonProperties=n))}unsetPersonProperties(e){var t;let n=(j(e)?e:[e]).filter(e=>F(e)&&e.length>0);n.length!==0&&this._requirePersonProcessing(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this._cachedPersonProperties=null)}group(e,t,n){var r;if(!e||!t)return void V.error(`posthog.group requires a group type and group key`);(r=this.persistence)==null||r.syncCookieProperties(),this._processCookieIdentityChange();let i=this.getGroups(),a=i[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:B(B({},i),{},{[e]:t})}),(a||n)&&this._hasPersonProcessing()){let r={$group_type:e,$group_key:t};n&&(r.$group_set=n),this.capture(pt,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._requirePersonProcessing(`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=Lt(e)?e:e?.resetDeviceID,n=Lt(e)||e==null?void 0:e.bootstrap;this._reset(t,!1,n)}_reset(e,t=!1,n){var r,o,s,c,l;if(V.info(`reset`),!this.__loaded)return V.uninitializedWarning(`posthog.reset`);let u=n?.sessionID;this.config.bootstrap=n||this._originalUserConfig?.bootstrap||{},(r=this.featureFlags)==null||(o=r.updateConfig)==null||o.call(r,this.config,this._shouldDisableFlags());let d=this.get_property(i),f=this.get_property(a),p=this.get_property(S);(s=this.sessionRecording)==null||s.flushBeforeIdentityReset();let m=this.is_capturing();this.consent.reset(),t||!m||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 h=(c=this.persistence)==null||(l=c._beginCookieSyncSuppression)==null?void 0:l.call(c),g=!1;try{var _,v,y,b,x,ee,C,te,ne,re,ie,ae;if((_=this.persistence)==null||_.clear(),(v=this.sessionPersistence)==null||v.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),P(p)||(re=this.persistence)==null||re.register({$session_recording_remote_config:p}),(y=this.surveys)==null||y.reset(),(b=this.featureFlags)==null||b.reset(),(x=this.conversations)==null||x.reset(),(ee=this.logs)==null||ee.reset(),(C=this.metrics)==null||C.reset(),(te=this.persistence)==null||te.set_property(`$user_state`,`anonymous`),(ne=this.sessionManager)==null||ne.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===`always`)this.register_once({distinct_id:Ge,$device_id:null},``);else{let t=this.config.get_device_id(sa());this.register_once({distinct_id:t,$device_id:e?t:d},``),e||P(f)||this.register({[a]:f})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),n&&(n.distinctID&&!this._inCookielessMode()&&((ae=this.persistence)==null||ae.set_property(`$user_state`,n.isIdentifiedID?`identified`:`anonymous`),this.register({distinct_id:n.distinctID})),(ie=this.featureFlags)==null||ie.initialize(),!L(u)&&!this.sessionManager?.setBootstrapSessionId(u,!0))){let e=B({},n);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,g=!0}finally{var w,oe;h&&((w=this.persistence)==null||(oe=w._endCookieSyncSuppression)==null||oe.call(w,g))}this.reloadFeatureFlags()}shutdown(e){var t=this;return z(function*(){var e,n,r,i,a,o,s,c;if(t.__loaded){t._isShutdown=!0,t._getBrowserClientAdapter().dispose(),(e=t.sessionRecording)==null||e.dispose(),(n=t.logs)==null||n.flushLogs(`sendBeacon`),(r=t.metrics)==null||r.flush(`sendBeacon`),(i=t.metrics)==null||i.dispose(),(a=t._requestQueue)==null||a.unload(),(o=t._retryQueue)==null||o.unload();try{var l;(l=t.featureFlags)==null||l.destroy()}catch(e){V.error(`Error while destroying feature flags`,e)}(s=t.persistence)==null||s.destroy(),(c=t.sessionPersistence)==null||c.destroy()}else V.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._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)==null||e._onIdentityCleared()}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`)?(V.critical(`Attempting to create alias for existing People user - aborting.`),-2):this._requirePersonProcessing(`posthog.alias`)?(P(t)&&(t=this.get_distinct_id()),e===t?(V.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this._register_single(o,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){let n=B({},this.config);if(N(e)){var r,i,a,o,s,c,l,u,d,f,p,m,h,g;W(this.config,fl(e));let v=this._is_persistence_disabled();(r=this.persistence)==null||r.update_config(this.config,n,v),this.sessionPersistence=this.config.persistence===`
1sessionStorage`||this.config.persistence===`memory`?this.persistence:new is(B(B({},this.config),{},{persistence:`sessionStorage`}),v,!1);let y=this._checkLocalStorageForDebug(this.config.debug);var _;Lt(y)&&(this.config.debug=y),Lt(this.config.debug)&&(this.config.debug?(t.DEBUG=!0,q._is_supported()&&q._set(`ph_debug`,!0),V.info(`set_config`,{config:e,oldConfig:n,newConfig:B({},this.config)})):(t.DEBUG=!1,q._is_supported()&&q._remove(`ph_debug`))),(i=this.featureFlags)==null||(a=i.updateConfig)==null||a.call(i,this.config,this._shouldDisableFlags()),(o=this.exceptionObserver)==null||o.onConfigChange(),(s=this.exceptions)==null||s.onConfigChange(),(c=this.metrics)==null||c.onConfigChange(),(l=this.sessionRecording)==null||l.startIfEnabledOrStop(),(u=this.tracingHeaders)==null||u.startIfEnabledOrStop(),(d=this.autocapture)==null||d.startIfEnabled(),(f=this.heatmaps)==null||f.startIfEnabled(),(`capture_pageview`in e||`disable_capture_url_hashes`in e)&&((_=this.historyAutocapture)==null||_.startIfEnabledOrStop()),(p=this.exceptionObserver)==null||p.startIfEnabledOrStop(),(m=this.deadClicksAutocapture)==null||m.startIfEnabledOrStop(),(h=this.surveys)==null||h.loadIfEnabled(),this._sync_opt_out_with_persistence(),(g=this.externalIntegrations)==null||g.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&_o(this,$c,!1)}}_overrideSDKInfo(e,n){t.LIB_NAME=e,t.LIB_VERSION=n}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(B(B({},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??n._noopLogger}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??cl;return e!==cl&&(e=`posthog.`+e),e}_isIdentified(){return this.persistence?.get_property(`$user_state`)===`identified`||this.sessionPersistence?.get_property(`$user_state`)===`identified`}_hasPersonProcessing(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===`identified_only`&&!this._isIdentified()&&Pt(this.getGroups())&&!((e=this.persistence)!=null&&(e=e.props)!=null&&e.__alias)&&!((t=this.persistence)!=null&&(t=t.props)!=null&&t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return this.config.person_profiles===`never`?(V.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(We,!0),!0)}_is_persistence_disabled(){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`)}_sync_opt_out_with_persistence(){let e=this._is_persistence_disabled();var t,n,r;return this.is_capturing()||(t=this.logs)==null||t._onOptOut(),this.persistence?._disabled!==e&&((n=this.persistence)==null||n.set_disabled(e)),this.sessionPersistence?._disabled!==e&&((r=this.sessionPersistence)==null||r.set_disabled(e)),e&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),e}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==`always`){if(this._inCookielessMode()){var r,i,a;(r=this.sessionRecording)==null||r.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),(i=this.sessionManager)==null||i.destroy(),(a=this.pageViewM
1anager)==null||a.destroy(),this.sessionManager=new Ec(this),this.pageViewManager=new xo(this),this.persistence&&(this.sessionPropsManager=new Sc(this,this.sessionManager,this.persistence));let e=this.config.__extensionClasses?.sessionRecording??n.__defaultExtensionClasses?.sessionRecording;var o,s;e&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new e(this)),this._lastRemoteConfig&&((o=this.sessionRecording)==null||(s=o.onRemoteConfig)==null||s.call(o,this._lastRemoteConfig)))}var c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==`on_reject`&&((c=this.surveys)==null||c.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture(e?.captureEventName??`$opt_in`,e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else V.warn(el)}opt_out_capturing(){if(this.config.cookieless_mode===`always`)return void V.warn(el);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._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===`on_reject`&&(this.register({distinct_id:Ge,$device_id:null}),this._removeExtension(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._captureInitialPageview(),this._start_queue_if_opted_in())}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._sync_opt_out_with_persistence()}_is_bot(){return ht?Dc(ht,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){O&&(O.visibilityState===`visible`?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ut,{title:O.title},{send_instantly:!0}),this._visibilityStateListener&&=(O.removeEventListener(ct,this._visibilityStateListener),null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),G(O,ct,this._visibilityStateListener)))}debug(e){!1===e?(D?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(D?.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}))}_shouldDisableFlags(){let e=this._originalUserConfig||{};return`advanced_disable_flags`in e?!!e.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(V.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&&!L(e[t]),o=n in e&&!L(e[n]);return a?e[t]:!!o&&(i&&i.warn(`Config field '${n}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[n])}(e,`advanced_disable_flags`,`advanced_disable_decide`,0,V):!!this.config.advanced_disable_flags}_runBeforeSend(e){if(L(this.config.before_send))return e;let t=Object.keys(e.properties??{}).filter(zt),n=j(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(let t of n)try{if(r=t(r),L(r)){let t=`Event '${e.event}' was rejected in beforeSend function`;return Rt(e.event)?V.warn(`${t}. This can cause unexpected behavior.`):V.info(t),null}r.properties&&!Pt(r.properties)||V.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return V.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(let n of t)if(r.properties&&L(r.properties[n]))return V.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}
1getPageViewId(){return this.pageViewManager._currentPageview?.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)})}_checkLocalStorageForDebug(e){let t=Lt(e)&&!e,n=q._is_supported()&&q._get(`ph_debug`)===`true`;return!t&&(!!n||e)}};ml.__defaultExtensionClasses={},ml._noopLogger=(()=>{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]]=Yi(e.prototype[t[n]])}(ml,[`identify`]);var hl=class{constructor(e){this.disabled=!1===e;let t=N(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;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}},gl=`$copy_autocapture`,_l=H(`[AutoCapture]`);function vl(e,t){return t.length>e?t.slice(0,e)+`...`:t}function yl(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!ka(t));return t}function bl(e,{e:t,maskAllElementAttributes:n,maskAllText:r,elementAttributeIgnoreList:i,elementsChainAsString:a,disableCaptureUrlHashes:o}){if(!ka(e))return{props:{}};let s=[e],c=new Set([e]),l=e;for(;l.parentNode&&!Y(l,`body`)&&1e3>s.length;){if(ja(l.parentNode)){let e=l.parentNode.host;if(c.has(e))break;c.add(e),s.push(e),l=e;continue}if(!ka(l.parentNode)||c.has(l.parentNode))break;c.add(l.parentNode),s.push(l.parentNode),l=l.parentNode}let u=t.type===`click`&&e.namespaceURI===`http://www.w3.org/2000/svg`?s.findIndex(e=>Y(e,`button`)||Y(e,`a`)):-1;u>0&&(r||=s.slice(0,u+1).some(e=>!Za(e)||Qa(e)));let d=[],f={},p,m=!1,h=!1;if(U(s,e=>{let t=Za(e);if(Y(e,`a`)&&!n&&!i?.includes(`href`)){let n=e.getAttribute(`href`);m=!!(t&&n&&oo(n))&&(o?fr(n):n)}A(Pa(e),`ph-no-capture`)&&(h=!0),d.push(function(e,t,n,r,i=!1){let a=e.tagName.toLowerCase(),o={tag_name:a};Ra.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?vl(1024,so(e)):vl(1024,Ia(e)));let s=Pa(e);t||r!=null&&r.includes(`class`)||0>=s.length||(o.classes=s.filter(function(e){return e!==``})),U(e.attributes,function(n){var a;if((!Qa(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&!r?.includes(n.name)&&!t&&oo(n.value)&&(!F(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){let e=n.value;n.name===`class`&&(e=Ma(e).join(` `)),o[`attr__`+n.name]=vl(1024,n.name===`href`&&i?fr(e):e)}});let c=1,l=1,u=e;for(;u=yl(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,n,r,i,o)),U(function(e){if(!Za(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&&oo(r)&&(t[n]=r)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(f,t)||(f[t]=e)})}),h)return{props:{},explicitNoCapture:h};if(u>0&&(e=s[u],d.splice(0,u)),r||(d[0].$el_text=Y(e,`a`)||Y(e,`button`)?so(e):Ia(e)),m){var g;d[0].attr__href=m;let e=Eo(m)?.host,t=D==null||(g=D.location)==null?void 0:g.host;e&&t&&e!==t&&(p=m)}return{props:W((v=t.type,{$event_type:v,$ce_version:1}),a?{}:{$elements:d},{$elements_chain:(_=d,j(_)?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=B(B(B(B({},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 Ji(n).sort(([e],[t])=>function(e,t){return t>e?-1:+(e>t)}(e,t)).forEach(([e,t])=>r[lo(e.toString())]=lo(t.toString())),t+=`:`,t+=Ji(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:uo(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Ji(e).filter(([e])=>
1e.indexOf(`attr__`)===0).forEach(([e,n])=>t.attributes[e]=n),t})}(_)):``)},d[0]?.$el_text?{$el_text:d[0]?.$el_text}:{},p&&t.type===`click`?{$external_click_url:p}:{},f),target:e};var _,v}var xl=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){if(!Za(e))return!0;let t=this._refreshConfig().css_selector_ignorelist??Ha,n=new Set,r=e;for(;r;){if(n.size>=1e3||n.has(r))return!0;n.add(r);let e=r,i=Pa(e);if(A(i,`ph-no-capture`)||A(i,`ph-sensitive`)||Qa(e)||t.some(t=>za(e,t)))return!0;let a=r.parentNode;r=ja(a)?a.host:a&&ka(a)?a:null}return!1}_trackPointer(e){if(!this.isEnabled||e.type===`pointercancel`)return void this._clearPointer();if(e.type===`pointerdown`){this._clearPointer();let t=La(e);e.isPrimary&&e.button===0&&!e.ctrlKey&&t&&ka(t)&&(this._pointerDown={target:t,excluded:this._isExcludedPointerTarget(t),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:this._client?.distinctId});return}let t=this._pointerDown;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this._clearPointer():e.type===`pointerup`&&(t.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){let t=this._pointerDown;this._clearPointer();let n=La(e);if(t?.released&&t.target.isConnected&&t.distinctId===this._client?.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._refreshConfig().css_selector_ignorelist??Ha;return[n,O?.documentElement,O?.body].some(t=>{if(!t)return!1;let n=Pa(t);return A(n,`ph-no-capture`)||A(n,`ph-sensitive`)||!Za(t)||Qa(t)||e.some(e=>za(t,e))})?null:t.target}}constructor(e){this._configSource=e,this.name=`autocapture`,this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementsC
1hainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new hl(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;let t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,(e=this._remoteConfigSubscription)==null||e.dispose(),this._remoteConfigSubscription=void 0,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){return this._refreshConfig(),this._config.url_allowlist=this._config.url_allowlist?.map(e=>new RegExp(e)),this._config.url_ignorelist=this._config.url_ignorelist?.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){if(!this.isBrowserSupported())return void _l.info(`Disabling Automatic Event Collection because this browser is not supported`);if(!D||!O)return;let e=this._domEventHandler=e=>{e||=D?.event;try{if(e.type===`blur`)return void this._clearPointer();if(e.type.indexOf(`pointer`)===0)return void this._trackPointer(e);let t=e.type===`click`?this._recoverClickTarget(e):void 0;if(I(t))return;this._captureEvent(e,`$autocapture`,t)}catch(e){_l.error(`Failed to capture event`,e)}};if(G(D,`blur`,e),G(O,`submit`,e,{capture:!0}),G(O,`change`,e,{capture:!0}),G(O,`click`,e,{capture:!0}),U([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],t=>{G(O,t,e,{capture:!0})}),this._refreshConfig().capture_copied_text){let e=this._copiedTextHandler=e=>{e||=D?.event;try{this._captureEvent(e,gl)}catch(e){_l.error(`Failed to capture clipboard event`,e)}};G(O,`copy`,e,{capture:!0}),G(O,`cut`,e,{capture:!0}),G(O,`paste`,e,{capture:!0})}}_removeDomEventHandlers(){this._clearPointer(),this._domEventHandler&&=(D?.removeEventListener(`blur`,this._domEventHandler),U([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],e=>{O?.removeEventListener(e,this._domEventHandler,!0)}),O?.removeEventListener(`submit`,this._domEventHandler,!0),O?.removeEventListener(`change`,this._domEventHandler,!0),O?.removeEventListener(`click`,this._domEventHandler,!0),void 0),this._copiedTextHandler&&=(O?.removeEventListener(`copy`,this._copiedTextHandler,!0),O?.removeEventListener(`cut`,this._copiedTextHandler,!0),O?.removeEventListener(`paste`,this._copiedTextHandler,!0),void 0),this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._disposed)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();let t=e.config;
1t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);let n=t.autocapture_opt_out;var r;Lt(n)&&((r=this._client)==null||r.kv.set(`$autocapture_disabled_server_side`,n),this._isDisabledServerSide=n),this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e,t){var n;let r=[];return(n=this._elementSelectors)==null||n.forEach(n=>{(O?.querySelectorAll(n))?.forEach(i=>{e!==i&&t!==i||A(r,n)||r.push(n)})}),r}get isEnabled(){if(this._disposed)return!1;let e=this._client?.kv.get(p),t=this._isDisabledServerSide,n=this._refreshConfig();if(!n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;let r=n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(I(t)&&!Lt(e)&&!r)return!1;let i=this._isDisabledServerSide??!!e;return!!n.enabled&&!i}_captureEvent(e,t=`$autocapture`,n){if(!this.isEnabled)return void this._clearPointer();let r=n||La(e);Aa(r)&&(r=r.parentNode||null);let i=this._compileUrlPatterns();var a;t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&i.rageclick&&(a=this.rageclicks)!=null&&a.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&Ja(r,i.rageclick)&&this._captureEvent(e,`$rageclick`,n);let o=t===gl,s=o?B(B({},i),{},{dom_event_allowlist:void 0}):i;if(r&&function(e,t,n,r,i,a){if(!D||Ya(e)||n?.url_allowlist&&!Na(n.url_allowlist,a)||n?.url_ignorelist&&Na(n.url_ignorelist,a))return!1;if(n?.dom_event_allowlist){let e=n.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}let{parentIsUsefulElement:o,targetElementList:s}=Xa(e,r);if(!function(e,t){let n=t?.element_allowlist;if(P(n))return!0;for(let t of e)if(n.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(s,n)||!Ba(s,n?.css_selector_allowlist)||Ba(s,n?.css_selector_ignorelist??Ha))return!1;try{let n=D.getComputedStyle(e);if(n&&n.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0}catch{}let c=e.tagName.toLowerCase();switch(c){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return o?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(Ra.indexOf(c)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,s,o,o?[`copy`,`cut`,`paste`]:void 0,{config:{get_current_url:i.getCurrentUrl}})){var c;let{props:n,explicitNoCapture:a,target:o}=bl(r,{e,maskAllElementAttributes:i.maskAllElementAttributes,maskAllText:i.maskAllText,elementAttributeIgnoreList:i.element_attribute_ignorelist,elementsChainAsString:this._elementsC
1hainAsString,disableCaptureUrlHashes:i.disableCaptureUrlHashes});if(a)return!1;let s=this.getElementSelectors(r,o);if(s&&s.length>0&&(n.$element_selectors=s),t===gl){let t=e.type||`clipboard`;if(t!==`paste`){var l;let e=D==null||(l=D.getSelection())==null?void 0:l.toString(),t=Fa(e);if(!t)return!1;n.$selected_content=t,n.$clipboard_text_length=e?.length??0}n.$copy_type=t}return(c=this._client)==null||c.capture(t,n).catch(e=>_l.error(`Failed to capture event`,e)),!0}}isBrowserSupported(){return M(O?.querySelectorAll)}},Sl=class{constructor(e){this._instance=e}refresh(e){let t=this._instance.config,n=N(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),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}},Cl=H(`[ExceptionAutocapture]`),wl=()=>{},Tl=e=>{if(M(e))return e.__posthog_layer__??e.__rrweb_layer__};function El(e,t,n){try{if(!(t in e))return wl;let r={next:e[t]},i=n(function(...e){return r.next.apply(this,e)});return M(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=Tl(n);for(;a;){if(a.next===i)return void(a.next=r.next);n=a.next,a=Tl(n)}}}catch{return wl}}var Dl=H(`[TracingHeaders]`),Ol=H(`[Web Vitals]`),kl=9e5,Al=[`CLS`,`FCP`,`INP`,`LCP`],jl=[`INP`,`LCP`],Ml=[`interactionTarget`,`interactionType`,`inputDelay`,`processingDuration`,`presentationDelay`,`loadState`,`target`,`url`,`timeToFirstByte`,`resourceLoadDelay`,`resourceLoadDuration`,`elementRenderDelay`,`largestShiftTarget`,`largestShiftTime`,`largestShiftValue`,`firstByteToFCP`],Nl=`disabled`,Pl=`lazy_loading`,Fl=H(`[SessionRecording]`),Il=H(`[Heatmaps]`);function Ll(e){return N(e)&&`clientX`in e&&`clientY`in e&&R(e.clientX)&&R(e.clientY)}var Rl=H(`[Product Tours]`),zl=e=>!e.config.disable_product_tours&&!!e.persistence?.get_property(b),Bl=[`$set_once`,`$set`],Vl=H(`[SiteApps]`),Hl=`Error while initializing PostHog app with config id `,Ul=(e,t)=>e?.then?e.then(t):t(e),Wl=`SDK is not enabled or survey functionality is not yet loaded`,Gl=`Disabled. Not loading surveys.`,Kl=class{constructor(e,t){this._configSource=e,this._initialClientState=t,this.name=`surveys`,this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(this._disposed||this._config.disableSurveys)return;if(!e.ok)return $.warn(`Remote config unavailable. Not loading surveys.`);let t=e.config.surveys;if(L(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);this._isSurveysEnabled=Lt(t)?t:t.length>0,$.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()}}setup(e){if(!this._disposed)return this._initializingClient=e,Ul(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;let t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,(e=this._remoteConfigSubscription)==null||e.dispose(),this._remoteConfigSubscription=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._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._renderTimeouts.forEac
1h(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.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._disposed||!this._client)return;let e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void $.info(`Already initializing surveys, skipping...`);if(e.disableSurveys)return void $.info(Gl);if(e.cookielessMode&&this._configSource.isOptedOut())return void $.info(`Not loading surveys in cookieless mode without consent.`);let t=this._configSource.getExtensions();if(!t)return void $.error(`PostHog Extensions not found.`);if(P(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;let n=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0;try{let e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,n),void(this._isInitializingSurveys=!1);let r=t.loadExternalDependency;if(!r)return this._handleSurveyLoadError(it),void(this._isInitializingSurveys=!1);r(e=>{try{if(this._disposed)return;let t=this._configSource.getExtensions();e||!t?.generateSurveys?this._handleSurveyLoadError(`Could not load surveys script`,e):this._completeSurveyInitialization(t.generateSurveys,n)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError(`Error initializing surveys`,e),e}}_completeSurveyInitialization(e,t){this._disposed||(this._surveyManager=e(t),this._surveyEventReceiver=this._configSource.createEventReceiver(),$.info(`Surveys loaded successfully`),this._notifySurveyCallbacks({isLoaded:!0}))}_handleSurveyLoadError(e,t){$.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(t=>t!==e)}}getSurveys(e,t=!1){let n=this._client??this._initialClientState;if(!n||this._disposed)return;if(this._config.disableSurveys)return $.info(Gl),e([]);let r=n.kv.get(Se);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:n})=>{this._disposed||e(t,n)}).catch(e=>$.error(`Error in survey callback`,e));let i=this._sendSurveysRequest(`/api/surveys/`,{method:`GET`,query:{token:n.projectToken},sentAt:`query`,timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(n,e)}catch(e){return $.error(`Error processing surveys response`,e),this._handleSurveyResponse(n,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(n,{statusCode:0,error:e}));this._getSurveysInFlightPromise=i;let a=()=>{this._getSurveysInFlightPromise===i&&(this._getSurveysInFlightPromise=null)};i.then(t=>{a(),this._disposed||e(t.surveys,t.context)},a).catch(e=>$.error(`Error in survey callback`,e))}_sendSurveysRequest(e,t){let n=this._client;return n?n.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:Error(Wl)}))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:Wl}};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._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;let r=t.json.surveys||[],i=r.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(Ac(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({[Se]:r,[Ce]:Date.now()}),{surveys:r,context:{isLoaded:!0}}}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefresh
1BackingOff()}_isSurveyCacheStale(){let e=(this._client??this._initialClientState)?.kv.get(Ce);return R(e)&&Date.now()-e>3e5}_isSurveyRefreshBackingOff(){return R(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){Vc({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}_notifySurveyCallbacks(e){for(let t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t=!1){if(!L(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}_getSurveyById(e){let t=null;return this.getSurveys(n=>{t=n.find(t=>t.id===e)??null}),t}_checkSurveyEligibility(e){if(L(this._surveyManager))return{eligible:!1,reason:Wl};let t=typeof e==`string`?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}_checkSurveyRenderability(e){if(!this._configSource.isCapturing())return{eligible:!1,reason:`PostHog is not capturing, so a survey response cannot be recorded`};if(L(this._surveyManager))return{eligible:!1,reason:Wl};let t=typeof e==`string`?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(L(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:Wl};let t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return L(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Wl})):new Promise(n=>{this.getSurveys(t=>{let r=t.find(t=>t.id===e)??null;if(r){let e=this._checkSurveyRenderability(r);n({visible:e.eligible,disabledReason:e.reason})}else n({visible:!1,disabledReason:`Survey not found`})},t)})}renderSurvey(e,t,n){if(!this._configSource.isCapturing())return;if(L(this._surveyManager))return void $.warn(`init was not called`);let r=typeof e==`string`?this._getSurveyById(e):e;if(!r?.id)return void $.warn(`Survey not found`);if(!Hc.includes(r.type))return void $.warn(`Surveys of type ${r.type} cannot be rendered in the app`);let i=O?.querySelector(t);if(i){if(r.appearance?.surveyPopupDelaySeconds){$.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);let e=setTimeout(()=>{var t;this._renderTimeouts.delete(e),!this._disposed&&this._configSource.isCapturing()&&($.info(`Rendering survey ${r.id} with delay of ${r.appearance?.surveyPopupDelaySeconds} seconds`),(t=this._surveyManager)==null||t.renderSurvey(r,i,n),$.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);this._renderTimeouts.add(e);return}this._surveyManager.renderSurvey(r,i,n)}else $.warn(`Survey element not found`)}displaySurvey(e,t){var n;if(!this._configSource.isCapturing())return;if(L(this._surveyManager))return void $.warn(`init was not called`);let r=this._getSurveyById(e);if(!r)return void $.warn(`Survey not found`);let i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=B(B({},r),{},{appearance:B(B({},r.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==us.Popover&&t.initialResponses&&$.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){let e=this._checkSurveyEligibility(r);if(!e.eligible)return void $.warn(`Survey is not eligible to be displayed: `,e.reason)}t.displayType===us.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}cancelPendingSurvey(e){L(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 ql(e,t,n){if(L(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 Jl=class{constructor(e){this._instance=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Cc,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>
1!t?.event||e?.event===t?.event}init(){P(this._instance?._addCaptureHook)||(this._captureHookUnsubscribe=this._instance?._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;(e=this._captureHookUnsubscribe)==null||e.call(this),this._captureHookUnsubscribe=void 0,this._debugEventEmitter=new Cc}register(e){if(!P(this._instance?._addCaptureHook)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),(t=e.steps)==null||t.forEach(e=>{this._actionEvents.add(e?.event||``)})}),this._instance?.autocapture)){let e=new Set;this._actionRegistry.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._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry.forEach(e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit(`actionCaptured`,e.name)})}_addActionHook(e){this.onAction(`actionCaptured`,t=>e(t))}_checkAction(e,t){if(t?.steps==null)return!1;for(let n of t.steps)if(this._checkStep(e,n))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(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`||!ql(r,t.url,t.url_matching||`contains`))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var n;if(!t?.href)return!0;let r=this._getElementsList(e);if(r.length>0)return r.some(e=>ql(e.href,t.href,t.href_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&ql(function(e){let t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:``}(i),t.href,t.href_matching||`exact`)}_checkStepText(e,t){var n;if(!t?.text)return!0;let r=this._getElementsList(e);if(r.length>0)return r.some(e=>ql(e.text,t.text,t.text_matching||`exact`)||ql(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(;!L(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=>ql(e,o,s)));var a,o,s}_checkStepSelector(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}_getElementsList(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}_checkStepProperties(e,t){return!t?.properties||t.properties.length===0||Pc(t.properties.reduce((e,t)=>{let n=j(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)}},Yl=class{constructor(e){var t,n;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,this._sessionIdUnsubscribe=(t=this._instance)==null||(n=t.onSessionId)==null?void 0:n.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&Pc(e.propertyFilters,t?.properties)}_buildEventToItemMap(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}_getMatchingItems(e,t,n){let r=(n===os.Activation?this._eventToItems:this._cancelEventToItems).get(e),i=[];return this._getItems(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._doesEventMatchFilter(a,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){P(this._instance?._addCaptureHook)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(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._actionToItems.clear(),n.length===0)return void(t&&((r=this._actionMatcher)==null||r.replace([])));this._actionMatcher||(this._actionMatcher=new Jl(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));let i=[];
1n.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._actionToItems.get(t.name)??[];n.includes(e.id)||n.push(e.id),this._actionToItems.set(t.name,n)}})}),t?this._actionMatcher.replace(i):this._actionMatcher.register(i)}_mergeItemMaps(e,t){t.forEach((t,n)=>{let r=e.get(n)??[];t.forEach(e=>{r.includes(e)||r.push(e)}),e.set(n,r)})}_setupEventBasedItems(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._buildEventToItemMap(e,os.Activation),a=this._buildEventToItemMap(e,os.Cancellation);t?(this._eventToItems=i,this._cancelEventToItems=a):(this._mergeItemMaps(this._eventToItems,i),this._mergeItemMaps(this._cancelEventToItems,a)),(n.length!==0||r.length!==0)&&(this._captureHookUnsubscribe??=this._instance?._addCaptureHook((e,t)=>{this.onEvent(e,t)}))}onEvent(e,t){var n,r;let i=this._getLogger(),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._activationOutcome(e,a);if(t===`consume`)return i.info(`event consumed activated item, removing it`,{event:e,itemId:a}),void this._deactivateItems([a]);if(t===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),this._persistActivation(a),void this._clearActivationTimestamps([a])}if(this._cancelEventToItems.has(e)){let n=this._getMatchingItems(e,t,os.Cancellation);n.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:n.map(e=>e.id)}),this._deactivateItems(n.map(e=>e.id)),n.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;i.info(`event name matched`,{event:e,eventPayload:t,items:this._eventToItems.get(e)});let o=this._getMatchingItems(e,t,os.Activation);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(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._shouldPersistArmedActivation(t)?this._persistActivation(t)&&this._recordActivationTimestamp(t):i.push(t);i.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...i])]),this._getLogger().info(`updating activated items`,{activatedItems:this.getActivatedIds()})}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);let t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){let t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));let n=this._getRawPersistedActivatedIds(),r=n.filter(e=>!t.has(e));r.length!==n.length&&(this._setActivatedItems(r),r.length===0&&this._clearActivationSession()),this._clearActivationTimestamps(e)}_getRawActivationTimestamps(){var e;let t=this._getActivationTimestampsKey();if(!t)return{};let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return n&&typeof n==`object`?n:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;let t=this._getRawActivationTimestamps();this._writeActivationTimestamps(B(B({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;let t=this._getRawActivationTimestamps(),n={},r=!1;for(let[i,a]of Object.entries(t))e.includes(i)?r=!0:n[i]=a;r&&(Pt(n)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(n))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;let t=this._getRawActivationTimestamps()[e];return R(t)?t:void 0}_getRawPersistedActivatedIds(){var e;let t=this._getActivatedKey();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,n;let r=this._getRawPersistedActivatedIds();if(r.length===0)return[];let i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this._getActivatedSessionKey()],a=(t=this._instance)==null||(n=t.get_session_id)==null?void 0:n.call(t);return a&&i===a?r:[]}_stampActivationSession(){var e,t;let n=(e=this._instance)==null||(t=e.get_session_id)==null?void 0:t.call(e);n&&this._setActivatedSession(n)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t;let n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this._getActivatedSessionKey()];if(n&&n!==e){let e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>
1R(t[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,n;(e=this._sessionIdUnsubscribe)==null||e.call(this),this._sessionIdUnsubscribe=void 0,(t=this._captureHookUnsubscribe)==null||t.call(this),this._captureHookUnsubscribe=void 0,(n=this._actionMatcher)==null||n.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},Xl=class extends Yl{constructor(e){super(e)}_getActivatedKey(){return we}_getActivatedSessionKey(){return Te}_getActivationTimestampsKey(){return Ee}_writeActivationTimestamps(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_timestamps:e})}_clearActivationTimestampsStore(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_timestamps`)}_shouldPersistArmedActivation(e){var t;let n;this._getItems(t=>{n=t.find(t=>t.id===e)});let r=n==null||(t=n.appearance)==null?void 0:t.surveyPopupDelaySeconds;return R(r)&&r>0}_getShownEventName(){return cs.SHOWN}_getItems(e){var t;(t=this._instance)==null||t.getSurveys(e)}_cancelPendingItem(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}_getLogger(){return $}_setActivatedItems(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated:e})}_setActivatedSession(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_session:e})}_clearActivatedSession(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_session`)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){let n;return this._getItems(e=>{n=e.find(e=>e.id===t)}),!n||function(e){var t;return Ac(e)&&!!((t=e.conditions)!=null&&(t=t.events)!=null&&t.repeatedActivation)||e.schedule===`always`}(n)?e===cs.SHOWN?`consume`:`ignore`:e===cs.SHOWN?`persist`:e===cs.DISMISSED||e===cs.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Zl=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);P(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))}},Ql=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=k?.__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 Xl(this._instance)}},$l=D?.location?ko(D.location.hash,`__posthog`)||ko(location.hash,`state`):null,eu=`_postHogToolbarParams`,tu=H(`[Toolbar]`),nu=H(`[FeatureFlags]`),ru=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((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,idleRefreshBackoff:P(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:`best-available`,evaluationContexts:e.evaluation_contexts??e.evaluation_environments??[],flagKeys:j(e.flag_keys)?e.flag_keys:void 0}))(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(nu.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this._loggedEvaluationEnvironmentsDeprecation=!0),P(e.flag_keys)||j(e.flag_keys)||nu.error(`Invalid flag_keys found:`,e.flag_keys,`Expected array of non-empty strings`)}get(){return this._snapshot}},iu=H(`[FeatureFlags]`),au=H(`[FeatureFlags]`,{debugEnabled:!0}),ou=`" failed. Feature flags didn't load in time.`,su=[`click`,`keydown`,`wheel`,`touchstart`,`pointerdown`],cu=`connection_error`,lu=e=>{let t={};for(let n=0;e.length>n;n++)t[e[n]]=!0;return t},uu=e=>{let t={};for(let[n,r]of Ji(e||{}))r&&(t[n]=r);return t},du=e=>Ht(e)&&(e.name===`RangeError`&&e.message.indexOf(`Maximum call stack size exceeded`)===0||e.name===`InternalError`&&e.message===`too much recursion`),fu=H(`[Error tracking]`),pu=`webkit-masked-url:`,mu=[{value:`isolatedAPI.contexts.topHostname`,exact:!1},{value:`No response from target`,exact:!0}],hu=[`chrome-extension://`,`moz-extension://`,`safari-extension:`,`safari-web-extension:`,pu],gu=[`__firefox__`,`__gCrWeb`],_u=`Refusing to render web experiment since the viewer is a likely bot`,vu={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>jc(t,e),not_regex:(e,t)=>!jc(t,e),exact:(e,t)=>
1t===e,is_not:(e,t)=>t!==e},yu=H(`[Conversations]`),bu=`Conversations not available yet.`;function xu(e,t){let n=e?.flushIntervalMs??3e3,r=e?.maxBufferSize??100,i=t?.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,a=P(i)?Math.max(r,2048):Math.max(r,i),o=B(B({},function(){let e=``,t=``;try{let n=ht?.userAgent;n&&([e,t]=Qn(n))}catch{}return function(e,t){let n=function(e){if(e)return{}.hasOwnProperty.call(ji,e)?ji[e]:e}(e);return B(B({},n?{"os.name":n}:{}),t?{"os.version":t}:{})}(e,t)}()),e?.resourceAttributes);return{serviceName:o?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:o?.[`service.version`]??e?.serviceVersion,environment:o?.[`deployment.environment`]??e?.environment,resourceAttributes:o,beforeSend:e?.beforeSend,flushIntervalMs:n,maxBufferSize:r,maxQueueSize:a,maxBatchRecordsPerPost:100,rateCapWindowMs:n,maxLogsPerInterval:i,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Su=[`debug`,`log`,`warn`,`error`,`info`],Cu=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},wu=`console`,Tu=`__posthogHandledLogsRequestError`,Eu=(e,t)=>{let n=e instanceof Error?e:Error(t);return n[Tu]=!0,n},Du=e=>!!e&&typeof e==`object`&&!0===e[Tu],Ou=H(`[NetworkMetrics]`),ku=()=>{var e;return D!=null&&(e=D.performance)!=null&&e.now?D.performance.now():Date.now()},Au=e=>e?`${Math.floor(e/100)}xx`:`missing`,ju=(e,t)=>{let n=String(t);return{method:String(e).toUpperCase(),url:Eo(n)?.href||n}},Mu=(e,t,n,r,i)=>{try{var a;let s=i();if(!s)return;let c=n||void 0,l=ku()-r,u=Eo(t.url);if(u&&u.protocol!==`http:`&&u.protocol!==`https:`)return;let d={url:u?.href||t.url,method:t.method},f=M(s.name)?s.name(d):F(s.name)?s.name:`http.client.request.duration`;if(!f)return;let p=B({method:d.method,host:u?.hostname??``,path:u?(o=u.pathname,o.split(`/`).map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?`:id`:e).join(`/`)):``,status_class:Au(c)},s.attributes?.call(s,d,{status:c,durationMs:l}));(a=e.metrics)==null||a.histogram(f,l,{unit:`ms`,attributes:p})}catch(e){Ou.error(`Failed to record network metric`,e)}var o},Nu=()=>{},Pu=(e,t)=>M(D?.fetch)?El(D,`fetch`,n=>function(...r){let i=ku(),a=n.apply(this,r);if(!t())return a;try{let[n,o]=r,s=ju(o?.method??n?.method??`GET`,n?.url??n);return a.then(n=>(Mu(e,s,n?.status,i,t),n),n=>{throw Mu(e,s,void 0,i,t),n})}catch(e){return Ou.error(`Failed to observe fetch`,e),a}}):Nu,Fu=(e,t)=>{var n;let r=D==null||(n=D.XMLHttpRequest)==null?void 0:n.prototype;if(!r)return Nu;let i=new WeakMap,a=El(r,`open`,e=>function(...t){try{Zs.has(this)||i.set(this,ju(t[0],t[1]))}catch(e){Ou.error(`Failed to observe XHR open`,e)}return e.apply(this,t)}),o=El(r,`send`,n=>function(...r){let a;try{let n=i.get(this);if(n&&t()){let r=ku();a=()=>{this.removeEventListener(`loadend`,a),Mu(e,n,this.status,r,t)},G(this,`loadend`,a)}}catch(e){Ou.error(`Failed to observe XHR send`,e)}try{return n.apply(this,r)}catch(e){throw a&&this.removeEventListener(`loadend`,a),e}});return()=>{a(),o()}},Iu={featureFlags:class{constructor(e){this.name=`featureFlags`,this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=iu,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._hadUserInteraction=!1,this._onOnline=()=>{let e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{let e=this._refreshIntervalMs,t=this._dueRefreshIntervalMs??e;P(e)||P(t)||this._config.remoteRequestsDisabled||!O||O.visibilityState===`hidden`||Date.now()-(this._lastRefreshAt??0)<t||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?e:Math.min(2*t,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>
1{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{O?.visibilityState===`visible`&&this._resumeConfiguredInterval()},`get`in e?this._configSource=e:(this._instance=e,this._mutableConfigSource=new ru(e.config,e._shouldDisableFlags()),this._configSource=this._mutableConfigSource)}updateConfig(e,t){var n;(n=this._mutableConfigSource)==null||n.update(e,t),this._client&&this._syncAutomaticRefresh()}setup(e){return this._initializingClient=e,this._logger=e.logger.createLogger(`[FeatureFlags]`),Ul(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return D&&G(D,`online`,this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){let e=this._config.refreshIntervalMs,t=!this._config.remoteRequestsDisabled&&O&&!P(e)&&e>0?e:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=t),t!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),P(t)||(this._refreshIntervalMs=t,this._dueRefreshIntervalMs=t,this._scheduleNextRefresh(),O!=null&&O.addEventListener&&(G(O,ct,this._onVisibilityChange),qi(su,e=>{G(O,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){P(this._refreshIntervalMs)||(P(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e;P(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,O==null||(e=O.removeEventListener)==null||e.call(O,`visibilitychange`,this._onVisibilityChange),qi(su,e=>{var t;O==null||(t=O.removeEventListener)==null||t.call(O,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._client&&=(this._clearDebouncer(),(e=this._dynamicProperties)==null||e.dispose(),this._dynamicProperties=void 0,(t=this._crossTabPersistenceUnsubscribe)==null||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],D?.removeEventListener(`online`,this._onOnline),void 0)}get _config(){return this._configSource.get()}_prop(e){return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:this._client?.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){return!P(this._client?.kv.get(`$enabled_feature_flags`))&&this._clearBootstrapState()}_set(e){this._persist(()=>this._client?.kv.set(e))}_markCrossTabFeatureFlagSnapshot(e,t,n){if(!this._instance?.persistence||!e.$enabled_feature_flags)return;let r=this._prop(`$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&&!j(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(r),...Object.keys(i)])),l=this._prop(`$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={[fe]:p,[T]:p,[E]:m};e.$feature_flag_details&&(h[me]=p);for(let t of[he,Le,ge])P(e[t])||(h[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(h)}_remove(e){this._persist(()=>this._client?.kv.remove(e))}_persist(e){try{e()}catch(e){this._logger.error(`Failed to update feature flag persistence`,e)}}_rebuildEventProperties(){let e={};for(let t of[fe,E,he,_e]){let n=this._prop(t);P(n)||(e[t]=n)}this._baseEventProperties=e;let t=B({},e),n=this._prop(T);if(n)for(let[e,r]of Object.entries(n))t[`$feature/${e}`]=r;this._eventPropertiesWithFlagValues=t}_isCacheStale(){let e=this._config.cacheTtlMs;
1if(!e||0>=e)return!1;let t=this._prop(Le);return typeof t!=`number`||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){let e=this._config.evaluationContexts;return e?.length?e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this._logger.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t}):[]}_getValidFlagKeys(){let e=this._config.flagKeys;if(!P(e))return e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this._logger.error(`Invalid flag key found:`,e,`Expected non-empty string`),t})}initialize(){let e=this._config,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){let n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter(e=>!P(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._receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i},void 0,{persist:!1})}}updateFlags(e,t,n){var r,i;let a=n?.merge&&(r=this._prop(`$enabled_feature_flags`))!=null?r:{},o=n?.merge&&(i=this._prop(`$feature_flag_payloads`))!=null?i:{},s=B(B({},a),e),c=B(B({},o),t),l={};for(let[e,t]of Object.entries(s))l[e]={key:e,enabled:ui(t),variant:di(t),reason:void 0,metadata:P(c?.[e])?void 0:{id:0,version:void 0,description:void 0,payload:c[e]}};this._receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let e=this._prop(me),t=this._prop(_e),n=this._prop(ve);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=P(s)?(a=i?.enabled)!=null&&a:!!s,l=P(s)?i?.variant:typeof s==`string`?s:void 0,u=n?.[e],d=B(B({},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=B(B({},i?.metadata),{},{payload:u,original_payload:i==null||(o=i.metadata)==null?void 0:o.payload})),r[e]=d}return this._override_warning||=(this._logger.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:ui(r),variant:di(r),payload:li(t[n])}})}getFlagVariants(){let e=this._prop(T),t=this._prop(_e);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._override_warning||=(this._logger.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){let e=this._prop(E),t=this._prop(ve);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._override_warning||=(this._logger.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||=(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error(`Error while running feature flags reloading callback`,e)}}),setTimeout(()=>{this._callFlagsEndpoint()},5)))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(Pe)}_callFlagsEndpoint(e){this._clearDebouncer();let t=this._client;if(!t||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return;if(this._requestInFlight)return void(this._additionalReloadRequested=!0);let n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:B(B(B({},t.initialPersonProperties),this._prop(`$stored_person_properties`)||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this._prop(be),timezone:Go()};P(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this._config.featureFlagsDisabled)&&(n.disable_flags=!0);let r=this._getValidEvaluationEnvironments();r.length&&(n.evaluation_contexts=r);let i=this._getValidFlagKeys();P(i)||(n.flag_keys=i);let a=this._config.onlyEvaluateSurveyFeatureFlags,o=`/flags/?v=2`+(a?`&only_evaluate_survey_feature_flags=true`:``),s=this._requestGeneration;this._requestInFlight=!0;let c=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},l=e=>{let t=e.json??{},r=e.statusCode!==200;if(this._requestInFlight=!1,s!==this._requestGeneration)return void c();if(this._trackStatusZeroReachability(e.statusCode),r||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),n.disable_flags&&!this._additionalReloadRequested)return;this._flagsLoadedFromRemote=!r;let i=[];e.error?i.push(e.error instanceof Error&&e.error.name===`AbortError`?`timeout`:e.error instanceof Error?cu:`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._set({[Ie]:i}),o?this._logger.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._receivedFeatureFlags(t,r,{partialResponse:a}),c()},u=e=>{this._requestInFlight=!1,s===this._requestGeneration?(this._set({[Ie]:[cu]}),this._logger.error(`Feature flag request failed`,e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),c()):c()};try{t.sendRequest(o,{target:`flags`,method:`POST`,body:n,compression:this._config.compression,sentAt:`body`,timeoutMs:this._config.requestTimeoutMs}).then(l).catch(u)}catch(e){u(e)}}_hasStatusZeroCircuitBreakerTripped(){return Ao(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=jo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn(`getFeatureFlag for key "`+e+ou);if(this._checkAndTriggerStaleRefresh())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._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn(`getFeatureFlagResult for key "`+e+ou);if(this._checkAndTriggerStaleRefresh())return;let n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this._prop(`$feature_flag_request_id`)||void 0,c=this._prop(`$feature_flag_evaluated_at`)||void 0,l,u=this._prop(`$flag_call_reported`)||{};if(this._config.deduplicateCallsPerSession){let e=this._client?.session.sessionId,t=this._prop(Fe);e&&e!==t&&(u={},l=e)}if(t.send_event||!(`send_event`in t)){if(e in u&&u[e].includes(o))l&&this._set({[Pe]:u,[Fe]:l});else{var d,f,p,m,h,g,_,v;j(u[e])?u[e].push(o):u[e]=[o],this._set(B({[Pe]:u},l?{[Fe]:l}:{}));let t=this.getFeatureFlagDetails(e),n=[...this._prop(`$feature_flag_errors`)??[]];P(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._config.bootstrap)==null||(d=d.featureFlags)==null?void 0:d[e])??null,$feature_flag_bootstrapped_payload:((f=this._config.bootstrap)==null||(f=f.featureFlagPayloads)==null?void 0:f[e])??null,$used_bootstrap_value:!this._flagsLoadedFromRemote};P(t==null||(p=t.metadata)==null?void 0:p.has_experiment)||(r.$feature_flag_has_experiment=t.metadata.has_experiment),P(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),P(t?.original_variant)&&P(t?.original_enabled)||(r.$feature_flag_original_response=P(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._captureFeatureFlagCalled(r)}}else l&&this._set({[Pe]:u,[Fe]:l});return r?{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:li(a)}:void 0}_captureFeatureFlagCalled(e){try{var t;(t=this._client)==null||t.capture(`$feature_flag_called`,e).catch(e=>{this._logger.error(`Failed to capture feature flag call`,e)})}catch(e){this._logger.error(`Failed to capture feature flag call`,e)}}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var n=this;return z(function*(){let r=n._client;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._getValidEvaluationEnvironments();a.length&&(i.evaluation_contexts=a);let o=n._getValidFlagKeys(),s;P(o)||(i.flag_keys=o);try{s=(yield r.sendRequest(`/flags/?v=2`,{target:`flags`,method:`POST`,body:i,compression:n._config.compression,sentAt:`body`,timeoutMs:n._config.requestTimeoutMs})).json?.featureFlagPayloads?.[e]||void 0}catch(e){n._logger.error(`Remote config feature flag request failed`,e);return}try{t(s)}catch(e){n._logger.error(`Remote config feature flag callback failed`,e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>
10))return this._logger.warn(`isFeatureEnabled for key "`+e+ou),t.defaultValue;let n=this.getFeatureFlag(e,t);return P(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this._receivedFeatureFlags(e,t,n)}_receivedFeatureFlags(e,t,n){if(!this._client)return;this._hasLoadedFlags=!0;let r=((e,t={},n={},r={},i,a=iu)=>{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=>!P(n[e].metadata?.payload)).map(e=>[e,n[e].metadata?.payload]));return B(B({},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(j(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{[fe]:c,[T]:e,[ge]:!1}}let f=c,p=l,m=s;if(i?.partialResponse){let e=Object.keys(f),i=p||{};f=B(B({},t),f),p=B(B({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=B(B({},r),m)}else if(e.errorsWhileComputingFlags){if(s){let e=new Set(Object.keys(s).filter(e=>!s[e]?.failed));f=B(B({},t),Object.fromEntries(Object.entries(f).filter(([t])=>e.has(t))));let i=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=B(B({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=B(B({},r),Object.fromEntries(Object.entries(m||{}).filter(([t])=>e.has(t))))}else f=B(B({},t),f),p=B(B({},n),p),m=B(B({},r),m)}return B(B({[fe]:Object.keys(uu(f)),[T]:f||{},[E]:p||{},[me]:m||{},[ge]:!0===e.minimalFlagCalledEvents},u?{[he]:u}:{}),d?{[Le]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this._logger);if(r){if(!1===n?.persist){let e=!P(this._client.kv.get(T));this._bootstrapState=r,e||this._set(r)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(r,e,!!n?.partialResponse),this._set(r)}else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,t=!1){this._logger.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([_e,ve]),this._fireFeatureFlagsCallbacks(),void au.info(`All overrides cleared`);if(j(e))return this._set({[_e]:lu(e)}),this._fireFeatureFlagsCallbacks(),void au.info(`Flag overrides set`,{flags:e});if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var t;let n=e;this._override_warning=!!((t=n.suppressWarning)!=null&&t);let r={},i=n.flags,a=n.payloads;i&&(r[_e]=j(i)?lu(i):i),a&&(r[ve]=a),Object.keys(r).length&&this._set(r),!1===i&&!1===a?this._remove([_e,ve]):!1===i?this._remove(_e):!1===a&&this._remove(ve),this._fireFeatureFlagsCallbacks(),!1===i?au.info(`Flag overrides cleared`):i&&au.info(`Flag overrides set`,{flags:i}),!1===a?au.info(`Payload overrides cleared`):a&&au.info(`Payload overrides set`,{payloads:a});return}if(e&&typeof e==`object`)return this._set({[_e]:e}),this._fireFeatureFlagsCallbacks(),void au.info(`Flag overrides set`,{flags:e});this._logger.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}else this._logger.warn(`posthog.featureFlags.overrideFeatureFlags called before feature flags were ready`)}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){let{flags:t,flagVariants:n}=this._prepareFeatureFlagsForCallbacks();try{e(t,n)}catch(e){this._logger.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;let i=(this._prop(`$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=B(B({},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._set({[fe]:Object.keys(uu(s)),[T]:s,[ye]:B(B({},this._prop(`$stored_person_properties`)||{}),a)}),this._fireFeatureFlagsCallbacks();try{var c;(c=this._client)==null||c.capture(`$feature_enrollment_update`,o).catch(e=>{this._logger.error(`Failed to capture early access feature enrollment`,e)})}catch(e){this._logger.error(`Failed to capture early access feature enrollment`,e)}}getEarlyAccessFeatures(e,t=!1,n){let r=this._prop(pe);!r||t?this._getEarlyAccessFeatures(e,n):e(r)}_getEarlyAccessFeatures(e,t){var n=this;return z(function*(){let r=n._client;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._set({[pe]:a})}catch(e){n._logger.error(`Early access feature request failed`,e);return}try{e(a)}catch(e){n._logger.error(`Early access feature callback failed`,e)}})()}_prepareFeatureFlagsForCallbacks(){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),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();let{flags:t,flagVariants:n}=this._prepareFeatureFlagsForCallbacks();
1this.featureFlagEventHandlers.forEach(r=>{try{r(t,n,{errorsLoading:e})}catch(e){this._logger.error(`Error while running feature flags callback`,e)}})}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){let n=this._prop(`$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._set({[ye]:B(B(B({},n),a),r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){let n=B({},this._prop(`$stored_person_properties`)||{});e.forEach(e=>{delete n[e]}),this._set({[ye]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(ye),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){let n=this._prop(`$stored_group_properties`)||{},r=B({},n);for(let t of Object.keys(e))r[t]=B(B({},n[t]),e[t]);this._set({[be]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){let t=this._prop(`$stored_group_properties`)||{};this._set({[be]:B(B({},t),{},{[e]:{}})})}else this._remove(be)}reset(){this._requestGeneration++,this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0}}},Lu={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){return!!this._lazyLoadedSessionRecording?.isStarted}get status(){return this._recordingStatus===`awaiting_config`||this._recordingStatus===`missing_config`?this._recordingStatus:this._lazyLoadedSessionRecording?.status??this._recordingStatus}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Nl,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var e,t;if(!O?.visibilityState||O.visibilityState===`visible`)return!0;let n=D==null||(e=D.performance)==null||(t=e.getEntriesByType)==null?void 0:t.call(e,`visibility-state`);return!n?.length||n.some(e=>e.name===`visible`)})(),this._onVisibilityChange=()=>{var e,t;O?.visibilityState===`visible`&&(this._documentWasEverVisible=!0,(e=this._lazyLoadedSessionRecording)==null||(t=e.setDocumentWasEverVisible)==null||t.call(e,!0))},!this._instance.sessionManager)throw Fl.error(`started without valid sessionManager`),Error(`[SessionRecording] started without valid sessionManager. This is a bug.`);if(this._config.cookieless_mode===`always`)throw Error(`[SessionRecording] cannot be used with cookieless_mode="always"`);O!=null&&O.addEventListener&&G(O,`visibilitychange`,this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,O==null||(t=O.removeEventListener)==null||t.call(O,`visibilitychange`,this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){let e=!!this._instance.get_property(`$session_recording_remote_config`)?.enabled,t=!this._config.disable_session_recording,n=this._config.disable_session_recording||this._instance.consent.isOptedOut();return D&&e&&t&&!n}startIfEnabledOrStop(e){if(this._sessionRecordingDisposed||this._isRecordingEnabled&&this._lazyLoadedSessionRecording?.isStarted)return;let t=!P(Object.assign)&&!P(Array.from);this._isRecordingEnabled&&t?(this._lazyLoadAndStart(e),Fl.info(`starting`)):(this._recordingStatus=Nl,this.stopRecording())}_lazyLoadAndStart(e){var t;if(this._isRecordingEnabled){if(this._recordingStatus!==`awaiting_config`&&this._recordingStatus!==`missing_config`&&(this._recordingStatus=Pl),k!=null&&(t=k.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&k.__PosthogExtensions__?.initSessionRecording)this._onScriptLoaded(e);else{var n,r;let t=this._instance.sessionManager;(n=k.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,this._scriptName,n=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return n?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Fl.error(`could not load recorder`,n)):void this._onScriptLoaded(e);this._recordingStatus=`disabled`})}}}stopRecording(){var e,t;(e=this._persistFlagsOnSessionListener)==null||e.call(this),this._persistFlagsOnSessionListener=void 0,(t=this._lazyLoadedSessionRecording)==null||t.stop()}_discardRecording(e=!1){var t,n;(t=this._persistFlagsOnSessionListener)==null||t.call(this),this._persistFlagsOnSessionListener=void 0,(n=this._lazyLoadedSessionRecording)==null||n.discard({discardProducerEvents:e})}_resetSampling(){var e,t;(e=this._persistence)==null||e.unregister(`$session_is_sampled`),(t=this._persistence)==null||t.unregister(`$replay_sample_rate`)}_validateSampleRate(e,t){if(L(e))return null;let n=R(e)?e:parseFloat(e);return typeof(r=n)!=`number`||!Number.isFinite(r)||0>r||r>1?(Fl.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):n;var r}_persistRemoteConfig(e){if(this._persistence){var t;let n=this._persistence,r=()=>{let t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this._val
1idateSampleRate(this._config.session_recording?.sampleRate,`session_recording.sampleRate`),i=this._validateSampleRate(t?.sampleRate,`remote config sampleRate`),a=r??i;L(a)&&this._resetSampling();let o=t?.minimumDurationMilliseconds;n.register({[S]:B(B({cache_timestamp:Date.now(),enabled:!!t},t),{},{networkPayloadCapture:B({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:P(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this._persistFlagsOnSessionListener)==null||t.call(this),this._persistFlagsOnSessionListener=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){let t=e.ok?e.config:void 0;t&&`sessionRecording`in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),this._discardRecording()):(this._persistRemoteConfig(t),this.startIfEnabledOrStop()):(this._recordingStatus===`awaiting_config`&&(this._recordingStatus=`missing_config`,Fl.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t=`log`){this._lazyLoadedSessionRecording?.log?this._lazyLoadedSessionRecording.log(e,t):Fl.warn(`log called before recorder was ready`)}get _scriptName(){var e,t;let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(S);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}_isRemoteConfigFresh(){let e=this._instance.get_property(S);if(!e)return!1;let t;try{t=typeof e==`object`?e:JSON.parse(e)}catch(e){return Fl.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}return!L(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,n;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!k.__PosthogExtensions__?.initSessionRecording)return Fl.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Ye]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=k.__PosthogExtensions__?.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===`missing_config`||this._recordingStatus===`awaiting_config`)return;this._recordingStatus=`awaiting_config`,Fl.info(`persisted remote config is stale, requesting fresh config before starting`),new _s(this._instance).load();return}this._recordingStatus=Pl,(t=(n=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)==null||t.call(n,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=Nl}onRRwebEmit(e){var t,n;(t=this._lazyLoadedSessionRecording)==null||(n=t.onRRwebEmit)==null||n.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||(t=this._persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this._lazyLoadedSessionRecording)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||(t=this._persistence)==null||t.register({$replay_override_sampling:!0}),(e=this._lazyLoadedSessionRecording)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this._lazyLoadedSessionRecording||(n=this._persistence)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this._lazyLoadedSessionRecording)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this._lazyLoadedSessionRecording?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){return!!this._lazyLoadedSessionRecording?.tryAddCustomEvent(e,t)}flushBeforeIdentityReset(){var e,t;(e=this._lazyLoadedSessionRecording)==null||(t=e.flushBeforeIdentityReset)==null||t.call(e)}}},Ru={autocapture:class extends xl{constructor(e){super(new Sl(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){let e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(V.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,V.info(`History API monitoring stopped`)}monitorHistoryChanges(){D&&D.history&&(this._patchHistoryMethod(`pushState`),this._patchHistoryMethod(`replaceState`),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(e){if(!D||D.history[e]?.__posthog_wrapped__)return;let t=this;El(D.history,e,n=>
1function(r,i,a){n.call(this,r,i,a),t._capturePageview(e)})}_getCurrentLocation(){let e=D?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}_getCaptureOptions(){let e=this._instance.config.capture_pageview;return e===`history_change`?{path:!0}:N(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){let t=this._getCaptureOptions(),n=this._lastLocation;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this._shouldCaptureHashChanges(t)&&e.hash!==n.hash))}_capturePageview(e){try{let t=this._getCurrentLocation();if(!t)return;this._hasLocationChanged(t)&&this._instance.capture(ut,{navigation_type:e}),this._lastLocation=t}catch(t){V.error(`Error capturing ${e} pageview`,t)}}_setupPopstateListener(){if(this._popstateListener)return;let e=()=>{this._capturePageview(`popstate`)};G(D,`popstate`,e),this._popstateListener=()=>{D&&D.removeEventListener(`popstate`,e)}}_setupHashchangeListener(){if(this._hashchangeListener)return;let e=()=>{this._capturePageview(`hashchange`)};G(D,`hashchange`,e),this._hashchangeListener=()=>{D&&D.removeEventListener(`hashchange`,e)}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!!this.instance.persistence?.props[m],this.rageclicks=new hl(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return N(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return L(this._config.capture_heatmaps)?L(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Il.info(`starting...`),this._setupListeners(),this._onVisibilityChange()}else clearInterval(this._flushInterval??void 0),this._removeListeners(),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({[m]:n}),this._enabledServerSide=n,this.startIfEnabled()}getAndClearBuffer(){let e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){Ll(e.originalEvent)&&this._onClick(e.originalEvent,`deadclick`)}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=O?.visibilityState===`visible`?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){D&&O&&(this._flushHandler=this._flush.bind(this),G(D,lt,this._flushHandler),this._onClickHandler=e=>this._onClick(e||D?.event),G(O,`click`,this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||D?.event),G(O,`mousemove`,this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new ho(this.instance,po,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),G(O,ct,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;D&&O&&(this._flushHandler&&D.removeEventListener(lt,this._flushHandler),this._onClickHandler&&O.removeEventListener(`click`,this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&O.removeEventListener(`mousemove`,this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&O.removeEventListener(ct,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),(e=this._deadClicksCapture)==null||e.stop(),this._initialized=!1)}_getProperties(e,t){let n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){let r=e;for(;r&&ka(r)&&!Y(r,`body`);){if(r===n)return!1;let e;try{e=(r.ownerDocument?.defaultView??D)?.getComputedStyle(r).position}catch{return!1}if(A(t,e))return!0;r=Va(r)}return!1}(La(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}_onClick(e,t=`click`){var n;if(Oa(e.target)||!Ll(e))return;let r=this._getProperties(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Ja(La(e),this.instance.config.rageclick)&&this._capture(B(B({},r),{},{type:`rageclick`})),this._capture(r)}_onMouseMove(e){!Oa(e.target)&&Ll(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,`mousemove`))},500))}_capture(e){if(!D)return;let t=this._config.disable_capture_url_hashes?fr(D.location.href):D.location.href,n=this._config.custom_personal_data_properties,r=Oo(t,this._config.mask_personal_data_properties?[...Mo,...n||[]]:[],Po);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(e)}_flush(){this._buffer&&!Pt(this._buffer)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ho,webVitalsAutocapture:class{constructor(e){this._instance=e,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,this._buffer.metrics.length!==0&&(this._instance.capture(`$web_vitals`,B({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>
1B(B({},e),{},{[`$web_vitals_${t.name}_event`]:B({},t),[`$web_vitals_${t.name}_value`]:t.value}),{}))),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},L(e?.name)||L(e?.value))return void Ol.error(`Invalid metric received`,e);let t=typeof e.navigationURL==`string`?e.navigationURL:void 0,n=this._maskedURL(t);if(P(n))return;let r=R(e.navigationId)||typeof e.navigationId==`string`?`navigation:${e.navigationId}`:`url:${n}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void Ol.error(`Ignoring metric with value >= `+this._maxAllowedValue,e);this._buffer.navigationKey!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),P(this._buffer.navigationKey)&&(this._buffer.navigationKey=r,this._buffer.url=n),this._buffer.firstMetricTimestamp=P(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;let i=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),a=B(B(B({},e),t?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete a.entries,N(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){let t={};for(let n of Ml){let r=n===`url`&&typeof e.attribution[n]==`string`?this._maskedURL(e.attribution[n]):e.attribution[n];P(r)||(t[n]=r)}a.attribution=t}else delete a.attribution;P(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this._buffer.metrics.push(a),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let e,t,n,r,i=!1,a=k.__PosthogExtensions__,o=a?.postHogWebVitalsCallbacksByFlavor,s=o?.[this._callbackFlavor]||(this._callbackFlavor===`web-vitals`&&P(o)?a?.postHogWebVitalsCallbacks:void 0);if(!P(s)){let a=s.withoutAttribution,o=this.attributionMetrics;i=!P(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 Ol.error(`web vitals callbacks not loaded - not starting`);let c={reportSoftNavs:this.useSoftNavs},l=i&&this.attributionMetrics.indexOf(`INP`)>-1?B(B({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf(`LCP`)>-1&&e(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf(`INP`)>-1&&r(this._addToBuffer.bind(this),l),this._initialized=!0},this._enabledServerSide=!!this._instance.persistence?.props[v],this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){let e=N(this._perfConfig)?this._perfConfig?.web_vitals_allowed_metrics:void 0;return L(e)?this._instance.persistence?.props.$web_vitals_allowed_metrics||Al:e}get flushToCaptureTimeoutMs(){return(N(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let e=N(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return Lt(e)?e?Al:[]:j(e)?e:jl}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let e=N(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get _maxAllowedValue(){let e=N(this._perfConfig)&&R(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:kl;return e>0&&6e4>=e?kl:e}get isEnabled(){let e=gt?.protocol;if(e!==`http:`&&e!==`https:`)return Ol.info(`Web Vitals are disabled on non-http/https protocols`),!1;let t=N(this._perfConfig)?this._perfConfig.web_vitals:Lt(this._perfConfig)?this._perfConfig:void 0;return Lt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ol.info(`enabled, starting...`),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`capturePerformance`in t))return;let n=N(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=N(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[v]:n}),this._instance.persistence.register({[ee]:r})),this._enabledServerSide=n,this.startIfEnabled()}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?`web-vitals-with-attribution-soft-navs`:`web-vitals-soft-navs`:this.useAttribution?`web-vitals-with-attribution`:`web-vitals`}_loadScript(e){var t;let n=k.__PosthogExtensions__,r=this._callbackFlavor,i=n?.postHogWebVitalsCallbacksByFlavor;i?.[r]||r===`web-vitals`&&P(i)&&n?.postHogWebVitalsCallbacks?e():n==null||(t=n.loadExternalDependency)==null||t.call(n,this._instance,r,t=>{t?Ol.error(`failed to load script`,t):e()})}_maskedURL(e){let t=e||D?.location.href;if(!t)return void Ol.error(`Could not determine current URL`);let n=this._instance.config.disable_capture_url_hashes?fr(t):t,r=this._instance.config.custom_personal_data_properties;return Oo(n,this._instance.config.mask_personal_data_properties?[...Mo,...r||[]]:[],Po)}}},zu={exceptionObserver:class{constructor(e){this._startCapturing=()=>{if(!D||!this.isEnabled||!k.__PosthogExtensions__?.errorWrappingFunctions)return;let e=k.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,t=k.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=k.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=e(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=t(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=n(this.captureException.bind(this)))}catch(e){Cl.error(`failed to start`,e),this._stopCapturing()}},this._instance=e,this._remoteEnabled=!!this._instance.persistence?.props[h],this._rateLimiter=new Qt(B(B({},function(e={}){return{refillRate:e.exceptionRateLimiterRefillRate??e.__exceptionRateLimiterRefillRate??1,bucketSize:e.exceptionRateLimiterBucketSize??e.__exceptionRateLimiterBucketSize??10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:Cl})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){let e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return N(e)?t=B(B({},t),e):(P(e)?this._remoteEnabled:e)&&(t=B(B({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Cl.info(`enabled`),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,n;k.__PosthogExtensions__?.errorWrappingFunctions?e():(t=k.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`exception-autocapture`,t=>{if(t)return Cl.error(`failed to load script`,t);
1e()})}_stopCapturing(){var e,t,n;(e=this._unwrapOnError)==null||e.call(this),this._unwrapOnError=void 0,(t=this._unwrapUnhandledRejection)==null||t.call(this),this._unwrapUnhandledRejection=void 0,(n=this._unwrapConsoleError)==null||n.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`autocaptureExceptions`in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[h]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}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._rateLimiter.consumeRateLimit(r))return void Cl.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._suppressionRules=[],this._errorPropertiesBuilder=new wr([new Gr,new ti,new qr,new Kr,new $r,new Qr,new Yr,new ei],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=Lr.test(r)?r.replace(Lr,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);let e=zr(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(Ur(i,s)>=50)break}}let c=[...s].sort((e,t)=>t.start-e.start),l=c[c.length-1];if(l){let e=Vr(i,l);i.splice(l.start-e,e);for(let t of c)t.start-=e}for(let e of c)Br(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++)Wr(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 B(B({},e),{},{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||`?`});var n})}(i)}}(`web:javascript`,Nr,Ir)),this._instance=e,this._suppressionRules=this._instance.persistence?.get_property(`$error_tracking_suppression_rules`)??[],this._exceptionStepsConfig=oi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new si(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=oi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}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._suppressionRules=n,this._instance.persistence&&this._instance.persistence.register({[g]:this._suppressionRules,[_]:r})}get _captureExtensionExceptions(){var e;let t=!!this._instance.get_property(_);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!F(e)||e.trim().length===0)return void fu.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)=>ii.has(r)?(t.push(r),n):(n[r]=e[r],n),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));r.length>0&&fu.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this._exceptionStepsBuffer.add(B({[ni]:e,[ri]:new Date().toISOString()},n))}catch(e){fu.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{let t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep(`Exception dropped: matched a suppression rule`),void fu.info(`Skipping exception capture because a suppression rule matched`);if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep(`Exception dropped: thrown by a browser extension`),void fu.info(`Skipping exception capture because it was thrown by an extension`);if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep(`Exception dropped: thrown by an injected browser script`),void fu.info(`Skipping exception capture because it was thrown by an injected browser script`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep(`Exception dropped: thrown by the PostHog SDK`),void fu.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}let n=this._exceptionStepsConfig.enabled&&L(e.$exception_steps)?this._addBufferedExceptionSteps(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`,_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){du(e)||fu.error(`Failed to capture exception event. Dropping this exception.`,e),this._exceptionStepsBuffer.clear();return}}catch(e){du(e)||fu.error(`Failed to process exception event. Ignoring this exception.`,e);return}}_addBufferedExceptionSteps(e){try{let t=this._exceptionStepsBuffer.getAttachable();return t.length===0?e:B(B({},e),{},{$exception_steps:t})}catch(t){return fu.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[ni]:e,[ri]:new Date().toISOString()})}_coerceExceptionStepProperties(e){return N(e)?B({},e):{}}_getExceptionStepsConfig(){return this._instance.config.error_tracking?.exception_steps??{}}_matchesSuppressionRule(e){if(e.length===0)return!1;try{let t=e.reduce((e,{type:t,value:n})=>(F(t)&&t.length>0&&e.$exception_types.push(t),F(n)&&n.length>0&&e.$exception_values.push(n),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{let n=e.values.map(e=>{let n=Nc[e.operator],r=t[e.key];if(!n||!r)return!1;let i=j(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 fu.warn(`Failed to evaluate suppression rules. Capturing the exception.`,e),!1}}_isExtensionException(e){let t=e.flatMap(e=>e.stacktrace?.frames??[]),n=t.filter(({filename:e})=>!!e&&hu.some(t=>e.startsWith(t)));return n.length!==0&&(!n.every(({filename:e})=>!!e&&e.startsWith(pu))||e.some(({type:e,value:t})=>e===`NoResponse`||F(t)&&mu.some(({value:e,exact:n})=>n?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!t?.startsWith(pu)))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>F(e)&&gu.some(t=>e.includes(t)))}_isPostHogException(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}_isExceptionList(e){return!L(e)&&j(e)}}},Bu=B({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=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._persistence&&this._persistence.register({[b]:!!t.productTours}),!zl(this._instance))return!this._productTourManager&&L(this._persistence?.props.ph_product_tours)||Rl.info(`product tours disabled; stopping and clearing cached tours`),(n=this._productTourManager)==null||n.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&zl(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,n;k.__PosthogExtensions__?.generateProductTours?e():(t=k.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`product-tours`,t=>{t?Rl.error(`Could not load product tours script`,t):e()})}_startProductTours(){var e;!this._productTourManager&&(e=k.__PosthogExtensions__)!=null&&e.generateProductTours&&(this._productTourManager=k.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(j(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});let n=this._persistence;if(n){let r=n.props[De];if(j(r)&&!t)return this._cachedTours=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(!zl(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||Rl.warn(n):Rl.error(n),e([],{isLoaded:!1,error:n});return}let i=j(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=i,n&&n.register({[De]:i}),e(i,{isLoaded:!0})}})}getActiveProductTours(e){L(this._productTourManager)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;(t=this._productTourManager)==null||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),(t=this._productTourManager)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this._productTourManager)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this._productTourManager)==null||e.nextStep()}previousStep(){var e;(e=this._productTourManager)==null||e.previousStep()}clearCache(){var e;this._cachedTours=null,(e=this._persistence)==null||e.unregister(`ph_product_tours`)}resetTour(e){var t;(t=this._productTourManager)==null||t.resetTour(e)}resetAllTours(){var e;(e=this._productTourManager)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this._productTourManager)==null||t.cancelPendingTour(e)}}},Iu),Vu={siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(!t)return;let n=this.globalsForEvent(t);this._bufferedInvocations.push(n),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}get siteAppLoaders(){var e;return(e=k._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._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=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:B(B({},Si(e,Bl)),{},{properties:B(B(B({},e.properties),a?{$set:B(B({},e.properties?.$set??{}),a)}:{}),i?{$set_once:B(B({},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}}_prepareElementForSiteApp(e){let t=e.tagName?.toLowerCase();
2return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Vl.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)||(Vl.error(`prepare_external_dependency_script returned null`),null):e}_patchSiteAppElementInsertionMethods(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let t=O?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();let r=[],i=this,a=new WeakSet,o=(e,t,n)=>{if(!e?.[t])return;let i=e[t];e[t]=n(i),r.push(()=>{e[t]=i})},s=e=>{if(a.has(e))return e;let t=i._prepareElementForSiteApp(e);return t&&a.add(t),t},c=e=>e.map(e=>typeof e==`string`?e:s(e)).filter(e=>!I(e));return o(n,`appendChild`,e=>function(t){let n=s(t);return n?e.call(this,n):t}),o(n,`insertBefore`,e=>function(t,n){let r=s(t);return r?e.call(this,r,n):t}),o(n,`replaceChild`,e=>function(t,n){let r=s(t);return r?e.call(this,r,n):n}),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach(e=>{o(e,`append`,e=>function(...t){return e.apply(this,c(t))}),o(e,`prepend`,e=>function(...t){return e.apply(this,c(t))})}),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach(e=>{o(e,`before`,e=>function(...t){return e.apply(this,c(t))}),o(e,`after`,e=>function(...t){return e.apply(this,c(t))}),o(e,`replaceWith`,e=>function(...t){let n=c(t);return t.length&&!n.length?void 0:e.apply(this,n)})}),o(t.Element?.prototype,`insertAdjacentElement`,e=>function(t,n){let r=s(n);return r?e.call(this,t,r):null}),this._restoreSiteAppElementPatches=()=>{r.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,this._siteAppElementPatchCount===0&&((t=this._restoreSiteAppElementPatches)==null||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){let n=this._patchSiteAppElementInsertionMethods();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._bufferedInvocations.length&&(Vl.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>t.processEvent?.call(t,e))),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&((n=this._stopBuffering)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Vl.info(`Site app with id ${e.id} ${i?`loaded`:`errored`}`),r&&n()};try{let{processEvent:n}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),i(e)}}),!1);n&&(t.processEvent=n),r=!0}catch(t){Vl.error(Hl+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Vl.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}_setupSiteApps(){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)}_onCapturedEvent(e){if(Object.keys(this.apps).length===0)return;let t=this.globalsForEvent(e);for(let n of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>n.processEvent?.call(n,t))}catch(t){Vl.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._setupSiteApps(),void this._instance.on(`eventCaptured`,e=>this._onCapturedEvent(e))):void Vl.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((t=this._stopBuffering)==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;k[`__$$ph_site_app_${e}`]=this._instance,(r=k.__PosthogExtensions__)==null||(i=r.loadSiteApp)==null||i.call(r,this._instance,t,t=>{if(t)return Vl.error(Hl+e,t)})}else Vl.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}}},Hu={tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{let e=this._syncHostnamesForPatch();var t,n;e?(P(this._restoreXHRPatch)&&(this._restoreXHRPatch=(t=k.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),P(this._restoreFetchPatch)&&(this._restoreFetchPatch=(n=k.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,n;k.__PosthogExtensions__?.tracingHeadersPatchFns?e():(t=k.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`tracing-headers`,t=>{if(t)return Dl.error(`failed to load script`,t);
2e()})}_getConfiguredHostnames(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){let e=this._getConfiguredHostnames();return j(e)?(j(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(j(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;(e=this._restoreXHRPatch)==null||e.call(this),(t=this._restoreFetchPatch)==null||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},Uu=B({surveys:class extends Kl{constructor(e){var t;super(new Ql(e),(t=e,{get projectToken(){return t.config.token},kv:new Zl(t)})),this._instance=e}_sendSurveysRequest(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})})}}},Iu),Wu={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){k.ph_toolbar_state=e}_getToolbarState(){return k.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,n=void 0){if(ea(this.instance.config)||!D||!O)return!1;e??=D.location,n??=D.history;try{if(!t){try{D.localStorage.setItem(`test`,`test`),D.localStorage.removeItem(`test`)}catch{return!1}t=D?.localStorage}let r=$l||ko(e.hash,`__posthog`)||ko(e.hash,`state`),i,a=r?pr(()=>JSON.parse(atob(decodeURIComponent(r))))||pr(()=>JSON.parse(decodeURIComponent(r))):null;return a&&a.action===`ph_authorize`?(i=a,i.source=`url`,i&&Object.keys(i).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):(i=JSON.parse(t.getItem(eu)||`{}`),i.source=`localstorage`,delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}_callLoadToolbar(e){let t=k.ph_load_toolbar||k.ph_load_editor;!L(t)&&M(t)?t(e,this.instance):tu.warn(`No toolbar load function found`)}loadToolbar(e){let t=!!O?.getElementById(`__POSTHOG_TOOLBAR__`);if(!D||t)return!1;let n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=B(B({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(D.localStorage.setItem(eu,JSON.stringify(B(B({},r),{},{source:void 0}))),this._getToolbarState()===2)this._callLoadToolbar(r);else if(this._getToolbarState()===0){var i,a;this._setToolbarState(1),(i=k.__PosthogExtensions__)==null||(a=i.loadExternalDependency)==null||a.call(i,this.instance,`toolbar`,e=>{if(e)return tu.error(`[Toolbar] Failed to load`,e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),G(D,`turbolinks:load`,()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,n=void 0){return this.maybeLoadToolbar(e,t,n)}}},Gu=B({experiments:class e{get _config(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{e._logInfo(`retrieved web experiments from the server`),this._flagToExperiments=new Map,t.forEach(t=>{if(t.feature_flag_key){var n;this._flagToExperiments&&(e._logInfo(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(n=this._flagToExperiments)==null||n.set(t.feature_flag_key,t));let r=this._instance.getFeatureFlag(t.feature_flag_key);F(r)&&t.variants[r]&&this._applyTransforms(t.name,r,t.variants[r].transforms)}else if(t.variants)for(let n in t.variants){let r=t.variants[n];e._matchesTestVariant(r,this._instance)&&this._applyTransforms(t.name,n,r.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e._logInfo(_u);else if(!this._config.disable_web_experiments){if(L(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();
2e._logInfo(`applying feature flags`,t),t.forEach(e=>{if(this._flagToExperiments&&this._flagToExperiments?.has(e)){let t=this._instance.getFeatureFlag(e),n=this._flagToExperiments?.get(e);t&&n!=null&&n.variants[t]&&this._applyTransforms(n.name,t,n.variants[t].transforms)}})}}previewWebExperiment(){let t=e.getWindowLocation();if(t?.search){let n=Do(t?.search,`__experiment_id`),r=Do(t?.search,`__experiment_variant`);n&&r&&(e._logInfo(`previewing web experiments ${n} && ${r}`),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(n),r,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this._config.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._config.token}`),method:`GET`,timestampMode:`query`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(t,n,r){let i=r.filter(e=>e.id===t);i&&i.length>0&&(e._logInfo(`Previewing web experiment [${i[0].name}] with variant [${n}]`),this._applyTransforms(i[0].name,n,i[0].variants[n].transforms))}static _matchesTestVariant(t,n){return!L(t.conditions)&&e._matchUrlConditions(t,n)&&e._matchUTMConditions(t)}static _matchUrlConditions(t,n){if(L(t.conditions)||L(t.conditions?.url))return!0;let r=e.getWindowLocation();if(r){let e=Da(n,r.href);return!t.conditions?.url||vu[t.conditions?.urlMatchType??`icontains`](t.conditions.url,e)}return!1}
2static getWindowLocation(){return D?.location}static _matchUTMConditions(e){if(L(e.conditions)||L(e.conditions?.utm))return!0;let t=Io();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 _logInfo(e,...t){V.info(`[WebExperiments] ${e}`,t)}_applyTransforms(t,n,r){this._is_bot()?e._logInfo(_u):n===`control`?e._logInfo(`Control variants leave the page unmodified.`):r.forEach(r=>{r.selector&&(e._logInfo(`applying transform of variant ${n} for experiment ${t} `,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 ht&&this._instance?Dc(ht,this._config.custom_blocked_useragents):void 0}}},Iu),Ku={conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this._remoteConfigSuccessful=e.ok,!e.ok))return;let t=e.config.conversations;L(t)||(Lt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1}loadIfEnabled(){if(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||ea(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let e=k?.__PosthogExtensions__;if(e&&!P(this._isConversationsEnabled)&&this._isConversationsEnabled){if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{let t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);let n=e.loadExternalDependency;if(!n)return void this._handleLoadError(it);n(this._instance,`conversations`,t=>{t||!e.initConversations?this._handleLoadError(`Could not load conversations script`,t):this._completeInitialization(e.initConversations),this._isInitializing=!1})}catch(e){this._handleLoadError(`Error initializing conversations`,e),this._isInitializing=!1}}else yu.error(`Conversations enabled but missing token in remote config.`)}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,yu.info(`Conversations loaded successfully`)}catch(e){this._handleLoadError(`Error completing conversations initialization`,e)}else yu.error(`Cannot complete initialization: remote config is null`)}_handleLoadError(e,t){yu.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():yu.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!I(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?`disabled_by_config`:ea(this._instance.config)?`disabled_for_toolbar`:this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?`consent_opted_out`:!1===this._remoteConfigSuccessful?`remote_config_failed`:P(this._isConversationsEnabled)?this._remoteConfigSuccessful?`disabled_in_project`:`remote_config_pending`:this._isConversationsEnabled?L(this._remoteConfig)||!this._remoteConfig.token?`missing_token`:k?.__PosthogExtensions__?this._isInitializing?`initializing`:this._loadFailed?`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 z(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(yu.w
2arn(bu),null)})()}getMessages(e,t){var n=this;return z(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(yu.warn(bu),null)})()}markAsRead(e){var t=this;return z(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(yu.warn(bu),null)})()}getTickets(e){var t=this;return z(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(yu.warn(bu),null)})()}requestRestoreLink(e){var t=this;return z(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(yu.warn(bu),null)})()}restoreFromToken(e){var t=this;return z(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(yu.warn(bu),null)})()}restoreFromUrlToken(){var e=this;return z(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(yu.warn(bu),null)})()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}_onIdentityChanged(){var e;(e=this._conversationsManager)==null||e.setIdentity()}_onIdentityCleared(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},qu={logs:class{constructor(e){var t;this._instance=e,this.name=`logs`,this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=H(`[logs]`),this._coreLogger=B(B({},this._logger),{},{error:(...e)=>{e.some(Du)||this._logger.error(...e)}}),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,(e=this._core)==null||e.onReconnect(),(t=this._consoleCore)==null||t.onReconnect())},this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),D&&G(D,`online`,this._onReconnect)}_buildCore(e,t,n,r){var i;let a=xu((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new Vi(this._createHost(e,t),a,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,r),a]}_getCore(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this._core&&this._resolvedFrom===t||((n=this._core)==null||n.reset(),this._resolvedFrom=t,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this._consoleCore&&this._consoleResolvedFrom===t||((n=this._consoleCore)==null||n.reset(),this._consoleResolvedFrom=t,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},wu)),this._consoleCore}setup(e){var t;if(this._disposed)return;this._client=e,(t=this._instance)!=null&&(t=t.config)!=null&&(t=t.logs)!=null&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._remoteConfigWillArrive()&&this._persistedCaptureHint())&&this._startConsoleRecorder();let n=!1,r=e.onRemoteConfig(e=>{n=e.ok&&!0===e.config.logs?.captureConsoleLogs,this.onRemoteConfig(e)});this._disposed?r.dispose():(this._remoteConfigSubscription=r,n||this.loadIfEnabled())}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),(e=this._remoteConfigSubscription)==null||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,D?.removeEventListener(`online`,this._onReconnect),(t=this._consoleLogsDispose)==null||t.call(this),this._consoleLogsDispose=void 0,(n=this._core)==null||n.reset(),(r=this._consoleCore)==null||r.reset())}onRemoteConfig(e){var t;if(this._disposed)return;let n=e.ok?e.config.logs?.captureConsoleLogs:void 0;L(n)?this._stopRecorderStartedByPersistedHint():((t=this._instance)==null||(t=t.persistence)==null||t.register({$logs_capture_enabled_server_side:!!n}),n?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}reset(){var e,t,n,r;this._stopConsoleRecorder(),(e=this._core)==null||e.clearQueue(),this._queue=[],(t=this._core)==null||t.reset(),(n=this._consoleCore)==null||n.clearQueue(),this._consoleQueue=[],(r=this._consoleCore)==null||r.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){this._disposed||this._getCore().captureLog(e)}captureConsoleLog(e){this._disposed||this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,n){this._disposed||this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:n})}_persistedCaptureHint(){var e;return!!((e=this._instance)!=null&&(e=e.persistence)!=null&&(e=e.props)!=null&&e[x])}_remoteConfigWillArrive(){var e,t,n;return!((e=this._instance)!=null&&(t=e._shouldDisableFlags)!=null&&t.call(e))||!!((n=k._POSTHOG_REMOTE_CONFIG)!=null&&(n=n[this._instance.config.token])!=null&&n.config)}_onOptOut(){var e;this._stopConsoleRecorder(),(e=this._consoleCore)==null||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!k?.console)return;let t=xu((e=this._instance)==null||(e=e.config)==null?void 0:e.logs).maxBufferSize,n=!0;
2this._consoleRecorderUnpatchers.push(()=>{n=!1});for(let e of Su){let r;try{r=Cu(k.console[e])}catch{continue}r&&this._consoleRecorderUnpatchers.push(El(k.console,e,i=>{let a=(...r)=>{try{n&&this._recordConsoleEntry(e,r,t)}catch{}return i.apply(k.console,r)};return a.__rrweb_original__=r,a}))}this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}_recordConsoleEntry(e,t,n){if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&t.length!==0){if(this._instance?.is_capturing()){if(n>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&=(clearTimeout(this._consoleRecorderTimeout),void 0);for(let e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){let e=this._consoleBuffer;return this._stopConsoleRecorder(),e}get logger(){return this._capture_logger||={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._capture_logger}flushLogs(e){e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e)))}_logFlushError(e){Du(e)||this._logger.error(`PostHog logs flush failed:`,e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;let e=k?.__PosthogExtensions__;if(!e)return this._logger.error(`PostHog Extensions not found.`),void this._stopConsoleRecorder();let t=e.loadExternalDependency;if(!t)return this._logger.error(it),void this._stopConsoleRecorder();this._isLoading=!0;try{t(this._instance,`logs`,t=>{if(this._isLoading=!1,this._disposed||!this._isLogsEnabled)return;let n=e.logs;if(t||!n?.initializeLogs)this._logger.error(`Could not load logs script`,t),this._stopConsoleRecorder();else{let e=this._takeConsoleBuffer();var r;this._consoleLogsDispose=n.initializeLogs(this._client??this._instance),this._isLoaded=!0,e.length>0&&((r=n.replayConsoleBuffer)==null||r.call(n,this._client??this._instance,e))}})}catch(e){throw this._isLoading=!1,e}}_createHost(e,n){let r=this._instance;return{get isDisabled(){return!1},get optedOut(){return!r.is_capturing()},getPersistedProperty:t=>t===wt.LogsQueue?e():void 0,setPersistedProperty(e,t){e===wt.LogsQueue&&n(t??[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>t.LIB_NAME,getLibraryVersion:()=>t.LIB_VERSION}}_sendLogsBatch(e){return new Promise(t=>{if(Ao(this._consecutiveStatusZeroFailures,3))return void t({kind:`fatal`,error:Eu(void 0,`logs endpoint is unreachable, dropping batch`)});let n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout(()=>{this._logger.warn(`Logs request timed out before receiving a response`),r({kind:`retry-later`,error:Eu(void 0,`logs request timed out`)})},9e4);this._instance._send_request({method:`POST`,url:this._logsUrl(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{let t=e.statusCode;this._trackEndpointReachability(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._logger.warn(`Logs request failed before receiving an HTTP response`),r({kind:`retry-later`,error:Eu(e.error,`logs request failed before receiving an HTTP response`)})):r({kind:`retry-later`,error:e.error??Error(`logs request failed with status ${t}`)})}})})}_trackEndpointReachability(e){(e!==0||this._instance.__loaded)&&(this._consecutiveStatusZeroFailures=jo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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.`)))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,t.LIB_NAME,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,wu,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,n,r,i,a){if(n.length===0)return;let o=n.map(e=>e.record);a([]);let s=Li(o,Ii(r,t.LIB_NAME,t.LIB_VERSION),i,t.LIB_VERSION);this._instance._send_request({method:`POST`,url:this._logsUrl(),data:s,compression:`best-available`,batchKey:`logs`,transport:e})}_logsUrl(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}_getSdkContext(){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,L(r)||(t.sessionStartTimestamp=r),L(i)||(t.lastActivityTimestamp=i)}if(k!=null&&(e=k.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?fr(k.location.href):k.location.href),this._instance.featureFlags){let e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},Ju={metrics:class{constructor(e){this._instance=e,this._logger=H(`[metrics]`),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){if(this._disposed)return;let e=!!this._instance.config.metrics?.network;e&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0,n=()=>t?(e=>{let t=e.config.metrics?.network;return!0===t?{}:t||void 0})(e):void 0,r=Pu(e,n),i=Fu(e,n);return()=>{t=!1,r(),i()}})(this._instance):!e&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;var n;return this._core&&this._resolvedFrom===t||((n=this._core)==null||n.reset(),this._resolvedFrom=t,this._core=new Gi(this._createHost(),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._logger)),this._core}count(e,t=1,n){this._getCore().count(e,t,n)}
2gauge(e,t,n){this._getCore().gauge(e,t,n)}histogram(e,t,n){this._getCore().histogram(e,t,n)}flush(e){if(!this._core)return Promise.resolve();if(e){let t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error(`PostHog metrics flush failed:`,e))}reset(){var e;(e=this._core)==null||e.reset()}dispose(){var e,t;this._disposed=!0,(e=this._stopNetworkMetrics)==null||e.call(this),this._stopNetworkMetrics=void 0,(t=this._core)==null||t.reset()}_createHost(){let e=this._instance,n=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>n._sendMetricsBatch(e),getLibraryId:()=>t.LIB_NAME,getLibraryVersion:()=>t.LIB_VERSION}}_sendMetricsBatch(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(B(B({method:`POST`,url:this._metricsUrl(),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}`)})}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}};ml.__defaultExtensionClasses=B({},B(B(B(B(B(B(B(B(B(B(B(B(B({},Iu),Lu),Ru),zu),Bu),Vu),Uu),Hu),Wu),Gu),Ku),qu),Ju));var Yu=function(){t.SDK_DIST_CHANNEL=`npm`;let e=Zc[cl]=new ml;return function(){function e(){e.done||(e.done=!0,hc=!1,U(Zc,function(e){e._dom_loaded()}))}O?.addEventListener?O.readyState===`complete`?e():G(O,`DOMContentLoaded`,e,{capture:!1}):D&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();function Xu(e){return e.categories?.analytics===!0||e.allowed===!0&&e.categories===void 0}function Zu(e){if(typeof window>`u`)return;let t=window;(t._hsp??=[]).push([`addPrivacyConsentListener`,e])}var Qu=`/$7C2F0`,$u=new URL(`https://us.i.posthog.com`);new URL(`https://us-assets.i.posthog.com`);var ed=Symbol.for(`arcjet:posthog`);function td(){if(typeof window>`u`)throw Error(`PostHog can only be initialized in the browser`);if(window[ed]){console.warn(`PostHog is already initialized`);return}let e=Yu.init(`phc_5zXpESjq8Sb8xzgfnnprjX8ZfpdfpmhrYndyguYhdWW`,{api_host:Qu,opt_out_capturing_by_default:!0,debug:!1,ui_host:$u.toString(),autocapture:!0,enable_heatmaps:!0,rageclick:!0,advanced_disable_flags:!0});e.register({"✦app":`arcjet-docs`,"✦commit":`a3edaccb6027d14ea943d9b8e748f489327ab3ee`,"✦environment":`production`,"✦repository":`https://github.com/arcjet/arcjet-docs`}),Zu(t=>{Xu(t)?e.opt_in_capturing():e.opt_out_capturing()}),window[ed]=e}var nd=`1e8a6033a509691`,rd=`https://static.reo.dev/${nd}/reo.js`,id=Symbol.for(`arcjet:reo`),ad=`reo-script`,od=!1;
2function sd(){if(typeof window>`u`)throw Error(`Reo can only be initialized in the browser`);if(window[id])return;let e=window.Reo;if(!e){console.error(`Error loading Reo: window.Reo is missing`);return}window[id]=e,e.init({clientID:nd})}function cd(){if(document.getElementById(ad)){window.Reo&&sd();return}let e=document.createElement(`script`);e.id=ad,e.src=rd,e.async=!0,e.addEventListener(`load`,sd,{once:!0}),e.addEventListener(`error`,()=>{console.error(`Error loading Reo`)},{once:!0}),document.head.append(e)}function ld(){if(typeof window>`u`)throw Error(`Reo can only be initialized in the browser`);if(od)return;od=!0;let e=!1;Zu(t=>{let n=Xu(t);if(e&&!n){window.location.reload();return}e=n,n&&cd()})}td(),ld();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.