@deriv-com/analytics 1.43.0 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +0,0 @@
1
- /* @deriv-com/analytics - Browser ESM Bundle (RudderStack + PostHog) - Built with tsup */
2
- import{d as nn,e as on,f as an,g as ln,h as un}from"./chunk-MHY63WMT.mjs";var Pi,Il=["retriesPerformedSoFar"],Ol=["$set_once","$set"];function Oo(e,t){if(e==null)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.indexOf(s)!==-1)continue;i[s]=e[s]}return i}function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},w.apply(null,arguments)}function hn(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(u){return void i(u)}a.done?t(l):Promise.resolve(l).then(s,r)}function X(e){return function(){var t=this,i=arguments;return new Promise(function(s,r){var n=e.apply(t,i);function o(l){hn(n,s,r,o,a,"next",l)}function a(l){hn(n,s,r,o,a,"throw",l)}o(void 0)})}}var f="u">typeof window?window:void 0,Se="u">typeof globalThis?globalThis:f,_e=Se?.navigator,E=Se?.document,ne=Se?.location,_i=Se?.fetch,Dr=Se!=null&&Se.XMLHttpRequest&&"withCredentials"in new Se.XMLHttpRequest?Se.XMLHttpRequest:void 0,cn=Se?.AbortController,Cl=Se?.CompressionStream,$e=_e?.userAgent;function Co(){return!(!f||f.navigator.onLine===!1)}var Zt=typeof globalThis<"u"?globalThis:f;Zt&&typeof self>"u"&&(Zt.self=Zt),Zt&&typeof File>"u"&&(Zt.File=function(){});var O=f??{},dn="0.8.2",it={DEBUG:!1,LIB_VERSION:dn,LIB_NAME:"browser-common",JS_SDK_VERSION:dn},Al=["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"],vn=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var i=e.toLowerCase();return Al.concat(t).some(s=>{var r=s.toLowerCase();return i.indexOf(r)!==-1})};function A(e,t){return e.indexOf(t)!==-1}var ps=function(e){return e.trim()},tr=function(e){return e.replace(/^\$/,"")};function Ao(e){var t,i=[];return(t=JSON.stringify(e,function(s,r){if(typeof r=="bigint")return r.toString();if(typeof r!="function"&&typeof r!="symbol"){if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r&&typeof r=="object"){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(r))return"[Circular]";i.push(r)}return r}}))!==null&&t!==void 0?t:"null"}var We=(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})({}),ir=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({}),Ml=["$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"],Ll=["token"],Mo=Object.prototype,Lo=Mo.hasOwnProperty,fs=Mo.toString,C=Array.isArray||function(e){return fs.call(e)==="[object Array]"},ke=e=>typeof e=="function",j=e=>e===Object(e)&&!C(e),Oe=e=>{if(j(e)){for(var t in e)if(Lo.call(e,t))return!1;return!0}return!1},b=e=>e===void 0,q=e=>fs.call(e)=="[object String]",hi=e=>q(e)&&e.trim().length===0,oe=e=>e===null,D=e=>b(e)||oe(e),ae=e=>fs.call(e)=="[object Number]"&&e==e,Ze=e=>ae(e)&&e>0,Te=e=>fs.call(e)==="[object Boolean]",Dl=e=>A(Ml,e),Nl=e=>A(Ll,e);function Do(e){return e===null||typeof e!="object"}function Yi(e,t){return{}.toString.call(e)==="[object "+t+"]"}function ki(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 No(e,Error)}}function Nr(e){return"u">typeof Event&&No(e,Event)}function No(e,t){try{return e instanceof t}catch{return!1}}var jl=[!0,"true",1,"1","yes"],bs=e=>A(jl,e),ql=[!1,"false",0,"0","no"];function Je(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),ae(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Je(r??i,t,i,s))}var Bl=class{constructor(e){this.C={},this.I=e.I,this.R=Je(e.bucketSize,0,100,e.A),this.O=Je(e.refillRate,0,this.R,e.A),this.N=Je(e.refillInterval,0,864e5,e.A)}F(e,t){var i=Math.floor((t-e.lastAccess)/this.N);i>0&&(e.tokens=Math.min(e.tokens+i*this.O,this.R),e.lastAccess=e.lastAccess+i*this.N)}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this.C[s];return r?this.F(r,i):this.C[s]=r={tokens:this.R,lastAccess:i},r.tokens===0||(r.tokens--,r.tokens===0&&((t=this.I)==null||t.call(this,e)),r.tokens===0)}stop(){this.C={}}},jt="Mobile",mi="Android",Ki="Tablet",jo="Android Tablet",qo="iPad",Bo="Apple Watch",ji="Safari",gs="BlackBerry",Uo="Samsung Internet",qi="Chrome",Ho="Chrome iOS",zo="Internet Explorer",Vo="Internet Explorer Mobile",Wo="Opera",Go="Microsoft Edge",Bi="Firefox",Jo="Firefox iOS",Xi="Nintendo",Zi="PlayStation",_s="Xbox",Yo="Android Mobile",Ko="Mobile Safari",ws="Windows",Xo="Windows Phone",pn="Nokia",sr="Ouya",Ul="Generic "+jt.toLowerCase(),Zo="Generic "+Ki.toLowerCase(),rr="Konqueror",Qo="Oculus Browser",ea="Vivaldi",ta="Yandex",ia="Whale",sa="DuckDuckGo",ra="Pale Moon",na="Waterfox",nr="Brave",oa="Claude",aa="Codex",la="ChatGPT",ua="Google Search App",Es=new RegExp("Version/(\\d+(\\.\\d+)?)"),xs=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Hl=new RegExp(_s,"i"),zl=new RegExp("PlayStation \\w+","i"),Vl=new RegExp("Nintendo \\w+","i"),jr=new RegExp("BlackBerry|PlayBook|BB10","i"),Wl={"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"},ha=function(e,t,i,s){t=t||"";var r=(function(n){return n!=null&&n.brave?nr:null})(i);return r||(s!=null&&s.detectGoogleSearchApp&&A(e,"GSA/")?ua:A(e," OPR/")&&A(e,"Mini")?"Opera Mini":A(e," OPR/")?Wo:jr.test(e)?gs:A(e,"IEMobile")||A(e,"WPDesktop")?Vo:A(e,"OculusBrowser")?Qo:A(e,"SamsungBrowser")?Uo:A(e,"Edge")||A(e,"Edg/")?Go:A(e,"Vivaldi/")?ea:A(e,"YaBrowser/")?ta:A(e,"Whale/")?ia:A(e,"DuckDuckGo/")||A(e,"Ddg/")?sa:A(e,"Claude/")?oa:A(e,"Codex/")?aa:A(e,"ChatGPT/")?la:A(e,"FBIOS")?"Facebook Mobile":A(e,"UCWEB")||A(e,"UCBrowser")?"UC Browser":A(e,"CriOS")?Ho:A(e,"CrMo")||A(e,qi)?qi:A(e,mi)&&A(e,ji)?Yo:A(e,"FxiOS")?Jo:A(e.toLowerCase(),rr.toLowerCase())?rr:A(e,"Brave/")?nr:((n,o)=>o&&A(o,"Apple")||(function(a){return A(a,ji)&&!A(a,qi)&&!A(a,mi)})(n))(e,t)?A(e,jt)?Ko:ji:A(e,"PaleMoon/")?ra:A(e,"Waterfox/")?na:A(e,Bi)?Bi:A(e,"MSIE")||A(e,"Trident/")?zo:A(e,"Gecko")?Bi:"")},Gl={[Vo]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Go]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[qi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Ho]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ji]:[Es],[Ko]:[Es],[Wo]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Bi]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Jo]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[rr]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[gs]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Es],[Yo]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Uo]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Qo]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[ea]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[ta]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ia]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[nr]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[oa]:[xs],[aa]:[xs],[la]:[xs],[sa]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[ra]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[na]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[ua]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[zo]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Jl=function(e,t,i,s){var r=Gl[ha(e,t,i,s)];if(b(r))return null;for(var n=0;r.length>n;n++){var o=e.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},fn=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[_s,e&&e[1]||""]],[new RegExp(Xi,"i"),[Xi,""]],[new RegExp(Zi,"i"),[Zi,""]],[jr,[gs,""]],[new RegExp(ws,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Xo,""];if(new RegExp(jt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=Wl[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[ws,s]}return[ws,""]}],[/((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=>{var t="";return e&&e.length>=3&&(t=b(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[mi,[e[2],e[3],e[4]||"0"].join(".")]:[mi,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],ca=function(e){for(var t=0;fn.length>t;t++){var i=fn[t],s=i[1],r=i[0].exec(e),n=r&&(ke(s)?s(r,e):s);if(n)return n}return["",""]},gn=function(e){return Vl.test(e)?Xi:zl.test(e)?Zi:Hl.test(e)?_s:new RegExp(sr,"i").test(e)?sr:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?Xo:/iPad/.test(e)?qo:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Bo:jr.test(e)?gs:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(pn,"i").test(e)?pn:/(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(jt).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)?mi:jo:new RegExp("(pda|Mobile)","i").test(e)?Ul:new RegExp(Ki,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?Zo:""},ks=/\bFBAV\/(\d+(?:\.\d+)*)/i,_n=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ks],[/\bFBAN\/EMA\b/i,"Facebook Lite",ks],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ks],[/\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"]],or="[Truncated]",ms="[Unserializable]";function Lt(e){for(var t="",i=0;e.length>i;i++){var s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"\uFFFD";else{var r=e.charCodeAt(i+1);56320>r||r>57343?t+="\uFFFD":(t+=e[i]+e[i+1],i++)}}return t}var Ri,mn,Ss,Yl=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function yn(e,t){return typeof(i=e)=="string"&&Yl.test(i)?e:t();var i}function da(e,t){var i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return i}function ct(e){return e&&e.split("#")[0]}function qr(e,t){var i=setTimeout(e,t);return i!=null&&i.unref&&i?.unref(),i}function bn(e,t,i){return va.apply(this,arguments)}function va(){return(va=X(function*(e,t,i){var s;try{return yield Promise.race([e,new Promise((r,n)=>{s=qr(()=>{try{i?.(),r()}catch(o){n(o)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function Kl(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Ss&&i.length===mn?Ss:(mn=i.length,Ss=i.reduce((s,r)=>{Ri||(Ri={});var n=Ri[r];if(n)s[n[0]]=n[1];else for(var o=e(r),a=o.length-1;a>=0;a--){var l,u=(l=o[a])==null?void 0:l.filename,h=t[r];if(u&&h){s[u]=h,Ri[r]=[u,h];break}}return s},{}))}}var Xl=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(t),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var t=this;return X(function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&C(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,s;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),w({},e,{cause:i,stack:s})}applyChunkIds(e,t){return e.map(i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return X(function*(){var i=e;for(var s of t.modifiers)i=yield s(i);return i})()}convertToExceptionList(e,t){var i,s,r,n={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(s=t.handled)===null||s===void 0||s,synthetic:(r=e.synthetic)!==null&&r!==void 0&&r}};e.stack&&(n.stacktrace={type:"raw",frames:e.stack});var o=[n];return e.cause!=null&&o.push(...this.convertToExceptionList(e.cause,w({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:Kl(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var s=(r,n)=>{if(4>=n){var o=this.buildCoercingContext(e,t,n);return this.applyCoercers(r,o)}};return w({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:r=>s(r,i),next:r=>s(r,i+1)})}};function ar(e,t,i,s,r){var n={platform:e,filename:t,function:i==="<anonymous>"?"?":i,in_app:!!t&&!t.startsWith("webkit-masked-url://")&&t!=="<anonymous>"};return b(s)||(n.lineno=s),b(r)||(n.colno=r),n}var pa=(e,t)=>{var i=e.indexOf("safari-extension")!==-1,s=e.indexOf("safari-web-extension")!==-1;return i||s?[e.indexOf("@")!==-1?e.split("@")[0]:"?",i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Zl=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ql=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,eu=/\((\S*)(?::(\d+))(?::(\d+))\)/,tu=(e,t)=>{var i=Zl.exec(e);if(i)return ar(t,i[1],"?",+i[2],+i[3]);var s=Ql.exec(e);if(s){if(s[2]&&s[2].indexOf("eval")===0){var r=eu.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var n=pa(s[1]||"?",s[2]);return ar(t,n[1],n[0],s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},iu=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,su=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ru=(e,t)=>{var i=iu.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=su.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||"?",o=pa(n,r);return ar(t,r=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},wn=/\(error: (.*)\)/,nu=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=q(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Yi(e,"DOMException")}isDOMError(e){return Yi(e,"DOMError")}},ou=class{match(e){return ki(e)}coerce(e,t){var i,s=this.getStack(e),r=s===void 0;return{type:this.getType(e),value:this.getMessage(e,t),stack:s??((i=t.syntheticException)==null?void 0:i.stack),cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},au=class{match(e){return!!Yi(e,"ErrorEvent")&&(e.error!=null||this.an(e))}coerce(e,t){var i;if(e.error!=null)return t.apply(e.error);var s=t.apply(e.message);return w({},s,{stack:(i=this.sn(e))!==null&&i!==void 0?i:s.stack,synthetic:!0})}an(e){return q(e.message)&&e.message.length>0}sn(e){var t,i,s=e,r=(t=s.lineno)!==null&&t!==void 0?t:0,n=(i=s.colno)!==null&&i!==void 0?i:0;if(q(s.filename)&&s.filename.length!==0&&r!==0)return`Error
3
- at `+s.filename+":"+r+":"+n}},lu=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,uu=class{match(e){return typeof e=="string"}coerce(e,t){var i,s=this.getInfos(e),r=s[0],n=s[1];return{type:r??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(lu);return s&&(t=s[1],i=s[2]),[t,i]}},hu=["fatal","error","warning","log","info","debug"];function fa(e,t){t===void 0&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(t>=r.length)return s===i.length?r:r.length>t?r.slice(0,t)+"...":r}return""}var cu=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,s,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(i=this.getStack(e))!==null&&i!==void 0?i:(s=t.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Nr(e))return e.constructor.name;var t="name"in e?e.name:void 0;return q(t)&&!hi(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+fa(e)}isSeverityLevel(e){return q(e)&&!hi(e)&&hu.indexOf(e)>=0}getStack(e){try{return q(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:q(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ki(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},du=class{match(e){return Nr(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+fa(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},vu=class{match(e){return Do(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},pu=class{match(e){return Yi(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Nr(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Do(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(s)}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}},Qi="$message",es="$timestamp",fu=new Set([Qi,es]),Ps={enabled:!0,max_bytes:32768};function ts(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:Ps.enabled,max_bytes:_u(e.max_bytes,Ps.max_bytes)}:w({},Ps)}var gu=class{constructor(e){this.Gn=[],this.Zn=0,this.Rn=ts(e)}setConfig(e){this.Rn=ts(e),this.Jn()}add(e){var t=(function(s){var r;try{r=Ao(s)}catch{return}try{var n=JSON.parse(r);if(!j(n))return;var o=n,a=o[Qi],l=o[es];return!q(a)||a.trim().length===0||!q(l)&&!ae(l)?void 0:{step:o,json:r}}catch{return}})(e);if(t){var i=(function(s){if("u">typeof TextEncoder)return new TextEncoder().encode(s).length;for(var r=encodeURIComponent(s),n=0,o=0;r.length>o;o++)r[o]==="%"?(n+=1,o+=2):n+=1;return n})(t.json);i>this.Rn.max_bytes||(this.Gn.push({step:t.step,bytes:i}),this.Zn+=i,this.Jn())}}getAttachable(){return this.Gn.map(e=>e.step)}clear(){this.Gn=[],this.Zn=0}size(){return this.Gn.length}Jn(){for(;this.Zn>this.Rn.max_bytes&&this.Gn.length>0;){var e=this.Gn.shift();e&&(this.Zn-=e.bytes)}}};function _u(e,t){if(!ae(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var En=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function xn(e){return typeof e=="string"||e}function kn(e){return typeof e=="string"?e:void 0}var Qt,mu=["$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"],ga="NativeGzipValidationError",lr=e=>e.length>=2&&e[0]===31&&e[1]===139,Sn=(e,t)=>e===ir.GZipJS||t===ir.GZipJS||t==="gzip",Pn=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError",$i=e=>{throw da(ga,"Native gzip produced invalid output: "+e)},yu=(function(){var e=X(function*(t,i){18>t.size&&$i("too-short");var s=new Uint8Array(yield t.slice(0,10).arrayBuffer());lr(s)&&s[2]===8||$i("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(o=>{for(var a=(()=>{if(Qt)return Qt;Qt=[];for(var h=0;256>h;h++){for(var c=h,d=0;8>d;d++)c=1&c?3988292384^c>>>1:c>>>1;Qt[h]=c>>>0}return Qt})(),l=4294967295,u=0;o.length>u;u++)l=a[255&(l^o[u])]^l>>>8;return(4294967295^l)>>>0})(i)&&$i("invalid-crc");var n=i.length>>>0;r.getUint32(4,!0)!==n&&$i("invalid-size")});return function(t,i){return e.apply(this,arguments)}})();function ur(){return ur=X(function*(e,t,i){t===void 0&&(t=!0);try{var s=new TextEncoder().encode(e),r=new globalThis.CompressionStream("gzip"),n=r.writable.getWriter(),o=n.write(s).then(()=>n.close()).catch((function(){var u=X(function*(h){try{yield n.abort(h)}catch{}throw h});return function(h){return u.apply(this,arguments)}})()),a=new Response(r.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield yu(l,s),l}catch(u){if(i!=null&&i.rethrow)throw u;return t&&console.error("Failed to gzip compress data",u),null}}),ur.apply(this,arguments)}var bu={}.propertyIsEnumerable;function is(e,t){try{return _a(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Br(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:or};if(i.remainingNodes--,Te(e))return{boolValue:e};if(typeof e=="bigint")return(function(l,u){var h=l.toString(),c=BigInt("9223372036854775808");return l>=c||-c>l?(u?.debug("Attribute "+h+" is outside the int64 range; encoding it as a string"),{stringValue:h}):{intValue:h}})(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)};var r=BigInt(e).toString();return e>=9223372036854776e3||-9223372036854776e3>e?(t?.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:Lt(e)};if(typeof e=="function")return{stringValue:"[Function]"};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:or};if(e instanceof Date){var n=e.getTime(),o=Number.isFinite(n)?e.toISOString():String(e);return{stringValue:typeof o=="string"?Lt(o):String(o)}}i.ancestors.add(e);try{try{var a=e.toJSON;if(typeof a=="function")return Br(a.call(e),t,i,s+1)}catch{}return C(e)?{arrayValue:{values:wu(e,t,i,s+1)}}:{kvlistValue:{values:_a(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:Lt(String(e))}}function wu(e,t,i,s){for(var r=[],n=Math.min(e.length,1e3),o=0;n>o&&i.remainingNodes>0;o++)try{var a=o in e?e[o]:void 0;if(D(a))continue;r.push(Br(a,t,i,s))}catch{r.push({stringValue:ms})}return e.length>o&&r.push({stringValue:or}),r}function _a(e,t,i,s){var r=[];for(var n in e)if(bu.call(e,n)){if(!n){t?.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=i.remainingNodes){t?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=e[n];if(oe(o)||b(o))continue;r.push({key:Lt(n),value:Br(o,t,i,s)})}catch{r.push({key:Lt(n),value:{stringValue:ms}})}}return r}function ma(e,t,i){return w({},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":i})}var Rn={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"},ya={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}},Eu=ya.info;function xu(e){try{return Lt(String(e))}catch{return ms}}function ku(e,t,i,s){var r,n=ya[e.level||"info"]||Eu,o=n.text,a=n.number,l=((r=ae(s)?s:void 0)===void 0&&(r=Date.now()),String(r)+"000000"),u={};t.distinctId&&(u.posthogDistinctId=t.distinctId),t.sessionId&&(u.sessionId=t.sessionId),t.windowId&&(u["window.id"]=t.windowId),D(t.sessionStartTimestamp)||(u.sessionStartTimestamp=String(t.sessionStartTimestamp)),D(t.lastActivityTimestamp)||(u.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(u["url.full"]=t.currentUrl),t.screenName&&(u["screen.name"]=t.screenName),t.appState&&(u["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(u.feature_flags=t.activeFeatureFlags);var h=w({},u),c=e.attributes;if(c){var d=[];try{d=Object.keys(c)}catch{d=[]}for(var v of d){var p=void 0;try{p=c[v]}catch{p=ms}Object.defineProperty(h,v,{value:p,enumerable:!0,writable:!0,configurable:!0})}}var g={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:a,severityText:o,body:{stringValue:xu(e.body)},attributes:is(h,i)};return e.trace_id&&(g.traceId=e.trace_id),e.span_id&&(g.spanId=e.span_id),b(e.trace_flags)||(g.flags=e.trace_flags),g}function ba(e,t,i){return ma(e,t,i)}function wa(e,t,i,s){return{resourceLogs:[{resource:{attributes:is(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var Su=class{constructor(e,t,i,s,r,n,o){var a;n===void 0&&(n=()=>Promise.resolve()),this._instance=e,this.Rn=t,this.A=i,this.Qn=s,this.Kn=r,this.Xn=n,this.Yn=o,this.ts=null,this.es=0,this.rs=0,this.ns=0,this.ss=0,this.ls=0,this.us=!1,this.hs=t.maxBufferSize,this.ds=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this.vs=t.flushIntervalMs,this.cs=t.maxBatchRecordsPerPost,this.fs=t.rateCapWindowMs,this.ps=t.maxLogsPerInterval}clearQueue(){this.rs++,this._instance.setPersistedProperty(We.LogsQueue,[])}reset(){this.gs(),this.ss=0,this.ls=0,this.us=!1,this.ns=0,this.cs=this.Rn.maxBatchRecordsPerPost}onReconnect(){this.ns=0,this.ys()}captureLog(e,t){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var s=this.bs(e);if(s!==null)if(s.body){if(this._s()){var r={record:ku(s,(i=t?.context)!==null&&i!==void 0?i:this.Qn(),this.A,t?.occurredAtMs)};this.Kn(()=>this.ws(r))}}else this.A.info("Log was rejected in beforeSend function")}}bs(e){var t=this.Rn.beforeSend;if(!t)return e;var i=C(t)?t:[t],s=e;for(var r of i)try{var n=r(s);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;s=n}catch(o){return this.A.error("Error in beforeSend function for log:",o),null}return s}_s(){if(this.ps===void 0)return!0;var e=Date.now(),t=e-this.ss;return this.fs>t&&t>=0||(this.ss=e,this.ls=0,this.us=!1),this.ps>this.ls?(this.ls++,!0):(this.us||(this.A.warn("captureLog dropping logs: exceeded "+this.ps+" logs per "+this.fs+"ms"),this.us=!0),!1)}flush(){var e=this;return X(function*(){if(!e._instance.isDisabled)return e.ts||(e.ts=e.ks().finally(()=>{e.ts=null})),e.ts})()}ks(){var e=this;return X(function*(){var t;e.gs();var i=(t=e._instance.getPersistedProperty(We.LogsQueue))!==null&&t!==void 0?t:[];if(i.length!==0)for(var s=i.length,r=0;i.length>0&&s>r;){var n,o,a=e.rs;e.es=0;var l=Math.min(i.length,e.cs),u=i.slice(0,l),h=wa(u.map(d=>d.record),e.Ss(),(n=e.Yn)!==null&&n!==void 0?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance.xs(h);if(e.rs!==a)return;if(c.kind==="too-large"&&u.length>1)e.cs=Math.max(1,Math.floor(u.length/2)),e.A.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+e.cs);else if(c.kind==="retry-later"||(c.kind==="too-large"?e.A.warn("Dropping a single log record after 413 with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):c.kind==="ok"&&e.Rn.maxBatchRecordsPerPost>e.cs&&(e.cs=Math.min(e.Rn.maxBatchRecordsPerPost,e.cs+1)),yield e.Cs(u.length),i=(o=e._instance.getPersistedProperty(We.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,c.kind==="fatal"))throw c.error}})()}Cs(e){var t=this;return X(function*(){var i,s=Math.max(0,e-t.es),r=(i=t._instance.getPersistedProperty(We.LogsQueue))!==null&&i!==void 0?i:[];t._instance.setPersistedProperty(We.LogsQueue,r.slice(s)),yield t.Xn()})()}Ss(){return ba(this.Rn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}ws(e){var t;if(!this._instance.optedOut){var i=(t=this._instance.getPersistedProperty(We.LogsQueue))!==null&&t!==void 0?t:[];this.ds>i.length||(i.shift(),this.es++,this.A.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(We.LogsQueue,i),this.hs>i.length?this.Ts():this.ys()}}Ts(e){e===void 0&&(e=this.vs),this.Ms||(this.Ms=qr(()=>{this.Ms=void 0,this.ys()},e))}Is(){var e=Math.min(Math.max(0,this.ns-1),6);return this.vs*Math.pow(2,e)}Es(){var e=this._instance.getPersistedProperty(We.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return X(function*(){t.gs();var i=t.flush().catch(()=>{});e!==void 0?yield bn(i,e):yield i})()}flushWithTimeout(e){var t=this;return X(function*(){var i=t.flush();yield bn(i,e,()=>{i.catch(()=>{})})})()}ys(){this.flush().then(()=>{this.ns=0},e=>{this.ns++,this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.Es()&&this.Ts(this.Is())})}gs(){this.Ms&&(clearTimeout(this.Ms),this.Ms=void 0)}},Rs=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function $n(e){return String(e)+"000000"}function Tn(e,t,i,s){var r="";return s&&(r=Object.keys(s).sort().map(n=>JSON.stringify(n)+":"+JSON.stringify(s[n])).join(",")),e+"\0"+t+"\0"+(i??"")+"\0"+r}var Pu=class{constructor(e,t,i){this._instance=e,this.Rn=t,this.A=i,this.Rs=new Map,this.ts=null,this.As=!1,this.Ps=new Map,this.Fs=new Set,this.Os=0}count(e,t,i){t===void 0&&(t=1),this.$s({name:e,type:"count",value:t,unit:i?.unit,attributes:i?.attributes})}gauge(e,t,i){this.$s({name:e,type:"gauge",value:t,unit:i?.unit,attributes:i?.attributes})}histogram(e,t,i){this.$s({name:e,type:"histogram",value:t,unit:i?.unit,attributes:i?.attributes})}flush(){var e=this,t=this.ts,i=(function(){var s=X(function*(){t&&(yield t.catch(()=>{})),yield e.Ds()});return function(){return s.apply(this,arguments)}})()().finally(()=>{this.ts===i&&(this.ts=null)});return this.ts=i,i}drainWindow(){if(this.Rs.size===0)return null;var e=this.Rs;return this.Rs=new Map,this.As=!1,this.Ps=new Map,this.Fs=new Set,this.Ls(e)}reset(){this.Os++,this.gs(),this.Rs=new Map,this.ts=null,this.As=!1,this.Ps=new Map,this.Fs=new Set}$s(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this.bs(e);if(t!==null)if(t.name&&typeof t.name=="string")if(typeof t.value=="number"&&Number.isFinite(t.value))if(t.type==="count"&&0>t.value)this.A.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var i,s;try{i=t.attributes?w({},t.attributes):void 0,s=Tn(t.type,t.name,t.unit,i)}catch(o){return void this.A.warn("Dropping metric '"+t.name+"': attributes could not be serialized",o)}var r=this.Rs.get(s);if(!r){if(!this.Ns())return;r={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this.Rs.set(s,r)}var n=this.Ps.get(t.name);n===void 0?this.Ps.set(t.name,t.type):n===t.type||this.Fs.has(t.name)||(this.Fs.add(t.name),this.A.warn("Metric name '"+t.name+"' is already used as a "+n+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this.qs(r,t.value),this.Ts()}else this.A.warn("Dropping metric '"+t.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ns(){return this.Rn.maxSeriesPerFlush>this.Rs.size||(this.As||(this.As=!0,this.A.warn("Metric series cap reached ("+this.Rn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}qs(e,t){var i;switch(e.type){case"count":e.total=((i=e.total)!==null&&i!==void 0?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(Rs.length+1).fill(0)});var s=e.hist;s.count+=1,s.sum+=t,s.min=Math.min(s.min,t),s.max=Math.max(s.max,t),s.bucketCounts[(function(r,n){for(var o=0;n.length>o;o++)if(n[o]>=r)return o;return n.length})(t,Rs)]+=1}}bs(e){var t=this.Rn.beforeSend;if(!t)return e;var i=C(t)?t:[t],s=e;for(var r of i)try{var n=r(s);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;s=n}catch(o){return this.A.error("Error in beforeSend function for metric:",o),null}return s}Ts(){this.Ms||(this.Ms=qr(()=>{this.Ms=void 0,this.flush().catch(e=>{this.A.error("Metrics flush failed:",e)})},this.Rn.flushIntervalMs))}gs(){this.Ms&&(clearTimeout(this.Ms),this.Ms=void 0)}Ds(){var e=this;return X(function*(){if(e.Rs.size!==0){var t=e.Rs;e.Rs=new Map,e.As=!1,e.Ps=new Map,e.Fs=new Set;var i=e.Os,s=yield e._instance.js(e.Ls(t));if(i===e.Os)switch(s.kind){case"ok":return;case"retry-later":return e.Bs(t),void e.Ts();case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",s.error)}}})()}Ls(e){return t=this.Hs(e),i=(function(n,o,a){return ma(n,o,a)})(this.Rn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:is(i)},scopeMetrics:[{scope:{name:s,version:r},metrics:t}]}]};var t,i,s,r}Hs(e){var t=$n(Date.now()),i=new Map;for(var s of e.values()){var r,n=Tn(s.type,s.name,s.unit,void 0),o=i.get(n);o||(o=w({name:s.name},s.unit&&{unit:s.unit}),s.type==="count"?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:s.type==="gauge"?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},i.set(n,o));var a=is((r=s.attributes)!==null&&r!==void 0?r:{},this.A),l=$n(s.windowStartMs);if(s.type==="count"){var u,h={attributes:a,startTimeUnixNano:l,timeUnixNano:t,asDouble:(u=s.total)!==null&&u!==void 0?u:0};o.sum.dataPoints.push(h)}else if(s.type==="gauge"){var c,d={attributes:a,timeUnixNano:t,asDouble:(c=s.last)!==null&&c!==void 0?c:0};o.gauge.dataPoints.push(d)}else s.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:t,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Rs})}return Array.from(i.values())}Bs(e){var t,i;for(var s of e){var r=s[0],n=s[1],o=this.Rs.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=((t=o.total)!==null&&t!==void 0?t:0)+((i=n.total)!==null&&i!==void 0?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ns()&&this.Rs.set(r,n)}}},Ea=function(e,t){var i=(t===void 0?{}:t).debugEnabled,s={q(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];f&&(it.DEBUG||f.POSTHOG_DEBUG||i)&&!b(f.console)&&f.console&&("__rrweb_original__"in f.console[r]?f.console[r].__rrweb_original__:f.console[r])(e,...o)},debug(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.q("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.q("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.q("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.q("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(e,...n)},uninitializedWarning(r){s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Ea(e+" "+r,n)};return s},S=Ea("[PostHog.js]"),le=S.createLogger,Ru=le("[ExternalScriptsLoader]"),ss=e=>{var t=E?.querySelectorAll("script");if(t){for(var i=0;t.length>i;i++)if(t[i].src===e||t[i].getAttribute("src")===e)return t[i]}},mt=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return Ru.warn(t+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=ss(t);if(s){if(s.__posthog_loading_callback_fired)return i();var r=s.__posthog_loading_error;return r?i(r):(s.addEventListener("load",o=>{s.__posthog_loading_callback_fired=!0,i(void 0,o)}),void s.addEventListener("error",o=>{s.__posthog_loading_error=o,i(o)}))}var n=()=>{if(!E)return i("document not found");if(ss(t))return mt(e,t,i);var o=E.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=t,o.onload=u=>{o.__posthog_loading_callback_fired=!0,i(void 0,u)},o.onerror=u=>{o.__posthog_loading_error=u,i(u)},e.config.prepare_external_dependency_script&&(o=e.config.prepare_external_dependency_script(o)),!o)return i("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")E.head.appendChild(o);else{var a,l=E.querySelectorAll("body > script");l.length>0?(a=l[0].parentNode)==null||a.insertBefore(o,l[0]):E.body.appendChild(o)}};E!=null&&E.body?n():E?.addEventListener("DOMContentLoaded",n)},$s={},Fn=(e,t)=>{var i="/static/"+t+".js?v="+e.version;if(t==="toolbar"){var s=3e5;i=i+"&t="+Math.floor(Date.now()/s)*s}return e.requestRouter.endpointFor("assets",i)};O.__PosthogExtensions__=O.__PosthogExtensions__||{},O.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{if(t!=="remote-config"){var s=e.config.strict_script_versioning;if(s){var r=e.requestRouter.endpointFor("assets","/static/"+e.version+"/"+t+".js"),n=$s[r];if(s==="fallback"&&n){if(ss(n))return void mt(e,n,i);delete $s[r]}mt(e,r,s==="fallback"?(o,a)=>{if(o)if(typeof o=="string")i(o);else{var l,u=Fn(e,t);$s[r]=u;var h=ss(r);h==null||(l=h.parentNode)==null||l.removeChild(h),mt(e,u,i)}else i(void 0,a)}:i)}else mt(e,Fn(e,t),i)}else mt(e,e.requestRouter.endpointFor("assets","/array/"+e.config.token+"/config.js"),i)},O.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{mt(e,e.requestRouter.endpointFor("api",t),i)},it.DEBUG=!1,it.LIB_VERSION="1.428.7",it.LIB_NAME="web";var pe=it,$u="$people_distinct_id",Be="distinct_id",Ur="$device_id",Ts="$device_model",rs="__alias",Tu="__cmpns",Fs="$fbc",Ue="$fbc_persistence",hr="__timers",cr="$autocapture_disabled_server_side",dr="$heatmaps_enabled_server_side",vr="$exception_capture_enabled_server_side",xa="$error_tracking_suppression_rules",pr="$error_tracking_capture_extension_exceptions",fr="$web_vitals_enabled_server_side",Hr="$dead_clicks_enabled_server_side",zr="$product_tours_enabled_server_side",gr="$logs_capture_enabled_server_side",ka="$web_vitals_allowed_metrics",Dt="$session_recording_remote_config",Fu="$session_recording_enabled_server_side",Sa="$replay_sample_rate",Pa="$replay_override_sampling",Ra="$replay_override_linked_flag",$a="$replay_override_url_trigger",Ta="$replay_override_event_trigger",Ct="$sesid",Vr="$session_is_sampled",Iu="$session_past_minimum_duration",Ou="$session_recording_url_trigger_activated_session",Cu="$session_recording_event_trigger_activated_session",Au="$debug_first_full_snapshot_timestamp",Mu="$sess_rec_flush_size",Ne="$enabled_feature_flags",Ge="$active_feature_flags",_r="$early_access_features",wt="$feature_flag_details",at="$feature_flag_payloads",Et="$feature_flag_request_id",ci="$minimal_flag_called_events",Ve="$override_feature_flags",yt="$override_feature_flag_payloads",et="$stored_person_properties",lt="$stored_group_properties",Fa="$groups",mr="$surveys",ns="$surveys_loaded_at",yr="$surveys_activated",Ui="$surveys_activated_session",Hi="$surveys_activated_timestamps",zi="ph_product_tours",Lu="$product_tours_activated",Du="$product_tours_activated_session",Nu="$conversations_widget_session_id",ju="$conversations_ticket_id",qu="$conversations_widget_state",Bu="$conversations_user_traits",ut="$flag_call_reported",ai="$flag_call_reported_session_id",yi="$feature_flag_errors",ht="$feature_flag_evaluated_at",Ee="$user_state",br="$client_session_props",Ia="$capture_rate_limit",Oa="$initial_campaign_params",Ca="$initial_referrer_info",At="$initial_person_info",Wr="$epp",Is="$posthog_cookieless",Aa="$cookieless_mode",Ma="$sdk_debug_extensions_init_method",La="$sdk_debug_extensions_init_time_ms",wr="$sdk_debug_recording_script_not_loaded",Uu="$sdk_debug_replay_event_trigger_status",Hu="$sdk_debug_replay_linked_flag_trigger_status",zu="$sdk_debug_replay_matched_recording_trigger_groups",Vu="$sdk_debug_replay_pending_trigger_conditions",Wu="$sdk_debug_replay_remote_trigger_matching_config",Gu="$sdk_debug_replay_trigger_groups_count",Ju="$sdk_debug_replay_url_trigger_status",Yu="$session_recording_start_reason",Er="PostHog loadExternalDependency extension not found.",ot="anonymous",li="identified",Da="identified_only",qt="visibilitychange",os="beforeunload",Gr="$pageview",In="$pageleave",xr="$identify",On="$groupidentify";function Ti(e,t){C(e)&&e.forEach(t)}function U(e,t){if(!D(e))if(C(e))e.forEach(t);else if((s=>s instanceof FormData)(e))e.forEach((s,r)=>t(s,r));else for(var i in e)Lo.call(e,i)&&t(e[i],i)}var K=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)r[n]!==void 0&&(e[n]=r[n]);return e};function Vi(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Cn=function(e){try{return e()}catch{return}},Ku=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(r){S.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),S.critical(r)}}},Jr=function(e){var t={};return U(e,function(i,s){(q(i)&&i.length>0||ae(i))&&(t[s]=i)}),t};function Na(e){var t=w({},e);for(var i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch{}return t}var Xu=["herokuapp.com","vercel.app","netlify.app"];function Zu(e){var t=e?.hostname;if(!q(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of Xu)if(i===s)return!1;return!0}function z(e,t,i,s){var r=s??{},n=r.capture,o=r.passive;e?.addEventListener(t,i,{capture:n!==void 0&&n,passive:o===void 0||o})}function kr(e){return e.name==="ph_toolbar_internal"}var Sr=e=>{if(E){try{for(var t=e+"=",i=E.cookie.split(";").filter(n=>n.length),s=0;i.length>s;s++){for(var r=i[s];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 ae(e)&&isFinite(e)&&Math.floor(e)===e});var Qu=class Pr{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>t||0>i||0>s||0>r||t>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|i>>>8,n[7]=i,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new Pr(n)}toString(){for(var t="",i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),i!==3&&i!==5&&i!==7&&i!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Pr(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var i=0;16>i;i++){var s=this.bytes[i]-t.bytes[i];if(s!==0)return Math.sign(s)}return 0}},eh=class{generate(){var e=this.generateOrAbort();if(!b(e))return e;this.Ct=0;var t=this.generateOrAbort();if(b(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e,t=(e=Date.now(),ae(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0);if(t>this.Ct)this.Ct=t,this.Mt();else{if(this.Ct>=t+1e4)return;this.Tt++,this.Tt>4398046511103&&(this.Ct++,this.Mt())}return Qu.fromFieldsV7(this.Ct,Math.trunc(this.Tt/Math.pow(2,30)),this.Tt&Math.pow(2,30)-1,this.It.nextUint32())}Mt(){this.Tt=1024*this.It.nextUint32()+(1023&this.It.nextUint32())}constructor(){this.Ct=0,this.Tt=0,this.It=new th}},ja=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};f&&!b(f.crypto)&&crypto.getRandomValues&&(ja=e=>crypto.getRandomValues(e));var An,th=class{nextUint32(){return this.Rt.length>this.At||(ja(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}},He=()=>ih().toString(),ih=()=>(An||(An=new eh)).generate(),ei="",sh=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Rt=null,re={Et(){if(!oe(Rt))return Rt;if(Rt=!1,E)try{var e="__ph_cookie_support_"+He();re.Ot(e,"xyz"),Rt=Sr(e)==='"xyz"',re.Dt(e)}catch{Rt=!1}return Rt},Pt(e){S.error("cookieStore error: "+e)},Lt:Sr,Nt(e){var t;try{t=JSON.parse(re.Lt(e))||{}}catch{}return t},Ot(e,t,i,s,r){if(!E)return!1;try{var n="",o="",a=(function(h,c){if(c){var d=(function(p,g){if(g===void 0&&(g=E),ei)return ei;if(!g||["localhost","127.0.0.1"].includes(p))return"";for(var _=p.split("."),m=Math.min(_.length,8),y="dmn_chk_"+He();!ei&&m--;){var k=_.slice(m).join("."),x=y+"=1;domain=."+k+";path=/";g.cookie=x+";max-age=3",g.cookie.includes(y)&&(g.cookie=x+";max-age=0",ei=k)}return ei})(h);if(!d){var v=(p=>{var g=p.match(sh);return g?g[0]:""})(h);v!==d&&S.info("Warning: cookie subdomain discovery mismatch",v,d),d=v}return d?"; domain=."+d:""}return""})(E.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&S.warn("cookieStore warning: large cookie, len="+u.length),E.cookie=u,!0}catch{return!1}},Dt(e,t){if(E!=null&&E.cookie)try{re.Ot(e,"",-1,t)}catch{return}}},Os=null,B={Et(){if(!oe(Os))return Os;var e=!0;if(b(f))e=!1;else try{var t="__mplssupport__";B.Ot(t,"xyz"),B.Lt(t)!=='"xyz"'&&(e=!1),B.Dt(t)}catch{e=!1}return e||S.error("localStorage unsupported; falling back to cookie store"),Os=e,e},Pt(e){S.error("localStorage error: "+e)},Lt(e){try{return f?.localStorage.getItem(e)}catch(t){B.Pt(t)}return null},Nt(e){try{return JSON.parse(B.Lt(e))||{}}catch{}return null},Ot(e,t){try{return f?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(i){B.Pt(i)}return!1},Dt(e){try{f?.localStorage.removeItem(e)}catch(t){B.Pt(t)}}},Cs=[et,Ge,Ne,wt,at,Et,ht,yi,ut],bt=[Ur,Be,Ct,Vr,Wr,At,Ue,Ee],as=e=>e+"_cpm",rh=["__proto__","constructor","prototype"],As=e=>{if(!j(e))return{};var t={};return Object.keys(e).forEach(i=>{rh.indexOf(i)===-1&&(t[i]=e[i])}),t},Ms=function(e,t){t===void 0&&(t=[]);var i={};return[...bt,...t].forEach(s=>{var r=e[s];b(r)||oe(r)||r===""||(i[s]=r)}),i},qa=e=>{for(var t=5381,i=2166136261,s=0;e.length>s;s++){var r=e.charCodeAt(s);t=33*t^r,i=Math.imul(i^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Mn=(e,t)=>({p:t,f:qa(JSON.stringify(e))}),Ln=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var i=re.Nt(as(e)),s=i?.f===qa(t)&&C(i.p);return{properties:s?i.p:[],isValid:s}}catch{return{properties:[],isValid:!1}}},Ls=(e,t)=>t+"|"+(re.Lt(as(e))||""),$t={},Rr={Et:()=>!0,Pt(e){S.error("memoryStorage error: "+e)},Lt:e=>e in $t?$t[e]:null,Nt:e=>e in $t?$t[e]:null,Ot:(e,t)=>($t[e]=t,!0),Dt(e){delete $t[e]}},vt=null,G={Et(){if(!oe(vt))return vt;if(vt=!0,b(f))vt=!1;else try{var e="__support__";G.Ot(e,"xyz"),G.Lt(e)!=='"xyz"'&&(vt=!1),G.Dt(e)}catch{vt=!1}return vt},Pt(e){S.error("sessionStorage error: ",e)},Lt(e){try{return f?.sessionStorage.getItem(e)}catch(t){G.Pt(t)}return null},Nt(e){try{return JSON.parse(G.Lt(e))||null}catch{}return null},Ot(e,t){try{return f?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(i){G.Pt(i)}return!1},Dt(e){try{f?.sessionStorage.removeItem(e)}catch(t){G.Pt(t)}}},nh=class{constructor(e){this._instance=e}get Rn(){return this._instance.config}get consent(){return this.vo()?0:this.co}isOptedOut(){return this.Rn.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Rn.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rn.opt_out_capturing_by_default}optInOut(e){this.fo.Ot(this.po,e?1:0,this.Rn.cookie_expiration,this.Rn.cross_subdomain_cookie,this.Rn.secure_cookie)}reset(){this.fo.Dt(this.po,this.Rn.cross_subdomain_cookie)}get po(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get co(){var e=this.fo.Lt(this.po);return bs(e)?1:A(ql,e)?0:-1}get fo(){var e=this.Rn.opt_out_capturing_persistence_type,t=e==="localStorage"?B:re,i=t.Et()?t:Rr;if(!this.mo||this.mo!==i){this.mo=i;var s=e==="localStorage"?re:B;s.Lt(this.po)&&(this.mo.Lt(this.po)||this.optInOut(bs(s.Lt(this.po))),s.Dt(this.po,this.Rn.cross_subdomain_cookie))}return this.mo}vo(){return!!this.Rn.respect_dnt&&[_e?.doNotTrack,_e?.msDoNotTrack,O.doNotTrack,_e?.globalPrivacyControl].some(e=>bs(e))}};function Ba(e,t){var i,s=e==null||(i=e.config)==null?void 0:i.get_current_url;if(!ke(s))return t;try{var r=s(t);return q(r)&&r?r:t}catch(n){return S.error("Error in get_current_url, falling back to window.location.href",n),t}}function Dn(e){return e instanceof Element&&(e.id==="__POSTHOG_TOOLBAR__"||!(e.closest==null||!e.closest(".toolbar-global-fade-container")))}function Ye(e){return!!e&&e.nodeType===1}function xe(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ua(e){return!!e&&e.nodeType===3}function Yr(e){return!!e&&e.nodeType===11&&Ye(e.host)}function Kr(e){return e?ps(e).split(/\s+/):[]}function Nn(e,t){var i=(function(s){var r,n=f==null||(r=f.location)==null?void 0:r.href;return b(n)?void 0:Ba(s,n)})(t);return!!(i&&e&&e.some(s=>i.match(s)))}function Bt(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Kr(t)}function Ha(e){return D(e)?null:ps(e).split(/(\s+)/).filter(t=>vi(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function bi(e){var t="";return Nt(e)&&!wi(e)&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(i){var s;Ua(i)&&i.textContent&&(t+=(s=Ha(i.textContent))!==null&&s!==void 0?s:"")}),ps(t)}function di(e){var t;return b(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var Xr=["a","button","form","input","select","textarea","label"];function $r(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch{return!1}}function Tr(e,t){if(b(t))return!0;var i,s=function(n){if(t.some(o=>$r(n,o)))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function za(e){var t=e.parentNode;return!(!t||!Ye(t))&&t}var Ds=[".ph-no-autocapture","[data-ph-no-autocapture]"],Va=["next","previous","prev",">","<"],oh=[...Va,"+","-","\u2212","\u2013"],jn=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,qn=[".ph-no-rageclick",".ph-no-capture"],ah=["","text","search","email","password","url","tel","number"];function Wa(e,t){if(!f||Zr(e))return!1;var i,s,r,n,o;if(Te(t)?(i=!!t&&qn,s=void 0,r=!1):(i=(n=t?.css_selector_ignorelist)!==null&&n!==void 0?n:qn,s=t?.content_ignorelist,r=(o=t?.ignore_text_selection)!==null&&o!==void 0&&o),i===!1||r&&(function(l){return!(!l||!Ye(l))&&(!!xe(l,"textarea")||(xe(l,"input")?A(ah,(l.getAttribute("type")||"").toLowerCase()):(function(u){if(u.isContentEditable)return!0;var h=u.getAttribute==null?void 0:u.getAttribute("contenteditable");return h==="true"||h===""})(l)))})(e))return!1;var a=Ga(e,!1).targetElementList;return!(function(l,u){if(l===!1||b(l))return!1;var h;if(l===!0)h=Va;else{if(!C(l))return!1;if(l.length>10)return S.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;h=l.map(c=>c.toLowerCase())}return u.some(c=>{var d=c.safeText,v=c.ariaLabel;return h.some(p=>jn(d,p)||jn(v,p))})})(s,a.map(l=>{var u;return{safeText:bi(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))==null?void 0:u.toLowerCase().trim())||""}}))&&!Tr(a,i)}var Zr=e=>!e||xe(e,"html")||!Ye(e),Ga=(e,t)=>{if(!f||Zr(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],r=e;r.parentNode&&!xe(r,"body");)if(Yr(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=za(r);if(!n)break;if(t||Xr.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=f.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(i=!0)}catch{}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};function Nt(e){for(var t=new Set,i=0,s=e;s.parentNode&&!xe(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);var r=Bt(s);if(A(r,"ph-sensitive")||A(r,"ph-no-capture"))return!1}if(A(Bt(e),"ph-include"))return!0;var n=e.type||"";if(q(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!q(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function wi(e){return!!(xe(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||xe(e,"select")||xe(e,"textarea")||e.getAttribute("contenteditable")==="true")}var Bn=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Un=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,lh=[16,15,14,13],uh=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Hn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),zn=/[0-9A-Za-z_]/;function hh(e){for(var t=0,i=!1,s=e.length-1;s>=0;s--){var r=e.charCodeAt(s)-48;i&&(r*=2)>9&&(r-=9),t+=r,i=!i}return t%10==0}function vi(e,t){return t===void 0&&(t=!0),!(D(e)||q(e)&&(e=ps(e),(t?Bn.test((e||"").replace(/[- ]/g,"")):(function(i){var s;for(Un.lastIndex=0;s=Un.exec(i);){var r=s[2];if(r)for(var n=r.replace(/[- ]/g,""),o=0;n.length>o;o++)for(var a of lh){var l=o+a;if(n.length>=l){var u=n.slice(o,l);if(Bn.test(u)&&hh(u))return!0}}}return!1})(e))||(t?uh.test(e):(function(i){var s;for(Hn.lastIndex=0;s=Hn.exec(i);){var r=s[1],n=s[3];if(!(r&&n&&zn.test(r)&&zn.test(n)))return!0}return!1})(e))))}function Vn(e){var t=bi(e);return vi(t=(t+" "+Ja(e)).trim())?t:""}function Ja(e){var t="";return e&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(i){var s;if(i&&((s=i.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=bi(i);t=(t+" "+r).trim(),i.childNodes&&i.childNodes.length&&(t=(t+" "+Ja(i)).trim())}catch(n){S.error("[AutoCapture]",n)}}),t}function Wn(e){return e.replace(/"|\\"/g,'\\"')}function ch(e){var t=e.attr__class;if(t)return C(t)?t:Kr(t)}var Fi=le("[Dead Clicks]"),dh=()=>!0,vh=e=>{var t,i=!((t=e.instance.persistence)==null||!t.get_property(Hr)),s=e.instance.config.capture_dead_clicks;return Te(s)?s:!!j(s)||i},Gn=class{get lazyLoadedDeadClicksAutocapture(){return this.yo}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Hr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.bo(()=>{this._o()}):this.stop()}bo(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture?e():(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",s=>{s?Fi.error("failed to load script",s):e()})}_o(){var e;if(E){if(!this.yo&&(e=O.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=j(this.instance.config.capture_dead_clicks)?w({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.yo=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.yo.start(E),Fi.info("starting...")}}else Fi.error("`document` not found. Cannot start.")}stop(){this.yo&&(this.yo.stop(),this.yo=void 0,Fi.info("stopping..."))}},Ii=le("[SegmentIntegration]");function Jn(e,t,i){i===void 0&&(i=!0);var s=e.config.segment;if(!s)return t();(function(r,n,o){var a=r.config.segment;if(!a)return n();var l=h=>{var c=()=>h.anonymousId()||He();r.config.get_device_id=c,o&&h.id()&&(r.register({distinct_id:h.id(),$device_id:c()}),r.persistence.set_property(Ee,li)),n(o?void 0:h.anonymousId()||void 0)},u=a.user();"then"in u&&ke(u.then)?u.then(l):l(u)})(e,r=>{s.register(((n,o)=>{typeof Promise<"u"&&Promise.resolve||Ii.warn("This browser does not have Promise support, and can not use the segment integration");var a=(l,u)=>{if(!u)return l;var h=!!o&&l.event.anonymousId===o&&!l.event.userId;h||l.event.userId||l.event.anonymousId===n.get_distinct_id()||(Ii.info("No userId set, resetting PostHog"),n.reset()),h||(o=void 0),l.event.userId&&l.event.userId!==n.get_distinct_id()&&(Ii.info("UserId set, identifying with PostHog"),n.identify(l.event.userId));var c=n.calculateEventProperties(u,l.event.properties);return l.event.properties=Object.assign({},c,l.event.properties),l};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(l){return a(l,l.event.event)},page(l){return a(l,Gr)},identify(l){return a(l,xr)},screen(l){return a(l,"$screen")}}})(e,r)).then(()=>{t()},n=>{Ii.error("Failed to register the Segment integration",n),t()})},i)}var Ya="posthog-js";function Ka(e,t){var i=t===void 0?{}:t,s=i.organization,r=i.projectId,n=i.prefix,o=i.severityAllowList,a=o===void 0?["error"]:o,l=i.sendExceptionsToPostHog,u=l===void 0||l;return h=>{var c,d,v,p,g,_;if(a!=="*"&&!a.includes(h.level)||!e.__loaded)return h;h.tags||(h.tags={});var m=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());h.tags["PostHog Person URL"]=m,e.sessionRecordingStarted()&&(h.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var y=((c=h.exception)==null?void 0:c.values)||[],k=y.map(P=>w({},P,{stacktrace:P.stacktrace?w({},P.stacktrace,{type:"raw",frames:(P.stacktrace.frames||[]).map($=>w({},$,{platform:"web:javascript"}))}):void 0})),x={$exception_message:((d=y[0])==null?void 0:d.value)||h.message,$exception_type:(v=y[0])==null?void 0:v.type,$exception_level:h.level,$exception_list:k,$sentry_event_id:h.event_id,$sentry_exception:h.exception,$sentry_exception_message:((p=y[0])==null?void 0:p.value)||h.message,$sentry_exception_type:(g=y[0])==null?void 0:g.type,$sentry_tags:h.tags};return s&&r&&(x.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+h.event_id),u&&((_=e.exceptions)==null||_.sendExceptionEvent(x)),h}}var ph=class{constructor(e,t,i,s,r,n){this.name=Ya,this.setupOnce=function(o){o(Ka(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},Yn=class{constructor(e){this.wo=(t,i,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength||s.crossTabAdoption)&&(S.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:s}),this.ko=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.So()}So(){var e;this.xo=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.wo)}destroy(){var e;(e=this.xo)==null||e.call(this),this.xo=void 0}doPageView(e,t){var i,s=this.Co(e,t);return this.ko={pathname:(i=f?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.Co(e,(t=this.ko)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.ko)==null?void 0:e.pageViewId}}Co(e,t){var i=this.ko;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,u=r.lastContentY,h=r.maxContentY;if(!(b(n)||b(o)||b(a)||b(l)||b(u)||b(h))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),h=Math.ceil(h);var c=n>1?Je(o/n,0,1,S):1,d=n>1?Je(a/n,0,1,S):1,v=l>1?Je(u/l,0,1,S):1,p=l>1?Je(h/l,0,1,S):1;s=K(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:c,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},ti=["flags","surveys"],fh={[$u]:{exposure:"hidden"},[rs]:{exposure:"hidden"},[Tu]:{exposure:"hidden"},[hr]:{exposure:"hidden"},[Ue]:{exposure:"hidden"},[cr]:{exposure:"event"},[dr]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[vr]:{exposure:"event"},[xa]:{exposure:"hidden"},[pr]:{exposure:"event"},[fr]:{exposure:"event"},[Hr]:{exposure:"event"},[zr]:{exposure:"hidden"},[ka]:{exposure:"event"},[Dt]:{exposure:"hidden"},[Fu]:{exposure:"hidden"},[Ct]:{exposure:"hidden"},[Vr]:{exposure:"event"},[Sa]:{exposure:"event",shouldSkipFromEventProperties:e=>oe(e)},[Iu]:{exposure:"event"},[Ou]:{exposure:"event"},[Cu]:{exposure:"event"},[Au]:{exposure:"event"},[Mu]:{exposure:"hidden"},[Ne]:{exposure:"hidden",storageGroup:"flags"},[Ge]:{exposure:"hidden",storageGroup:"flags"},[_r]:{exposure:"hidden"},[wt]:{exposure:"hidden",storageGroup:"flags"},[at]:{exposure:"hidden",storageGroup:"flags"},[Et]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ci]:{exposure:"hidden",storageGroup:"flags"},[Ve]:{exposure:"hidden"},[yt]:{exposure:"hidden"},[et]:{exposure:"hidden"},[lt]:{exposure:"hidden"},[mr]:{exposure:"hidden",storageGroup:"surveys"},[ns]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[yr]:{exposure:"event"},[Ui]:{exposure:"hidden"},[Hi]:{exposure:"hidden"},[zi]:{exposure:"hidden"},[Lu]:{exposure:"hidden"},[Du]:{exposure:"hidden"},[Nu]:{exposure:"event"},[ju]:{exposure:"event"},[qu]:{exposure:"event"},[Bu]:{exposure:"event"},[ut]:{exposure:"hidden"},[ai]:{exposure:"hidden"},[Fa]:{exposure:"event"},[yi]:{exposure:"hidden"},[ht]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Ee]:{exposure:"hidden"},[br]:{exposure:"hidden"},[Ia]:{exposure:"hidden"},[Oa]:{exposure:"hidden"},[Ca]:{exposure:"hidden"},[At]:{exposure:"hidden"},[Wr]:{exposure:"hidden"},[Pa]:{exposure:"event"},[Ra]:{exposure:"event"},[$a]:{exposure:"event"},[Ta]:{exposure:"event"},[Ma]:{exposure:"event"},[La]:{exposure:"event"},[wr]:{exposure:"event"},[Uu]:{exposure:"event"},[Hu]:{exposure:"event"},[zu]:{exposure:"event"},[Vu]:{exposure:"event"},[Wu]:{exposure:"event"},[Gu]:{exposure:"event"},[Ju]:{exposure:"event"},[Yu]:{exposure:"event"}},gh=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],be=e=>{var t=fh[e];if(t)return t;for(var i of gh){var s=i[1];if(e.indexOf(i[0])===0)return s}},Mt=(e,t)=>{try{var i;return JSON.stringify(e,(s,r)=>ki(r)?(i!=null||(i=new WeakMap),i.has(r)||i.set(r,Na(r)),i.get(r)):typeof r=="bigint"?r.toString():r,t)}catch{return Ao(e)}},Ut=e=>{var t=E?.createElement("a");return b(t)?null:(t.href=e,t)},Ht=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch{S.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ei=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],h=0;l.length>h;h++){var c=l[h].split("=");C(c)&&(t.includes(c[0])?u.push(c[0]+"="+i):u.push(l[h]))}var d=a;return o!=null&&(d+="?"+u.join("&")),r!=null&&(d+="#"+r),d},ls=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Xa=(e,t)=>e>=t&&Co(),Za=(e,t,i,s)=>{if(e===0){if(Co()){var r=t+1;return r===i&&s(),r}return t}return 0},zt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],_h=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...zt],xi="<masked>",mh=["li_fat_id"];function Qa(e,t,i){if(!E)return{};var s,r=t?[...zt,...i||[]]:[],n=el(Ei(E.URL,r,xi),e);return K((s={},U(mh,function(o){var a=Sr(o);s[o]=a||null}),s),n)}function el(e,t){var i=_h.concat(t||[]),s={};return U(i,function(r){var n=Ht(e,r);s[r]=n||null}),s}function tl(e){var t=(function(n){return n?n.search("https?://(.*)google.([^/?]*)")===0?"google":n.search("https?://(.*)bing.com")===0?"bing":n.search("https?://(.*)yahoo.com")===0?"yahoo":n.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(e),i=t!="yahoo"?"q":"p",s={};if(!oe(t)){s.$search_engine=t;var r=E?Ht(E.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function Kn(){return navigator.language||navigator.userLanguage}var us="$direct";function il(){return E?.referrer||us}function sl(e,t,i){var s;i===void 0&&(i=!1);var r=e?[...zt,...t||[]]:[],n=(s=i?ct(ne?.href):ne?.href)==null?void 0:s.substring(0,1e3);return{r:il().substring(0,1e3),u:n?Ei(n,r,xi):void 0}}function rl(e,t){var i;t===void 0&&(t=!1);var s=e.r,r=e.u,n=t?ct(r):r,o={$referrer:s,$referring_domain:s==null?void 0:s==us?us:(i=Ut(s))==null?void 0:i.host};if(n){o.$current_url=n;var a=Ut(n);o.$host=a?.host,o.$pathname=a?.pathname,K(o,el(n))}return s&&K(o,tl(s)),o}function nl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function yh(){try{return new Date().getTimezoneOffset()}catch{return}}var bh={flags:ht,surveys:ns},wh=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Oi=e=>e+"_cookie_identity_change_pending",Ci=e=>{var t="",i=0;for(var s of e){var r=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+r>1e3)break;t+=s,i+=r}return t},ve="main",Qe=[Ne,Ge,wt,at,Et,ht,ci,et],Ns=e=>Qe.indexOf(e)!==-1,st=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},Tt=e=>{if(!e)return{};var t=JSON.parse(e);return j(t)?t:{}},Xn=(e,t)=>{U(e,(i,s)=>{var r=be(s);r&&r.exposure!=="event"||{}.hasOwnProperty.call(t,s)||delete e[s]})},js=class{constructor(e,t,i){if(i===void 0&&(i=!0),this.To={},this.Mo=!1,this.Io=!1,this.Eo=!1,this.Ro=!1,this.Ao=!1,this.Po=new Map,this.Fo=!1,this.Oo=!1,this.$o=!1,this.Do=!1,this.Lo=new Set,this.Rn=e,this.No=i,this.props={},this.qo=void 0,this.jo=(r=>{var n="";return r.token&&(n=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+n+"_posthog"})(e),this.fo=this.Bo(e),this.Eo=this.Ho(e),this.load(),this.zo(),e.debug&&S.info("Persistence loaded",e.persistence,w({},this.props)),this.update_config(e,e,t),this.save(),f){var s=()=>this.flush();z(f,"beforeunload",s,{capture:!1}),z(f,"pagehide",s,{capture:!1}),this.Uo=r=>{if(this.Mo&&(!r.storageArea||r.storageArea===f?.localStorage)&&r.key)if(r.key!==this.jo){if(this.Eo){var n=ti.find(o=>r.key===this.Wo(o));n&&this.Vo(r.key,n)}}else this.Vo(r.key,ve)},z(f,"storage",this.Uo)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(t=>{var i=t[0],s=t[1],r=this.Po.get(i);if(Ns(i)&&r!==!0)if(s!==!0){var n=new Set(r||[]);s.forEach(o=>n.add(o)),n.size&&this.Go(i,n)}else this.Go(i,!0)})}onCrossTabFeatureFlagChange(e){return this.Lo.add(e),()=>this.Lo.delete(e)}destroy(){this.Uo&&f&&(f.removeEventListener("storage",this.Uo),this.Uo=void 0),this.Lo.clear()}Vo(e,t,i){if(i===void 0&&(i=!0),this.gi)return!1;var s,r;try{if(r=B.Lt(e),oe(r)){var n=this.Zo(t);return n.storageValue=null,t!==ve&&(n.persisted=!1),!1}s=Tt(r)}catch{return!1}var o=t===ve?s:B.Nt(this.jo);if(o&&this.Jo(o))return!1;var a=this.Qo(s,t,i);return t===ve&&this.Eo&&!st(this.Ko().main,s)||this.Xo(s,t,!0,r),a}Jo(e){var t=this.props[Be],i=e[Be];return!b(t)&&!b(i)&&t!==i}Xo(e,t,i,s){var r=this.Zo(t);r.storageValue=s,t!==ve&&(r.persisted=i);try{r.fingerprint=this.Yo(e,t)}catch{r.fingerprint=void 0}}Qo(e,t,i){var s=!1;return Qe.forEach(r=>{var n,o=(n=be(r))==null?void 0:n.storageGroup;if(!(t===ve&&this.Eo&&o||t!==ve&&o!==t)){var a=r in e,l=this.ta(r,a?e[r]:void 0),u=this.Po.has(r)?r in this.props:a;u===r in this.props&&st(l,this.props[r])||(u?this.ea(r,l,!1):this.ia(r,!1),s=!0)}}),s&&i&&this.Lo.forEach(r=>r()),s}ra(){if(!this.Mo)return!1;try{this.$o=!1;var e,t=B.Lt(this.jo),i=this.Zo(ve),s=!1,r=!1;if(t!==i.storageValue)if(oe(t))i.storageValue=null;else{if(e=Tt(t),this.$o=!this.Oo&&this.Jo(e),this.$o)return!1;r=this.Qo(e,ve,!1),!this.Eo||st(this.Ko().main,e)?this.Xo(e,ve,!0,t):i.storageValue=t,s=!0}return this.Eo&&ti.forEach(n=>{var o=B.Lt(this.Wo(n)),a=this.Zo(n),l=e||{},u=s&&Qe.some(c=>{var d;return((d=be(c))==null?void 0:d.storageGroup)===n&&c in l});if(o!==a.storageValue||u){if(oe(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this.Qo(l,n,!1)||r));var h=Tt(o);r=this.Qo(h,n,!1)||r,this.Xo(h,n,!0,o)}}),r}catch{return!1}}Go(e,t){this.Po.set(e,t);var i=be(e);i!=null&&i.volatile||(this.Zo((this.Eo?i?.storageGroup:void 0)||ve).fingerprint=void 0,this.na(e))}sa(){Qe.forEach(e=>this.Po.set(e,!0))}zo(){if(this.Mo)try{var e=B.Lt(this.jo),t=Tt(e);this.Zo(ve).storageValue=e,Qe.forEach(i=>{var s,r=this.Eo?(s=be(i))==null?void 0:s.storageGroup:void 0,n=r?B.Lt(this.Wo(r)):null;if(r){var o=this.Zo(r);o.storageValue=n,o.persisted=!oe(n)}var a=r&&!oe(n)?Tt(n):t;i in this.props?this.oa(i,a[i],this.props[i]):i in a&&this.Go(i,!0)})}catch{}}ta(e,t){var i=this.Po.get(e);if(!i)return t;if(i===!0)return this.props[e];if(e==="$active_feature_flags"){var s=new Set(C(t)?t:[]),r=new Set(C(this.props[e])?this.props[e]:[]);return i.forEach(a=>r.has(a)?s.add(a):s.delete(a)),Array.from(s)}var n=j(t)?w({},t):{},o=j(this.props[e])?this.props[e]:{};return i.forEach(a=>{a in o?n[a]=o[a]:delete n[a]}),n}oa(e,t,i){if(Ns(e)){var s=this.Po.get(e);if(s!==!0){var r=t;if(this.Mo)try{var n,o=this.Eo?(n=be(e))==null?void 0:n.storageGroup:void 0,a=o?this.Wo(o):this.jo;r=Tt(B.Lt(a))[e]}catch{}var l=new Set(s||[]);if(e==="$active_feature_flags"){if(!b(t)&&!C(t)||!b(r)&&!C(r)||!C(i))return void this.Go(e,!0);var u=new Set(t||[]),h=new Set(r||[]),c=new Set(i);new Set([...u,...c]).forEach(p=>{u.has(p)!==c.has(p)&&l.add(p)}),l.forEach(p=>{h.has(p)===c.has(p)&&l.delete(p)})}else{if(!j(i))return void(st(r,i)?this.Po.delete(e):this.Go(e,!0));if(!b(t)&&!j(t)||b(t)&&Oe(i)&&b(r))return void this.Go(e,!0);var d=j(t)?t:{},v=j(r)?r:{};new Set([...Object.keys(d),...Object.keys(i)]).forEach(p=>{p in d==p in i&&st(d[p],i[p])||l.add(p)}),l.forEach(p=>{p in v==p in i&&st(v[p],i[p])&&l.delete(p)})}l.size?this.Go(e,l):this.Po.delete(e)}}}aa(){var e,t=(e=this.Rn)==null?void 0:e.persistence_save_debounce_ms;return ae(t)&&t>0?t:0}la(e){if(this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie")if(e)try{var t=Ms(e,this.Rn.cookie_persisted_properties||[]),i=Mn(t,this.Rn.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),r=re.Lt(this.jo)||void 0;r&&Ls(this.jo,r)===s&&(this.ua=s,this.ha=r)}catch{}else try{var n=re.Lt(this.jo)||void 0;this.ua=n?Ls(this.jo,n):void 0,this.ha=n}catch{}}syncCookieProperties(){return this.da(this.Rn)}da(e,t){if(t===void 0&&(t=!1),this.gi&&!t||this.Ao||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;var i;try{i=re.Lt(this.jo)||void 0}catch{}if(!i||i===this.ha)return!1;var s,r=Ls(this.jo,i);try{s=As(JSON.parse(i))}catch{return!1}if((re.Lt(this.jo)||void 0)!==i)return!1;this.ua=r,this.ha=i;var n=Ln(this.jo,i),o=[...bt,...n.properties],a={};if(Object.keys(s).forEach(g=>{var _=s[g];(b(_)||oe(_)||_===""||g==="$user_state"&&_!=="anonymous"&&_!=="identified")&&(a[g]=!0,delete s[g])}),Oe(s))return!1;var l="distinct_id"in s||s.$user_state==="anonymous"||s.$user_state==="identified",u=this.props,h=u[Be],c=u[Ee],d=K({},u);[...bt,...e.cookie_persisted_properties||[]].forEach(g=>{if(o.indexOf(g)!==-1&&!(g in s)&&!a[g]&&(l||g!=="distinct_id"&&g!=="$user_state")){var _=d[g];(n.isValid||bt.indexOf(g)===-1||_!==!1&&_!==0)&&delete d[g]}}),this.props=K(d,s),Qe.forEach(g=>{var _=g in this.props;g in u===_&&st(u[g],this.props[g])||(_?this.oa(g,u[g],this.props[g]):this.Go(g,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this.ea(Ee,ot);var v=this.props[Be],p=this.props[Ee];return!l||v===h&&p===c||(this.Oo=!0,this.Ro=!0,G.Ot(Oi(this.jo),!0),this.ia(et),this.ia(Ge),this.ia(Ne),this.ia(wt),this.ia(at),this.ia(Et),this.ia(ht),this.ia(yi),this.ia(ut),p!=="anonymous"||c!=="identified"&&s.$user_state!=="anonymous"&&(b(h)||v===h)||(Xn(this.props,s),this.ia(lt)),p==="identified"?this.props.$user_id=v:delete this.props.$user_id,this.ia(rs)),!0}consumeCookieIdentityChange(){var e=Oi(this.jo),t=this.Ro||!!G.Lt(e);return this.Ro=!1,t&&G.Dt(e),t}va(e){return e===void 0&&(e=!1),!(this.Ao||this.gi&&!e||!this.Rn.cookieWinsOnConflict||this.Rn.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ao=!0,0))}ca(){this.Ao&&(b(this.fa)||(clearTimeout(this.fa),this.fa=void 0),delete this.To[ve],this.pa(!0))}ga(e){if(e===void 0&&(e=!0),this.Ao)try{e?this.ca():b(this.fa)||(clearTimeout(this.fa),this.fa=void 0)}finally{this.Ao=!1}}isDisabled(){return!!this.gi}Bo(e){wh.indexOf(e.persistence.toLowerCase())===-1&&(S.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,i=(function(o,a){o===void 0&&(o=[]),a===void 0&&(a=!1);var l=[...bt,...o];return w({},B,{Nt(u){try{var h,c={};try{h=re.Lt(u)||void 0,c=h?As(JSON.parse(h)):{}}catch{}var d,v=JSON.parse(B.Lt(u)||"{}");if(a){var p=Ln(u,h),g=[...bt,...p.properties],_={};Object.keys(c).forEach(P=>{var $=c[P];oe($)||$===""||P==="$user_state"&&$!=="anonymous"&&$!=="identified"||(_[P]=$)});var m="distinct_id"in _||_.$user_state==="anonymous"||_.$user_state==="identified";if(Object.keys(_).length>0){var y,k=v[Be],x=(y=v.$user_state)!==null&&y!==void 0?y:"anonymous";l.forEach(P=>{if(g.indexOf(P)!==-1&&!(P in c)&&(m||P!=="distinct_id"&&P!=="$user_state")){var $=v[P];(p.isValid||bt.indexOf(P)===-1||$!==!1&&$!==0)&&delete v[P]}}),!m||"$user_state"in c||"$user_state"in v||(v[Ee]=ot),!m||("distinct_id"in _?_[Be]:v[Be])===k&&("$user_state"in _?_[Ee]:v[Ee])===x||(Cs.forEach(P=>delete v[P]),_.$user_state==="identified"&&"distinct_id"in _?v.$user_id=_[Be]:delete v.$user_id,_.$user_state!=="identified"&&(delete v[Fa],delete v[lt]),delete v.__alias)}d=K(v,_)}else d=K(c,v);return B.Ot(u,d),d}catch{}return null},Ot(u,h,c,d,v,p){var g=B.Ot(u,h,void 0,void 0,p);try{var _=Ms(h,o);if(Object.keys(_).length){if(a){var m=as(u),y=Mn(_,o);if(re.Ot(m,y,c,d,v,p),re.Lt(m)!==JSON.stringify(y)){re.Dt(m,d);var k=Ms(h);return re.Ot(u,k,c,d,v,p),g}}re.Ot(u,_,c,d,v,p)}}catch(x){B.Pt(x)}return g},Dt(u,h){try{f?.localStorage.removeItem(u),re.Dt(u,h),re.Dt(as(u),h)}catch(c){B.Pt(c)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),s=!1,r=!1,n=e.persistence.toLowerCase();return n==="localstorage"&&B.Et()?(t=B,r=!0):n==="localstorage+cookie"&&i.Et()?(t=i,r=!0,s=!0):n==="sessionstorage"&&G.Et()?t=G:n==="memory"?t=Rr:n==="cookie"&&re.Et()?(t=re,s=!0):i.Et()?(t=i,r=!0,s=!0):re.Et()?(t=re,s=!0):t=Rr,this.Mo=r,this.Io=s,t}Wo(e){return this.jo+"__"+e}Ho(e){return this.Mo&&!!e.split_storage}properties(){var e={};return U(this.props,(t,i)=>{var s=be(i);if(!s||s.exposure==="event"){if(s!=null&&s.shouldSkipFromEventProperties!=null&&s.shouldSkipFromEventProperties(t))return;e[i]=t}}),e}load(e){if(e===void 0&&(e=!1),!this.gi||e){var t=this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie",i=t?B.Nt(this.jo):null,s={};if(t)try{U(s=As(re.Nt(this.jo)),(v,p)=>{(b(v)||oe(v)||v==="")&&delete s[p]})}catch{}var r=this.fo.Nt(this.jo);if(r&&(this.props=K({},r)),this.Eo&&this.ma(),t&&r){var n,o,a=i?.[Be],l=(n=i?.$user_state)!==null&&n!==void 0?n:"anonymous",u=r[Be],h=(o=r.$user_state)!==null&&o!==void 0?o:"anonymous";if(u!==a||h!==l){this.Ro=!0,G.Ot(Oi(this.jo),!0);var c=K({},this.props);Cs.forEach(v=>delete c[v]),h!=="anonymous"||l!=="identified"&&s.$user_state!=="anonymous"&&(b(a)||u===a)||(Xn(c,s),delete c[lt]),this.props=c;var d=new Set;Cs.forEach(v=>{var p,g=(p=be(v))==null?void 0:p.storageGroup;g&&d.add(g)}),d.forEach(v=>{var p={};U(this.props,(g,_)=>{var m;((m=be(_))==null?void 0:m.storageGroup)===v&&(p[_]=g)}),Oe(p)?(B.Dt(this.Wo(v)),this.To[v]={}):B.Ot(this.Wo(v),p)&&(this.To[v]={persisted:!0,fingerprint:this.Yo(p,v)})})}}G.Lt(Oi(this.jo))&&(this.Ro=!0)}}ma(){for(var e of ti){var t=B.Nt(this.Wo(e));if(t&&!Oe(t)){var i=this.Zo(e);i.persisted=!0,this.ya(e)||(i.fingerprint=this.Yo(t,e)),this.ba(e,t)||K(this.props,t)}}}ya(e){return Object.keys(this.props).some(t=>{var i;return((i=be(t))==null?void 0:i.storageGroup)===e})}ba(e,t){var i=bh[e];if(!i)return!1;var s=t[i],r=this.props[i];return ae(s)&&ae(r)&&r>s}refreshKey(e){var t;if(!(this.gi||e==="$fbc_persistence"&&this.Do)){var i=this.Eo?(t=be(e))==null?void 0:t.storageGroup:void 0,s=i?B.Nt(this.Wo(i)):this.fo.Nt(this.jo);if(s&&e in s)this.ea(e,s[e],!1);else{if(i){var r=this.fo.Nt(this.jo);if(r&&e in r)return void this.ea(e,r[e],!1)}this.ia(e,!1)}}}save(){if(!this.gi){var e=this.aa();e>0?b(this.fa)&&(this.fa=setTimeout(()=>{this.fa=void 0,this.pa()},e)):this.pa()}}flush(){b(this.fa)||(clearTimeout(this.fa),this.fa=void 0,this.pa())}pa(e){if(e===void 0&&(e=!1),!(this.gi||this.Ao&&!e)){e||(this.syncCookieProperties(),this.Do||this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie"||this.refreshKey(Ue));var t=!e&&!this.Fo;t||(this.$o=!1);var i=!!t&&this.ra();if(this.$o)this.Rn.debug&&S.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this.Eo)return this._a(),void(i&&this.Lo.forEach(r=>r()));var s=this.wa(this.fo,this.jo,this.props,ve);s==="written"&&this.la(this.props),s!=="failed"&&(this.Po.clear(),this.Oo=!1,this.Do=!1),i&&this.Lo.forEach(r=>r())}}}_a(){var e=this,t=this.Ko(),i=t.main,s=t.groups,r=this.wa(this.fo,this.jo,i,ve);r==="written"&&this.la(i),r!=="failed"&&(this.Oo=!1,this.Do=!1,Qe.forEach(a=>{var l;(l=be(a))!=null&&l.storageGroup||this.Po.delete(a)}));var n=function(a){var l,u=s[a];if(Oe(u)&&((l=e.To[a])==null||!l.persisted))return Qe.forEach(c=>{var d;((d=be(c))==null?void 0:d.storageGroup)===a&&e.Po.delete(c)}),1;var h=e.wa(B,e.Wo(a),u,a);h!=="failed"&&Qe.forEach(c=>{var d=be(c);d?.storageGroup!==a||h!=="written"&&d.volatile||e.Po.delete(c)})};for(var o of ti)n(o)}Ko(){var e={},t={flags:{},surveys:{}};return U(this.props,(i,s)=>{var r,n=(r=be(s))==null?void 0:r.storageGroup;n?t[n][s]=i:e[s]=i}),{main:e,groups:t}}Yo(e,t){if(t===ve)return JSON.stringify(e)+"|"+this.ka+"|"+this.Sa+"|"+this.xa;var i={};return U(e,(s,r)=>{var n;i[r]=(n=be(r))!=null&&n.volatile?"__volatile__":s}),JSON.stringify(i)}wa(e,t,i,s){var r,n=this.Zo(s);if(s!==ve&&!n.dirty&&!b(n.fingerprint))return"skipped";try{if((r=this.Yo(i,s))===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return e.Ot(t,i,this.ka,this.Sa,this.xa,this.Rn.debug)?(n.dirty=!1,s!==ve&&(n.persisted=!0),b(r)||(n.fingerprint=r),this.Mo&&(n.storageValue=B.Lt(t)),"written"):(this.Rn.debug&&S.warn('failed to persist storage entry "'+t+'"; will retry on next save'),"failed")}remove(e){var t=(e===void 0?{}:e).keepGroupEntries,i=t!==void 0&&t;if(this.sa(),b(this.fa)||(clearTimeout(this.fa),this.fa=void 0),this.fo.Dt(this.jo,!1),this.fo.Dt(this.jo,!0),!i&&this.No)for(var s of ti)B.Dt(this.Wo(s));i?delete this.To[ve]:this.To={},this.ua=void 0,this.ha=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(j(e)){this.syncCookieProperties(),b(t)&&(t="None"),this.ka=b(i)?this.Ca:i;var s=!1;if(U(e,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.ea(n,r),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(j(e)){this.syncCookieProperties(),this.ka=b(t)?this.Ca:t;var i=!1;if(U(e,(s,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==s||j(s)||C(s))&&(this.ea(r,s),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t=typeof e=="string"?[e]:e,i=!1;for(var s of t)s in this.props&&(this.ia(s),i=!0);i&&this.save()}update_campaign_params(){var e=E?.URL;if(e!==this.qo){var t=Qa(this.Rn.custom_campaign_params,this.Rn.mask_personal_data_properties,this.Rn.custom_personal_data_properties),i=!Oe(Jr(t));return i&&this.register(t),this.qo=e,i?t:void 0}}update_search_keyword(){var e;this.register((e=E?.referrer)?tl(e):{})}update_referrer_info(){var e;this.register_once({$referrer:il(),$referring_domain:E!=null&&E.referrer&&((e=Ut(E.referrer))==null?void 0:e.host)||us},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var e=sl(this.Rn.mask_personal_data_properties,this.Rn.custom_personal_data_properties,this.Rn.disable_capture_url_hashes);this.register_once({[At]:this.Io?{r:Ci(e.r),u:e.u?Ci(e.u):void 0}:e},void 0)}}get_initial_props(){var e={};U([Ca,Oa],i=>{var s=this.props[i];s&&U(s,function(r,n){e["$initial_"+tr(n)]=r})});var t=this.props[At];return t&&K(e,(function(i,s){s===void 0&&(s=!1);var r=rl(i,s),n={};return U(r,function(o,a){n["$initial_"+tr(a)]=o}),n})(t,this.Rn.disable_capture_url_hashes)),e}safe_merge(e){return U(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){var s=e.persistence!==t.persistence,r=!((p,g)=>{if(p.length!==g.length)return!1;var _=[...p].sort(),m=[...g].sort();return _.every((y,k)=>y===m[k])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),n=s||r,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this.gi&&!a;a||this.da(t,l),this.Rn=e,!a&&(s||r||o)&&(this.ua=void 0,this.ha=void 0,this.da(w({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),l));var u=n||o?this.Bo(e):this.fo;this.Ta();var h=this.Ho(e),c=n||h!==this.Eo,d=!a&&(c||e.cross_subdomain_cookie!==this.Sa||e.secure_cookie!==this.xa)&&this.va(l);this.Fo=c;try{if(this.Ca=this.ka=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),c){var v=this.props;this.clear(),this.fo=u,this.Eo=h,this.props=v,this.save()}else o&&(this.fo=u,a||(delete this.To[ve],this.pa()))}finally{this.Fo=!1,d&&this.ga()}}Ta(){var e=this.props[At];if(this.Io&&j(e)&&typeof e.r=="string"){var t=Ci(e.r),i=typeof e.u=="string"?Ci(e.u):e.u;t===e.r&&i===e.u||this.ea(At,w({},e,{r:t,u:i}))}}set_disabled(e){this.gi=e,this.gi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Sa&&(this.Sa=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.xa&&(this.xa=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props.__timers||{};i[e]=t,this.ea(hr,i),this.save()}remove_event_timer(e){var t=this.props.__timers||{},i=t[e];return b(i)||(delete t[e],this.ea(hr,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this.ea(e,t),this.save()}ea(e,t,i){var s;i===void 0&&(i=!0);var r=this.props[e];this.props[e]=t,i&&(e!=="distinct_id"&&e!=="$user_state"||r===t||(this.Oo=!0),e!=="$fbc_persistence"||st(r,t)||(this.Do=!0),this.oa(e,r,t),(s=be(e))!=null&&s.volatile||this.na(e))}ia(e,t){t===void 0&&(t=!0),delete this.props[e],t&&(Ns(e)&&this.Go(e,!0),e==="$fbc_persistence"&&(this.Do=!0),this.na(e))}na(e){var t,i=(t=be(e))==null?void 0:t.storageGroup;i&&(this.Zo(i).dirty=!0)}Zo(e){return this.To[e]||(this.To[e]={})}},Ae={GZipJS:"gzip-js",Base64:"base64"},ii={Activation:"events",Cancellation:"cancelEvents"};var qs={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"};var tt={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Bs={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Fr={Popover:"popover",Inline:"inline"};function Ai(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&ke(i.then)&&i.then(void 0,()=>{})}}}}var Eh={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"},Zn={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"},Qn=le("[RateLimiter]"),xh=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(s=>{Qn.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4})}catch(s){return void Qn.warn('could not rate limit - continuing. Error: "'+s?.message+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;e===void 0&&(e=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=new Date().getTime(),a=(t=(i=this.instance.persistence)==null?void 0:i.get_property("$capture_rate_limit"))!==null&&t!==void 0?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var u=(ae(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Ma(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,(s=this.instance.persistence)==null||s.set_property(Ia,a),{isRateLimited:l,remainingTokens:a.tokens}}Ia(e){var t=this.instance.config.property_denylist;return!C(t)||!t.includes(e)}Ea(){var e;if(this.Ia("$current_url")&&this.Ia("$pathname")&&ne!=null&&ne.pathname)return""+((e=ne.origin)!==null&&e!==void 0?e:"")+ne.pathname}Ma(e){var t,i,s=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this.Ea(),o=this.Ia("$session_id")?(t=(i=this.instance).get_session_id)==null?void 0:t.call(i):void 0,a=[e+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+r+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},rt=le("[RemoteConfig]"),ol=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ra(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}Aa(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 rt.info("Using preloaded remote config",this.remoteConfig),void this.Pa(this.remoteConfig);if(this._instance.Fa())return void rt.warn("Remote config is disabled. Falling back to local config.");this.Ra(e=>{if(!e)return rt.info("No config found after loading remote JS config. Falling back to JSON."),void this.Aa(t=>{this.Pa(t.json,t)});this.Pa(e)})}catch(e){rt.error("Error loading remote config",e),this.Pa()}}Pa(e,t){!e&&t&&(t.statusCode===0?t.error||rt.warn("Failed to fetch remote config from PostHog."):rt.error("Failed to fetch remote config from PostHog."));try{this._instance.Pa(e?{ok:!0,config:e}:{ok:!1})}catch(s){rt.error("Error applying remote config",s)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded()}catch(s){rt.error("Error loading feature flags",s)}}};var Me=Uint8Array,Fe=Uint16Array,Vt=Uint32Array,Qr=new Me([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]),en=new Me([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]),eo=new Me([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),al=function(e,t){for(var i=new Fe(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new Vt(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},ll=al(Qr,2),Ir=ll[1];ll[0][28]=258,Ir[258]=28;for(Or=al(en,0)[1],hs=new Fe(32768),te=0;32768>te;++te)pt=(43690&te)>>>1|(21845&te)<<1,hs[te]=((65280&(pt=(61680&(pt=(52428&pt)>>>2|(13107&pt)<<2))>>>4|(3855&pt)<<4))>>>8|(255&pt)<<8)>>>1;var pt,Or,hs,te,pi=function(e,t,i){for(var s=e.length,r=0,n=new Fe(t);s>r;++r)++n[e[r]-1];var o,a=new Fe(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Fe(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var u=r<<4|e[r],h=t-e[r],c=a[e[r]-1]++<<h,d=c|(1<<h)-1;d>=c;++c)o[hs[c]>>>l]=u}else for(o=new Fe(s),r=0;s>r;++r)o[r]=hs[a[e[r]-1]++]>>>15-e[r];return o},xt=new Me(288);for(te=0;144>te;++te)xt[te]=8;for(te=144;256>te;++te)xt[te]=9;for(te=256;280>te;++te)xt[te]=7;for(te=280;288>te;++te)xt[te]=8;var cs=new Me(32);for(te=0;32>te;++te)cs[te]=5;var kh=pi(xt,9,0),Sh=pi(cs,5,0),ul=function(e){return(e/8|0)+(7&e&&1)},hl=function(e,t,i){(t==null||0>t)&&(t=0),(i==null||i>e.length)&&(i=e.length);var s=new(e instanceof Fe?Fe:e instanceof Vt?Vt:Me)(i-t);return s.set(e.subarray(t,i)),s},Ke=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},si=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Us=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Me(0),0];if(r==1){var o=new Me(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(P,$){return P.f-$.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,h=1,c=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=r-1;)a=i[i[c].f>i[u].f?u++:c++],l=i[u!=h&&i[c].f>i[u].f?u++:c++],i[h++]={s:-1,f:a.f+l.f,l:a,r:l};var d=n[0].s;for(s=1;r>s;++s)n[s].s>d&&(d=n[s].s);var v=new Fe(d+1),p=Cr(i[h-1],v,0);if(p>t){s=0;var g=0,_=p-t,m=1<<_;for(n.sort(function(P,$){return v[$.s]-v[P.s]||P.f-$.f});r>s;++s){var y=n[s].s;if(t>=v[y])break;g+=m-(1<<p-v[y]),v[y]=t}for(g>>>=_;g>0;){var k=n[s].s;t>v[k]?g-=1<<t-v[k]++-1:++s}for(;s>=0&&g;--s){var x=n[s].s;v[x]==t&&(--v[x],++g)}p=t}return[new Me(v),p]},Cr=function(e,t,i){return e.s==-1?Math.max(Cr(e.l,t,i+1),Cr(e.r,t,i+1)):t[e.s]=i},to=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Fe(++t),s=0,r=e[0],n=1,o=function(l){i[s++]=l},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},ri=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},Wi=function(e,t,i){var s=i.length,r=ul(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},io=function(e,t,i,s,r,n,o,a,l,u,h){Ke(t,h++,i),++r[256];for(var c=Us(r,15),d=c[0],v=c[1],p=Us(n,15),g=p[0],_=p[1],m=to(d),y=m[0],k=m[1],x=to(g),P=x[0],$=x[1],N=new Fe(19),T=0;y.length>T;++T)N[31&y[T]]++;for(T=0;P.length>T;++T)N[31&P[T]]++;for(var J=Us(N,7),F=J[0],R=J[1],L=19;L>4&&!F[eo[L-1]];--L);var I,M,Y,ue,Z=u+5<<3,W=ri(r,xt)+ri(n,cs)+o,ee=ri(r,d)+ri(n,g)+o+14+3*L+ri(N,F)+(2*N[16]+3*N[17]+7*N[18]);if(W>=Z&&ee>=Z)return Wi(t,h,e.subarray(l,l+u));if(Ke(t,h,1+(W>ee)),h+=2,W>ee){I=pi(d,v,0),M=d,Y=pi(g,_,0),ue=g;var fe=pi(F,R,0);for(Ke(t,h,k-257),Ke(t,h+5,$-1),Ke(t,h+10,L-4),h+=14,T=0;L>T;++T)Ke(t,h+3*T,F[eo[T]]);h+=3*L;for(var me=[y,P],ge=0;2>ge;++ge){var ye=me[ge];for(T=0;ye.length>T;++T)Ke(t,h,fe[V=31&ye[T]]),h+=F[V],V>15&&(Ke(t,h,ye[T]>>>5&127),h+=ye[T]>>>12)}}else I=kh,M=xt,Y=Sh,ue=cs;for(T=0;a>T;++T)if(s[T]>255){var V;si(t,h,I[257+(V=s[T]>>>18&31)]),h+=M[V+257],V>7&&(Ke(t,h,s[T]>>>23&31),h+=Qr[V]);var ie=31&s[T];si(t,h,Y[ie]),h+=ue[ie],ie>3&&(si(t,h,s[T]>>>5&8191),h+=en[ie])}else si(t,h,I[s[T]]),h+=M[s[T]];return si(t,h,I[256]),h+M[256]},Ph=new Vt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Rh=new Me(0),$h=(function(){for(var e=new Vt(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e})(),Hs=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Th(e,t){t===void 0&&(t={});var i=(function(){var d=4294967295;return{p(v){for(var p=d,g=0;v.length>g;++g)p=$h[255&p^v[g]]^p>>>8;d=p},d(){return 4294967295^d}}})(),s=e.length;i.p(e);var r,n,o,a,l,u,h=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,(function(d,v,p,g,_,m){var y=d.length,k=new Me(g+y+5*(1+Math.floor(y/7e3))+_),x=k.subarray(g,k.length-_),P=0;if(!v||8>y)for(var $=0;y>=$;$+=65535){var N=$+65535;y>N?P=Wi(x,P,d.subarray($,N)):(x[$]=m,P=Wi(x,P,d.subarray($,y)))}else{for(var T=Ph[v-1],J=T>>>13,F=8191&T,R=(1<<p)-1,L=new Fe(32768),I=new Fe(R+1),M=Math.ceil(p/3),Y=2*M,ue=function(Xt){return(d[Xt]^d[Xt+1]<<M^d[Xt+2]<<Y)&R},Z=new Vt(25e3),W=new Fe(288),ee=new Fe(32),fe=0,me=0,ge=($=0,0),ye=0,V=0;y>$;++$){var ie=ue($),Q=32767&$,se=I[ie];if(L[Q]=se,I[ie]=Q,$>=ye){var je=y-$;if((fe>7e3||ge>24576)&&je>423){P=io(d,x,0,Z,W,ee,me,ge,V,$-V,P),ge=fe=me=0,V=$;for(var he=0;286>he;++he)W[he]=0;for(he=0;30>he;++he)ee[he]=0}var we=2,Ce=0,dt=F,de=Q-se&32767;if(je>2&&ie==ue($-de))for(var Wt=Math.min(J,je)-1,Gt=Math.min(32767,$),Jt=Math.min(258,je);Gt>=de&&--dt&&Q!=se;){if(d[$+we]==d[$+we-de]){for(var Le=0;Jt>Le&&d[$+Le]==d[$+Le-de];++Le);if(Le>we){if(we=Le,Ce=de,Le>Wt)break;var Ie=Math.min(de,Le-2),Yt=0;for(he=0;Ie>he;++he){var kt=$-de+he+32768&32767,St=kt-L[kt]+32768&32767;St>Yt&&(Yt=St,se=kt)}}}de+=(Q=se)-(se=L[Q])+32768&32767}if(Ce){Z[ge++]=268435456|Ir[we]<<18|Or[Ce];var Kt=31&Ir[we],Pt=31&Or[Ce];me+=Qr[Kt]+en[Pt],++W[257+Kt],++ee[Pt],ye=$+we,++fe}else Z[ge++]=d[$],++W[d[$]]}}P=io(d,x,m,Z,W,ee,me,ge,V,$-V,P),m||(P=Wi(x,P,Rh))}return hl(k,0,g+ul(P)+_)})(n=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!u)),c=h.length;return(function(d,v){var p=v.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>v.level?4:v.level==9?2:0,d[9]=3,v.mtime!=0&&Hs(d,4,Math.floor(new Date(v.mtime||Date.now())/1e3)),p){d[3]=8;for(var g=0;p.length>=g;++g)d[g+10]=p.charCodeAt(g)}})(h,t),Hs(h,c-8,i.d()),Hs(h,c-4,s),h}var Fh=!!Dr||!!_i,cl="text/plain",Gi=!1,dl=(e,t)=>{var i=e.split("#"),s=i[1],r=i[0].split("?"),n=r[0],o=r[1];if(!o)return e;var a=o.split("&").filter(l=>l.split("=")[0]!==t).join("&");return n+(a?"?"+a:"")+(s?"#"+s:"")},Si=function(e,t,i){var s;i===void 0&&(i=!0);var r=e.split("?"),n=r[0],o=r[1],a=w({},t),l=(s=o?.split("&").map(h=>{var c,d=h.split("="),v=d[0],p=i&&(c=a[v])!==null&&c!==void 0?c:d[1];return delete a[v],v+"="+p}))!==null&&s!==void 0?s:[],u=(function(h,c){var d,v;c===void 0&&(c="&");var p=[];return U(h,function(g,_){b(g)||b(_)||_==="undefined"||(d=encodeURIComponent((m=>m instanceof File)(g)?g.name:g.toString()),v=encodeURIComponent(_),p[p.length]=v+"="+d)}),p.join(c)})(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},zs=e=>{if(e.Oa)return e.Oa;var t=e.data,i=e.compression;if(t){if(i===Ae.GZipJS){var s=Th((function(o){var a=o.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(o);for(var l=new Me(o.length+(o.length>>>1)),u=0,h=function(p){l[u++]=p},c=0;a>c;++c){if(u+5>l.length){var d=new Me(u+8+(a-c<<1));d.set(l),l=d}var v=o.charCodeAt(c);128>v?h(v):2048>v?(h(192|v>>>6),h(128|63&v)):v>55295&&57344>v?(h(240|(v=65536+(1047552&v)|1023&o.charCodeAt(++c))>>>18),h(128|v>>>12&63),h(128|v>>>6&63),h(128|63&v)):(h(224|v>>>12),h(128|v>>>6&63),h(128|63&v))}return hl(l,0,u)})(Mt(t)),{mtime:0});return{contentType:cl,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===Ae.Base64){var r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Mt(o)))((function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Mt(t)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=Mt(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},vl=e=>{var t,i,s=()=>e.transport==="sendBeacon"?{url:Si(e.url,{compression:Ae.Base64}),encodedBody:zs(w({},e,{compression:Ae.Base64,Oa:void 0}))}:{url:dl(e.url,"compression"),encodedBody:zs(w({},e,{compression:void 0,Oa:void 0}))};try{t=zs(e)}catch(r){if(Sn(e.compression,Ht(e.url,"compression")))return S.error("Failed to gzip request body, sending uncompressed payload",r),s();throw r}return t&&Sn(e.compression,Ht(e.url,"compression"))&&!((i=t.body)instanceof ArrayBuffer?lr(new Uint8Array(i)):ArrayBuffer.isView(i)&&lr(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Gi=!0,s()):{url:e.url,encodedBody:t}},pl=e=>{try{return vl(e)}catch(t){return S.error(t),void(e.callback==null||e.callback({statusCode:0,error:t}))}},Ih=(function(){var e=X(function*(t){var i=yield(function(r,n,o){return ur.apply(this,arguments)})(Mt(t.data),pe.DEBUG,{rethrow:!0});if(!i)return t;var s=yield i.arrayBuffer();return w({},t,{Oa:{contentType:cl,body:s,estimatedSize:s.byteLength}})});return function(t){return e.apply(this,arguments)}})(),Oh=/Failed to fetch|NetworkError|Load failed/i,fl=e=>e?.name==="TypeError"&&Oh.test(e?.message||""),gl=e=>{var t=pl(e);if(t){var i=new Dr,s=t.encodedBody;i.open(e.method||"GET",t.url,!0);var r=s??{},n=r.contentType,o=r.body;U(e.headers,function(a,l){i.setRequestHeader(l,a)}),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(i.readyState===4){var a={statusCode:i.status,text:i.responseText};if(i.status===200)try{a.json=JSON.parse(i.responseText)}catch{}e.callback==null||e.callback(a)}},i.send(o)}},_l=e=>{var t=pl(e);if(t){var i=t.url,s=t.encodedBody,r=s??{},n=r.contentType,o=r.body,a=r.estimatedSize,l=new Headers;U(e.headers,function(p,g){l.append(g,p)}),n&&l.append("Content-Type",n);var u=null,h=!1;if(cn){var c=new cn;u={signal:c.signal,timeout:setTimeout(()=>{var p;h=!0,c.abort(da("AbortError","PostHog request timed out"+((p=e.timeout)?" after "+p+"ms":"")))},e.timeout)}}var d=p=>{h&&p?.name==="AbortError"||fl(p)?S.warn(p):S.error(p),e.callback==null||e.callback({statusCode:0,error:p})};try{var v;_i(i,w({method:e?.method||"GET",headers:l,keepalive:e.method==="POST"&&!e.$a&&52428.8>(a||0),body:o,signal:(v=u)==null?void 0:v.signal},e.fetchOptions)).then(p=>p.text().then(g=>{var _={statusCode:p.status,text:g};if(p.status===200)try{_.json=JSON.parse(g)}catch(m){S.error(m)}e.callback==null||e.callback(_)})).catch(d).finally(()=>u?clearTimeout(u.timeout):null)}catch(p){u&&clearTimeout(u.timeout),d(p)}}},Ar=e=>{try{var t,i=vl(e),s=i.url,r=i.encodedBody,n=r??{},o=n.body,a=n.estimatedSize;if(!o)return;var l=o instanceof Blob?o:new Blob([o],{type:n.contentType});if(_e.sendBeacon(s,l))return;var u=C(e.data)?e.data:(t=e.data)==null?void 0:t.batch;if(C(u)&&u.length>1&&(a??0)>16384){var h=Math.ceil(u.length/2),c=d=>C(e.data)?d:w({},e.data,{batch:d});return Ar(w({},e,{data:c(u.slice(0,h))})),void Ar(w({},e,{data:c(u.slice(h))}))}S.warn("Beacon of ~"+(a??0)+" bytes was rejected by the browser, falling back to "+(_i?"fetch":"XHR")),_i?_l(w({},e,{$a:!0})):gl(e)}catch(d){S.warn("Beacon send failed",d)}},so=(e,t,i,s)=>{var r=s==="query"?t==="POST"?"sent_at":"_":void 0;return Si(i===Ae.GZipJS?dl(e,"compression"):e,w({},r?{[r]:Date.now().toString()}:{},i===Ae.GZipJS?{}:{compression:i}))},Ji=[];_i&&Ji.push({transport:"fetch",method:_l}),Dr&&Ji.push({transport:"XHR",method:gl}),_e!=null&&_e.sendBeacon&&Ji.push({transport:"sendBeacon",method:Ar});var Ch=class{constructor(e,t){this.Da=!0,this.La=[],this.Na=Je(t?.flush_interval_ms||3e3,250,5e3,S.createLogger("flush interval"),3e3),this.qa=e}enqueue(e){this.La.push(e),this.ja||this.Ba()}unload(){this.Ha();var e=this.La.length>0?this.za():{},t=Object.values(e);[...t.filter(i=>i.url.indexOf("/e")===0),...t.filter(i=>i.url.indexOf("/e")!==0)].map(i=>{this.Ua(w({},i,{transport:"sendBeacon"}))})}enable(){this.Da=!1,this.Ba()}Ba(){var e=this;this.Da||(this.ja=setTimeout(()=>{if(this.Ha(),this.La.length>0){var t=this.za(),i=function(){var r=t[s],n=new Date().getTime();r.data&&C(r.data)&&U(r.data,o=>{o.offset=Math.abs(o.timestamp-n),delete o.timestamp}),e.Ua(r)};for(var s in t)i()}},this.Na))}Ua(e){try{this.qa(e)}catch(t){S.error(t)}}Ha(){clearTimeout(this.ja),this.ja=void 0}za(){var e={};return U(this.La,t=>{var i,s=t,r=(s?s.batchKey:null)||s.url;b(e[r])&&(e[r]=w({},s,{data:[]})),(i=e[r].data)==null||i.push(s.data)}),this.La=[],e}},Ah=class{constructor(e){this._instance=e,this.Wa=!1,this.Va=3e3,this.La=[],this.La=[],this.Ga=!0,this.resume()}resume(){if(!b(f)&&"onLine"in f.navigator){if(this.Ga=f.navigator.onLine,this.Za)return;this.Za=()=>{this.Ga=!0,this.Ja()},this.Qa=()=>{this.Ga=!1},z(f,"online",this.Za),z(f,"offline",this.Qa)}}get length(){return this.La.length}retriableRequest(e){var t=e.retriesPerformedSoFar,i=Oo(e,Il);Ze(t)&&(i.url=Si(i.url,{retry_count:t})),this._instance._send_request(w({},i,{callback:s=>{if(s.statusCode!==200&&(400>s.statusCode||s.statusCode>=500)){if((s.statusCode===0?3:10)>(t??0))return void this.ws(w({retriesPerformedSoFar:t},i));s.statusCode===0&&S.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(t??0)+" retries.")}i.callback==null||i.callback(s)}}))}ws(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(n){var o=3e3*Math.pow(2,n),a=o/2,l=Math.min(18e5,o),u=(Math.random()-.5)*(l-a);return Math.ceil(l+u)})(t),s=Date.now()+i;this.La.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),S.warn(r),this.Wa||(this.Wa=!0,this.Ka())}Ka(){if(this.Xa&&clearTimeout(this.Xa),this.La.length===0)return this.Wa=!1,void(this.Xa=void 0);this.Xa=setTimeout(()=>{this.Ga&&this.La.length>0&&this.Ja(),this.Ka()},this.Va)}Ja(){var e=Date.now(),t=[],i=this.La.filter(r=>e>r.retryAt||(t.push(r),!1));if(this.La=t,i.length>0)for(var s of i)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this.Xa&&(clearTimeout(this.Xa),this.Xa=void 0),this.Wa=!1,b(f)||(this.Za&&(f.removeEventListener("online",this.Za),this.Za=void 0),this.Qa&&(f.removeEventListener("offline",this.Qa),this.Qa=void 0)),this.La)){var t=e.requestOptions;try{this._instance._send_request(w({},t,{transport:"sendBeacon"}))}catch(i){S.error(i)}}this.La=[]}},Mh=class{constructor(e){this._instance=e,this.Ya=()=>{var t,i,s,r;this.tl||(this.tl={});var n=this.scrollElement(),o=this.scrollY(),a=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=o+(n?.clientHeight||0),u=n?.scrollHeight||0;this.tl.lastScrollY=Math.ceil(o),this.tl.maxScrollY=Math.max(o,(t=this.tl.maxScrollY)!==null&&t!==void 0?t:0),this.tl.maxScrollHeight=Math.max(a,(i=this.tl.maxScrollHeight)!==null&&i!==void 0?i:0),this.tl.lastContentY=l,this.tl.maxContentY=Math.max(l,(s=this.tl.maxContentY)!==null&&s!==void 0?s:0),this.tl.maxContentHeight=Math.max(u,(r=this.tl.maxContentHeight)!==null&&r!==void 0?r:0)}}get el(){return this._instance.config.scroll_root_selector}getContext(){return this.tl}resetContext(){var e=this.tl;return setTimeout(this.Ya,0),e}startMeasuringScrollPosition(){z(f,"scroll",this.Ya,{capture:!0}),z(f,"scrollend",this.Ya,{capture:!0}),z(f,"resize",this.Ya)}scrollElement(){var e;if(!this.el)return f==null||(e=f.document)==null?void 0:e.documentElement;for(var t of C(this.el)?this.el:[this.el]){var i,s=f==null||(i=f.document)==null?void 0:i.querySelector(t);if(s)return s}}il(e){var t,i,s=e==="y"?"scrollTop":"scrollLeft";if(this.el){var r=this.scrollElement();return r&&r[s]||0}return f?e==="y"?f.scrollY||f.pageYOffset||((t=f.document)==null||(t=t.documentElement)==null?void 0:t.scrollTop)||0:f.scrollX||f.pageXOffset||((i=f.document)==null||(i=i.documentElement)==null?void 0:i.scrollLeft)||0:0}scrollY(){return this.il("y")}scrollX(){return this.il("x")}},Lh=e=>sl(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),ro=class{constructor(e,t,i,s){this.Be=r=>{var n=this.rl();if(!n||n.sessionId!==r){var o={sessionId:r,props:this.nl(this._instance)};this.sl.register({[br]:o})}},this._instance=e,this.ol=t,this.sl=i,this.nl=s||Lh,this.ol.onSessionId(this.Be)}rl(){return this.sl.props[br]}getSetOnceProps(){var e,t=(e=this.rl())==null?void 0:e.props;return t?"r"in t?rl(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return U(Jr(this.getSetOnceProps()),(t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+tr(i)]=t}),e}},ds=class{on(e,t){return this.al[e]||(this.al[e]=[]),this.al[e].push(t),()=>{this.al[e]=this.al[e].filter(i=>i!==t)}}emit(e,t){for(var i of this.al[e]||[])i(t);for(var s of this.al["*"]||[])s(e,t)}constructor(){this.al={}}},Ft=le("[SessionId]"),no=864e5,oo=class{on(e,t){return this.ll.on(e,t)}constructor(e,t,i){var s;if(this.ul=null,this.hl=null,this.dl=[],this.vl=void 0,this.cl=!1,this.ll=new ds,this.fl=(a,l)=>!(!Ze(a)||!Ze(l))&&Math.abs(a-l)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Rn=e.config,this.sl=e.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.pl=void 0,this._sessionActivityTimestamp=null,this.gl=t||He,this.ml=i||He;var r=this.Rn.persistence_name||this.Rn.token;if(this._sessionTimeoutMs=1e3*Je(this.Rn.session_idle_timeout_seconds||1800,60,36e3,Ft.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.yl(),this.bl="ph_"+r+"_window_id",this._l="ph_"+r+"_primary_window_exists",this.wl()){var n=G.Nt(this.bl),o=G.Nt(this._l);n&&!o?this.He=n:G.Dt(this.bl),G.Ot(this._l,!0)}(s=this.Rn.bootstrap)!=null&&s.sessionID&&this.setBootstrapSessionId(this.Rn.bootstrap.sessionID),this.kl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return b(this.dl)&&(this.dl=[]),this.dl.push(e),this.Xt&&e(this.Xt,this.He),()=>{this.dl=this.dl.filter(t=>t!==e)}}wl(){return this.Rn.persistence!=="memory"&&!this.sl.gi&&G.Et()}Sl(e){e!==this.He&&(this.He=e,this.wl()&&G.Ot(this.bl,e))}xl(){return this.He?this.He:this.wl()?G.Nt(this.bl):null}Cl(e){var t=this.ul;return!oe(t)&&!oe(e)&&5e3>Math.abs(e-t)}Tl(e,t,i){var s=t!==this._sessionActivityTimestamp,r=!(e!==this.Xt||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.Xt=e,r&&!s||r&&this.Cl(t)||(this.ul=t,this.sl.register({[Ct]:[t,e,i]}))}Ml(){var e,t=(e=this.Rn)==null?void 0:e.persistence_save_debounce_ms;return Ze(t)&&t>0}Il(){this.Ml()?this.sl.refreshKey(Ct):(this.sl.flush(),this.sl.load())}El(){var e;if(!oe(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.ul){this.Il();var t=this.Rl();t[1]===this.Xt&&t[2]===this._sessionStartTimestamp&&(this.ul=this._sessionActivityTimestamp,this.sl.register({[Ct]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.sl.flush())}}Al(){var e=this.Rl()[0],t=Ze(e)?e:0,i=Ze(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}Pl(e){return this.Il(),this.fl(e,this.Al())}Rl(){var e=this.sl.props[Ct];return C(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.ul=null,this.pl=void 0,clearTimeout(this.Fl),this.Fl=void 0,this.Tl(null,null,null)}setBootstrapSessionId(e,t){t===void 0&&(t=!1);var i=(function(s,r){r===void 0&&(r=new Date().getTime());try{var n=(o=>{var a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(s);return n>r+6e4?void Ft.error("Bootstrap sessionID cannot be in the future"):n}catch(o){return void Ft.error("Invalid sessionID in bootstrap",o)}})(e);return!b(i)&&(t?this.pl={sessionId:e,sessionStartTimestamp:i}:this.Tl(e,new Date().getTime(),i),!0)}destroy(){this.cl=!0,this.El(),clearTimeout(this.Fl),this.Fl=void 0,this.vl&&f&&(f.removeEventListener(os,this.vl,{capture:!1}),this.vl=void 0),this.dl=[]}kl(){this.vl=()=>{this.El(),this.wl()&&G.Dt(this._l)},z(f,os,this.vl,{capture:!1})}checkAndGetSessionAndWindowId(e,t,i){if(e===void 0&&(e=!1),t===void 0&&(t=null),i===void 0&&(i=!1),this.Rn.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||new Date().getTime(),r=this.Xt;if(i)this.hl=s;else if(oe(this.hl)||this.hl>s||s-this.hl>=1e3){var n,o;(n=(o=this.sl).syncCookieProperties)==null||n.call(o),this.hl=s}var a=this.Rl(),l=a[1],u=a[2],h=!b(r)&&l!==r,c=this.Al(),d=this.xl(),v=this.pl,p=!!v&&(v.sessionStartTimestamp>s+6e4||s-v.sessionStartTimestamp>no),g=v?p:Ze(u)&&Math.abs(s-u)>no,_=!1,m=h,y=!l||!!v,k=l,x=!y&&!e&&this.fl(s,c);if(x){(x=this.Pl(s))||Ft.info("cross-tab refresh kept the session alive",{sessionId:l});var P=this.Rl();l=P[1],u=P[2]}if(y||x||g){m=!1;var $=v&&!p;l=$?v.sessionId:this.gl(),d=this.ml(),Ft.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!$,changeReason:{noSessionId:y,activityTimeout:x,sessionPastMaximumLength:g}}),u=$?v.sessionStartTimestamp:s,this.pl=void 0,_=!0}else d||(d=this.ml(),_=!0),(m=m||l!==k)&&(Ft.info("adopted cross-tab session id",{sessionId:l,windowId:d}),_=!0);var N=Ze(c)&&e&&!g?c:s,T=Ze(u)?u:new Date().getTime();this.Sl(d),this.Tl(l,N,T),e||this.yl();var J={noSessionId:y,activityTimeout:x,sessionPastMaximumLength:g,crossTabAdoption:m};return _&&this.dl.forEach(F=>F(l,d,J)),{sessionId:l,windowId:d,sessionStartTimestamp:T,changeReason:_?J:void 0,lastActivityTimestamp:c}}yl(){this.cl||(clearTimeout(this.Fl),this.Fl=setTimeout(()=>{if(!this.cl)if(this.Pl(new Date().getTime())){var e=this.Xt;this.resetSessionId(),this.ll.emit("forcedIdleReset",{idleSessionId:e})}else this.yl()},1.1*this.sessionTimeoutMs))}},ml=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&vn(i,t))return!0;try{var s=e?.userAgentData;if(s!=null&&s.brands&&s.brands.some(r=>vn(r?.brand,t)))return!0}catch{}return!!e.webdriver};function yl(){return(yl=X(function*(){var e=_e?.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t,i=(t=yield e.getHighEntropyValues(["model"]))==null?void 0:t.model;return q(i)&&i.length>0?i:void 0}catch(s){return void S.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",s)}})).apply(this,arguments)}function Dh(e,t){var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i}function bl(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var vs=(e,t)=>{if(!(i=>{try{new RegExp(i)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Mi=e=>e.toLowerCase(),wl={exact:(e,t)=>t.some(i=>e.some(s=>i===s)),is_not:(e,t)=>t.every(i=>e.every(s=>i!==s)),regex:(e,t)=>t.some(i=>e.some(s=>vs(i,s))),not_regex:(e,t)=>t.every(i=>e.every(s=>!vs(i,s))),icontains:(e,t)=>t.map(Mi).some(i=>e.map(Mi).some(s=>i.includes(s))),not_icontains:(e,t)=>t.map(Mi).every(i=>e.map(Mi).every(s=>!i.includes(s))),gt:(e,t)=>t.some(i=>{var s=parseFloat(i);return!isNaN(s)&&e.some(r=>s>parseFloat(r))}),lt:(e,t)=>t.some(i=>{var s=parseFloat(i);return!isNaN(s)&&e.some(r=>s<parseFloat(r))})};function El(e,t){return!e||Object.entries(e).every(i=>{var s=i[1],r=t?.[i[0]];if(r==null)return!1;var n=wl[s.operator];return!!n&&n(s.values,[String(r)])})}function Vs(e,t,i){return Mt({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Mr="custom",ao="i.posthog.com",Nh=/^\/static\//,jh=["/s/","/e/","/i/"],qh=class{constructor(e){this.Ol={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Ol[this.apiHost]||(this.Ol[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":Mr),this.Ol[this.apiHost]}$l(e){if(Nh.test(e)){var t=this.instance.config.asset_host;if(typeof t=="string")return t.trim().replace(/\/$/,"")||void 0}}Dl(e){var t=Ut(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}Ll(e,t,i){if(e==="ui")return i;var s=i,r=this.instance.config.rewriteRequestPath;if(r){var n,o=((n=Ut(i))==null?void 0:n.href)||i;s=r(new URL(o)).toString()}if(r&&e==="api"&&jh.some(c=>t.indexOf(c)===0)){var a=this.Dl(s);if(a){var l,u=this.apiHost,h=this.Nl;((l=h)==null?void 0:l.apiHost)===u&&h.rewriteRequestPath===r||(this.Nl=h={apiHost:u,rewriteRequestPath:r,urls:new Set}),h.urls.add(a)}}return s}isIngestionEndpoint(e){var t=this.Nl,i=this.Dl(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.Ll(e,t,this.uiHost+t);if(e==="flags")return this.Ll(e,t,this.flagsApiHost+t);if(e==="assets"){var i=this.$l(t);if(i)return this.Ll(e,t,""+i+t)}if(this.region===Mr)return this.Ll(e,t,this.apiHost+t);var s=ao+t;switch(e){case"assets":return this.Ll(e,t,"https://"+this.region+"-assets."+s);case"api":return this.Ll(e,t,"https://"+this.region+"."+s)}}},H=le("[Surveys]"),xl=e=>{try{var t=(i=>((s,r)=>"seenSurvey_"+(function(n){return n.current_iteration&&n.current_iteration>0?n.id+"_"+n.current_iteration:n.id})(r))(0,i))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(i){H.error("Failed to persist survey seen state",i)}},Bh=[qs.Popover,qs.Widget,qs.API],Uh={ignoreConditions:!1,ignoreDelay:!1,displayType:Fr.Popover},Hh=le("[PostHog ExternalIntegrations]"),zh={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Vh=class{constructor(e){this._instance=e}bo(e,t){var i;(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,s=>{if(s)return Hh.error("failed to load script",s);t()})}startIfEnabledOrStop(){var e=this,t=function(){var r,n,o,a=i[0],l=i[1];!l||(r=O.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]||e.bo(zh[a],()=>{var u;(u=O.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.start(e._instance)}),!l&&(n=O.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[a]&&((o=O.__PosthogExtensions__)==null||(o=o.integrations)==null||(o=o[a])==null||o.stop())};for(var i of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t()}}},Wh=class{constructor(e,t){this.A=e,this.Js=t,this.ql=new Map,this.ro=!1}add(e){var t=this;return X(function*(){if(t.ro)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.ql.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t.ql.set(e.name,e);try{var i=e.setup(t.Js);i&&(yield i)}catch(r){var s=t.ql.get(e.name)===e;s&&t.ql.delete(e.name),t.A.error('Failed to set up browser extension "'+e.name+'"',r),s&&t.jl(e)}})()}getExtension(e){return this.ql.get(e)}dispose(){if(!this.ro){this.ro=!0;var e=Array.from(this.ql.values()).reverse();for(var t of(this.ql.clear(),e))this.jl(t)}}jl(e){try{var t=e.dispose==null?void 0:e.dispose();t&&ke(t.then)&&t.then(void 0,i=>{this.A.error('Failed to dispose browser extension "'+e.name+'"',i)})}catch(i){this.A.error('Failed to dispose browser extension "'+e.name+'"',i)}}},Gh=class{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if(typeof e=="string")return t?.get_property(e);var i={};for(var s of e){var r=t?.get_property(s);b(r)||(i[s]=r)}return i}set(e,t){var i;(i=this._instance.persistence)==null||i.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}},lo="extensionsRemoteConfig",Jh=class{constructor(e){this.instance=e,this.ro=!1,this.A=S,this.Bl=e.Hl,this.kv=new Gh(e),this.onEvent=t=>Ai(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(s){this.A.error("Browser extension event listener failed",s)}})),this.onRemoteConfig=t=>{if(this.ro)return Ai(()=>{});var i=r=>{try{t(r)}catch(n){this.A.error("Browser extension remote config listener failed",n)}},s=this.instance.zl.on(lo,i);return this.Bl&&i(this.Bl),Ai(s)},this.Ul=new Wh(S.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){var e=this.instance.get_property(Ur);return typeof e=="string"?e:void 0}get library(){return{name:pe.LIB_NAME,version:pe.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)==null?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,r=(e=this.instance.sessionManager)==null?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=r?.sessionId)!==null&&t!==void 0?t:"",windowId:(i=r?.windowId)!==null&&i!==void 0?i:"",sessionStartTimestamp:(s=r?.sessionStartTimestamp)!==null&&s!==void 0?s: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.Ul.add(e)}getExtension(e){return this.Ul.getExtension(e)}capture(e,t,i){var s=this;return X(function*(){i?s.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):s.instance.capture(e,t)})()}registerDynamicEventProperties(e){return Ai(this.instance.Wl(e))}handleRemoteConfig(e){this.ro||(this.Bl=e,this.instance.zl.emit(lo,e))}sendRequest(e,t){var i=this;return X(function*(){var s;t===void 0&&(t={});var r=i.instance.requestRouter.endpointFor((s=t.target)!==null&&s!==void 0?s:"api",e),n={method:t.method,url:t.query?Si(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,compressionFallback:t.target==="flags"&&t.compression==="best-available"?ir.Base64:void 0,timestampMode:t.sentAt};return t.transport==="sendBeacon"?(i.instance._send_request(n),{statusCode:202}):new Promise(o=>{n.callback=o,i.instance._send_request(n)})})()}dispose(){this.ro||(this.ro=!0,this.Ul.dispose())}},fi={},Ws=0,gi=()=>{},uo='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ni="Surveys module not available",ho="sanitize_properties is deprecated. Use before_send instead",kl="Invalid value for property_denylist config: ",Yh=/^[A-Za-z0-9_-]{1,400}$/,Gs=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Kh=["token","distinct_id",Aa],ui="posthog",Sl=!Fh&&$e?.indexOf("MSIE")===-1&&$e?.indexOf("Mozilla")===-1,Xh=e=>{var 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},Js=e=>{var t;return w({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Zu(E?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:gi,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:ne&&q(ne?.search)&&ne.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:(f==null||(t=f.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(i){S.error("Bad HTTP status: "+i.statusCode+" "+i.text)},get_device_id:i=>i,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Da,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:gi},(i=>({rageclick:i&&i>="2026-05-30"?{content_ignorelist:oh,ignore_text_selection:!0}:!i||"2025-11-30">i||{content_ignorelist:!0},capture_pageview:!i||"2025-05-24">i||"history_change",session_recording:Xh(i),external_scripts_inject_target:i&&i>="2026-01-30"?"head":"body",internal_or_test_user_hostname:i&&i>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:i&&i>="2026-05-30"?250:0,split_storage:!(!i||"2026-05-30">i),detect_google_search_app:!(!i||"2026-05-30">i),disable_capture_url_hashes:!(!i||"2026-06-25">i),cookieWinsOnConflict:!(!i||i==="unset"||"2026-08-29">i)}))(e))},Zh=[["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"]],co=e=>{var t={};for(var i of Zh){var s=i[0],r=i[1];b(e[s])||(t[r]=e[s])}var n=K({},t,e),o=e.__preview_external_dependency_versioned_paths;return b(o)||(b(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),q(o)&&b(e.asset_host)&&(n.asset_host=o)),C(e.property_blacklist)&&(b(e.property_denylist)?n.property_denylist=e.property_blacklist:C(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:S.error(kl+e.property_denylist)),n},Qh=class{constructor(){this.__forceAllowLocalhost=!1}get Vl(){return this.__forceAllowLocalhost}set Vl(e){S.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},tn=(Pi=class nt{Gl(t){if(t){var i=this.ql.indexOf(t);i!==-1&&this.ql.splice(i,1)}}Zl(t,i){return this.Gl(t),this.ql.push(i),i.initialize==null||i.initialize(),i}Jl(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}Ql(){if(!(this.Kl||this.config.reuseAnonymousId||this.config.segment||this.Jl())){var t,i,s,r=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";(r||this.config.disable_persistence)&&(this.Xl||(r?(t="persistence is set to '"+this.config.persistence+"'",i=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.Kl=!0,console.warn("[PostHog.js]",t+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+i+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+s)))}}Yl(){if(!this.Jl()&&this.get_distinct_id()==="$posthog_cookieless"){var t=this.persistence;if(t){this.tu()||t.load(!0);var i=this.get_distinct_id();if(!i||i==="$posthog_cookieless"){var s=this.config.get_device_id(He());this.register({distinct_id:s,$device_id:s}),t.set_property(Ee,ot)}this.eu()}}}get decideEndpointWasHit(){var t,i;return(t=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,i;return(t=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.iu=!1,this.ru=!1,this.webPerformance=new Qh,this.nu=!1,this.version=pe.LIB_VERSION,this.su=new Set,this.ou="",this.zl=new ds,this.ql=[],this.au=[],this.Xl=!1,this.Kl=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Js(),this.SentryIntegration=ph,this.sentryIntegration=s=>(function(r,n){var o=Ka(r,n);return{name:Ya,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.lu=!1,this.uu=null,this.hu=null,this.du=null,this.scrollManager=new Mh(this),this.pageViewManager=new Yn(this),this.rateLimiter=new xh(this),this.requestRouter=new qh(this),this.consent=new nh(this),this.externalIntegrations=new Vh(this);var i=(t=nt.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(s,r,n)=>{var o=q(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=q(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",s=>S.info('send "'+s?.event+'"',s))}init(t,i,s){if(s&&s!==ui){var r,n=(r=fi[s])!==null&&r!==void 0?r:new nt;return n._init(t,i,s),fi[s]=n,fi[ui][s]=n,n}return this._init(t,i,s)}_init(t,i,s){var r,n,o;i===void 0&&(i={});var a,l=q(t)?t.trim():"";if(!l)return S.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 l!==((a=this.config)==null?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+l+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Js(i.defaults),i.debug=this.vu(i.debug),this.cu=i,this.fu=[],i.person_profiles?this.hu=i.person_profiles:i.process_person&&(this.hu=i.process_person);var u=Js(i.defaults),h=co(i),c=K({},u,h,{name:s,token:l});j(u.rageclick)&&j(h.rageclick)&&(c.rageclick=K({},u.rageclick,h.rageclick)),j(u.session_recording)&&j(h.session_recording)&&(c.session_recording=K({},u.session_recording,h.session_recording)),this.set_config(c),this.config.on_xhr_error&&S.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Ae.GZipJS;var d=this.tu();if(this.persistence=new js(this.config,d),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new js(w({},this.config,{persistence:"sessionStorage"}),d,!1),this.ou="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&G.Et()){var v=G.Nt(this.ou);C(v)&&v.forEach(T=>{q(T)&&this.su.add(T)})}else G.Dt(this.ou);var p=w({},this.persistence.props),g=w({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.pu=new Ch(T=>this.gu(T),this.config.request_queue_config),this.mu=new Ah(this),this.__request_queue=[];var _=this.Jl();_||(this.sessionManager=new oo(this),this.sessionPropsManager=new ro(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((T,J,F)=>{(F!=null&&F.activityTimeout||F!=null&&F.sessionPastMaximumLength||F!=null&&F.crossTabAdoption)&&this.yu()})),this.bu(),this.config.__preview_deferred_init_extensions?(S.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._u(_)},0)):(S.info("Initializing extensions synchronously"),this._u(_)),pe.DEBUG=pe.DEBUG||this.config.debug,pe.DEBUG&&S.info("Starting in debug mode",{this:this,config:i,thisC:w({},this.config),p,s:g}),!this.config.identity_distinct_id||(r=i.bootstrap)!=null&&r.distinctID||(i.bootstrap=w({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var m=(n=i.bootstrap)==null?void 0:n.distinctID;if(this.Xl=!!m&&!hi(m),((o=i.bootstrap)==null?void 0:o.distinctID)!==void 0){var y=i.bootstrap.distinctID,k=this.get_distinct_id(),x=this.persistence.get_property(Ee);if(i.bootstrap.isIdentifiedID&&k!=null&&k!==y&&x==="anonymous")this.identify(y);else if(i.bootstrap.isIdentifiedID&&k!=null&&k!==y&&x==="identified")S.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var P=this.config.get_device_id(He()),$=i.bootstrap.isIdentifiedID?P:y;this.persistence.set_property(Ee,i.bootstrap.isIdentifiedID?li:ot),this.register({distinct_id:y,$device_id:$})}}if(_)this.register_once({distinct_id:Is,$device_id:null},"");else if(!this.get_distinct_id()){var N=this.config.get_device_id(He());this.register_once({distinct_id:N,$device_id:N},""),this.persistence.set_property(Ee,ot)}return z(f,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),z(f,"pageshow",()=>{var T;this.iu=!1,this.ru||(T=this.mu)==null||T.resume()}),i.segment?Jn(this,()=>this.wu()):this.wu(),ke(this.config._onCapture)&&this.config._onCapture!==gi&&(S.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",T=>this.config._onCapture(T.event,T))),this.config.ip&&S.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 yl.apply(this,arguments)})().then(T=>{T&&this.register({[Ts]:T})}).catch(gi),this}ku(t){var i=t;return q(i.name)&&ke(i.setup)}Su(t,i){this.ku(t)?i.push(()=>{this.xu().add(t).catch(()=>t.dispose==null?void 0:t.dispose()).catch(s=>{S.error('Failed to dispose browser extension "'+t.name+'"',s)})}):this.ql.push(t)}bu(){var t,i,s,r,n,o,a=(t=(i=this.config.__extensionClasses)==null?void 0:i.featureFlags)!==null&&t!==void 0?t:(s=nt.__defaultExtensionClasses)==null?void 0:s.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||((o=this.Cu)==null||o.call(this),this.Cu=void 0,this.featureFlags=new a(this)),ke(this.featureFlags.onReloading)&&ke(this.featureFlags.setup)?this.Cu||(this.Cu=this.featureFlags.onReloading(()=>{this.zl.emit("featureFlagsReloading",!0)}),this.xu().add(this.featureFlags)):(r=(n=this.featureFlags).initialize)==null||r.call(n))}_u(t){var i,s,r,n,o,a,l,u=performance.now(),h=w({},nt.__defaultExtensionClasses,this.config.__extensionClasses),c=[];h.exceptions&&this.ql.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new h.exceptions(this)),h.historyAutocapture&&this.ql.push(this.historyAutocapture=new h.historyAutocapture(this)),h.tracingHeaders&&this.ql.push(this.tracingHeaders=new h.tracingHeaders(this)),h.siteApps&&this.ql.push(this.siteApps=new h.siteApps(this)),h.sessionRecording&&!t&&this.ql.push(this.sessionRecording=new h.sessionRecording(this)),this.config.disable_scroll_properties||c.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),h.autocapture&&this.Su(this.autocapture=new h.autocapture(this),c),h.surveys&&this.Su(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new h.surveys(this),c),h.logs&&this.Su(this.logs=(r=this.logs)!==null&&r!==void 0?r:new h.logs(this),c),h.metrics&&this.ql.push(this.metrics=(n=this.metrics)!==null&&n!==void 0?n:new h.metrics(this)),h.conversations&&this.ql.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new h.conversations(this)),h.productTours&&this.ql.push(this.productTours=new h.productTours(this)),h.heatmaps&&this.ql.push(this.heatmaps=new h.heatmaps(this)),h.webVitalsAutocapture&&this.ql.push(this.webVitalsAutocapture=new h.webVitalsAutocapture(this)),h.exceptionObserver&&this.ql.push(this.exceptionObserver=new h.exceptionObserver(this)),h.deadClicksAutocapture&&this.ql.push(this.deadClicksAutocapture=new h.deadClicksAutocapture(this,vh)),h.toolbar&&this.ql.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new h.toolbar(this)),h.experiments&&this.ql.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new h.experiments(this)),this.ql.forEach(d=>{d.initialize&&c.push(()=>{d.initialize==null||d.initialize()})}),c.push(()=>{if(this.Tu){var d=this.Tu;this.Tu=void 0,this.ql.forEach(v=>v.onRemoteConfig==null?void 0:v.onRemoteConfig(d))}}),this.Mu(c,u)}Mu(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.Mu(t,i)},0);var s=t.shift();if(s)try{s()}catch(n){S.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-i);this.register_for_session({[Ma]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[La]:r}),this.config.__preview_deferred_init_extensions&&S.info("PostHog extensions initialized ("+r+"ms)")}Pa(t){var i;if(!E||!E.body)return S.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Pa(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Tu=t),this.Hl=t,this.compression=void 0,t.ok){var s,r=t.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=A(r.supportedCompression,Ae.GZipJS)?Ae.GZipJS:A(r.supportedCompression,Ae.Base64)?Ae.Base64:void 0),(s=r.analytics)!=null&&s.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.hu?this.hu:Da}),(i=this.Iu)==null||i.handleRemoteConfig(t),this.ql.forEach(n=>n.onRemoteConfig==null?void 0:n.onRemoteConfig(t))}wu(){try{this.config.loaded(this)}catch(s){S.critical("`loaded` function failed",s)}if(this.Eu(),this.config.internal_or_test_user_hostname&&ne!=null&&ne.hostname){var t=ne.hostname,i=this.config.internal_or_test_user_hostname;(typeof i=="string"?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Jl())&&this.Ru()},1),this.Au=new ol(this),this.Au.load()}Eu(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.pu)==null||t.enable())}_dom_loaded(){this.is_capturing()&&Ti(this.__request_queue,t=>this.gu(t)),this.__request_queue=[],this.Eu()}_handle_unload(){var t,i,s,r,n;this.iu=!0,(t=this.surveys)==null||t.handlePageUnload==null||t.handlePageUnload(),(i=this.metrics)==null||i.flush("sendBeacon"),this.config.request_batching?(this.Pu()&&this.capture(In),(s=this.logs)==null||s.flushLogs("sendBeacon"),(r=this.pu)==null||r.unload(),(n=this.mu)==null||n.unload()):this.Pu()&&this.capture(In,null,{transport:"sendBeacon"})}_send_request(t){var i;this.__loaded?Sl?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=w({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?(i=this.compression)!==null&&i!==void 0?i:t.compressionFallback:t.compression,(b(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(s=>{var r,n,o,a=w({},s);a.timeout=a.timeout||6e4;var l,u,h,c,d,v=(r=a.transport)!==null&&r!==void 0?r:"fetch";v==="sendBeacon"&&b(a.compression)&&a.data&&(a.compression=Ae.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(u=(d=(c=(C(l=a.data)?l:[l]).map(m=>w({},m,m.timestamp instanceof Date&&!isNaN(m.timestamp.getTime())?{timestamp:m.timestamp.toISOString()}:{})))[0])==null||(h=d.properties)==null?void 0:h.token)!==null&&u!==void 0?u:d?.token,batch:c,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=(function(m,y){return y===void 0&&(y=new Date().toISOString()),C(m)?m.map(k=>w({},k,{sent_at:y})):w({},m,{sent_at:y})})(a.data))),a.url=so(a.url,a.method,a.compression,a.timestampMode);var p=Ji.filter(m=>!a.disableTransport||!m.transport||!a.disableTransport.includes(m.transport)),g=(n=(o=(function(m,y){for(var k=0;m.length>k;k++)if(y(m[k]))return m[k]})(p,m=>m.transport===v))==null?void 0:o.method)!==null&&n!==void 0?n:p[0].method;if(!g)throw new Error("No available transport method");var _=m=>{try{g(m)}catch(y){fl(y)?S.warn(y):S.error(y),a.callback==null||a.callback({statusCode:0,error:y})}};v!=="sendBeacon"&&a.data&&a.compression===Ae.GZipJS&&Cl&&typeof Promise<"u"&&!Gi?Ih(a).then(m=>{_(m)}).catch(m=>{if(Pn(m))return Gi=!0,void _(w({},a,{compression:void 0,url:so(s.url,s.method,void 0,s.timestampMode)}));(y=>{if(!y||typeof y!="object")return!1;var k="name"in y?String(y.name):"";return Pn(y)||k===ga})(m)&&(Gi=!0),_(a)}):g(a)})(w({},t,{callback:s=>{var r,n;this.rateLimiter.checkForLimiting(s),400>s.statusCode||(r=(n=this.config).on_request_error)==null||r.call(n,s),t.callback==null||t.callback(s)}}))):t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:0}))}gu(t){this.mu?this.mu.retriableRequest(t):this._send_request(t)}_execute_array(t){Ws++;try{var i,s=[],r=[],n=[];Ti(t,a=>{if(a)if(C(i=a[0]))n.push(a);else if(ke(a))try{a.call(this)}catch(l){S.error("Error executing queued PostHog call",a,l)}else C(a)&&i==="alias"?s.push(a):C(a)&&i.indexOf("capture")!==-1&&ke(this[i])?n.push(a):r.push(a)});var o=function(a,l){Ti(a,function(u){try{if(C(u[0])){var h=l;U(u,function(c){h=h[c[0]].apply(h,c.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(c){S.error("Error executing queued PostHog call",u,c)}})};o(s,this),o(r,this),o(n,this)}finally{Ws--}}push(t){if(Ws>0&&C(t)&&q(t[0])){var i=nt.prototype[t[0]];ke(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}Fu(){var t,i=(t=this.persistence)==null?void 0:t.get_property(Ue);return q(i)&&Gs.test(i)?{value:i,delivered:!1}:j(i)&&q(i.value)&&Gs.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}Ou(t,i,s,r){if(this.persistence){this.persistence.refreshKey(Ue);var n=this.Fu();if(!r){if(s)return q(i)&&Gs.test(i)?(i!==n?.value&&this.persistence.register({[Ue]:{value:i,delivered:!1}}),{value:i,pending:i!==n?.value||!n.delivered}):void this.persistence.unregister(Ue);if(q(t)&&Yh.test(t)){if(n?.value.split(".")[3]===t)return{value:n.value,pending:!n.delivered};var o="fb.1."+Date.now()+"."+t;return this.persistence.register({[Ue]:{value:o,delivered:!1}}),{value:o,pending:!0}}return n?{value:n.value,pending:!n.delivered}:void 0}this.persistence.unregister(Ue)}}$u(t){if(this.persistence){this.persistence.refreshKey(Ue);var i=this.Fu();i?.value!==t||i.delivered||this.persistence.register({[Ue]:{value:t,delivered:!0}})}}capture(t,i,s){var r,n,o,a,l,u,h,c,d,v;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.pu){if(this.is_capturing())if(!b(t)&&q(t)){this.Yl();var p=!this.config.opt_out_useragent_filter&&this._is_bot();if(!p||this.config.__preview_capture_bot_pageviews){var g=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(g==null||!g.isRateLimited){var _;i!=null&&i.$current_url&&!q(i?.$current_url)&&(S.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),t!=="$exception"||s!=null&&s.Du||S.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(_=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var m=new Date,y=s?.timestamp||m,k=yn(s?.uuid,He),x={uuid:k,event:t,properties:this.calculateEventProperties(t,i||{},y,k)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&p&&(x.event="$bot_pageview",x.properties.$browser_type="bot"),g&&(x.properties.$lib_rate_limit_remaining_tokens=g.remainingTokens);var P=t==="$feature_flag_called"&&x.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;s!=null&&s.$set&&!P&&(x.$set=s?.$set);var $=j(i?.$set)?i.$set:void 0,N=!(s==null||!s.$set)&&"$fbc"in s.$set,T=N||!!$&&"$fbc"in $,J=N?s==null||(r=s.$set)==null?void 0:r[Fs]:$?.[Fs],F=C(i?.$unset)?i.$unset:[],R=s?.$unset||[],L=F.indexOf("$fbc")!==-1||R.indexOf("$fbc")!==-1,I=this.Ou((n=_)==null?void 0:n.fbclid,J,T,L);I&&x.properties.$process_person_profile===!0&&I.pending&&!T&&!P&&(x.$set=w({[Fs]:I.value},x.$set));var M=s?.$unset;M&&(x.$unset=M);var Y=P?void 0:this.Lu(s?.$set_once,t!==On,t===xr);if(Y&&(x.$set_once=Y),s!=null&&s._noTruncate||(h=this.config.properties_string_max_length,c=x,d=Q=>q(Q)?Q.slice(0,h):Q,v=new Set,x=(function Q(se,je){if(se!==Object(se))return d?d(se):se;if(!v.has(se)){var he;if(v.add(se),C(se))he=[],Ti(se,Ce=>{he.push(Q(Ce))});else{var we={};U(ki(se)?Na(se):se,(Ce,dt)=>{v.has(Ce)||(we[dt]=Q(Ce,dt))}),he=we}return he}})(c)),x.timestamp=y,b(s?.timestamp)||(x.properties.$event_time_override_provided=!0,x.properties.$event_time_override_system_time=m),P&&(x.properties=(function(Q,se){se===void 0&&(se=[]);var je={},he=we=>{Q[we]!==void 0&&(je[we]=Q[we])};return mu.forEach(he),se.forEach(he),je})(x.properties,Kh)),t===tt.DISMISSED||t===tt.SENT){var ue=i?.[Bs.SURVEY_ID],Z=i?.[Bs.SURVEY_ITERATION];xl({id:ue,current_iteration:Z}),x.$set=w({},x.$set,{[Dh({id:ue,current_iteration:Z},t===tt.SENT?"responded":"dismissed")]:!0})}else t===tt.SHOWN&&(x.$set=w({},x.$set,{[Bs.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(t===Eh.SHOWN){var W=i?.[Zn.TOUR_TYPE];W&&(x.$set=w({},x.$set,{[Zn.TOUR_LAST_SEEN_DATE+"/"+W]:new Date().toISOString()}))}var ee=w({},x.properties.$set,x.$set);if(Oe(ee)||this.setPersonPropertiesForFlags(ee),!D(this.config.before_send)){var fe=this.bs(x);if(!fe)return;(x=fe).uuid=yn(x.uuid,He)}var me=(o=(a=x.$set)==null?void 0:a.$fbc)!==null&&o!==void 0?o:j((l=x.properties)==null?void 0:l.$set)?x.properties.$set.$fbc:void 0,ge=I!=null&&I.pending&&me===I.value?I.value:void 0;this.zl.emit("eventCaptured",x);var ye,V=(u=s?._url)!==null&&u!==void 0?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),ie=w({method:"POST",url:V,data:x,compression:"best-available",timestampMode:s?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(V)?"body":"capture-body",batchKey:s?._batchKey},s!=null&&s.transport?{transport:s.transport}:{},ge?{fireCallbackOnDrop:!0,callback:Q=>{Q.statusCode>=200&&300>Q.statusCode&&this.$u(ge)}}:{});return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly||ge?(!ie.transport&&!ie.callback&&Oe((ye=this.config.request_headers)!==null&&ye!==void 0?ye:{})&&this.iu&&(ie.transport="sendBeacon"),this.gu(ie)):this.pu.enqueue(ie),x}S.critical("This capture call is ignored due to client rate limiting.")}}else S.error("No event name provided to posthog.capture")}else S.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return(i=this.Iu)==null?void 0:i.getExtension(t)}xu(){var t;return(t=this.Iu)!==null&&t!==void 0?t:this.Iu=new Jh(this)}Wl(t){this.au.push(t);var i=!0;return()=>{if(i){i=!1;var s=this.au.indexOf(t);s!==-1&&this.au.splice(s,1)}}}Nu(t){var i,s,r;return t===void 0&&(t=!0),!((i=this.persistence)==null||!i.consumeCookieIdentityChange())&&(this.du=null,this.persistence.get_property("$user_state")==="anonymous"&&((r=this.sessionPersistence)==null||r.clear(),this.su.clear(),this.qu()),(s=this.featureFlags)==null||s.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,i,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this.Nu();var o=n?void 0:this.persistence.remove_event_timer(t),a=w({},i);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Jl()&&(a[Aa]=!0),t==="$snapshot"){var l=w({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!q(a.distinct_id)&&!ae(a.distinct_id)||hi(a.distinct_id))&&S.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,h=(function(N,T,J,F){var R,L,I,M;if(F===void 0&&(F=!1),!$e)return{};var Y,ue=N?[...zt,...T||[]]:[],Z=ca($e),W=Z[0],ee=Z[1],fe=(function(kt){for(var St=0;_n.length>St;St++){var Kt,Pt=_n[St],Xt=Pt[1],sn=Pt[2],rn=kt.match(Pt[0]);if(rn)return[Xt,((Kt=sn&&kt.match(sn)||rn)==null?void 0:Kt[1])||""]}return["",""]})($e),me=fe[0],ge=fe[1],ye=(Y="u">typeof navigator?navigator:void 0)!=null&&Y.brave?{brave:!0}:{},V={};b(J)||(V.detectGoogleSearchApp=J);var ie={},Q=(R=navigator)==null||(R=R.userAgentData)==null?void 0:R.platform,se=(L=navigator)==null?void 0:L.maxTouchPoints,je=f==null||(I=f.screen)==null?void 0:I.width,he=f==null||(M=f.screen)==null?void 0:M.height,we=f?.devicePixelRatio;b(Q)||(ie.userAgentDataPlatform=Q),b(se)||(ie.maxTouchPoints=se),b(je)||(ie.screenWidth=je),b(he)||(ie.screenHeight=he),b(we)||(ie.devicePixelRatio=we);var Ce,dt,de,Wt,Gt,Jt,Le,Ie,Yt=K(Jr({$os:W,$os_version:ee,$browser:ha($e,navigator.vendor,ye,V),$webview_app:me,$webview_app_version:ge,$device:gn($e),$device_type:(dt=$e,de=ie,Ie=gn(dt),Ie===qo||Ie===jo||Ie==="Kobo"||Ie==="Kindle Fire"||Ie===Zo?Ki:Ie===Xi||Ie===_s||Ie===Zi||Ie===sr?"Console":Ie===Bo?"Wearable":Ie?jt:de?.userAgentDataPlatform==="Android"&&((Wt=de?.maxTouchPoints)!==null&&Wt!==void 0?Wt:0)>0?600>Math.min((Gt=de?.screenWidth)!==null&&Gt!==void 0?Gt:0,(Jt=de?.screenHeight)!==null&&Jt!==void 0?Jt:0)/((Le=de?.devicePixelRatio)!==null&&Le!==void 0?Le:1)?jt:Ki:"Desktop"),$timezone:nl(),$timezone_offset:yh()}),{$current_url:Ei(F?ct(ne?.href):ne?.href,ue,xi),$host:ne?.host,$pathname:ne?.pathname,$raw_user_agent:$e.length>1e3?$e.substring(0,997)+"...":$e,$browser_version:Jl($e,navigator.vendor,ye,V),$browser_language:Kn(),$browser_language_prefix:(Ce=Kn(),typeof Ce=="string"?Ce.split("-")[0]:void 0),$screen_height:f?.screen.height,$screen_width:f?.screen.width,$viewport_height:f?.innerHeight,$viewport_width:f?.innerWidth,$lib:it.LIB_NAME,$lib_version:it.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return it.SDK_DIST_CHANNEL&&(Yt.$sdk_dist_channel=it.SDK_DIST_CHANNEL),Yt})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var c=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime(),!0),d=c.windowId;a.$session_id=c.sessionId,a.$window_id=d}this.sessionPropsManager&&K(a,this.sessionPropsManager.getSessionProps());try{var v;this.sessionRecording&&K(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(v=this.mu)==null?void 0:v.length}catch(N){a.$sdk_debug_error_capturing_properties=String(N)}if(this.requestRouter.region===Mr&&(a.$lib_custom_api_host=this.config.api_host),u=t!=="$pageview"||n?t!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=K(a,u),t==="$pageview"&&E&&(a.title=E.title),!b(o)){var p=s.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}$e&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");var g=this.persistence.properties(),_=this.sessionPersistence.properties(),m=a.$groups,y=g.$groups;j(m)&&!Oe(m)&&(a.$groups=w({},j(y)?y:{},m)),U(["$referrer","$referring_domain"],N=>{N in g&&delete _[N]});var k={};if(this.au.length>0)for(var x of this.au.slice())try{K(k,x())}catch(N){S.error("Failed to produce browser extension event properties",N)}(a=K({},h,g,_,w({},k,a))).$is_identified=this._isIdentified(),C(this.config.property_denylist)?U(this.config.property_denylist,function(N){delete a[N]}):S.error(kl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var P=this.config.sanitize_properties;P&&(S.error(ho),a=P(a,t));var $=this.ju();return a.$process_person_profile=$,$&&!n&&this.Bu("_calculate_event_properties"),a}Lu(t,i,s){var r;if(i===void 0&&(i=!0),s===void 0&&(s=!1),!this.persistence||!this.ju()||this.nu&&!s)return t;var n=K({},this.persistence.get_initial_props(),((r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps())||{},t||{}),o=this.config.sanitize_properties;return o&&(S.error(ho),n=o(n,"$set_once")),i&&(this.nu=!0),Oe(n)?void 0:n}register(t,i){var s;(s=this.persistence)==null||s.register(t,i)}register_once(t,i,s){var r;(r=this.persistence)==null||r.register_once(t,i,s)}register_for_session(t){var i,s;(i=this.persistence)==null||i.syncCookieProperties(),this.Nu(),(s=this.sessionPersistence)==null||s.register(t),Object.keys(t).forEach(r=>this.su.add(r)),this.qu()}unregister(t){var i;(i=this.persistence)==null||i.unregister(t)}unregister_for_session(t){var i;(i=this.sessionPersistence)==null||i.unregister(t),this.su.delete(t),this.qu()}Hu(t,i){this.register({[t]:i})}yu(){this.su.forEach(t=>{var i;(i=this.sessionPersistence)==null||i.unregister(t)}),this.su.clear(),this.qu()}qu(){var t;if(this.ou)if(this.config.persistence==="memory"||(t=this.sessionPersistence)!=null&&t.gi||!G.Et())G.Dt(this.ou);else{var i=[];this.su.forEach(s=>i.push(s)),i.length>0?G.Ot(this.ou,i):G.Dt(this.ou)}}getFeatureFlag(t,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return(t=(i=this.featureFlags)==null?void 0:i.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,i){var s,r;return(s=(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(t,i))!==null&&s!==void 0?s:i?.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)==null||t.reloadFeatureFlags()}updateFlags(t,i,s){var r;(r=this.featureFlags)==null||r.updateFlags(t,i,s)}updateEarlyAccessFeatureEnrollment(t,i,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(t,i,s)}getEarlyAccessFeatures(t,i,s){var r;return i===void 0&&(i=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(t,i,s)}on(t,i){return this.zl.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:ni}),()=>{})}onSessionId(t){var i,s;return(i=(s=this.sessionManager)==null?void 0:s.onSessionId(t))!==null&&i!==void 0?i:()=>{}}getSurveys(t,i){i===void 0&&(i=!1),this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:ni})}getActiveMatchingSurveys(t,i){i===void 0&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:ni})}renderSurvey(t,i){var s;(s=this.surveys)==null||s.renderSurvey(t,i)}displaySurvey(t,i){var s;i===void 0&&(i=Uh),(s=this.surveys)==null||s.displaySurvey(t,i)}cancelPendingSurvey(t){var i;(i=this.surveys)==null||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,s;return(i=(s=this.surveys)==null?void 0:s.canRenderSurvey(t))!==null&&i!==void 0?i:{visible:!1,disabledReason:ni}}canRenderSurveyAsync(t,i){var s,r;return i===void 0&&(i=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(t,i))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:ni})}zu(t){return!t||hi(t)?(S.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(S.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(S.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,i,s){if(!this.__loaded||!this.persistence)return S.uninitializedWarning("posthog.identify");if(ae(t)&&(t=t.toString(),S.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.zu(t)&&this.Bu("posthog.identify")){this.Yl();var r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.Nu(!1),a=this.persistence.va(),l=!1;try{var u=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),t!==u&&t!==this.get_property("__alias")&&(this.unregister(rs),this.register({distinct_id:t}));var h=(this.persistence.get_property("$user_state")||"anonymous")===ot,c=t!==u,d=!c&&h;if(c&&h){var v,p=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:u};this.persistence.set_property(Ee,li),this.setPersonPropertiesForFlags({$set:i||{},$set_once:s||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.ca(),this.capture(xr,p,{$set:i||{},$set_once:s||{}}),this.du=Vs(t,i,s),(v=this.featureFlags)==null||v.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(d){this.persistence.set_property(Ee,li);var g=i||{},_=s||{};this.setPersonPropertiesForFlags({$set:g,$set_once:_},!1),this.config.cookieWinsOnConflict&&this.persistence.ca(),this.capture("$set",{$set:g,$set_once:_}),this.du=Vs(t,i,s)}else(i||s)&&this.setPersonProperties(i,s);c||n||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ut)):d&&(i||s)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.ga(l)}}}setPersonProperties(t,i){if((t||i)&&this.Bu("posthog.setPersonProperties")){var s=Vs(this.get_distinct_id(),t,i);this.du!==s?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.du=s):S.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var i,s=(C(t)?t:[t]).filter(r=>q(r)&&r.length>0);s.length!==0&&this.Bu("posthog.unsetPersonProperties")&&((i=this.featureFlags)==null||i.unsetPersonPropertiesForFlags(s,!0),this.capture("$set",{$unset:s}),this.du=null)}group(t,i,s){var r;if(t&&i){(r=this.persistence)==null||r.syncCookieProperties(),this.Nu();var n=this.getGroups(),o=n[t]!==i;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:w({},n,{[t]:i})}),(o||s)&&this.ju()){var a={$group_type:t,$group_key:i};s&&(a.$group_set=s),this.capture(On,a)}s&&this.setGroupPropertiesForFlags({[t]:s}),o&&!s&&this.reloadFeatureFlags()}else S.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i){var s;i===void 0&&(i=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t){var i;t===void 0&&(t=!0),(i=this.featureFlags)==null||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i){var s;i===void 0&&(i=!0),this.Bu("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;(i=this.featureFlags)==null||i.resetGroupPropertiesForFlags(t)}reset(t){var i=Te(t)?t:t?.resetDeviceID,s=Te(t)||t==null?void 0:t.bootstrap;this.Uu(i,!1,s)}Uu(t,i,s){var r,n,o,a;if(i===void 0&&(i=!1),S.info("reset"),!this.__loaded)return S.uninitializedWarning("posthog.reset");var l=s?.sessionID;this.config.bootstrap=s||((r=this.cu)==null?void 0:r.bootstrap)||{},(n=this.featureFlags)==null||n.updateConfig==null||n.updateConfig(this.config,this.Fa());var u=this.get_property(Ur),h=this.get_property(Ts),c=this.get_property(Dt);(o=this.sessionRecording)==null||o.flushBeforeIdentityReset();var d=this.is_capturing();this.consent.reset(),i||!d||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var v=(a=this.persistence)==null||a.va==null?void 0:a.va(),p=!1;try{var g,_,m,y,k,x,P,$,N,T,J,F,R;if((g=this.persistence)==null||g.clear(),(_=this.sessionPersistence)==null||_.clear(),this.su.clear(),this.qu(),b(c)||(m=this.persistence)==null||m.register({[Dt]:c}),(y=this.surveys)==null||y.reset(),(k=this.featureFlags)==null||k.reset(),(x=this.conversations)==null||x.reset(),(P=this.logs)==null||P.reset(),($=this.metrics)==null||$.reset(),(N=this.persistence)==null||N.set_property(Ee,ot),(T=this.sessionManager)==null||T.resetSessionId(),this.du=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Is,$device_id:null},"");else{var L=this.config.get_device_id(He());this.register_once({distinct_id:L,$device_id:t?L:u},""),t||b(h)||this.register({[Ts]:h})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),s&&(s.distinctID===void 0||this.Jl()||((R=this.persistence)==null||R.set_property(Ee,s.isIdentifiedID?li:ot),this.register({distinct_id:s.distinctID})),(J=this.featureFlags)==null||J.initialize(),!(b(l)||(F=this.sessionManager)!=null&&F.setBootstrapSessionId(l,!0)))){var I=w({},s);delete I.sessionID,this.config.bootstrap=I}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,p=!0}finally{var M;v&&((M=this.persistence)==null||M.ga==null||M.ga(p))}this.reloadFeatureFlags()}shutdown(t){var i=this;return X(function*(){var s,r,n,o,a,l,u;if(i.__loaded){i.ru=!0,i.xu().dispose(),(s=i.sessionRecording)==null||s.dispose(),(r=i.logs)==null||r.flushLogs("sendBeacon"),(n=i.metrics)==null||n.flush("sendBeacon"),(o=i.pu)==null||o.unload(),(a=i.mu)==null||a.unload();try{var h;(h=i.featureFlags)==null||h.destroy()}catch(c){S.error("Error while destroying feature flags",c)}(l=i.persistence)==null||l.destroy(),(u=i.sessionPersistence)==null||u.destroy()}else S.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var s;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),(s=this.conversations)==null||s.Wu()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(t=this.conversations)==null||t.Vu()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var i=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=i.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i.sessionId);if(t!=null&&t.withTimestamp&&s){var n,o=(n=t.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(t,i){return t===this.get_property("$people_distinct_id")?(S.critical("Attempting to create alias for existing People user - aborting."),-2):this.Bu("posthog.alias")?(b(i)&&(i=this.get_distinct_id()),t!==i?(this.Hu(rs,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(S.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var i=w({},this.config);if(j(t)){var s,r,n,o,a,l,u,h,c,d,v,p,g;K(this.config,co(t));var _=this.tu();(s=this.persistence)==null||s.update_config(this.config,i,_),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new js(w({},this.config,{persistence:"sessionStorage"}),_,!1);var m=this.vu(this.config.debug);Te(m)&&(this.config.debug=m),Te(this.config.debug)&&(this.config.debug?(pe.DEBUG=!0,B.Et()&&B.Ot("ph_debug",!0),S.info("set_config",{config:t,oldConfig:i,newConfig:w({},this.config)})):(pe.DEBUG=!1,B.Et()&&B.Dt("ph_debug"))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.Fa()),(n=this.exceptionObserver)==null||n.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(h=this.heatmaps)==null||h.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((c=this.historyAutocapture)==null||c.startIfEnabledOrStop()),(d=this.exceptionObserver)==null||d.startIfEnabledOrStop(),(v=this.deadClicksAutocapture)==null||v.startIfEnabledOrStop(),(p=this.surveys)==null||p.loadIfEnabled(),this.eu(),(g=this.externalIntegrations)==null||g.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&Jn(this,gi,!1)}}_overrideSDKInfo(t,i){pe.LIB_NAME=t,pe.LIB_VERSION=i}startSessionRecording(t){var i,s,r,n,o,a=t===!0,l={sampling:a||!(t==null||!t.sampling),linked_flag:a||!(t==null||!t.linked_flag),url_trigger:a||!(t==null||!t.url_trigger),event_trigger:a||!(t==null||!t.event_trigger)};Object.values(l).some(Boolean)&&((i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),l.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,i){try{if(!this.exceptions)return;var s=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(w({},s,i))}catch{return}}addExceptionStep(t,i){var s;(s=this.exceptions)==null||s.addExceptionStep(t,i)}captureLog(t){var i;(i=this.logs)==null||i.captureLog(t)}get logger(){var t,i;return(t=(i=this.logs)==null?void 0:i.logger)!==null&&t!==void 0?t:nt.Gu}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,s;return(i=(s=this.toolbar)==null?void 0:s.loadToolbar(t))!==null&&i!==void 0&&i}get_property(t){var i;return(i=this.persistence)==null?void 0:i.props[t]}getSessionProperty(t){var i;return(i=this.sessionPersistence)==null?void 0:i.props[t]}toString(){var t,i=(t=this.config.name)!==null&&t!==void 0?t:ui;return i!==ui&&(i="posthog."+i),i}_isIdentified(){var t,i;return((t=this.persistence)==null?void 0:t.get_property("$user_state"))==="identified"||((i=this.sessionPersistence)==null?void 0:i.get_property("$user_state"))==="identified"}ju(){var t,i;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Oe(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t.__alias)&&((i=this.persistence)==null||(i=i.props)==null||!i.$epp))}Pu(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.ju()||this.Bu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Bu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Bu(t){return this.config.person_profiles==="never"?(S.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Ql(),this.Hu(Wr,!0),!0)}tu(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}eu(){var t,i,s,r,n,o=this.tu();return this.is_capturing()||(t=this.logs)==null||t.Zu(),((i=this.persistence)==null?void 0:i.gi)!==o&&((s=this.persistence)==null||s.set_disabled(o)),((r=this.sessionPersistence)==null?void 0:r.gi)!==o&&((n=this.sessionPersistence)==null||n.set_disabled(o)),o&&(this.su.clear(),this.qu()),o}opt_in_capturing(t){var i,s,r;if(this.config.cookieless_mode!=="always"){if(this.Jl()){var n,o,a,l,u,h;(n=this.sessionRecording)==null||n.dispose({discardBufferedEvents:!0}),this.Uu(!0,!0),(o=this.sessionManager)==null||o.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new oo(this),this.pageViewManager=new Yn(this),this.persistence&&(this.sessionPropsManager=new ro(this,this.sessionManager,this.persistence));var c,d=(l=(u=this.config.__extensionClasses)==null?void 0:u.sessionRecording)!==null&&l!==void 0?l:(h=nt.__defaultExtensionClasses)==null?void 0:h.sessionRecording;d&&(this.sessionRecording=this.Zl(this.sessionRecording,new d(this)),this.Hl&&((c=this.sessionRecording)==null||c.onRemoteConfig==null||c.onRemoteConfig(this.Hl)))}this.consent.optInOut(!0),this.eu(),this.Eu(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((s=this.surveys)==null||s.loadIfEnabled()),(b(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture((r=t?.captureEventName)!==null&&r!==void 0?r:"$opt_in",t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ru()}else S.warn(uo)}opt_out_capturing(){if(this.config.cookieless_mode!=="always"){var t,i,s=this.config.cookieless_mode==="on_reject"?this.sessionRecording:void 0;s?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.Uu(!0,!0),this.consent.optInOut(!1),this.eu(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Is,$device_id:null}),this.Gl(s),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Ru(),this.Eu())}else S.warn(uo)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.eu()}_is_bot(){return _e?ml(_e,this.config.custom_blocked_useragents):void 0}Ru(){E&&(E.visibilityState==="visible"?this.lu||(this.lu=!0,this.capture(Gr,{title:E.title},{send_instantly:!0}),this.uu&&(E.removeEventListener(qt,this.uu),this.uu=null)):this.uu||(this.uu=this.Ru.bind(this),z(E,qt,this.uu)))}debug(t){t===!1?(f?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(f?.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}))}Fa(){var t=this.cu||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(S.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(i,s,r,n,o){var a=s in i&&!D(i[s]),l=r in i&&!D(i[r]);return a?i[s]:!!l&&(o&&o.warn("Config field '"+r+"' is deprecated. Please use '"+s+"' instead. The old field will be removed in a future major version."),i[r])})(t,"advanced_disable_flags","advanced_disable_decide",0,S)}bs(t){var i;if(D(this.config.before_send))return t;var s=Object.keys((i=t.properties)!==null&&i!==void 0?i:{}).filter(Nl),r=C(this.config.before_send)?this.config.before_send:[this.config.before_send],n=t;for(var o of r)try{if(n=o(n),D(n)){var a="Event '"+t.event+"' was rejected in beforeSend function";return Dl(t.event)?S.warn(a+". This can cause unexpected behavior."):S.info(a),null}n.properties&&!Oe(n.properties)||S.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(u){return S.error("Error in beforeSend function for event '"+t.event+"':",u),null}for(var l of s)if(n.properties&&D(n.properties[l]))return S.warn("Event '"+t.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return n}getPageViewId(){var t;return(t=this.pageViewManager.ko)==null?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,s){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(s)})}vu(t){var i=Te(t)&&!t,s=B.Et()&&B.Lt("ph_debug")==="true";return!i&&(!!s||t)}},Pi.__defaultExtensionClasses={},Pi.Gu=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),Pi);(function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Ku(e.prototype[t[i]])})(tn,["identify"]);var Pl=class{constructor(e){this.disabled=e===!1;var t=j(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,i){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Ys="$copy_autocapture",Li=le("[AutoCapture]");function Ks(e,t){return t.length>e?t.slice(0,e)+"...":t}function ec(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Ye(t));return t}function tc(e,t){var i,s,r=t.e,n=t.maskAllElementAttributes,o=t.maskAllText,a=t.elementAttributeIgnoreList,l=t.elementsChainAsString,u=t.disableCaptureUrlHashes;if(!Ye(e))return{props:{}};for(var h=[e],c=new Set([e]),d=e;d.parentNode&&!xe(d,"body")&&1e3>h.length;)if(Yr(d.parentNode)){var v=d.parentNode.host;if(c.has(v))break;c.add(v),h.push(v),d=v}else{if(!Ye(d.parentNode)||c.has(d.parentNode))break;c.add(d.parentNode),h.push(d.parentNode),d=d.parentNode}var p=r.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?h.findIndex(F=>xe(F,"button")||xe(F,"a")):-1;p>0&&(o=o||h.slice(0,p+1).some(F=>!Nt(F)||wi(F)));var g,_,m,y=[],k={},x=!1,P=!1;if(U(h,F=>{var R=Nt(F);if(xe(F,"a")){var L=F.getAttribute("href");x=!!(R&&L&&vi(L))&&(u?ct(L):L)}A(Bt(F),"ph-no-capture")&&(P=!0),y.push((function(I,M,Y,ue,Z){Z===void 0&&(Z=!1);var W=I.tagName.toLowerCase(),ee={tag_name:W};Xr.indexOf(W)>-1&&!Y&&(ee.$el_text=W.toLowerCase()==="a"||W.toLowerCase()==="button"?Ks(1024,Vn(I)):Ks(1024,bi(I)));var fe=Bt(I);fe.length>0&&(ee.classes=fe.filter(function(V){return V!==""})),U(I.attributes,function(V){var ie;if((!wi(I)||["name","id","class","aria-label"].indexOf(V.name)!==-1)&&(ue==null||!ue.includes(V.name))&&!M&&vi(V.value)&&(!q(ie=V.name)||ie.substring(0,10)!=="_ngcontent"&&ie.substring(0,7)!=="_nghost")){var Q=V.value;V.name==="class"&&(Q=Kr(Q).join(" ")),ee["attr__"+V.name]=Ks(1024,V.name==="href"&&Z?ct(Q):Q)}});for(var me=1,ge=1,ye=I;ye=ec(ye);)me++,ye.tagName===I.tagName&&ge++;return ee.nth_child=me,ee.nth_of_type=ge,ee})(F,n,o,a,u)),U((function(I){if(!Nt(I))return{};var M={};return U(I.attributes,function(Y){if(Y.name&&Y.name.indexOf("data-ph-capture-attribute")===0){var ue=Y.name.replace("data-ph-capture-attribute-",""),Z=Y.value;ue&&Z&&vi(Z)&&(M[ue]=Z)}}),M})(F),(I,M)=>{({}).hasOwnProperty.call(k,M)||(k[M]=I)})}),P)return{props:{},explicitNoCapture:P};if(p>0&&(e=h[p],y.splice(0,p)),o||(y[0].$el_text=xe(e,"a")||xe(e,"button")?Vn(e):bi(e)),x){var $,N;y[0].attr__href=x;var T=($=Ut(x))==null?void 0:$.host,J=f==null||(N=f.location)==null?void 0:N.host;T&&J&&T!==J&&(g=x)}return{props:K((_=r.type,{$event_type:_,$ce_version:1}),l?{}:{$elements:y},{$elements_chain:(m=y,C(m)?(function(F){return F.map(R=>{var L,I,M="";if(R.tag_name&&(M+=R.tag_name),R.attr_class)for(var Y of(R.attr_class.sort(),R.attr_class))M+="."+Y.replace(/"/g,"");var ue=w({},R.text?{text:R.text}:{},{"nth-child":(L=R.nth_child)!==null&&L!==void 0?L:0,"nth-of-type":(I=R.nth_of_type)!==null&&I!==void 0?I:0},R.href?{href:R.href}:{},R.attr_id?{attr_id:R.attr_id}:{},R.attributes),Z={};return Vi(ue).sort((W,ee)=>{return(me=ee[0])>(fe=W[0])?-1:fe>me?1:0;var fe,me}).forEach(W=>{var ee=W[1];return Z[Wn(W[0].toString())]=Wn(ee.toString())}),(M+=":")+Vi(Z).map(W=>W[0]+'="'+W[1]+'"').join("")}).join(";")})((function(F){return F.map(R=>{var L,I,M={text:(L=R.$el_text)==null?void 0:L.slice(0,400),tag_name:R.tag_name,href:(I=R.attr__href)==null?void 0:I.slice(0,2048),attr_class:ch(R),attr_id:R.attr__id,nth_child:R.nth_child,nth_of_type:R.nth_of_type,attributes:{}};return Vi(R).filter(Y=>Y[0].indexOf("attr__")===0).forEach(Y=>M.attributes[Y[0]]=Y[1]),M})})(m)):"")},(i=y[0])!=null&&i.$el_text?{$el_text:(s=y[0])==null?void 0:s.$el_text}:{},g&&r.type==="click"?{$external_click_url:g}:{},k),target:e}}var ic=class{zs(){this.Us=void 0,clearTimeout(this.Ws),this.Ws=void 0}Vs(e){var t;if(!Nt(e))return!0;for(var i,s=(t=this.Gs().css_selector_ignorelist)!==null&&t!==void 0?t:Ds,r=new Set,n=e,o=function(){if(r.size>=1e3||r.has(n))return{v:!0};r.add(n);var a=n,l=Bt(a);if(A(l,"ph-no-capture")||A(l,"ph-sensitive")||wi(a)||s.some(h=>$r(a,h)))return{v:!0};var u=n.parentNode;n=Yr(u)?u.host:u&&Ye(u)?u:null};n;)if(i=o())return i.v;return!1}Zs(e){if(this.isEnabled&&e.type!=="pointercancel")if(e.type!=="pointerdown"){var t=this.Us;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this.zs():e.type==="pointerup"&&(t.released=!0,this.Ws=setTimeout(()=>this.zs(),0)))}else{var i;this.zs();var s=di(e);e.isPrimary&&e.button===0&&!e.ctrlKey&&s&&Ye(s)&&(this.Us={target:s,excluded:this.Vs(s),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(i=this.Js)==null?void 0:i.distinctId})}else this.zs()}Qs(e){var t,i=this.Us;this.zs();var s=di(e);if(i!=null&&i.released&&i.target.isConnected&&i.distinctId===((t=this.Js)==null?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(xe(s,"html")||xe(s,"body"))){var r;if(i.excluded)return null;var n=(r=this.Gs().css_selector_ignorelist)!==null&&r!==void 0?r:Ds;return[s,E?.documentElement,E?.body].some(o=>{if(!o)return!1;var a=Bt(o);return A(a,"ph-no-capture")||A(a,"ph-sensitive")||!Nt(o)||wi(o)||n.some(l=>$r(o,l))})?null:i.target}}constructor(e){this.Ks=e,this.name="autocapture",this.Xs=!1,this.Ys=null,this.eo=!1,this.io=!1,this.Rn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.ro=!1,this.Ks.refresh(this.Rn),this.rageclicks=new Pl(this.Rn.rageclick),this.no=null}setup(e){this.so(),this.Js=e;var t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.ro?t.dispose():(this.oo=t,this.startIfEnabled())}dispose(){var e;this.ro||(this.ro=!0,this.Js=void 0,(e=this.oo)==null||e.dispose(),this.oo=void 0,this.ao())}Gs(){return this.Ks.refresh(this.Rn),this.Rn}so(){var e,t;return this.Gs(),this.Rn.url_allowlist=(e=this.Rn.url_allowlist)==null?void 0:e.map(i=>new RegExp(i)),this.Rn.url_ignorelist=(t=this.Rn.url_ignorelist)==null?void 0:t.map(i=>new RegExp(i)),this.Rn}lo(){if(this.isBrowserSupported()){if(f&&E){var e=this.uo=i=>{i=i||f?.event;try{if(i.type==="blur")return void this.zs();if(i.type.indexOf("pointer")===0)return void this.Zs(i);var s=i.type==="click"?this.Qs(i):void 0;if(oe(s))return;this.ho(i,"$autocapture",s)}catch(r){Li.error("Failed to capture event",r)}};if(z(f,"blur",e),z(E,"submit",e,{capture:!0}),z(E,"change",e,{capture:!0}),z(E,"click",e,{capture:!0}),U(["pointerdown","pointermove","pointerup","pointercancel"],i=>{z(E,i,e,{capture:!0})}),this.Gs().capture_copied_text){var t=this.do=i=>{i=i||f?.event;try{this.ho(i,Ys)}catch(s){Li.error("Failed to capture clipboard event",s)}};z(E,"copy",t,{capture:!0}),z(E,"cut",t,{capture:!0}),z(E,"paste",t,{capture:!0})}}}else Li.info("Disabling Automatic Event Collection because this browser is not supported")}ao(){this.zs(),this.uo&&(f?.removeEventListener("blur",this.uo),U(["pointerdown","pointermove","pointerup","pointercancel"],e=>{E?.removeEventListener(e,this.uo,!0)}),E?.removeEventListener("submit",this.uo,!0),E?.removeEventListener("change",this.uo,!0),E?.removeEventListener("click",this.uo,!0),this.uo=void 0),this.do&&(E?.removeEventListener("copy",this.do,!0),E?.removeEventListener("cut",this.do,!0),E?.removeEventListener("paste",this.do,!0),this.do=void 0),this.Xs=!1}startIfEnabled(){this.isEnabled||this.zs(),!this.ro&&this.Js&&this.isEnabled&&!this.Xs&&(this.lo(),this.Xs=!0)}onRemoteConfig(e){if(!this.ro)if(this.eo=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this.io=t.elementsChainAsString);var i,s=t.autocapture_opt_out;Te(s)&&((i=this.Js)==null||i.kv.set(cr,s),this.Ys=s),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this.no=e}getElementSelectors(e,t){var i,s=[];return(i=this.no)==null||i.forEach(r=>{var n;E==null||(n=E.querySelectorAll(r))==null||n.forEach(o=>{e!==o&&t!==o||A(s,r)||s.push(r)})}),s}get isEnabled(){var e,t;if(this.ro)return!1;var i=(e=this.Js)==null?void 0:e.kv.get(cr),s=this.Ys,r=this.Gs();if(!r.remoteRequestsDisabled&&!this.eo)return!1;var n=r.remoteRequestsDisabled&&!this.eo;if(oe(s)&&!Te(i)&&!n)return!1;var o=(t=this.Ys)!==null&&t!==void 0?t:!!i;return!!r.enabled&&!o}ho(e,t,i){if(t===void 0&&(t="$autocapture"),this.isEnabled){var s=i||di(e);Ua(s)&&(s=s.parentNode||null);var r,n=this.so();t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&n.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&Wa(s,n.rageclick)&&this.ho(e,"$rageclick",i);var o=t===Ys,a=o?w({},n,{dom_event_allowlist:void 0}):n;if(s&&(function(m,y,k,x,P,$){var N;if(!f||Zr(m)||k!=null&&k.url_allowlist&&!Nn(k.url_allowlist,$)||k!=null&&k.url_ignorelist&&Nn(k.url_ignorelist,$))return!1;if(k!=null&&k.dom_event_allowlist){var T=k.dom_event_allowlist;if(T&&!T.some(M=>y.type===M))return!1}var J=Ga(m,x),F=J.parentIsUsefulElement,R=J.targetElementList;if(!(function(M,Y){var ue=Y?.element_allowlist;if(b(ue))return!0;var Z,W=function(fe){if(ue.some(me=>fe.tagName.toLowerCase()===me))return{v:!0}};for(var ee of M)if(Z=W(ee))return Z.v;return!1})(R,k)||!Tr(R,k?.css_selector_allowlist)||Tr(R,(N=k?.css_selector_ignorelist)!==null&&N!==void 0?N:Ds))return!1;try{var L=f.getComputedStyle(m);if(L&&L.getPropertyValue("cursor")==="pointer"&&y.type==="click")return!0}catch{}var I=m.tagName.toLowerCase();switch(I){case"html":return!1;case"form":return(P||["submit"]).indexOf(y.type)>=0;case"input":case"select":case"textarea":return(P||["change","click"]).indexOf(y.type)>=0;default:return F?(P||["click"]).indexOf(y.type)>=0:(P||["click"]).indexOf(y.type)>=0&&(Xr.indexOf(I)>-1||m.getAttribute("contenteditable")==="true")}})(s,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,u=tc(s,{e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.io,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),h=u.props;if(u.explicitNoCapture)return!1;var c=this.getElementSelectors(s,u.target);if(c&&c.length>0&&(h.$element_selectors=c),t===Ys){var d=e.type||"clipboard";if(d!=="paste"){var v,p,g=f==null||(v=f.getSelection())==null?void 0:v.toString(),_=Ha(g);if(!_)return!1;h.$selected_content=_,h.$clipboard_text_length=(p=g?.length)!==null&&p!==void 0?p:0}h.$copy_type=d}return(l=this.Js)==null||l.capture(t,h).catch(m=>Li.error("Failed to capture event",m)),!0}}else this.zs()}isBrowserSupported(){return ke(E?.querySelectorAll)}},sc=class{constructor(e){this._instance=e}refresh(e){var t=this._instance.config,i=j(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.Fa(),e.url_allowlist=i?.url_allowlist,e.url_ignorelist=i?.url_ignorelist,e.dom_event_allowlist=i?.dom_event_allowlist,e.element_allowlist=i?.element_allowlist,e.css_selector_allowlist=i?.css_selector_allowlist,e.css_selector_ignorelist=i?.css_selector_ignorelist,e.element_attribute_ignorelist=i?.element_attribute_ignorelist,e.capture_copied_text=i?.capture_copied_text}},oi=le("[ExceptionAutocapture]"),vo=()=>{},po=e=>{var t;if(ke(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function Rl(e,t,i){try{if(!(t in e))return vo;var s={next:e[t]},r=i(function(){for(var n=arguments.length,o=new Array(n),a=0;n>a;a++)o[a]=arguments[a];return s.next.apply(this,o)});return ke(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=r,()=>{if(e[t]!==r)for(var n=e[t],o=po(n);o;){if(o.next===r)return void(o.next=s.next);o=po(n=o.next)}else e[t]=s.next}}catch{return vo}}var rc=le("[TracingHeaders]"),ft=le("[Web Vitals]"),fo=9e5,go=["CLS","FCP","INP","LCP"],nc=["INP","LCP"],oc=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Di="disabled",_o="lazy_loading",Xe=le("[SessionRecording]"),ac=le("[Heatmaps]");function Xs(e){return j(e)&&"clientX"in e&&"clientY"in e&&ae(e.clientX)&&ae(e.clientY)}var Ni=le("[Product Tours]"),Zs=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(zr))},ze=le("[SiteApps]"),mo="Error while initializing PostHog app with config id ",$l=(e,t)=>e!=null&&e.then?e.then(t):t(e),It="SDK is not enabled or survey functionality is not yet loaded",yo="Disabled. Not loading surveys.",lc=class{constructor(e,t){this.Ks=e,this.Ju=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Qu=!1,this.Ku=[],this.Xu=null,this.Yu=null,this.ro=!1,this.th=new Set,this.onRemoteConfig=i=>{if(!this.ro&&!this.Rn.disableSurveys){if(!i.ok)return H.warn("Remote config unavailable. Not loading surveys.");var s=i.config.surveys;if(D(s))return H.warn("Flags not loaded yet. Not loading surveys.");this.eh=Te(s)?s:s.length>0,H.info("flags response received, isSurveysEnabled: "+this.eh),this.loadIfEnabled()}}}setup(e){if(!this.ro)return this.ih=e,$l(e.kv.initialize(),()=>{if(this.ih===e&&!this.ro){this.ih=void 0,this.Js=e;var t=e.onRemoteConfig(this.onRemoteConfig);this.ro?t.dispose():(this.oo=t,this.loadIfEnabled())}})}dispose(){var e,t,i;this.ro||(this.ro=!0,this.ih=void 0,this.Js=void 0,(e=this.oo)==null||e.dispose(),this.oo=void 0,(t=this._surveyEventReceiver)==null||t.dispose(),this._surveyEventReceiver=null,(i=this._surveyManager)==null||i.dispose==null||i.dispose(),this._surveyManager=null,this.Ku=[],this.Xu=null,this.th.forEach(s=>clearTimeout(s)),this.th.clear())}get Rn(){return this.Ks.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var s=localStorage.key(i);(s!=null&&s.startsWith("seenSurvey_")||s!=null&&s.startsWith("inProgressSurvey_"))&&t.push(s)}t.forEach(r=>localStorage.removeItem(r))}catch{}}loadIfEnabled(){if(!this.ro&&this.Js){var e=this.Rn;if(!this._surveyManager)if(this.Qu)H.info("Already initializing surveys, skipping...");else if(e.disableSurveys)H.info(yo);else if(e.cookielessMode&&this.Ks.isOptedOut())H.info("Not loading surveys in cookieless mode without consent.");else{var t=this.Ks.getExtensions();if(t){if(!b(this.eh)||e.advancedEnableSurveys){var i=this.eh||e.advancedEnableSurveys;this.Qu=!0;try{var s=t.generateSurveys;if(s)return this.rh(s,i),void(this.Qu=!1);var r=t.loadExternalDependency;if(!r)return this.nh(Er),void(this.Qu=!1);r(n=>{try{if(this.ro)return;var o=this.Ks.getExtensions();n||o==null||!o.generateSurveys?this.nh("Could not load surveys script",n):this.rh(o.generateSurveys,i)}finally{this.Qu=!1}})}catch(n){throw this.Qu=!1,this.nh("Error initializing surveys",n),n}}}else H.error("PostHog Extensions not found.")}}}rh(e,t){this.ro||(this._surveyManager=e(t),this._surveyEventReceiver=this.Ks.createEventReceiver(),H.info("Surveys loaded successfully"),this.sh({isLoaded:!0}))}nh(e,t){H.error(e,t),this.sh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Ku.push(e),this._surveyManager&&this.sh({isLoaded:!0}),()=>{this.Ku=this.Ku.filter(t=>t!==e)}}getSurveys(e,t){var i;t===void 0&&(t=!1);var s=(i=this.Js)!==null&&i!==void 0?i:this.Ju;if(s&&!this.ro){if(this.Rn.disableSurveys)return H.info(yo),e([]);var r=s.kv.get(mr);if(r&&!t)return e(r,{isLoaded:!0}),void(this.oh()&&this.getSurveys(()=>{},!0));if(this.Xu)this.Xu.then(a=>{this.ro||e(a.surveys,a.context)}).catch(a=>H.error("Error in survey callback",a));else{var n=this.ah("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Rn.requestTimeoutMs}).then(a=>{try{return this.uh(s,a)}catch(l){return H.error("Error processing surveys response",l),this.uh(s,{statusCode:0,error:l})}},a=>this.uh(s,{statusCode:0,error:a}));this.Xu=n;var o=()=>{this.Xu===n&&(this.Xu=null)};n.then(a=>{o(),this.ro||e(a.surveys,a.context)},o).catch(a=>H.error("Error in survey callback",a))}}}ah(e,t){var i=this.Js;return i?i.sendRequest(e,t):new Promise(s=>s({statusCode:0,error:new Error(It)}))}uh(e,t){var i;if(this.ro)return{surveys:[],context:{isLoaded:!1,error:It}};var s=t.statusCode;if(s!==200||!t.json){var r="Surveys API could not be loaded, status: "+s;return s!==0?H.error(r):t.error||H.warn(r),this.Yu=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Yu=null;var n=t.json.surveys||[],o=n.filter(a=>(function(l){return!(!l.start_date||l.end_date)})(a)&&(bl(a)||(function(l){var u;return!((u=l.conditions)==null||(u=u.actions)==null||(u=u.values)==null||!u.length)})(a)));return o.length>0&&((i=this._surveyEventReceiver)==null||i.register(o)),e.kv.set({[mr]:n,[ns]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}oh(){return this.hh()&&!this.Xu&&!this.dh()}hh(){var e,t,i=(e=(t=this.Js)!==null&&t!==void 0?t:this.Ju)==null?void 0:e.kv.get(ns);return ae(i)&&Date.now()-i>3e5}dh(){return ae(this.Yu)&&3e5>Date.now()-this.Yu}markSurveyAsSeen(e,t){var i;xl({id:e,current_iteration:(i=t?.iteration)!==null&&i!==void 0?i:null});try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}sh(e){for(var t of this.Ku)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){H.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!D(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);H.warn("init was not called")}fh(e){var t=null;return this.getSurveys(i=>{var s;t=(s=i.find(r=>r.id===e))!==null&&s!==void 0?s:null}),t}ph(e){if(D(this._surveyManager))return{eligible:!1,reason:It};var t=typeof e=="string"?this.fh(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}gh(e){if(D(this._surveyManager))return{eligible:!1,reason:It};var t=typeof e=="string"?this.fh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(D(this._surveyManager))return H.warn("init was not called"),{visible:!1,disabledReason:It};var t=this.gh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return D(this._surveyManager)?(H.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:It})):new Promise(i=>{this.getSurveys(s=>{var r,n=(r=s.find(a=>a.id===e))!==null&&r!==void 0?r:null;if(n){var o=this.gh(n);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s;if(D(this._surveyManager))H.warn("init was not called");else{var r=typeof e=="string"?this.fh(e):e;if(r!=null&&r.id)if(Bh.includes(r.type)){var n=E?.querySelector(t);if(n)if((s=r.appearance)!=null&&s.surveyPopupDelaySeconds){H.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var a,l;this.th.delete(o),this.ro||(H.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(r,n,i),H.info("Survey "+r.id+" rendered"))},1e3*r.appearance.surveyPopupDelaySeconds);this.th.add(o)}else this._surveyManager.renderSurvey(r,n,i);else H.warn("Survey element not found")}else H.warn("Surveys of type "+r.type+" cannot be rendered in the app");else H.warn("Survey not found")}}displaySurvey(e,t){var i;if(D(this._surveyManager))H.warn("init was not called");else{var s=this.fh(e);if(s){var r=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=w({},s,{appearance:w({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Fr.Popover&&t.initialResponses&&H.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var n=this.ph(s);if(!n.eligible)return void H.warn("Survey is not eligible to be displayed: ",n.reason)}t.displayType!==Fr.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}else H.warn("Survey not found")}}cancelPendingSurvey(e){D(this._surveyManager)?H.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload==null||e.handlePageUnload()}};function Ot(e,t,i){if(D(e))return!1;switch(i){case"exact":return e===t;case"contains":var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var uc=class{constructor(e){this._instance=e,this.mh=new Set,this.yh=new Set,this.bh=new ds,this._h=(t,i)=>this.wh(t,i)&&this.kh(t,i)&&this.Sh(t,i)&&this.xh(t,i),this.wh=(t,i)=>i==null||!i.event||t?.event===i?.event}init(){var e,t;b((e=this._instance)==null?void 0:e._addCaptureHook)||(this.Ch=(t=this._instance)==null?void 0:t._addCaptureHook((i,s)=>{this.on(i,s)}))}dispose(){var e;(e=this.Ch)==null||e.call(this),this.Ch=void 0,this.bh=new ds}register(e){var t,i;if(!b((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach(r=>{var n;this.mh.add(r),(n=r.steps)==null||n.forEach(o=>{this.yh.add(o?.event||"")})}),(i=this._instance)!=null&&i.autocapture)){var s=new Set;this.mh.forEach(r=>{var n;(n=r.steps)==null||n.forEach(o=>{o!=null&&o.selector&&s.add(o.selector)})}),this._instance.autocapture.setElementSelectors(s)}}replace(e){this.mh.clear(),this.yh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.yh.has(e)||this.yh.has(t.event))&&this.mh.forEach(i=>{this.Th(t,i)&&this.bh.emit("actionCaptured",i.name)})}Mh(e){this.onAction("actionCaptured",t=>e(t))}Th(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this._h(e,i))return!0;return!1}onAction(e,t){return this.bh.on(e,t)}kh(e,t){if(t!=null&&t.url){var i,s=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!s||typeof s!="string"||!Ot(s,t.url,t.url_matching||"contains"))return!1}return!0}Sh(e,t){return!!this.Ih(e,t)&&!!this.Eh(e,t)&&!!this.Rh(e,t)}Ih(e,t){var i;if(t==null||!t.href)return!0;var s=this.Ah(e);if(s.length>0)return s.some(o=>Ot(o.href,t.href,t.href_matching||"exact"));var r,n=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!n&&Ot((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}Eh(e,t){var i;if(t==null||!t.text)return!0;var s=this.Ah(e);if(s.length>0)return s.some(l=>Ot(l.text,t.text,t.text_matching||"exact")||Ot(l.$el_text,t.text,t.text_matching||"exact"));var r,n,o,a=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!a&&(r=(function(l){for(var u,h=[],c=/(?::|")text="(.*?)"/g;!D(u=c.exec(l));)h.includes(u[1])||h.push(u[1]);return h})(a),n=t.text,o=t.text_matching||"exact",r.some(l=>Ot(l,n,o)))}Rh(e,t){var i,s;if(t==null||!t.selector||e!=null&&(i=e.properties)!=null&&(i=i.$element_selectors)!=null&&i.includes(t.selector))return!0;var r=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch{return!1}return!1}Ah(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}xh(e,t){return t==null||!t.properties||t.properties.length===0||El(t.properties.reduce((i,s)=>{var r=C(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return i[s.key]={values:r,operator:s.operator||"exact"},i},{}),e?.properties)}},hc=class{constructor(e){var t;this.Ph=[],this._instance=e,this.Fh=new Map,this.Oh=new Map,this.$h=new Map,this.Dh=(t=this._instance)==null||t.onSessionId==null?void 0:t.onSessionId(i=>this.Lh(i))}Nh(e){return!1}qh(){return null}jh(e){}Bh(){}Hh(e,t){return!!e&&El(e.propertyFilters,t?.properties)}zh(e,t){var i=new Map;return e.forEach(s=>{var r;(r=s.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach(n=>{if(n!=null&&n.name){var o=i.get(n.name)||[];o.push(s.id),i.set(n.name,o)}})}),i}Uh(e,t,i){var s=(i===ii.Activation?this.Fh:this.Oh).get(e),r=[];return this.Wh(n=>{r=n.filter(o=>s?.includes(o.id))}),r.filter(n=>{var o,a=(o=n.conditions)==null||(o=o[i])==null||(o=o.values)==null?void 0:o.find(l=>l.name===e);return this.Hh(a,t)})}register(e){this.Vh(e,!1)}replace(e){this.Vh(e,!0)}Vh(e,t){var i;b((i=this._instance)==null?void 0:i._addCaptureHook)||(this.Gh(e,t),this.Zh(e,t))}Zh(e,t){var i=e.filter(n=>{var o;return(o=n.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length});if(t&&this.$h.clear(),i.length!==0){this.Jh||(this.Jh=new uc(this._instance),this.Jh.init(),this.Jh.Mh(n=>this.onAction(n)));var s=[];i.forEach(n=>{var o;(o=n.conditions)==null||(o=o.actions)==null||o.values.forEach(a=>{if(s.push(a),a.name){var l,u=(l=this.$h.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.$h.set(a.name,u)}})}),t?this.Jh.replace(s):this.Jh.register(s)}else{var r;t&&((r=this.Jh)==null||r.replace([]))}}Qh(e,t){t.forEach((i,s)=>{var r,n=(r=e.get(s))!==null&&r!==void 0?r:[];i.forEach(o=>{n.includes(o)||n.push(o)}),e.set(s,n)})}Gh(e,t){var i,s,r=e.filter(l=>{var u,h;return((u=l.conditions)==null?void 0:u.events)&&((h=l.conditions)==null||(h=h.events)==null||(h=h.values)==null?void 0:h.length)>0}),n=e.filter(l=>{var u,h;return((u=l.conditions)==null?void 0:u.cancelEvents)&&((h=l.conditions)==null||(h=h.cancelEvents)==null||(h=h.values)==null?void 0:h.length)>0}),o=this.zh(e,ii.Activation),a=this.zh(e,ii.Cancellation);t?(this.Fh=o,this.Oh=a):(this.Qh(this.Fh,o),this.Qh(this.Oh,a)),(r.length!==0||n.length!==0)&&((i=this.Ch)!==null&&i!==void 0||(this.Ch=(s=this._instance)==null?void 0:s._addCaptureHook((l,u)=>{this.onEvent(l,u)})))}onEvent(e,t){var i,s,r=this.Kh(),n=(t==null||(i=t.properties)==null?void 0:i.$survey_id)||(t==null||(s=t.properties)==null?void 0:s.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Xh(e,n);if(o==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this.Yh([n]);if(o==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this.td(n),void this.ed([n])}if(this.Oh.has(e)){var a=this.Uh(e,t,ii.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(u=>u.id)}),this.Yh(a.map(u=>u.id)),a.forEach(u=>this.rd(u.id)))}if(this.Fh.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.Fh.get(e)});var l=this.Uh(e,t,ii.Activation);this.nd(l.map(u=>u.id))}}onAction(e){this.$h.has(e)&&this.nd(this.$h.get(e)||[])}nd(e){var t;if(e.length!==0){var i=!((t=this._instance)==null||t.get_session_id==null||!t.get_session_id()),s=[];for(var r of e)i&&this.Nh(r)?this.td(r)&&this.sd(r):s.push(r);s.length>0&&(this.Ph=[...new Set([...this.Ph,...s])]),this.Kh().info("updating activated items",{activatedItems:this.getActivatedIds()})}}td(e){this.Ph=this.Ph.filter(i=>i!==e);var t=this.od();return!t.includes(e)&&(this.ad([...t,e]),this.ld(),!0)}Yh(e){var t=new Set(e);this.Ph=this.Ph.filter(r=>!t.has(r));var i=this.ud(),s=i.filter(r=>!t.has(r));s.length!==i.length&&(this.ad(s),s.length===0&&this.hd()),this.ed(e)}dd(){var e,t=this.qh();if(!t)return{};var i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i&&typeof i=="object"?i:{}}sd(e){if(this.qh()){var t=this.dd();this.jh(w({},t,{[e]:Date.now()}))}}ed(e){if(this.qh()){var t=this.dd(),i={},s=!1;for(var r of Object.entries(t)){var n=r[0],o=r[1];e.includes(n)?s=!0:i[n]=o}s&&(Oe(i)?this.Bh():this.jh(i))}}vd(){this.qh()&&this.Bh()}getActivationTimestamp(e){if(this.od().includes(e)){var t=this.dd()[e];return ae(t)?t:void 0}}ud(){var e,t=this.fd();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}od(){var e,t,i=this.ud();if(i.length===0)return[];var s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.pd()],r=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();return r&&s===r?i:[]}ld(){var e,t=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();t&&this.gd(t)}hd(){this.md()}Lh(e){var t,i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.pd()];if(i&&i!==e){var s=this.ud(),r=this.dd();s.length>0&&(this.ad([]),s.filter(n=>ae(r[n])).forEach(n=>this.rd(n))),this.hd(),this.vd()}}getActivatedIds(){return[...new Set([...this.od(),...this.Ph])].filter(e=>!this.yd(e))}dispose(){var e,t,i;(e=this.Dh)==null||e.call(this),this.Dh=void 0,(t=this.Ch)==null||t.call(this),this.Ch=void 0,(i=this.Jh)==null||i.dispose(),this.Jh=void 0}reset(){this.Ph=[],this.ud().length>0&&this.ad([]),this.hd(),this.vd()}getEventToItemsMap(){return this.Fh}bd(){return this.Jh}},cc=class extends hc{constructor(e){super(e)}fd(){return yr}pd(){return Ui}qh(){return Hi}jh(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Hi]:e})}Bh(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Hi)}Nh(e){var t,i;this.Wh(r=>{i=r.find(n=>n.id===e)});var s=(t=i)==null||(t=t.appearance)==null?void 0:t.surveyPopupDelaySeconds;return ae(s)&&s>0}_d(){return tt.SHOWN}Wh(e){var t;(t=this._instance)==null||t.getSurveys(e)}rd(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Kh(){return H}ad(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[yr]:e})}gd(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Ui]:e})}md(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Ui)}yd(){return!1}Xh(e,t){var i;return this.Wh(s=>{i=s.find(r=>r.id===t)}),!i||(function(s){var r;return bl(s)&&!((r=s.conditions)==null||(r=r.events)==null||!r.repeatedActivation)||s.schedule==="always"})(i)?e===tt.SHOWN?"consume":"ignore":e===tt.SHOWN?"persist":e===tt.DISMISSED||e===tt.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},dc=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);var t={};for(var i of e){var s=this._instance.get_property(i);b(s)||(t[i]=s)}return t}set(e,t){this._instance.register(typeof e=="string"?{[e]:t}:e)}remove(e){typeof e!="string"?e.forEach(t=>this._instance.unregister(t)):this._instance.unregister(e)}},vc=class{constructor(e){this._instance=e}get(){var 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()}getExtensions(){var e=O?.__PosthogExtensions__;if(e){var t=e.generateSurveys,i=e.loadExternalDependency;return{generateSurveys:t?s=>t(this._instance,s):void 0,loadExternalDependency:i?s=>i(this._instance,"surveys",s):void 0}}}createEventReceiver(){return new cc(this._instance)}},pc=f!=null&&f.location?ls(f.location.hash,"__posthog")||ls(location.hash,"state"):null,bo="_postHogToolbarParams",wo=le("[Toolbar]"),Eo=le("[FeatureFlags]"),fc=class{constructor(e,t){t===void 0&&(t=!1),this.wd=!1,this.update(e,t)}update(e,t){this.kd=((i,s)=>{var r,n,o,a,l;return{bootstrap:{featureFlags:(r=i.bootstrap)==null?void 0:r.featureFlags,featureFlagPayloads:(n=i.bootstrap)==null?void 0:n.featureFlagPayloads},remoteRequestsDisabled:s,featureFlagsDisabled:!!i.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!i.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!i.advanced_feature_flags_dedup_per_session,cacheTtlMs:i.feature_flag_cache_ttl_ms,refreshIntervalMs:(o=i.remote_config_refresh_interval_ms)!==null&&o!==void 0?o:3e5,requestTimeoutMs:i.feature_flag_request_timeout_ms,compression:i.disable_compression?void 0:"best-available",evaluationContexts:(a=(l=i.evaluation_contexts)!==null&&l!==void 0?l:i.evaluation_environments)!==null&&a!==void 0?a:[],flagKeys:C(i.flag_keys)?i.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.wd||(Eo.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.wd=!0),b(e.flag_keys)||C(e.flag_keys)||Eo.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.kd}},xo=le("[FeatureFlags]"),gt=le("[FeatureFlags]",{debugEnabled:!0}),Qs=`" failed. Feature flags didn't load in time.`,ko="connection_error",So=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Po=e=>{var t={};for(var i of Vi(e||{})){var s=i[1];s&&(t[i[0]]=s)}return t},Ro=e=>ki(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),qe=le("[Error tracking]"),Lr="webkit-masked-url:",gc=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],_c=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Lr],mc=["__firefox__","__gCrWeb"],$o="Refusing to render web experiment since the viewer is a likely bot",yc={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>vs(t,e),not_regex:(e,t)=>!vs(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},De=le("[Conversations]"),_t="Conversations not available yet.";function To(e,t){var i,s,r,n,o,a,l,u=(i=e?.flushIntervalMs)!==null&&i!==void 0?i:3e3,h=(s=e?.maxBufferSize)!==null&&s!==void 0?s:100,c=t!=null&&t.consoleCapture?void 0:(r=e?.maxLogsPerInterval)!==null&&r!==void 0?r:1e3,d=b(c)?Math.max(h,2048):Math.max(h,c),v=w({},(function(){var p="",g="";try{var _=_e?.userAgent;if(_){var m=ca(_);p=m[0],g=m[1]}}catch{}return(function(y,k){var x=(function(P){if(P)return{}.hasOwnProperty.call(Rn,P)?Rn[P]:P})(y);return w({},x?{"os.name":x}:{},k?{"os.version":k}:{})})(p,g)})(),e?.resourceAttributes);return{serviceName:(n=(o=v?.["service.name"])!==null&&o!==void 0?o:e?.serviceName)!==null&&n!==void 0?n:t?.serviceNameDefault,serviceVersion:(a=v?.["service.version"])!==null&&a!==void 0?a:e?.serviceVersion,environment:(l=v?.["deployment.environment"])!==null&&l!==void 0?l:e?.environment,resourceAttributes:v,beforeSend:e?.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:c,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var bc=["debug","log","warn","error","info"],Fo="console",Tl="__posthogHandledLogsRequestError",er=(e,t)=>{var i=e instanceof Error?e:new Error(t);return i[Tl]=!0,i},Io=e=>!!e&&typeof e=="object"&&e[Tl]===!0,ys={featureFlags:class{constructor(e){this.name="featureFlags",this.Sd=!1,this.featureFlagEventHandlers=[],this.A=xo,this.xd={},this.Cd={},this.Td=[],this.Md=!1,this.Id=!1,this.Ed=0,this.Rd=!1,this.Ad=!1,this.Pd=!1,this.Fd=!1,this.Od=0,this.nr=()=>{var t=this.$d();this.Od=0,t&&this.reloadFeatureFlags()},this.Dd=()=>{var t,i=this.Ld;b(i)||this.Rn.remoteRequestsDisabled||!E||E.visibilityState==="hidden"||Date.now()-((t=this.Nd)!==null&&t!==void 0?t:0)<i||(this.reloadFeatureFlags(),this.qd())},this.ar=()=>{E?.visibilityState==="visible"&&this.Dd()},"get"in e?this.Ks=e:(this._instance=e,this.jd=new fc(e.config,e.Fa()),this.Ks=this.jd)}updateConfig(e,t){var i;(i=this.jd)==null||i.update(e,t),this.Js&&this.Bd()}setup(e){return this.ih=e,this.A=e.logger.createLogger("[FeatureFlags]"),$l(e.kv.initialize(),()=>{this.ih===e&&(this.ih=void 0,this.Js=e,this.Hd(e))})}Hd(e){var t;if(this.Js===e)return f&&z(f,"online",this.nr),this.Bd(),this.zd=e.registerDynamicEventProperties(()=>this.Ud()?this.xd:this.Cd),this.Wd=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.onCrossTabFeatureFlagChange(()=>{this.Vd(),this.Gd(),this.Zd()}),this.Gd(),this.initialize()}Bd(){var e=this.Rn.refreshIntervalMs,t=!this.Rn.remoteRequestsDisabled&&E&&!b(e)&&e>0?e:void 0;t!==this.Ld&&(this.Jd(),b(t)||(this.Ld=t,this.qd(),E!=null&&E.addEventListener&&z(E,qt,this.ar)))}qd(){b(this.Ld)||(b(this.Qd)||clearInterval(this.Qd),this.Nd=Date.now(),this.Qd=setInterval(this.Dd,this.Ld))}Jd(){b(this.Qd)||(clearInterval(this.Qd),this.Qd=void 0,E==null||E.removeEventListener==null||E.removeEventListener(qt,this.ar)),this.Ld=void 0,this.Nd=void 0}destroy(){this.Kd()}dispose(){this.Kd()}Kd(){var e,t;this.Jd(),this.Ed++,this.Ad=!1,this.ih=void 0,this.Js&&(this.Xd(),(e=this.zd)==null||e.dispose(),this.zd=void 0,(t=this.Wd)==null||t.call(this),this.Wd=void 0,this.Td=[],f?.removeEventListener("online",this.nr),this.Js=void 0)}get Rn(){return this.Ks.get()}Yd(e){var t;return this.tv&&e in this.tv?this.tv[e]:(t=this.Js)==null?void 0:t.kv.get(e)}Vd(){return!!this.tv&&(this.tv=void 0,!0)}ev(){var e;return!b((e=this.Js)==null?void 0:e.kv.get("$enabled_feature_flags"))&&this.Vd()}Ot(e){this.iv(()=>{var t;return(t=this.Js)==null?void 0:t.kv.set(e)})}rv(e,t,i){var s;if((s=this._instance)!=null&&s.persistence&&e.$enabled_feature_flags){var r=this.Yd("$enabled_feature_flags")||{},n=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(y=>{var k=y[1];return!(k!=null&&k.failed)}).map(y=>y[0]):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,u=l?a:i&&!C(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),h=this.Yd("$feature_flag_payloads")||{},c=e.$feature_flag_payloads||{},d=l||i?u:Array.from(new Set([...Object.keys(h),...Object.keys(c)])),v=!l&&!i,p=!!v||u,g=!!v||d,_={[Ge]:p,[Ne]:p,[at]:g};for(var m of(e.$feature_flag_details&&(_[wt]=p),[Et,ht,ci]))b(e[m])||(_[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(_)}}Dt(e){this.iv(()=>{var t;return(t=this.Js)==null?void 0:t.kv.remove(e)})}iv(e){try{e()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Gd(){var e={};for(var t of[Ge,at,Et,Ve]){var i=this.Yd(t);b(i)||(e[t]=i)}this.xd=e;var s=w({},e),r=this.Yd(Ne);if(r)for(var n of Object.entries(r))s["$feature/"+n[0]]=n[1];this.Cd=s}Ud(){var e=this.Rn.cacheTtlMs;if(!e||0>=e)return!1;var t=this.Yd(ht);return typeof t!="number"||Date.now()-t>e}nv(){return!!this.Ud()&&(this.Fd||this.Id||(this.Fd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}sv(){var e=this.Rn.evaluationContexts;return e!=null&&e.length?e.filter(t=>{var i=t&&typeof t=="string"&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}ov(){var e=this.Rn.flagKeys;if(!b(e))return e.filter(t=>{var i=t&&typeof t=="string"&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var e,t,i=this.Rn,s=(e=(t=i.bootstrap)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(s).length){var r,n,o=(r=(n=i.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(s).filter(u=>!b(s[u])).reduce((u,h)=>(u[h]=s[h],u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,h)=>(u[h]=o[h],u),{});return this.av({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,i){var s,r,n=i!=null&&i.merge&&(s=this.Yd("$enabled_feature_flags"))!==null&&s!==void 0?s:{},o=i!=null&&i.merge&&(r=this.Yd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=w({},n,e),l=w({},o,t),u={};for(var h of Object.entries(a)){var c=h[0],d=h[1];u[c]={key:c,enabled:xn(d),variant:kn(d),reason:void 0,metadata:b(l?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}}}this.av({flags:u})}get hasLoadedFlags(){return this.Md}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Yd(wt),t=this.Yd(Ve),i=this.Yd(yt);if(!i&&!t)return e||{};var s=K({},e||{});for(var r of[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])]){var n,o,a=s[r],l=t?.[r],u=b(l)?(n=a?.enabled)!==null&&n!==void 0&&n:!!l,h=b(l)?a?.variant:typeof l=="string"?l:void 0,c=i?.[r],d=w({},a,{enabled:u,variant:u?h??a?.variant:void 0});u!==a?.enabled&&(d.original_enabled=a?.enabled),h!==a?.variant&&(d.original_variant=a?.variant),c&&(d.metadata=w({},a?.metadata,{payload:c,original_payload:a==null||(o=a.metadata)==null?void 0:o.payload})),s[r]=d}return this.Sd||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this.Sd=!0),s}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{var s=e[i];return{key:i,enabled:xn(s),variant:kn(s),payload:En(t[i])}})}getFlagVariants(){var e=this.Yd(Ne),t=this.Yd(Ve);if(!t)return e||{};for(var i=K({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this.Sd||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.Sd=!0),i}getFlagPayloads(){var e=this.Yd(at),t=this.Yd(yt);if(!t)return e||{};for(var i=K({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this.Sd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.Sd=!0),i}reloadFeatureFlags(){this.Rd||this.Rn.featureFlagsDisabled||this.$d()||(this.Id&&(this.Ad=!0),this.lv||(this.Td.slice().forEach(e=>{try{e()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.lv=setTimeout(()=>{this.uv()},5)))}Xd(){clearTimeout(this.lv),this.lv=void 0}onReloading(e){return this.Td.push(e),()=>{this.Td=this.Td.filter(t=>t!==e)}}ensureFlagsLoaded(){this.Md||this.Id||this.lv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Rd=e}resetFlagCallReported(){this.Dt(ut)}uv(e){this.Xd();var t=this.Js;if(t&&!this.Rn.remoteRequestsDisabled&&!this.$d())if(this.Id)this.Ad=!0;else{var i={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:w({},t.initialPersonProperties,this.Yd("$stored_person_properties")||{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Yd(lt),timezone:nl()};b(t.deviceId)||(i.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Rn.featureFlagsDisabled)&&(i.disable_flags=!0);var s=this.sv();s.length&&(i.evaluation_contexts=s);var r=this.ov();b(r)||(i.flag_keys=r);var n=this.Rn.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.Ed;this.Id=!0;var l=()=>{this.Ad&&(this.Ad=!1,this.uv())},u=h=>{this.Id=!1,a===this.Ed&&(this.Ot({[yi]:[ko]}),this.A.error("Feature flag request failed",h),this.ev()&&this.Zd(!0)),l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:i,compression:this.Rn.compression,sentAt:"body",timeoutMs:this.Rn.requestTimeoutMs}).then(h=>{var c,d,v=(c=h.json)!==null&&c!==void 0?c:{},p=h.statusCode!==200;if(this.Id=!1,a===this.Ed){if(this.hv(h.statusCode),p||this.Ad||(this.$anon_distinct_id=void 0),!i.disable_flags||this.Ad){this.Pd=!p;var g=[];h.error?g.push(h.error instanceof Error&&h.error.name==="AbortError"?"timeout":h.error instanceof Error?ko:"unknown_error"):h.statusCode!==200&&g.push("api_error_"+h.statusCode),v.errorsWhileComputingFlags&&g.push("errors_while_computing_flags");var _=!((d=v.quotaLimited)==null||!d.includes("feature_flags"));_&&g.push("quota_limited"),this.Ot({[yi]:g}),_?this.A.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."):i.disable_flags||this.av(v,p,{partialResponse:n}),l()}}else l()}).catch(u)}catch(h){u(h)}}}$d(){return Xa(this.Od,3)}hv(e){this.Od=Za(e,this.Od,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t){var i;if(t===void 0&&(t={}),!t.fresh||this.Pd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.nv()){var s=this.getFeatureFlagResult(e,t);return(i=s?.variant)!==null&&i!==void 0?i:s?.enabled}}else this.A.warn('getFeatureFlag for key "'+e+Qs)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t;return(t=this.getFeatureFlagResult(e,{send_event:!1}))==null?void 0:t.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.Pd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.nv()){var i,s=this.getFlagVariants(),r=e in s,n=s[e],o=this.getFlagPayloads()[e],a=String(n),l=this.Yd("$feature_flag_request_id")||void 0,u=this.Yd("$feature_flag_evaluated_at")||void 0,h=this.Yd("$flag_call_reported")||{};if(this.Rn.deduplicateCallsPerSession){var c,d=(c=this.Js)==null?void 0:c.session.sessionId,v=this.Yd(ai);d&&d!==v&&(h={},i=d)}if(t.send_event||!("send_event"in t))if(e in h&&h[e].includes(a))i&&this.Ot({[ut]:h,[ai]:i});else{var p,g,_,m,y,k,x,P,$,N,T,J,F;C(h[e])?h[e].push(a):h[e]=[a],this.Ot(w({[ut]:h},i?{[ai]:i}:{}));var R=this.getFeatureFlagDetails(e),L=[...(p=this.Yd("$feature_flag_errors"))!==null&&p!==void 0?p:[]];b(n)&&L.push("flag_missing");var I={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:o??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(g=(_=this.Rn.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[e])!==null&&g!==void 0?g:null,$feature_flag_bootstrapped_payload:(m=(y=this.Rn.bootstrap)==null||(y=y.featureFlagPayloads)==null?void 0:y[e])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.Pd};b(R==null||(k=R.metadata)==null?void 0:k.has_experiment)||(I.$feature_flag_has_experiment=R.metadata.has_experiment),b(R==null||(x=R.metadata)==null?void 0:x.version)||(I.$feature_flag_version=R.metadata.version);var M=(P=R==null||($=R.reason)==null?void 0:$.description)!==null&&P!==void 0?P:R==null||(N=R.reason)==null?void 0:N.code;M&&(I.$feature_flag_reason=M),R!=null&&(T=R.metadata)!=null&&T.id&&(I.$feature_flag_id=R.metadata.id),b(R?.original_variant)&&b(R?.original_enabled)||(I.$feature_flag_original_response=b(R.original_variant)?R.original_enabled:R.original_variant),R!=null&&(J=R.metadata)!=null&&J.original_payload&&(I.$feature_flag_original_payload=R==null||(F=R.metadata)==null?void 0:F.original_payload),L.length&&(I.$feature_flag_error=L.join(",")),this.dv(I)}else i&&this.Ot({[ut]:h,[ai]:i});if(r)return{key:e,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:En(o)}}}else this.A.warn('getFeatureFlagResult for key "'+e+Qs)}dv(e){try{var t;(t=this.Js)==null||t.capture("$feature_flag_called",e).catch(i=>{this.A.error("Failed to capture feature flag call",i)})}catch(i){this.A.error("Failed to capture feature flag call",i)}}getRemoteConfigPayload(e,t){this.vv(e,t)}vv(e,t){var i=this;return X(function*(){var s=i.Js;if(s){var r={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},n=i.sv();n.length&&(r.evaluation_contexts=n);var o,a=i.ov();b(a)||(r.flag_keys=a);try{var l;o=((l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:i.Rn.compression,sentAt:"body",timeoutMs:i.Rn.requestTimeoutMs})).json)==null||(l=l.featureFlagPayloads)==null?void 0:l[e])||void 0}catch(u){return void i.A.error("Remote config feature flag request failed",u)}try{t(o)}catch(u){i.A.error("Remote config feature flag callback failed",u)}}})()}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.Pd)return t.defaultValue;if(!(this.Md||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+e+Qs),t.defaultValue;var i=this.getFeatureFlag(e,t);return b(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this.av(e,t,i)}av(e,t,i){if(this.Js){this.Md=!0;var s=(function(n,o,a,l,u,h){o===void 0&&(o={}),a===void 0&&(a={}),l===void 0&&(l={}),h===void 0&&(h=xo);var c=((F,R)=>{var L=F.flags;return L?w({},F,{featureFlags:Object.fromEntries(Object.keys(L).map(I=>{var M;return[I,(M=L[I].variant)!==null&&M!==void 0?M:L[I].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(L).filter(I=>L[I].enabled).filter(I=>{var M;return!b((M=L[I].metadata)==null?void 0:M.payload)}).map(I=>{var M;return[I,(M=L[I].metadata)==null?void 0:M.payload]}))}):(F.featureFlags&&R.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),F)})(n,h),d=c.flags,v=c.featureFlags,p=c.featureFlagPayloads;if(v){var g=n.requestId,_=n.evaluatedAt;if(C(v)){h.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(v)for(var y=0;v.length>y;y++)m[v[y]]=!0;return{[Ge]:v,[Ne]:m,[ci]:!1}}var k=v,x=p,P=d;if(u!=null&&u.partialResponse){var $=Object.keys(k),N=x||{};k=w({},o,k),x=w({},a,N),$.forEach(F=>{var R;F in N||(R=x)==null||delete R[F]}),P=w({},l,P)}else if(n.errorsWhileComputingFlags)if(d){var T=new Set(Object.keys(d).filter(F=>{var R;return!((R=d[F])!=null&&R.failed)}));k=w({},o,Object.fromEntries(Object.entries(k).filter(F=>T.has(F[0]))));var J=Object.fromEntries(Object.entries(x||{}).filter(F=>T.has(F[0])));x=w({},a,J),T.forEach(F=>{var R;F in J||(R=x)==null||delete R[F]}),P=w({},l,Object.fromEntries(Object.entries(P||{}).filter(F=>T.has(F[0]))))}else k=w({},o,k),x=w({},a,x),P=w({},l,P);return w({[Ge]:Object.keys(Po(k)),[Ne]:k||{},[at]:x||{},[wt]:P||{},[ci]:n.minimalFlagCalledEvents===!0},g?{[Et]:g}:{},_?{[ht]:_}:{})}})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this.A);if(s)if(i?.persist===!1){var r=!b(this.Js.kv.get(Ne));this.tv=s,r||this.Ot(s)}else this.Vd(),this.rv(s,e,!(i==null||!i.partialResponse)),this.Ot(s);else t&&this.ev();t||(this.Fd=!1),this.Zd(t)}}override(e,t){t===void 0&&(t=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.fv(e)}fv(e){if(this.Js){if(e===!1)return this.Dt([Ve,yt]),this.Zd(),void gt.info("All overrides cleared");if(C(e))return this.Ot({[Ve]:So(e)}),this.Zd(),void gt.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,i=e;this.Sd=!!((t=i.suppressWarning)!==null&&t!==void 0&&t);var s={},r=i.flags,n=i.payloads;return r&&(s[Ve]=C(r)?So(r):r),n&&(s[yt]=n),Object.keys(s).length&&this.Ot(s),r===!1&&n===!1?this.Dt([Ve,yt]):r===!1?this.Dt(Ve):n===!1&&this.Dt(yt),this.Zd(),r===!1?gt.info("Flag overrides cleared"):r&&gt.info("Flag overrides set",{flags:r}),void(n===!1?gt.info("Payload overrides cleared"):n&&gt.info("Payload overrides set",{payloads:n}))}if(e&&typeof e=="object")return this.Ot({[Ve]:e}),this.Zd(),void gt.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Md){var t=this.pv(),i=t.flags,s=t.flagVariants;try{e(i,s)}catch(r){this.A.error("Error while running feature flags callback",r)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s,r=(this.Yd("$early_access_features")||[]).find(u=>u.flagKey===e),n={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:n};r&&(o.$early_access_feature_name=r.name),i&&(o.$feature_enrollment_stage=i);var a=w({},this.getFlagVariants(),{[e]:t});(s=this._instance)==null||(s=s.persistence)==null||s.markCrossTabFeatureFlagChanges({[Ge]:[e],[Ne]:[e],[et]:Object.keys(n)}),this.Ot({[Ge]:Object.keys(Po(a)),[Ne]:a,[et]:w({},this.Yd("$stored_person_properties")||{},n)}),this.Zd();try{var l;(l=this.Js)==null||l.capture("$feature_enrollment_update",o).catch(u=>{this.A.error("Failed to capture early access feature enrollment",u)})}catch(u){this.A.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(e,t,i){t===void 0&&(t=!1);var s=this.Yd(_r);!s||t?this.gv(e,i):e(s)}gv(e,t){var i=this;return X(function*(){var s=i.Js;if(s){var r,n=t?"&"+t.map(a=>"stage="+a).join("&"):"";try{var o=yield s.sendRequest("/api/early_access_features/?token="+s.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,i.Ot({[_r]:r})}catch(a){return void i.A.error("Early access feature request failed",a)}try{e(r)}catch(a){i.A.error("Early access feature callback failed",a)}}})()}pv(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(i=>t[i]),flagVariants:Object.keys(t).filter(i=>t[i]).reduce((i,s)=>(i[s]=t[s],i),{})}}Zd(e){this.Gd();var t=this.pv(),i=t.flags,s=t.flagVariants;this.featureFlagEventHandlers.forEach(r=>{try{r(i,s,{errorsLoading:e})}catch(n){this.A.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.mv(e,t)}mv(e,t){t===void 0&&(t=!0);var i=this.Yd("$stored_person_properties")||{},s=e?.$set||(e!=null&&e.$set_once?{}:e),r=e?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in i||(n[o]=r[o]));this.Ot({[et]:w({},i,n,s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=w({},this.Yd("$stored_person_properties")||{});e.forEach(s=>{delete i[s]}),this.Ot({[et]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this.Dt(et),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this.Yd("$stored_group_properties")||{},s=w({},i);for(var r of Object.keys(e))s[r]=w({},i[r],e[r]);this.Ot({[lt]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Yd("$stored_group_properties")||{};this.Ot({[lt]:w({},t,{[e]:{}})})}else this.Dt(lt)}reset(){this.Ed++,this.Ad=!1,this.xd={},this.Cd={},this.tv=void 0,this.Md=!1,this.Rd=!1,this.Pd=!1,this.$anon_distinct_id=void 0,this.Xd(),this.Sd=!1,this.Od=0}}},wc={sessionRecording:class{get Rn(){return this._instance.config}get sl(){return this._instance.persistence}get started(){var e;return!((e=this.yv)==null||!e.isStarted)}get status(){var e,t;return this.bv==="awaiting_config"||this.bv==="missing_config"?this.bv:(e=(t=this.yv)==null?void 0:t.status)!==null&&e!==void 0?e:this.bv}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.bv=Di,this._v=void 0,this.wv=!1,this.Ke=(()=>{var t;if(E==null||!E.visibilityState||E.visibilityState==="visible")return!0;var i=f==null||(t=f.performance)==null||t.getEntriesByType==null?void 0:t.getEntriesByType("visibility-state");return!(i!=null&&i.length)||i.some(s=>s.name==="visible")})(),this.ar=()=>{var t;E?.visibilityState==="visible"&&(this.Ke=!0,(t=this.yv)==null||t.setDocumentWasEverVisible==null||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Xe.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Rn.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');E!=null&&E.addEventListener&&z(E,"visibilitychange",this.ar)}initialize(){this.startIfEnabledOrStop()}dispose(e){var t=(e===void 0?{}:e).discardBufferedEvents,i=t!==void 0&&t;this.wv=!0,E==null||E.removeEventListener==null||E.removeEventListener("visibilitychange",this.ar),i?this.Sv(!0):this.stopRecording()}get xv(){var e,t=!((e=this._instance.get_property(Dt))==null||!e.enabled),i=!this.Rn.disable_session_recording,s=this.Rn.disable_session_recording||this._instance.consent.isOptedOut();return f&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!(this.wv||this.xv&&(t=this.yv)!=null&&t.isStarted)){var i=!b(Object.assign)&&!b(Array.from);this.xv&&i?(this.Cv(e),Xe.info("starting")):(this.bv=Di,this.stopRecording())}}Cv(e){var t,i;if(this.xv)if(this.bv!=="awaiting_config"&&this.bv!=="missing_config"&&(this.bv=_o),O!=null&&(t=O.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(i=O.__PosthogExtensions__)!=null&&i.initSessionRecording)this.Tv(e);else{var s,r=this._instance.sessionManager;(s=O.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.Mv,n=>{if(!this.wv&&this.xv&&this._instance.sessionManager===r)return n?(this._instance.register_for_session({[wr]:!0}),Xe.error("could not load recorder",n)):void this.Tv(e);this.bv=Di})}}stopRecording(){var e,t;(e=this._v)==null||e.call(this),this._v=void 0,(t=this.yv)==null||t.stop()}Sv(e){var t,i;e===void 0&&(e=!1),(t=this._v)==null||t.call(this),this._v=void 0,(i=this.yv)==null||i.discard({discardProducerEvents:e})}Iv(){var e,t;(e=this.sl)==null||e.unregister(Vr),(t=this.sl)==null||t.unregister(Sa)}Ev(e,t){if(D(e))return null;var i,s=ae(e)?e:parseFloat(e);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Xe.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):s}Rv(e){if(this.sl){var t,i,s=this.sl,r=()=>{var n,o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.Ev((n=this.Rn.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ev(o?.sampleRate,"remote config sampleRate"),u=a??l;D(u)&&this.Iv();var h=o?.minimumDurationMilliseconds;s.register({[Dt]:w({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:w({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:b(h)?null:h,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(t=this._v)==null||t.call(this),this._v=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(r)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.Rv(t),void this.Sv()):(this.Rv(t),void this.startIfEnabledOrStop()):(this.bv==="awaiting_config"&&(this.bv="missing_config",Xe.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;t===void 0&&(t="log"),(i=this.yv)!=null&&i.log?this.yv.log(e,t):Xe.warn("log called before recorder was ready")}get Mv(){var e;return((e=this._instance)==null||(e=e.persistence)==null||(e=e.get_property("$session_recording_remote_config"))==null||(e=e.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Av(){var e,t=this._instance.get_property(Dt);if(!t)return!1;try{e=typeof t=="object"?t:JSON.parse(t)}catch(i){return Xe.warn("persisted remote config for session recording is invalid and will be ignored",i),!1}return!D(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}Tv(e){var t,i,s;if(!this.wv&&this.xv&&this._instance.sessionManager){if((t=O.__PosthogExtensions__)==null||!t.initSessionRecording)return Xe.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[wr]:!0});var r;if(this.yv||(this.yv=(r=O.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance,this.Ke),this.yv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Av())return this.bv==="missing_config"||this.bv==="awaiting_config"?void 0:(this.bv="awaiting_config",Xe.info("persisted remote config is stale, requesting fresh config before starting"),void new ol(this._instance).load());this.bv=_o,(i=(s=this.yv).setDocumentWasEverVisible)==null||i.call(s,this.Ke),this.yv.start(e)}else this.bv=Di}onRRwebEmit(e){var t;(t=this.yv)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.yv||(e=this.sl)==null||e.register({[Ra]:!0}),(t=this.yv)==null||t.overrideLinkedFlag()}overrideSampling(){var e,t;this.yv||(e=this.sl)==null||e.register({[Pa]:!0}),(t=this.yv)==null||t.overrideSampling()}overrideTrigger(e){var t,i;this.yv||(t=this.sl)==null||t.register({[e==="url"?$a:Ta]:!0}),(i=this.yv)==null||i.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.yv)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!((i=this.yv)==null||!i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e;(e=this.yv)==null||e.flushBeforeIdentityReset==null||e.flushBeforeIdentityReset()}}},Ec={autocapture:class extends ic{constructor(e){super(new sc(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.Pv=this.Fv()}initialize(){this.startIfEnabled()}get isEnabled(){var e=this.Ov();return!!(e.path||e.search||this.$v(e))}startIfEnabled(){this.isEnabled&&(S.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Pv=this.Fv(),this.startIfEnabled()}stop(){this.Dv&&this.Dv(),this.Dv=void 0,this.Lv&&this.Lv(),this.Lv=void 0,S.info("History API monitoring stopped")}monitorHistoryChanges(){f&&f.history&&(this.Nv("pushState"),this.Nv("replaceState"),this.qv(),this.$v()&&this.jv())}Nv(e){var t;if(f&&((t=f.history[e])==null||!t.__posthog_wrapped__)){var i=this;Rl(f.history,e,s=>function(r,n,o){s.call(this,r,n,o),i.Bv(e)})}}Fv(){var e=f?.location;if(e!=null&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}Ov(){var e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:j(e)?e:{}}$v(e){return e===void 0&&(e=this.Ov()),!!e.hash&&!this._instance.config.disable_capture_url_hashes}Hv(e){var t=this.Ov(),i=this.Pv;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this.$v(t)&&e.hash!==i.hash))}Bv(e){try{var t=this.Fv();if(!t)return;this.Hv(t)&&this._instance.capture(Gr,{navigation_type:e}),this.Pv=t}catch(i){S.error("Error capturing "+e+" pageview",i)}}qv(){if(!this.Dv){var e=()=>{this.Bv("popstate")};z(f,"popstate",e),this.Dv=()=>{f&&f.removeEventListener("popstate",e)}}}jv(){if(!this.Lv){var e=()=>{this.Bv("hashchange")};z(f,"hashchange",e),this.Lv=()=>{f&&f.removeEventListener("hashchange",e)}}}},heatmaps:class{get Rn(){return this.instance.config}constructor(e){var t;this.zv=!1,this.Xs=!1,this.Uv=null,this.instance=e,this.zv=!((t=this.instance.persistence)==null||!t.props[dr]),this.rageclicks=new Pl(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return j(this.Rn.capture_heatmaps)&&this.Rn.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rn.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return D(this.Rn.capture_heatmaps)?D(this.Rn.enable_heatmaps)?this.zv:this.Rn.enable_heatmaps:this.Rn.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Xs)return;ac.info("starting..."),this.Wv(),this.ar()}else{var e;clearInterval((e=this.Uv)!==null&&e!==void 0?e:void 0),this.Vv(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[dr]:i}),this.zv=i,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.Rt;return this.Rt=void 0,e}Gv(e){Xs(e.originalEvent)&&this.vn(e.originalEvent,"deadclick")}ar(){this.Uv&&clearInterval(this.Uv),this.Uv=E?.visibilityState==="visible"?setInterval(this.Ja.bind(this),this.flushIntervalMilliseconds):null}Wv(){f&&E&&(this.Zv=this.Ja.bind(this),z(f,os,this.Zv),this.Jv=e=>this.vn(e||f?.event),z(E,"click",this.Jv,{capture:!0}),this.Qv=e=>this.Kv(e||f?.event),z(E,"mousemove",this.Qv,{capture:!0}),this.Xv=new Gn(this.instance,dh,this.Gv.bind(this)),this.Xv.startIfEnabledOrStop(),this.Yv=this.ar.bind(this),z(E,qt,this.Yv),this.Xs=!0)}Vv(){var e;f&&E&&(this.Zv&&f.removeEventListener(os,this.Zv),this.Jv&&E.removeEventListener("click",this.Jv,{capture:!0}),this.Qv&&E.removeEventListener("mousemove",this.Qv,{capture:!0}),this.Yv&&E.removeEventListener(qt,this.Yv),clearTimeout(this.tc),(e=this.Xv)==null||e.stop(),this.Xs=!1)}ec(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&Ye(u)&&!xe(u,"body");){if(u===l)return!1;var h=void 0;try{var c,d,v;h=(c=(d=(v=u.ownerDocument)==null?void 0:v.defaultView)!==null&&d!==void 0?d:f)==null?void 0:c.getComputedStyle(u).position}catch{return!1}if(A(a,h))return!0;u=za(u)}return!1})(di(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:s),y:e.clientY+(n?0:i),target_fixed:n,type:t}}vn(e,t){var i;if(t===void 0&&(t="click"),!Dn(e.target)&&Xs(e)){var s=this.ec(e,t);(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Wa(di(e),this.instance.config.rageclick)&&this.$s(w({},s,{type:"rageclick"})),this.$s(s)}}Kv(e){!Dn(e.target)&&Xs(e)&&(clearTimeout(this.tc),this.tc=setTimeout(()=>{this.$s(this.ec(e,"mousemove"))},500))}$s(e){if(f){var t=this.Rn.disable_capture_url_hashes?ct(f.location.href):f.location.href,i=this.Rn.custom_personal_data_properties,s=Ei(t,this.Rn.mask_personal_data_properties?[...zt,...i||[]]:[],xi);this.Rt=this.Rt||{},this.Rt[s]||(this.Rt[s]=[]),this.Rt[s].push(e)}}Ja(){this.Rt&&!Oe(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Gn,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.zv=!1,this.Xs=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rc=()=>{clearTimeout(this.nc),this.nc=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",w({$current_url:this.Rt.url},this.Rt.metrics.reduce((i,s)=>w({},i,{["$web_vitals_"+s.name+"_event"]:w({},s),["$web_vitals_"+s.name+"_value"]:s.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.sc=i=>{var s;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},D(i?.name)||D(i?.value))ft.error("Invalid metric received",i);else{var r=typeof i.navigationURL=="string"?i.navigationURL:void 0,n=this.oc(r);if(!b(n)){var o=ae(i.navigationId)||typeof i.navigationId=="string"?"navigation:"+i.navigationId:"url:"+n;if(!this.ac||this.ac>i.value){this.Rt.navigationKey!==o&&(this.rc(),this.nc=setTimeout(this.rc,this.flushToCaptureTimeoutMs)),b(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=n),this.Rt.firstMetricTimestamp=b(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0),l=w({},i,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,j(i.attribution)&&this.attributionMetrics.indexOf(i.name)>-1){var u={};for(var h of oc){var c=h==="url"&&typeof i.attribution[h]=="string"?this.oc(i.attribution[h]):i.attribution[h];b(c)||(u[h]=c)}l.attribution=u}else delete l.attribution;b(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.rc()}else ft.error("Ignoring metric with value >= "+this.ac,i)}}},this.lc=()=>{if(!this.Xs){var i,s,r,n,o=!1,a=O.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.uc]||(this.uc==="web-vitals"&&b(l)?a?.postHogWebVitalsCallbacks:void 0);if(!b(u)){var h=u.withoutAttribution,c=this.attributionMetrics;o=!b(h),i=c.indexOf("LCP")>-1?u.onLCP:h?.onLCP||u.onLCP,s=c.indexOf("CLS")>-1?u.onCLS:h?.onCLS||u.onCLS,r=c.indexOf("FCP")>-1?u.onFCP:h?.onFCP||u.onFCP,n=c.indexOf("INP")>-1?u.onINP:h?.onINP||u.onINP}if(i&&s&&r&&n){var d={reportSoftNavs:this.useSoftNavs},v=o&&this.attributionMetrics.indexOf("INP")>-1?w({},d,{includeProcessedEventEntries:!1}):d;this.allowedMetrics.indexOf("LCP")>-1&&i(this.sc.bind(this),d),this.allowedMetrics.indexOf("CLS")>-1&&s(this.sc.bind(this),d),this.allowedMetrics.indexOf("FCP")>-1&&r(this.sc.bind(this),d),this.allowedMetrics.indexOf("INP")>-1&&n(this.sc.bind(this),v),this.Xs=!0}else ft.error("web vitals callbacks not loaded - not starting")}},this.zv=!((t=this._instance.persistence)==null||!t.props[fr]),this.startIfEnabled()}get hc(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=j(this.hc)?(e=this.hc)==null?void 0:e.web_vitals_allowed_metrics:void 0;return D(i)?((t=this._instance.persistence)==null?void 0:t.props.$web_vitals_allowed_metrics)||go:i}get flushToCaptureTimeoutMs(){return(j(this.hc)?this.hc.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var e=j(this.hc)?this.hc.web_vitals_attribution:void 0;return Te(e)?e?go:[]:C(e)?e:nc}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var e;return(e=j(this.hc)?this.hc.__preview_web_vitals_soft_navs:void 0)!==null&&e!==void 0&&e}get ac(){var e=j(this.hc)&&ae(this.hc.__web_vitals_max_value)?this.hc.__web_vitals_max_value:fo;return e>0&&6e4>=e?fo:e}get isEnabled(){var e=ne?.protocol;if(e!=="http:"&&e!=="https:")return ft.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=j(this.hc)?this.hc.web_vitals:Te(this.hc)?this.hc:void 0;return Te(t)?t:this.zv}startIfEnabled(){this.isEnabled&&!this.Xs&&(ft.info("enabled, starting..."),this.bo(this.lc))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var i=j(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=j(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[fr]:i}),this._instance.persistence.register({[ka]:s})),this.zv=i,this.startIfEnabled()}}}get uc(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}bo(e){var t=O.__PosthogExtensions__,i=this.uc,s=t?.postHogWebVitalsCallbacksByFlavor;s!=null&&s[i]||i==="web-vitals"&&b(s)&&t!=null&&t.postHogWebVitalsCallbacks?e():t==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,i,r=>{r?ft.error("failed to load script",r):e()})}oc(e){var t=e||f?.location.href;if(t){var i=this._instance.config.disable_capture_url_hashes?ct(t):t,s=this._instance.config.custom_personal_data_properties;return Ei(i,this._instance.config.mask_personal_data_properties?[...zt,...s||[]]:[],xi)}ft.error("Could not determine current URL")}}},xc={exceptionObserver:class{constructor(e){var t;this.lc=()=>{var i;if(f&&this.isEnabled&&(i=O.__PosthogExtensions__)!=null&&i.errorWrappingFunctions){var s=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.dc&&this.Rn.capture_unhandled_errors&&(this.dc=s(this.captureException.bind(this))),!this.vc&&this.Rn.capture_unhandled_rejections&&(this.vc=r(this.captureException.bind(this))),!this.cc&&this.Rn.capture_console_errors&&(this.cc=n(this.captureException.bind(this)))}catch(o){oi.error("failed to start",o),this.fc()}}},this._instance=e,this.gc=!((t=this._instance.persistence)==null||!t.props[vr]),this.wt=new Bl(w({},(function(i){var s,r,n,o;return i===void 0&&(i={}),{refillRate:(s=(r=i.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:i.__exceptionRateLimiterRefillRate)!==null&&s!==void 0?s:1,bucketSize:(n=(o=i.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:i.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}})(this._instance.config.error_tracking),{refillInterval:1e4,A:oi})),this.Rn=this.mc(),this.startIfEnabledOrStop()}mc(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return j(e)?t=w({},t,e):(b(e)?this.gc:e)&&(t=w({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rn.capture_console_errors||this.Rn.capture_unhandled_errors||this.Rn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(oi.info("enabled"),this.fc(),this.bo(this.lc)):this.fc()}bo(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",s=>{if(s)return oi.error("failed to load script",s);e()})}fc(){var e,t,i;(e=this.dc)==null||e.call(this),this.dc=void 0,(t=this.vc)==null||t.call(this),this.vc=void 0,(i=this.cc)==null||i.call(this),this.cc=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this.gc=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[vr]:this.gc}),this.Rn=this.mc(),this.startIfEnabledOrStop())}}onConfigChange(){this.Rn=this.mc()}captureException(e){try{var t,i,s,r=(t=e==null||(i=e.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&t!==void 0?t:"Exception";if(this.wt.consumeRateLimit(r))return void oi.info("Skipping exception capture because of client rate limiting.",{exception:r});(s=this._instance.exceptions)==null||s.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){var t,i;this.yc=[],this.bc=new Xl([new nu,new pu,new au,new ou,new du,new cu,new uu,new vu],(function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],h=a.split(`
4
- `),c=l;h.length>c;c++){var d=h[c];if(1024>=d.length){var v=wn.test(d)?d.replace(wn,"$1"):d;if(!v.match(/\S*Error: /)){for(var p of n){var g=p(v,s);if(g){u.push(g);break}}if(u.length>=50)break}}}return(function(_){if(!_.length)return[];var m=Array.from(_);return m.reverse(),m.slice(0,50).map(y=>{return w({},y,{filename:y.filename||(k=m,k[k.length-1]||{}).filename,function:y.function||"?"});var k})})(u)}})("web:javascript",tu,ru)),this._instance=e,this.yc=(t=(i=this._instance.persistence)==null?void 0:i.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this._c=ts(this.wc()),this.kc=new gu(this._c)}onConfigChange(){this._c=ts(this.wc()),this.kc.setConfig(this._c)}onRemoteConfig(e){var t,i,s;if(e.ok){var r=e.config;if("errorTracking"in r){var n=(t=(i=r.errorTracking)==null?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],o=(s=r.errorTracking)==null?void 0:s.captureExtensionExceptions;this.yc=n,this._instance.persistence&&this._instance.persistence.register({[xa]:this.yc,[pr]:o})}}}get Sc(){var e,t,i=!!this._instance.get_property(pr);return(e=(t=this._instance.config.error_tracking.captureExtensionExceptions)!==null&&t!==void 0?t:i)!==null&&e!==void 0&&e}buildProperties(e,t){return this.bc.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this._c.enabled)try{if(!q(e)||e.trim().length===0)return void qe.warn("Ignoring exception step because message must be a non-empty string");var i=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(n).reduce((a,l)=>fu.has(l)?(o.push(l),a):(a[l]=n[l],a),{}),droppedKeys:o}})(this.xc(t)),s=i.sanitizedProperties,r=i.droppedKeys;r.length>0&&qe.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.kc.add(w({[Qi]:e,[es]:new Date().toISOString()},s))}catch(n){qe.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Cc(t)){if(this.Tc(t))return this.Mc("Exception dropped: matched a suppression rule"),void qe.info("Skipping exception capture because a suppression rule matched");if(!this.Sc&&this.Ic(t))return this.Mc("Exception dropped: thrown by a browser extension"),void qe.info("Skipping exception capture because it was thrown by an extension");if(!this.Sc&&this.Ec(t))return this.Mc("Exception dropped: thrown by an injected browser script"),void qe.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Rc(t))return this.Mc("Exception dropped: thrown by the PostHog SDK"),void qe.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._c.enabled&&D(e.$exception_steps)?this.Ac(e):e,s=typeof(n=globalThis._posthogReleaseId)=="string"&&n.length>0?n:void 0;s&&(i.$release_id=s);try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Du:!0});return r&&this.kc.clear(),r}catch(o){return Ro(o)||qe.error("Failed to capture exception event. Dropping this exception.",o),void this.kc.clear()}}catch(o){return void(Ro(o)||qe.error("Failed to process exception event. Ignoring this exception.",o))}var n}Ac(e){try{var t=this.kc.getAttachable();return t.length===0?e:w({},e,{$exception_steps:t})}catch(i){return qe.error("Failed to read buffered exception steps. Capturing exception without steps.",i),e}}Mc(e){this._c.enabled&&this.kc.add({[Qi]:e,[es]:new Date().toISOString()})}xc(e){return j(e)?w({},e):{}}wc(){var e,t;return(e=(t=this._instance.config.error_tracking)==null?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}Tc(e){if(e.length===0)return!1;try{var t=e.reduce((i,s)=>{var r=s.type,n=s.value;return q(r)&&r.length>0&&i.$exception_types.push(r),q(n)&&n.length>0&&i.$exception_values.push(n),i},{$exception_types:[],$exception_values:[]});return this.yc.some(i=>{var s=i.values.map(r=>{var n=wl[r.operator],o=t[r.key];if(!n||!o)return!1;var a=C(r.value)?r.value:[r.value];return a.length>0&&n(a,o)});return i.type==="OR"?s.some(Boolean):s.every(Boolean)})}catch(i){return qe.warn("Failed to evaluate suppression rules. Capturing the exception.",i),!1}}Ic(e){var t=e.flatMap(s=>{var r,n;return(r=(n=s.stacktrace)==null?void 0:n.frames)!==null&&r!==void 0?r:[]}),i=t.filter(s=>{var r=s.filename;return!!r&&_c.some(n=>r.startsWith(n))});return i.length!==0&&(!i.every(s=>{var r=s.filename;return!!r&&r.startsWith(Lr)})||e.some(s=>{var r=s.value;return s.type==="NoResponse"||q(r)&&gc.some(n=>{var o=n.value;return n.exact?r===o:r.includes(o)})})&&!t.some(s=>{var r=s.filename;return s.in_app&&!(r!=null&&r.startsWith(Lr))}))}Ec(e){return e.some(t=>{var i=t.value;return q(i)&&mc.some(s=>i.includes(s))})}Rc(e){if(e.length>0){var t,i,s,r,n=(t=(i=e[0].stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[];return(s=(r=n[n.length-1])==null||(r=r.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}Cc(e){return!D(e)&&C(e)}}},kc=w({productTours:class{get sl(){return this._instance.persistence}constructor(e){this.Pc=null,this.Fc=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var i,s;if(this.sl&&this.sl.register({[zr]:!!t.productTours}),!Zs(this._instance))return!this.Pc&&D((i=this.sl)==null?void 0:i.props.ph_product_tours)||Ni.info("product tours disabled; stopping and clearing cached tours"),(s=this.Pc)==null||s.stop(),this.Pc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Pc&&Zs(this._instance)&&this.bo(()=>this.Oc())}bo(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.generateProductTours?e():(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",s=>{s?Ni.error("Could not load product tours script",s):e()})}Oc(){var e;!this.Pc&&(e=O.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Pc=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!C(this.Fc)||t){var i=this.sl;if(i){var s=i.props[zi];if(C(s)&&!t)return this.Fc=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:r=>{if(Zs(this._instance)){var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return n===0?r.error||Ni.warn(o):Ni.error(o),void e([],{isLoaded:!1,error:o})}var a=C(r.json.product_tours)?r.json.product_tours:[];this.Fc=a,i&&i.register({[zi]:a}),e(a,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.Fc,{isLoaded:!0})}getActiveProductTours(e){D(this.Pc)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Pc.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Pc)==null||t.showTourById(e)}previewTour(e){this.Pc?this.Pc.previewTour(e):this.bo(()=>{var t;this.Oc(),(t=this.Pc)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Pc)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Pc)==null||e.nextStep()}previousStep(){var e;(e=this.Pc)==null||e.previousStep()}clearCache(){var e;this.Fc=null,(e=this.sl)==null||e.unregister(zi)}resetTour(e){var t;(t=this.Pc)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Pc)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Pc)==null||t.cancelPendingTour(e)}}},ys),Sc={siteApps:class{constructor(e){this._instance=e,this.$c=0,this.Dc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lc(e,t){if(t){var i=this.globalsForEvent(t);this.Dc.push(i),this.Dc.length>1e3&&(this.Dc=this.Dc.slice(10))}}get siteAppLoaders(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Lc.bind(this));this.Nc=()=>{e(),this.Dc=[],this.Nc=void 0}}}globalsForEvent(e){var t,i,s,r,n,o,a;if(!e)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(h)){var d=c[0];l[d]={id:u[d],type:d,properties:c[1]}}var v=e.$set_once,p=e.$set;return{event:w({},Oo(e,Ol),{properties:w({},e.properties,p?{$set:w({},(t=(i=e.properties)==null?void 0:i.$set)!==null&&t!==void 0?t:{},p)}:{},v?{$set_once:w({},(s=(r=e.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},v)}:{}),elements_chain:(n=(o=e.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=e.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}qc(e){var t,i=(t=e.tagName)==null?void 0:t.toLowerCase();return i==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(ze.error("prepare_external_dependency_stylesheet returned null"),null):i==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(ze.error("prepare_external_dependency_script returned null"),null):e}jc(){var e,t,i,s,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=E?.defaultView,u=l==null||(e=l.Node)==null?void 0:e.prototype;if(!l||!u)return()=>{};if(this.$c++,this.Bc)return this.Hc();var h=[],c=this,d=new WeakSet,v=(_,m,y)=>{if(_!=null&&_[m]){var k=_[m];_[m]=y(k),h.push(()=>{_[m]=k})}},p=_=>{if(d.has(_))return _;var m=c.qc(_);return m&&d.add(m),m},g=_=>_.map(m=>typeof m=="string"?m:p(m)).filter(m=>!oe(m));return v(u,"appendChild",_=>function(m){var y=p(m);return y?_.call(this,y):m}),v(u,"insertBefore",_=>function(m,y){var k=p(m);return k?_.call(this,k,y):m}),v(u,"replaceChild",_=>function(m,y){var k=p(m);return k?_.call(this,k,y):y}),[(t=l.Element)==null?void 0:t.prototype,(i=l.Document)==null?void 0:i.prototype,(s=l.DocumentFragment)==null?void 0:s.prototype].forEach(_=>{v(_,"append",m=>function(){for(var y=arguments.length,k=new Array(y),x=0;y>x;x++)k[x]=arguments[x];return m.apply(this,g(k))}),v(_,"prepend",m=>function(){for(var y=arguments.length,k=new Array(y),x=0;y>x;x++)k[x]=arguments[x];return m.apply(this,g(k))})}),[(r=l.Element)==null?void 0:r.prototype,(n=l.CharacterData)==null?void 0:n.prototype,(o=l.DocumentType)==null?void 0:o.prototype].forEach(_=>{v(_,"before",m=>function(){for(var y=arguments.length,k=new Array(y),x=0;y>x;x++)k[x]=arguments[x];return m.apply(this,g(k))}),v(_,"after",m=>function(){for(var y=arguments.length,k=new Array(y),x=0;y>x;x++)k[x]=arguments[x];return m.apply(this,g(k))}),v(_,"replaceWith",m=>function(){for(var y=arguments.length,k=new Array(y),x=0;y>x;x++)k[x]=arguments[x];var P=g(k);return k.length&&!P.length?void 0:m.apply(this,P)})}),v((a=l.Element)==null?void 0:a.prototype,"insertAdjacentElement",_=>function(m,y){var k=p(y);return k?_.call(this,m,k):null}),this.Bc=()=>{h.forEach(_=>_()),this.Bc=void 0},this.Hc()}Hc(){var e=!1;return()=>{var t;e||(e=!0,this.$c--,this.$c===0&&((t=this.Bc)==null||t.call(this)))}}zc(e,t){t===void 0&&(t=!0);var i=this.jc();try{var s=e(i);return t&&i(),s}catch(r){throw i(),r}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var o;!t.errored&&this.Dc.length&&(ze.info("Processing "+this.Dc.length+" events for site app with id "+e.id),this.Dc.forEach(a=>this.zc(()=>t.processEvent==null?void 0:t.processEvent(a))),t.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.Nc)==null||o.call(this))},s=!1,r=o=>{t.errored=!o,t.loaded=!0,ze.info("Site app with id "+e.id+" "+(o?"loaded":"errored")),s&&i()};try{var n=this.zc(o=>e.init({posthog:this._instance,callback(a){o(),r(a)}}),!1).processEvent;n&&(t.processEvent=n),s=!0}catch(o){ze.error(mo+e.id,o),r(!1)}if(s&&t.loaded)try{i()}catch(o){ze.error("Error while processing buffered events PostHog app with config id "+e.id,o),t.errored=!0}}Uc(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}Wc(e){var t=this;if(Object.keys(this.apps).length!==0){var i=this.globalsForEvent(e),s=function(n){try{t.zc(()=>n.processEvent==null?void 0:n.processEvent(i))}catch(o){ze.error("Error while processing event "+e.event+" for site app "+n.id,o)}};for(var r of Object.values(this.apps))s(r)}}onRemoteConfig(e){var t,i,s,r=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Uc(),void this._instance.on("eventCaptured",l=>this.Wc(l))):void ze.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Nc)==null||i.call(this),e.ok){var n=e.config;if((s=n.siteApps)!=null&&s.length)if(this.isEnabled){var o=function(){var l,u=a.id,h=a.url;O["__$$ph_site_app_"+u]=r._instance,(l=O.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(r._instance,h,c=>{if(c)return ze.error(mo+u,c)})};for(var a of n.siteApps)o()}else ze.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Pc={tracingHeaders:class{constructor(e){this._instance=e,this.Vc=void 0,this.Gc=void 0,this.Zc=void 0,this.lc=()=>{var t,i,s=this.Jc();s?(b(this.Vc)&&(this.Vc=(t=O.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(s,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),b(this.Gc)&&(this.Gc=(i=O.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null?void 0:i._patchFetch(s,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.fc()}}initialize(){this.startIfEnabledOrStop()}bo(e){var t,i;(t=O.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(i=O.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",s=>{if(s)return rc.error("failed to load script",s);e()})}Qc(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}Jc(){var e=this.Qc();return C(e)?(C(this.Zc)?this.Zc.splice(0,this.Zc.length,...e):this.Zc=[...e],e.length>0?this.Zc:void 0):(C(this.Zc)&&this.Zc.splice(0),this.Zc=e||void 0,this.Zc)}fc(){var e,t;(e=this.Vc)==null||e.call(this),(t=this.Gc)==null||t.call(this),this.Vc=void 0,this.Gc=void 0}startIfEnabledOrStop(){this.Jc()?this.bo(this.lc):this.fc()}}},Rc=w({surveys:class extends lc{constructor(e){var t;super(new vc(e),(t=e,{get projectToken(){return t.config.token},kv:new dc(t)})),this._instance=e}ah(e,t){var i=t.query?Si(e,t.query):e;return new Promise(s=>{var r;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((r=t.target)!==null&&r!==void 0?r:"api",i),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:s})})}}},ys),$c={toolbar:class{constructor(e){this.instance=e}Kc(e){O.ph_toolbar_state=e}Xc(){var e;return(e=O.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),kr(this.instance.config)||!f||!E)return!1;e=e??f.location,i=i??f.history;try{if(!t){try{f.localStorage.setItem("test","test"),f.localStorage.removeItem("test")}catch{return!1}t=f?.localStorage}var s,r=pc||ls(e.hash,"__posthog")||ls(e.hash,"state"),n=r?Cn(()=>JSON.parse(atob(decodeURIComponent(r))))||Cn(()=>JSON.parse(decodeURIComponent(r))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(bo)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}Yc(e){var t=O.ph_load_toolbar||O.ph_load_editor;!D(t)&&ke(t)?t(e,this.instance):wo.warn("No toolbar load function found")}loadToolbar(e){var t=!(E==null||!E.getElementById("__POSTHOG_TOOLBAR__"));if(!f||t)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=w({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(f.localStorage.setItem(bo,JSON.stringify(w({},s,{source:void 0}))),this.Xc()===2)this.Yc(s);else if(this.Xc()===0){var r;this.Kc(1),(r=O.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",n=>{if(n)return wo.error("[Toolbar] Failed to load",n),void this.Kc(0);this.Kc(2),this.Yc(s)}),z(f,"turbolinks:load",()=>{this.Kc(0),this.loadToolbar(s)})}return!0}tf(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},Tc=w({experiments:class Re{get Rn(){return this._instance.config}constructor(t){var i=this;this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),i.getWebExperiments(r=>{Re.ef("retrieved web experiments from the server"),i.if=new Map,r.forEach(n=>{if(n.feature_flag_key){var o;i.if&&(Re.ef("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=i.if)==null||o.set(n.feature_flag_key,n));var a=i._instance.getFeatureFlag(n.feature_flag_key);q(a)&&n.variants[a]&&i.rf(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];Re.nf(u,i._instance)&&i.rf(n.name,l,u.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(t){if(this._is_bot())Re.ef($o);else if(!this.Rn.disable_web_experiments){if(D(this.if))return this.if=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Re.ef("applying feature flags",t),t.forEach(i=>{var s;if(this.if&&(s=this.if)!=null&&s.has(i)){var r,n=this._instance.getFeatureFlag(i),o=(r=this.if)==null?void 0:r.get(i);n&&o!=null&&o.variants[n]&&this.rf(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){var t=Re.getWindowLocation();if(t!=null&&t.search){var i=Ht(t?.search,"__experiment_id"),s=Ht(t?.search,"__experiment_variant");i&&s&&(Re.ef("previewing web experiments "+i+" && "+s),this.getWebExperiments(r=>{this.sf(parseInt(i),s,r)},!1,!0))}}loadIfEnabled(){this.Rn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,s){if(this.Rn.disable_web_experiments&&!s)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Rn.token),method:"GET",timestampMode:"query",callback:n=>t(n.statusCode===200&&n.json&&n.json.experiments||[])})}sf(t,i,s){var r=s.filter(n=>n.id===t);r&&r.length>0&&(Re.ef("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.rf(r[0].name,i,r[0].variants[i].transforms))}static nf(t,i){return!D(t.conditions)&&Re.af(t,i)&&Re.lf(t)}static af(t,i){var s;if(D(t.conditions)||D((s=t.conditions)==null?void 0:s.url))return!0;var r=Re.getWindowLocation();if(r){var n,o,a,l=Ba(i,r.href);return(n=t.conditions)==null||!n.url||yc[(o=(a=t.conditions)==null?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return f?.location}static lf(t){var i;if(D(t.conditions)||D((i=t.conditions)==null?void 0:i.utm))return!0;var s=Qa();if(s.utm_source){var r,n,o,a,l,u,h,c,d=(r=t.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=t.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.utm_campaign,v=(o=t.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=t.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==s.utm_source,p=(l=t.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=t.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==s.utm_medium,g=(h=t.conditions)==null||(h=h.utm)==null||!h.utm_term||((c=t.conditions)==null||(c=c.utm)==null?void 0:c.utm_term)==s.utm_term;return d&&p&&g&&v}return!1}static ef(t){for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;i>r;r++)s[r-1]=arguments[r];S.info("[WebExperiments] "+t,s)}rf(t,i,s){this._is_bot()?Re.ef($o):i!=="control"?s.forEach(r=>{var n;r.selector&&(Re.ef("applying transform of variant "+i+" for experiment "+t+" ",r),(n=document)==null||(n=n.querySelectorAll(r.selector))==null||n.forEach(o=>{var a=o;r.html&&(a.innerHTML=r.html),r.css&&a.setAttribute("style",r.css)}))}):Re.ef("Control variants leave the page unmodified.")}_is_bot(){return _e&&this._instance?ml(_e,this.Rn.custom_blocked_useragents):void 0}}},ys),Fc=w({},ys,wc,Ec,xc,kc,Sc,Rc,Pc,$c,Tc,{conversations:class{constructor(e){this._instance=e,this.uf=void 0,this._conversationsManager=null,this.hf=!1,this.re=null,this.df=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this.vf=e.ok,e.ok)){var t=e.config.conversations;D(t)||(Te(t)?this.uf=t:(this.uf=t.enabled,this.re=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.uf=void 0,this.re=null,this.vf=void 0,this.df=!1}loadIfEnabled(){if(!(this._conversationsManager||this.hf||this._instance.config.disable_conversations||kr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=O?.__PosthogExtensions__;if(e&&!b(this.uf)&&this.uf)if(this.re&&this.re.token){this.hf=!0;try{var t=e.initConversations;if(t)return this.cf(t),void(this.hf=!1);var i=e.loadExternalDependency;if(!i)return void this.ff(Er);i(this._instance,"conversations",s=>{s||!e.initConversations?this.ff("Could not load conversations script",s):this.cf(e.initConversations),this.hf=!1})}catch(s){this.ff("Error initializing conversations",s),this.hf=!1}}else De.error("Conversations enabled but missing token in remote config.")}}cf(e){if(this.re)try{this._conversationsManager=e(this.re,this._instance),this.df=!1,De.info("Conversations loaded successfully")}catch(t){this.ff("Error completing conversations initialization",t)}else De.error("Cannot complete initialization: remote config is null")}ff(e,t){De.error(e,t),this._conversationsManager=null,this.hf=!1,this.df=!0}show(){this._conversationsManager?this._conversationsManager.show():De.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.uf===!0&&!oe(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":kr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.vf===!1?"remote_config_failed":b(this.uf)?this.vf?"disabled_in_project":"remote_config_pending":this.uf?D(this.re)||!this.re.token?"missing_token":O!=null&&O.__PosthogExtensions__?this.hf?"initializing":this.df?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,i){var s=this;return X(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(De.warn(_t),null)})()}getMessages(e,t){var i=this;return X(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(De.warn(_t),null)})()}markAsRead(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(De.warn(_t),null)})()}getTickets(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(De.warn(_t),null)})()}requestRestoreLink(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(De.warn(_t),null)})()}restoreFromToken(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(De.warn(_t),null)})()}restoreFromUrlToken(){var e=this;return X(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(De.warn(_t),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}Wu(){var e;(e=this._conversationsManager)==null||e.setIdentity()}Vu(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t,i=this;this._instance=e,this.name="logs",this.pf=!1,this.gf=!1,this.mf=!1,this.A=le("[logs]"),this.yf=w({},this.A,{error(){for(var s=arguments.length,r=new Array(s),n=0;s>n;n++)r[n]=arguments[n];r.some(Io)||i.A.error(...r)}}),this.La=[],this.bf=[],this.Od=0,this.ro=!1,this._f=[],this.wf=[],this.kf=!1,this.Sf=!1,this.xf=()=>{var s,r;this.ro||(this.Od=0,(s=this.Cf)==null||s.onReconnect(),(r=this.Tf)==null||r.onReconnect())},this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.pf=!0),f&&z(f,"online",this.xf)}Mf(e,t,i,s){var r,n=To((r=this._instance)==null||(r=r.config)==null?void 0:r.logs,i);return[new Su(this.If(e,t),n,this.yf,()=>this.Ef(),o=>o(),void 0,s),n]}Rf(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Cf||this.Af!==t){var i;(i=this.Cf)==null||i.reset(),this.Af=t;var s=this.Mf(()=>this.La,r=>{this.La=r});this.Cf=s[0],this.Pf=s[1]}return this.Cf}Ff(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Tf||this.Of!==t){var i;(i=this.Tf)==null||i.reset(),this.Of=t;var s=this.Mf(()=>this.bf,r=>{this.bf=r},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Fo);this.Tf=s[0],this.$f=s[1]}return this.Tf}setup(e){var t;if(!this.ro){this.Js=e,(t=this._instance)!=null&&(t=t.config)!=null&&(t=t.logs)!=null&&t.captureConsoleLogs&&(this.pf=!0),(this.pf||this.Df()&&this.Lf())&&this.Nf();var i=!1,s=e.onRemoteConfig(r=>{var n;i=r.ok&&((n=r.config.logs)==null?void 0:n.captureConsoleLogs)===!0,this.onRemoteConfig(r)});this.ro?s.dispose():(this.oo=s,i||this.loadIfEnabled())}}dispose(){var e,t,i,s;this.ro||(this.ro=!0,this.qf(),(e=this.oo)==null||e.dispose(),this.oo=void 0,this.Js=void 0,this.mf=!1,f?.removeEventListener("online",this.xf),(t=this.jf)==null||t.call(this),this.jf=void 0,(i=this.Cf)==null||i.reset(),(s=this.Tf)==null||s.reset())}onRemoteConfig(e){var t,i;if(!this.ro){var s=e.ok?(t=e.config.logs)==null?void 0:t.captureConsoleLogs:void 0;D(s)?this.Bf():((i=this._instance)==null||(i=i.persistence)==null||i.register({[gr]:!!s}),s?(this.pf=!0,this.gf||this.Nf(),this.loadIfEnabled()):this.Bf())}}reset(){var e,t,i,s;this.qf(),(e=this.Cf)==null||e.clearQueue(),this.La=[],(t=this.Cf)==null||t.reset(),(i=this.Tf)==null||i.clearQueue(),this.bf=[],(s=this.Tf)==null||s.reset(),this.Od=0}captureLog(e){this.ro||this.Rf().captureLog(e)}captureConsoleLog(e){this.ro||this.Ff().captureLog(e)}captureBufferedConsoleLog(e,t,i){this.ro||this.Ff().captureLog(e,{context:t,occurredAtMs:i})}Lf(){var e;return!((e=this._instance)==null||(e=e.persistence)==null||(e=e.props)==null||!e[gr])}Df(){var e,t;return(e=this._instance)==null||e.Fa==null||!e.Fa()||!((t=O._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null||!t.config)}Zu(){var e;this.qf(),(e=this.Tf)==null||e.clearQueue(),this.bf=[]}Bf(){this.pf||this.qf()}Nf(){var e,t=this;if(!this.kf&&O!=null&&O.console){var i=To((e=this._instance)==null||(e=e.config)==null?void 0:e.logs).maxBufferSize,s=function(n){var o;try{o=(a=>{for(;(l=a)!=null&&l.__rrweb_original__;){var l;a=a.__rrweb_original__}return a})(O.console[n])}catch{return 0}if(!o)return 0;t.wf.push(Rl(O.console,n,a=>{var l=function(){for(var u=arguments.length,h=new Array(u),c=0;u>c;c++)h[c]=arguments[c];try{t.Hf(n,h,i)}catch{}return a.apply(O.console,h)};return l.__rrweb_original__=o,l}))};for(var r of bc)s(r);this.kf=!0,this.zf=setTimeout(()=>{this.qf()},3e4)}}Hf(e,t,i){var s;if(this.kf&&!this.Sf&&t.length!==0)if((s=this._instance)!=null&&s.is_capturing()){if(i>this._f.length){this.Sf=!0;try{this._f.push({level:e,args:t,occurredAtMs:Date.now(),context:this.Ef()})}finally{this.Sf=!1}}}else this.qf()}qf(){if(this._f=[],this.kf){for(var e of(this.kf=!1,this.zf&&(clearTimeout(this.zf),this.zf=void 0),this.wf))e();this.wf=[]}}Uf(){var e=this._f;return this.qf(),e}get logger(){return this.Wf||(this.Wf={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.Wf}flushLogs(e){e?this.Vf(e):(this.Cf&&this.Cf.flush().catch(t=>this.Gf(t)),this.Tf&&this.Tf.flush().catch(t=>this.Gf(t)))}Gf(e){Io(e)||this.A.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(!this.ro&&this.pf&&!this.gf&&!this.mf){var e=O?.__PosthogExtensions__;if(!e)return this.A.error("PostHog Extensions not found."),void this.qf();var t=e.loadExternalDependency;if(!t)return this.A.error(Er),void this.qf();this.mf=!0;try{t(this._instance,"logs",i=>{if(this.mf=!1,!this.ro&&this.pf){var s=e.logs;if(i||s==null||!s.initializeLogs)this.A.error("Could not load logs script",i),this.qf();else{var r,n,o=this.Uf();this.jf=s.initializeLogs((r=this.Js)!==null&&r!==void 0?r:this._instance),this.gf=!0,o.length>0&&(s.replayConsoleBuffer==null||s.replayConsoleBuffer((n=this.Js)!==null&&n!==void 0?n:this._instance,o))}}})}catch(i){throw this.mf=!1,i}}}If(e,t){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:s=>s===We.LogsQueue?e():void 0,setPersistedProperty(s,r){s===We.LogsQueue&&t(r??[])},xs:s=>this.xs(s),getLibraryId:()=>pe.LIB_NAME,getLibraryVersion:()=>pe.LIB_VERSION}}xs(e){return new Promise(t=>{if(Xa(this.Od,3))t({kind:"fatal",error:er(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,s=n=>{i||(i=!0,clearTimeout(r),t(n))},r=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:er(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Zf(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{var o=n.statusCode;if(this.Jf(o),o>=200&&300>o)s({kind:"ok"});else if(o===413)s({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)s({kind:"fatal",error:new Error("logs request failed with status "+o)});else{var a;o===0?(n.error||this.A.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:er(n.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:(a=n.error)!==null&&a!==void 0?a:new Error("logs request failed with status "+o)})}}})}})}Jf(e){(e!==0||this._instance.__loaded)&&(this.Od=Za(e,this.Od,3,()=>this.A.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.")))}Vf(e){this.La.length>0&&this.Qf(e,this.La,this.Pf,pe.LIB_NAME,t=>{this.La=t}),this.bf.length>0&&this.Qf(e,this.bf,this.$f,Fo,t=>{this.bf=t})}Qf(e,t,i,s,r){if(t.length!==0){var n=t.map(a=>a.record);r([]);var o=wa(n,ba(i,pe.LIB_NAME,pe.LIB_VERSION),s,pe.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Zf(),data:o,compression:"best-available",batchKey:"logs",transport:e})}}Zf(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Ef(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),s=i.windowId,r=i.sessionStartTimestamp,n=i.lastActivityTimestamp;t.sessionId=i.sessionId,t.windowId=s,D(r)||(t.sessionStartTimestamp=r),D(n)||(t.lastActivityTimestamp=n)}if(O!=null&&(e=O.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ct(O.location.href):O.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},{metrics:class{constructor(e){this._instance=e,this.A=le("[metrics]")}initialize(){}Rf(){var e,t,i=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.Cf&&this.Af===i||((t=this.Cf)==null||t.reset(),this.Af=i,this.Cf=new Pu(this.If(),(function(s){var r,n,o,a,l,u=s?.resourceAttributes;return{serviceName:(r=u?.["service.name"])!==null&&r!==void 0?r:s?.serviceName,serviceVersion:(n=u?.["service.version"])!==null&&n!==void 0?n:s?.serviceVersion,environment:(o=u?.["deployment.environment"])!==null&&o!==void 0?o:s?.environment,resourceAttributes:u,beforeSend:s?.beforeSend,flushIntervalMs:(a=s?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=s?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(i),this.A)),this.Cf}count(e,t,i){t===void 0&&(t=1),this.Rf().count(e,t,i)}gauge(e,t,i){this.Rf().gauge(e,t,i)}histogram(e,t,i){this.Rf().histogram(e,t,i)}flush(e){if(!this.Cf)return Promise.resolve();if(e){var t=this.Cf.drainWindow();return t&&this.js(t,e),Promise.resolve()}return this.Cf.flush().catch(i=>this.A.error("PostHog metrics flush failed:",i))}reset(){var e;(e=this.Cf)==null||e.reset()}If(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},js:i=>t.js(i),getLibraryId:()=>pe.LIB_NAME,getLibraryVersion:()=>pe.LIB_VERSION}}js(e,t){return new Promise(i=>{var s=!1,r=o=>{s||(s=!0,clearTimeout(n),i(o))},n=setTimeout(()=>r({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(w({method:"POST",url:this.Kf(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(o){var a,l=o.statusCode;r(l>=200&&300>l?{kind:"ok"}:l===413?{kind:"too-large"}:l!==0&&l!==408&&l!==429&&500>l?{kind:"fatal",error:new Error("metrics request failed with status "+l)}:{kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error("metrics request failed with status "+l)})}}))})}Kf(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});tn.__defaultExtensionClasses=w({},Fc);var Ic=(function(){pe.SDK_DIST_CHANNEL="npm";var e=fi[ui]=new tn;return(function(){function t(){t.done||(t.done=!0,Sl=!1,U(fi,function(i){i._dom_loaded()}))}E!=null&&E.addEventListener?E.readyState==="complete"?t():z(E,"DOMContentLoaded",t,{capture:!1}):f&&S.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})(),ce=Ic;var Pe=class Pe{constructor(t,i=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=ln("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=t=>{if(typeof document>"u"||typeof window>"u")return;let i=`ph_${t}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==i);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(u=>{let h=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${h}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:t,api_host:i,config:s={}}=this.options;if(!t){console.warn("Posthog: No API key provided");return}if(Pe._hasLoaded||ce.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(t);let r=i||on();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:nn,autocapture:{dom_event_allowlist:["click"]},rate_limiting:{events_per_second:10,events_burst_limit:100},...s,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...s.session_recording,recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0},before_send:o=>{if(typeof window>"u"||!o)return null;if(o.timestamp){let u=o.timestamp.getTime(),h=Date.now();if(u<h-6048e5||u>h+6048e5)return this.log("init | before_send dropped event with bad timestamp",{event:o.event,timestamp:o.timestamp.toISOString()}),null}let a=window.location.hostname;if(a!=="localhost"&&a!=="127.0.0.1"&&!an.some(u=>a.endsWith(`.${u}`)||a===u))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(s.before_send){let l=Array.isArray(s.before_send)?s.before_send:[s.before_send],u=o;for(let h of l)u=u?h(u):null;return u}return o}};ce.init(t,n),this.options.app_version&&ce.register({app_version:this.options.app_version}),Pe._hasLoaded=!0,this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(t){console.error("Posthog: Failed to initialize",t)}};this.resetIfStaleId=(t,i,s)=>{Pe.isAnonymousId(t)||(this.log(`${s} | stale identified user, resetting`,{previous:t,next:i}),ce.reset())};this.identifyEvent=(t,i={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!t||!t.trim()||Pe.ILLEGAL_IDS.has(t.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:t});return}let s=ce.get_distinct_id();if(s===t){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:t});return}this.resetIfStaleId(s,t,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:t,traits:i}),ce.identify(t,{...i,client_id:t}),this.has_identified=!0}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),ce.reset(),this.has_identified=!1}catch(t){console.error("Posthog: Failed to reset",t)}};this.backfillPersonProperties=({user_id:t,email:i,language:s,country_of_residence:r})=>{if(!(!this.has_initialized||!t)){if(!t.trim()||Pe.ILLEGAL_IDS.has(t.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:t});return}try{let n=ce.get_distinct_id(),o=n===t;o||this.resetIfStaleId(n,t,"backfillPersonProperties");let a={};if(ce.get_property("client_id")||(a.client_id=t),i&&ce.get_property("is_internal")==null&&(a.is_internal=un(i)),s&&!ce.get_property("language")&&(a.language=s),r&&!ce.get_property("country_of_residence")&&(a.country_of_residence=r),o){if(Object.keys(a).length===0){this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:t});return}this.log("backfillPersonProperties | backfilling person properties",{user_id:t,updates:a}),ce.setPersonProperties(a)}else a.client_id||(a.client_id=t),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:t,updates:a}),ce.identify(t,a),this.has_identified=!0}catch(n){console.error("Posthog: Failed to backfill person properties",n)}}};this.capture=(t,i)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:t,properties:i}),ce.capture(t,i)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.isFeatureEnabled=t=>{if(this.has_initialized)try{let i=ce.isFeatureEnabled(t);return this.log("isFeatureEnabled",{key:t,result:i}),i}catch(i){console.error("Posthog: Failed to check feature flag",i);return}};this.getFeatureFlag=t=>{if(this.has_initialized)try{let i=ce.getFeatureFlag(t);return this.log("getFeatureFlag",{key:t,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag",i);return}};this.getFeatureFlagPayload=t=>{if(this.has_initialized)try{let i=ce.getFeatureFlagResult(t)?.payload;return this.log("getFeatureFlagPayload",{key:t,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag payload",i);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let t=ce.featureFlags?.getFlagVariants()??{},i=Object.fromEntries(Object.entries(t).filter(s=>s[1]!=null));return this.log("getAllFlags",{result:i}),i}catch(t){return console.error("Posthog: Failed to get all feature flags",t),{}}};this.onFeatureFlags=t=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let i=ce.onFeatureFlags(t);return typeof i=="function"?i:()=>{}}catch(i){return console.error("Posthog: Failed to subscribe to feature flags",i),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),ce.reloadFeatureFlags()}catch(t){console.error("Posthog: Failed to reload feature flags",t)}};this.options=t,this.debug=i,this.init()}};Pe._hasLoaded=!1,Pe.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),Pe.getPosthogInstance=(t,i=!1)=>(Pe._instance?t.apiKey&&t.apiKey!==Pe._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):Pe._instance=new Pe(t,i),Pe._instance),Pe.isAnonymousId=t=>t?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t):!0;var Fl=Pe;export{Fl as Posthog};
5
- //# sourceMappingURL=posthog-LBWKPBQW.mjs.map