@promptowl/contextnest-community 1.21.0 → 1.22.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.
@@ -0,0 +1,3 @@
1
+ const y="u">typeof window?window:void 0,_e="u">typeof globalThis?globalThis:y,fe=_e==null?void 0:_e.navigator,w=_e==null?void 0:_e.document,ee=_e==null?void 0:_e.location,ns=_e==null?void 0:_e.fetch,_n=_e!=null&&_e.XMLHttpRequest&&"withCredentials"in new _e.XMLHttpRequest?_e.XMLHttpRequest:void 0,qn=_e==null?void 0:_e.AbortController,_l=_e==null?void 0:_e.CompressionStream,ye=fe==null?void 0:fe.userAgent;function lo(){return!(!y||y.navigator.onLine===!1)}const Lt=typeof globalThis<"u"?globalThis:y;Lt&&typeof self>"u"&&(Lt.self=Lt),Lt&&typeof File>"u"&&(Lt.File=function(){});const O=y??{},ml="0.8.2",Je={DEBUG:!1,LIB_VERSION:ml,LIB_NAME:"browser-common"};var Ne=(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})({}),Ni=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const yl=["$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"],bl=["token"];function A(e,t){return e.indexOf(t)!==-1}const Ks=function(e){return e.trim()},ji=function(e){return e.replace(/^\$/,"")};function uo(e){var t;const s=[];return(t=JSON.stringify(e,function(i,n){if(typeof n=="bigint")return n.toString();if(typeof n!="function"&&typeof n!="symbol"){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(n))return"[Circular]";s.push(n)}return n}}))!==null&&t!==void 0?t:"null"}const co=Object.prototype,mn=co.hasOwnProperty,Ys=co.toString,R=Array.isArray||function(e){return Ys.call(e)==="[object Array]"},ve=e=>typeof e=="function",T=e=>e===Object(e)&&!R(e),$e=e=>{if(T(e)){for(const t in e)if(mn.call(e,t))return!1;return!0}return!1},b=e=>e===void 0,L=e=>Ys.call(e)=="[object String]",Jt=e=>L(e)&&e.trim().length===0,se=e=>e===null,M=e=>b(e)||se(e),ie=e=>Ys.call(e)=="[object Number]"&&e==e,He=e=>ie(e)&&e>0,we=e=>Ys.call(e)==="[object Boolean]",wl=e=>A(yl,e),xl=e=>A(bl,e);function ho(e){return e===null||typeof e!="object"}function Cs(e,t){return{}.toString.call(e)===`[object ${t}]`}function hs(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 fo(e,Error)}}function yn(e){return"u">typeof Event&&fo(e,Event)}function fo(e,t){try{return e instanceof t}catch{return!1}}const Sl=[!0,"true",1,"1","yes"],ii=e=>A(Sl,e),$l=[!1,"false",0,"0","no"];function zn(e,t,s,i,n,r,o){try{var a=e[r](o),l=a.value}catch(u){return void s(u)}a.done?t(l):Promise.resolve(l).then(i,n)}function Z(e){return function(){var t=this,s=arguments;return new Promise(function(i,n){var r=e.apply(t,s);function o(l){zn(r,i,n,o,a,"next",l)}function a(l){zn(r,i,n,o,a,"throw",l)}o(void 0)})}}const kl=["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"],Hn=function(e,t=[]){if(!e)return!1;const s=e.toLowerCase();return kl.concat(t).some(i=>{const n=i.toLowerCase();return s.indexOf(n)!==-1})};function je(e,t,s,i,n){return t>s&&(i.warn("min cannot be greater than max."),t=s),ie(e)?e>s?(i.warn(" cannot be greater than max: "+s+". Using max value instead."),s):t>e?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+n),je(n??s,t,s,i))}var El=class{constructor(e){this.C={},this.I=e.I,this.R=je(e.bucketSize,0,100,e.$),this.A=je(e.refillRate,0,this.R,e.$),this.O=je(e.refillInterval,0,864e5,e.$)}F(e,t){const s=Math.floor((t-e.lastAccess)/this.O);s>0&&(e.tokens=Math.min(e.tokens+s*this.A,this.R),e.lastAccess=e.lastAccess+s*this.O)}consumeRateLimit(e){var t;const s=Date.now(),i=String(e);let n=this.C[i];return n?this.F(n,s):(n={tokens:this.R,lastAccess:s},this.C[i]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.I)===null||t===void 0||t.call(this,e)),n.tokens===0)}stop(){this.C={}}};const Ot="Mobile",rs="Android",Rs="Tablet",po="Android Tablet",vo="iPad",go="Apple Watch",ks="Safari",Zs="BlackBerry",_o="Samsung Internet",Es="Chrome",mo="Chrome iOS",yo="Internet Explorer",bo="Internet Explorer Mobile",wo="Opera",xo="Microsoft Edge",Ps="Firefox",So="Firefox iOS",As="Nintendo",Ms="PlayStation",Xs="Xbox",$o="Android Mobile",ko="Mobile Safari",ni="Windows",Eo="Windows Phone",Un="Nokia",Bi="Ouya",Pl="Generic "+Ot.toLowerCase(),Po="Generic "+Rs.toLowerCase(),qi="Konqueror",Fo="Oculus Browser",Io="Vivaldi",Oo="Yandex",Co="Whale",Ro="DuckDuckGo",Ao="Pale Moon",Mo="Waterfox",zi="Brave",To="Claude",Lo="Codex",Do="ChatGPT",No="Google Search App",ri=new RegExp("Version/(\\d+(\\.\\d+)?)"),oi=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Fl=new RegExp(Xs,"i"),Il=new RegExp("PlayStation \\w+","i"),Ol=new RegExp("Nintendo \\w+","i"),bn=new RegExp("BlackBerry|PlayBook|BB10","i"),Cl={"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"},jo=function(e,t,s,i){return t=t||"",(function(r){return r!=null&&r.brave?zi:null})(s)||(i!=null&&i.detectGoogleSearchApp&&A(e,"GSA/")?No:A(e," OPR/")&&A(e,"Mini")?"Opera Mini":A(e," OPR/")?wo:bn.test(e)?Zs:A(e,"IEMobile")||A(e,"WPDesktop")?bo:A(e,"OculusBrowser")?Fo:A(e,"SamsungBrowser")?_o:A(e,"Edge")||A(e,"Edg/")?xo:A(e,"Vivaldi/")?Io:A(e,"YaBrowser/")?Oo:A(e,"Whale/")?Co:A(e,"DuckDuckGo/")||A(e,"Ddg/")?Ro:A(e,"Claude/")?To:A(e,"Codex/")?Lo:A(e,"ChatGPT/")?Do:A(e,"FBIOS")?"Facebook Mobile":A(e,"UCWEB")||A(e,"UCBrowser")?"UC Browser":A(e,"CriOS")?mo:A(e,"CrMo")||A(e,Es)?Es:A(e,rs)&&A(e,ks)?$o:A(e,"FxiOS")?So:A(e.toLowerCase(),qi.toLowerCase())?qi:A(e,"Brave/")?zi:((r,o)=>o&&A(o,"Apple")||(function(a){return A(a,ks)&&!A(a,Es)&&!A(a,rs)})(r))(e,t)?A(e,Ot)?ko:ks:A(e,"PaleMoon/")?Ao:A(e,"Waterfox/")?Mo:A(e,Ps)?Ps:A(e,"MSIE")||A(e,"Trident/")?yo:A(e,"Gecko")?Ps:"")},Rl={[bo]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[xo]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Es]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[mo]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ks]:[ri],[ko]:[ri],[wo]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Ps]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[So]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[qi]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Zs]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),ri],[$o]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[_o]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Fo]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Io]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Oo]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Co]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[zi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[To]:[oi],[Lo]:[oi],[Do]:[oi],[Ro]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Ao]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Mo]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[No]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[yo]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Al=function(e,t,s,i){const n=jo(e,t,s,i),r=Rl[n];if(b(r))return null;for(let o=0;r.length>o;o++){const a=e.match(r[o]);if(a)return parseFloat(a[a.length-2])}return null},Vn=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[Xs,e&&e[1]||""]],[new RegExp(As,"i"),[As,""]],[new RegExp(Ms,"i"),[Ms,""]],[bn,[Zs,""]],[new RegExp(ni,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Eo,""];if(new RegExp(Ot).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const s=/Windows NT ([0-9.]+)/i.exec(t);if(s&&s[1]){let i=Cl[s[1]]||"";return/arm/i.test(t)&&(i="RT"),[ni,i]}return[ni,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=b(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[rs,[e[2],e[3],e[4]||"0"].join(".")]:[rs,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const 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",""]]],Bo=function(e){for(let t=0;Vn.length>t;t++){const[s,i]=Vn[t],n=s.exec(e),r=n&&(ve(i)?i(n,e):i);if(r)return r}return["",""]},qo=function(e){return Ol.test(e)?As:Il.test(e)?Ms:Fl.test(e)?Xs:new RegExp(Bi,"i").test(e)?Bi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?Eo:/iPad/.test(e)?vo:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?go:bn.test(e)?Zs:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Un,"i").test(e)?Un:/(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(Ot).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)?rs:po:new RegExp("(pda|Mobile)","i").test(e)?Pl:new RegExp(Rs,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?Po:""},Ml=function(e,t){var s;const i=qo(e);return i===vo||i===po||i==="Kobo"||i==="Kindle Fire"||i===Po?Rs:i===As||i===Xs||i===Ms||i===Bi?"Console":i===go?"Wearable":i?Ot:(t==null?void 0:t.userAgentDataPlatform)==="Android"&&((s=t==null?void 0:t.maxTouchPoints)!==null&&s!==void 0?s:0)>0?600>Math.min((n=t==null?void 0:t.screenWidth)!==null&&n!==void 0?n:0,(r=t==null?void 0:t.screenHeight)!==null&&r!==void 0?r:0)/((o=t==null?void 0:t.devicePixelRatio)!==null&&o!==void 0?o:1)?Ot:Rs:"Desktop";var n,r,o},ai=/\bFBAV\/(\d+(?:\.\d+)*)/i,Wn=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ai],[/\bFBAN\/EMA\b/i,"Facebook Lite",ai],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ai],[/\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"]],Hi="[Truncated]",Qs="[Unserializable]";function Ft(e){let t="";for(let s=0;e.length>s;s++){const i=e.charCodeAt(s);if(55296>i||i>56319)t+=56320>i||i>57343?e[s]:"�";else{const n=e.charCodeAt(s+1);56320>n||n>57343?t+="�":(t+=e[s]+e[s+1],s++)}}return t}const Tl=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Gn(e,t){return typeof(s=e)=="string"&&Tl.test(s)?e:t();var s}function zo(e,t){const s=new Error(t);try{Object.defineProperty(s,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function ot(e){return e&&e.split("#")[0]}function wn(e,t){const s=setTimeout(e,t);return s!=null&&s.unref&&(s==null||s.unref()),s}function Jn(e,t,s){return Ho.apply(this,arguments)}function Ho(){return(Ho=Z(function*(e,t,s){let i;try{return yield Promise.race([e,new Promise((n,r)=>{i=wn(()=>{try{s==null||s(),n()}catch(o){r(o)}},t)})])}finally{clearTimeout(i)}})).apply(this,arguments)}let ps,Kn,li;function Ll(e){const t=globalThis._posthogChunkIds;if(!t)return;const s=Object.keys(t);return li&&s.length===Kn||(Kn=s.length,li=s.reduce((i,n)=>{ps||(ps={});const r=ps[n];if(r)i[r[0]]=r[1];else{const o=e(n);for(let a=o.length-1;a>=0;a--){const l=o[a],u=l==null?void 0:l.filename,c=t[n];if(u&&c){i[u]=c,ps[n]=[u,c];break}}}return i},{})),li}function Kt(e){return Kt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(e)}function Dl(e,t,s){return(t=(function(i){var n=(function(r){if(Kt(r)!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var a=o.call(r,"string");if(Kt(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(i);return Kt(n)=="symbol"?n:n+""})(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Yn(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function p(e){for(var t=1;arguments.length>t;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Yn(Object(s),!0).forEach(function(i){Dl(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Yn(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}var Nl=class{constructor(e,t,s=[]){this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t={}){const s=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(i,n);return{$exception_list:this.convertToExceptionList(r,s),$exception_level:"error"}}modifyFrames(e){var t=this;return Z(function*(){for(const s of e)s.stacktrace&&s.stacktrace.frames&&R(s.stacktrace.frames)&&(s.stacktrace.frames=yield t.applyModifiers(s.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)===null||t===void 0?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){let s,i;return e.cause!=null&&(s=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),p(p({},e),{},{cause:s,stack:i})}applyChunkIds(e,t){return e.map(s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s))}applyCoercers(e,t){for(const s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Z(function*(){let s=e;for(const i of t.modifiers)s=yield i(s);return s})()}convertToExceptionList(e,t){var s,i,n;const r={type:e.type,value:e.value,mechanism:{type:(s=t.type)!==null&&s!==void 0?s:"generic",handled:(i=t.handled)===null||i===void 0||i,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(r.stacktrace={type:"raw",frames:e.stack});const o=[r];return e.cause!=null&&o.push(...this.convertToExceptionList(e.cause,p(p({},t),{},{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:Ll(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,s=0){const i=(n,r)=>{if(4>=r){const o=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,o)}};return p(p({},t),{},{syntheticException:s==0?t.syntheticException:void 0,mechanism:e,apply:n=>i(n,s),next:n=>i(n,s+1)})}};function Ui(e,t,s,i,n){const r={platform:e,filename:t,function:s==="<anonymous>"?"?":s,in_app:!!t&&!t.startsWith("webkit-masked-url://")&&t!=="<anonymous>"};return b(i)||(r.lineno=i),b(n)||(r.colno=n),r}const Uo=(e,t)=>{const s=e.indexOf("safari-extension")!==-1,i=e.indexOf("safari-web-extension")!==-1;return s||i?[e.indexOf("@")!==-1?e.split("@")[0]:"?",s?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},jl=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Bl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ql=/\((\S*)(?::(\d+))(?::(\d+))\)/,zl=(e,t)=>{const s=jl.exec(e);if(s){const[,n,r,o]=s;return Ui(t,n,"?",+r,+o)}const i=Bl.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){const o=ql.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}const[n,r]=Uo(i[1]||"?",i[2]);return Ui(t,r,n,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},Hl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ul=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Vl=(e,t)=>{const s=Hl.exec(e);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){const r=Ul.exec(s[3]);r&&(s[1]=s[1]||"eval",s[3]=r[1],s[4]=r[2],s[5]="")}let i=s[3],n=s[1]||"?";return[n,i]=Uo(n,i),Ui(t,i,n,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},Zn=/\(error: (.*)\)/;function xn(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Wl(e){for(let t=1;10>=t;t++){const s=e.length-2*t;if(0>s)break;let i=!0;for(let n=0;t>n;n++)if(!xn(e[s+n],e[s+t+n])){i=!1;break}if(i){for(let n=0;t>n;n++)e[s+n]=e[s+t+n];return e.length=s+t,{start:s,length:t}}}}function Gl(e,t){const s=t.start+t.length,i=Wo(e,t);i&&e.splice(s+i===e.length?s:t.start,i)}function Vo(e,t){let s=t.start;for(;s>0&&xn(e[s-1],e[s-1+t.length]);)s--;return t.start-s}function Wo(e,t){const s=t.start+t.length;let i=s;for(;e.length>i&&xn(e[i],e[i-t.length]);)i++;return i-s}function Jl(e,t){const s=t[0];let i=e.length-(s?Vo(e,s):0);for(const n of t)i-=Wo(e,n);return i}function Kl(e,t,s){for(let i=0;e.length>i;i++){const n=e[(t+i)%e.length],r=e[(s+i)%e.length];if(n!==r)return r>n}return!1}var Yl=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const s=L(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?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){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Cs(e,"DOMException")}isDOMError(e){return Cs(e,"DOMError")}},Zl=class{match(e){return hs(e)}coerce(e,t){var s;const i=this.getStack(e),n=i===void 0;return{type:this.getType(e),value:this.getMessage(e,t),stack:i??((s=t.syntheticException)===null||s===void 0?void 0:s.stack),cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){return e.stacktrace||e.stack||void 0}},Xl=class{match(e){return!!Cs(e,"ErrorEvent")&&(e.error!=null||this.sr(e))}coerce(e,t){var s;if(e.error!=null)return t.apply(e.error);const i=t.apply(e.message);return p(p({},i),{},{stack:(s=this.ar(e))!==null&&s!==void 0?s:i.stack,synthetic:!0})}sr(e){return L(e.message)&&e.message.length>0}ar(e){var t,s;const i=e,n=(t=i.lineno)!==null&&t!==void 0?t:0,r=(s=i.colno)!==null&&s!==void 0?s:0;if(L(i.filename)&&i.filename.length!==0&&n!==0)return`Error
2
+ at ${i.filename}:${n}:${r}`}};const Ql=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var eu=class{match(e){return typeof e=="string"}coerce(e,t){var s;const[i,n]=this.getInfos(e);return{type:i??"Error",value:n??e,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}getInfos(e){let t="Error",s=e;const i=e.match(Ql);return i&&(t=i[1],s=i[2]),[t,s]}};const tu=["fatal","error","warning","log","info","debug"];function Go(e,t=40){const s=Object.keys(e);if(s.sort(),!s.length)return"[object has no keys]";for(let i=s.length;i>0;i--){const n=s.slice(0,i).join(", ");if(t>=n.length)return i===s.length?n:n.length>t?`${n.slice(0,t)}...`:n}return""}var su=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,i;const n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:(s=this.getStack(e))!==null&&s!==void 0?s:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(yn(e))return e.constructor.name;const t="name"in e?e.name:void 0;return L(t)&&!Jt(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let s=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(s+=` with message: '${e.message}'`),s}if("message"in e&&typeof e.message=="string")return e.message;const t=this.getObjectClassName(e);return`${t&&t!=="Object"?`'${t}'`:"Object"} captured as exception with keys: ${Go(e)}`}isSeverityLevel(e){return L(e)&&!Jt(e)&&tu.indexOf(e)>=0}getStack(e){try{return L(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:L(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const s=e[t];if(hs(s))return s}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},iu=class{match(e){return yn(e)}coerce(e,t){var s;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${Go(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},nu=class{match(e){return ho(e)}coerce(e,t){var s;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},ru=class{match(e){return Cs(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!yn(e))return!1;try{const t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var s;const i=this.getUnhandledRejectionReason(e);return ho(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}:t.apply(i)}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}};const Ts="$message",Ls="$timestamp",ou=new Set([Ts,Ls]),ui={enabled:!0,max_bytes:32768};function Ds(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:ui.enabled,max_bytes:lu(e.max_bytes,ui.max_bytes)}:p({},ui)}var au=class{constructor(e){this.ts=[],this.es=0,this.Sr=Ds(e)}setConfig(e){this.Sr=Ds(e),this.ns()}add(e){const t=(function(i){let n;try{n=uo(i)}catch{return}try{const r=JSON.parse(n);if(!T(r))return;const o=r,a=o[Ts],l=o[Ls];return!L(a)||a.trim().length===0||!L(l)&&!ie(l)?void 0:{step:o,json:n}}catch{return}})(e);if(!t)return;const s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;const n=encodeURIComponent(i);let r=0;for(let o=0;n.length>o;o++)n[o]==="%"?(r+=1,o+=2):r+=1;return r})(t.json);s>this.Sr.max_bytes||(this.ts.push({step:t.step,bytes:s}),this.es+=s,this.ns())}getAttachable(){return this.ts.map(e=>e.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Sr.max_bytes&&this.ts.length>0;){const e=this.ts.shift();e&&(this.es-=e.bytes)}}};function lu(e,t){if(!ie(e)||e===1/0||e===-1/0)return t;const s=Math.floor(e);return 0>s?t:s}const Xn=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function Qn(e){return typeof e=="string"||e}function er(e){return typeof e=="string"?e:void 0}const uu=["$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"],Jo="NativeGzipValidationError",Vi=e=>e.length>=2&&e[0]===31&&e[1]===139,tr=(e,t)=>e===Ni.GZipJS||t===Ni.GZipJS||t==="gzip",sr=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let Dt;const vs=e=>{throw zo(Jo,`Native gzip produced invalid output: ${e}`)},cu=(ir=Z(function*(e,t){18>e.size&&vs("too-short");const s=new Uint8Array(yield e.slice(0,10).arrayBuffer());Vi(s)&&s[2]===8||vs("invalid-header");const i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(r=>{const o=(()=>{if(Dt)return Dt;Dt=[];for(let l=0;256>l;l++){let u=l;for(let c=0;8>c;c++)u=1&u?3988292384^u>>>1:u>>>1;Dt[l]=u>>>0}return Dt})();let a=4294967295;for(let l=0;r.length>l;l++)a=o[255&(a^r[l])]^a>>>8;return(4294967295^a)>>>0})(t)&&vs("invalid-crc");const n=t.length>>>0;i.getUint32(4,!0)!==n&&vs("invalid-size")}),function(e,t){return ir.apply(this,arguments)});var ir;function Wi(){return Wi=Z(function*(e,t=!0,s){try{const n=new TextEncoder().encode(e),r=new globalThis.CompressionStream("gzip"),o=r.writable.getWriter(),a=o.write(n).then(()=>o.close()).catch((i=Z(function*(c){try{yield o.abort(c)}catch{}throw c}),function(c){return i.apply(this,arguments)})),l=new Response(r.readable).blob(),[u]=yield Promise.all([l,a]);return yield cu(u,n),u}catch(n){if(s!=null&&s.rethrow)throw n;return t&&console.error("Failed to gzip compress data",n),null}var i}),Wi.apply(this,arguments)}function Ko(e,t){if(e==null)return{};var s,i,n=(function(o,a){if(o==null)return{};var l={};for(var u in o)if({}.hasOwnProperty.call(o,u)){if(a.includes(u))continue;l[u]=o[u]}return l})(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;r.length>i;i++)t.includes(s=r[i])||{}.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}const du={}.propertyIsEnumerable;function Ns(e,t){try{return Yo(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Sn(e,t,s,i){if(0>=s.remainingNodes)return{stringValue:Hi};if(s.remainingNodes--,we(e))return{boolValue:e};if(typeof e=="bigint")return(function(n,r){const o=n.toString(),a=BigInt("9223372036854775808");return n>=a||-a>n?(r==null||r.debug(`Attribute ${o} is outside the int64 range; encoding it as a string`),{stringValue:o}):{intValue:o}})(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)};const n=BigInt(e).toString();return e>=9223372036854776e3||-9223372036854776e3>e?(t==null||t.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:Ft(e)};if(typeof e=="function")return{stringValue:"[Function]"};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(s.ancestors.has(e))return{stringValue:"[Circular]"};if(i>=20)return{stringValue:Hi};if(e instanceof Date){const n=e.getTime(),r=Number.isFinite(n)?e.toISOString():String(e);return{stringValue:typeof r=="string"?Ft(r):String(r)}}s.ancestors.add(e);try{try{const n=e.toJSON;if(typeof n=="function")return Sn(n.call(e),t,s,i+1)}catch{}return R(e)?{arrayValue:{values:hu(e,t,s,i+1)}}:{kvlistValue:{values:Yo(e,t,s,i+1)}}}finally{s.ancestors.delete(e)}}return{stringValue:Ft(String(e))}}function hu(e,t,s,i){const n=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&s.remainingNodes>0;o++)try{const a=o in e?e[o]:void 0;if(M(a))continue;n.push(Sn(a,t,s,i))}catch{n.push({stringValue:Qs})}return e.length>o&&n.push({stringValue:Hi}),n}function Yo(e,t,s,i){const n=[];for(const r in e)if(du.call(e,r)){if(!r){t==null||t.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=s.remainingNodes){t==null||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(se(o)||b(o))continue;n.push({key:Ft(r),value:Sn(o,t,s,i)})}catch{n.push({key:Ft(r),value:{stringValue:Qs}})}}return n}function Zo(e,t,s){return p(p(p(p({},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":s})}const nr={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"},Xo={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}},fu=Xo.info;function pu(e){try{return Ft(String(e))}catch{return Qs}}function vu(e,t,s,i){const n=e.level||"info",{text:r,number:o}=Xo[n]||fu,a=(function(f=Date.now()){return String(f)+"000000"})(ie(i)?i:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),M(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),M(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const u=p({},l),c=e.attributes;if(c){let f=[];try{f=Object.keys(c)}catch{f=[]}for(const h of f){let g;try{g=c[h]}catch{g=Qs}Object.defineProperty(u,h,{value:g,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:pu(e.body)},attributes:Ns(u,s)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),b(e.trace_flags)||(d.flags=e.trace_flags),d}function Qo(e,t,s){return Zo(e,t,s)}function ea(e,t,s,i){return{resourceLogs:[{resource:{attributes:Ns(t)},scopeLogs:[{scope:{name:s,version:i},logRecords:e}]}]}}var gu=class{constructor(e,t,s,i,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this.Sr=t,this.$=s,this.ss=i,this.rs=n,this.ls=r,this.us=o,this.hs=null,this.cs=0,this.ds=0,this.vs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=t.maxBufferSize,this.bs=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this._s=t.flushIntervalMs,this.ws=t.maxBatchRecordsPerPost,this.ks=t.rateCapWindowMs,this.Ss=t.maxLogsPerInterval}clearQueue(){this.ds++,this._instance.setPersistedProperty(Ne.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.vs=0,this.ws=this.Sr.maxBatchRecordsPerPost}onReconnect(){this.vs=0,this.Cs()}captureLog(e,t){var s;if(this._instance.isDisabled||this._instance.optedOut||!(e!=null&&e.body))return;const i=this.$s(e);if(i===null)return;if(!i.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ts())return;const n={record:vu(i,(s=t==null?void 0:t.context)!==null&&s!==void 0?s:this.ss(),this.$,t==null?void 0:t.occurredAtMs)};this.rs(()=>this.Is(n))}$s(e){const t=this.Sr.beforeSend;if(!t)return e;const s=R(t)?t:[t];let i=e;for(const n of s)try{const r=n(i);if(!r)return this.$.info("Log was rejected in beforeSend function"),null;i=r}catch(r){return this.$.error("Error in beforeSend function for log:",r),null}return i}Ts(){if(this.Ss===void 0)return!0;const e=Date.now(),t=e-this.fs;return this.ks>t&&t>=0||(this.fs=e,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.$.warn(`captureLog dropping logs: exceeded ${this.Ss} logs per ${this.ks}ms`),this.gs=!0),!1)}flush(){var e=this;return Z(function*(){if(!e._instance.isDisabled)return e.hs||(e.hs=e.Ms().finally(()=>{e.hs=null})),e.hs})()}Ms(){var e=this;return Z(function*(){var t;e.xs();let s=(t=e._instance.getPersistedProperty(Ne.LogsQueue))!==null&&t!==void 0?t:[];if(s.length===0)return;const i=s.length;let n=0;for(;s.length>0&&i>n;){var r,o;const a=e.ds;e.cs=0;const l=Math.min(s.length,e.ws),u=s.slice(0,l),c=ea(u.map(f=>f.record),e.Es(),(r=e.us)!==null&&r!==void 0?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),d=yield e._instance.Ps(c);if(e.ds!==a)return;if(d.kind==="too-large"&&u.length>1)e.ws=Math.max(1,Math.floor(u.length/2)),e.$.warn(`Received 413 when sending logs batch of size ${u.length}, reducing batch size to ${e.ws}`);else if(d.kind==="retry-later"||(d.kind==="too-large"?e.$.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):d.kind==="ok"&&e.Sr.maxBatchRecordsPerPost>e.ws&&(e.ws=Math.min(e.Sr.maxBatchRecordsPerPost,e.ws+1)),yield e.Rs(u.length),s=(o=e._instance.getPersistedProperty(Ne.LogsQueue))!==null&&o!==void 0?o:[],n+=u.length,d.kind==="fatal"))throw d.error}})()}Rs(e){var t=this;return Z(function*(){var s;const i=Math.max(0,e-t.cs),n=(s=t._instance.getPersistedProperty(Ne.LogsQueue))!==null&&s!==void 0?s:[];t._instance.setPersistedProperty(Ne.LogsQueue,n.slice(i)),yield t.ls()})()}Es(){return Qo(this.Sr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(e){var t;if(this._instance.optedOut)return;const s=(t=this._instance.getPersistedProperty(Ne.LogsQueue))!==null&&t!==void 0?t:[];this.bs>s.length||(s.shift(),this.cs++,this.$.info("Logs queue is full, dropping oldest record.")),s.push(e),this._instance.setPersistedProperty(Ne.LogsQueue,s),this.ys>s.length?this.As():this.Cs()}As(e=this._s){this.Fs||(this.Fs=wn(()=>{this.Fs=void 0,this.Cs()},e))}Os(){const e=Math.min(Math.max(0,this.vs-1),6);return this._s*Math.pow(2,e)}Ds(){const e=this._instance.getPersistedProperty(Ne.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Z(function*(){t.xs();const s=t.flush().catch(()=>{});e!==void 0?yield Jn(s,e):yield s})()}flushWithTimeout(e){var t=this;return Z(function*(){const s=t.flush();yield Jn(s,e,()=>{s.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.vs=0},e=>{this.vs++,this.$.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.As(this.Os())})}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}};const ci=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function rr(e){return String(e)+"000000"}function or(e,t,s,i){let n="";return i&&(n=Object.keys(i).sort().map(r=>`${JSON.stringify(r)}:${JSON.stringify(i[r])}`).join(",")),`${e}\0${t}\0${s??""}\0${n}`}var _u=class{constructor(e,t,s){this._instance=e,this.Sr=t,this.$=s,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(e,t=1,s){this.Hs({name:e,type:"count",value:t,unit:s==null?void 0:s.unit,attributes:s==null?void 0:s.attributes})}gauge(e,t,s){this.Hs({name:e,type:"gauge",value:t,unit:s==null?void 0:s.unit,attributes:s==null?void 0:s.attributes})}histogram(e,t,s){this.Hs({name:e,type:"histogram",value:t,unit:s==null?void 0:s.unit,attributes:s==null?void 0:s.attributes})}flush(){var e=this;const t=this.hs,s=(function(){var i=Z(function*(){t&&(yield t.catch(()=>{})),yield e.zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.hs===s&&(this.hs=null)});return this.hs=s,s}drainWindow(){if(this.Ls.size===0)return null;const e=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(e)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this.$s(e);if(t===null)return;if(!t.name||typeof t.name!="string")return void this.$.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=t.attributes?p({},t.attributes):void 0,i=or(t.type,t.name,t.unit,s)}catch(o){return void this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,o)}let n=this.Ls.get(i);if(!n){if(!this.Ws())return;n={name:t.name,type:t.type,unit:t.unit,attributes:s,windowStartMs:Date.now()},this.Ls.set(i,n)}const r=this.qs.get(t.name);r===void 0?this.qs.set(t.name,t.type):r===t.type||this.js.has(t.name)||(this.js.add(t.name),this.$.warn(`Metric name '${t.name}' is already used as a ${r}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Vs(n,t.value),this.As()}Ws(){return this.Sr.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.$.warn(`Metric series cap reached (${this.Sr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Vs(e,t){switch(e.type){case"count":var s;e.total=((s=e.total)!==null&&s!==void 0?s: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(ci.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[(function(n,r){for(let o=0;r.length>o;o++)if(r[o]>=n)return o;return r.length})(t,ci)]+=1;break}}}$s(e){const t=this.Sr.beforeSend;if(!t)return e;const s=R(t)?t:[t];let i=e;for(const n of s)try{const r=n(i);if(!r)return this.$.info("Metric was rejected in beforeSend function"),null;i=r}catch(r){return this.$.error("Error in beforeSend function for metric:",r),null}return i}As(){this.Fs||(this.Fs=wn(()=>{this.Fs=void 0,this.flush().catch(e=>{this.$.error("Metrics flush failed:",e)})},this.Sr.flushIntervalMs))}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}zs(){var e=this;return Z(function*(){if(e.Ls.size===0)return;const t=e.Ls;e.Ls=new Map,e.Ns=!1,e.qs=new Map,e.js=new Set;const s=e.Bs,i=yield e._instance.Gs(e.Us(t));if(s===e.Bs)switch(i.kind){case"ok":return;case"retry-later":return e.Zs(t),void e.As();case"too-large":return void e.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.$.error("Failed to send metrics batch:",i.error)}})()}Us(e){return t=this.Qs(e),s=(function(r,o,a){return Zo(r,o,a)})(this.Sr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ns(s)},scopeMetrics:[{scope:{name:i,version:n},metrics:t}]}]};var t,s,i,n}Qs(e){const t=rr(Date.now()),s=new Map;for(const o of e.values()){var i;const a=or(o.type,o.name,o.unit,void 0);let l=s.get(a);l||(l=p({name:o.name},o.unit&&{unit:o.unit}),o.type==="count"?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:o.type==="gauge"?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},s.set(a,l));const u=Ns((i=o.attributes)!==null&&i!==void 0?i:{},this.$),c=rr(o.windowStartMs);if(o.type==="count"){var n;const d={attributes:u,startTimeUnixNano:c,timeUnixNano:t,asDouble:(n=o.total)!==null&&n!==void 0?n:0};l.sum.dataPoints.push(d)}else if(o.type==="gauge"){var r;const d={attributes:u,timeUnixNano:t,asDouble:(r=o.last)!==null&&r!==void 0?r:0};l.gauge.dataPoints.push(d)}else o.hist&&l.histogram.dataPoints.push({attributes:u,startTimeUnixNano:c,timeUnixNano:t,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:ci})}return Array.from(s.values())}Zs(e){for(const[i,n]of e){const r=this.Ls.get(i);if(r)switch(r.windowStartMs=Math.min(r.windowStartMs,n.windowStartMs),r.type){case"count":var t,s;r.total=((t=r.total)!==null&&t!==void 0?t:0)+((s=n.total)!==null&&s!==void 0?s:0);break;case"gauge":break;case"histogram":if(n.hist)if(r.hist){r.hist.count+=n.hist.count,r.hist.sum+=n.hist.sum,r.hist.min=Math.min(r.hist.min,n.hist.min),r.hist.max=Math.max(r.hist.max,n.hist.max);for(let o=0;r.hist.bucketCounts.length>o;o++)r.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else r.hist=n.hist}else this.Ws()&&this.Ls.set(i,n)}}};const ta=(e,{debugEnabled:t}={})=>{const s={N(i,...n){y&&(Je.DEBUG||y.POSTHOG_DEBUG||t)&&!b(y.console)&&y.console&&("__rrweb_original__"in y.console[i]?y.console[i].__rrweb_original__:y.console[i])(e,...n)},debug(...i){s.N("debug",...i)},info(...i){s.N("log",...i)},warn(...i){s.N("warn",...i)},error(...i){s.N("error",...i)},critical(...i){console.error(e,...i)},uninitializedWarning(i){s.error(`You must initialize PostHog before calling ${i}`)},createLogger:(i,n)=>ta(`${e} ${i}`,n)};return s},k=ta("[PostHog.js]"),ne=k.createLogger,mu=ne("[ExternalScriptsLoader]"),js=e=>{const t=w==null?void 0:w.querySelectorAll("script");if(t){for(let s=0;t.length>s;s++)if(t[s].src===e||t[s].getAttribute("src")===e)return t[s]}},ht=(e,t,s)=>{if(e.config.disable_external_dependency_loading)return mu.warn(`${t} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");const i=js(t);if(i){if(i.__posthog_loading_callback_fired)return s();const r=i.__posthog_loading_error;return r?s(r):(i.addEventListener("load",o=>{i.__posthog_loading_callback_fired=!0,s(void 0,o)}),void i.addEventListener("error",o=>{i.__posthog_loading_error=o,s(o)}))}const n=()=>{if(!w)return s("document not found");if(js(t))return ht(e,t,s);let r=w.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=a=>{r.__posthog_loading_callback_fired=!0,s(void 0,a)},r.onerror=a=>{r.__posthog_loading_error=a,s(a)},e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return s("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")w.head.appendChild(r);else{const a=w.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(r,a[0]):w.body.appendChild(r)}};w!=null&&w.body?n():w==null||w.addEventListener("DOMContentLoaded",n)},di={},ar=(e,t)=>{let s=`/static/${t}.js?v=${e.version}`;return t==="toolbar"&&(s=`${s}&t=${Math.floor(Date.now()/3e5)*3e5}`),e.requestRouter.endpointFor("assets",s)};O.__PosthogExtensions__=O.__PosthogExtensions__||{},O.__PosthogExtensions__.loadExternalDependency=(e,t,s)=>{if(t==="remote-config"){const n=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void ht(e,n,s)}const i=e.config.strict_script_versioning;if(i){const n=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),r=di[n];if(i==="fallback"&&r){if(js(r))return void ht(e,r,s);delete di[n]}return void ht(e,n,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;const u=ar(e,t);di[n]=u;const c=js(n);c==null||(l=c.parentNode)===null||l===void 0||l.removeChild(c),ht(e,u,s)}else s(void 0,a)}:s)}ht(e,ar(e,t),s)},O.__PosthogExtensions__.loadSiteApp=(e,t,s)=>{const i=e.requestRouter.endpointFor("api",t);ht(e,i,s)},Je.DEBUG=!1,Je.LIB_VERSION="1.429.2",Je.LIB_NAME="web";var he=Je;const yu="$people_distinct_id",Ce="distinct_id",$n="$device_id",hi="$device_model",Bs="__alias",bu="__cmpns",gs="$fbc",Re="$fbc_persistence",Gi="__timers",sa="$autocapture_disabled_server_side",Ji="$heatmaps_enabled_server_side",Ki="$exception_capture_enabled_server_side",ia="$error_tracking_suppression_rules",Yi="$error_tracking_capture_extension_exceptions",Zi="$web_vitals_enabled_server_side",kn="$dead_clicks_enabled_server_side",En="$product_tours_enabled_server_side",na="$logs_capture_enabled_server_side",ra="$web_vitals_allowed_metrics",Yt="$session_recording_remote_config",wu="$session_recording_enabled_server_side",xu="$replay_sample_rate",Su="$replay_override_sampling",$u="$replay_override_linked_flag",ku="$replay_override_url_trigger",Eu="$replay_override_event_trigger",kt="$sesid",oa="$session_is_sampled",Pu="$session_past_minimum_duration",Fu="$session_recording_url_trigger_activated_session",Iu="$session_recording_event_trigger_activated_session",Ou="$debug_first_full_snapshot_timestamp",Cu="$sess_rec_flush_size",Ae="$enabled_feature_flags",Ve="$active_feature_flags",Xi="$early_access_features",vt="$feature_flag_details",tt="$feature_flag_payloads",gt="$feature_flag_request_id",Zt="$minimal_flag_called_events",De="$override_feature_flags",ft="$override_feature_flag_payloads",st="$stored_person_properties",it="$stored_group_properties",aa="$groups",Qi="$surveys",qs="$surveys_loaded_at",la="$surveys_activated",ua="$surveys_activated_session",ca="$surveys_activated_timestamps",en="ph_product_tours",Ru="$product_tours_activated",Au="$product_tours_activated_session",Mu="$conversations_widget_session_id",Tu="$conversations_ticket_id",Lu="$conversations_widget_state",Du="$conversations_user_traits",nt="$flag_call_reported",Wt="$flag_call_reported_session_id",os="$feature_flag_errors",rt="$feature_flag_evaluated_at",be="$user_state",tn="$client_session_props",Nu="$capture_rate_limit",da="$initial_campaign_params",ha="$initial_referrer_info",Et="$initial_person_info",Pn="$epp",fi="$posthog_cookieless",fa="$cookieless_mode",pa="$sdk_debug_extensions_init_method",va="$sdk_debug_extensions_init_time_ms",ga="$sdk_debug_recording_script_not_loaded",ju="$sdk_debug_replay_event_trigger_status",Bu="$sdk_debug_replay_linked_flag_trigger_status",qu="$sdk_debug_replay_matched_recording_trigger_groups",zu="$sdk_debug_replay_pending_trigger_conditions",Hu="$sdk_debug_replay_remote_trigger_matching_config",Uu="$sdk_debug_replay_trigger_groups_count",Vu="$sdk_debug_replay_url_trigger_status",Wu="$session_recording_start_reason",Fn="PostHog loadExternalDependency extension not found.",We="anonymous",Fs="identified",_a="identified_only",as="visibilitychange",zs="beforeunload",In="$pageview",lr="$pageleave",sn="$identify",ur="$groupidentify";function _s(e,t){R(e)&&e.forEach(t)}function q(e,t){if(!M(e))if(R(e))e.forEach(t);else if((s=>s instanceof FormData)(e))e.forEach((s,i)=>t(s,i));else for(const s in e)mn.call(e,s)&&t(e[s],s)}const Y=function(e,...t){for(const s of t)for(const i in s)s[i]!==void 0&&(e[i]=s[i]);return e};function Is(e){const t=Object.keys(e);let s=t.length;const i=new Array(s);for(;s--;)i[s]=[t[s],e[t[s]]];return i}const cr=function(e){try{return e()}catch{return}},Gu=function(e){return function(...t){try{return e.apply(this,t)}catch(s){k.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),k.critical(s)}}},On=function(e){const t={};return q(e,function(s,i){(L(s)&&s.length>0||ie(s))&&(t[i]=s)}),t};function ma(e){const t=p({},e);for(const s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch{}return t}const Ju=["herokuapp.com","vercel.app","netlify.app"];function Ku(e){const t=e==null?void 0:e.hostname;if(!L(t))return!1;const s=t.split(".").slice(-2).join(".");for(const i of Ju)if(s===i)return!1;return!0}function U(e,t,s,i){const{capture:n=!1,passive:r=!0}=i??{};e==null||e.addEventListener(t,s,{capture:n,passive:r})}function nn(e){return e.name==="ph_toolbar_internal"}const rn=e=>{if(w){try{const t=e+"=",s=w.cookie.split(";").filter(i=>i.length);for(let i=0;s.length>i;i++){let n=s[i];for(;n.charAt(0)==" ";)n=n.substring(1,n.length);if(n.indexOf(t)===0)return decodeURIComponent(n.substring(t.length,n.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 ie(e)&&isFinite(e)&&Math.floor(e)===e});var Yu=class on{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,s,i,n){if(!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(n)||0>t||0>s||0>i||0>n||t>0xffffffffffff||s>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|s>>>8,r[7]=s,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new on(r)}toString(){let t="";for(let s=0;this.bytes.length>s;s++)t=t+(this.bytes[s]>>>4).toString(16)+(15&this.bytes[s]).toString(16),s!==3&&s!==5&&s!==7&&s!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new on(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let s=0;16>s;s++){const i=this.bytes[s]-t.bytes[s];if(i!==0)return Math.sign(i)}return 0}},Zu=class{generate(){const e=this.generateOrAbort();if(!b(e))return e;{this.Ct=0;const t=this.generateOrAbort();if(b(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const e=(()=>{const t=Date.now();return ie(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return Yu.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(2,30)-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new Xu}};let ya=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};y&&!b(y.crypto)&&crypto.getRandomValues&&(ya=e=>crypto.getRandomValues(e));var Xu=class{nextUint32(){return this.Rt.length>this.$t||(ya(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}};let dr;const Me=()=>Qu().toString(),Qu=()=>(dr||(dr=new Zu)).generate();let Nt="";const ec=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let mt=null;const Q={Et(){if(!se(mt))return mt;if(mt=!1,w)try{const e=`__ph_cookie_support_${Me()}`;Q.At(e,"xyz"),mt=rn(e)==='"xyz"',Q.Lt(e)}catch{mt=!1}return mt},Pt(e){k.error("cookieStore error: "+e)},Ot:rn,Dt(e){let t;try{t=JSON.parse(Q.Ot(e))||{}}catch{}return t},At(e,t,s,i,n){if(!w)return!1;try{let r="",o="";const a=(function(u,c){if(c){let d=(function(f,h=w){if(Nt)return Nt;if(!h||["localhost","127.0.0.1"].includes(f))return"";const g=f.split(".");let v=Math.min(g.length,8);const _="dmn_chk_"+Me();for(;!Nt&&v--;){const m=g.slice(v).join("."),x=_+"=1;domain=."+m+";path=/";h.cookie=x+";max-age=3",h.cookie.includes(_)&&(h.cookie=x+";max-age=0",Nt=m)}return Nt})(u);if(!d){const f=(h=>{const g=h.match(ec);return g?g[0]:""})(u);f!==d&&k.info("Warning: cookie subdomain discovery mismatch",f,d),d=f}return d?"; domain=."+d:""}return""})(w.location.hostname,i);if(s){const u=new Date;u.setTime(u.getTime()+864e5*s),r="; expires="+u.toUTCString()}n&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&k.warn("cookieStore warning: large cookie, len="+l.length),w.cookie=l,!0}catch{return!1}},Lt(e,t){if(w!=null&&w.cookie)try{Q.At(e,"",-1,t)}catch{return}}};let pi=null;const N={Et(){if(!se(pi))return pi;let e=!0;if(b(y))e=!1;else try{const t="__mplssupport__";N.At(t,"xyz"),N.Ot(t)!=='"xyz"'&&(e=!1),N.Lt(t)}catch{e=!1}return e||k.error("localStorage unsupported; falling back to cookie store"),pi=e,e},Pt(e){k.error("localStorage error: "+e)},Ot(e){try{return y==null?void 0:y.localStorage.getItem(e)}catch(t){N.Pt(t)}return null},Dt(e){try{return JSON.parse(N.Ot(e))||{}}catch{}return null},At(e,t){try{return y==null||y.localStorage.setItem(e,JSON.stringify(t)),!0}catch(s){N.Pt(s)}return!1},Lt(e){try{y==null||y.localStorage.removeItem(e)}catch(t){N.Pt(t)}}},vi=[st,Ve,Ae,vt,tt,gt,rt,os,nt],pt=[$n,Ce,kt,oa,Pn,Et,Re,be],Hs=e=>e+"_cpm",tc=["__proto__","constructor","prototype"],gi=e=>{if(!T(e))return{};const t={};return Object.keys(e).forEach(s=>{tc.indexOf(s)===-1&&(t[s]=e[s])}),t},_i=(e,t=[])=>{const s={};return[...pt,...t].forEach(i=>{const n=e[i];b(n)||se(n)||n===""||(s[i]=n)}),s},ba=e=>{let t=5381,s=2166136261;for(let i=0;e.length>i;i++){const n=e.charCodeAt(i);t=33*t^n,s=Math.imul(s^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(s>>>0).toString(36)},hr=(e,t)=>({p:t,f:ba(JSON.stringify(e))}),fr=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const s=Q.Dt(Hs(e)),i=(s==null?void 0:s.f)===ba(t)&&R(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},mi=(e,t)=>t+"|"+(Q.Ot(Hs(e))||""),yt={},an={Et:()=>!0,Pt(e){k.error("memoryStorage error: "+e)},Ot:e=>e in yt?yt[e]:null,Dt:e=>e in yt?yt[e]:null,At:(e,t)=>(yt[e]=t,!0),Lt(e){delete yt[e]}};let lt=null;const K={Et(){if(!se(lt))return lt;if(lt=!0,b(y))lt=!1;else try{const e="__support__";K.At(e,"xyz"),K.Ot(e)!=='"xyz"'&&(lt=!1),K.Lt(e)}catch{lt=!1}return lt},Pt(e){k.error("sessionStorage error: ",e)},Ot(e){try{return y==null?void 0:y.sessionStorage.getItem(e)}catch(t){K.Pt(t)}return null},Dt(e){try{return JSON.parse(K.Ot(e))||null}catch{}return null},At(e,t){try{return y==null||y.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(s){K.Pt(s)}return!1},Lt(e){try{y==null||y.sessionStorage.removeItem(e)}catch(t){K.Pt(t)}}};var sc=class{constructor(e){this._instance=e}get Sr(){return this._instance.config}get consent(){return this.xo()?0:this.Co}isOptedOut(){return this.Sr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Sr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Sr.opt_out_capturing_by_default}optInOut(e){this.$o.At(this.To,e?1:0,this.Sr.cookie_expiration,this.Sr.cross_subdomain_cookie,this.Sr.secure_cookie)}reset(){this.$o.Lt(this.To,this.Sr.cross_subdomain_cookie)}get To(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:s}=this._instance.config;return s||(t?t+e:"__ph_opt_in_out_"+e)}get Co(){const e=this.$o.Ot(this.To);return ii(e)?1:A($l,e)?0:-1}get $o(){const e=this.Sr.opt_out_capturing_persistence_type,t=e==="localStorage"?N:Q,s=t.Et()?t:an;if(!this.Io||this.Io!==s){this.Io=s;const i=e==="localStorage"?Q:N;i.Ot(this.To)&&(this.Io.Ot(this.To)||this.optInOut(ii(i.Ot(this.To))),i.Lt(this.To,this.Sr.cross_subdomain_cookie))}return this.Io}xo(){return!!this.Sr.respect_dnt&&[fe==null?void 0:fe.doNotTrack,fe==null?void 0:fe.msDoNotTrack,O.doNotTrack,fe==null?void 0:fe.globalPrivacyControl].some(e=>ii(e))}};function wa(e,t){var s;const i=e==null||(s=e.config)===null||s===void 0?void 0:s.get_current_url;if(!ve(i))return t;try{const n=i(t);return L(n)&&n?n:t}catch(n){return k.error("Error in get_current_url, falling back to window.location.href",n),t}}function pr(e){var t;return e instanceof Element&&(e.id==="__POSTHOG_TOOLBAR__"||!!(!((t=e.closest)===null||t===void 0)&&t.call(e,".toolbar-global-fade-container")))}function Be(e){return!!e&&e.nodeType===1}function ge(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function xa(e){return!!e&&e.nodeType===3}function Cn(e){return!!e&&e.nodeType===11&&Be(e.host)}function Rn(e){return e?Ks(e).split(/\s+/):[]}function vr(e,t){const s=(function(i){var n;const r=y==null||(n=y.location)===null||n===void 0?void 0:n.href;return b(r)?void 0:wa(i,r)})(t);return!!(s&&e&&e.some(i=>s.match(i)))}function Ct(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Rn(t)}function Sa(e){return M(e)?null:Ks(e).split(/(\s+)/).filter(t=>Qt(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ls(e){let t="";return It(e)&&!us(e)&&e.childNodes&&e.childNodes.length&&q(e.childNodes,function(s){var i;xa(s)&&s.textContent&&(t+=(i=Sa(s.textContent))!==null&&i!==void 0?i:"")}),Ks(t)}function Xt(e){var t;return b(e.target)?e.srcElement||null:!((t=e.target)===null||t===void 0)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}const An=["a","button","form","input","select","textarea","label"];function ln(e,t){const s=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!s&&s.call(e,t)}catch{return!1}}function un(e,t){if(b(t))return!0;for(const s of e)if(t.some(i=>ln(s,i)))return!0;return!1}function $a(e){const t=e.parentNode;return!(!t||!Be(t))&&t}const yi=[".ph-no-autocapture","[data-ph-no-autocapture]"],ka=["next","previous","prev",">","<"],ic=[...ka,"+","-","−","–"],gr=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,_r=[".ph-no-rageclick",".ph-no-capture"],nc=["","text","search","email","password","url","tel","number"];function Ea(e,t){if(!y||Mn(e))return!1;let s,i,n;var r,o;if(we(t)?(s=!!t&&_r,i=void 0,n=!1):(s=(r=t==null?void 0:t.css_selector_ignorelist)!==null&&r!==void 0?r:_r,i=t==null?void 0:t.content_ignorelist,n=(o=t==null?void 0:t.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||n&&(function(l){return!(!l||!Be(l))&&(!!ge(l,"textarea")||(ge(l,"input")?A(nc,(l.getAttribute("type")||"").toLowerCase()):(function(u){var c;if(u.isContentEditable)return!0;const d=(c=u.getAttribute)===null||c===void 0?void 0:c.call(u,"contenteditable");return d==="true"||d===""})(l)))})(e))return!1;const{targetElementList:a}=Pa(e,!1);return!(function(l,u){if(l===!1||b(l))return!1;let c;if(l===!0)c=ka;else{if(!R(l))return!1;if(l.length>10)return k.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(d=>d.toLowerCase())}return u.some(({safeText:d,ariaLabel:f})=>c.some(h=>gr(d,h)||gr(f,h)))})(i,a.map(l=>{var u;return{safeText:ls(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))===null||u===void 0?void 0:u.toLowerCase().trim())||""}}))&&!un(a,s)}const Mn=e=>!e||ge(e,"html")||!Be(e),Pa=(e,t)=>{if(!y||Mn(e))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const i=[e];let n=e;for(;n.parentNode&&!ge(n,"body");){if(Cn(n.parentNode)){i.push(n.parentNode.host),n=n.parentNode.host;continue}const r=$a(n);if(!r)break;if(t||An.indexOf(r.tagName.toLowerCase())>-1)s=!0;else try{const o=y.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(r),n=r}return{parentIsUsefulElement:s,targetElementList:i}};function It(e){const t=new Set;let s=0;for(let r=e;r.parentNode&&!ge(r,"body");r=r.parentNode){if(s++>=1e3||t.has(r))return!1;t.add(r);const o=Ct(r);if(A(o,"ph-sensitive")||A(o,"ph-no-capture"))return!1}if(A(Ct(e),"ph-include"))return!0;const i=e.type||"";if(L(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}const n=e.name||e.id||"";return!L(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function us(e){return!!(ge(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ge(e,"select")||ge(e,"textarea")||e.getAttribute("contenteditable")==="true")}const mr=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}))$"),yr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,rc=[16,15,14,13],oc=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),br=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),wr=/[0-9A-Za-z_]/;function ac(e){let t=0,s=!1;for(let i=e.length-1;i>=0;i--){let n=e.charCodeAt(i)-48;s&&(n*=2,n>9&&(n-=9)),t+=n,s=!s}return t%10==0}function Qt(e,t=!0){return!(M(e)||L(e)&&(e=Ks(e),(t?mr.test((e||"").replace(/[- ]/g,"")):(function(s){let i;for(yr.lastIndex=0;i=yr.exec(s);){const n=i[2];if(!n)continue;const r=n.replace(/[- ]/g,"");for(let o=0;r.length>o;o++)for(const a of rc){const l=o+a;if(r.length>=l){const u=r.slice(o,l);if(mr.test(u)&&ac(u))return!0}}}return!1})(e))||(t?oc.test(e):(function(s){let i;for(br.lastIndex=0;i=br.exec(s);){const n=i[1],r=i[3];if(!(n&&r&&wr.test(n)&&wr.test(r)))return!0}return!1})(e))))}function xr(e){let t=ls(e);return t=`${t} ${Fa(e)}`.trim(),Qt(t)?t:""}function Fa(e){let t="";return e&&e.childNodes&&e.childNodes.length&&q(e.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{const n=ls(s);t=`${t} ${n}`.trim(),s.childNodes&&s.childNodes.length&&(t=`${t} ${Fa(s)}`.trim())}catch(n){k.error("[AutoCapture]",n)}}),t}function Sr(e){return e.replace(/"|\\"/g,'\\"')}function lc(e){const t=e.attr__class;if(t)return R(t)?t:Rn(t)}const ms=ne("[Dead Clicks]"),uc=()=>!0,cc=e=>{var t;const s=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(kn)),i=e.instance.config.capture_dead_clicks;return we(i)?i:!!T(i)||s};var $r=class{get lazyLoadedDeadClicksAutocapture(){return this.Mo}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[kn]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Eo(()=>{this.Po()}):this.stop()}Eo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",n=>{n?ms.error("failed to load script",n):e()})}Po(){var e;if(w){if(!this.Mo&&(!((e=O.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=T(this.instance.config.capture_dead_clicks)?p({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Mo=O.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Mo.start(w),ms.info("starting...")}}else ms.error("`document` not found. Cannot start.")}stop(){this.Mo&&(this.Mo.stop(),this.Mo=void 0,ms.info("stopping..."))}};const jt=ne("[SegmentIntegration]");function kr(e,t,s=!0){const i=e.config.segment;if(!i)return t();const{analytics:n,filterProperties:r}=(a=>ve(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,u,c){const d=h=>{const g=()=>h.anonymousId()||Me();a.config.get_device_id=g,c&&h.id()&&(a.register({distinct_id:h.id(),$device_id:g()}),a.persistence.set_property(be,Fs)),u(c?void 0:h.anonymousId()||void 0)},f=l.user();"then"in f&&ve(f.then)?f.then(d):d(f)})(e,n,a=>{n.register(((l,u,{filterProperties:c}={})=>{typeof Promise<"u"&&Promise.resolve||jt.warn("This browser does not have Promise support, and can not use the segment integration");const d=(f,h)=>{if(!h)return f;const g=!!u&&f.event.anonymousId===u&&!f.event.userId;g||f.event.userId||f.event.anonymousId===l.get_distinct_id()||(jt.info("No userId set, resetting PostHog"),l.reset()),g||(u=void 0),f.event.userId&&f.event.userId!==l.get_distinct_id()&&(jt.info("UserId set, identifying with PostHog"),l.identify(f.event.userId));let v=l.calculateEventProperties(h,f.event.properties);if(!M(c)){const _=f.event.properties||{},m={};for(const S of Object.keys(v))mn.call(_,S)||(m[S]=v[S]);const x=((S,C)=>{const $=R(S)?S:[S];let F=p({},C);for(const I of $)try{if(F=I(F),M(F))return null}catch(E){return jt.error("Error in Segment filterProperties:",E),null}return F})(c,m);if(M(x))return f;v=x}return f.event.properties=Object.assign({},v,f.event.properties),f};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(f){return d(f,f.event.event)},page(f){return d(f,In)},identify(f){return d(f,sn)},screen(f){return d(f,"$screen")}}})(e,a,{filterProperties:r})).then(()=>{t()},l=>{jt.error("Failed to register the Segment integration",l),t()})},s)}const Ia="posthog-js";function Oa(e,{organization:t,projectId:s,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,u,c,d;if(n!=="*"&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const f=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=f,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const h=((a=o.exception)===null||a===void 0?void 0:a.values)||[],g=h.map(m=>p(p({},m),{},{stacktrace:m.stacktrace?p(p({},m.stacktrace),{},{type:"raw",frames:(m.stacktrace.frames||[]).map(x=>p(p({},x),{},{platform:"web:javascript"}))}):void 0})),v={$exception_message:((l=h[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(u=h[0])===null||u===void 0?void 0:u.type,$exception_level:o.level,$exception_list:g,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((c=h[0])===null||c===void 0?void 0:c.value)||o.message,$sentry_exception_type:(d=h[0])===null||d===void 0?void 0:d.type,$sentry_tags:o.tags};var _;return t&&s&&(v.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+o.event_id),r&&((_=e.exceptions)===null||_===void 0||_.sendExceptionEvent(v)),o}}var dc=class{constructor(e,t,s,i,n,r){this.name=Ia,this.setupOnce=function(o){o(Oa(e,{organization:t,projectId:s,prefix:i,severityAllowList:n,sendExceptionsToPostHog:r==null||r}))}}},Er=class{constructor(e){this.Ro=(t,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(k.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Ao=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Fo()}Fo(){var e;this.Oo=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Ro)}destroy(){var e;(e=this.Oo)===null||e===void 0||e.call(this),this.Oo=void 0}doPageView(e,t){var s;const i=this.Do(e,t);return this.Ao={pathname:(s=y==null?void 0:y.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Do(e,(t=this.Ao)===null||t===void 0?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Ao)===null||e===void 0?void 0:e.pageViewId}}Do(e,t){const s=this.Ao;if(!s)return{$pageview_id:t};let i={$pageview_id:t,$prev_pageview_id:s.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:r,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=n;if(!(b(r)||b(o)||b(a)||b(l)||b(u)||b(c))){r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);const d=r>1?je(o/r,0,1,k):1,f=r>1?je(a/r,0,1,k):1,h=l>1?je(u/l,0,1,k):1,g=l>1?je(c/l,0,1,k):1;i=Y(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:g})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),i}};const Bt=["flags","surveys"],hc={[yu]:{exposure:"hidden"},[Bs]:{exposure:"hidden"},[bu]:{exposure:"hidden"},[Gi]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[sa]:{exposure:"event"},[Ji]:{exposure:"hidden"},[na]:{exposure:"hidden"},[Ki]:{exposure:"event"},[ia]:{exposure:"hidden"},[Yi]:{exposure:"event"},[Zi]:{exposure:"event"},[kn]:{exposure:"event"},[En]:{exposure:"hidden"},[ra]:{exposure:"event"},[Yt]:{exposure:"hidden"},[wu]:{exposure:"hidden"},[kt]:{exposure:"hidden"},[oa]:{exposure:"event"},[xu]:{exposure:"event",shouldSkipFromEventProperties:e=>se(e)},[Pu]:{exposure:"event"},[Fu]:{exposure:"event"},[Iu]:{exposure:"event"},[Ou]:{exposure:"event"},[Cu]:{exposure:"hidden"},[Ae]:{exposure:"hidden",storageGroup:"flags"},[Ve]:{exposure:"hidden",storageGroup:"flags"},[Xi]:{exposure:"hidden"},[vt]:{exposure:"hidden",storageGroup:"flags"},[tt]:{exposure:"hidden",storageGroup:"flags"},[gt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Zt]:{exposure:"hidden",storageGroup:"flags"},[De]:{exposure:"hidden"},[ft]:{exposure:"hidden"},[st]:{exposure:"hidden"},[it]:{exposure:"hidden"},[Qi]:{exposure:"hidden",storageGroup:"surveys"},[qs]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[la]:{exposure:"event"},[ua]:{exposure:"hidden"},[ca]:{exposure:"hidden"},[en]:{exposure:"hidden"},[Ru]:{exposure:"hidden"},[Au]:{exposure:"hidden"},[Mu]:{exposure:"event"},[Tu]:{exposure:"event"},[Lu]:{exposure:"event"},[Du]:{exposure:"event"},[nt]:{exposure:"hidden"},[Wt]:{exposure:"hidden"},[aa]:{exposure:"event"},[os]:{exposure:"hidden"},[rt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[be]:{exposure:"hidden"},[tn]:{exposure:"hidden"},[Nu]:{exposure:"hidden"},[da]:{exposure:"hidden"},[ha]:{exposure:"hidden"},[Et]:{exposure:"hidden"},[Pn]:{exposure:"hidden"},[Su]:{exposure:"event"},[$u]:{exposure:"event"},[ku]:{exposure:"event"},[Eu]:{exposure:"event"},[pa]:{exposure:"event"},[va]:{exposure:"event"},[ga]:{exposure:"event"},[ju]:{exposure:"event"},[Bu]:{exposure:"event"},[qu]:{exposure:"event"},[zu]:{exposure:"event"},[Hu]:{exposure:"event"},[Uu]:{exposure:"event"},[Vu]:{exposure:"event"},[Wu]:{exposure:"event"}},fc=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],pe=e=>{const t=hc[e];if(t)return t;for(const[s,i]of fc)if(e.indexOf(s)===0)return i},Pt=(e,t)=>{try{let s;return JSON.stringify(e,(i,n)=>{var r;return hs(n)?((r=s)!==null&&r!==void 0||(s=new WeakMap),s.has(n)||s.set(n,ma(n)),s.get(n)):typeof n=="bigint"?n.toString():n},t)}catch{return uo(e)}},Rt=e=>{const t=w==null?void 0:w.createElement("a");return b(t)?null:(t.href=e,t)},At=function(e,t){const s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let i;for(let n=0;s.length>n;n++){const r=s[n].split("=");if(r[0]===t){i=r;break}}if(!R(i)||2>i.length)return"";{let n=i[1];try{n=decodeURIComponent(n)}catch{k.error("Skipping decoding for malformed query param: "+n)}return n.replace(/\+/g," ")}},cs=function(e,t,s){if(!e||!t||!t.length)return e;const i=e.split("#"),n=i[1],r=(i[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),u=[];for(let d=0;l.length>d;d++){const f=l[d].split("=");R(f)&&(t.includes(f[0])?u.push(f[0]+"="+s):u.push(l[d]))}let c=a;return o!=null&&(c+="?"+u.join("&")),n!=null&&(c+="#"+n),c},Us=function(e,t){const s=e.match(new RegExp(t+"=([^&]*)"));return s?s[1]:null},Ca=(e,t)=>e>=t&&lo(),Ra=(e,t,s,i)=>{if(e===0){if(lo()){const n=t+1;return n===s&&i(),n}return t}return 0},Mt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],pc=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Mt],ds="<masked>",vc=["li_fat_id"];function Aa(e,t,s){if(!w)return{};const i=t?[...Mt,...s||[]]:[],n=Ma(cs(w.URL,i,ds),e),r=(function(){const o={};return q(vc,function(a){const l=rn(a);o[a]=l||null}),o})();return Y(r,n)}function Ma(e,t){const s=pc.concat(t||[]),i={};return q(s,function(n){const r=At(e,n);i[n]=r||null}),i}function Ta(e){const 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),s=t!="yahoo"?"q":"p",i={};if(!se(t)){i.$search_engine=t;const n=w?At(w.referrer,s):"";n.length&&(i.ph_keyword=n)}return i}function La(){return navigator.language||navigator.userLanguage}function gc(){const e=La();return typeof e=="string"?e.split("-")[0]:void 0}const Vs="$direct";function Da(){return(w==null?void 0:w.referrer)||Vs}function Na(e,t,s=!1){const i=e?[...Mt,...t||[]]:[],n=s?ot(ee==null?void 0:ee.href):ee==null?void 0:ee.href,r=n==null?void 0:n.substring(0,1e3);return{r:Da().substring(0,1e3),u:r?cs(r,i,ds):void 0}}function ja(e,t=!1){var s;const{r:i,u:n}=e,r=t?ot(n):n,o={$referrer:i,$referring_domain:i==null?void 0:i==Vs?Vs:(s=Rt(i))===null||s===void 0?void 0:s.host};if(r){o.$current_url=r;const a=Rt(r);o.$host=a==null?void 0:a.host,o.$pathname=a==null?void 0:a.pathname;const l=Ma(r);Y(o,l)}if(i){const a=Ta(i);Y(o,a)}return o}function Ba(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function _c(){try{return new Date().getTimezoneOffset()}catch{return}}const mc={flags:rt,surveys:qs},yc=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],ys=e=>`${e}_cookie_identity_change_pending`,bs=e=>{let t="",s=0;for(const i of e){const n=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+n>1e3)break;t+=i,s+=n}return t},de="main",Ue=[Ae,Ve,vt,tt,gt,rt,Zt,st],bi=e=>Ue.indexOf(e)!==-1,Xe=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},bt=e=>{if(!e)return{};const t=JSON.parse(e);return T(t)?t:{}},Pr=(e,t)=>{q(e,(s,i)=>{const n=pe(i);n&&n.exposure!=="event"||{}.hasOwnProperty.call(t,i)||delete e[i]})};var wi=class{constructor(e,t,s=!0){if(this.Lo={},this.No=!1,this.qo=!1,this.jo=!1,this.Bo=!1,this.Ho=!1,this.zo=new Map,this.Uo=!1,this.Wo=!1,this.Vo=!1,this.Go=!1,this.Zo=new Set,this.Sr=e,this.Qo=s,this.props={},this.Jo=void 0,this.Ko=(i=>{let n="";return i.token&&(n=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+n+"_posthog"})(e),this.$o=this.Yo(e),this.jo=this.Xo(e),this.load(),this.tl(),e.debug&&k.info("Persistence loaded",e.persistence,p({},this.props)),this.update_config(e,e,t),this.save(),y){const i=()=>this.flush();U(y,"beforeunload",i,{capture:!1}),U(y,"pagehide",i,{capture:!1}),this.el=n=>{if(this.No&&(!n.storageArea||n.storageArea===(y==null?void 0:y.localStorage))&&n.key)if(n.key!==this.Ko){if(this.jo){const r=Bt.find(o=>n.key===this.il(o));r&&this.nl(n.key,r)}}else this.nl(n.key,de)},U(y,"storage",this.el)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,s])=>{const i=this.zo.get(t);if(!bi(t)||i===!0)return;if(s===!0)return void this.sl(t,!0);const n=new Set(i||[]);s.forEach(r=>n.add(r)),n.size&&this.sl(t,n)})}onCrossTabFeatureFlagChange(e){return this.Zo.add(e),()=>this.Zo.delete(e)}destroy(){this.el&&y&&(y.removeEventListener("storage",this.el),this.el=void 0),this.Zo.clear()}nl(e,t,s=!0){if(this.pi)return!1;let i,n;try{if(n=N.Ot(e),se(n)){const a=this.rl(t);return a.storageValue=null,t!==de&&(a.persisted=!1),!1}i=bt(n)}catch{return!1}const r=t===de?i:N.Dt(this.Ko);if(r&&this.ol(r))return!1;const o=this.ll(i,t,s);return t===de&&this.jo&&!Xe(this.al().main,i)||this.ul(i,t,!0,n),o}ol(e){const t=this.props[Ce],s=e[Ce];return!b(t)&&!b(s)&&t!==s}ul(e,t,s,i){const n=this.rl(t);n.storageValue=i,t!==de&&(n.persisted=s);try{n.fingerprint=this.hl(e,t)}catch{n.fingerprint=void 0}}ll(e,t,s){let i=!1;return Ue.forEach(n=>{var r;const o=(r=pe(n))===null||r===void 0?void 0:r.storageGroup;if(t===de&&this.jo&&o||t!==de&&o!==t)return;const a=n in e,l=this.cl(n,a?e[n]:void 0),u=this.zo.has(n)?n in this.props:a;u===n in this.props&&Xe(l,this.props[n])||(u?this.dl(n,l,!1):this.vl(n,!1),i=!0)}),i&&s&&this.Zo.forEach(n=>n()),i}fl(){if(!this.No)return!1;try{this.Vo=!1;const e=N.Ot(this.Ko),t=this.rl(de);let s,i=!1,n=!1;if(e!==t.storageValue)if(se(e))t.storageValue=null;else{if(s=bt(e),this.Vo=!this.Wo&&this.ol(s),this.Vo)return!1;n=this.ll(s,de,!1),!this.jo||Xe(this.al().main,s)?this.ul(s,de,!0,e):t.storageValue=e,i=!0}return this.jo&&Bt.forEach(r=>{const o=N.Ot(this.il(r)),a=this.rl(r),l=s||{},u=i&&Ue.some(d=>{var f;return((f=pe(d))===null||f===void 0?void 0:f.storageGroup)===r&&d in l});if(o===a.storageValue&&!u)return;if(se(o))return a.storageValue=null,a.persisted=!1,void(u&&(n=this.ll(l,r,!1)||n));const c=bt(o);n=this.ll(c,r,!1)||n,this.ul(c,r,!0,o)}),n}catch{return!1}}sl(e,t){this.zo.set(e,t);const s=pe(e);s!=null&&s.volatile||(this.rl((this.jo?s==null?void 0:s.storageGroup:void 0)||de).fingerprint=void 0,this.pl(e))}gl(){Ue.forEach(e=>this.zo.set(e,!0))}tl(){if(this.No)try{const e=N.Ot(this.Ko),t=bt(e);this.rl(de).storageValue=e,Ue.forEach(s=>{var i;const n=this.jo?(i=pe(s))===null||i===void 0?void 0:i.storageGroup:void 0,r=n?N.Ot(this.il(n)):null;if(n){const a=this.rl(n);a.storageValue=r,a.persisted=!se(r)}const o=n&&!se(r)?bt(r):t;s in this.props?this.ml(s,o[s],this.props[s]):s in o&&this.sl(s,!0)})}catch{}}cl(e,t){const s=this.zo.get(e);if(!s)return t;if(s===!0)return this.props[e];if(e==="$active_feature_flags"){const r=new Set(R(t)?t:[]),o=new Set(R(this.props[e])?this.props[e]:[]);return s.forEach(a=>o.has(a)?r.add(a):r.delete(a)),Array.from(r)}const i=T(t)?p({},t):{},n=T(this.props[e])?this.props[e]:{};return s.forEach(r=>{r in n?i[r]=n[r]:delete i[r]}),i}ml(e,t,s){if(!bi(e))return;const i=this.zo.get(e);if(i===!0)return;let n=t;if(this.No)try{var r;const a=this.jo?(r=pe(e))===null||r===void 0?void 0:r.storageGroup:void 0,l=a?this.il(a):this.Ko;n=bt(N.Ot(l))[e]}catch{}const o=new Set(i||[]);if(e==="$active_feature_flags"){if(!b(t)&&!R(t)||!b(n)&&!R(n)||!R(s))return void this.sl(e,!0);const a=new Set(t||[]),l=new Set(n||[]),u=new Set(s);new Set([...a,...u]).forEach(c=>{a.has(c)!==u.has(c)&&o.add(c)}),o.forEach(c=>{l.has(c)===u.has(c)&&o.delete(c)})}else{if(!T(s))return void(Xe(n,s)?this.zo.delete(e):this.sl(e,!0));{if(!b(t)&&!T(t)||b(t)&&$e(s)&&b(n))return void this.sl(e,!0);const a=T(t)?t:{},l=T(n)?n:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(u=>{u in a==u in s&&Xe(a[u],s[u])||o.add(u)}),o.forEach(u=>{u in l==u in s&&Xe(l[u],s[u])&&o.delete(u)})}}o.size?this.sl(e,o):this.zo.delete(e)}yl(){var e;const t=(e=this.Sr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return ie(t)&&t>0?t:0}bl(e){if(this.Sr.cookieWinsOnConflict&&this.Sr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=_i(e,this.Sr.cookie_persisted_properties||[]),s=hr(t,this.Sr.cookie_persisted_properties||[]),i=JSON.stringify(t)+"|"+JSON.stringify(s),n=Q.Ot(this.Ko)||void 0;n&&mi(this.Ko,n)===i&&(this._l=i,this.wl=n)}catch{}else try{const t=Q.Ot(this.Ko)||void 0;this._l=t?mi(this.Ko,t):void 0,this.wl=t}catch{}}syncCookieProperties(){return this.kl(this.Sr)}kl(e,t=!1){if(this.pi&&!t||this.Ho||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=Q.Ot(this.Ko)||void 0}catch{}if(!s||s===this.wl)return!1;const i=mi(this.Ko,s);let n;try{n=gi(JSON.parse(s))}catch{return!1}if((Q.Ot(this.Ko)||void 0)!==s)return!1;this._l=i,this.wl=s;const r=fr(this.Ko,s),o=[...pt,...r.properties],a={};if(Object.keys(n).forEach(v=>{const _=n[v];(b(_)||se(_)||_===""||v==="$user_state"&&_!=="anonymous"&&_!=="identified")&&(a[v]=!0,delete n[v])}),$e(n))return!1;const l="distinct_id"in n||n.$user_state==="anonymous"||n.$user_state==="identified",u=this.props,c=u[Ce],d=u[be],f=Y({},u);[...pt,...e.cookie_persisted_properties||[]].forEach(v=>{if(o.indexOf(v)!==-1&&!(v in n)&&!a[v]&&(l||v!=="distinct_id"&&v!=="$user_state")){const _=f[v];(r.isValid||pt.indexOf(v)===-1||_!==!1&&_!==0)&&delete f[v]}}),this.props=Y(f,n),Ue.forEach(v=>{const _=v in this.props;v in u===_&&Xe(u[v],this.props[v])||(_?this.ml(v,u[v],this.props[v]):this.sl(v,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this.dl(be,We);const h=this.props[Ce],g=this.props[be];return!l||h===c&&g===d||(this.Wo=!0,this.Bo=!0,K.At(ys(this.Ko),!0),this.vl(st),this.vl(Ve),this.vl(Ae),this.vl(vt),this.vl(tt),this.vl(gt),this.vl(rt),this.vl(os),this.vl(nt),g!=="anonymous"||d!=="identified"&&n.$user_state!=="anonymous"&&(b(c)||h===c)||(Pr(this.props,n),this.vl(it)),g==="identified"?this.props.$user_id=h:delete this.props.$user_id,this.vl(Bs)),!0}consumeCookieIdentityChange(){const e=ys(this.Ko),t=this.Bo||!!K.Ot(e);return this.Bo=!1,t&&K.Lt(e),t}Sl(e=!1){return!(this.Ho||this.pi&&!e||!this.Sr.cookieWinsOnConflict||this.Sr.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ho=!0,0))}xl(){this.Ho&&(b(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0),delete this.Lo[de],this.$l(!0))}Tl(e=!0){if(this.Ho)try{e?this.xl():b(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0)}finally{this.Ho=!1}}isDisabled(){return!!this.pi}Yo(e){yc.indexOf(e.persistence.toLowerCase())===-1&&(k.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((o=[],a=!1)=>{const l=[...pt,...o];return p(p({},N),{},{Dt(u){try{let d,f={};try{d=Q.Ot(u)||void 0,f=d?gi(JSON.parse(d)):{}}catch{}const h=JSON.parse(N.Ot(u)||"{}");let g;if(a){const v=fr(u,d),_=[...pt,...v.properties],m={};Object.keys(f).forEach(S=>{const C=f[S];se(C)||C===""||S==="$user_state"&&C!=="anonymous"&&C!=="identified"||(m[S]=C)});const x="distinct_id"in m||m.$user_state==="anonymous"||m.$user_state==="identified";if(Object.keys(m).length>0){var c;const S=h[Ce],C=(c=h.$user_state)!==null&&c!==void 0?c:We;l.forEach($=>{if(_.indexOf($)!==-1&&!($ in f)&&(x||$!=="distinct_id"&&$!=="$user_state")){const F=h[$];(v.isValid||pt.indexOf($)===-1||F!==!1&&F!==0)&&delete h[$]}}),!x||"$user_state"in f||"$user_state"in h||(h[be]=We),!x||("distinct_id"in m?m[Ce]:h[Ce])===S&&("$user_state"in m?m[be]:h[be])===C||(vi.forEach($=>delete h[$]),m.$user_state==="identified"&&"distinct_id"in m?h.$user_id=m[Ce]:delete h.$user_id,m.$user_state!=="identified"&&(delete h[aa],delete h[it]),delete h.__alias)}g=Y(h,m)}else g=Y(f,h);return N.At(u,g),g}catch{}return null},At(u,c,d,f,h,g){const v=N.At(u,c,void 0,void 0,g);try{const _=_i(c,o);if(Object.keys(_).length){if(a){const m=Hs(u),x=hr(_,o);if(Q.At(m,x,d,f,h,g),Q.Ot(m)!==JSON.stringify(x)){Q.Lt(m,f);const S=_i(c);return Q.At(u,S,d,f,h,g),v}}Q.At(u,_,d,f,h,g)}}catch(_){N.Pt(_)}return v},Lt(u,c){try{y==null||y.localStorage.removeItem(u),Q.Lt(u,c),Q.Lt(Hs(u),c)}catch(d){N.Pt(d)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict);let s,i=!1,n=!1;const r=e.persistence.toLowerCase();return r==="localstorage"&&N.Et()?(s=N,n=!0):r==="localstorage+cookie"&&t.Et()?(s=t,n=!0,i=!0):r==="sessionstorage"&&K.Et()?s=K:r==="memory"?s=an:r==="cookie"&&Q.Et()?(s=Q,i=!0):t.Et()?(s=t,n=!0,i=!0):Q.Et()?(s=Q,i=!0):s=an,this.No=n,this.qo=i,s}il(e){return`${this.Ko}__${e}`}Xo(e){return this.No&&!!e.split_storage}properties(){const e={};return q(this.props,(t,s)=>{const i=pe(s);if(!i||i.exposure==="event"){var n;if(!(i==null||(n=i.shouldSkipFromEventProperties)===null||n===void 0)&&n.call(i,t))return;e[s]=t}}),e}load(e=!1){if(this.pi&&!e)return;const t=this.Sr.cookieWinsOnConflict&&this.Sr.persistence.toLowerCase()==="localstorage+cookie",s=t?N.Dt(this.Ko):null;let i={};if(t)try{i=gi(Q.Dt(this.Ko)),q(i,(a,l)=>{(b(a)||se(a)||a==="")&&delete i[l]})}catch{}const n=this.$o.Dt(this.Ko);if(n&&(this.props=Y({},n)),this.jo&&this.Il(),t&&n){var r,o;const a=s==null?void 0:s[Ce],l=(r=s==null?void 0:s.$user_state)!==null&&r!==void 0?r:We,u=n[Ce],c=(o=n.$user_state)!==null&&o!==void 0?o:We;if(u!==a||c!==l){this.Bo=!0,K.At(ys(this.Ko),!0);const d=Y({},this.props);vi.forEach(h=>delete d[h]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(b(a)||u===a)||(Pr(d,i),delete d[it]),this.props=d;const f=new Set;vi.forEach(h=>{var g;const v=(g=pe(h))===null||g===void 0?void 0:g.storageGroup;v&&f.add(v)}),f.forEach(h=>{const g={};q(this.props,(v,_)=>{var m;((m=pe(_))===null||m===void 0?void 0:m.storageGroup)===h&&(g[_]=v)}),$e(g)?(N.Lt(this.il(h)),this.Lo[h]={}):N.At(this.il(h),g)&&(this.Lo[h]={persisted:!0,fingerprint:this.hl(g,h)})})}}K.Ot(ys(this.Ko))&&(this.Bo=!0)}Il(){for(const e of Bt){const t=N.Dt(this.il(e));if(t&&!$e(t)){const s=this.rl(e);s.persisted=!0,this.Ml(e)||(s.fingerprint=this.hl(t,e)),this.El(e,t)||Y(this.props,t)}}}Ml(e){return Object.keys(this.props).some(t=>{var s;return((s=pe(t))===null||s===void 0?void 0:s.storageGroup)===e})}El(e,t){const s=mc[e];if(!s)return!1;const i=t[s],n=this.props[s];return ie(i)&&ie(n)&&n>i}refreshKey(e){var t;if(this.pi||e==="$fbc_persistence"&&this.Go)return;const s=this.jo?(t=pe(e))===null||t===void 0?void 0:t.storageGroup:void 0,i=s?N.Dt(this.il(s)):this.$o.Dt(this.Ko);if(i&&e in i)this.dl(e,i[e],!1);else{if(s){const n=this.$o.Dt(this.Ko);if(n&&e in n)return void this.dl(e,n[e],!1)}this.vl(e,!1)}}save(){if(this.pi)return;const e=this.yl();e>0?b(this.Cl)&&(this.Cl=setTimeout(()=>{this.Cl=void 0,this.$l()},e)):this.$l()}flush(){b(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0,this.$l())}$l(e=!1){if(this.pi||this.Ho&&!e)return;e||(this.syncCookieProperties(),this.Go||this.Sr.cookieWinsOnConflict&&this.Sr.persistence.toLowerCase()==="localstorage+cookie"||this.refreshKey(Re));const t=!e&&!this.Uo;t||(this.Vo=!1);const s=!!t&&this.fl();if(this.Vo)return void(this.Sr.debug&&k.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.jo)return this.Pl(),void(s&&this.Zo.forEach(n=>n()));const i=this.Rl(this.$o,this.Ko,this.props,de);i==="written"&&this.bl(this.props),i!=="failed"&&(this.zo.clear(),this.Wo=!1,this.Go=!1),s&&this.Zo.forEach(n=>n())}Pl(){const{main:e,groups:t}=this.al(),s=this.Rl(this.$o,this.Ko,e,de);s==="written"&&this.bl(e),s!=="failed"&&(this.Wo=!1,this.Go=!1,Ue.forEach(n=>{var r;!((r=pe(n))===null||r===void 0)&&r.storageGroup||this.zo.delete(n)}));for(const n of Bt){var i;const r=t[n];if($e(r)&&!(!((i=this.Lo[n])===null||i===void 0)&&i.persisted)){Ue.forEach(a=>{var l;((l=pe(a))===null||l===void 0?void 0:l.storageGroup)===n&&this.zo.delete(a)});continue}const o=this.Rl(N,this.il(n),r,n);o!=="failed"&&Ue.forEach(a=>{const l=pe(a);(l==null?void 0:l.storageGroup)!==n||o!=="written"&&l.volatile||this.zo.delete(a)})}}al(){const e={},t={flags:{},surveys:{}};return q(this.props,(s,i)=>{var n;const r=(n=pe(i))===null||n===void 0?void 0:n.storageGroup;r?t[r][i]=s:e[i]=s}),{main:e,groups:t}}hl(e,t){if(t===de)return JSON.stringify(e)+"|"+this.Al+"|"+this.Fl+"|"+this.Ol;const s={};return q(e,(i,n)=>{var r;s[n]=!((r=pe(n))===null||r===void 0)&&r.volatile?"__volatile__":i}),JSON.stringify(s)}Rl(e,t,s,i){const n=this.rl(i);if(i!==de&&!n.dirty&&!b(n.fingerprint))return"skipped";let r;try{if(r=this.hl(s,i),r===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return e.At(t,s,this.Al,this.Fl,this.Ol,this.Sr.debug)?(n.dirty=!1,i!==de&&(n.persisted=!0),b(r)||(n.fingerprint=r),this.No&&(n.storageValue=N.Ot(t)),"written"):(this.Sr.debug&&k.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.gl(),b(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0),this.$o.Lt(this.Ko,!1),this.$o.Lt(this.Ko,!0),!e&&this.Qo)for(const t of Bt)N.Lt(this.il(t));e?delete this.Lo[de]:this.Lo={},this._l=void 0,this.wl=void 0}clear(){this.remove(),this.props={}}register_once(e,t,s){if(T(e)){this.syncCookieProperties(),b(t)&&(t="None"),this.Al=b(s)?this.Dl:s;let i=!1;if(q(e,(n,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==t||(this.dl(r,n),i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(T(e)){this.syncCookieProperties(),this.Al=b(t)?this.Dl:t;let s=!1;if(q(e,(i,n)=>{e.hasOwnProperty(n)&&(this.props[n]!==i||T(i)||R(i))&&(this.dl(n,i),s=!0)}),s)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t=typeof e=="string"?[e]:e;let s=!1;for(const i of t)i in this.props&&(this.vl(i),s=!0);s&&this.save()}update_campaign_params(){const e=w==null?void 0:w.URL;if(e===this.Jo)return;const t=Aa(this.Sr.custom_campaign_params,this.Sr.mask_personal_data_properties,this.Sr.custom_personal_data_properties),s=!$e(On(t));return s&&this.register(t),this.Jo=e,s?t:void 0}update_search_keyword(){this.register((function(){const e=w==null?void 0:w.referrer;return e?Ta(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:Da(),$referring_domain:(w==null?void 0:w.referrer)&&((e=Rt(w.referrer))===null||e===void 0?void 0:e.host)||Vs},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Na(this.Sr.mask_personal_data_properties,this.Sr.custom_personal_data_properties,this.Sr.disable_capture_url_hashes);this.register_once({[Et]:this.qo?{r:bs(e.r),u:e.u?bs(e.u):void 0}:e},void 0)}get_initial_props(){const e={};q([ha,da],s=>{const i=this.props[s];i&&q(i,function(n,r){e["$initial_"+ji(r)]=n})});const t=this.props[Et];if(t){const s=(function(i,n=!1){const r=ja(i,n),o={};return q(r,function(a,l){o[`$initial_${ji(l)}`]=a}),o})(t,this.Sr.disable_capture_url_hashes);Y(e,s)}return e}safe_merge(e){return q(this.props,function(t,s){s in e||(e[s]=t)}),e}update_config(e,t,s){const i=e.persistence!==t.persistence,n=!((h,g)=>{if(h.length!==g.length)return!1;const v=[...h].sort(),_=[...g].sort();return v.every((m,x)=>m===_[x])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=i||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!s,l=!!this.pi&&!a;a||this.kl(t,l),this.Sr=e,!a&&(i||n||o)&&(this._l=void 0,this.wl=void 0,this.kl(p(p({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const u=r||o?this.Yo(e):this.$o;this.Ll();const c=this.Xo(e),d=r||c!==this.jo,f=!a&&(d||e.cross_subdomain_cookie!==this.Fl||e.secure_cookie!==this.Ol)&&this.Sl(l);this.Uo=d;try{if(this.Dl=this.Al=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const h=this.props;this.clear(),this.$o=u,this.jo=c,this.props=h,this.save()}else o&&(this.$o=u,a||(delete this.Lo[de],this.$l()))}finally{this.Uo=!1,f&&this.Tl()}}Ll(){const e=this.props[Et];if(!this.qo||!T(e)||typeof e.r!="string")return;const t=bs(e.r),s=typeof e.u=="string"?bs(e.u):e.u;t===e.r&&s===e.u||this.dl(Et,p(p({},e),{},{r:t,u:s}))}set_disabled(e){this.pi=e,this.pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Fl&&(this.Fl=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Ol&&(this.Ol=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const s=this.props.__timers||{};s[e]=t,this.dl(Gi,s),this.save()}remove_event_timer(e){const t=this.props.__timers||{},s=t[e];return b(s)||(delete t[e],this.dl(Gi,t),this.save()),s}get_property(e){return this.props[e]}set_property(e,t){this.dl(e,t),this.save()}dl(e,t,s=!0){var i;const n=this.props[e];this.props[e]=t,s&&(e!=="distinct_id"&&e!=="$user_state"||n===t||(this.Wo=!0),e!=="$fbc_persistence"||Xe(n,t)||(this.Go=!0),this.ml(e,n,t),!((i=pe(e))===null||i===void 0)&&i.volatile||this.pl(e))}vl(e,t=!0){delete this.props[e],t&&(bi(e)&&this.sl(e,!0),e==="$fbc_persistence"&&(this.Go=!0),this.pl(e))}pl(e){var t;const s=(t=pe(e))===null||t===void 0?void 0:t.storageGroup;s&&(this.rl(s).dirty=!0)}rl(e){return this.Lo[e]||(this.Lo[e]={})}};const Ee={GZipJS:"gzip-js",Base64:"base64"},qt={Activation:"events",Cancellation:"cancelEvents"},xi={Popover:"popover",API:"api",Widget:"widget"},Ge={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Si={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},cn={Popover:"popover",Inline:"inline"};function ws(e){let t=!0;return{dispose(){if(t){t=!1;const s=e();s&&ve(s.then)&&s.then(void 0,()=>{})}}}}const bc={SHOWN:"product tour shown"},Fr={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Ir=ne("[RateLimiter]");var wc=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{Ir.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void Ir.warn(`could not rate limit - continuing. Error: "${i==null?void 0:i.message}"`,{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,s,i;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=new Date().getTime(),a=(t=(s=this.instance.persistence)===null||s===void 0?void 0:s.get_property("$capture_rate_limit"))!==null&&t!==void 0?t:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*r,a.last=o,a.tokens>n&&(a.tokens=n);const l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){const u=(ie(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Nl(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}ql(e){const t=this.instance.config.property_denylist;return!R(t)||!t.includes(e)}jl(){var e;if(this.ql("$current_url")&&this.ql("$pathname")&&(ee!=null&&ee.pathname))return`${(e=ee.origin)!==null&&e!==void 0?e:""}${ee.pathname}`}Nl(e){var t,s;const{captureEventsBurstLimit:i,captureEventsPerSecond:n}=this,r=this.jl(),o=this.ql("$session_id")?(t=(s=this.instance).get_session_id)===null||t===void 0?void 0:t.call(s):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${n} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}};const Qe=ne("[RemoteConfig]");var qa=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Bl(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}Hl(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 Qe.info("Using preloaded remote config",this.remoteConfig),void this.zl(this.remoteConfig);if(this._instance.Ul())return void Qe.warn("Remote config is disabled. Falling back to local config.");this.Bl(e=>{if(!e)return Qe.info("No config found after loading remote JS config. Falling back to JSON."),void this.Hl(t=>{this.zl(t.json,t)});this.zl(e)})}catch(e){Qe.error("Error loading remote config",e),this.zl()}}zl(e,t){!e&&t&&(t.statusCode===0?t.error||Qe.warn("Failed to fetch remote config from PostHog."):Qe.error("Failed to fetch remote config from PostHog."));try{this._instance.zl(e?{ok:!0,config:e}:{ok:!1})}catch(i){Qe.error("Error applying remote config",i)}if((e==null?void 0:e.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)===null||s===void 0||s.ensureFlagsLoaded()}catch(i){Qe.error("Error loading feature flags",i)}}},Fe=Uint8Array,ke=Uint16Array,Tt=Uint32Array,Tn=new Fe([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]),Ln=new Fe([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]),Or=new Fe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),za=function(e,t){for(var s=new ke(31),i=0;31>i;++i)s[i]=t+=1<<e[i-1];var n=new Tt(s[30]);for(i=1;30>i;++i)for(var r=s[i];s[i+1]>r;++r)n[r]=r-s[i]<<5|i;return[s,n]},Ha=za(Tn,2),dn=Ha[1];Ha[0][28]=258,dn[258]=28;for(var Cr=za(Ln,0)[1],Ua=new ke(32768),te=0;32768>te;++te){var wt=(43690&te)>>>1|(21845&te)<<1;Ua[te]=((65280&(wt=(61680&(wt=(52428&wt)>>>2|(13107&wt)<<2))>>>4|(3855&wt)<<4))>>>8|(255&wt)<<8)>>>1}var es=function(e,t,s){for(var i=e.length,n=0,r=new ke(t);i>n;++n)++r[e[n]-1];var o,a=new ke(t);for(n=0;t>n;++n)a[n]=a[n-1]+r[n-1]<<1;for(o=new ke(i),n=0;i>n;++n)o[n]=Ua[a[e[n]-1]++]>>>15-e[n];return o},_t=new Fe(288);for(te=0;144>te;++te)_t[te]=8;for(te=144;256>te;++te)_t[te]=9;for(te=256;280>te;++te)_t[te]=7;for(te=280;288>te;++te)_t[te]=8;var Ws=new Fe(32);for(te=0;32>te;++te)Ws[te]=5;var xc=es(_t,9),Sc=es(Ws,5),Va=function(e){return(e/8|0)+(7&e&&1)},Wa=function(e,t,s){(s==null||s>e.length)&&(s=e.length);var i=new(e instanceof ke?ke:e instanceof Tt?Tt:Fe)(s-t);return i.set(e.subarray(t,s)),i},qe=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8},zt=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8,e[i+2]|=s>>>16},$i=function(e,t){for(var s=[],i=0;e.length>i;++i)e[i]&&s.push({s:i,f:e[i]});var n=s.length,r=s.slice();if(!n)return[new Fe(0),0];if(n==1){var o=new Fe(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function($,F){return $.f-F.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],u=0,c=1,d=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=n-1;)a=s[s[d].f>s[u].f?u++:d++],l=s[u!=c&&s[d].f>s[u].f?u++:d++],s[c++]={s:-1,f:a.f+l.f,l:a,r:l};var f=r[0].s;for(i=1;n>i;++i)r[i].s>f&&(f=r[i].s);var h=new ke(f+1),g=hn(s[c-1],h,0);if(g>t){i=0;var v=0,_=g-t,m=1<<_;for(r.sort(function($,F){return h[F.s]-h[$.s]||$.f-F.f});n>i;++i){var x=r[i].s;if(t>=h[x])break;v+=m-(1<<g-h[x]),h[x]=t}for(v>>>=_;v>0;){var S=r[i].s;t>h[S]?v-=1<<t-h[S]++-1:++i}for(;i>=0&&v;--i){var C=r[i].s;h[C]==t&&(--h[C],++v)}g=t}return[new Fe(h),g]},hn=function(e,t,s){return e.s==-1?Math.max(hn(e.l,t,s+1),hn(e.r,t,s+1)):t[e.s]=s},Rr=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new ke(++t),i=0,n=e[0],r=1,o=function(l){s[i++]=l},a=1;t>=a;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[s.subarray(0,i),t]},Ht=function(e,t){for(var s=0,i=0;t.length>i;++i)s+=e[i]*t[i];return s},fn=function(e,t,s){var i=s.length,n=Va(t+2);e[n]=255&i,e[n+1]=i>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;i>r;++r)e[n+r+4]=s[r];return 8*(n+4+i)},Ar=function(e,t,s,i,n,r,o,a,l,u,c){qe(t,c++,s),++n[256];for(var d=$i(n,15),f=d[0],h=d[1],g=$i(r,15),v=g[0],_=g[1],m=Rr(f),x=m[0],S=m[1],C=Rr(v),$=C[0],F=C[1],I=new ke(19),E=0;x.length>E;++E)I[31&x[E]]++;for(E=0;$.length>E;++E)I[31&$[E]]++;for(var P=$i(I,7),D=P[0],B=P[1],z=19;z>4&&!D[Or[z-1]];--z);var G,V,re,W,oe=u+5<<3,j=Ht(n,_t)+Ht(r,Ws)+o,J=Ht(n,f)+Ht(r,v)+o+14+3*z+Ht(I,D)+(2*I[16]+3*I[17]+7*I[18]);if(j>=oe&&J>=oe)return fn(t,c,e.subarray(l,l+u));if(qe(t,c,1+(j>J)),c+=2,j>J){G=es(f,h),V=f,re=es(v,_),W=v;var ue=es(D,B);for(qe(t,c,S-257),qe(t,c+5,F-1),qe(t,c+10,z-4),c+=14,E=0;z>E;++E)qe(t,c+3*E,D[Or[E]]);c+=3*z;for(var ae=[x,$],X=0;2>X;++X){var xe=ae[X];for(E=0;xe.length>E;++E)qe(t,c,ue[le=31&xe[E]]),c+=D[le],le>15&&(qe(t,c,xe[E]>>>5&127),c+=xe[E]>>>12)}}else G=xc,V=_t,re=Sc,W=Ws;for(E=0;a>E;++E)if(i[E]>255){var le;zt(t,c,G[257+(le=i[E]>>>18&31)]),c+=V[le+257],le>7&&(qe(t,c,i[E]>>>23&31),c+=Tn[le]);var ce=31&i[E];zt(t,c,re[ce]),c+=W[ce],ce>3&&(zt(t,c,i[E]>>>5&8191),c+=Ln[ce])}else zt(t,c,G[i[E]]),c+=V[i[E]];return zt(t,c,G[256]),c+V[256]},$c=new Tt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kc=(function(){for(var e=new Tt(256),t=0;256>t;++t){for(var s=t,i=9;--i;)s=(1&s&&3988292384)^s>>>1;e[t]=s}return e})(),ki=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function Ec(e,t){t===void 0&&(t={});var s=(function(){var d=4294967295;return{p(f){for(var h=d,g=0;f.length>g;++g)h=kc[255&h^f[g]]^h>>>8;d=h},d(){return 4294967295^d}}})(),i=e.length;s.p(e);var n,r,o,a,l,u=(a=10+((n=t).filename&&n.filename.length+1||0),l=8,(function(d,f,h,g,v,_){var m=d.length,x=new Fe(g+m+5*(1+Math.floor(m/7e3))+v),S=x.subarray(g,x.length-v),C=0;if(!f||8>m)for(var $=0;m>=$;$+=65535){var F=$+65535;m>F?C=fn(S,C,d.subarray($,F)):(S[$]=_,C=fn(S,C,d.subarray($,m)))}else{for(var I=$c[f-1],E=I>>>13,P=8191&I,D=(1<<h)-1,B=new ke(32768),z=new ke(D+1),G=Math.ceil(h/3),V=2*G,re=function(si){return(d[si]^d[si+1]<<G^d[si+2]<<V)&D},W=new Tt(25e3),oe=new ke(288),j=new ke(32),J=0,ue=0,ae=($=0,0),X=0,xe=0;m>$;++$){var le=re($),ce=32767&$,Ie=z[le];if(B[ce]=Ie,z[le]=ce,$>=X){var Ke=m-$;if((J>7e3||ae>24576)&&Ke>423){C=Ar(d,S,0,W,oe,j,ue,ae,xe,$-xe,C),ae=J=ue=0,xe=$;for(var Se=0;286>Se;++Se)oe[Se]=0;for(Se=0;30>Se;++Se)j[Se]=0}var Te=2,at=0,hl=P,Ye=ce-Ie&32767;if(Ke>2&&le==re($-Ye))for(var fl=Math.min(E,Ke)-1,pl=Math.min(32767,$),vl=Math.min(258,Ke);pl>=Ye&&--hl&&ce!=Ie;){if(d[$+Te]==d[$+Te-Ye]){for(var Ze=0;vl>Ze&&d[$+Ze]==d[$+Ze-Ye];++Ze);if(Ze>Te){if(Te=Ze,at=Ye,Ze>fl)break;var gl=Math.min(Ye,Ze-2),Dn=0;for(Se=0;gl>Se;++Se){var ti=$-Ye+Se+32768&32767,Nn=ti-B[ti]+32768&32767;Nn>Dn&&(Dn=Nn,Ie=ti)}}}Ye+=(ce=Ie)-(Ie=B[ce])+32768&32767}if(at){W[ae++]=268435456|dn[Te]<<18|Cr[at];var jn=31&dn[Te],Bn=31&Cr[at];ue+=Tn[jn]+Ln[Bn],++oe[257+jn],++j[Bn],X=$+Te,++J}else W[ae++]=d[$],++oe[d[$]]}}C=Ar(d,S,_,W,oe,j,ue,ae,xe,$-xe,C)}return Wa(x,0,g+Va(C)+v)})(r=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,a,l,!0)),c=u.length;return(function(d,f){var h=f.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>f.level?4:f.level==9?2:0,d[9]=3,f.mtime!=0&&ki(d,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),h){d[3]=8;for(var g=0;h.length>=g;++g)d[g+10]=h.charCodeAt(g)}})(u,t),ki(u,c-8,s.d()),ki(u,c-4,i),u}const Pc=!!_n||!!ns,Ga="text/plain";let Os=!1;const Ja=(e,t)=>{const[s,i]=e.split("#"),[n,r]=s.split("?");if(!r)return e;const o=r.split("&").filter(a=>a.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${i?`#${i}`:""}`},fs=(e,t,s=!0)=>{var i;const[n,r]=e.split("?"),o=p({},t),a=(i=r==null?void 0:r.split("&").map(u=>{var c;const[d,f]=u.split("="),h=s&&(c=o[d])!==null&&c!==void 0?c:f;return delete o[d],`${d}=${h}`}))!==null&&i!==void 0?i:[],l=(function(u,c="&"){let d,f;const h=[];return q(u,function(g,v){b(g)||b(v)||v==="undefined"||(d=encodeURIComponent((_=>_ instanceof File)(g)?g.name:g.toString()),f=encodeURIComponent(v),h[h.length]=f+"="+d)}),h.join(c)})(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},Ei=e=>{if(e.Wl)return e.Wl;const{data:t,compression:s}=e;if(!t)return;if(s===Ee.GZipJS){const n=Ec((function(r){var o=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new Fe(r.length+(r.length>>>1)),l=0,u=function(h){a[l++]=h},c=0;o>c;++c){if(l+5>a.length){var d=new Fe(l+8+(o-c<<1));d.set(a),a=d}var f=r.charCodeAt(c);128>f?u(f):2048>f?(u(192|f>>>6),u(128|63&f)):f>55295&&57344>f?(u(240|(f=65536+(1047552&f)|1023&r.charCodeAt(++c))>>>18),u(128|f>>>12&63),u(128|f>>>6&63),u(128|63&f)):(u(224|f>>>12),u(128|f>>>6&63),u(128|63&f))}return Wa(a,0,l)})(Pt(t)),{mtime:0});return{contentType:Ga,body:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),estimatedSize:n.byteLength}}if(s===Ee.Base64){const n=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Pt(t)),r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Pt(o)))(n);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}const i=Pt(t);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},Ka=e=>{const t=()=>e.transport==="sendBeacon"?{url:fs(e.url,{compression:Ee.Base64}),encodedBody:Ei(p(p({},e),{},{compression:Ee.Base64,Wl:void 0}))}:{url:Ja(e.url,"compression"),encodedBody:Ei(p(p({},e),{},{compression:void 0,Wl:void 0}))};let s;try{s=Ei(e)}catch(n){if(tr(e.compression,At(e.url,"compression")))return k.error("Failed to gzip request body, sending uncompressed payload",n),t();throw n}return s&&tr(e.compression,At(e.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?Vi(new Uint8Array(i)):ArrayBuffer.isView(i)&&Vi(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Os=!0,t()):{url:e.url,encodedBody:s};var i},Ya=e=>{try{return Ka(e)}catch(s){var t;return k.error(s),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:s}))}},Fc=(function(){var e=Z(function*(t){const s=yield(function(n){return Wi.apply(this,arguments)})(Pt(t.data),he.DEBUG,{rethrow:!0});if(!s)return t;const i=yield s.arrayBuffer();return p(p({},t),{},{Wl:{contentType:Ga,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}})(),Ic=/Failed to fetch|NetworkError|Load failed/i,Za=e=>(e==null?void 0:e.name)==="TypeError"&&Ic.test((e==null?void 0:e.message)||""),Xa=e=>{const t=Ya(e);if(!t)return;const s=new _n,{url:i,encodedBody:n}=t;s.open(e.method||"GET",i,!0);const{contentType:r,body:o}=n??{};q(e.headers,function(a,l){s.setRequestHeader(l,a)}),r&&s.setRequestHeader("Content-Type",r),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a;const l={statusCode:s.status,text:s.responseText};if(s.status===200)try{l.json=JSON.parse(s.responseText)}catch{}(a=e.callback)===null||a===void 0||a.call(e,l)}},s.send(o)},Qa=e=>{const t=Ya(e);if(!t)return;const{url:s,encodedBody:i}=t,{contentType:n,body:r,estimatedSize:o}=i??{},a=new Headers;q(e.headers,function(d,f){a.append(f,d)}),n&&a.append("Content-Type",n);let l=null,u=!1;if(qn){const d=new qn;l={signal:d.signal,timeout:setTimeout(()=>{var f;u=!0,d.abort(zo("AbortError","PostHog request timed out"+((f=e.timeout)?` after ${f}ms`:"")))},e.timeout)}}const c=d=>{var f;u&&(d==null?void 0:d.name)==="AbortError"||Za(d)?k.warn(d):k.error(d),(f=e.callback)===null||f===void 0||f.call(e,{statusCode:0,error:d})};try{ns(s,p({method:(e==null?void 0:e.method)||"GET",headers:a,keepalive:e.method==="POST"&&!e.Vl&&52428.8>(o||0),body:r,signal:l==null?void 0:l.signal},e.fetchOptions)).then(d=>d.text().then(f=>{var h;const g={statusCode:d.status,text:f};if(d.status===200)try{g.json=JSON.parse(f)}catch(v){k.error(v)}(h=e.callback)===null||h===void 0||h.call(e,g)})).catch(c).finally(()=>l?clearTimeout(l.timeout):null)}catch(d){l&&clearTimeout(l.timeout),c(d)}},pn=e=>{try{var t;const{url:s,encodedBody:i}=Ka(e),{contentType:n,body:r,estimatedSize:o}=i??{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:n});if(fe.sendBeacon(s,a))return;const l=R(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(R(l)&&l.length>1&&(o??0)>16384){const u=Math.ceil(l.length/2),c=d=>R(e.data)?d:p(p({},e.data),{},{batch:d});return pn(p(p({},e),{},{data:c(l.slice(0,u))})),void pn(p(p({},e),{},{data:c(l.slice(u))}))}k.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${ns?"fetch":"XHR"}`),ns?Qa(p(p({},e),{},{Vl:!0})):Xa(e)}catch(s){k.warn("Beacon send failed",s)}},Mr=(e,t,s,i)=>{const n=i==="query"?t==="POST"?"sent_at":"_":void 0;return fs(s===Ee.GZipJS?Ja(e,"compression"):e,p(p({},n?{[n]:Date.now().toString()}:{}),s===Ee.GZipJS?{}:{compression:s}))},Oc=(()=>{const e=[];return ns&&e.push({transport:"fetch",method:Qa}),_n&&e.push({transport:"XHR",method:Xa}),fe!=null&&fe.sendBeacon&&e.push({transport:"sendBeacon",method:pn}),e})();var Cc=class{constructor(e,t){this.Gl=!0,this.Zl=[],this.Ql=je((t==null?void 0:t.flush_interval_ms)||3e3,250,5e3,k.createLogger("flush interval"),3e3),this.Jl=e}enqueue(e){this.Zl.push(e),this.Kl||this.Yl()}unload(){this.Xl();const e=this.Zl.length>0?this.ta():{},t=Object.values(e);[...t.filter(s=>s.url.indexOf("/e")===0),...t.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.ea(p(p({},s),{},{transport:"sendBeacon"}))})}enable(){this.Gl=!1,this.Yl()}Yl(){this.Gl||(this.Kl=setTimeout(()=>{if(this.Xl(),this.Zl.length>0){const e=this.ta();for(const t in e){const s=e[t],i=new Date().getTime();s.data&&R(s.data)&&q(s.data,n=>{n.offset=Math.abs(n.timestamp-i),delete n.timestamp}),this.ea(s)}}},this.Ql))}ea(e){try{this.Jl(e)}catch(t){k.error(t)}}Xl(){clearTimeout(this.Kl),this.Kl=void 0}ta(){const e={};return q(this.Zl,t=>{var s;const i=t,n=(i?i.batchKey:null)||i.url;b(e[n])&&(e[n]=p(p({},i),{},{data:[]})),(s=e[n].data)===null||s===void 0||s.push(i.data)}),this.Zl=[],e}};const Rc=["retriesPerformedSoFar"];var Ac=class{constructor(e){this._instance=e,this.ia=!1,this.na=3e3,this.Zl=[],this.Zl=[],this.sa=!0,this.resume()}resume(){if(!b(y)&&"onLine"in y.navigator){if(this.sa=y.navigator.onLine,this.ra)return;this.ra=()=>{this.sa=!0,this.oa()},this.la=()=>{this.sa=!1},U(y,"online",this.ra),U(y,"offline",this.la)}}get length(){return this.Zl.length}retriableRequest(e){let{retriesPerformedSoFar:t}=e,s=Ko(e,Rc);He(t)&&(s.url=fs(s.url,{retry_count:t})),this._instance._send_request(p(p({},s),{},{callback:i=>{var n;if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(t??0))return void this.Is(p({retriesPerformedSoFar:t},s));i.statusCode===0&&k.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${t??0} retries.`)}(n=s.callback)===null||n===void 0||n.call(s,i)}}))}Is(e){const t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;const s=(function(r){const o=3e3*Math.pow(2,r),a=o/2,l=Math.min(18e5,o),u=(Math.random()-.5)*(l-a);return Math.ceil(l+u)})(t),i=Date.now()+s;this.Zl.push({retryAt:i,requestOptions:e});let n=`Enqueued failed request for retry in ${s}`;navigator.onLine||(n+=" (Browser is offline)"),k.warn(n),this.ia||(this.ia=!0,this.aa())}aa(){if(this.ua&&clearTimeout(this.ua),this.Zl.length===0)return this.ia=!1,void(this.ua=void 0);this.ua=setTimeout(()=>{this.sa&&this.Zl.length>0&&this.oa(),this.aa()},this.na)}oa(){const e=Date.now(),t=[],s=this.Zl.filter(i=>e>i.retryAt||(t.push(i),!1));if(this.Zl=t,s.length>0)for(const{requestOptions:i}of s)this.retriableRequest(i)}unload(){this.ua&&(clearTimeout(this.ua),this.ua=void 0),this.ia=!1,b(y)||(this.ra&&(y.removeEventListener("online",this.ra),this.ra=void 0),this.la&&(y.removeEventListener("offline",this.la),this.la=void 0));for(const{requestOptions:e}of this.Zl)try{this._instance._send_request(p(p({},e),{},{transport:"sendBeacon"}))}catch(t){k.error(t)}this.Zl=[]}},Mc=class{constructor(e){this._instance=e,this.ha=()=>{var t,s,i,n;this.ca||(this.ca={});const r=this.scrollElement(),o=this.scrollY(),a=r?Math.max(0,r.scrollHeight-r.clientHeight):0,l=o+((r==null?void 0:r.clientHeight)||0),u=(r==null?void 0:r.scrollHeight)||0;this.ca.lastScrollY=Math.ceil(o),this.ca.maxScrollY=Math.max(o,(t=this.ca.maxScrollY)!==null&&t!==void 0?t:0),this.ca.maxScrollHeight=Math.max(a,(s=this.ca.maxScrollHeight)!==null&&s!==void 0?s:0),this.ca.lastContentY=l,this.ca.maxContentY=Math.max(l,(i=this.ca.maxContentY)!==null&&i!==void 0?i:0),this.ca.maxContentHeight=Math.max(u,(n=this.ca.maxContentHeight)!==null&&n!==void 0?n:0)}}get da(){return this._instance.config.scroll_root_selector}getContext(){return this.ca}resetContext(){const e=this.ca;return setTimeout(this.ha,0),e}startMeasuringScrollPosition(){U(y,"scroll",this.ha,{capture:!0}),U(y,"scrollend",this.ha,{capture:!0}),U(y,"resize",this.ha)}scrollElement(){if(this.da){const s=R(this.da)?this.da:[this.da];for(const i of s){var e;const n=y==null||(e=y.document)===null||e===void 0?void 0:e.querySelector(i);if(n)return n}return}var t;return y==null||(t=y.document)===null||t===void 0?void 0:t.documentElement}va(e){var t,s;const i=e==="y"?"scrollTop":"scrollLeft";if(this.da){const n=this.scrollElement();return n&&n[i]||0}return y?e==="y"?y.scrollY||y.pageYOffset||((t=y.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:y.scrollX||y.pageXOffset||((s=y.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.va("y")}scrollX(){return this.va("x")}};const Tc=e=>Na(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);var Tr=class{constructor(e,t,s,i){this.je=n=>{const r=this.fa();if(r&&r.sessionId===n)return;const o={sessionId:n,props:this.pa(this._instance)};this.ga.register({[tn]:o})},this._instance=e,this.ma=t,this.ga=s,this.pa=i||Tc,this.ma.onSessionId(this.je)}fa(){return this.ga.props[tn]}getSetOnceProps(){var e;const t=(e=this.fa())===null||e===void 0?void 0:e.props;return t?"r"in t?ja(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(){const e={};return q(On(this.getSetOnceProps()),(t,s)=>{s==="$current_url"&&(s="url"),e[`$session_entry_${ji(s)}`]=t}),e}},Gs=class{on(e,t){return this.ya[e]||(this.ya[e]=[]),this.ya[e].push(t),()=>{this.ya[e]=this.ya[e].filter(s=>s!==t)}}emit(e,t){for(const s of this.ya[e]||[])s(t);for(const s of this.ya["*"]||[])s(e,t)}constructor(){this.ya={}}};const xt=ne("[SessionId]"),Lr=864e5;var Dr=class{on(e,t){return this.ba.on(e,t)}constructor(e,t,s){var i;if(this._a=null,this.wa=null,this.ka=[],this.Sa=void 0,this.xa=!1,this.ba=new Gs,this.Ca=(r,o)=>!(!He(r)||!He(o))&&Math.abs(r-o)>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.Sr=e.config,this.ga=e.persistence,this.Be=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.$a=void 0,this._sessionActivityTimestamp=null,this.Ta=t||Me,this.Ia=s||Me;const n=this.Sr.persistence_name||this.Sr.token;if(this._sessionTimeoutMs=1e3*je(this.Sr.session_idle_timeout_seconds||1800,60,36e3,xt.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Ma(),this.Ea="ph_"+n+"_window_id",this.Pa="ph_"+n+"_primary_window_exists",this.Ra()){const r=K.Dt(this.Ea),o=K.Dt(this.Pa);r&&!o?this.Be=r:K.Lt(this.Ea),K.At(this.Pa,!0)}!((i=this.Sr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Sr.bootstrap.sessionID),this.Aa()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return b(this.ka)&&(this.ka=[]),this.ka.push(e),this.Xt&&e(this.Xt,this.Be),()=>{this.ka=this.ka.filter(t=>t!==e)}}Ra(){return this.Sr.persistence!=="memory"&&!this.ga.pi&&K.Et()}Fa(e){e!==this.Be&&(this.Be=e,this.Ra()&&K.At(this.Ea,e))}Oa(){return this.Be?this.Be:this.Ra()?K.Dt(this.Ea):null}Da(e){const t=this._a;return!se(t)&&!se(e)&&5e3>Math.abs(e-t)}La(e,t,s){const i=t!==this._sessionActivityTimestamp,n=!(e!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this.Xt=e,n&&!i||n&&this.Da(t)||(this._a=t,this.ga.register({[kt]:[t,e,s]}))}Na(){var e;const t=(e=this.Sr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return He(t)&&t>0}qa(){this.Na()?this.ga.refreshKey(kt):(this.ga.flush(),this.ga.load())}ja(){var e;if(se(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._a)return;this.qa();const[,t,s]=this.Ba();t===this.Xt&&s===this._sessionStartTimestamp&&(this._a=this._sessionActivityTimestamp,this.ga.register({[kt]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.ga.flush())}Ha(){const[e]=this.Ba(),t=He(e)?e:0,s=He(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,s)}za(e){return this.qa(),this.Ca(e,this.Ha())}Ba(){const e=this.ga.props[kt];return R(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._a=null,this.$a=void 0,clearTimeout(this.Ua),this.Ua=void 0,this.La(null,null,null)}setBootstrapSessionId(e,t=!1){const s=((i,n=new Date().getTime())=>{try{const r=(o=>{const 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)})(i);return r>n+6e4?void xt.error("Bootstrap sessionID cannot be in the future"):r}catch(r){return void xt.error("Invalid sessionID in bootstrap",r)}})(e);return!b(s)&&(t?this.$a={sessionId:e,sessionStartTimestamp:s}:this.La(e,new Date().getTime(),s),!0)}destroy(){this.xa=!0,this.ja(),clearTimeout(this.Ua),this.Ua=void 0,this.Sa&&y&&(y.removeEventListener(zs,this.Sa,{capture:!1}),this.Sa=void 0),this.ka=[]}Aa(){this.Sa=()=>{this.ja(),this.Ra()&&K.Lt(this.Pa)},U(y,zs,this.Sa,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,s=!1){if(this.Sr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const i=t||new Date().getTime(),n=this.Xt;if(s)this.wa=i;else if(se(this.wa)||this.wa>i||i-this.wa>=1e3){var r,o;(r=(o=this.ga).syncCookieProperties)===null||r===void 0||r.call(o),this.wa=i}let[,a,l]=this.Ba();const u=!b(n)&&a!==n,c=this.Ha();let d=this.Oa();const f=this.$a,h=!!f&&(f.sessionStartTimestamp>i+6e4||i-f.sessionStartTimestamp>Lr),g=f?h:He(l)&&Math.abs(i-l)>Lr;let v=!1,_=u;const m=!a||!!f,x=a;let S=!m&&!e&&this.Ca(i,c);if(S&&(S=this.za(i),S||xt.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Ba()),m||S||g){_=!1;const I=f&&!h;a=I?f.sessionId:this.Ta(),d=this.Ia(),xt.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!I,changeReason:{noSessionId:m,activityTimeout:S,sessionPastMaximumLength:g}}),l=I?f.sessionStartTimestamp:i,this.$a=void 0,v=!0}else d||(d=this.Ia(),v=!0),_=_||a!==x,_&&(xt.info("adopted cross-tab session id",{sessionId:a,windowId:d}),v=!0);const C=He(c)&&e&&!g?c:i,$=He(l)?l:new Date().getTime();this.Fa(d),this.La(a,C,$),e||this.Ma();const F={noSessionId:m,activityTimeout:S,sessionPastMaximumLength:g,crossTabAdoption:_};return v&&this.ka.forEach(I=>I(a,d,F)),{sessionId:a,windowId:d,sessionStartTimestamp:$,changeReason:v?F:void 0,lastActivityTimestamp:c}}Ma(){this.xa||(clearTimeout(this.Ua),this.Ua=setTimeout(()=>{if(!this.xa)if(this.za(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.ba.emit("forcedIdleReset",{idleSessionId:e})}else this.Ma()},1.1*this.sessionTimeoutMs))}};const el=function(e,t){if(!e)return!1;const s=e.userAgent;if(s&&Hn(s,t))return!0;try{const i=e==null?void 0:e.userAgentData;if(i!=null&&i.brands&&i.brands.some(n=>Hn(n==null?void 0:n.brand,t)))return!0}catch{}return!!e.webdriver};function tl(){return(tl=Z(function*(){const e=fe==null?void 0:fe.userAgentData;if(e!=null&&e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),s=t==null?void 0:t.model;return L(s)&&s.length>0?s:void 0}catch(t){return void k.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function Lc(e,t){let s=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(s=`$survey_${t}/${e.id}/${e.current_iteration}`),s}function sl(e){var t;return!!(!((t=e.conditions)===null||t===void 0||(t=t.events)===null||t===void 0||(t=t.values)===null||t===void 0)&&t.length)}const Js=(e,t)=>{if(!(s=>{try{new RegExp(s)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},xs=e=>e.toLowerCase(),il={exact:(e,t)=>t.some(s=>e.some(i=>s===i)),is_not:(e,t)=>t.every(s=>e.every(i=>s!==i)),regex:(e,t)=>t.some(s=>e.some(i=>Js(s,i))),not_regex:(e,t)=>t.every(s=>e.every(i=>!Js(s,i))),icontains:(e,t)=>t.map(xs).some(s=>e.map(xs).some(i=>s.includes(i))),not_icontains:(e,t)=>t.map(xs).every(s=>e.map(xs).every(i=>!s.includes(i))),gt:(e,t)=>t.some(s=>{const i=parseFloat(s);return!isNaN(i)&&e.some(n=>i>parseFloat(n))}),lt:(e,t)=>t.some(s=>{const i=parseFloat(s);return!isNaN(i)&&e.some(n=>i<parseFloat(n))})};function nl(e,t){return!e||Object.entries(e).every(([s,i])=>{const n=t==null?void 0:t[s];if(n==null)return!1;const r=il[i.operator];return!!r&&r(i.values,[String(n)])})}function Pi(e,t,s){return Pt({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:s})}const vn="custom",Nr="i.posthog.com",Dc=/^\/static\//,Nc=["/s/","/e/","/i/"];var jc=class{constructor(e){this.Wa={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${Nr}`,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Wa[this.apiHost]||(this.Wa[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":vn),this.Wa[this.apiHost]}Va(e){if(!Dc.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}Ga(e){const t=Rt(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}Za(e,t,s){if(e==="ui")return s;let i=s;const n=this.instance.config.rewriteRequestPath;if(n){var r;const o=((r=Rt(s))===null||r===void 0?void 0:r.href)||s;i=n(new URL(o)).toString()}if(n&&e==="api"&&Nc.some(o=>t.indexOf(o)===0)){const o=this.Ga(i);if(o){const a=this.apiHost;let l=this.Qa;(l==null?void 0:l.apiHost)===a&&l.rewriteRequestPath===n||(l={apiHost:a,rewriteRequestPath:n,urls:new Set},this.Qa=l),l.urls.add(o)}}return i}isIngestionEndpoint(e){const t=this.Qa,s=this.Ga(e);return(t==null?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&t.urls.has(s)}endpointFor(e,t=""){if(t&&(t=t[0]==="/"?t:`/${t}`),e==="ui")return this.Za(e,t,this.uiHost+t);if(e==="flags")return this.Za(e,t,this.flagsApiHost+t);if(e==="assets"){const i=this.Va(t);if(i)return this.Za(e,t,`${i}${t}`)}if(this.region===vn)return this.Za(e,t,this.apiHost+t);const s=Nr+t;switch(e){case"assets":return this.Za(e,t,`https://${this.region}-assets.${s}`);case"api":return this.Za(e,t,`https://${this.region}.${s}`)}}};const H=ne("[Surveys]"),rl=e=>{try{const t=(s=>((i,n)=>`seenSurvey_${(function(r){return r.current_iteration&&r.current_iteration>0?`${r.id}_${r.current_iteration}`:r.id})(n)}`)(0,s))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(t){H.error("Failed to persist survey seen state",t)}},Bc=[xi.Popover,xi.Widget,xi.API],qc={ignoreConditions:!1,ignoreDelay:!1,displayType:cn.Popover},zc=ne("[PostHog ExternalIntegrations]"),Hc={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Uc=class{constructor(e){this._instance=e}Eo(e,t){var s,i;(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,e,n=>{if(n)return zc.error("failed to load script",n);t()})}startIfEnabledOrStop(){var e;for(const[n,r]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var t,s,i;r&&!(!((t=O.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[n])&&this.Eo(Hc[n],()=>{var o;(o=O.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[n])===null||o===void 0||o.start(this._instance)}),!r&&(!((s=O.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[n])&&((i=O.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[n])===null||i===void 0||i.stop())}}},Vc=class{constructor(e,t){this.$=e,this.lo=t,this.Ja=new Map,this.fo=!1}add(e){var t=this;return Z(function*(){if(t.fo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.Ja.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);t.Ja.set(e.name,e);try{const s=e.setup(t.lo);s&&(yield s)}catch(s){const i=t.Ja.get(e.name)===e;i&&t.Ja.delete(e.name),t.$.error(`Failed to set up browser extension "${e.name}"`,s),i&&t.Ka(e)}})()}getExtension(e){return this.Ja.get(e)}dispose(){if(this.fo)return;this.fo=!0;const e=Array.from(this.Ja.values()).reverse();this.Ja.clear();for(const t of e)this.Ka(t)}Ka(e){try{var t;const s=(t=e.dispose)===null||t===void 0?void 0:t.call(e);s&&ve(s.then)&&s.then(void 0,i=>{this.$.error(`Failed to dispose browser extension "${e.name}"`,i)})}catch(s){this.$.error(`Failed to dispose browser extension "${e.name}"`,s)}}},Wc=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if(typeof e=="string")return t==null?void 0:t.get_property(e);const s={};for(const i of e){const n=t==null?void 0:t.get_property(i);b(n)||(s[i]=n)}return s}set(e,t){var s;(s=this._instance.persistence)===null||s===void 0||s.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)===null||t===void 0||t.unregister(e)}};const jr="extensionsRemoteConfig";var Gc=class{constructor(e){this.instance=e,this.fo=!1,this.$=k,this.Ya=e.Xa,this.kv=new Wc(e),this.onEvent=t=>ws(this.instance.on("eventCaptured",s=>{try{t({event:s.event,properties:s.properties})}catch(i){this.$.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=t=>{if(this.fo)return ws(()=>{});const s=n=>{try{t(n)}catch(r){this.$.error("Browser extension remote config listener failed",r)}},i=this.instance.tu.on(jr,s);return this.Ya&&s(this.Ya),ws(i)},this.eu=new Vc(k.createLogger("[BrowserExtensions]"),this)}get logger(){return this.$}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(){const e=this.instance.get_property($n);return typeof e=="string"?e:void 0}get library(){return{name:he.LIB_NAME,version:he.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)===null||t===void 0?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,s,i;const n=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=n==null?void 0:n.sessionId)!==null&&t!==void 0?t:"",windowId:(s=n==null?void 0:n.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=n==null?void 0:n.sessionStartTimestamp)!==null&&i!==void 0?i: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.eu.add(e)}getExtension(e){return this.eu.getExtension(e)}capture(e,t,s){var i=this;return Z(function*(){s?i.instance.capture(e,t,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):i.instance.capture(e,t)})()}registerDynamicEventProperties(e){return ws(this.instance.iu(e))}handleRemoteConfig(e){this.fo||(this.Ya=e,this.instance.tu.emit(jr,e))}sendRequest(e){var t=this;return Z(function*(s,i={}){var n;const r=t.instance.requestRouter.endpointFor((n=i.target)!==null&&n!==void 0?n:"api",s),o={method:i.method,url:i.query?fs(r,i.query):r,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?Ni.Base64:void 0,timestampMode:i.sentAt};return i.transport==="sendBeacon"?(t.instance._send_request(o),{statusCode:202}):new Promise(a=>{o.callback=a,t.instance._send_request(o)})}).apply(this,arguments)}dispose(){this.fo||(this.fo=!0,this.eu.dispose())}};const ts={};let Fi=0;const ss=()=>{},Br='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ut="Surveys module not available",qr="sanitize_properties is deprecated. Use before_send instead",ol="Invalid value for property_denylist config: ",Jc=/^[A-Za-z0-9_-]{1,400}$/,Ii=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Kc=["token","distinct_id",fa],Gt="posthog";let al=!Pc&&(ye==null?void 0:ye.indexOf("MSIE"))===-1&&(ye==null?void 0:ye.indexOf("Mozilla"))===-1;const Yc=e=>{const 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},Oi=e=>{var t;return p({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Ku(w==null?void 0:w.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:ss,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:ee&&L(ee==null?void 0:ee.search)&&ee.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:(y==null||(t=y.location)===null||t===void 0?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(s){k.error("Bad HTTP status: "+s.statusCode+" "+s.text)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:_a,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:ss},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:ic,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:Yc(s),external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:s&&s>="2026-05-30"?250:0,split_storage:!(!s||"2026-05-30">s),detect_google_search_app:!(!s||"2026-05-30">s),disable_capture_url_hashes:!(!s||"2026-06-25">s),cookieWinsOnConflict:!(!s||s==="unset"||"2026-08-29">s)}))(e))},Zc=[["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"]],zr=e=>{const t={};for(const[n,r]of Zc)b(e[n])||(t[r]=e[n]);const s=Y({},t,e),i=e.__preview_external_dependency_versioned_paths;return b(i)||(b(e.strict_script_versioning)&&(s.strict_script_versioning=!!i),L(i)&&b(e.asset_host)&&(s.asset_host=i)),R(e.property_blacklist)&&(b(e.property_denylist)?s.property_denylist=e.property_blacklist:R(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:k.error(ol+e.property_denylist)),s};var Xc=class{constructor(){this.__forceAllowLocalhost=!1}get nu(){return this.__forceAllowLocalhost}set nu(e){k.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},is=class et{su(t){if(!t)return;const s=this.Ja.indexOf(t);s!==-1&&this.Ja.splice(s,1)}ru(t,s){var i;return this.su(t),this.Ja.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}ou(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}lu(){if(this.au||this.config.reuseAnonymousId||this.config.segment||this.ou())return;const t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this.uu)return;let s,i,n;t?(s=`persistence is set to '${this.config.persistence}'`,i=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",n="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(s="persistence is disabled (disable_persistence is true)",i="on every page load",n="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.au=!0,console.warn("[PostHog.js]",`${s} 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. ${n}`)}hu(){if(this.ou()||this.get_distinct_id()!=="$posthog_cookieless")return;const t=this.persistence;if(!t)return;this.cu()||t.load(!0);const s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){const i=this.config.get_device_id(Me());this.register({distinct_id:i,$device_id:i}),t.set_property(be,We)}this.du()}get decideEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.vu=!1,this.fu=!1,this.webPerformance=new Xc,this.pu=!1,this.version=he.LIB_VERSION,this.gu=new Set,this.mu="",this.tu=new Gs,this.Ja=[],this.yu=[],this.uu=!1,this.au=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Oi(),this.SentryIntegration=dc,this.sentryIntegration=i=>(function(n,r){const o=Oa(n,r);return{name:Ia,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bu=!1,this._u=null,this.wu=null,this.ku=null,this.scrollManager=new Mc(this),this.pageViewManager=new Er(this),this.rateLimiter=new wc(this),this.requestRouter=new jc(this),this.consent=new sc(this),this.externalIntegrations=new Uc(this);const s=(t=et.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(i,n,r)=>{const o=L(i)?{[i]:n}:i;this.setPersonProperties(o),r==null||r({})},set_once:(i,n,r)=>{const o=L(i)?{[i]:n}:i;this.setPersonProperties(void 0,o),r==null||r({})}},this.on("eventCaptured",i=>k.info(`send "${i==null?void 0:i.event}"`,i))}init(t,s,i){if(i&&i!==Gt){var n;const r=(n=ts[i])!==null&&n!==void 0?n:new et;return r._init(t,s,i),ts[i]=r,ts[Gt][i]=r,r}return this._init(t,s,i)}_init(t,s={},i){var n,r,o;const a=L(t)?t.trim():"";if(!a)return k.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==((l=this.config)===null||l===void 0?void 0:l.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('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Oi(s.defaults),s.debug=this.Su(s.debug),this.xu=s,this.Cu=[],s.person_profiles?this.wu=s.person_profiles:s.process_person&&(this.wu=s.process_person);const u=Oi(s.defaults),c=zr(s),d=Y({},u,c,{name:i,token:a});T(u.rageclick)&&T(c.rageclick)&&(d.rageclick=Y({},u.rageclick,c.rageclick)),T(u.session_recording)&&T(c.session_recording)&&(d.session_recording=Y({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&k.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Ee.GZipJS;const f=this.cu();if(this.persistence=new wi(this.config,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wi(p(p({},this.config),{},{persistence:"sessionStorage"}),f,!1),this.mu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!f&&K.Et()){const m=K.Dt(this.mu);R(m)&&m.forEach(x=>{L(x)&&this.gu.add(x)})}else K.Lt(this.mu);const h=p({},this.persistence.props),g=p({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.$u=new Cc(m=>this.Tu(m),this.config.request_queue_config),this.Iu=new Ac(this),this.__request_queue=[];const v=this.ou();v||(this.sessionManager=new Dr(this),this.sessionPropsManager=new Tr(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((m,x,S)=>{(S!=null&&S.activityTimeout||S!=null&&S.sessionPastMaximumLength||S!=null&&S.crossTabAdoption)&&this.Mu()})),this.Eu(),this.config.__preview_deferred_init_extensions?(k.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Pu(v)},0)):(k.info("Initializing extensions synchronously"),this.Pu(v)),he.DEBUG=he.DEBUG||this.config.debug,he.DEBUG&&k.info("Starting in debug mode",{this:this,config:s,thisC:p({},this.config),p:h,s:g}),this.config.identity_distinct_id&&!(!((n=s.bootstrap)===null||n===void 0)&&n.distinctID)&&(s.bootstrap=p(p({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const _=(r=s.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.uu=!!_&&!Jt(_),((o=s.bootstrap)===null||o===void 0?void 0:o.distinctID)!==void 0){const m=s.bootstrap.distinctID,x=this.get_distinct_id(),S=this.persistence.get_property(be);if(s.bootstrap.isIdentifiedID&&x!=null&&x!==m&&S==="anonymous")this.identify(m);else if(s.bootstrap.isIdentifiedID&&x!=null&&x!==m&&S==="identified")k.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const C=this.config.get_device_id(Me()),$=s.bootstrap.isIdentifiedID?C:m;this.persistence.set_property(be,s.bootstrap.isIdentifiedID?Fs:We),this.register({distinct_id:m,$device_id:$})}}if(v)this.register_once({distinct_id:fi,$device_id:null},"");else if(!this.get_distinct_id()){const m=this.config.get_device_id(Me());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(be,We)}return U(y,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),U(y,"pageshow",()=>{var m;this.vu=!1,this.fu||(m=this.Iu)===null||m===void 0||m.resume()}),s.segment?kr(this,()=>this.Ru()):this.Ru(),ve(this.config._onCapture)&&this.config._onCapture!==ss&&(k.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",m=>this.config._onCapture(m.event,m))),this.config.ip&&k.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 tl.apply(this,arguments)})().then(m=>{m&&this.register({[hi]:m})}).catch(ss),this}Au(t){const s=t;return L(s.name)&&ve(s.setup)}Fu(t,s){this.Au(t)?s.push(()=>{this.Ou().add(t).catch(()=>{var i;return(i=t.dispose)===null||i===void 0?void 0:i.call(t)}).catch(i=>{k.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.Ja.push(t)}Eu(){var t,s,i;const n=(t=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&t!==void 0?t:(i=et.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var r,o,a;n&&(this.featureFlags&&this.featureFlags instanceof n||((r=this.Du)===null||r===void 0||r.call(this),this.Du=void 0,this.featureFlags=new n(this)),ve(this.featureFlags.onReloading)&&ve(this.featureFlags.setup)?this.Du||(this.Du=this.featureFlags.onReloading(()=>{this.tu.emit("featureFlagsReloading",!0)}),this.Ou().add(this.featureFlags)):(o=(a=this.featureFlags).initialize)===null||o===void 0||o.call(a))}Pu(t){const s=performance.now(),i=p(p({},et.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,u,c,d;i.exceptions&&this.Ja.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new i.exceptions(this)),i.historyAutocapture&&this.Ja.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.Ja.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.Ja.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!t&&this.Ja.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.Fu(this.autocapture=new i.autocapture(this),n),i.surveys&&this.Fu(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),n),i.logs&&this.Fu(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),n),i.metrics&&this.Ja.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.Ja.push(this.conversations=(u=this.conversations)!==null&&u!==void 0?u:new i.conversations(this)),i.productTours&&this.Ja.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.Ja.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.Ja.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.Ja.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.Ja.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,cc)),i.toolbar&&this.Ja.push(this.toolbar=(c=this.toolbar)!==null&&c!==void 0?c:new i.toolbar(this)),i.experiments&&this.Ja.push(this.experiments=(d=this.experiments)!==null&&d!==void 0?d:new i.experiments(this)),this.Ja.forEach(f=>{f.initialize&&n.push(()=>{var h;(h=f.initialize)===null||h===void 0||h.call(f)})}),n.push(()=>{if(this.Lu){const f=this.Lu;this.Lu=void 0,this.Ja.forEach(h=>{var g;return(g=h.onRemoteConfig)===null||g===void 0?void 0:g.call(h,f)})}}),this.Nu(n,s)}Nu(t,s){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&t.length>0)return void setTimeout(()=>{this.Nu(t,s)},0);const n=t.shift();if(n)try{n()}catch(r){k.error("Error initializing extension:",r)}}const i=Math.round(performance.now()-s);this.register_for_session({[pa]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[va]:i}),this.config.__preview_deferred_init_extensions&&k.info(`PostHog extensions initialized (${i}ms)`)}zl(t){var s;if(!w||!w.body)return k.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.zl(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Lu=t),this.Xa=t,this.compression=void 0,t.ok){var i;const n=t.config;n.supportedCompression&&!this.config.disable_compression&&(this.compression=A(n.supportedCompression,Ee.GZipJS)?Ee.GZipJS:A(n.supportedCompression,Ee.Base64)?Ee.Base64:void 0),!((i=n.analytics)===null||i===void 0)&&i.endpoint&&(this.analyticsDefaultEndpoint=n.analytics.endpoint)}this.set_config({person_profiles:this.wu?this.wu:_a}),(s=this.qu)===null||s===void 0||s.handleRemoteConfig(t),this.Ja.forEach(n=>{var r;return(r=n.onRemoteConfig)===null||r===void 0?void 0:r.call(n,t)})}Ru(){try{this.config.loaded(this)}catch(t){k.critical("`loaded` function failed",t)}if(this.ju(),this.config.internal_or_test_user_hostname&&(ee==null?void 0:ee.hostname)){const t=ee.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?t===s:s.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.ou())&&this.Bu()},1),this.Hu=new qa(this),this.Hu.load()}ju(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.$u)===null||t===void 0||t.enable())}_dom_loaded(){this.is_capturing()&&_s(this.__request_queue,t=>this.Tu(t)),this.__request_queue=[],this.ju()}_handle_unload(){var t,s,i,n,r,o;this.vu=!0,(t=this.surveys)===null||t===void 0||(s=t.handlePageUnload)===null||s===void 0||s.call(t),(i=this.metrics)===null||i===void 0||i.flush("sendBeacon"),this.config.request_batching?(this.zu()&&this.capture(lr),(n=this.logs)===null||n===void 0||n.flushLogs("sendBeacon"),(r=this.$u)===null||r===void 0||r.unload(),(o=this.Iu)===null||o===void 0||o.unload()):this.zu()&&this.capture(lr,null,{transport:"sendBeacon"})}_send_request(t){var s,i,n;this.__loaded?al?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((i=t.callback)===null||i===void 0||i.call(t,{statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=p(p({},this.config.request_headers),t.headers),t.compression=t.compression==="best-available"?(s=this.compression)!==null&&s!==void 0?s: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,(r=>{var o,a,l;const u=p({},r);u.timeout=u.timeout||6e4;const c=(o=u.transport)!==null&&o!==void 0?o:"fetch";c==="sendBeacon"&&b(u.compression)&&u.data&&(u.compression=Ee.Base64),u.method==="POST"&&u.data&&(u.timestampMode==="capture-body"?u.data=(g=>{var v,_;const m=(R(g)?g:[g]).map(S=>p(p({},S),S.timestamp instanceof Date&&!isNaN(S.timestamp.getTime())?{timestamp:S.timestamp.toISOString()}:{})),x=m[0];return{api_key:(v=x==null||(_=x.properties)===null||_===void 0?void 0:_.token)!==null&&v!==void 0?v:x==null?void 0:x.token,batch:m,sent_at:new Date().toISOString()}})(u.data):u.timestampMode==="body"&&(u.data=((g,v=new Date().toISOString())=>R(g)?g.map(_=>p(p({},_),{},{sent_at:v})):p(p({},g),{},{sent_at:v}))(u.data))),u.url=Mr(u.url,u.method,u.compression,u.timestampMode);const d=Oc.filter(g=>!u.disableTransport||!g.transport||!u.disableTransport.includes(g.transport)),f=(a=(l=(function(g,v){for(let _=0;g.length>_;_++)if(v(g[_]))return g[_]})(d,g=>g.transport===c))===null||l===void 0?void 0:l.method)!==null&&a!==void 0?a:d[0].method;if(!f)throw new Error("No available transport method");const h=g=>{try{f(g)}catch(_){var v;Za(_)?k.warn(_):k.error(_),(v=u.callback)===null||v===void 0||v.call(u,{statusCode:0,error:_})}};c!=="sendBeacon"&&u.data&&u.compression===Ee.GZipJS&&_l&&typeof Promise<"u"&&!Os?Fc(u).then(g=>{h(g)}).catch(g=>{if(sr(g))return Os=!0,void h(p(p({},u),{},{compression:void 0,url:Mr(r.url,r.method,void 0,r.timestampMode)}));(v=>{if(!v||typeof v!="object")return!1;const _="name"in v?String(v.name):"";return sr(v)||_===Jo})(g)&&(Os=!0),h(u)}):f(u)})(p(p({},t),{},{callback:r=>{var o,a,l;this.rateLimiter.checkForLimiting(r),400>r.statusCode||(a=(l=this.config).on_request_error)===null||a===void 0||a.call(l,r),(o=t.callback)===null||o===void 0||o.call(t,r)}}))):t.fireCallbackOnDrop&&((n=t.callback)===null||n===void 0||n.call(t,{statusCode:0}))}Tu(t){this.Iu?this.Iu.retriableRequest(t):this._send_request(t)}_execute_array(t){Fi++;try{let s;const i=[],n=[],r=[];_s(t,a=>{if(a)if(s=a[0],R(s))r.push(a);else if(ve(a))try{a.call(this)}catch(l){k.error("Error executing queued PostHog call",a,l)}else R(a)&&s==="alias"?i.push(a):R(a)&&s.indexOf("capture")!==-1&&ve(this[s])?r.push(a):n.push(a)});const o=function(a,l){_s(a,function(u){try{if(R(u[0])){let c=l;q(u,function(d){c=c[d[0]].apply(c,d.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(c){k.error("Error executing queued PostHog call",u,c)}})};o(i,this),o(n,this),o(r,this)}finally{Fi--}}push(t){if(Fi>0&&R(t)&&L(t[0])){const s=et.prototype[t[0]];return void(ve(s)&&s.apply(this,t.slice(1)))}this._execute_array([t])}Uu(){var t;const s=(t=this.persistence)===null||t===void 0?void 0:t.get_property(Re);return L(s)&&Ii.test(s)?{value:s,delivered:!1}:T(s)&&L(s.value)&&Ii.test(s.value)?{value:s.value,delivered:s.delivered===!0}:void 0}Wu(t,s,i,n){if(!this.persistence)return;this.persistence.refreshKey(Re);const r=this.Uu();if(!n){if(i)return L(s)&&Ii.test(s)?(s!==(r==null?void 0:r.value)&&this.persistence.register({[Re]:{value:s,delivered:!1}}),{value:s,pending:s!==(r==null?void 0:r.value)||!r.delivered}):void this.persistence.unregister(Re);if(L(t)&&Jc.test(t)){if((r==null?void 0:r.value.split(".")[3])===t)return{value:r.value,pending:!r.delivered};const o=`fb.1.${Date.now()}.${t}`;return this.persistence.register({[Re]:{value:o,delivered:!1}}),{value:o,pending:!0}}return r?{value:r.value,pending:!r.delivered}:void 0}this.persistence.unregister(Re)}Vu(t){if(!this.persistence)return;this.persistence.refreshKey(Re);const s=this.Uu();(s==null?void 0:s.value)!==t||s.delivered||this.persistence.register({[Re]:{value:t,delivered:!0}})}capture(t,s,i){var n,r,o,a,l;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.$u))return void k.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(b(t)||!L(t))return void k.error("No event name provided to posthog.capture");this.hu();const u=!this.config.opt_out_useragent_filter&&this._is_bot();if(u&&!this.config.__preview_capture_bot_pageviews)return;const c=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c!=null&&c.isRateLimited)return void k.critical("This capture call is ignored due to client rate limiting.");let d;s!=null&&s.$current_url&&!L(s==null?void 0:s.$current_url)&&(k.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),t!=="$exception"||i!=null&&i.Gu||k.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&&(d=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const f=new Date,h=(i==null?void 0:i.timestamp)||f,g=Gn(i==null?void 0:i.uuid,Me);let v={uuid:g,event:t,properties:this.calculateEventProperties(t,s||{},h,g)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&u&&(v.event="$bot_pageview",v.properties.$browser_type="bot"),c&&(v.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens);const _=t==="$feature_flag_called"&&v.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i!=null&&i.$set&&!_&&(v.$set=i==null?void 0:i.$set);const m=T(s==null?void 0:s.$set)?s.$set:void 0,x=!!(i!=null&&i.$set)&&"$fbc"in i.$set,S=x||!!m&&"$fbc"in m,C=x?i==null||(n=i.$set)===null||n===void 0?void 0:n[gs]:m==null?void 0:m[gs],$=R(s==null?void 0:s.$unset)?s.$unset:[],F=(i==null?void 0:i.$unset)||[],I=$.indexOf("$fbc")!==-1||F.indexOf("$fbc")!==-1,E=this.Wu(d==null?void 0:d.fbclid,C,S,I);E&&v.properties.$process_person_profile===!0&&E.pending&&!S&&!_&&(v.$set=p({[gs]:E.value},v.$set));const P=i==null?void 0:i.$unset;P&&(v.$unset=P);const D=_?void 0:this.Zu(i==null?void 0:i.$set_once,t!==ur,t===sn);if(D&&(v.$set_once=D),i!=null&&i._noTruncate||(B=this.config.properties_string_max_length,v=(function(j,J){const ue=new Set;return(function ae(X,xe){if(X!==Object(X))return J?J(X):X;if(ue.has(X))return;let le;if(ue.add(X),R(X))le=[],_s(X,ce=>{le.push(ae(ce))});else{const ce={};q(hs(X)?ma(X):X,(Ie,Ke)=>{ue.has(Ie)||(ce[Ke]=ae(Ie))}),le=ce}return le})(j)})(v,j=>L(j)?j.slice(0,B):j)),v.timestamp=h,b(i==null?void 0:i.timestamp)||(v.properties.$event_time_override_provided=!0,v.properties.$event_time_override_system_time=f),_&&(v.properties=((j,J=[])=>{const ue={},ae=X=>{j[X]!==void 0&&(ue[X]=j[X])};return uu.forEach(ae),J.forEach(ae),ue})(v.properties,Kc)),t===Ge.DISMISSED||t===Ge.SENT){const j=s==null?void 0:s[Si.SURVEY_ID],J=s==null?void 0:s[Si.SURVEY_ITERATION];rl({id:j,current_iteration:J}),v.$set=p(p({},v.$set),{},{[Lc({id:j,current_iteration:J},t===Ge.SENT?"responded":"dismissed")]:!0})}else t===Ge.SHOWN&&(v.$set=p(p({},v.$set),{},{[Si.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var B;if(t===bc.SHOWN){const j=s==null?void 0:s[Fr.TOUR_TYPE];j&&(v.$set=p(p({},v.$set),{},{[`${Fr.TOUR_LAST_SEEN_DATE}/${j}`]:new Date().toISOString()}))}const z=p(p({},v.properties.$set),v.$set);if($e(z)||this.setPersonPropertiesForFlags(z),!M(this.config.before_send)){const j=this.$s(v);if(!j)return;v=j,v.uuid=Gn(v.uuid,Me)}const G=(r=(o=v.$set)===null||o===void 0?void 0:o.$fbc)!==null&&r!==void 0?r:T((a=v.properties)===null||a===void 0?void 0:a.$set)?v.properties.$set[gs]:void 0,V=E!=null&&E.pending&&G===E.value?E.value:void 0;this.tu.emit("eventCaptured",v);const re=(l=i==null?void 0:i._url)!==null&&l!==void 0?l:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),W=p(p({method:"POST",url:re,data:v,compression:"best-available",timestampMode:(i==null?void 0:i._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(re)?"body":"capture-body",batchKey:i==null?void 0:i._batchKey},i!=null&&i.transport?{transport:i.transport}:{}),V?{fireCallbackOnDrop:!0,callback:j=>{j.statusCode>=200&&300>j.statusCode&&this.Vu(V)}}:{});var oe;return!this.config.request_batching||i&&!(i!=null&&i._batchKey)||i!=null&&i.send_instantly||V?(!W.transport&&!W.callback&&$e((oe=this.config.request_headers)!==null&&oe!==void 0?oe:{})&&this.vu&&(W.transport="sendBeacon"),this.Tu(W)):this.$u.enqueue(W),v}_addCaptureHook(t){return this.on("eventCaptured",s=>t(s.event,s))}getExtension(t){var s;return(s=this.qu)===null||s===void 0?void 0:s.getExtension(t)}Ou(){var t;return(t=this.qu)!==null&&t!==void 0?t:this.qu=new Gc(this)}iu(t){this.yu.push(t);let s=!0;return()=>{if(!s)return;s=!1;const i=this.yu.indexOf(t);i!==-1&&this.yu.splice(i,1)}}Qu(t=!0){var s,i,n;return!!(!((s=this.persistence)===null||s===void 0)&&s.consumeCookieIdentityChange())&&(this.ku=null,this.persistence.get_property("$user_state")==="anonymous"&&((n=this.sessionPersistence)===null||n===void 0||n.clear(),this.gu.clear(),this.Ju()),(i=this.featureFlags)===null||i===void 0||i.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,s,i,n,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.persistence.syncCookieProperties(),this.Qu();const o=r?void 0:this.persistence.remove_event_timer(t);let a=p({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.ou()&&(a[fa]=!0),t==="$snapshot"){const x=p(p({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=x.distinct_id,(!L(a.distinct_id)&&!ie(a.distinct_id)||Jt(a.distinct_id))&&k.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=(function(x,S,C,$=!1){var F,I,E,P;if(!ye)return{};const D=x?[...Mt,...S||[]]:[],[B,z]=Bo(ye),[G,V]=(function(le){for(let ce=0;Wn.length>ce;ce++){const[Ie,Ke,Se]=Wn[ce],Te=le.match(Ie);if(Te){const at=Se&&le.match(Se)||Te;return[Ke,(at==null?void 0:at[1])||""]}}return["",""]})(ye),re=(function(){const le="u">typeof navigator?navigator:void 0;return le!=null&&le.brave?{brave:!0}:{}})(),W={};b(C)||(W.detectGoogleSearchApp=C);const oe={},j=(F=navigator)===null||F===void 0||(F=F.userAgentData)===null||F===void 0?void 0:F.platform,J=(I=navigator)===null||I===void 0?void 0:I.maxTouchPoints,ue=y==null||(E=y.screen)===null||E===void 0?void 0:E.width,ae=y==null||(P=y.screen)===null||P===void 0?void 0:P.height,X=y==null?void 0:y.devicePixelRatio;b(j)||(oe.userAgentDataPlatform=j),b(J)||(oe.maxTouchPoints=J),b(ue)||(oe.screenWidth=ue),b(ae)||(oe.screenHeight=ae),b(X)||(oe.devicePixelRatio=X);const xe=Y(On({$os:B,$os_version:z,$browser:jo(ye,navigator.vendor,re,W),$webview_app:G,$webview_app_version:V,$device:qo(ye),$device_type:Ml(ye,oe),$timezone:Ba(),$timezone_offset:_c()}),{$current_url:cs($?ot(ee==null?void 0:ee.href):ee==null?void 0:ee.href,D,ds),$host:ee==null?void 0:ee.host,$pathname:ee==null?void 0:ee.pathname,$raw_user_agent:ye.length>1e3?ye.substring(0,997)+"...":ye,$browser_version:Al(ye,navigator.vendor,re,W),$browser_language:La(),$browser_language_prefix:gc(),$screen_height:y==null?void 0:y.screen.height,$screen_width:y==null?void 0:y.screen.width,$viewport_height:y==null?void 0:y.innerHeight,$viewport_width:y==null?void 0:y.innerWidth,$lib:Je.LIB_NAME,$lib_version:Je.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Je.SDK_DIST_CHANNEL&&(xe.$sdk_dist_channel=Je.SDK_DIST_CHANNEL),xe})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:x,windowId:S}=this.sessionManager.checkAndGetSessionAndWindowId(r,i.getTime(),!0);a.$session_id=x,a.$window_id=S}this.sessionPropsManager&&Y(a,this.sessionPropsManager.getSessionProps());try{var u;this.sessionRecording&&Y(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(u=this.Iu)===null||u===void 0?void 0:u.length}catch(x){a.$sdk_debug_error_capturing_properties=String(x)}let c;if(this.requestRouter.region===vn&&(a.$lib_custom_api_host=this.config.api_host),c=t!=="$pageview"||r?t!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,n),a=Y(a,c),t==="$pageview"&&w&&(a.title=w.title),!b(o)){const x=i.getTime()-o;a.$duration=parseFloat((x/1e3).toFixed(3))}ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),f=this.sessionPersistence.properties(),h=a.$groups,g=d.$groups;T(h)&&!$e(h)&&(a.$groups=p(p({},T(g)?g:{}),h)),q(["$referrer","$referring_domain"],x=>{x in d&&delete f[x]});const v={};if(this.yu.length>0)for(const x of this.yu.slice())try{Y(v,x())}catch(S){k.error("Failed to produce browser extension event properties",S)}a=Y({},l,d,f,p(p({},v),a)),a.$is_identified=this._isIdentified(),R(this.config.property_denylist)?q(this.config.property_denylist,function(x){delete a[x]}):k.error(ol+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const _=this.config.sanitize_properties;_&&(k.error(qr),a=_(a,t));const m=this.Ku();return a.$process_person_profile=m,m&&!r&&this.Yu("_calculate_event_properties"),a}Zu(t,s=!0,i=!1){var n;if(!this.persistence||!this.Ku()||this.pu&&!i)return t;const r=this.persistence.get_initial_props(),o=(n=this.sessionPropsManager)===null||n===void 0?void 0:n.getSetOnceProps();let a=Y({},r,o||{},t||{});const l=this.config.sanitize_properties;return l&&(k.error(qr),a=l(a,"$set_once")),s&&(this.pu=!0),$e(a)?void 0:a}register(t,s){var i;(i=this.persistence)===null||i===void 0||i.register(t,s)}register_once(t,s,i){var n;(n=this.persistence)===null||n===void 0||n.register_once(t,s,i)}register_for_session(t){var s,i;(s=this.persistence)===null||s===void 0||s.syncCookieProperties(),this.Qu(),(i=this.sessionPersistence)===null||i===void 0||i.register(t),Object.keys(t).forEach(n=>this.gu.add(n)),this.Ju()}unregister(t){var s;(s=this.persistence)===null||s===void 0||s.unregister(t)}unregister_for_session(t){var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t),this.gu.delete(t),this.Ju()}Xu(t,s){this.register({[t]:s})}Mu(){this.gu.forEach(t=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t)}),this.gu.clear(),this.Ju()}Ju(){var t;if(!this.mu)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.pi||!K.Et())return void K.Lt(this.mu);const s=[];this.gu.forEach(i=>s.push(i)),s.length>0?K.At(this.mu,s):K.Lt(this.mu)}getFeatureFlag(t,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlag(t,s)}getFeatureFlagPayload(t){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlagPayload(t)}getFeatureFlagResult(t,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlagResult(t,s)}getAllFeatureFlags(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,s){var i,n;return(i=(n=this.featureFlags)===null||n===void 0?void 0:n.isFeatureEnabled(t,s))!==null&&i!==void 0?i:s==null?void 0:s.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)===null||t===void 0||t.reloadFeatureFlags()}updateFlags(t,s,i){var n;(n=this.featureFlags)===null||n===void 0||n.updateFlags(t,s,i)}updateEarlyAccessFeatureEnrollment(t,s,i){var n;(n=this.featureFlags)===null||n===void 0||n.updateEarlyAccessFeatureEnrollment(t,s,i)}getEarlyAccessFeatures(t,s=!1,i){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getEarlyAccessFeatures(t,s,i)}on(t,s){return this.tu.on(t,s)}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:Ut}),()=>{})}onSessionId(t){var s,i;return(s=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(t))!==null&&s!==void 0?s:()=>{}}getSurveys(t,s=!1){this.surveys?this.surveys.getSurveys(t,s):t([],{isLoaded:!1,error:Ut})}getActiveMatchingSurveys(t,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,s):t([],{isLoaded:!1,error:Ut})}renderSurvey(t,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(t,s)}displaySurvey(t,s=qc){var i;(i=this.surveys)===null||i===void 0||i.displaySurvey(t,s)}cancelPendingSurvey(t){var s;(s=this.surveys)===null||s===void 0||s.cancelPendingSurvey(t)}canRenderSurvey(t){var s,i;return(s=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurvey(t))!==null&&s!==void 0?s:{visible:!1,disabledReason:Ut}}canRenderSurveyAsync(t,s=!1){var i,n;return(i=(n=this.surveys)===null||n===void 0?void 0:n.canRenderSurveyAsync(t,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:Ut})}th(t){return!t||Jt(t)?(k.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(k.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())||(k.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,s,i){if(!this.__loaded||!this.persistence)return k.uninitializedWarning("posthog.identify");if(ie(t)&&(t=t.toString(),k.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.th(t)||!this.Yu("posthog.identify"))return;this.hu();const n=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==n,o=this.Qu(!1),a=this.persistence.Sl();let l=!1;try{const c=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:c},""),t!==c&&t!==this.get_property("__alias")&&(this.unregister(Bs),this.register({distinct_id:t}));const d=(this.persistence.get_property("$user_state")||"anonymous")===We,f=t!==c,h=!f&&d;if(f&&d){var u;const g=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:c};this.persistence.set_property(be,Fs),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.xl(),this.capture(sn,g,{$set:s||{},$set_once:i||{}}),this.ku=Pi(t,s,i),(u=this.featureFlags)===null||u===void 0||u.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:c)}else if(h){this.persistence.set_property(be,Fs);const g=s||{},v=i||{};this.setPersonPropertiesForFlags({$set:g,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence.xl(),this.capture("$set",{$set:g,$set_once:v}),this.ku=Pi(t,s,i)}else(s||i)&&this.setPersonProperties(s,i);f||r||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(nt)):h&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.Tl(l)}}setPersonProperties(t,s){if(!t&&!s||!this.Yu("posthog.setPersonProperties"))return;const i=Pi(this.get_distinct_id(),t,s);this.ku!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:s||{}},!0),this.capture("$set",{$set:t||{},$set_once:s||{}}),this.ku=i):k.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var s;const i=(R(t)?t:[t]).filter(n=>L(n)&&n.length>0);i.length!==0&&this.Yu("posthog.unsetPersonProperties")&&((s=this.featureFlags)===null||s===void 0||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.ku=null)}group(t,s,i){var n;if(!t||!s)return void k.error("posthog.group requires a group type and group key");(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.Qu();const r=this.getGroups(),o=r[t]!==s;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:p(p({},r),{},{[t]:s})}),(o||i)&&this.Ku()){const a={$group_type:t,$group_key:s};i&&(a.$group_set=i),this.capture(ur,a)}i&&this.setGroupPropertiesForFlags({[t]:i}),o&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,s=!0){var i;(i=this.featureFlags)===null||i===void 0||i.setPersonPropertiesForFlags(t,s)}resetPersonPropertiesForFlags(t=!0){var s;(s=this.featureFlags)===null||s===void 0||s.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,s=!0){var i;this.Yu("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)===null||i===void 0||i.setGroupPropertiesForFlags(t,s))}resetGroupPropertiesForFlags(t){var s;(s=this.featureFlags)===null||s===void 0||s.resetGroupPropertiesForFlags(t)}reset(t){const s=we(t)?t:t==null?void 0:t.resetDeviceID,i=we(t)||t==null?void 0:t.bootstrap;this.eh(s,!1,i)}eh(t,s=!1,i){var n,r,o,a,l,u;if(k.info("reset"),!this.__loaded)return k.uninitializedWarning("posthog.reset");const c=i==null?void 0:i.sessionID;this.config.bootstrap=i||((n=this.xu)===null||n===void 0?void 0:n.bootstrap)||{},(r=this.featureFlags)===null||r===void 0||(o=r.updateConfig)===null||o===void 0||o.call(r,this.config,this.Ul());const d=this.get_property($n),f=this.get_property(hi),h=this.get_property(Yt);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const g=this.is_capturing();this.consent.reset(),s||!g||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const v=(l=this.persistence)===null||l===void 0||(u=l.Sl)===null||u===void 0?void 0:u.call(l);let _=!1;try{var m,x,S,C,$,F,I,E,P,D,B,z,G;if((m=this.persistence)===null||m===void 0||m.clear(),(x=this.sessionPersistence)===null||x===void 0||x.clear(),this.gu.clear(),this.Ju(),b(h)||(D=this.persistence)===null||D===void 0||D.register({$session_recording_remote_config:h}),(S=this.surveys)===null||S===void 0||S.reset(),(C=this.featureFlags)===null||C===void 0||C.reset(),($=this.conversations)===null||$===void 0||$.reset(),(F=this.logs)===null||F===void 0||F.reset(),(I=this.metrics)===null||I===void 0||I.reset(),(E=this.persistence)===null||E===void 0||E.set_property("$user_state","anonymous"),(P=this.sessionManager)===null||P===void 0||P.resetSessionId(),this.ku=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:fi,$device_id:null},"");else{const W=this.config.get_device_id(Me());this.register_once({distinct_id:W,$device_id:t?W:d},""),t||b(f)||this.register({[hi]:f})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID===void 0||this.ou()||((G=this.persistence)===null||G===void 0||G.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(B=this.featureFlags)===null||B===void 0||B.initialize(),!b(c)&&!(!((z=this.sessionManager)===null||z===void 0)&&z.setBootstrapSessionId(c,!0)))){const W=p({},i);delete W.sessionID,this.config.bootstrap=W}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var V,re;v&&((V=this.persistence)===null||V===void 0||(re=V.Tl)===null||re===void 0||re.call(V,_))}this.reloadFeatureFlags()}shutdown(t){var s=this;return Z(function*(){var i,n,r,o,a,l,u;if(s.__loaded){s.fu=!0,s.Ou().dispose(),(i=s.sessionRecording)===null||i===void 0||i.dispose(),(n=s.logs)===null||n===void 0||n.flushLogs("sendBeacon"),(r=s.metrics)===null||r===void 0||r.flush("sendBeacon"),(o=s.$u)===null||o===void 0||o.unload(),(a=s.Iu)===null||a===void 0||a.unload();try{var c;(c=s.featureFlags)===null||c===void 0||c.destroy()}catch(d){k.error("Error while destroying feature flags",d)}(l=s.persistence)===null||l===void 0||l.destroy(),(u=s.sessionPersistence)===null||u===void 0||u.destroy()}else k.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,s){var i;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=s,this.alias(t),(i=this.conversations)===null||i===void 0||i.ih()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(t=this.conversations)===null||t===void 0||t.nh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,s;return(t=(s=this.sessionManager)===null||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:s,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let n=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${s}`);if(t!=null&&t.withTimestamp&&i){var r;const o=(r=t.timestampLookBack)!==null&&r!==void 0?r:10;if(!i)return n;n+=`?t=${Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}`}return n}alias(t,s){return t===this.get_property("$people_distinct_id")?(k.critical("Attempting to create alias for existing People user - aborting."),-2):this.Yu("posthog.alias")?(b(s)&&(s=this.get_distinct_id()),t!==s?(this.Xu(Bs,t),this.capture("$create_alias",{alias:t,distinct_id:s})):(k.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const s=p({},this.config);if(T(t)){var i,n,r,o,a,l,u,c,d,f,h,g,v;Y(this.config,zr(t));const m=this.cu();(i=this.persistence)===null||i===void 0||i.update_config(this.config,s,m),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wi(p(p({},this.config),{},{persistence:"sessionStorage"}),m,!1);const x=this.Su(this.config.debug);var _;we(x)&&(this.config.debug=x),we(this.config.debug)&&(this.config.debug?(he.DEBUG=!0,N.Et()&&N.At("ph_debug",!0),k.info("set_config",{config:t,oldConfig:s,newConfig:p({},this.config)})):(he.DEBUG=!1,N.Et()&&N.Lt("ph_debug"))),(n=this.featureFlags)===null||n===void 0||(r=n.updateConfig)===null||r===void 0||r.call(n,this.config,this.Ul()),(o=this.exceptionObserver)===null||o===void 0||o.onConfigChange(),(a=this.exceptions)===null||a===void 0||a.onConfigChange(),(l=this.sessionRecording)===null||l===void 0||l.startIfEnabledOrStop(),(u=this.tracingHeaders)===null||u===void 0||u.startIfEnabledOrStop(),(c=this.autocapture)===null||c===void 0||c.startIfEnabled(),(d=this.heatmaps)===null||d===void 0||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((_=this.historyAutocapture)===null||_===void 0||_.startIfEnabledOrStop()),(f=this.exceptionObserver)===null||f===void 0||f.startIfEnabledOrStop(),(h=this.deadClicksAutocapture)===null||h===void 0||h.startIfEnabledOrStop(),(g=this.surveys)===null||g===void 0||g.loadIfEnabled(),this.du(),(v=this.externalIntegrations)===null||v===void 0||v.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&kr(this,ss,!1)}}_overrideSDKInfo(t,s){he.LIB_NAME=t,he.LIB_VERSION=s}startSessionRecording(t){const s=t===!0,i={sampling:s||!!(t!=null&&t.sampling),linked_flag:s||!!(t!=null&&t.linked_flag),url_trigger:s||!!(t!=null&&t.url_trigger),event_trigger:s||!!(t!=null&&t.event_trigger)};var n,r,o,a,l;Object.values(i).some(Boolean)&&((n=this.sessionManager)===null||n===void 0||n.checkAndGetSessionAndWindowId(),i.sampling&&((r=this.sessionRecording)===null||r===void 0||r.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)===null||o===void 0||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.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===void 0)&&t.started)}captureException(t,s){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(p(p({},i),s))}catch{return}}addExceptionStep(t,s){var i;(i=this.exceptions)===null||i===void 0||i.addExceptionStep(t,s)}captureLog(t){var s;(s=this.logs)===null||s===void 0||s.captureLog(t)}get logger(){var t,s;return(t=(s=this.logs)===null||s===void 0?void 0:s.logger)!==null&&t!==void 0?t:et.sh}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var s,i;return(s=(i=this.toolbar)===null||i===void 0?void 0:i.loadToolbar(t))!==null&&s!==void 0&&s}get_property(t){var s;return(s=this.persistence)===null||s===void 0?void 0:s.props[t]}getSessionProperty(t){var s;return(s=this.sessionPersistence)===null||s===void 0?void 0:s.props[t]}toString(){var t;let s=(t=this.config.name)!==null&&t!==void 0?t:Gt;return s!==Gt&&(s="posthog."+s),s}_isIdentified(){var t,s;return((t=this.persistence)===null||t===void 0?void 0:t.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)===null||s===void 0?void 0:s.get_property("$user_state"))==="identified"}Ku(){var t,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&$e(this.getGroups())&&!(!((t=this.persistence)===null||t===void 0||(t=t.props)===null||t===void 0)&&t.__alias)&&!(!((s=this.persistence)===null||s===void 0||(s=s.props)===null||s===void 0)&&s.$epp))}zu(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.Ku()||this.Yu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Yu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Yu(t){return this.config.person_profiles==="never"?(k.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.lu(),this.Xu(Pn,!0),!0)}cu(){if(this.config.cookieless_mode==="always")return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}du(){var t,s;const i=this.cu();var n,r,o;return this.is_capturing()||(n=this.logs)===null||n===void 0||n.rh(),((t=this.persistence)===null||t===void 0?void 0:t.pi)!==i&&((r=this.persistence)===null||r===void 0||r.set_disabled(i)),((s=this.sessionPersistence)===null||s===void 0?void 0:s.pi)!==i&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(i)),i&&(this.gu.clear(),this.Ju()),i}opt_in_capturing(t){var s;if(this.config.cookieless_mode!=="always"){if(this.ou()){var i,n,r,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.eh(!0,!0),(n=this.sessionManager)===null||n===void 0||n.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new Dr(this),this.pageViewManager=new Er(this),this.persistence&&(this.sessionPropsManager=new Tr(this,this.sessionManager,this.persistence));const h=(o=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&o!==void 0?o:(l=et.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var u,c;h&&(this.sessionRecording=this.ru(this.sessionRecording,new h(this)),this.Xa&&((u=this.sessionRecording)===null||u===void 0||(c=u.onRemoteConfig)===null||c===void 0||c.call(u,this.Xa)))}var d,f;this.consent.optInOut(!0),this.du(),this.ju(),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((d=this.surveys)===null||d===void 0||d.loadIfEnabled()),(b(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((f=t==null?void 0:t.captureEventName)!==null&&f!==void 0?f:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bu()}else k.warn(Br)}opt_out_capturing(){if(this.config.cookieless_mode==="always")return void k.warn(Br);const t=this.config.cookieless_mode==="on_reject"?this.sessionRecording:void 0;var s,i;t==null||t.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.eh(!0,!0),this.consent.optInOut(!1),this.du(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:fi,$device_id:null}),this.su(t),this.sessionRecording=void 0,(s=this.sessionManager)===null||s===void 0||s.destroy(),(i=this.pageViewManager)===null||i===void 0||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Bu(),this.ju())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 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.du()}_is_bot(){return fe?el(fe,this.config.custom_blocked_useragents):void 0}Bu(){w&&(w.visibilityState==="visible"?this.bu||(this.bu=!0,this.capture(In,{title:w.title},{send_instantly:!0}),this._u&&(w.removeEventListener(as,this._u),this._u=null)):this._u||(this._u=this.Bu.bind(this),U(w,as,this._u)))}debug(t){t===!1?(y==null||y.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(y==null||y.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}))}Ul(){const t=this.xu||{};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?(k.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(s,i,n,r,o){const a=i in s&&!M(s[i]),l=n in s&&!M(s[n]);return a?s[i]:!!l&&(o&&o.warn(`Config field '${n}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),s[n])})(t,"advanced_disable_flags","advanced_disable_decide",0,k)}$s(t){var s;if(M(this.config.before_send))return t;const i=Object.keys((s=t.properties)!==null&&s!==void 0?s:{}).filter(xl),n=R(this.config.before_send)?this.config.before_send:[this.config.before_send];let r=t;for(const o of n)try{if(r=o(r),M(r)){const a=`Event '${t.event}' was rejected in beforeSend function`;return wl(t.event)?k.warn(`${a}. This can cause unexpected behavior.`):k.info(a),null}r.properties&&!$e(r.properties)||k.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return k.error(`Error in beforeSend function for event '${t.event}':`,a),null}for(const o of i)if(r.properties&&M(r.properties[o]))return k.warn(`Event '${t.event}' had its '${o}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){var t;return(t=this.pageViewManager.Ao)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,s){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:s})}captureTraceMetric(t,s,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:s,$ai_metric_value:String(i)})}Su(t){const s=we(t)&&!t,i=N.Et()&&N.Ot("ph_debug")==="true";return!s&&(!!i||t)}};is.__defaultExtensionClasses={},is.sh=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(let s=0;t.length>s;s++)e.prototype[t[s]]=Gu(e.prototype[t[s]])})(is,["identify"]);var ll=class{constructor(e){this.disabled=e===!1;const t=T(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,s){if(this.disabled)return!1;const i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&this.timeoutMs>s-i.timestamp){if(this.clicks.push({x:e,y:t,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:s}];return!1}};const Ci="$copy_autocapture",Ss=ne("[AutoCapture]");function Ri(e,t){return t.length>e?t.slice(0,e)+"...":t}function Qc(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Be(t));return t}function ed(e,{e:t,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!Be(e))return{props:{}};const u=[e],c=new Set([e]);let d=e;for(;d.parentNode&&!ge(d,"body")&&1e3>u.length;){if(Cn(d.parentNode)){const F=d.parentNode.host;if(c.has(F))break;c.add(F),u.push(F),d=F;continue}if(!Be(d.parentNode)||c.has(d.parentNode))break;c.add(d.parentNode),u.push(d.parentNode),d=d.parentNode}const f=t.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?u.findIndex(F=>ge(F,"button")||ge(F,"a")):-1;f>0&&(i=i||u.slice(0,f+1).some(F=>!It(F)||us(F)));const h=[],g={};let v,_=!1,m=!1;if(q(u,F=>{const I=It(F);if(ge(F,"a")){const E=F.getAttribute("href");_=!!(I&&E&&Qt(E))&&(o?ot(E):E)}A(Ct(F),"ph-no-capture")&&(m=!0),h.push((function(E,P,D,B,z=!1){const G=E.tagName.toLowerCase(),V={tag_name:G};An.indexOf(G)>-1&&!D&&(V.$el_text=G.toLowerCase()==="a"||G.toLowerCase()==="button"?Ri(1024,xr(E)):Ri(1024,ls(E)));const re=Ct(E);re.length>0&&(V.classes=re.filter(function(J){return J!==""})),q(E.attributes,function(J){var ue;if((!us(E)||["name","id","class","aria-label"].indexOf(J.name)!==-1)&&!(B!=null&&B.includes(J.name))&&!P&&Qt(J.value)&&(!L(ue=J.name)||ue.substring(0,10)!=="_ngcontent"&&ue.substring(0,7)!=="_nghost")){let ae=J.value;J.name==="class"&&(ae=Rn(ae).join(" ")),V["attr__"+J.name]=Ri(1024,J.name==="href"&&z?ot(ae):ae)}});let W=1,oe=1,j=E;for(;j=Qc(j);)W++,j.tagName===E.tagName&&oe++;return V.nth_child=W,V.nth_of_type=oe,V})(F,s,i,n,o)),q((function(E){if(!It(E))return{};const P={};return q(E.attributes,function(D){if(D.name&&D.name.indexOf("data-ph-capture-attribute")===0){const B=D.name.replace("data-ph-capture-attribute-",""),z=D.value;B&&z&&Qt(z)&&(P[B]=z)}}),P})(F),(E,P)=>{({}).hasOwnProperty.call(g,P)||(g[P]=E)})}),m)return{props:{},explicitNoCapture:m};if(f>0&&(e=u[f],h.splice(0,f)),i||(h[0].$el_text=ge(e,"a")||ge(e,"button")?xr(e):ls(e)),_){var x,S;h[0].attr__href=_;const F=(x=Rt(_))===null||x===void 0?void 0:x.host,I=y==null||(S=y.location)===null||S===void 0?void 0:S.host;F&&I&&F!==I&&(v=_)}return{props:Y(($=t.type,{$event_type:$,$ce_version:1}),r?{}:{$elements:h},{$elements_chain:(C=h,R(C)?(function(F){return F.map(I=>{var E,P;let D="";if(I.tag_name&&(D+=I.tag_name),I.attr_class){I.attr_class.sort();for(const G of I.attr_class)D+=`.${G.replace(/"/g,"")}`}const B=p(p(p(p({},I.text?{text:I.text}:{}),{},{"nth-child":(E=I.nth_child)!==null&&E!==void 0?E:0,"nth-of-type":(P=I.nth_of_type)!==null&&P!==void 0?P:0},I.href?{href:I.href}:{}),I.attr_id?{attr_id:I.attr_id}:{}),I.attributes),z={};return Is(B).sort(([G],[V])=>(function(re,W){return W>re?-1:re>W?1:0})(G,V)).forEach(([G,V])=>z[Sr(G.toString())]=Sr(V.toString())),D+=":",D+=Is(z).map(([G,V])=>`${G}="${V}"`).join(""),D}).join(";")})((function(F){return F.map(I=>{var E,P;const D={text:(E=I.$el_text)===null||E===void 0?void 0:E.slice(0,400),tag_name:I.tag_name,href:(P=I.attr__href)===null||P===void 0?void 0:P.slice(0,2048),attr_class:lc(I),attr_id:I.attr__id,nth_child:I.nth_child,nth_of_type:I.nth_of_type,attributes:{}};return Is(I).filter(([B])=>B.indexOf("attr__")===0).forEach(([B,z])=>D.attributes[B]=z),D})})(C)):"")},!((a=h[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=h[0])===null||l===void 0?void 0:l.$el_text}:{},v&&t.type==="click"?{$external_click_url:v}:{},g),target:e};var C,$}var td=class{Js(){this.Ks=void 0,clearTimeout(this.Ys),this.Ys=void 0}Xs(e){var t;if(!It(e))return!0;const s=(t=this.so().css_selector_ignorelist)!==null&&t!==void 0?t:yi,i=new Set;let n=e;for(;n;){if(i.size>=1e3||i.has(n))return!0;i.add(n);const r=n,o=Ct(r);if(A(o,"ph-no-capture")||A(o,"ph-sensitive")||us(r)||s.some(l=>ln(r,l)))return!0;const a=n.parentNode;n=Cn(a)?a.host:a&&Be(a)?a:null}return!1}oo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.Js();if(e.type==="pointerdown"){this.Js();const i=Xt(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&Be(i)&&(this.Ks={target:i,excluded:this.Xs(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this.lo)===null||t===void 0?void 0:t.distinctId}))}const s=this.Ks;s&&(e.pointerId!==s.id||Math.abs(e.clientX-s.x)>5||Math.abs(e.clientY-s.y)>5?this.Js():e.type==="pointerup"&&(s.released=!0,this.Ys=setTimeout(()=>this.Js(),0)))}ao(e){var t;const s=this.Ks;this.Js();const i=Xt(e);if(s!=null&&s.released&&s.target.isConnected&&s.distinctId===((t=this.lo)===null||t===void 0?void 0:t.distinctId)&&e.pointerId===s.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-s.x)&&5>=Math.abs(e.clientY-s.y)&&i&&(ge(i,"html")||ge(i,"body"))){var n;if(s.excluded)return null;const r=(n=this.so().css_selector_ignorelist)!==null&&n!==void 0?n:yi;return[i,w==null?void 0:w.documentElement,w==null?void 0:w.body].some(o=>{if(!o)return!1;const a=Ct(o);return A(a,"ph-no-capture")||A(a,"ph-sensitive")||!It(o)||us(o)||r.some(l=>ln(o,l))})?null:s.target}}constructor(e){this.uo=e,this.name="autocapture",this.ho=!1,this.co=null,this.do=!1,this.vo=!1,this.Sr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.fo=!1,this.uo.refresh(this.Sr),this.rageclicks=new ll(this.Sr.rageclick),this.po=null}setup(e){this.mo(),this.lo=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.fo?t.dispose():(this.yo=t,this.startIfEnabled())}dispose(){var e;this.fo||(this.fo=!0,this.lo=void 0,(e=this.yo)===null||e===void 0||e.dispose(),this.yo=void 0,this.bo())}so(){return this.uo.refresh(this.Sr),this.Sr}mo(){var e,t;return this.so(),this.Sr.url_allowlist=(e=this.Sr.url_allowlist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Sr.url_ignorelist=(t=this.Sr.url_ignorelist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Sr}_o(){if(!this.isBrowserSupported())return void Ss.info("Disabling Automatic Event Collection because this browser is not supported");if(!y||!w)return;const e=this.wo=t=>{t=t||(y==null?void 0:y.event);try{if(t.type==="blur")return void this.Js();if(t.type.indexOf("pointer")===0)return void this.oo(t);const s=t.type==="click"?this.ao(t):void 0;if(se(s))return;this.ko(t,"$autocapture",s)}catch(s){Ss.error("Failed to capture event",s)}};if(U(y,"blur",e),U(w,"submit",e,{capture:!0}),U(w,"change",e,{capture:!0}),U(w,"click",e,{capture:!0}),q(["pointerdown","pointermove","pointerup","pointercancel"],t=>{U(w,t,e,{capture:!0})}),this.so().capture_copied_text){const t=this.So=s=>{s=s||(y==null?void 0:y.event);try{this.ko(s,Ci)}catch(i){Ss.error("Failed to capture clipboard event",i)}};U(w,"copy",t,{capture:!0}),U(w,"cut",t,{capture:!0}),U(w,"paste",t,{capture:!0})}}bo(){this.Js(),this.wo&&(y==null||y.removeEventListener("blur",this.wo),q(["pointerdown","pointermove","pointerup","pointercancel"],e=>{w==null||w.removeEventListener(e,this.wo,!0)}),w==null||w.removeEventListener("submit",this.wo,!0),w==null||w.removeEventListener("change",this.wo,!0),w==null||w.removeEventListener("click",this.wo,!0),this.wo=void 0),this.So&&(w==null||w.removeEventListener("copy",this.So,!0),w==null||w.removeEventListener("cut",this.So,!0),w==null||w.removeEventListener("paste",this.So,!0),this.So=void 0),this.ho=!1}startIfEnabled(){this.isEnabled||this.Js(),!this.fo&&this.lo&&this.isEnabled&&!this.ho&&(this._o(),this.ho=!0)}onRemoteConfig(e){if(this.fo)return;if(this.do=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this.vo=t.elementsChainAsString);const s=t.autocapture_opt_out;var i;we(s)&&((i=this.lo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.co=s),this.startIfEnabled()}setElementSelectors(e){this.po=e}getElementSelectors(e,t){var s;const i=[];return(s=this.po)===null||s===void 0||s.forEach(n=>{const r=w==null?void 0:w.querySelectorAll(n);r==null||r.forEach(o=>{e!==o&&t!==o||A(i,n)||i.push(n)})}),i}get isEnabled(){var e,t;if(this.fo)return!1;const s=(e=this.lo)===null||e===void 0?void 0:e.kv.get(sa),i=this.co,n=this.so();if(!n.remoteRequestsDisabled&&!this.do)return!1;const r=n.remoteRequestsDisabled&&!this.do;if(se(i)&&!we(s)&&!r)return!1;const o=(t=this.co)!==null&&t!==void 0?t:!!s;return!!n.enabled&&!o}ko(e,t="$autocapture",s){if(!this.isEnabled)return void this.Js();let i=s||Xt(e);xa(i)&&(i=i.parentNode||null);const n=this.mo();var r;t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&n.rageclick&&(!((r=this.rageclicks)===null||r===void 0)&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime()))&&Ea(i,n.rageclick)&&this.ko(e,"$rageclick",s);const o=t===Ci,a=o?p(p({},n),{},{dom_event_allowlist:void 0}):n;if(i&&(function(d,f,h,g,v,_){var m;if(!y||Mn(d)||h!=null&&h.url_allowlist&&!vr(h.url_allowlist,_)||h!=null&&h.url_ignorelist&&vr(h.url_ignorelist,_))return!1;if(h!=null&&h.dom_event_allowlist){const $=h.dom_event_allowlist;if($&&!$.some(F=>f.type===F))return!1}const{parentIsUsefulElement:x,targetElementList:S}=Pa(d,g);if(!(function($,F){const I=F==null?void 0:F.element_allowlist;if(b(I))return!0;for(const E of $)if(I.some(P=>E.tagName.toLowerCase()===P))return!0;return!1})(S,h)||!un(S,h==null?void 0:h.css_selector_allowlist)||un(S,(m=h==null?void 0:h.css_selector_ignorelist)!==null&&m!==void 0?m:yi))return!1;try{const $=y.getComputedStyle(d);if($&&$.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0}catch{}const C=d.tagName.toLowerCase();switch(C){case"html":return!1;case"form":return(v||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(f.type)>=0;default:return x?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(An.indexOf(C)>-1||d.getAttribute("contenteditable")==="true")}})(i,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l;const{props:d,explicitNoCapture:f,target:h}=ed(i,{e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.vo,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(f)return!1;const g=this.getElementSelectors(i,h);if(g&&g.length>0&&(d.$element_selectors=g),t===Ci){const v=e.type||"clipboard";if(v!=="paste"){var u,c;const _=y==null||(u=y.getSelection())===null||u===void 0?void 0:u.toString(),m=Sa(_);if(!m)return!1;d.$selected_content=m,d.$clipboard_text_length=(c=_==null?void 0:_.length)!==null&&c!==void 0?c:0}d.$copy_type=v}return(l=this.lo)===null||l===void 0||l.capture(t,d).catch(v=>Ss.error("Failed to capture event",v)),!0}}isBrowserSupported(){return ve(w==null?void 0:w.querySelectorAll)}},sd=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,s=T(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.Ul(),e.url_allowlist=s==null?void 0:s.url_allowlist,e.url_ignorelist=s==null?void 0:s.url_ignorelist,e.dom_event_allowlist=s==null?void 0:s.dom_event_allowlist,e.element_allowlist=s==null?void 0:s.element_allowlist,e.css_selector_allowlist=s==null?void 0:s.css_selector_allowlist,e.css_selector_ignorelist=s==null?void 0:s.css_selector_ignorelist,e.element_attribute_ignorelist=s==null?void 0:s.element_attribute_ignorelist,e.capture_copied_text=s==null?void 0:s.capture_copied_text}};const Vt=ne("[ExceptionAutocapture]"),Hr=()=>{},Ur=e=>{var t;if(ve(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function ul(e,t,s){try{if(!(t in e))return Hr;const i={next:e[t]},n=s(function(...r){return i.next.apply(this,r)});return ve(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=i.next);let r=e[t],o=Ur(r);for(;o;){if(o.next===n)return void(o.next=i.next);r=o.next,o=Ur(r)}}}catch{return Hr}}const id=ne("[TracingHeaders]"),ut=ne("[Web Vitals]"),Vr=9e5,Wr=["CLS","FCP","INP","LCP"],nd=["INP","LCP"],rd=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Ai="disabled",Gr="lazy_loading",ze=ne("[SessionRecording]"),od=ne("[Heatmaps]");function Mi(e){return T(e)&&"clientX"in e&&"clientY"in e&&ie(e.clientX)&&ie(e.clientY)}const $s=ne("[Product Tours]"),Ti=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(En))},ad=["$set_once","$set"],Le=ne("[SiteApps]"),Jr="Error while initializing PostHog app with config id ",cl=(e,t)=>e!=null&&e.then?e.then(t):t(e),St="SDK is not enabled or survey functionality is not yet loaded",Kr="Disabled. Not loading surveys.";var ld=class{constructor(e,t){this.uo=e,this.oh=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ah=!1,this.uh=[],this.hh=null,this.dh=null,this.fo=!1,this.fh=new Set,this.onRemoteConfig=s=>{if(this.fo||this.Sr.disableSurveys)return;if(!s.ok)return H.warn("Remote config unavailable. Not loading surveys.");const i=s.config.surveys;if(M(i))return H.warn("Flags not loaded yet. Not loading surveys.");this.ph=we(i)?i:i.length>0,H.info(`flags response received, isSurveysEnabled: ${this.ph}`),this.loadIfEnabled()}}setup(e){if(!this.fo)return this.gh=e,cl(e.kv.initialize(),()=>{if(this.gh!==e||this.fo)return;this.gh=void 0,this.lo=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.fo?t.dispose():(this.yo=t,this.loadIfEnabled())})}dispose(){var e,t,s,i;this.fo||(this.fo=!0,this.gh=void 0,this.lo=void 0,(e=this.yo)===null||e===void 0||e.dispose(),this.yo=void 0,(t=this._surveyEventReceiver)===null||t===void 0||t.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)===null||s===void 0||(i=s.dispose)===null||i===void 0||i.call(s),this._surveyManager=null,this.uh=[],this.hh=null,this.fh.forEach(n=>clearTimeout(n)),this.fh.clear())}get Sr(){return this.uo.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;(e=this._surveyEventReceiver)===null||e===void 0||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let s=0;s<localStorage.length;s++){const i=localStorage.key(s);(i!=null&&i.startsWith("seenSurvey_")||i!=null&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach(s=>localStorage.removeItem(s))}catch{}}loadIfEnabled(){if(this.fo||!this.lo)return;const e=this.Sr;if(this._surveyManager)return;if(this.ah)return void H.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void H.info(Kr);if(e.cookielessMode&&this.uo.isOptedOut())return void H.info("Not loading surveys in cookieless mode without consent.");const t=this.uo.getExtensions();if(!t)return void H.error("PostHog Extensions not found.");if(b(this.ph)&&!e.advancedEnableSurveys)return;const s=this.ph||e.advancedEnableSurveys;this.ah=!0;try{const i=t.generateSurveys;if(i)return this.mh(i,s),void(this.ah=!1);const n=t.loadExternalDependency;if(!n)return this.yh(Fn),void(this.ah=!1);n(r=>{try{if(this.fo)return;const o=this.uo.getExtensions();r||!(o!=null&&o.generateSurveys)?this.yh("Could not load surveys script",r):this.mh(o.generateSurveys,s)}finally{this.ah=!1}})}catch(i){throw this.ah=!1,this.yh("Error initializing surveys",i),i}}mh(e,t){this.fo||(this._surveyManager=e(t),this._surveyEventReceiver=this.uo.createEventReceiver(),H.info("Surveys loaded successfully"),this.bh({isLoaded:!0}))}yh(e,t){H.error(e,t),this.bh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.uh.push(e),this._surveyManager&&this.bh({isLoaded:!0}),()=>{this.uh=this.uh.filter(t=>t!==e)}}getSurveys(e,t=!1){var s;const i=(s=this.lo)!==null&&s!==void 0?s:this.oh;if(!i||this.fo)return;if(this.Sr.disableSurveys)return H.info(Kr),e([]);const n=i.kv.get(Qi);if(n&&!t)return e(n,{isLoaded:!0}),void(this._h()&&this.getSurveys(()=>{},!0));if(this.hh)return void this.hh.then(({surveys:a,context:l})=>{this.fo||e(a,l)}).catch(a=>H.error("Error in survey callback",a));const r=this.wh("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Sr.requestTimeoutMs}).then(a=>{try{return this.kh(i,a)}catch(l){return H.error("Error processing surveys response",l),this.kh(i,{statusCode:0,error:l})}},a=>this.kh(i,{statusCode:0,error:a}));this.hh=r;const o=()=>{this.hh===r&&(this.hh=null)};r.then(a=>{o(),this.fo||e(a.surveys,a.context)},o).catch(a=>H.error("Error in survey callback",a))}wh(e,t){const s=this.lo;return s?s.sendRequest(e,t):new Promise(i=>i({statusCode:0,error:new Error(St)}))}kh(e,t){if(this.fo)return{surveys:[],context:{isLoaded:!1,error:St}};const s=t.statusCode;if(s!==200||!t.json){const o=`Surveys API could not be loaded, status: ${s}`;return s!==0?H.error(o):t.error||H.warn(o),this.dh=Date.now(),{surveys:[],context:{isLoaded:!1,error:o}}}this.dh=null;const i=t.json.surveys||[],n=i.filter(o=>(function(a){return!(!a.start_date||a.end_date)})(o)&&(sl(o)||(function(a){var l;return!!(!((l=a.conditions)===null||l===void 0||(l=l.actions)===null||l===void 0||(l=l.values)===null||l===void 0)&&l.length)})(o)));var r;return n.length>0&&((r=this._surveyEventReceiver)===null||r===void 0||r.register(n)),e.kv.set({[Qi]:i,[qs]:Date.now()}),{surveys:i,context:{isLoaded:!0}}}_h(){return this.Sh()&&!this.hh&&!this.xh()}Sh(){var e,t;const s=(e=(t=this.lo)!==null&&t!==void 0?t:this.oh)===null||e===void 0?void 0:e.kv.get(qs);return ie(s)&&Date.now()-s>3e5}xh(){return ie(this.dh)&&3e5>Date.now()-this.dh}markSurveyAsSeen(e,t){var s;const i={id:e,current_iteration:(s=t==null?void 0:t.iteration)!==null&&s!==void 0?s:null};rl(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}bh(e){for(const t of this.uh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(s){H.error("Error in survey callback",s)}}getActiveMatchingSurveys(e,t=!1){if(!M(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);H.warn("init was not called")}Ch(e){let t=null;return this.getSurveys(s=>{var i;t=(i=s.find(n=>n.id===e))!==null&&i!==void 0?i:null}),t}$h(e){if(M(this._surveyManager))return{eligible:!1,reason:St};const t=typeof e=="string"?this.Ch(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Th(e){if(!this.uo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(M(this._surveyManager))return{eligible:!1,reason:St};const t=typeof e=="string"?this.Ch(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(M(this._surveyManager))return H.warn("init was not called"),{visible:!1,disabledReason:St};const t=this.Th(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return M(this._surveyManager)?(H.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:St})):new Promise(s=>{this.getSurveys(i=>{var n;const r=(n=i.find(o=>o.id===e))!==null&&n!==void 0?n:null;if(r){const o=this.Th(r);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,s){var i;if(!this.uo.isCapturing())return;if(M(this._surveyManager))return void H.warn("init was not called");const n=typeof e=="string"?this.Ch(e):e;if(!(n!=null&&n.id))return void H.warn("Survey not found");if(!Bc.includes(n.type))return void H.warn(`Surveys of type ${n.type} cannot be rendered in the app`);const r=w==null?void 0:w.querySelector(t);if(r){if(!((i=n.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){H.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);const o=setTimeout(()=>{var a,l;this.fh.delete(o),!this.fo&&this.uo.isCapturing()&&(H.info(`Rendering survey ${n.id} with delay of ${(a=n.appearance)===null||a===void 0?void 0:a.surveyPopupDelaySeconds} seconds`),(l=this._surveyManager)===null||l===void 0||l.renderSurvey(n,r,s),H.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.fh.add(o)}this._surveyManager.renderSurvey(n,r,s)}else H.warn("Survey element not found")}displaySurvey(e,t){var s;if(!this.uo.isCapturing())return;if(M(this._surveyManager))return void H.warn("init was not called");const i=this.Ch(e);if(!i)return void H.warn("Survey not found");let n=i;if(!((s=i.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=p(p({},i),{},{appearance:p(p({},i.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==cn.Popover&&t.initialResponses&&H.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){const r=this.$h(i);if(!r.eligible)return void H.warn("Survey is not eligible to be displayed: ",r.reason)}t.displayType!==cn.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}cancelPendingSurvey(e){M(this._surveyManager)?H.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.handlePageUnload)===null||t===void 0||t.call(e)}};function $t(e,t,s){if(M(e))return!1;switch(s){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var ud=class{constructor(e){this._instance=e,this.Ih=new Set,this.Mh=new Set,this.Eh=new Gs,this.Ph=(t,s)=>this.Rh(t,s)&&this.Ah(t,s)&&this.Fh(t,s)&&this.Oh(t,s),this.Rh=(t,s)=>!(s!=null&&s.event)||(t==null?void 0:t.event)===(s==null?void 0:s.event)}init(){var e,t;b((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.Dh=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var e;(e=this.Dh)===null||e===void 0||e.call(this),this.Dh=void 0,this.Eh=new Gs}register(e){var t,s;if(!b((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(i=>{var n;this.Ih.add(i),(n=i.steps)===null||n===void 0||n.forEach(r=>{this.Mh.add((r==null?void 0:r.event)||"")})}),(s=this._instance)===null||s===void 0?void 0:s.autocapture)){const i=new Set;this.Ih.forEach(n=>{var r;(r=n.steps)===null||r===void 0||r.forEach(o=>{o!=null&&o.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i)}}replace(e){this.Ih.clear(),this.Mh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Mh.has(e)||this.Mh.has(t.event))&&this.Ih.forEach(s=>{this.Lh(t,s)&&this.Eh.emit("actionCaptured",s.name)})}Nh(e){this.onAction("actionCaptured",t=>e(t))}Lh(e,t){if((t==null?void 0:t.steps)==null)return!1;for(const s of t.steps)if(this.Ph(e,s))return!0;return!1}onAction(e,t){return this.Eh.on(e,t)}Ah(e,t){if(t!=null&&t.url){var s;const i=e==null||(s=e.properties)===null||s===void 0?void 0:s.$current_url;if(!i||typeof i!="string"||!$t(i,t.url,t.url_matching||"contains"))return!1}return!0}Fh(e,t){return!!this.qh(e,t)&&!!this.jh(e,t)&&!!this.Bh(e,t)}qh(e,t){var s;if(!(t!=null&&t.href))return!0;const i=this.Hh(e);if(i.length>0)return i.some(r=>$t(r.href,t.href,t.href_matching||"exact"));const n=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!n&&$t((function(r){const o=r.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(n),t.href,t.href_matching||"exact")}jh(e,t){var s;if(!(t!=null&&t.text))return!0;const i=this.Hh(e);if(i.length>0)return i.some(l=>$t(l.text,t.text,t.text_matching||"exact")||$t(l.$el_text,t.text,t.text_matching||"exact"));const n=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!n&&(r=(function(l){const u=[],c=/(?::|")text="(.*?)"/g;let d;for(;!M(d=c.exec(l));)u.includes(d[1])||u.push(d[1]);return u})(n),o=t.text,a=t.text_matching||"exact",r.some(l=>$t(l,o,a)));var r,o,a}Bh(e,t){var s,i;if(!(t!=null&&t.selector))return!0;const n=e==null||(s=e.properties)===null||s===void 0?void 0:s.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;const r=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch{return!1}return!1}Hh(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e==null?void 0:e.properties.$elements}Oh(e,t){return!(t!=null&&t.properties)||t.properties.length===0||nl(t.properties.reduce((s,i)=>{const n=R(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:n,operator:i.operator||"exact"},s},{}),e==null?void 0:e.properties)}},cd=class{constructor(e){var t,s;this.zh=[],this._instance=e,this.Uh=new Map,this.Wh=new Map,this.Vh=new Map,this.Gh=(t=this._instance)===null||t===void 0||(s=t.onSessionId)===null||s===void 0?void 0:s.call(t,i=>this.Zh(i))}Qh(e){return!1}Jh(){return null}Kh(e){}Yh(){}Xh(e,t){return!!e&&nl(e.propertyFilters,t==null?void 0:t.properties)}tc(e,t){const s=new Map;return e.forEach(i=>{var n;(n=i.conditions)===null||n===void 0||(n=n[t])===null||n===void 0||(n=n.values)===null||n===void 0||n.forEach(r=>{if(r!=null&&r.name){const o=s.get(r.name)||[];o.push(i.id),s.set(r.name,o)}})}),s}ec(e,t,s){const i=(s===qt.Activation?this.Uh:this.Wh).get(e);let n=[];return this.nc(r=>{n=r.filter(o=>i==null?void 0:i.includes(o.id))}),n.filter(r=>{var o;const a=(o=r.conditions)===null||o===void 0||(o=o[s])===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.find(l=>l.name===e);return this.Xh(a,t)})}register(e){this.sc(e,!1)}replace(e){this.sc(e,!0)}sc(e,t){var s;b((s=this._instance)===null||s===void 0?void 0:s._addCaptureHook)||(this.rc(e,t),this.oc(e,t))}oc(e,t){const s=e.filter(r=>{var o;return(o=r.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.length});var i;if(t&&this.Vh.clear(),s.length===0)return void(t&&((i=this.lc)===null||i===void 0||i.replace([])));this.lc||(this.lc=new ud(this._instance),this.lc.init(),this.lc.Nh(r=>this.onAction(r)));const n=[];s.forEach(r=>{var o;(o=r.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||o.values.forEach(a=>{if(n.push(a),a.name){var l;const u=(l=this.Vh.get(a.name))!==null&&l!==void 0?l:[];u.includes(r.id)||u.push(r.id),this.Vh.set(a.name,u)}})}),t?this.lc.replace(n):this.lc.register(n)}ac(e,t){t.forEach((s,i)=>{var n;const r=(n=e.get(i))!==null&&n!==void 0?n:[];s.forEach(o=>{r.includes(o)||r.push(o)}),e.set(i,r)})}rc(e,t){var s,i;const n=e.filter(l=>{var u,c;return((u=l.conditions)===null||u===void 0?void 0:u.events)&&((c=l.conditions)===null||c===void 0||(c=c.events)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length)>0}),r=e.filter(l=>{var u,c;return((u=l.conditions)===null||u===void 0?void 0:u.cancelEvents)&&((c=l.conditions)===null||c===void 0||(c=c.cancelEvents)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length)>0}),o=this.tc(e,qt.Activation),a=this.tc(e,qt.Cancellation);t?(this.Uh=o,this.Wh=a):(this.ac(this.Uh,o),this.ac(this.Wh,a)),(n.length!==0||r.length!==0)&&((s=this.Dh)!==null&&s!==void 0||(this.Dh=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((l,u)=>{this.onEvent(l,u)})))}onEvent(e,t){var s,i;const n=this.uc(),r=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$survey_id)||(t==null||(i=t.properties)===null||i===void 0?void 0:i.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const a=this.hc(e,r);if(a==="consume")return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this.cc([r]);if(a==="persist")return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this.dc(r),void this.vc([r])}if(this.Wh.has(e)){const a=this.ec(e,t,qt.Cancellation);a.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(l=>l.id)}),this.cc(a.map(l=>l.id)),a.forEach(l=>this.fc(l.id)))}if(!this.Uh.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this.Uh.get(e)});const o=this.ec(e,t,qt.Activation);this.gc(o.map(a=>a.id))}onAction(e){this.Vh.has(e)&&this.gc(this.Vh.get(e)||[])}gc(e){var t,s;if(e.length===0)return;const i=!!(!((t=this._instance)===null||t===void 0||(s=t.get_session_id)===null||s===void 0)&&s.call(t)),n=[];for(const r of e)i&&this.Qh(r)?this.dc(r)&&this.mc(r):n.push(r);n.length>0&&(this.zh=[...new Set([...this.zh,...n])]),this.uc().info("updating activated items",{activatedItems:this.getActivatedIds()})}dc(e){this.zh=this.zh.filter(s=>s!==e);const t=this.yc();return!t.includes(e)&&(this.bc([...t,e]),this._c(),!0)}cc(e){const t=new Set(e);this.zh=this.zh.filter(n=>!t.has(n));const s=this.wc(),i=s.filter(n=>!t.has(n));i.length!==s.length&&(this.bc(i),i.length===0&&this.kc()),this.vc(e)}Sc(){var e;const t=this.Jh();if(!t)return{};const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t];return s&&typeof s=="object"?s:{}}mc(e){if(!this.Jh())return;const t=this.Sc();this.Kh(p(p({},t),{},{[e]:Date.now()}))}vc(e){if(!this.Jh())return;const t=this.Sc(),s={};let i=!1;for(const[n,r]of Object.entries(t))e.includes(n)?i=!0:s[n]=r;i&&($e(s)?this.Yh():this.Kh(s))}xc(){this.Jh()&&this.Yh()}getActivationTimestamp(e){if(!this.yc().includes(e))return;const t=this.Sc()[e];return ie(t)?t:void 0}wc(){var e;const t=this.Cc();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t])||[]}yc(){var e,t,s;const i=this.wc();if(i.length===0)return[];const n=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.$c()],r=(t=this._instance)===null||t===void 0||(s=t.get_session_id)===null||s===void 0?void 0:s.call(t);return r&&n===r?i:[]}_c(){var e,t;const s=(e=this._instance)===null||e===void 0||(t=e.get_session_id)===null||t===void 0?void 0:t.call(e);s&&this.Tc(s)}kc(){this.Ic()}Zh(e){var t;const s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.$c()];if(s&&s!==e){const i=this.wc(),n=this.Sc();i.length>0&&(this.bc([]),i.filter(r=>ie(n[r])).forEach(r=>this.fc(r))),this.kc(),this.xc()}}getActivatedIds(){return[...new Set([...this.yc(),...this.zh])].filter(e=>!this.Mc(e))}dispose(){var e,t,s;(e=this.Gh)===null||e===void 0||e.call(this),this.Gh=void 0,(t=this.Dh)===null||t===void 0||t.call(this),this.Dh=void 0,(s=this.lc)===null||s===void 0||s.dispose(),this.lc=void 0}reset(){this.zh=[],this.wc().length>0&&this.bc([]),this.kc(),this.xc()}getEventToItemsMap(){return this.Uh}Ec(){return this.lc}},dd=class extends cd{constructor(e){super(e)}Cc(){return la}$c(){return ua}Jh(){return ca}Kh(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_timestamps:e})}Yh(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}Qh(e){var t;let s;this.nc(n=>{s=n.find(r=>r.id===e)});const i=s==null||(t=s.appearance)===null||t===void 0?void 0:t.surveyPopupDelaySeconds;return ie(i)&&i>0}Pc(){return Ge.SHOWN}nc(e){var t;(t=this._instance)===null||t===void 0||t.getSurveys(e)}fc(e){var t;(t=this._instance)===null||t===void 0||t.cancelPendingSurvey(e)}uc(){return H}bc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated:e})}Tc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_session:e})}Ic(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}Mc(){return!1}hc(e,t){let s;return this.nc(i=>{s=i.find(n=>n.id===t)}),!s||(function(i){var n;return sl(i)&&!!(!((n=i.conditions)===null||n===void 0||(n=n.events)===null||n===void 0)&&n.repeatedActivation)||i.schedule==="always"})(s)?e===Ge.SHOWN?"consume":"ignore":e===Ge.SHOWN?"persist":e===Ge.DISMISSED||e===Ge.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},hd=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);const t={};for(const s of e){const i=this._instance.get_property(s);b(i)||(t[s]=i)}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)}},fd=class{constructor(e){this._instance=e}get(){const e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=O==null?void 0:O.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:s}=e;return{generateSurveys:t?i=>t(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}createEventReceiver(){return new dd(this._instance)}};const pd=y!=null&&y.location?Us(y.location.hash,"__posthog")||Us(location.hash,"state"):null,Yr="_postHogToolbarParams",Zr=ne("[Toolbar]"),Xr=ne("[FeatureFlags]");var vd=class{constructor(e,t=!1){this.Rc=!1,this.update(e,t)}update(e,t){this.Ac=((s,i)=>{var n,r,o,a,l;return{bootstrap:{featureFlags:(n=s.bootstrap)===null||n===void 0?void 0:n.featureFlags,featureFlagPayloads:(r=s.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!s.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!s.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!s.advanced_feature_flags_dedup_per_session,cacheTtlMs:s.feature_flag_cache_ttl_ms,refreshIntervalMs:(o=s.remote_config_refresh_interval_ms)!==null&&o!==void 0?o:3e5,requestTimeoutMs:s.feature_flag_request_timeout_ms,compression:s.disable_compression?void 0:"best-available",evaluationContexts:(a=(l=s.evaluation_contexts)!==null&&l!==void 0?l:s.evaluation_environments)!==null&&a!==void 0?a:[],flagKeys:R(s.flag_keys)?s.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.Rc||(Xr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rc=!0),b(e.flag_keys)||R(e.flag_keys)||Xr.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.Ac}};const Qr=ne("[FeatureFlags]"),ct=ne("[FeatureFlags]",{debugEnabled:!0}),Li=`" failed. Feature flags didn't load in time.`,eo="connection_error",to=e=>{const t={};for(let s=0;e.length>s;s++)t[e[s]]=!0;return t},so=e=>{const t={};for(const[s,i]of Is(e||{}))i&&(t[s]=i);return t},io=e=>hs(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Oe=ne("[Error tracking]"),gn="webkit-masked-url:",gd=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],_d=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",gn],md=["__firefox__","__gCrWeb"],no="Refusing to render web experiment since the viewer is a likely bot",yd={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Js(t,e),not_regex:(e,t)=>!Js(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Pe=ne("[Conversations]"),dt="Conversations not available yet.";function ro(e,t){var s,i,n,r,o,a,l;const u=(s=e==null?void 0:e.flushIntervalMs)!==null&&s!==void 0?s:3e3,c=(i=e==null?void 0:e.maxBufferSize)!==null&&i!==void 0?i:100,d=t!=null&&t.consoleCapture?void 0:(n=e==null?void 0:e.maxLogsPerInterval)!==null&&n!==void 0?n:1e3,f=b(d)?Math.max(c,2048):Math.max(c,d),h=p(p({},(function(){let g="",v="";try{const _=fe==null?void 0:fe.userAgent;_&&([g,v]=Bo(_))}catch{}return(function(_,m){const x=(function(S){if(S)return{}.hasOwnProperty.call(nr,S)?nr[S]:S})(_);return p(p({},x?{"os.name":x}:{}),m?{"os.version":m}:{})})(g,v)})()),e==null?void 0:e.resourceAttributes);return{serviceName:(r=(o=h==null?void 0:h["service.name"])!==null&&o!==void 0?o:e==null?void 0:e.serviceName)!==null&&r!==void 0?r:t==null?void 0:t.serviceNameDefault,serviceVersion:(a=h==null?void 0:h["service.version"])!==null&&a!==void 0?a:e==null?void 0:e.serviceVersion,environment:(l=h==null?void 0:h["deployment.environment"])!==null&&l!==void 0?l:e==null?void 0:e.environment,resourceAttributes:h,beforeSend:e==null?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:f,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const bd=["debug","log","warn","error","info"],wd=e=>{for(;e!=null&&e.__rrweb_original__;)e=e.__rrweb_original__;return e},oo="console",dl="__posthogHandledLogsRequestError",Di=(e,t)=>{const s=e instanceof Error?e:new Error(t);return s[dl]=!0,s},ao=e=>!!e&&typeof e=="object"&&e[dl]===!0,ei={featureFlags:class{constructor(e){this.name="featureFlags",this.Fc=!1,this.featureFlagEventHandlers=[],this.$=Qr,this.Oc={},this.Dc={},this.Lc=[],this.Nc=!1,this.qc=!1,this.jc=0,this.Bc=!1,this.Hc=!1,this.zc=!1,this.Uc=!1,this.Wc=0,this.sn=()=>{const t=this.Vc();this.Wc=0,t&&this.reloadFeatureFlags()},this.Gc=()=>{var t;const s=this.Zc;b(s)||this.Sr.remoteRequestsDisabled||!w||w.visibilityState==="hidden"||Date.now()-((t=this.Qc)!==null&&t!==void 0?t:0)<s||(this.reloadFeatureFlags(),this.Jc())},this.an=()=>{(w==null?void 0:w.visibilityState)==="visible"&&this.Gc()},"get"in e?this.uo=e:(this._instance=e,this.Kc=new vd(e.config,e.Ul()),this.uo=this.Kc)}updateConfig(e,t){var s;(s=this.Kc)===null||s===void 0||s.update(e,t),this.lo&&this.Yc()}setup(e){return this.gh=e,this.$=e.logger.createLogger("[FeatureFlags]"),cl(e.kv.initialize(),()=>{this.gh===e&&(this.gh=void 0,this.lo=e,this.Xc(e))})}Xc(e){var t;if(this.lo===e)return y&&U(y,"online",this.sn),this.Yc(),this.td=e.registerDynamicEventProperties(()=>this.ed()?this.Oc:this.Dc),this.nd=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.sd(),this.rd(),this.od()}),this.rd(),this.initialize()}Yc(){const e=this.Sr.refreshIntervalMs,t=!this.Sr.remoteRequestsDisabled&&w&&!b(e)&&e>0?e:void 0;t!==this.Zc&&(this.ld(),b(t)||(this.Zc=t,this.Jc(),w!=null&&w.addEventListener&&U(w,as,this.an)))}Jc(){b(this.Zc)||(b(this.ad)||clearInterval(this.ad),this.Qc=Date.now(),this.ad=setInterval(this.Gc,this.Zc))}ld(){var e;b(this.ad)||(clearInterval(this.ad),this.ad=void 0,w==null||(e=w.removeEventListener)===null||e===void 0||e.call(w,"visibilitychange",this.an)),this.Zc=void 0,this.Qc=void 0}destroy(){this.ud()}dispose(){this.ud()}ud(){var e,t;this.ld(),this.jc++,this.Hc=!1,this.gh=void 0,this.lo&&(this.hd(),(e=this.td)===null||e===void 0||e.dispose(),this.td=void 0,(t=this.nd)===null||t===void 0||t.call(this),this.nd=void 0,this.Lc=[],y==null||y.removeEventListener("online",this.sn),this.lo=void 0)}get Sr(){return this.uo.get()}dd(e){var t;return this.vd&&e in this.vd?this.vd[e]:(t=this.lo)===null||t===void 0?void 0:t.kv.get(e)}sd(){return!!this.vd&&(this.vd=void 0,!0)}fd(){var e;return!b((e=this.lo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.sd()}At(e){this.pd(()=>{var t;return(t=this.lo)===null||t===void 0?void 0:t.kv.set(e)})}gd(e,t,s){var i;if(!(!((i=this._instance)===null||i===void 0)&&i.persistence)||!e.$enabled_feature_flags)return;const n=this.dd("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(([,m])=>!(m!=null&&m.failed)).map(([m])=>m):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,u=l?a:s&&!R(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),c=this.dd("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},f=l||s?u:Array.from(new Set([...Object.keys(c),...Object.keys(d)])),h=!l&&!s,g=!!h||u,v=!!h||f,_={[Ve]:g,[Ae]:g,[tt]:v};e.$feature_flag_details&&(_[vt]=g);for(const m of[gt,rt,Zt])b(e[m])||(_[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(_)}Lt(e){this.pd(()=>{var t;return(t=this.lo)===null||t===void 0?void 0:t.kv.remove(e)})}pd(e){try{e()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}rd(){const e={};for(const i of[Ve,tt,gt,De]){const n=this.dd(i);b(n)||(e[i]=n)}this.Oc=e;const t=p({},e),s=this.dd(Ae);if(s)for(const[i,n]of Object.entries(s))t[`$feature/${i}`]=n;this.Dc=t}ed(){const e=this.Sr.cacheTtlMs;if(!e||0>=e)return!1;const t=this.dd(rt);return typeof t!="number"||Date.now()-t>e}md(){return!!this.ed()&&(this.Uc||this.qc||(this.Uc=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}yd(){const e=this.Sr.evaluationContexts;return e!=null&&e.length?e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),s}):[]}bd(){const e=this.Sr.flagKeys;if(!b(e))return e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),s})}initialize(){var e,t;const s=this.Sr,i=(e=(t=s.bootstrap)===null||t===void 0?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var n,r;const o=(n=(r=s.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads)!==null&&n!==void 0?n:{},a=Object.keys(i).filter(u=>!b(i[u])).reduce((u,c)=>(u[c]=i[c],u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this._d({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,s){var i,n;const r=s!=null&&s.merge&&(i=this.dd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s!=null&&s.merge&&(n=this.dd("$feature_flag_payloads"))!==null&&n!==void 0?n:{},a=p(p({},r),e),l=p(p({},o),t),u={};for(const[c,d]of Object.entries(a))u[c]={key:c,enabled:Qn(d),variant:er(d),reason:void 0,metadata:b(l==null?void 0:l[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}};this._d({flags:u})}get hasLoadedFlags(){return this.Nc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.dd(vt),t=this.dd(De),s=this.dd(ft);if(!s&&!t)return e||{};const i=Y({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(const a of n){var r;const l=i[a],u=t==null?void 0:t[a],c=b(u)?(r=l==null?void 0:l.enabled)!==null&&r!==void 0&&r:!!u,d=b(u)?l==null?void 0:l.variant:typeof u=="string"?u:void 0,f=s==null?void 0:s[a],h=p(p({},l),{},{enabled:c,variant:c?d??(l==null?void 0:l.variant):void 0});var o;c!==(l==null?void 0:l.enabled)&&(h.original_enabled=l==null?void 0:l.enabled),d!==(l==null?void 0:l.variant)&&(h.original_variant=l==null?void 0:l.variant),f&&(h.metadata=p(p({},l==null?void 0:l.metadata),{},{payload:f,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=h}return this.Fc||(this.$.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:i}),this.Fc=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(s=>{const i=e[s];return{key:s,enabled:Qn(i),variant:er(i),payload:Xn(t[s])}})}getFlagVariants(){const e=this.dd(Ae),t=this.dd(De);if(!t)return e||{};const s=Y({},e||{}),i=Object.keys(t);for(let n=0;i.length>n;n++)s[i[n]]=t[i[n]];return this.Fc||(this.$.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:s}),this.Fc=!0),s}getFlagPayloads(){const e=this.dd(tt),t=this.dd(ft);if(!t)return e||{};const s=Y({},e||{}),i=Object.keys(t);for(let n=0;i.length>n;n++)s[i[n]]=t[i[n]];return this.Fc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:s}),this.Fc=!0),s}reloadFeatureFlags(){this.Bc||this.Sr.featureFlagsDisabled||this.Vc()||(this.qc&&(this.Hc=!0),this.wd||(this.Lc.slice().forEach(e=>{try{e()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.wd=setTimeout(()=>{this.kd()},5)))}hd(){clearTimeout(this.wd),this.wd=void 0}onReloading(e){return this.Lc.push(e),()=>{this.Lc=this.Lc.filter(t=>t!==e)}}ensureFlagsLoaded(){this.Nc||this.qc||this.wd||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Bc=e}resetFlagCallReported(){this.Lt(nt)}kd(e){this.hd();const t=this.lo;if(!t||this.Sr.remoteRequestsDisabled||this.Vc())return;if(this.qc)return void(this.Hc=!0);const s={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:p(p(p({},t.initialPersonProperties),this.dd("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.dd(it),timezone:Ba()};b(t.deviceId)||(s.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Sr.featureFlagsDisabled)&&(s.disable_flags=!0);const i=this.yd();i.length&&(s.evaluation_contexts=i);const n=this.bd();b(n)||(s.flag_keys=n);const r=this.Sr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),a=this.jc;this.qc=!0;const l=()=>{this.Hc&&(this.Hc=!1,this.kd())},u=d=>{var f,h;const g=(f=d.json)!==null&&f!==void 0?f:{},v=d.statusCode!==200;if(this.qc=!1,a!==this.jc)return void l();if(this.Sd(d.statusCode),v||this.Hc||(this.$anon_distinct_id=void 0),s.disable_flags&&!this.Hc)return;this.zc=!v;const _=[];d.error?_.push(d.error instanceof Error&&d.error.name==="AbortError"?"timeout":d.error instanceof Error?eo:"unknown_error"):d.statusCode!==200&&_.push(`api_error_${d.statusCode}`),g.errorsWhileComputingFlags&&_.push("errors_while_computing_flags");const m=!!(!((h=g.quotaLimited)===null||h===void 0)&&h.includes("feature_flags"));m&&_.push("quota_limited"),this.At({[os]:_}),m?this.$.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):s.disable_flags||this._d(g,v,{partialResponse:r}),l()},c=d=>{this.qc=!1,a===this.jc&&(this.At({[os]:[eo]}),this.$.error("Feature flag request failed",d),this.fd()&&this.od(!0)),l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:s,compression:this.Sr.compression,sentAt:"body",timeoutMs:this.Sr.requestTimeoutMs}).then(u).catch(c)}catch(d){c(d)}}Vc(){return Ca(this.Wc,3)}Sd(e){this.Wc=Ra(e,this.Wc,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var s;if(t.fresh&&!this.zc)return;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+e+Li);if(this.md())return;const i=this.getFeatureFlagResult(e,t);return(s=i==null?void 0:i.variant)!==null&&s!==void 0?s:i==null?void 0:i.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.zc)return;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+e+Li);if(this.md())return;const s=this.getFlagVariants(),i=e in s,n=s[e],r=this.getFlagPayloads()[e],o=String(n),a=this.dd("$feature_flag_request_id")||void 0,l=this.dd("$feature_flag_evaluated_at")||void 0;let u,c=this.dd("$flag_call_reported")||{};if(this.Sr.deduplicateCallsPerSession){var d;const P=(d=this.lo)===null||d===void 0?void 0:d.session.sessionId,D=this.dd(Wt);P&&P!==D&&(c={},u=P)}if(t.send_event||!("send_event"in t))if(e in c&&c[e].includes(o))u&&this.At({[nt]:c,[Wt]:u});else{var f,h,g,v,_,m,x,S,C,$,F,I;R(c[e])?c[e].push(o):c[e]=[o],this.At(p({[nt]:c},u?{[Wt]:u}:{}));const P=this.getFeatureFlagDetails(e),D=[...(f=this.dd("$feature_flag_errors"))!==null&&f!==void 0?f:[]];b(n)&&D.push("flag_missing");const B={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:r??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(h=(g=this.Sr.bootstrap)===null||g===void 0||(g=g.featureFlags)===null||g===void 0?void 0:g[e])!==null&&h!==void 0?h:null,$feature_flag_bootstrapped_payload:(v=(_=this.Sr.bootstrap)===null||_===void 0||(_=_.featureFlagPayloads)===null||_===void 0?void 0:_[e])!==null&&v!==void 0?v:null,$used_bootstrap_value:!this.zc};b(P==null||(m=P.metadata)===null||m===void 0?void 0:m.has_experiment)||(B.$feature_flag_has_experiment=P.metadata.has_experiment),b(P==null||(x=P.metadata)===null||x===void 0?void 0:x.version)||(B.$feature_flag_version=P.metadata.version);const z=(S=P==null||(C=P.reason)===null||C===void 0?void 0:C.description)!==null&&S!==void 0?S:P==null||($=P.reason)===null||$===void 0?void 0:$.code;var E;z&&(B.$feature_flag_reason=z),!(P==null||(F=P.metadata)===null||F===void 0)&&F.id&&(B.$feature_flag_id=P.metadata.id),b(P==null?void 0:P.original_variant)&&b(P==null?void 0:P.original_enabled)||(B.$feature_flag_original_response=b(P.original_variant)?P.original_enabled:P.original_variant),!(P==null||(I=P.metadata)===null||I===void 0)&&I.original_payload&&(B.$feature_flag_original_payload=P==null||(E=P.metadata)===null||E===void 0?void 0:E.original_payload),D.length&&(B.$feature_flag_error=D.join(",")),this.xd(B)}else u&&this.At({[nt]:c,[Wt]:u});return i?{key:e,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:Xn(r)}:void 0}xd(e){try{var t;(t=this.lo)===null||t===void 0||t.capture("$feature_flag_called",e).catch(s=>{this.$.error("Failed to capture feature flag call",s)})}catch(s){this.$.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(e,t){this.Cd(e,t)}Cd(e,t){var s=this;return Z(function*(){const i=s.lo;if(!i)return;const n={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},r=s.yd();r.length&&(n.evaluation_contexts=r);const o=s.bd();let a;b(o)||(n.flag_keys=o);try{var l;const u=(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:s.Sr.compression,sentAt:"body",timeoutMs:s.Sr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=(u==null?void 0:u[e])||void 0}catch(u){return void s.$.error("Remote config feature flag request failed",u)}try{t(a)}catch(u){s.$.error("Remote config feature flag callback failed",u)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.zc)return t.defaultValue;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+e+Li),t.defaultValue;const s=this.getFeatureFlag(e,t);return b(s)?t.defaultValue:!!s}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,s){this._d(e,t,s)}_d(e,t,s){if(!this.lo)return;this.Nc=!0;const i=((n,r={},o={},a={},l,u=Qr)=>{const c=((S,C)=>{const $=S.flags;if($){const F=Object.fromEntries(Object.keys($).map(E=>{var P;return[E,(P=$[E].variant)!==null&&P!==void 0?P:$[E].enabled]})),I=Object.fromEntries(Object.keys($).filter(E=>$[E].enabled).filter(E=>{var P;return!b((P=$[E].metadata)===null||P===void 0?void 0:P.payload)}).map(E=>{var P;return[E,(P=$[E].metadata)===null||P===void 0?void 0:P.payload]}));return p(p({},S),{},{featureFlags:F,featureFlagPayloads:I})}return S.featureFlags&&C.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),S})(n,u),d=c.flags,f=c.featureFlags,h=c.featureFlagPayloads;if(!f)return;const g=n.requestId,v=n.evaluatedAt;if(R(f)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const S={};if(f)for(let C=0;f.length>C;C++)S[f[C]]=!0;return{[Ve]:f,[Ae]:S,[Zt]:!1}}let _=f,m=h,x=d;if(l!=null&&l.partialResponse){const S=Object.keys(_),C=m||{};_=p(p({},r),_),m=p(p({},o),C),S.forEach($=>{$ in C||m==null||delete m[$]}),x=p(p({},a),x)}else if(n.errorsWhileComputingFlags)if(d){const S=new Set(Object.keys(d).filter($=>{var F;return!(!((F=d[$])===null||F===void 0)&&F.failed)}));_=p(p({},r),Object.fromEntries(Object.entries(_).filter(([$])=>S.has($))));const C=Object.fromEntries(Object.entries(m||{}).filter(([$])=>S.has($)));m=p(p({},o),C),S.forEach($=>{$ in C||m==null||delete m[$]}),x=p(p({},a),Object.fromEntries(Object.entries(x||{}).filter(([$])=>S.has($))))}else _=p(p({},r),_),m=p(p({},o),m),x=p(p({},a),x);return p(p({[Ve]:Object.keys(so(_)),[Ae]:_||{},[tt]:m||{},[vt]:x||{},[Zt]:n.minimalFlagCalledEvents===!0},g?{[gt]:g}:{}),v?{[rt]:v}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.$);if(i)if((s==null?void 0:s.persist)===!1){const n=!b(this.lo.kv.get(Ae));this.vd=i,n||this.At(i)}else this.sd(),this.gd(i,e,!!(s!=null&&s.partialResponse)),this.At(i);else t&&this.fd();t||(this.Uc=!1),this.od(t)}override(e,t=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.$d(e)}$d(e){if(this.lo){if(e===!1)return this.Lt([De,ft]),this.od(),void ct.info("All overrides cleared");if(R(e))return this.At({[De]:to(e)}),this.od(),void ct.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;const s=e;this.Fc=!!((t=s.suppressWarning)!==null&&t!==void 0&&t);const i={},n=s.flags,r=s.payloads;return n&&(i[De]=R(n)?to(n):n),r&&(i[ft]=r),Object.keys(i).length&&this.At(i),n===!1&&r===!1?this.Lt([De,ft]):n===!1?this.Lt(De):r===!1&&this.Lt(ft),this.od(),n===!1?ct.info("Flag overrides cleared"):n&&ct.info("Flag overrides set",{flags:n}),void(r===!1?ct.info("Payload overrides cleared"):r&&ct.info("Payload overrides set",{payloads:r}))}if(e&&typeof e=="object")return this.At({[De]:e}),this.od(),void ct.info("Flag overrides set",{flags:e});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Nc){const{flags:t,flagVariants:s}=this.Td();try{e(t,s)}catch(i){this.$.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var i;const n=(this.dd("$early_access_features")||[]).find(u=>u.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};n&&(o.$early_access_feature_name=n.name),s&&(o.$feature_enrollment_stage=s);const a=p(p({},this.getFlagVariants()),{},{[e]:t});(i=this._instance)===null||i===void 0||(i=i.persistence)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this.At({[Ve]:Object.keys(so(a)),[Ae]:a,[st]:p(p({},this.dd("$stored_person_properties")||{}),r)}),this.od();try{var l;(l=this.lo)===null||l===void 0||l.capture("$feature_enrollment_update",o).catch(u=>{this.$.error("Failed to capture early access feature enrollment",u)})}catch(u){this.$.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(e,t=!1,s){const i=this.dd(Xi);!i||t?this.Id(e,s):e(i)}Id(e,t){var s=this;return Z(function*(){const i=s.lo;if(!i)return;const n=t?`&${t.map(o=>`stage=${o}`).join("&")}`:"";let r;try{const o=yield i.sendRequest(`/api/early_access_features/?token=${i.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,s.At({[Xi]:r})}catch(o){return void s.$.error("Early access feature request failed",o)}try{e(r)}catch(o){s.$.error("Early access feature callback failed",o)}})()}Td(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(s=>t[s]),flagVariants:Object.keys(t).filter(s=>t[s]).reduce((s,i)=>(s[i]=t[i],s),{})}}od(e){this.rd();const{flags:t,flagVariants:s}=this.Td();this.featureFlagEventHandlers.forEach(i=>{try{i(t,s,{errorsLoading:e})}catch(n){this.$.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(e,t=!0){this.Md(e,t)}Md(e,t=!0){const s=this.dd("$stored_person_properties")||{},i=(e==null?void 0:e.$set)||(e!=null&&e.$set_once?{}:e),n=e==null?void 0:e.$set_once,r={};if(n)for(const o in n)({}).hasOwnProperty.call(n,o)&&(o in s||(r[o]=n[o]));this.At({[st]:p(p(p({},s),r),i)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const s=p({},this.dd("$stored_person_properties")||{});e.forEach(i=>{delete s[i]}),this.At({[st]:s}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(st),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const s=this.dd("$stored_group_properties")||{},i=p({},s);for(const n of Object.keys(e))i[n]=p(p({},s[n]),e[n]);this.At({[it]:i}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.dd("$stored_group_properties")||{};this.At({[it]:p(p({},t),{},{[e]:{}})})}else this.Lt(it)}reset(){this.jc++,this.Hc=!1,this.Oc={},this.Dc={},this.vd=void 0,this.Nc=!1,this.Bc=!1,this.zc=!1,this.$anon_distinct_id=void 0,this.hd(),this.Fc=!1,this.Wc=0}}},xd={sessionRecording:class{get Sr(){return this._instance.config}get ga(){return this._instance.persistence}get started(){var e;return!!(!((e=this.Ed)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.Pd==="awaiting_config"||this.Pd==="missing_config"?this.Pd:(e=(t=this.Ed)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.Pd}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.Pd=Ai,this.Rd=void 0,this.Ad=!1,this.Ke=(()=>{var t,s;if(!(w!=null&&w.visibilityState)||w.visibilityState==="visible")return!0;const i=y==null||(t=y.performance)===null||t===void 0||(s=t.getEntriesByType)===null||s===void 0?void 0:s.call(t,"visibility-state");return!(i!=null&&i.length)||i.some(n=>n.name==="visible")})(),this.an=()=>{var t,s;(w==null?void 0:w.visibilityState)==="visible"&&(this.Ke=!0,(t=this.Ed)===null||t===void 0||(s=t.setDocumentWasEverVisible)===null||s===void 0||s.call(t,!0))},!this._instance.sessionManager)throw ze.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Sr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');w!=null&&w.addEventListener&&U(w,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.Ad=!0,w==null||(t=w.removeEventListener)===null||t===void 0||t.call(w,"visibilitychange",this.an),e?this.Fd(!0):this.stopRecording()}get Od(){var e;const t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),s=!this.Sr.disable_session_recording,i=this.Sr.disable_session_recording||this._instance.consent.isOptedOut();return y&&t&&s&&!i}startIfEnabledOrStop(e){var t;if(this.Ad||this.Od&&(!((t=this.Ed)===null||t===void 0)&&t.isStarted))return;const s=!b(Object.assign)&&!b(Array.from);this.Od&&s?(this.Dd(e),ze.info("starting")):(this.Pd=Ai,this.stopRecording())}Dd(e){var t,s;if(this.Od)if(this.Pd!=="awaiting_config"&&this.Pd!=="missing_config"&&(this.Pd=Gr),(O==null||(t=O.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((s=O.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this.Ld(e);else{var i,n;const r=this._instance.sessionManager;(i=O.__PosthogExtensions__)===null||i===void 0||(n=i.loadExternalDependency)===null||n===void 0||n.call(i,this._instance,this.Nd,o=>{if(!this.Ad&&this.Od&&this._instance.sessionManager===r)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),ze.error("could not load recorder",o)):void this.Ld(e);this.Pd="disabled"})}}stopRecording(){var e,t;(e=this.Rd)===null||e===void 0||e.call(this),this.Rd=void 0,(t=this.Ed)===null||t===void 0||t.stop()}Fd(e=!1){var t,s;(t=this.Rd)===null||t===void 0||t.call(this),this.Rd=void 0,(s=this.Ed)===null||s===void 0||s.discard({discardProducerEvents:e})}qd(){var e,t;(e=this.ga)===null||e===void 0||e.unregister("$session_is_sampled"),(t=this.ga)===null||t===void 0||t.unregister("$replay_sample_rate")}jd(e,t){if(M(e))return null;const s=ie(e)?e:parseFloat(e);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(ze.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):s;var i}Bd(e){if(this.ga){var t,s;const i=this.ga,n=()=>{var r;const o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.jd((r=this.Sr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),l=this.jd(o==null?void 0:o.sampleRate,"remote config sampleRate"),u=a??l;M(u)&&this.qd();const c=o==null?void 0:o.minimumDurationMilliseconds;i.register({[Yt]:p(p({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:p({capturePerformance:e.capturePerformance},o==null?void 0:o.networkPayloadCapture),canvasRecording:{enabled:o==null?void 0:o.recordCanvas,fps:o==null?void 0:o.canvasFps,quality:o==null?void 0:o.canvasQuality},sampleRate:u,minimumDurationMilliseconds:b(c)?null:c,endpoint:o==null?void 0:o.endpoint,triggerMatchType:o==null?void 0:o.triggerMatchType,masking:o==null?void 0:o.masking,urlTriggers:o==null?void 0:o.urlTriggers,version:o==null?void 0:o.version,triggerGroups:o==null?void 0:o.triggerGroups})})};n(),(t=this.Rd)===null||t===void 0||t.call(this),this.Rd=(s=this._instance.sessionManager)===null||s===void 0?void 0:s.onSessionId(n)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.Bd(t),void this.Fd()):(this.Bd(t),void this.startIfEnabledOrStop()):(this.Pd==="awaiting_config"&&(this.Pd="missing_config",ze.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var s;!((s=this.Ed)===null||s===void 0)&&s.log?this.Ed.log(e,t):ze.warn("log called before recorder was ready")}get Nd(){var e,t;const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(Yt);return(s==null||(t=s.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}Hd(){const e=this._instance.get_property(Yt);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return ze.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!M(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Ld(e){var t,s,i;if(!this.Ad&&this.Od&&this._instance.sessionManager){if(!(!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return ze.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[ga]:!0});var n;if(this.Ed||(this.Ed=(n=O.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording(this._instance,this.Ke),this.Ed._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Hd())return this.Pd==="missing_config"||this.Pd==="awaiting_config"?void 0:(this.Pd="awaiting_config",ze.info("persisted remote config is stale, requesting fresh config before starting"),void new qa(this._instance).load());this.Pd=Gr,(s=(i=this.Ed).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Ke),this.Ed.start(e)}else this.Pd=Ai}onRRwebEmit(e){var t,s;(t=this.Ed)===null||t===void 0||(s=t.onRRwebEmit)===null||s===void 0||s.call(t,e)}overrideLinkedFlag(){var e,t;this.Ed||(t=this.ga)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.Ed)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Ed||(t=this.ga)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.Ed)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,s;this.Ed||(s=this.ga)===null||s===void 0||s.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Ed)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Ed)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var s;return!!(!((s=this.Ed)===null||s===void 0)&&s.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.Ed)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},Sd={autocapture:class extends td{constructor(e){super(new sd(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.zd=this.Ud()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.Wd();return!!(e.path||e.search||this.Vd(e))}startIfEnabled(){this.isEnabled&&(k.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.zd=this.Ud(),this.startIfEnabled()}stop(){this.Gd&&this.Gd(),this.Gd=void 0,this.Zd&&this.Zd(),this.Zd=void 0,k.info("History API monitoring stopped")}monitorHistoryChanges(){y&&y.history&&(this.Qd("pushState"),this.Qd("replaceState"),this.Jd(),this.Vd()&&this.Kd())}Qd(e){var t;if(!y||!((t=y.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const s=this;ul(y.history,e,i=>function(n,r,o){i.call(this,n,r,o),s.Yd(e)})}Ud(){const e=y==null?void 0:y.location;if(e!=null&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}Wd(){const e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:T(e)?e:{}}Vd(e=this.Wd()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}Xd(e){const t=this.Wd(),s=this.zd;return!(!s||!(t.path&&e.pathname!==s.pathname||t.search&&e.search!==s.search||this.Vd(t)&&e.hash!==s.hash))}Yd(e){try{const t=this.Ud();if(!t)return;this.Xd(t)&&this._instance.capture(In,{navigation_type:e}),this.zd=t}catch(t){k.error(`Error capturing ${e} pageview`,t)}}Jd(){if(this.Gd)return;const e=()=>{this.Yd("popstate")};U(y,"popstate",e),this.Gd=()=>{y&&y.removeEventListener("popstate",e)}}Kd(){if(this.Zd)return;const e=()=>{this.Yd("hashchange")};U(y,"hashchange",e),this.Zd=()=>{y&&y.removeEventListener("hashchange",e)}}},heatmaps:class{get Sr(){return this.instance.config}constructor(e){var t;this.tv=!1,this.ho=!1,this.ev=null,this.instance=e,this.tv=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[Ji]),this.rageclicks=new ll(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return T(this.Sr.capture_heatmaps)&&this.Sr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Sr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return M(this.Sr.capture_heatmaps)?M(this.Sr.enable_heatmaps)?this.tv:this.Sr.enable_heatmaps:this.Sr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ho)return;od.info("starting..."),this.iv(),this.an()}else{var e;clearInterval((e=this.ev)!==null&&e!==void 0?e:void 0),this.nv(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const s=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ji]:s}),this.tv=s,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}sv(e){Mi(e.originalEvent)&&this._r(e.originalEvent,"deadclick")}an(){this.ev&&clearInterval(this.ev),this.ev=(w==null?void 0:w.visibilityState)==="visible"?setInterval(this.oa.bind(this),this.flushIntervalMilliseconds):null}iv(){y&&w&&(this.rv=this.oa.bind(this),U(y,zs,this.rv),this.ov=e=>this._r(e||(y==null?void 0:y.event)),U(w,"click",this.ov,{capture:!0}),this.lv=e=>this.av(e||(y==null?void 0:y.event)),U(w,"mousemove",this.lv,{capture:!0}),this.uv=new $r(this.instance,uc,this.sv.bind(this)),this.uv.startIfEnabledOrStop(),this.hv=this.an.bind(this),U(w,as,this.hv),this.ho=!0)}nv(){var e;y&&w&&(this.rv&&y.removeEventListener(zs,this.rv),this.ov&&w.removeEventListener("click",this.ov,{capture:!0}),this.lv&&w.removeEventListener("mousemove",this.lv,{capture:!0}),this.hv&&w.removeEventListener(as,this.hv),clearTimeout(this.dv),(e=this.uv)===null||e===void 0||e.stop(),this.ho=!1)}vv(e,t){const s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(o,a,l){let u=o;for(;u&&Be(u)&&!ge(u,"body");){if(u===l)return!1;let h;try{var c,d,f;h=(c=(d=(f=u.ownerDocument)===null||f===void 0?void 0:f.defaultView)!==null&&d!==void 0?d:y)===null||c===void 0?void 0:c.getComputedStyle(u).position}catch{return!1}if(A(a,h))return!0;u=$a(u)}return!1})(Xt(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:i),y:e.clientY+(r?0:s),target_fixed:r,type:t}}_r(e,t="click"){var s;if(pr(e.target)||!Mi(e))return;const i=this.vv(e,t);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Ea(Xt(e),this.instance.config.rageclick)&&this.Hs(p(p({},i),{},{type:"rageclick"})),this.Hs(i)}av(e){!pr(e.target)&&Mi(e)&&(clearTimeout(this.dv),this.dv=setTimeout(()=>{this.Hs(this.vv(e,"mousemove"))},500))}Hs(e){if(!y)return;const t=this.Sr.disable_capture_url_hashes?ot(y.location.href):y.location.href,s=this.Sr.custom_personal_data_properties,i=this.Sr.mask_personal_data_properties?[...Mt,...s||[]]:[],n=cs(t,i,ds);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(e)}oa(){this.Rt&&!$e(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:$r,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.tv=!1,this.ho=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.fv=()=>{clearTimeout(this.pv),this.pv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",p({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>p(p({},s),{},{[`$web_vitals_${i.name}_event`]:p({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.gv=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},M(s==null?void 0:s.name)||M(s==null?void 0:s.value))return void ut.error("Invalid metric received",s);const n=typeof s.navigationURL=="string"?s.navigationURL:void 0,r=this.mv(n);if(b(r))return;const o=ie(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${r}`;if(this.yv&&s.value>=this.yv)return void ut.error("Ignoring metric with value >= "+this.yv,s);this.Rt.navigationKey!==o&&(this.fv(),this.pv=setTimeout(this.fv,this.flushToCaptureTimeoutMs)),b(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=r),this.Rt.firstMetricTimestamp=b(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const a=(i=this._instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0),l=p(p(p({},s),n?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete l.entries,T(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){const u={};for(const c of rd){const d=c==="url"&&typeof s.attribution[c]=="string"?this.mv(s.attribution[c]):s.attribution[c];b(d)||(u[c]=d)}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.fv()},this.bv=()=>{if(this.ho)return;let s,i,n,r,o=!1;const a=O.__PosthogExtensions__,l=a==null?void 0:a.postHogWebVitalsCallbacksByFlavor,u=(l==null?void 0:l[this._v])||(this._v==="web-vitals"&&b(l)?a==null?void 0:a.postHogWebVitalsCallbacks:void 0);if(!b(u)){const f=u.withoutAttribution,h=this.attributionMetrics;o=!b(f),s=h.indexOf("LCP")>-1?u.onLCP:(f==null?void 0:f.onLCP)||u.onLCP,i=h.indexOf("CLS")>-1?u.onCLS:(f==null?void 0:f.onCLS)||u.onCLS,n=h.indexOf("FCP")>-1?u.onFCP:(f==null?void 0:f.onFCP)||u.onFCP,r=h.indexOf("INP")>-1?u.onINP:(f==null?void 0:f.onINP)||u.onINP}if(!(s&&i&&n&&r))return void ut.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},d=o&&this.attributionMetrics.indexOf("INP")>-1?p(p({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&s(this.gv.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.gv.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&n(this.gv.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&r(this.gv.bind(this),d),this.ho=!0},this.tv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[Zi]),this.startIfEnabled()}get wv(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const s=T(this.wv)?(e=this.wv)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return M(s)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||Wr:s}get flushToCaptureTimeoutMs(){return(T(this.wv)?this.wv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=T(this.wv)?this.wv.web_vitals_attribution:void 0;return we(e)?e?Wr:[]:R(e)?e:nd}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=T(this.wv)?this.wv.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get yv(){const e=T(this.wv)&&ie(this.wv.__web_vitals_max_value)?this.wv.__web_vitals_max_value:Vr;return e>0&&6e4>=e?Vr:e}get isEnabled(){const e=ee==null?void 0:ee.protocol;if(e!=="http:"&&e!=="https:")return ut.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=T(this.wv)?this.wv.web_vitals:we(this.wv)?this.wv:void 0;return we(t)?t:this.tv}startIfEnabled(){this.isEnabled&&!this.ho&&(ut.info("enabled, starting..."),this.Eo(this.bv))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const s=T(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=T(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Zi]:s}),this._instance.persistence.register({[ra]:i})),this.tv=s,this.startIfEnabled()}get _v(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Eo(e){var t;const s=O.__PosthogExtensions__,i=this._v,n=s==null?void 0:s.postHogWebVitalsCallbacksByFlavor;n!=null&&n[i]||i==="web-vitals"&&b(n)&&(s!=null&&s.postHogWebVitalsCallbacks)?e():s==null||(t=s.loadExternalDependency)===null||t===void 0||t.call(s,this._instance,i,r=>{r?ut.error("failed to load script",r):e()})}mv(e){const t=e||(y==null?void 0:y.location.href);if(!t)return void ut.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?ot(t):t,i=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Mt,...i||[]]:[];return cs(s,n,ds)}}},$d={exceptionObserver:class{constructor(e){var t;this.bv=()=>{var s;if(!y||!this.isEnabled||!(!((s=O.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;const i=O.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=O.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=O.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Sv&&this.Sr.capture_unhandled_errors&&(this.Sv=i(this.captureException.bind(this))),!this.xv&&this.Sr.capture_unhandled_rejections&&(this.xv=n(this.captureException.bind(this))),!this.Cv&&this.Sr.capture_console_errors&&(this.Cv=r(this.captureException.bind(this)))}catch(o){Vt.error("failed to start",o),this.$v()}},this._instance=e,this.Tv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[Ki]),this.wt=new El(p(p({},(function(s={}){var i,n,r,o;return{refillRate:(i=(n=s.exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(r=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:Vt})),this.Sr=this.Iv(),this.startIfEnabledOrStop()}Iv(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return T(e)?t=p(p({},t),e):(b(e)?this.Tv:e)&&(t=p(p({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Sr.capture_console_errors||this.Sr.capture_unhandled_errors||this.Sr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Vt.info("enabled"),this.$v(),this.Eo(this.bv)):this.$v()}Eo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",n=>{if(n)return Vt.error("failed to load script",n);e()})}$v(){var e,t,s;(e=this.Sv)===null||e===void 0||e.call(this),this.Sv=void 0,(t=this.xv)===null||t===void 0||t.call(this),this.xv=void 0,(s=this.Cv)===null||s===void 0||s.call(this),this.Cv=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.Tv=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ki]:this.Tv}),this.Sr=this.Iv(),this.startIfEnabledOrStop())}onConfigChange(){this.Sr=this.Iv()}captureException(e){try{var t,s,i;const n=(t=e==null||(s=e.$exception_list)===null||s===void 0||(s=s[0])===null||s===void 0?void 0:s.type)!==null&&t!==void 0?t:"Exception";if(this.wt.consumeRateLimit(n))return void Vt.info("Skipping exception capture because of client rate limiting.",{exception:n});(i=this._instance.exceptions)===null||i===void 0||i.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){var t,s;this.Mv=[],this.Ev=new Nl([new Yl,new ru,new Xl,new Zl,new iu,new su,new eu,new nu],(function(i,...n){return(r,o=0)=>{const a=[],l=r.split(`
3
+ `),u=Math.min(l.length,o+1e3),c=[];for(let h=o;u>h;h++){const g=l[h];if(g.length>1024)continue;const v=Zn.test(g)?g.replace(Zn,"$1"):g;if(!v.match(/\S*Error: /)){for(const _ of n){const m=_(v,i);if(m){a.push(m);const x=Wl(a);if(x){for(let S=c.length-1;S>=0;S--){const C=c[S];if(x.start>=C.start+C.length)break;c.pop()}c.push(x)}break}}if(Jl(a,c)>=50)break}}const d=[...c].sort((h,g)=>g.start-h.start),f=d[d.length-1];if(f){const h=Vo(a,f);a.splice(f.start-h,h);for(const g of d)g.start-=h}for(const h of d)Gl(a,h);return c.some(h=>h.start===0&&a.length===h.length)&&(function(h){const g=h.map(_=>`${_.function}|${_.filename}|${_.lineno}|${_.colno}|${_.module}`);let v=0;for(let _=1;g.length>_;_++)Kl(g,_,v)&&(v=_);h.push(...h.splice(0,v))})(a),(function(h){if(!h.length)return[];const g=Array.from(h);return g.reverse(),g.slice(0,50).map(v=>{return p(p({},v),{},{filename:v.filename||(_=g,_[_.length-1]||{}).filename,function:v.function||"?"});var _})})(a)}})("web:javascript",zl,Vl)),this._instance=e,this.Mv=(t=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.Pv=Ds(this.Rv()),this.Av=new au(this.Pv)}onConfigChange(){this.Pv=Ds(this.Rv()),this.Av.setConfig(this.Pv)}onRemoteConfig(e){var t,s,i;if(!e.ok)return;const n=e.config;if(!("errorTracking"in n))return;const r=(t=(s=n.errorTracking)===null||s===void 0?void 0:s.suppressionRules)!==null&&t!==void 0?t:[],o=(i=n.errorTracking)===null||i===void 0?void 0:i.captureExtensionExceptions;this.Mv=r,this._instance.persistence&&this._instance.persistence.register({[ia]:this.Mv,[Yi]:o})}get Fv(){var e;const t=!!this._instance.get_property(Yi),s=this._instance.config.error_tracking.captureExtensionExceptions;return(e=s??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.Ev.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}addExceptionStep(e,t){if(this.Pv.enabled)try{if(!L(e)||e.trim().length===0)return void Oe.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:s,droppedKeys:i}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};const r=[];return{sanitizedProperties:Object.keys(n).reduce((o,a)=>ou.has(a)?(r.push(a),o):(o[a]=n[a],o),{}),droppedKeys:r}})(this.Ov(t));i.length>0&&Oe.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.Av.add(p({[Ts]:e,[Ls]:new Date().toISOString()},s))}catch(s){Oe.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this.Dv(t)){if(this.Lv(t))return this.Nv("Exception dropped: matched a suppression rule"),void Oe.info("Skipping exception capture because a suppression rule matched");if(!this.Fv&&this.qv(t))return this.Nv("Exception dropped: thrown by a browser extension"),void Oe.info("Skipping exception capture because it was thrown by an extension");if(!this.Fv&&this.jv(t))return this.Nv("Exception dropped: thrown by an injected browser script"),void Oe.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Bv(t))return this.Nv("Exception dropped: thrown by the PostHog SDK"),void Oe.info("Skipping exception capture because it was thrown by the PostHog SDK")}const s=this.Pv.enabled&&M(e.$exception_steps)?this.Hv(e):e,i=(function(){const n=globalThis._posthogReleaseId;return typeof n=="string"&&n.length>0?n:void 0})();i&&(s.$release_id=i);try{const n=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",Gu:!0});return n&&this.Av.clear(),n}catch(n){return io(n)||Oe.error("Failed to capture exception event. Dropping this exception.",n),void this.Av.clear()}}catch(t){return void(io(t)||Oe.error("Failed to process exception event. Ignoring this exception.",t))}}Hv(e){try{const t=this.Av.getAttachable();return t.length===0?e:p(p({},e),{},{$exception_steps:t})}catch(t){return Oe.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}Nv(e){this.Pv.enabled&&this.Av.add({[Ts]:e,[Ls]:new Date().toISOString()})}Ov(e){return T(e)?p({},e):{}}Rv(){var e,t;return(e=(t=this._instance.config.error_tracking)===null||t===void 0?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}Lv(e){if(e.length===0)return!1;try{const t=e.reduce((s,{type:i,value:n})=>(L(i)&&i.length>0&&s.$exception_types.push(i),L(n)&&n.length>0&&s.$exception_values.push(n),s),{$exception_types:[],$exception_values:[]});return this.Mv.some(s=>{const i=s.values.map(n=>{const r=il[n.operator],o=t[n.key];if(!r||!o)return!1;const a=R(n.value)?n.value:[n.value];return a.length>0&&r(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(t){return Oe.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qv(e){const t=e.flatMap(i=>{var n,r;return(n=(r=i.stacktrace)===null||r===void 0?void 0:r.frames)!==null&&n!==void 0?n:[]}),s=t.filter(({filename:i})=>!!i&&_d.some(n=>i.startsWith(n)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(gn))||e.some(({type:i,value:n})=>i==="NoResponse"||L(n)&&gd.some(({value:r,exact:o})=>o?n===r:n.includes(r)))&&!t.some(({in_app:i,filename:n})=>i&&!(n!=null&&n.startsWith(gn))))}jv(e){return e.some(({value:t})=>L(t)&&md.some(s=>t.includes(s)))}Bv(e){if(e.length>0){var t,s,i,n;const r=(t=(s=e[0].stacktrace)===null||s===void 0?void 0:s.frames)!==null&&t!==void 0?t:[],o=r[r.length-1];return(i=o==null||(n=o.filename)===null||n===void 0?void 0:n.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Dv(e){return!M(e)&&R(e)}}},kd=p({productTours:class{get ga(){return this._instance.persistence}constructor(e){this.zv=null,this.Uv=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var s,i;if(this.ga&&this.ga.register({[En]:!!t.productTours}),!Ti(this._instance))return!this.zv&&M((s=this.ga)===null||s===void 0?void 0:s.props.ph_product_tours)||$s.info("product tours disabled; stopping and clearing cached tours"),(i=this.zv)===null||i===void 0||i.stop(),this.zv=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.zv&&Ti(this._instance)&&this.Eo(()=>this.Wv())}Eo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",n=>{n?$s.error("Could not load product tours script",n):e()})}Wv(){var e;!this.zv&&(!((e=O.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.zv=O.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(R(this.Uv)&&!t)return void e(this.Uv,{isLoaded:!0});const s=this.ga;if(s){const i=s.props[en];if(R(i)&&!t)return this.Uv=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:i=>{if(!Ti(this._instance))return void e([],{isLoaded:!0});const n=i.statusCode;if(n!==200||!i.json){const o=`Product Tours API could not be loaded, status: ${n}`;return n===0?i.error||$s.warn(o):$s.error(o),void e([],{isLoaded:!1,error:o})}const r=R(i.json.product_tours)?i.json.product_tours:[];this.Uv=r,s&&s.register({[en]:r}),e(r,{isLoaded:!0})}})}getActiveProductTours(e){M(this.zv)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.zv.getActiveProductTours(e)}showProductTour(e){var t;(t=this.zv)===null||t===void 0||t.showTourById(e)}previewTour(e){this.zv?this.zv.previewTour(e):this.Eo(()=>{var t;this.Wv(),(t=this.zv)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.zv)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.zv)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.zv)===null||e===void 0||e.previousStep()}clearCache(){var e;this.Uv=null,(e=this.ga)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.zv)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.zv)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.zv)===null||t===void 0||t.cancelPendingTour(e)}}},ei),Ed={siteApps:class{constructor(e){this._instance=e,this.Vv=0,this.Gv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zv(e,t){if(!t)return;const s=this.globalsForEvent(t);this.Gv.push(s),this.Gv.length>1e3&&(this.Gv=this.Gv.slice(10))}get siteAppLoaders(){var e;return(e=O._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this.Zv.bind(this));this.Qv=()=>{e(),this.Gv=[],this.Qv=void 0}}}globalsForEvent(e){var t,s,i,n,r,o,a;if(!e)throw new Error("Event payload is required");const l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(const[h,g]of Object.entries(c))l[h]={id:u[h],type:h,properties:g};const{$set_once:d,$set:f}=e;return{event:p(p({},Ko(e,ad)),{},{properties:p(p(p({},e.properties),f?{$set:p(p({},(t=(s=e.properties)===null||s===void 0?void 0:s.$set)!==null&&t!==void 0?t:{}),f)}:{}),d?{$set_once:p(p({},(i=(n=e.properties)===null||n===void 0?void 0:n.$set_once)!==null&&i!==void 0?i:{}),d)}:{}),elements_chain:(r=(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(a=e.properties)===null||a===void 0?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}Jv(e){var t;const s=(t=e.tagName)===null||t===void 0?void 0:t.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Le.error("prepare_external_dependency_stylesheet returned null"),null):s==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Le.error("prepare_external_dependency_script returned null"),null):e}Kv(){var e,t,s,i,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=w==null?void 0:w.defaultView,u=l==null||(e=l.Node)===null||e===void 0?void 0:e.prototype;if(!l||!u)return()=>{};if(this.Vv++,this.Yv)return this.Xv();const c=[],d=this,f=new WeakSet,h=(_,m,x)=>{if(!(_!=null&&_[m]))return;const S=_[m];_[m]=x(S),c.push(()=>{_[m]=S})},g=_=>{if(f.has(_))return _;const m=d.Jv(_);return m&&f.add(m),m},v=_=>_.map(m=>typeof m=="string"?m:g(m)).filter(m=>!se(m));return h(u,"appendChild",_=>function(m){const x=g(m);return x?_.call(this,x):m}),h(u,"insertBefore",_=>function(m,x){const S=g(m);return S?_.call(this,S,x):m}),h(u,"replaceChild",_=>function(m,x){const S=g(m);return S?_.call(this,S,x):x}),[(t=l.Element)===null||t===void 0?void 0:t.prototype,(s=l.Document)===null||s===void 0?void 0:s.prototype,(i=l.DocumentFragment)===null||i===void 0?void 0:i.prototype].forEach(_=>{h(_,"append",m=>function(...x){return m.apply(this,v(x))}),h(_,"prepend",m=>function(...x){return m.apply(this,v(x))})}),[(n=l.Element)===null||n===void 0?void 0:n.prototype,(r=l.CharacterData)===null||r===void 0?void 0:r.prototype,(o=l.DocumentType)===null||o===void 0?void 0:o.prototype].forEach(_=>{h(_,"before",m=>function(...x){return m.apply(this,v(x))}),h(_,"after",m=>function(...x){return m.apply(this,v(x))}),h(_,"replaceWith",m=>function(...x){const S=v(x);return x.length&&!S.length?void 0:m.apply(this,S)})}),h((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",_=>function(m,x){const S=g(x);return S?_.call(this,m,S):null}),this.Yv=()=>{c.forEach(_=>_()),this.Yv=void 0},this.Xv()}Xv(){let e=!1;return()=>{var t;e||(e=!0,this.Vv--,this.Vv===0&&((t=this.Yv)===null||t===void 0||t.call(this)))}}tf(e,t=!0){const s=this.Kv();try{const i=e(s);return t&&s(),i}catch(i){throw s(),i}}setupSiteApp(e){const t=this.apps[e.id],s=()=>{var r;!t.errored&&this.Gv.length&&(Le.info(`Processing ${this.Gv.length} events for site app with id ${e.id}`),this.Gv.forEach(o=>this.tf(()=>{var a;return(a=t.processEvent)===null||a===void 0?void 0:a.call(t,o)})),t.processedBuffer=!0),Object.values(this.apps).every(o=>o.processedBuffer||o.errored)&&((r=this.Qv)===null||r===void 0||r.call(this))};let i=!1;const n=r=>{t.errored=!r,t.loaded=!0,Le.info(`Site app with id ${e.id} ${r?"loaded":"errored"}`),i&&s()};try{const{processEvent:r}=this.tf(o=>e.init({posthog:this._instance,callback(a){o(),n(a)}}),!1);r&&(t.processEvent=r),i=!0}catch(r){Le.error(Jr+e.id,r),n(!1)}if(i&&t.loaded)try{s()}catch(r){Le.error(`Error while processing buffered events PostHog app with config id ${e.id}`,r),t.errored=!0}}ef(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}if(e){if(Object.keys(this.apps).length===0)return;const t=this.globalsForEvent(e);for(const s of Object.values(this.apps))try{this.tf(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,t)})}catch(i){Le.error(`Error while processing event ${e.event} for site app ${s.id}`,i)}}onRemoteConfig(e){var t,s,i;if(!((t=this.siteAppLoaders)===null||t===void 0)&&t.length)return this.isEnabled?(this.ef(),void this._instance.on("eventCaptured",a=>this.if(a))):void Le.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Qv)===null||s===void 0||s.call(this),!e.ok)return;const n=e.config;if(!((i=n.siteApps)===null||i===void 0)&&i.length)if(this.isEnabled)for(const{id:a,url:l}of n.siteApps){var r,o;O[`__$$ph_site_app_${a}`]=this._instance,(r=O.__PosthogExtensions__)===null||r===void 0||(o=r.loadSiteApp)===null||o===void 0||o.call(r,this._instance,l,u=>{if(u)return Le.error(Jr+a,u)})}else Le.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Pd={tracingHeaders:class{constructor(e){this._instance=e,this.nf=void 0,this.sf=void 0,this.rf=void 0,this.bv=()=>{const t=this.lf();var s,i;t?(b(this.nf)&&(this.nf=(s=O.__PosthogExtensions__)===null||s===void 0||(s=s.tracingHeadersPatchFns)===null||s===void 0?void 0:s._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),b(this.sf)&&(this.sf=(i=O.__PosthogExtensions__)===null||i===void 0||(i=i.tracingHeadersPatchFns)===null||i===void 0?void 0:i._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.$v()}}initialize(){this.startIfEnabledOrStop()}Eo(e){var t,s,i;!((t=O.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(s=O.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",n=>{if(n)return id.error("failed to load script",n);e()})}af(){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}lf(){const e=this.af();return R(e)?(R(this.rf)?this.rf.splice(0,this.rf.length,...e):this.rf=[...e],e.length>0?this.rf:void 0):(R(this.rf)&&this.rf.splice(0),this.rf=e||void 0,this.rf)}$v(){var e,t;(e=this.nf)===null||e===void 0||e.call(this),(t=this.sf)===null||t===void 0||t.call(this),this.nf=void 0,this.sf=void 0}startIfEnabledOrStop(){this.lf()?this.Eo(this.bv):this.$v()}}},Fd=p({surveys:class extends ld{constructor(e){var t;super(new fd(e),(t=e,{get projectToken(){return t.config.token},kv:new hd(t)})),this._instance=e}wh(e,t){const s=t.query?fs(e,t.query):e;return new Promise(i=>{var n;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((n=t.target)!==null&&n!==void 0?n:"api",s),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:i})})}}},ei),Id={toolbar:class{constructor(e){this.instance=e}uf(e){O.ph_toolbar_state=e}hf(){var e;return(e=O.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,s=void 0){var i,n;if(nn(this.instance.config)||!y||!w)return!1;e=(i=e)!==null&&i!==void 0?i:y.location,s=(n=s)!==null&&n!==void 0?n:y.history;try{if(!t){try{y.localStorage.setItem("test","test"),y.localStorage.removeItem("test")}catch{return!1}t=y==null?void 0:y.localStorage}const r=pd||Us(e.hash,"__posthog")||Us(e.hash,"state");let o;const a=r?cr(()=>JSON.parse(atob(decodeURIComponent(r))))||cr(()=>JSON.parse(decodeURIComponent(r))):null;return a&&a.action==="ph_authorize"?(o=a,o.source="url",o&&Object.keys(o).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):(o=JSON.parse(t.getItem(Yr)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}cf(e){const t=O.ph_load_toolbar||O.ph_load_editor;!M(t)&&ve(t)?t(e,this.instance):Zr.warn("No toolbar load function found")}loadToolbar(e){const t=!!(w!=null&&w.getElementById("__POSTHOG_TOOLBAR__"));if(!y||t)return!1;const s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=p(p({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(y.localStorage.setItem(Yr,JSON.stringify(p(p({},i),{},{source:void 0}))),this.hf()===2)this.cf(i);else if(this.hf()===0){var n,r;this.uf(1),(n=O.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,"toolbar",o=>{if(o)return Zr.error("[Toolbar] Failed to load",o),void this.uf(0);this.uf(2),this.cf(i)}),U(y,"turbolinks:load",()=>{this.uf(0),this.loadToolbar(i)})}return!0}df(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,s=void 0){return this.maybeLoadToolbar(e,t,s)}}},Od=p({experiments:class me{get Sr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{me.vf("retrieved web experiments from the server"),this.ff=new Map,i.forEach(n=>{if(n.feature_flag_key){var r;this.ff&&(me.vf("setting flag key ",n.feature_flag_key," to web experiment ",n),(r=this.ff)===null||r===void 0||r.set(n.feature_flag_key,n));const o=this._instance.getFeatureFlag(n.feature_flag_key);L(o)&&n.variants[o]&&this.pf(n.name,o,n.variants[o].transforms)}else if(n.variants)for(const o in n.variants){const a=n.variants[o];me.gf(a,this._instance)&&this.pf(n.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(t){if(this._is_bot())me.vf(no);else if(!this.Sr.disable_web_experiments){if(M(this.ff))return this.ff=new Map,this.loadIfEnabled(),void this.previewWebExperiment();me.vf("applying feature flags",t),t.forEach(s=>{var i;if(this.ff&&(!((i=this.ff)===null||i===void 0)&&i.has(s))){var n;const r=this._instance.getFeatureFlag(s),o=(n=this.ff)===null||n===void 0?void 0:n.get(s);r&&(o!=null&&o.variants[r])&&this.pf(o.name,r,o.variants[r].transforms)}})}}previewWebExperiment(){const t=me.getWindowLocation();if(t!=null&&t.search){const s=At(t==null?void 0:t.search,"__experiment_id"),i=At(t==null?void 0:t.search,"__experiment_variant");s&&i&&(me.vf(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(n=>{this.mf(parseInt(s),i,n)},!1,!0))}}loadIfEnabled(){this.Sr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,s,i){if(this.Sr.disable_web_experiments&&!i)return t([]);const n=this._instance.get_property("$web_experiments");if(n&&!s)return t(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Sr.token}`),method:"GET",timestampMode:"query",callback:r=>t(r.statusCode===200&&r.json&&r.json.experiments||[])})}mf(t,s,i){const n=i.filter(r=>r.id===t);n&&n.length>0&&(me.vf(`Previewing web experiment [${n[0].name}] with variant [${s}]`),this.pf(n[0].name,s,n[0].variants[s].transforms))}static gf(t,s){return!M(t.conditions)&&me.yf(t,s)&&me.bf(t)}static yf(t,s){var i;if(M(t.conditions)||M((i=t.conditions)===null||i===void 0?void 0:i.url))return!0;const n=me.getWindowLocation();if(n){var r,o,a;const l=wa(s,n.href);return!(!((r=t.conditions)===null||r===void 0)&&r.url)||yd[(o=(a=t.conditions)===null||a===void 0?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return y==null?void 0:y.location}static bf(t){var s;if(M(t.conditions)||M((s=t.conditions)===null||s===void 0?void 0:s.utm))return!0;const i=Aa();if(i.utm_source){var n,r,o,a,l,u,c,d;const f=!(!((n=t.conditions)===null||n===void 0||(n=n.utm)===null||n===void 0)&&n.utm_campaign)||((r=t.conditions)===null||r===void 0||(r=r.utm)===null||r===void 0?void 0:r.utm_campaign)==i.utm_campaign,h=!(!((o=t.conditions)===null||o===void 0||(o=o.utm)===null||o===void 0)&&o.utm_source)||((a=t.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_source)==i.utm_source,g=!(!((l=t.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((u=t.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0?void 0:u.utm_medium)==i.utm_medium,v=!(!((c=t.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0)&&c.utm_term)||((d=t.conditions)===null||d===void 0||(d=d.utm)===null||d===void 0?void 0:d.utm_term)==i.utm_term;return f&&g&&v&&h}return!1}static vf(t,...s){k.info(`[WebExperiments] ${t}`,s)}pf(t,s,i){this._is_bot()?me.vf(no):s!=="control"?i.forEach(n=>{if(n.selector){var r;me.vf(`applying transform of variant ${s} for experiment ${t} `,n);const o=(r=document)===null||r===void 0?void 0:r.querySelectorAll(n.selector);o==null||o.forEach(a=>{const l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)})}}):me.vf("Control variants leave the page unmodified.")}_is_bot(){return fe&&this._instance?el(fe,this.Sr.custom_blocked_useragents):void 0}}},ei),Cd={conversations:class{constructor(e){this._instance=e,this._f=void 0,this._conversationsManager=null,this.wf=!1,this.ne=null,this.kf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Sf=e.ok,!e.ok))return;const t=e.config.conversations;M(t)||(we(t)?this._f=t:(this._f=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this._f=void 0,this.ne=null,this.Sf=void 0,this.kf=!1}loadIfEnabled(){if(this._conversationsManager||this.wf||this._instance.config.disable_conversations||nn(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=O==null?void 0:O.__PosthogExtensions__;if(e&&!b(this._f)&&this._f)if(this.ne&&this.ne.token){this.wf=!0;try{const t=e.initConversations;if(t)return this.xf(t),void(this.wf=!1);const s=e.loadExternalDependency;if(!s)return void this.Cf(Fn);s(this._instance,"conversations",i=>{i||!e.initConversations?this.Cf("Could not load conversations script",i):this.xf(e.initConversations),this.wf=!1})}catch(t){this.Cf("Error initializing conversations",t),this.wf=!1}}else Pe.error("Conversations enabled but missing token in remote config.")}xf(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.kf=!1,Pe.info("Conversations loaded successfully")}catch(t){this.Cf("Error completing conversations initialization",t)}else Pe.error("Cannot complete initialization: remote config is null")}Cf(e,t){Pe.error(e,t),this._conversationsManager=null,this.wf=!1,this.kf=!0}show(){this._conversationsManager?this._conversationsManager.show():Pe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this._f===!0&&!se(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":nn(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Sf===!1?"remote_config_failed":b(this._f)?this.Sf?"disabled_in_project":"remote_config_pending":this._f?M(this.ne)||!this.ne.token?"missing_token":O!=null&&O.__PosthogExtensions__?this.wf?"initializing":this.kf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,s){var i=this;return Z(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,s):(Pe.warn(dt),null)})()}getMessages(e,t){var s=this;return Z(function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,t):(Pe.warn(dt),null)})()}markAsRead(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Pe.warn(dt),null)})()}getTickets(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Pe.warn(dt),null)})()}requestRestoreLink(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Pe.warn(dt),null)})()}restoreFromToken(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Pe.warn(dt),null)})()}restoreFromUrlToken(){var e=this;return Z(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Pe.warn(dt),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}ih(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}nh(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},Rd={logs:class{constructor(e){var t;this._instance=e,this.name="logs",this.$f=!1,this.Tf=!1,this.If=!1,this.$=ne("[logs]"),this.Mf=p(p({},this.$),{},{error:(...s)=>{s.some(ao)||this.$.error(...s)}}),this.Zl=[],this.Ef=[],this.Wc=0,this.fo=!1,this.Pf=[],this.Rf=[],this.Af=!1,this.Ff=!1,this.Of=()=>{var s,i;this.fo||(this.Wc=0,(s=this.Df)===null||s===void 0||s.onReconnect(),(i=this.Lf)===null||i===void 0||i.onReconnect())},this._instance&&(!((t=this._instance.config.logs)===null||t===void 0)&&t.captureConsoleLogs)&&(this.$f=!0),y&&U(y,"online",this.Of)}Nf(e,t,s,i){var n;const r=ro((n=this._instance)===null||n===void 0||(n=n.config)===null||n===void 0?void 0:n.logs,s);return[new gu(this.qf(e,t),r,this.Mf,()=>this.jf(),o=>o(),void 0,i),r]}Bf(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var s;return this.Df&&this.Hf===t||((s=this.Df)===null||s===void 0||s.reset(),this.Hf=t,[this.Df,this.zf]=this.Nf(()=>this.Zl,i=>{this.Zl=i})),this.Df}Uf(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var s;return this.Lf&&this.Wf===t||((s=this.Lf)===null||s===void 0||s.reset(),this.Wf=t,[this.Lf,this.Vf]=this.Nf(()=>this.Ef,i=>{this.Ef=i},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},oo)),this.Lf}setup(e){var t;if(this.fo)return;this.lo=e,!((t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0||(t=t.logs)===null||t===void 0)&&t.captureConsoleLogs&&(this.$f=!0),(this.$f||this.Gf()&&this.Zf())&&this.Qf();let s=!1;const i=e.onRemoteConfig(n=>{var r;s=n.ok&&((r=n.config.logs)===null||r===void 0?void 0:r.captureConsoleLogs)===!0,this.onRemoteConfig(n)});this.fo?i.dispose():(this.yo=i,s||this.loadIfEnabled())}dispose(){var e,t,s,i;this.fo||(this.fo=!0,this.Jf(),(e=this.yo)===null||e===void 0||e.dispose(),this.yo=void 0,this.lo=void 0,this.If=!1,y==null||y.removeEventListener("online",this.Of),(t=this.Kf)===null||t===void 0||t.call(this),this.Kf=void 0,(s=this.Df)===null||s===void 0||s.reset(),(i=this.Lf)===null||i===void 0||i.reset())}onRemoteConfig(e){var t,s;if(this.fo)return;const i=e.ok?(t=e.config.logs)===null||t===void 0?void 0:t.captureConsoleLogs:void 0;M(i)?this.Yf():((s=this._instance)===null||s===void 0||(s=s.persistence)===null||s===void 0||s.register({$logs_capture_enabled_server_side:!!i}),i?(this.$f=!0,this.Tf||this.Qf(),this.loadIfEnabled()):this.Yf())}reset(){var e,t,s,i;this.Jf(),(e=this.Df)===null||e===void 0||e.clearQueue(),this.Zl=[],(t=this.Df)===null||t===void 0||t.reset(),(s=this.Lf)===null||s===void 0||s.clearQueue(),this.Ef=[],(i=this.Lf)===null||i===void 0||i.reset(),this.Wc=0}captureLog(e){this.fo||this.Bf().captureLog(e)}captureConsoleLog(e){this.fo||this.Uf().captureLog(e)}captureBufferedConsoleLog(e,t,s){this.fo||this.Uf().captureLog(e,{context:t,occurredAtMs:s})}Zf(){var e;return!!(!((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e[na])}Gf(){var e,t,s;return!(!((e=this._instance)===null||e===void 0||(t=e.Ul)===null||t===void 0)&&t.call(e))||!!(!((s=O._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[this._instance.config.token])===null||s===void 0)&&s.config)}rh(){var e;this.Jf(),(e=this.Lf)===null||e===void 0||e.clearQueue(),this.Ef=[]}Yf(){this.$f||this.Jf()}Qf(){var e;if(this.Af||!(O!=null&&O.console))return;const t=ro((e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs).maxBufferSize;for(const s of bd){let i;try{i=wd(O.console[s])}catch{continue}i&&this.Rf.push(ul(O.console,s,n=>{const r=(...o)=>{try{this.Xf(s,o,t)}catch{}return n.apply(O.console,o)};return r.__rrweb_original__=i,r}))}this.Af=!0,this.tp=setTimeout(()=>{this.Jf()},3e4)}Xf(e,t,s){var i;if(this.Af&&!this.Ff&&t.length!==0)if(!((i=this._instance)===null||i===void 0)&&i.is_capturing()){if(s>this.Pf.length){this.Ff=!0;try{this.Pf.push({level:e,args:t,occurredAtMs:Date.now(),context:this.jf()})}finally{this.Ff=!1}}}else this.Jf()}Jf(){if(this.Pf=[],this.Af){this.Af=!1,this.tp&&(clearTimeout(this.tp),this.tp=void 0);for(const e of this.Rf)e();this.Rf=[]}}ep(){const e=this.Pf;return this.Jf(),e}get logger(){return this.np||(this.np={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.np}flushLogs(e){e?this.sp(e):(this.Df&&this.Df.flush().catch(t=>this.rp(t)),this.Lf&&this.Lf.flush().catch(t=>this.rp(t)))}rp(e){ao(e)||this.$.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.fo||!this.$f||this.Tf||this.If)return;const e=O==null?void 0:O.__PosthogExtensions__;if(!e)return this.$.error("PostHog Extensions not found."),void this.Jf();const t=e.loadExternalDependency;if(!t)return this.$.error(Fn),void this.Jf();this.If=!0;try{t(this._instance,"logs",s=>{if(this.If=!1,this.fo||!this.$f)return;const i=e.logs;if(s||!(i!=null&&i.initializeLogs))this.$.error("Could not load logs script",s),this.Jf();else{var n;const a=this.ep();var r,o;this.Kf=i.initializeLogs((n=this.lo)!==null&&n!==void 0?n:this._instance),this.Tf=!0,a.length>0&&((r=i.replayConsoleBuffer)===null||r===void 0||r.call(i,(o=this.lo)!==null&&o!==void 0?o:this._instance,a))}})}catch(s){throw this.If=!1,s}}qf(e,t){const s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===Ne.LogsQueue?e():void 0,setPersistedProperty(i,n){var r;i===Ne.LogsQueue&&t((r=n)!==null&&r!==void 0?r:[])},Ps:i=>this.Ps(i),getLibraryId:()=>he.LIB_NAME,getLibraryVersion:()=>he.LIB_VERSION}}Ps(e){return new Promise(t=>{if(Ca(this.Wc,3))return void t({kind:"fatal",error:Di(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1;const i=r=>{s||(s=!0,clearTimeout(n),t(r))},n=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:Di(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.op(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:r=>{const o=r.statusCode;if(this.lp(o),o>=200&&300>o)i({kind:"ok"});else if(o===413)i({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)i({kind:"fatal",error:new Error(`logs request failed with status ${o}`)});else{var a;o===0?(r.error||this.$.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:Di(r.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=r.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${o}`)})}}})})}lp(e){(e!==0||this._instance.__loaded)&&(this.Wc=Ra(e,this.Wc,3,()=>this.$.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}sp(e){this.Zl.length>0&&this.ap(e,this.Zl,this.zf,he.LIB_NAME,t=>{this.Zl=t}),this.Ef.length>0&&this.ap(e,this.Ef,this.Vf,oo,t=>{this.Ef=t})}ap(e,t,s,i,n){if(t.length===0)return;const r=t.map(a=>a.record);n([]);const o=ea(r,Qo(s,he.LIB_NAME,he.LIB_VERSION),i,he.LIB_VERSION);this._instance._send_request({method:"POST",url:this.op(),data:o,compression:"best-available",batchKey:"logs",transport:e})}op(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}jf(){var e;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:s,windowId:i,sessionStartTimestamp:n,lastActivityTimestamp:r}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=s,t.windowId=i,M(n)||(t.sessionStartTimestamp=n),M(r)||(t.lastActivityTimestamp=r)}if(!(O==null||(e=O.location)===null||e===void 0)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ot(O.location.href):O.location.href),this._instance.featureFlags){const s=this._instance.featureFlags.getFlags();s&&s.length>0&&(t.activeFeatureFlags=s)}return t}}},Ad={metrics:class{constructor(e){this._instance=e,this.$=ne("[metrics]")}initialize(){}Bf(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.metrics;var s;return this.Df&&this.Hf===t||((s=this.Df)===null||s===void 0||s.reset(),this.Hf=t,this.Df=new _u(this.qf(),(function(i){var n,r,o,a,l;const u=i==null?void 0:i.resourceAttributes;return{serviceName:(n=u==null?void 0:u["service.name"])!==null&&n!==void 0?n:i==null?void 0:i.serviceName,serviceVersion:(r=u==null?void 0:u["service.version"])!==null&&r!==void 0?r:i==null?void 0:i.serviceVersion,environment:(o=u==null?void 0:u["deployment.environment"])!==null&&o!==void 0?o:i==null?void 0:i.environment,resourceAttributes:u,beforeSend:i==null?void 0:i.beforeSend,flushIntervalMs:(a=i==null?void 0:i.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i==null?void 0:i.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(t),this.$)),this.Df}count(e,t=1,s){this.Bf().count(e,t,s)}gauge(e,t,s){this.Bf().gauge(e,t,s)}histogram(e,t,s){this.Bf().histogram(e,t,s)}flush(e){if(!this.Df)return Promise.resolve();if(e){const t=this.Df.drainWindow();return t&&this.Gs(t,e),Promise.resolve()}return this.Df.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this.Df)===null||e===void 0||e.reset()}qf(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Gs:s=>t.Gs(s),getLibraryId:()=>he.LIB_NAME,getLibraryVersion:()=>he.LIB_VERSION}}Gs(e,t){return new Promise(s=>{let i=!1;const n=o=>{i||(i=!0,clearTimeout(r),s(o))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(p(p({method:"POST",url:this.up(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(o){const a=o.statusCode;if(a>=200&&300>a)n({kind:"ok"});else if(a===413)n({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)n({kind:"fatal",error:new Error(`metrics request failed with status ${a}`)});else{var l;n({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error(`metrics request failed with status ${a}`)})}}}))})}up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};is.__defaultExtensionClasses=p({},p(p(p(p(p(p(p(p(p(p(p(p(p({},ei),xd),Sd),$d),kd),Ed),Fd),Pd),Id),Od),Cd),Rd),Ad));const Md=(function(){he.SDK_DIST_CHANNEL="npm";const e=ts[Gt]=new is;return(function(){function t(){t.done||(t.done=!0,al=!1,q(ts,function(s){s._dom_loaded()}))}w!=null&&w.addEventListener?w.readyState==="complete"?t():U(w,"DOMContentLoaded",t,{capture:!1}):y&&k.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();var Td=Md;export{Ee as Compression,cn as DisplaySurveyType,is as PostHog,bc as ProductTourEventName,Fr as ProductTourEventProperties,Ge as SurveyEventName,Si as SurveyEventProperties,qt as SurveyEventType,xi as SurveyType,Td as default,Md as posthog};