@deriv-com/analytics 1.43.0 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ /* @deriv-com/analytics - Browser ESM Bundle (RudderStack + PostHog) - Built with tsup */
2
+ import{d as cr,e as ur,f as dr,g as hr,h as pr}from"./chunk-MHY63WMT.mjs";var b="u">typeof window?window:void 0,_e="u">typeof globalThis?globalThis:b,pe=_e?.navigator,E=_e?.document,Z=_e?.location,_i=_e?.fetch,Cn=_e?.XMLHttpRequest&&"withCredentials"in new _e.XMLHttpRequest?_e.XMLHttpRequest:void 0,vr=_e?.AbortController,Fc=_e?.CompressionStream,be=pe?.userAgent,Wt=typeof globalThis<"u"?globalThis:b;Wt&&typeof self>"u"&&(Wt.self=Wt),Wt&&typeof File>"u"&&(Wt.File=function(){});var C=b??{},fr="0.9.4",Ke={DEBUG:!1,LIB_VERSION:fr,LIB_NAME:"browser-common",JS_SDK_VERSION:fr},He=(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.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),sn=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({}),Ic=["$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"],Ac=["token"];function A(e,t){return e.indexOf(t)!==-1}var Nt=function(e){return e.trim()},nn=function(e){return e.replace(/^\$/,"")};function Xo(e){var t;let i=[];return(t=JSON.stringify(e,function(s,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(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(n))return"[Circular]";i.push(n)}return n}}))!==null&&t!==void 0?t:"null"}var Zo=Object.prototype,Rn=Zo.hasOwnProperty,cs=Zo.toString,I=Array.isArray||function(e){return cs.call(e)==="[object Array]"},oe=e=>typeof e=="function",L=e=>e===Object(e)&&!I(e),Se=e=>{if(L(e)){for(let t in e)if(Rn.call(e,t))return!1;return!0}return!1},x=e=>e===void 0,D=e=>cs.call(e)=="[object String]",oi=e=>D(e)&&e.trim().length===0,ne=e=>e===null,R=e=>x(e)||ne(e),re=e=>cs.call(e)=="[object Number]"&&e==e,Ge=e=>re(e)&&e>0,xe=e=>cs.call(e)==="[object Boolean]",Cc=e=>A(Ic,e),Rc=e=>A(Ac,e);function Qo(e){return e===null||typeof e!="object"}function Ui(e,t){return{}.toString.call(e)===`[object ${t}]`}function Vt(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 ea(e,Error)}}function Ln(e){return"u">typeof Event&&ea(e,Event)}function ea(e,t){try{return e instanceof t}catch{return!1}}var Lc=[!0,"true",1,"1","yes"],fs=e=>A(Lc,e),Dc=[!1,"false",0,"0","no"];function gr(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(c){return void i(c)}a.done?t(l):Promise.resolve(l).then(s,n)}function X(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(l){gr(r,s,n,o,a,"next",l)}function a(l){gr(r,s,n,o,a,"throw",l)}o(void 0)})}}var Nc=["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"],Pi=new Map,_r=function(e,t=[]){if(!e)return!1;let i=(function(o,a){let l="";for(let c=0;a.length>c;c++){let u=a[c];l+=u.length+":"+u}return o.length+":"+o+"|"+a.length+":"+l})(e,t),s=Pi.get(i);if(s!==void 0)return s;let n=e.toLowerCase(),r=Nc.concat(t).some(o=>n.indexOf(o.toLowerCase())!==-1);return 256>Pi.size||Pi.clear(),Pi.set(i,r),r};function Ue(e,t,i,s,n){return t>i&&(s.warn("min cannot be greater than max."),t=i),re(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),Ue(n??i,t,i,s))}var jc=class{constructor(e){this.C={},this.I=e.I,this.R=Ue(e.bucketSize,0,100,e.A),this.$=Ue(e.refillRate,0,this.R,e.A),this.O=Ue(e.refillInterval,0,864e5,e.A)}F(e,t){let i=Math.floor((t-e.lastAccess)/this.O);i>0&&(e.tokens=Math.min(e.tokens+i*this.$,this.R),e.lastAccess=e.lastAccess+i*this.O)}consumeRateLimit(e){var t;let i=Date.now(),s=String(e),n=this.C[s];return n?this.F(n,i):(n={tokens:this.R,lastAccess:i},this.C[s]=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={}}},jt="Mobile",mi="Android",qi="Tablet",ta="Android Tablet",ia="iPad",sa="Apple Watch",Ci="Safari",us="BlackBerry",na="Samsung Internet",Ri="Chrome",ra="Chrome iOS",oa="Internet Explorer",aa="Internet Explorer Mobile",la="Opera",ca="Microsoft Edge",Li="Firefox",ua="Firefox iOS",zi="Nintendo",Gi="PlayStation",ds="Xbox",da="Android Mobile",ha="Mobile Safari",gs="Windows",pa="Windows Phone",mr="Nokia",rn="Ouya",Bc="Generic "+jt.toLowerCase(),va="Generic "+qi.toLowerCase(),on="Konqueror",fa="Oculus Browser",ga="Vivaldi",_a="Yandex",ma="Whale",ya="DuckDuckGo",ba="Pale Moon",wa="Waterfox",an="Brave",xa="Claude",ka="Codex",Ea="ChatGPT",$a="Google Search App",_s=new RegExp("Version/(\\d+(\\.\\d+)?)"),ms=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Hc=new RegExp(ds,"i"),Uc=new RegExp("PlayStation \\w+","i"),qc=new RegExp("Nintendo \\w+","i"),Dn=new RegExp("BlackBerry|PlayBook|BB10","i"),zc={"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"},Sa=function(e,t,i,s){return t=t||"",(function(r){return r?.brave?an:null})(i)||(s?.detectGoogleSearchApp&&A(e,"GSA/")?$a:A(e," OPR/")&&A(e,"Mini")?"Opera Mini":A(e," OPR/")?la:Dn.test(e)?us:A(e,"IEMobile")||A(e,"WPDesktop")?aa:A(e,"OculusBrowser")?fa:A(e,"SamsungBrowser")?na:A(e,"Edge")||A(e,"Edg/")?ca:A(e,"Vivaldi/")?ga:A(e,"YaBrowser/")?_a:A(e,"Whale/")?ma:A(e,"DuckDuckGo/")||A(e,"Ddg/")?ya:A(e,"Claude/")?xa:A(e,"Codex/")?ka:A(e,"ChatGPT/")?Ea:A(e,"FBIOS")?"Facebook Mobile":A(e,"UCWEB")||A(e,"UCBrowser")?"UC Browser":A(e,"CriOS")?ra:A(e,"CrMo")||A(e,Ri)?Ri:A(e,mi)&&A(e,Ci)?da:A(e,"FxiOS")?ua:A(e.toLowerCase(),on.toLowerCase())?on:A(e,"Brave/")?an:((r,o)=>o&&A(o,"Apple")||(function(a){return A(a,Ci)&&!A(a,Ri)&&!A(a,mi)})(r))(e,t)?A(e,jt)?ha:Ci:A(e,"PaleMoon/")?ba:A(e,"Waterfox/")?wa:A(e,Li)?Li:A(e,"MSIE")||A(e,"Trident/")?oa:A(e,"Gecko")?Li:"")},Gc={[aa]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ca]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Ri]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[ra]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ci]:[_s],[ha]:[_s],[la]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Li]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ua]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[on]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[us]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),_s],[da]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[na]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[fa]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[ga]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[_a]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ma]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[an]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[xa]:[ms],[ka]:[ms],[Ea]:[ms],[ya]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[ba]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[wa]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[$a]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[oa]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Vc=function(e,t,i,s){let n=Sa(e,t,i,s),r=Gc[n];if(x(r))return null;for(let o=0;r.length>o;o++){let a=e.match(r[o]);if(a)return parseFloat(a[a.length-2])}return null},yr=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[ds,e&&e[1]||""]],[new RegExp(zi,"i"),[zi,""]],[new RegExp(Gi,"i"),[Gi,""]],[Dn,[us,""]],[new RegExp(gs,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[pa,""];if(new RegExp(jt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];let i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let s=zc[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[gs,s]}return[gs,""]}],[/((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=x(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[mi,[e[2],e[3],e[4]||"0"].join(".")]:[mi,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Pa=function(e){for(let t=0;yr.length>t;t++){let[i,s]=yr[t],n=i.exec(e),r=n&&(oe(s)?s(n,e):s);if(r)return r}return["",""]},Ta=function(e){return qc.test(e)?zi:Uc.test(e)?Gi:Hc.test(e)?ds:new RegExp(rn,"i").test(e)?rn:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?pa:/iPad/.test(e)?ia:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?sa:Dn.test(e)?us:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(mr,"i").test(e)?mr:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(jt).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?mi:ta:new RegExp("(pda|Mobile)","i").test(e)?Bc:new RegExp(qi,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?va:""},Wc=function(e,t){var i;let s=Ta(e);return s===ia||s===ta||s==="Kobo"||s==="Kindle Fire"||s===va?qi:s===zi||s===ds||s===Gi||s===rn?"Console":s===sa?"Wearable":s?jt:t?.userAgentDataPlatform==="Android"&&((i=t?.maxTouchPoints)!==null&&i!==void 0?i:0)>0?600>Math.min((n=t?.screenWidth)!==null&&n!==void 0?n:0,(r=t?.screenHeight)!==null&&r!==void 0?r:0)/((o=t?.devicePixelRatio)!==null&&o!==void 0?o:1)?jt:qi:"Desktop";var n,r,o},ys=/\bFBAV\/(\d+(?:\.\d+)*)/i,br=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ys],[/\bFBAN\/EMA\b/i,"Facebook Lite",ys],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ys],[/\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"]],ln="[Truncated]",Ei="[Unserializable]";function Rt(e){let t="";for(let i=0;e.length>i;i++){let s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"\uFFFD";else{let n=e.charCodeAt(i+1);56320>n||n>57343?t+="\uFFFD":(t+=e[i]+e[i+1],i++)}}return t}function Ma(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch{i=[]}for(let s of i){let n;try{n=t[s]}catch{n=Ei}Object.defineProperty(e,s,{value:n,enumerable:!0,writable:!0,configurable:!0})}return e}var Di=3e5,Oa=class{record(e){if(e.kind==="too-large")return;if(e.kind!=="retry-later")return void this.reset();if(!e.retryAfterMs)return;let t=this.isOpen(),i=Date.now(),s=Math.min(e.retryAfterMs,Di);if(!t)return this.ts=i,void(this.es=i+s);this.es=Math.max(this.es,Math.min(i+s,this.ts+Di))}remainingMs(){let e=Date.now();if(this.ts-5e3>e)return this.reset(),0;let t=Math.min(Di,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}},Yc=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function wr(e,t){return typeof(i=e)=="string"&&Yc.test(i)?e:t();var i}function Fa(e,t){let i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return i}function ct(e){return e&&e.split("#")[0]}function xr(e){try{return e()}catch{return}}function Ia(e,t){let i=setTimeout(e,t);return i!=null&&i.unref&&i?.unref(),i}function kr(e,t,i){return Aa.apply(this,arguments)}function Aa(){return(Aa=X(function*(e,t,i){let s;try{return yield Promise.race([e,new Promise((n,r)=>{s=Ia(()=>{try{i?.(),n()}catch(o){r(o)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function ai(e){return ai=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},ai(e)}function Kc(e,t,i){return(t=(function(s){var n=(function(r){if(ai(r)!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var a=o.call(r,"string");if(ai(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(s);return ai(n)=="symbol"?n:n+""})(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Er(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),i.push.apply(i,s)}return i}function v(e){for(var t=1;arguments.length>t;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?Er(Object(i),!0).forEach(function(s){Kc(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Er(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}var Yt,$r,Sr,kt;function Jc(e){var t;let i=globalThis._posthogChunkIds,s=globalThis._debugIds;if(!i&&!s)return;let n=i?Object.keys(i):[],r=s?Object.keys(s):[];if(kt&&Pr(i,n,$r)&&Pr(s,r,Sr))return kt;$r=i?v({},i):void 0,Sr=s?v({},s):void 0,kt={},(t=Yt)!==null&&t!==void 0||(Yt={});let o=(a,l)=>{for(let u of a){let h=l[u];if(!h)continue;let d=Yt?.[u];if(d){kt[d]=h;continue}let p=e(u);for(let f=p.length-1;f>=0;f--){var c;let _=(c=p[f])===null||c===void 0?void 0:c.filename;if(_){kt[_]=h,Yt[u]=_;break}}}};return s&&o(r,s),i&&o(n,i),kt}function Pr(e,t,i){return e&&i?t.length===Object.keys(i).length&&t.every(s=>e[s]===i[s]):e===i}var Xc=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){let i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return X(function*(){for(let i of e)i.stacktrace&&i.stacktrace.frames&&I(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)===null||t===void 0?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i;let s,n;if(e.cause!=null&&(s=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null)try{n=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return v(v({},e),{},{cause:s,stack:n,errors:(i=e.errors)===null||i===void 0?void 0:i.map(r=>this.parseStacktrace(r,t))})}applyChunkIds(e,t){return e.map(i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i))}applyCoercers(e,t){for(let i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return X(function*(){let i=e;for(let s of t.modifiers)i=yield s(i);return i})()}convertToExceptionList(e,t){let i=[],s=(n,r,o)=>{var a;let l=i.length,c=r===void 0?v(v({type:typeof t.type=="string"&&t.type.length>0?t.type:"generic"},typeof t.handled=="boolean"?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic=="boolean"?t.synthetic:n.synthetic,exception_id:l}):{type:"chained",source:o,synthetic:n.synthetic,exception_id:l,parent_id:r},u={type:n.type,value:n.value,mechanism:c};n.stack&&(u.stacktrace={type:"raw",frames:n.stack}),i.push(u),n.cause&&s(n.cause,l,"cause");for(let h of(a=n.errors)!==null&&a!==void 0?a:[])s(h,l,"member")};return s(e),i}buildParsingContext(e){var t;return{chunkIdMap:Jc(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(Vt(e)){let i=Object.getPrototypeOf(e);for(let s=0;i&&100>s;s++){var t;let n=(t=Object.getOwnPropertyDescriptor(i,"constructor"))===null||t===void 0?void 0:t.value;if(typeof n=="function"&&n.name==="AggregateError"){let r=e.errors;return I(r)?r:void 0}i=Object.getPrototypeOf(i)}}}catch{}}buildCoercingContext(e,t,i=0){let s=0,n=0,r=!1,o=new Set,a=[],l={},c=(d,p,f=0)=>{let _=u(p,f),g=_.apply;if(_.apply=k=>{a.push(d);try{return g(k)}finally{a.pop()}},f>4||f>0&&a.indexOf(d)!==-1)return this.coerceFallback(_);let y=typeof d=="object"&&d!==null||typeof d=="function";if(f===0&&s>=50||y&&o.has(d))return;y&&o.add(d),f===0&&s++;let m=this.getAggregateErrors(d),w,$;r||(r=!!m);try{if(w=this.applyCoercers(d,_),!w)throw l}catch(k){if(k===l)return void(f===0&&s--);if(!r)throw k;w=this.coerceFallback(_)}if(!m||s>=50)return w;try{$=m.length}catch{return w}if(!Number.isInteger($)||0>$||$>4294967295)return w;let P=[];for(let k=0;50>s&&1e3>n&&$>k;k++){let M;n++;try{M=_.next(m[k])}catch{s++,M=this.coerceFallback(u(p+1))}M&&P.push(M)}return v(v({},w),{},{errors:P})},u=(d,p=0)=>v(v({},t),{},{syntheticException:d==0?t.syntheticException:void 0,mechanism:d==0?e:{},apply(f){let _=c(f,d,p+1);if(!_)throw l;return _},next:f=>c(f,d+1)}),h=u(i);return v(v({},h),{},{apply:d=>{var p;return(p=c(d,i))!==null&&p!==void 0?p:this.coerceFallback(h)}})}},Zc=/^([a-z][a-z0-9.+-]+):/i,Qc=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function eu(e){if(!e||e==="<anonymous>")return!1;let t=Zc.exec(e);return!t||Qc.includes(t[1].toLowerCase())}function cn(e,t,i,s,n){let r={platform:e,filename:t,function:i==="<anonymous>"?"?":i,in_app:eu(t)};return x(s)||(r.lineno=s),x(n)||(r.colno=n),r}var Ca=(e,t)=>{let i=e.indexOf("safari-extension")!==-1,s=e.indexOf("safari-web-extension")!==-1;return i||s?[e.indexOf("@")!==-1?e.split("@")[0]:"?",i?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},tu=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,iu=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,su=/\((\S*)(?::(\d+))(?::(\d+))\)/,nu=(e,t)=>{let i=tu.exec(e);if(i){let[,n,r,o]=i;return cn(t,n,"?",+r,+o)}let s=iu.exec(e);if(s){if(s[2]&&s[2].indexOf("eval")===0){let o=su.exec(s[2]);o&&(s[2]=o[1],s[3]=o[2],s[4]=o[3])}let[n,r]=Ca(s[1]||"?",s[2]);return cn(t,r,n,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},ru=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ou=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,au=(e,t)=>{let i=ru.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){let r=ou.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}let s=i[3],n=i[1]||"?";return[n,s]=Ca(n,s),cn(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Tr=/\(error: (.*)\)/;function Nn(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function lu(e){for(let t=1;10>=t;t++){let i=e.length-2*t;if(0>i)break;let s=!0;for(let n=0;t>n;n++)if(!Nn(e[i+n],e[i+t+n])){s=!1;break}if(s){for(let n=0;t>n;n++)e[i+n]=e[i+t+n];return e.length=i+t,{start:i,length:t}}}}function cu(e,t){let i=t.start+t.length,s=La(e,t);s&&e.splice(i+s===e.length?i:t.start,s)}function Ra(e,t){let i=t.start;for(;i>0&&Nn(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function La(e,t){let i=t.start+t.length,s=i;for(;e.length>s&&Nn(e[s],e[s-t.length]);)s++;return s-i}function uu(e,t){let i=t[0],s=e.length-(i?Ra(e,i):0);for(let n of t)s-=La(e,n);return s}function du(e,t,i){for(let s=0;e.length>s;s++){let n=e[(t+s)%e.length],r=e[(i+s)%e.length];if(n!==r)return r>n}return!1}var hu=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){let i=D(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){let t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Ui(e,"DOMException")}isDOMError(e){return Ui(e,"DOMError")}},pu=class{match(e){return Vt(e)}coerce(e,t){var i;let s=this.getStack(e),n=s===void 0?(i=t.syntheticException)===null||i===void 0?void 0:i.stack:void 0,r=!!n;return{type:this.getType(e),value:this.getMessage(e,t),stack:s??n,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){try{let t=e.stacktrace;if(typeof t=="string"&&t.length>0)return t;let i=e.stack;return typeof i=="string"&&i.length>0?i:void 0}catch{return}}},vu=class{match(e){return!!Ui(e,"ErrorEvent")&&(e.error!=null||this.ar(e))}coerce(e,t){var i;if(e.error!=null)return t.apply(e.error);let s=t.apply(e.message);return v(v({},s),{},{stack:(i=this.lr(e))!==null&&i!==void 0?i:s.stack,synthetic:!0})}ar(e){return D(e.message)&&e.message.length>0}lr(e){var t,i;let s=e,n=(t=s.lineno)!==null&&t!==void 0?t:0,r=(i=s.colno)!==null&&i!==void 0?i:0;if(D(s.filename)&&s.filename.length!==0&&n!==0)return`Error
3
+ at ${s.filename}:${n}:${r}`}},fu=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,gu=class{match(e){return typeof e=="string"}coerce(e,t){var i;let[s,n]=this.getInfos(e);return{type:s??"Error",value:n??e,stack:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e,s=e.match(fu);return s&&(t=s[1],i=s[2]),[t,i]}},_u=["fatal","error","warning","log","info","debug"];function Da(e,t=40){let i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let s=i.length;s>0;s--){let n=i.slice(0,s).join(", ");if(t>=n.length)return s===i.length?n:n.length>t?`${n.slice(0,t)}...`:n}return""}var mu=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,s;let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:(i=this.getStack(e))!==null&&i!==void 0?i:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ln(e))return e.constructor.name;let t="name"in e?e.name:void 0;return D(t)&&!oi(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message: '${e.message}'`),i}if("message"in e&&typeof e.message=="string")return e.message;let t=this.getObjectClassName(e);return`${t&&t!=="Object"?`'${t}'`:"Object"} captured as exception with keys: ${Da(e)}`}isSeverityLevel(e){return D(e)&&!oi(e)&&_u.indexOf(e)>=0}getStack(e){try{return D(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:D(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(let t in e)if({}.hasOwnProperty.call(e,t)){let i=e[t];if(Vt(i))return i}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},yu=class{match(e){return Ln(e)}coerce(e,t){var i;let s=e.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Da(e)}`,stack:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,synthetic:!0}}},bu=class{match(e){return Qo(e)}coerce(e,t){var i;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,synthetic:!0}}},wu=class{match(e){return Ui(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ln(e))return!1;try{let t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i;let s=this.getUnhandledRejectionReason(e);return Qo(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},Vi="$message",Wi="$timestamp",xu=new Set([Vi,Wi]),bs={enabled:!0,max_bytes:32768};function Yi(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:bs.enabled,max_bytes:Eu(e.max_bytes,bs.max_bytes)}:v({},bs)}var ku=class{constructor(e){this.ns=[],this.ss=0,this.Mr=Yi(e)}setConfig(e){this.Mr=Yi(e),this.rs()}add(e){let t=(function(s){let n;try{n=Xo(s)}catch{return}try{let r=JSON.parse(n);if(!L(r))return;let o=r,a=o[Vi],l=o[Wi];return!D(a)||a.trim().length===0||!D(l)&&!re(l)?void 0:{step:o,json:n}}catch{return}})(e);if(!t)return;let i=(function(s){if("u">typeof TextEncoder)return new TextEncoder().encode(s).length;let n=encodeURIComponent(s),r=0;for(let o=0;n.length>o;o++)n[o]==="%"?(r+=1,o+=2):r+=1;return r})(t.json);i>this.Mr.max_bytes||(this.ns.push({step:t.step,bytes:i}),this.ss+=i,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){let e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function Eu(e,t){if(!re(e)||e===1/0||e===-1/0)return t;let i=Math.floor(e);return 0>i?t:i}var Mr=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function Or(e){return typeof e=="string"||e}function Fr(e){return typeof e=="string"?e:void 0}var $u=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Na="NativeGzipValidationError",un=e=>e.length>=2&&e[0]===31&&e[1]===139,Ir=(e,t)=>e===sn.GZipJS||t===sn.GZipJS||t==="gzip",Ar=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError",Kt,Ti=e=>{throw Fa(Na,`Native gzip produced invalid output: ${e}`)},Su=(Cr=X(function*(e,t){18>e.size&&Ti("too-short");let i=new Uint8Array(yield e.slice(0,10).arrayBuffer());un(i)&&i[2]===8||Ti("invalid-header");let s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(r=>{let o=(()=>{if(Kt)return Kt;Kt=[];for(let l=0;256>l;l++){let c=l;for(let u=0;8>u;u++)c=1&c?3988292384^c>>>1:c>>>1;Kt[l]=c>>>0}return Kt})(),a=4294967295;for(let l=0;r.length>l;l++)a=o[255&(a^r[l])]^a>>>8;return(4294967295^a)>>>0})(t)&&Ti("invalid-crc");let n=t.length>>>0;s.getUint32(4,!0)!==n&&Ti("invalid-size")}),function(e,t){return Cr.apply(this,arguments)}),Cr;function dn(){return dn=X(function*(e,t=!0,i){try{let n=new TextEncoder().encode(e),r=new globalThis.CompressionStream("gzip"),o=r.writable.getWriter(),a=o.write(n).then(()=>o.close()).catch((s=X(function*(u){try{yield o.abort(u)}catch{}throw u}),function(u){return s.apply(this,arguments)})),l=new Response(r.readable).blob(),[c]=yield Promise.all([l,a]);return yield Su(c,n),c}catch(n){if(i?.rethrow)throw n;return t&&console.error("Failed to gzip compress data",n),null}var s}),dn.apply(this,arguments)}function ja(e,t){if(e==null)return{};var i,s,n=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.includes(c))continue;l[c]=o[c]}return l})(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;r.length>s;s++)t.includes(i=r[s])||{}.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}var ge="[redacted]",Pu=/^[A-Za-z0-9+/\n\r]+=*$/,Tu=/^[A-Za-z0-9_-]+={0,2}$/,Mu=/[-_]/,Ou=/^data:[^,\s]*;base64,/i,Fu=/^[A-Za-z0-9+/_-]+={0,2}$/,Iu=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Au=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Ba=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Cu=/[\s<>"]/,Ha=new RegExp(Ba.source,"i"),Ua=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Ru=new RegExp(`^${Ua.source}`,"i"),Lu=new RegExp(Ua.source,"gi"),Du=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,Nu=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ju=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,Bu=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Hu=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,Uu=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,qu=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,zu=/\b\d(?:[ ./-]?\d){12,}\b/g,Rr=/\d+/g,Gu=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Vu=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function hn(e){return(function(t){return Au.test(t)})(e)||Du.test(e)||Nu.test(e)}function ws(e){return e.split("&",129).length>128}function Wu(e,t,i){return hn(e)||t.includes(";")&&(function(s){return s.split(";").some(n=>hn(n.split("=",1)[0]))})(t)?ge:Ha.test(t)?i?jn(t,{allowNestedUrls:!1,stripPunctuation:!0}):ge:t}function qa(e,t){let i=new URLSearchParams,s=!1,n=!1;for(let[r,o]of new URLSearchParams(e)){let a=Ki(r),l=Ki(o);s||(s=a!==r||l!==o);let c=Wu(a,l,t);s||(s=c!==l),n=hn(a)||c!==l,i.append(a,c)}return{changed:s,lastFieldSensitive:n,serialized:i.toString()}}function Lr(e,t){if(!e.includes("="))return{value:Yu(e,t),lastFieldSensitive:!1};let i=qa(e,t);return{value:i.changed?i.serialized:e,lastFieldSensitive:i.lastFieldSensitive}}function Yu(e,t){return t?jn(e,{allowNestedUrls:!1,stripPunctuation:!0}):Ha.test(e)?ge:e}function Ku(e,t,i){return e==="#"?!t.fragment&&(t.fragment=!0):e==="?"&&(t.fragment?i!=="="&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function xs(e,t){var i;if(e.length>8192&&Ru.test(e))return ge;let{address:s,suffix:n}=t.stripPunctuation?(function(g){let y=g.length;for(;y>0&&".,;:!?)]}'".includes(g[y-1]);)y--;return{address:g.slice(0,y),suffix:g.slice(y)}})(e):{address:e,suffix:""},r;try{r=new URL(s)}catch{return ge+n}let o=r.search.slice(1),a=r.hash!=="",l=(function(g){let y=g.slice(1),m=y.indexOf("?");return 0>m?{head:y,tail:null}:{head:y.slice(0,m),tail:y.slice(m+1)}})(r.hash);if(ws(o)||ws(l.head)||ws((i=l.tail)!==null&&i!==void 0?i:""))return ge+n;let c=!1;(r.username||r.password)&&(r.username=ge,r.password="",c=!0);let u=qa(o,t.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);let h=Lr(l.head,t.allowNestedUrls),d=l.tail===null?null:(p=l.tail,h.lastFieldSensitive?{value:p===""?"":ge,lastFieldSensitive:!0}:Lr(p,t.allowNestedUrls));var p;let f=d===null?h.value:`${h.value}?${d.value}`;f!==r.hash.slice(1)&&(r.hash=f,c=!0);let _=a?d??h:u;return(c?Ki(r.toString()):s)+(_.lastFieldSensitive?"":n)}function jn(e,t){return e.replace(Ba,i=>(function(s,n){let r=(function(l){if(!l.includes("://"))return[];let c=[...l.matchAll(Lu)].map(_=>_.index),u=[],h={query:!1,fragment:!1,fragmentQuery:!1},d=0,p=!1,f="";for(let _=0;l.length>_&&c.length>d;_++){c[d]===_&&(_>0&&f!=="="&&u.push(_),d++);let g=l[_];Ku(g,h,f)?(f=g,p=!0):p&&"=&".includes(g)&&(f=g)}return u})(s);if(r.length===0)return xs(s,n);let o="",a=0;for(let l of r)o+=xs(s.slice(a,l),v(v({},n),{},{stripPunctuation:!1})),a=l;return o+xs(s.slice(a),n)})(i,v(v({},t),{},{stripPunctuation:t.stripPunctuation&&i.length!==e.length})))}function Ki(e){return e.replace(Iu,ge)}function Ju(e,t){return(function(i){return i.length>=10240&&(Pu.test(i)||(function(s){let n=Ou.exec(s);if(!n)return!1;let r;try{r=decodeURIComponent(s.slice(n[0].length))}catch{return!1}return Fu.test(r.replace(/[\r\n]/g,""))})(i)||Mu.test(i)&&Tu.test(i))})(e)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(i,s,n){let r=4*n.maxStringLength;if(i.length>r){let o=s(i.slice(0,(function(a,l){let c=l;for(;c>0&&!Cu.test(a[c-1]);)c--;return c})(i,r)));if(o.length>=2*n.maxStringLength)return o+n.truncationSuffix}return s(i)})(e,i=>(function(s){return jn(s,{allowNestedUrls:!0,stripPunctuation:!0})})((function(s){let n=s.replace(ju," ");return n=n.replace(Bu,ge),n=n.replace(Hu,ge),n=n.replace(Uu,`$1${ge}`),n=n.replace(zu,Zu),n=n.replace(qu,ge),n=n.replace(Gu,`$1${ge}`),n=n.replace(Vu,`$1${ge}`),n})(Ki(i))),t)}function Xu(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;if(0>n||n>9)return!1;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function Zu(e){let t=[];for(let r=Rr.exec(e);r!==null;r=Rr.exec(e))t.push({digits:r[0],start:r.index,end:r.index+r[0].length});let i="",s=0,n=0;for(;t.length>n;){let r="",o=-1;for(let a=n;t.length>a&&(r+=t[a].digits,19>=r.length);a++)r.length>=13&&Xu(r)&&(o=a);0>o?n++:(i+=e.slice(s,t[n].start)+ge,s=t[o].end,n=o+1)}return i+e.slice(s)}var Qu={}.propertyIsEnumerable;function Ji(e,t){try{return za(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Bn(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:ln};if(i.remainingNodes--,xe(e))return{boolValue:e};if(typeof e=="bigint")return(function(n,r){let o=n.toString(),a=BigInt("9223372036854775808");return n>=a||-a>n?(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)};let n=BigInt(e).toString();return e>=9223372036854776e3||-9223372036854776e3>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:Rt(e)};if(typeof e=="function")return{stringValue:"[Function]"};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ln};if(e instanceof Date){let n=e.getTime(),r=Number.isFinite(n)?e.toISOString():String(e);return{stringValue:typeof r=="string"?Rt(r):String(r)}}i.ancestors.add(e);try{try{let n=e.toJSON;if(typeof n=="function")return Bn(n.call(e),t,i,s+1)}catch{}return I(e)?{arrayValue:{values:ed(e,t,i,s+1)}}:{kvlistValue:{values:za(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:Rt(String(e))}}function ed(e,t,i,s){let n=[],r=Math.min(e.length,1e3),o=0;for(;r>o&&i.remainingNodes>0;o++)try{let a=o in e?e[o]:void 0;if(R(a))continue;n.push(Bn(a,t,i,s))}catch{n.push({stringValue:Ei})}return e.length>o&&n.push({stringValue:ln}),n}function za(e,t,i,s){let n=[];for(let r in e)if(Qu.call(e,r)){if(!r){t?.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){t?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{let o=e[r];if(ne(o)||x(o))continue;n.push({key:Rt(r),value:Bn(o,t,i,s)})}catch{n.push({key:Rt(r),value:{stringValue:Ei}})}}return n}function Ga(e,t,i){return v(v(v(v({},Ma({},e.resourceAttributes)),{},{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":i})}var td=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Va(e,t){let i=Ma({},e),s={};for(let n of td)({}).hasOwnProperty.call(i,n)&&(s[n]=i[n],delete i[n]);return[...Ji(i,t),...Ji(s,t)]}var Dr={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},Wa={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}},id=Wa.info;function sd(e){try{return Rt(String(e))}catch{return Ei}}function nd(e,t,i,s){let n=e.level||"info",{text:r,number:o}=Wa[n]||id,a=(function(d=Date.now()){return String(d)+"000000"})(re(s)?s:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),R(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),R(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);let c=v({},l),u=e.attributes;if(u){let d=[];try{d=Object.keys(u)}catch{d=[]}for(let p of d){let f;try{f=u[p]}catch{f=Ei}Object.defineProperty(c,p,{value:f,enumerable:!0,writable:!0,configurable:!0})}}let h={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:sd(e.body)},attributes:Ji(c,i)};return e.trace_id&&(h.traceId=e.trace_id),e.span_id&&(h.spanId=e.span_id),x(e.trace_flags)||(h.flags=e.trace_flags),h}function Ya(e,t,i){return Ga(e,t,i)}function Ka(e,t,i,s){return{resourceLogs:[{resource:{attributes:Va(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var Ja=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.cs}arm(e){this.clear(),this.us=Date.now()+e,this.cs=Ia(()=>{this.cs=void 0,this.ls()},e)}armNoEarlierThan(e){this.cs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Xa(){return .75+.5*Math.random()}function Za(e,t,i,s){let n=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,n);return Math.round((s===void 0?r:Math.min(r,Math.max(s,e)))*i)}var rd=class{constructor(e,t,i,s,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this.Mr=t,this.A=i,this.hs=s,this.ds=n,this.vs=r,this.fs=o,this.ps=new Ja(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Oa,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=t.maxBufferSize,this.Is=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(He.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){var i;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;let s=this.Os(e);if(s===null)return;if(!s.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;let n={record:nd(s,(i=t?.context)!==null&&i!==void 0?i:this.hs(),this.A,t?.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(e){let t=this.Mr.beforeSend;if(!t)return e;let i=I(t)?t:[t],s=e;for(let n of i)try{let r=n(s);if(!r)return this.A.info("Log was rejected in beforeSend function"),null;s=r}catch(r){return this.A.error("Error in beforeSend function for log:",r),null}return s}Ds(){if(this.Rs===void 0)return!0;let e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var e=this;return X(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return X(function*(){var t;e.ps.clear();let i=(t=e._instance.getPersistedProperty(He.LogsQueue))!==null&&t!==void 0?t:[];if(i.length===0)return;let s=i.length,n=0;for(;i.length>0&&s>n;){var r,o;let a=e._s;e.bs=0;let l=Math.min(i.length,e.Es),c=i.slice(0,l),u=Ka(c.map(d=>d.record),e.qs(),(r=e.fs)!==null&&r!==void 0?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),h=yield e._instance.js(u);if(e._s!==a)return;if(h.kind==="too-large"&&c.length>1)e.Es=Math.max(1,Math.floor(c.length/2)),e.A.warn(`Logs batch of size ${c.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(h),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),h.kind==="retry-later"||(h.kind==="too-large"?e.A.warn("Dropping a single log record with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):h.kind==="ok"&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(c.length),i=(o=e._instance.getPersistedProperty(He.LogsQueue))!==null&&o!==void 0?o:[],n+=c.length,h.kind==="fatal"))throw h.error}})()}Bs(e){var t=this;return X(function*(){var i;let s=Math.max(0,e-t.bs),n=(i=t._instance.getPersistedProperty(He.LogsQueue))!==null&&i!==void 0?i:[];t._instance.setPersistedProperty(He.LogsQueue,n.slice(s)),yield t.vs()})()}qs(){return Ya(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;let i=(t=this._instance.getPersistedProperty(He.LogsQueue))!==null&&t!==void 0?t:[];this.Is>i.length||(i.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(He.LogsQueue,i),this.Ts>i.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Za(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){let e=this._instance.getPersistedProperty(He.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return X(function*(){t.ps.clear();let i=t.flush().catch(()=>{});e!==void 0?yield kr(i,e):yield i})()}flushWithTimeout(e){var t=this;return X(function*(){let i=t.flush();yield kr(i,e,()=>{i.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=Xa(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}},ks=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Nr(e){return String(e)+"000000"}function jr(e,t,i,s){let n="";return s&&(n=Object.keys(s).sort().map(r=>`${JSON.stringify(r)}:${JSON.stringify(s[r])}`).join(",")),`${e}\0${t}\0${i??""}\0${n}`}var od=class{constructor(e,t,i){this._instance=e,this.Mr=t,this.A=i,this.Hs=new Map,this.ps=new Ja(()=>this.flush().catch(s=>{this.A.error("Metrics flush failed:",s)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Oa,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,i){this.Qs({name:e,type:"count",value:t,unit:i?.unit,attributes:i?.attributes})}gauge(e,t,i){this.Qs({name:e,type:"gauge",value:t,unit:i?.unit,attributes:i?.attributes})}histogram(e,t,i){this.Qs({name:e,type:"histogram",value:t,unit:i?.unit,attributes:i?.attributes})}flush(){var e=this;let t=this.ys,i=(function(){var s=X(function*(){t&&(yield t.catch(()=>{})),yield e.Zs()});return function(){return s.apply(this,arguments)}})()().finally(()=>{this.ys===i&&(this.ys=null)});return this.ys=i,i}drainWindow(){if(this.Hs.size===0)return null;let e=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(e){if(this._instance.isDisabled||this._instance.optedOut)return;let t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.A.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.A.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,s;try{i=t.attributes?v({},t.attributes):void 0,s=jr(t.type,t.name,t.unit,i)}catch(o){return void this.A.warn(`Dropping metric '${t.name}': attributes could not be serialized`,o)}let n=this.Hs.get(s);if(!n){if(!this.Ks())return;n={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this.Hs.set(s,n)}let r=this.Ws.get(t.name);r===void 0?this.Ws.set(t.name,t.type):r===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.A.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.Xs(n,t.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case"count":var i;e.total=((i=e.total)!==null&&i!==void 0?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":{e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(ks.length+1).fill(0)});let s=e.hist;s.count+=1,s.sum+=t,s.min=Math.min(s.min,t),s.max=Math.max(s.max,t),s.bucketCounts[(function(n,r){for(let o=0;r.length>o;o++)if(r[o]>=n)return o;return r.length})(t,ks)]+=1;break}}}Os(e){let t=this.Mr.beforeSend;if(!t)return e;let i=I(t)?t:[t],s=e;for(let n of i)try{let r=n(s);if(!r)return this.A.info("Metric was rejected in beforeSend function"),null;s=r}catch(r){return this.A.error("Error in beforeSend function for metric:",r),null}return s}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Za(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var e=this;return X(function*(){if(e.ps.clear(),e.Hs.size===0)return;let t=e.Hs;e.Hs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;let i=e.Gs,s=yield e._instance.Ys(e.Js(t));if(i===e.Gs)switch(e.ws.record(s),s.kind==="retry-later"?(e.ks++,e.Ss=Xa()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.zs()),s.kind){case"ok":return;case"retry-later":return e.co(t),void e.ps.armNoEarlierThan(e.zs());case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",s.error)}})()}Js(e){return t=this.ho(e),i=(function(r,o,a){return Ga(r,o,a)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Va(i)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,i,s,n}ho(e){let t=Nr(Date.now()),i=new Map;for(let o of e.values()){var s;let a=jr(o.type,o.name,o.unit,void 0),l=i.get(a);l||(l=v({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:[]},i.set(a,l));let c=Ji((s=o.attributes)!==null&&s!==void 0?s:{},this.A),u=Nr(o.windowStartMs);if(o.type==="count"){var n;let h={attributes:c,startTimeUnixNano:u,timeUnixNano:t,asDouble:(n=o.total)!==null&&n!==void 0?n:0};l.sum.dataPoints.push(h)}else if(o.type==="gauge"){var r;let h={attributes:c,timeUnixNano:t,asDouble:(r=o.last)!==null&&r!==void 0?r:0};l.gauge.dataPoints.push(h)}else o.hist&&l.histogram.dataPoints.push({attributes:c,startTimeUnixNano:u,timeUnixNano:t,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:ks})}return Array.from(i.values())}co(e){for(let[s,n]of e){let r=this.Hs.get(s);if(r)switch(r.windowStartMs=Math.min(r.windowStartMs,n.windowStartMs),r.type){case"count":var t,i;r.total=((t=r.total)!==null&&t!==void 0?t:0)+((i=n.total)!==null&&i!==void 0?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(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.Ks()&&this.Hs.set(s,n)}}},Qa=(e,{debugEnabled:t}={})=>{let i={N(s,...n){let r;try{r=typeof window>"u"?void 0:window}catch{return}r&&(Ke.DEBUG||r.POSTHOG_DEBUG||t)&&!x(r.console)&&r.console&&("__rrweb_original__"in r.console[s]?r.console[s].__rrweb_original__:r.console[s])(e,...n)},debug(...s){i.N("debug",...s)},info(...s){i.N("log",...s)},warn(...s){i.N("warn",...s)},error(...s){i.N("error",...s)},critical(...s){console.error(e,...s)},uninitializedWarning(s){i.error(`You must initialize PostHog before calling ${s}`)},createLogger:(s,n)=>Qa(`${e} ${s}`,n)};return i},S=Qa("[PostHog.js]"),te=S.createLogger,ad=te("[ExternalScriptsLoader]"),Xi=e=>{let t=E?.querySelectorAll("script");if(t){for(let i=0;t.length>i;i++)if(t[i].src===e||t[i].getAttribute("src")===e)return t[i]}},gt=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return ad.warn(`${t} was requested but loading of external scripts is disabled.`),i("Loading of external scripts is disabled");let s=Xi(t);if(s){if(s.__posthog_loading_callback_fired)return i();let r=s.__posthog_loading_error;return r?i(r):(s.addEventListener("load",o=>{s.__posthog_loading_callback_fired=!0,i(void 0,o)}),void s.addEventListener("error",o=>{s.__posthog_loading_error=o,i(o)}))}let n=()=>{if(!E)return i("document not found");if(Xi(t))return gt(e,t,i);let r=E.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=a=>{r.__posthog_loading_callback_fired=!0,i(void 0,a)},r.onerror=a=>{r.__posthog_loading_error=a,i(a)},e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")E.head.appendChild(r);else{let a=E.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(r,a[0]):E.body.appendChild(r)}};E?.body?n():E?.addEventListener("DOMContentLoaded",n)},Es={},Br=(e,t)=>{let i=`/static/${t}.js?v=${e.version}`;return t==="toolbar"&&(i=`${i}&t=${Math.floor(Date.now()/3e5)*3e5}`),e.requestRouter.endpointFor("assets",i)};C.__PosthogExtensions__=C.__PosthogExtensions__||{},C.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{if(t==="remote-config"){let n=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void gt(e,n,i)}let s=e.config.strict_script_versioning;if(s){let n=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),r=Es[n];if(s==="fallback"&&r){if(Xi(r))return void gt(e,r,i);delete Es[n]}return void gt(e,n,s==="fallback"?(o,a)=>{if(o)if(typeof o=="string")i(o);else{var l;let c=Br(e,t);Es[n]=c;let u=Xi(n);u==null||(l=u.parentNode)===null||l===void 0||l.removeChild(u),gt(e,c,i)}else i(void 0,a)}:i)}gt(e,Br(e,t),i)},C.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{let s=e.requestRouter.endpointFor("api",t);gt(e,s,i)},Ke.DEBUG=!1,Ke.LIB_VERSION="1.438.7",Ke.LIB_NAME="web";var $e=Ke,pn="$early_access_features",We="$active_feature_flags",yt="$feature_flag_details",yi="$feature_flag_errors",lt="$feature_flag_evaluated_at",bt="$feature_flag_request_id",li="$minimal_flag_called_events",Re="$enabled_feature_flags",nt="$stored_group_properties",rt="$stored_person_properties",ot="$flag_call_reported",si="$flag_call_reported_session_id",at="$feature_flag_payloads",Be="$override_feature_flags",_t="$override_feature_flag_payloads",bi="visibilitychange",ld="$people_distinct_id",Ce="distinct_id",Hn="$device_id",$s="$device_model",Zi="__alias",cd="__cmpns",Hr="$fbc",Lt="$fbc_persistence",Ur="$fbp",ci="$fbp_persistence",vn="__timers",el="$autocapture_disabled_server_side",fn="$heatmaps_enabled_server_side",gn="$exception_capture_enabled_server_side",tl="$error_tracking_suppression_rules",_n="$error_tracking_capture_extension_exceptions",mn="$web_vitals_enabled_server_side",Un="$dead_clicks_enabled_server_side",qn="$product_tours_enabled_server_side",il="$logs_capture_enabled_server_side",sl="$web_vitals_allowed_metrics",ui="$session_recording_remote_config",ud="$session_recording_enabled_server_side",dd="$replay_sample_rate",hd="$replay_override_sampling",pd="$replay_override_linked_flag",vd="$replay_override_url_trigger",fd="$replay_override_event_trigger",Ft="$sesid",nl="$session_is_sampled",gd="$session_past_minimum_duration",_d="$session_recording_url_trigger_activated_session",md="$session_recording_event_trigger_activated_session",yd="$debug_first_full_snapshot_timestamp",bd="$sess_rec_flush_size",rl="$groups",ni="$surveys",Qi="$surveys_loaded_at",ol="$surveys_activated",al="$surveys_activated_session",ll="$surveys_activated_timestamps",yn="ph_product_tours",wd="$product_tours_activated",xd="$product_tours_activated_session",kd="$conversations_widget_session_id",Ed="$conversations_ticket_id",$d="$conversations_widget_state",Sd="$conversations_user_traits",we="$user_state",bn="$client_session_props",Pd="$capture_rate_limit",cl="$initial_campaign_params",ul="$initial_referrer_info",It="$initial_person_info",zn="$epp",Ss="$posthog_cookieless",dl="$cookieless_mode",hl="$sdk_debug_extensions_init_method",pl="$sdk_debug_extensions_init_time_ms",Gn="$sdk_debug_recording_script_not_loaded",Vn="$sdk_debug_replay_stale_config",vl="$sdk_debug_replay_event_trigger_status",fl="$sdk_debug_replay_linked_flag_trigger_status",gl="$sdk_debug_replay_matched_recording_trigger_groups",_l="$sdk_debug_replay_pending_trigger_conditions",ml="$sdk_debug_replay_remote_trigger_matching_config",yl="$sdk_debug_replay_trigger_groups_count",bl="$sdk_debug_replay_url_trigger_status",Td="$session_recording_start_reason",Wn="PostHog loadExternalDependency extension not found.",Ye="anonymous",Ni="identified",wl="identified_only",es="beforeunload",Yn="$pageview",qr="$pageleave",xl="$identify",zr="$groupidentify";function At(e,t){I(e)&&e.forEach(t)}function W(e,t){if(!R(e))if(I(e))e.forEach(t);else if((i=>i instanceof FormData)(e))e.forEach((i,s)=>t(i,s));else for(let i in e)Rn.call(e,i)&&t(e[i],i)}var Q=function(e,...t){for(let i of t)for(let s in i)i[s]!==void 0&&(e[s]=i[s]);return e};function ji(e){let t=Object.keys(e),i=t.length,s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}var Md=function(e){return function(...t){try{return e.apply(this,t)}catch(i){S.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),S.critical(i)}}},Kn=function(e){let t={};return W(e,function(i,s){(D(i)&&i.length>0||re(i))&&(t[s]=i)}),t};function kl(e){let t=v({},e);for(let i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch{}return t}var Od=["herokuapp.com","vercel.app","netlify.app"];function Fd(e){let t=e?.hostname;if(!D(t))return!1;let i=t.split(".").slice(-2).join(".");for(let s of Od)if(i===s)return!1;return!0}function G(e,t,i,s){let{capture:n=!1,passive:r=!0}=s??{};e?.addEventListener(t,i,{capture:n,passive:r})}function wn(e){return e.name==="ph_toolbar_internal"}var di=e=>{if(E){try{let t=e+"=",i=E.cookie.split(";").filter(s=>s.length);for(let s=0;i.length>s;s++){let n=i[s];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 re(e)&&isFinite(e)&&Math.floor(e)===e});var Id=class xn{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,n){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(n)||0>t||0>i||0>s||0>n||t>0xffffffffffff||i>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");let 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|i>>>8,r[7]=i,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new xn(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),i!==3&&i!==5&&i!==7&&i!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new xn(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let i=0;16>i;i++){let s=this.bytes[i]-t.bytes[i];if(s!==0)return Math.sign(s)}return 0}},Ad=class{generate(){let e=this.generateOrAbort();if(!x(e))return e;{this.Ct=0;let t=this.generateOrAbort();if(x(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){let e=(()=>{let t=Date.now();return re(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.It();else{if(this.Ct>=e+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Id.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Cd}},El=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};b&&!x(b.crypto)&&crypto.getRandomValues&&(El=e=>crypto.getRandomValues(e));var Cd=class{nextUint32(){return this.Rt.length>this.Et||(El(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}},Gr,Le=()=>Rd().toString(),Rd=()=>(Gr||(Gr=new Ad)).generate(),Jt="",Ld=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Et=null,se={At(){if(!ne(Et))return Et;if(Et=!1,E)try{let e=`__ph_cookie_support_${Le()}`;se.$t(e,"xyz"),Et=di(e)==='"xyz"',se.Pt(e)}catch{Et=!1}return Et},Lt(e){S.error("cookieStore error: "+e)},Ot:di,Dt(e){let t;try{t=JSON.parse(se.Ot(e))||{}}catch{}return t},$t(e,t,i,s,n){if(!E)return!1;try{let r="",o="",a=(function(c,u){if(u){let h=(function(d,p=E){if(Jt)return Jt;if(!p||["localhost","127.0.0.1"].includes(d))return"";let f=d.split("."),_=Math.min(f.length,8),g="dmn_chk_"+Le();for(;!Jt&&_--;){let y=f.slice(_).join("."),m=g+"=1;domain=."+y+";path=/";p.cookie=m+";max-age=3",p.cookie.includes(g)&&(p.cookie=m+";max-age=0",Jt=y)}return Jt})(c);if(!h){let d=(p=>{let f=p.match(Ld);return f?f[0]:""})(c);d!==h&&S.info("Warning: cookie subdomain discovery mismatch",d,h),h=d}return h?"; domain=."+h:""}return""})(E.location.hostname,s);if(i){let c=new Date;c.setTime(c.getTime()+864e5*i),r="; expires="+c.toUTCString()}n&&(o="; secure");let l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&S.warn("cookieStore warning: large cookie, len="+l.length),E.cookie=l,!0}catch{return!1}},Pt(e,t){if(E?.cookie&&(!t||!ne(di(e))))try{se.$t(e,"",-1,t)}catch{return}}},Ps=null,H={At(){if(!ne(Ps))return Ps;let e=!0;if(x(b))e=!1;else try{let t="__mplssupport__";H.$t(t,"xyz"),H.Ot(t)!=='"xyz"'&&(e=!1),H.Pt(t)}catch{e=!1}return e||S.error("localStorage unsupported; falling back to cookie store"),Ps=e,e},Lt(e){S.error("localStorage error: "+e)},Ot(e){try{return b?.localStorage.getItem(e)}catch(t){H.Lt(t)}return null},Dt(e){try{return JSON.parse(H.Ot(e))||{}}catch{}return null},$t(e,t){try{return b?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(i){H.Lt(i)}return!1},Pt(e){try{b?.localStorage.removeItem(e)}catch(t){H.Lt(t)}}},Ts=[rt,We,Re,yt,at,bt,lt,yi,ot],mt=[Hn,Ce,Ft,nl,zn,It,Lt,we],ts=e=>e+"_cpm",Dd=["__proto__","constructor","prototype"],Ms=e=>{if(!L(e))return{};let t={};return Object.keys(e).forEach(i=>{Dd.indexOf(i)===-1&&(t[i]=e[i])}),t},Os=(e,t=[])=>{let i={};return[...mt,...t].forEach(s=>{let n=e[s];x(n)||ne(n)||n===""||(i[s]=n)}),i},$l=e=>{let t=5381,i=2166136261;for(let s=0;e.length>s;s++){let n=e.charCodeAt(s);t=33*t^n,i=Math.imul(i^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Vr=(e,t)=>({p:t,f:$l(JSON.stringify(e))}),Wr=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{let i=se.Dt(ts(e)),s=i?.f===$l(t)&&I(i.p);return{properties:s?i.p:[],isValid:s}}catch{return{properties:[],isValid:!1}}},Fs=(e,t)=>t+"|"+(se.Ot(ts(e))||""),$t={},kn={At:()=>!0,Lt(e){S.error("memoryStorage error: "+e)},Ot:e=>e in $t?$t[e]:null,Dt:e=>e in $t?$t[e]:null,$t:(e,t)=>($t[e]=t,!0),Pt(e){delete $t[e]}},dt=null,J={At(){if(!ne(dt))return dt;if(dt=!0,x(b))dt=!1;else try{let e="__support__";J.$t(e,"xyz"),J.Ot(e)!=='"xyz"'&&(dt=!1),J.Pt(e)}catch{dt=!1}return dt},Lt(e){S.error("sessionStorage error: ",e)},Ot(e){try{return b?.sessionStorage.getItem(e)}catch(t){J.Lt(t)}return null},Dt(e){try{return JSON.parse(J.Ot(e))||null}catch{}return null},$t(e,t){try{return b?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(i){J.Lt(i)}return!1},Pt(e){try{b?.sessionStorage.removeItem(e)}catch(t){J.Lt(t)}}},Nd=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.No.$t(this.qo,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.No.Pt(this.qo,this.Mr.cross_subdomain_cookie)}get qo(){let{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get Lo(){let e=this.No.Ot(this.qo);return fs(e)?1:A(Dc,e)?0:-1}get No(){let e=this.Mr.opt_out_capturing_persistence_type,t=e==="localStorage"?H:se,i=t.At()?t:kn;if(!this.jo||this.jo!==i){this.jo=i;let s=e==="localStorage"?se:H;s.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(fs(s.Ot(this.qo))),s.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[pe?.doNotTrack,pe?.msDoNotTrack,C.doNotTrack,pe?.globalPrivacyControl].some(e=>fs(e))}};function Sl(e,t){var i;let s=e==null||(i=e.config)===null||i===void 0?void 0:i.get_current_url;if(!oe(s))return t;try{let n=s(t);return D(n)&&n?n:t}catch(n){return S.error("Error in get_current_url, falling back to window.location.href",n),t}}function Yr(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 De(e){return!!e&&e.nodeType===1}function ve(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Pl(e){return!!e&&e.nodeType===3}function Jn(e){return!!e&&e.nodeType===11&&De(e.host)}function Xn(e){return e?Nt(e).split(/\s+/):[]}function Kr(e,t){let i=(function(s){var n;let r=b==null||(n=b.location)===null||n===void 0?void 0:n.href;return x(r)?void 0:Sl(s,r)})(t);return!!(i&&e&&e.some(s=>i.match(s)))}function Bt(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 Xn(t)}function Tl(e){return R(e)?null:Nt(e).split(/(\s+)/).filter(t=>Dt(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function wi(e){let t="";return wt(e)&&!Ht(e)&&e.childNodes&&e.childNodes.length&&W(e.childNodes,function(i){var s;Pl(i)&&i.textContent&&(t+=(s=Tl(i.textContent))!==null&&s!==void 0?s:"")}),Nt(t)}function hi(e){var t;return x(e.target)?e.srcElement||null:!((t=e.target)===null||t===void 0)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var Zn=["a","button","form","input","select","textarea","label"];function En(e,t){let i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch{return!1}}function $n(e,t){if(x(t))return!0;for(let i of e)if(t.some(s=>En(i,s)))return!0;return!1}function Ml(e){let t=e.parentNode;return!(!t||!De(t))&&t}var Is=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ol=["next","previous","prev",">","<","\u2192","\u2190","\u203A","\u2039","\xBB","\xAB","\u25B6","\u25C0","\u276F","\u276E"],Qn=[...Ol,"+","-","\u2212","\u2013"],Jr=Qn.length+10,jd=["button","a","input","select","textarea","label"],Bd=["button","link","tab","menuitem","option"],Xr=(e,t)=>/[a-z0-9]/i.test(t)?A(Qn,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,Hd=e=>A(jd,e.tagName.toLowerCase())||A(Bd,(e.getAttribute("role")||"").toLowerCase());function As(e){let t="",i="",s=o=>{De(o)&&wt(o)&&!Ht(o)&&(t+=` ${wi(o)}`,i=i||o.getAttribute("aria-label")||"",W(o.childNodes,s))};s(e),t=Nt(t.replace(/\s+/g," "));let n=(Dt(t)?t:"").toLowerCase(),r=e.getAttribute("aria-label")||(n?"":i);return{safeText:n,ariaLabel:Nt(r).toLowerCase()}}var Zr=[".ph-no-rageclick",".ph-no-capture"],Ud=["","text","search","email","password","url","tel","number"];function Fl(e,t){if(!b||er(e))return!1;let i,s,n;var r,o;if(xe(t)?(i=!!t&&Zr,s=void 0,n=!1):(i=(r=t?.css_selector_ignorelist)!==null&&r!==void 0?r:Zr,s=t?.content_ignorelist,n=(o=t?.ignore_text_selection)!==null&&o!==void 0&&o),i===!1||n&&(function(l){return!(!l||!De(l))&&(!!ve(l,"textarea")||(ve(l,"input")?A(Ud,(l.getAttribute("type")||"").toLowerCase()):(function(c){var u;if(c.isContentEditable)return!0;let h=(u=c.getAttribute)===null||u===void 0?void 0:u.call(c,"contenteditable");return h==="true"||h===""})(l)))})(e))return!1;let{targetElementList:a}=Il(e,!1);return!(s&&(function(l,{safeText:c,ariaLabel:u}){let h;if(l===!0)h=Ol;else{if(!I(l))return!1;if(l.length>Jr)return S.error(`[PostHog] content_ignorelist array cannot exceed ${Jr} items. Use css_selector_ignorelist for more complex matching.`),!1;h=l.map(d=>d.toLowerCase())}return h.some(d=>Xr(c,d)||Xr(u,d))})(s,(function(l,c){for(let u of c)if(Hd(u))return As(u);for(let u of c){try{if(b?.getComputedStyle(u).getPropertyValue("cursor")!=="pointer")break}catch{break}let h=As(u);if(h.safeText||h.ariaLabel)return h}return As(l)})(e,a))||$n(a,i))}var er=e=>!e||ve(e,"html")||!De(e),Il=(e,t)=>{if(!b||er(e))return{parentIsUsefulElement:!1,targetElementList:[]};let i=!1,s=[e],n=e;for(;n.parentNode&&!ve(n,"body");){if(Jn(n.parentNode)){s.push(n.parentNode.host),n=n.parentNode.host;continue}let r=Ml(n);if(!r)break;if(t||Zn.indexOf(r.tagName.toLowerCase())>-1)i=!0;else try{let o=b.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(i=!0)}catch{}s.push(r),n=r}return{parentIsUsefulElement:i,targetElementList:s}};function wt(e){let t=new Set,i=0;for(let r=e;r.parentNode&&!ve(r,"body");r=r.parentNode){if(i++>=1e3||t.has(r))return!1;t.add(r);let o=Bt(r);if(A(o,"ph-sensitive")||A(o,"ph-no-capture"))return!1}if(A(Bt(e),"ph-include"))return!0;let s=e.type||"";if(D(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}let n=e.name||e.id||"";return!D(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 Ht(e){return!!(ve(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ve(e,"select")||ve(e,"textarea")||e.getAttribute("contenteditable")==="true")}var Qr=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}))$"),eo=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,qd=[16,15,14,13],zd=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),to=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),io=/[0-9A-Za-z_]/;function Gd(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function Dt(e,t=!0){return!(R(e)||D(e)&&(e=Nt(e),(t?Qr.test((e||"").replace(/[- ]/g,"")):(function(i){let s;for(eo.lastIndex=0;s=eo.exec(i);){let n=s[2];if(!n)continue;let r=n.replace(/[- ]/g,"");for(let o=0;r.length>o;o++)for(let a of qd){let l=o+a;if(r.length>=l){let c=r.slice(o,l);if(Qr.test(c)&&Gd(c))return!0}}}return!1})(e))||(t?zd.test(e):(function(i){let s;for(to.lastIndex=0;s=to.exec(i);){let n=s[1],r=s[3];if(!(n&&r&&io.test(n)&&io.test(r)))return!0}return!1})(e))))}function so(e){let t=wi(e);return t=`${t} ${Al(e)}`.trim(),Dt(t)?t:""}function Al(e){let t="";return e&&e.childNodes&&e.childNodes.length&&W(e.childNodes,function(i){var s;if(i&&((s=i.tagName)===null||s===void 0?void 0:s.toLowerCase())==="span")try{let n=wi(i);t=`${t} ${n}`.trim(),i.childNodes&&i.childNodes.length&&(t=`${t} ${Al(i)}`.trim())}catch(n){S.error("[AutoCapture]",n)}}),t}function no(e){return e.replace(/"|\\"/g,'\\"')}function Vd(e){let t=e.attr__class;if(t)return I(t)?t:Xn(t)}var Mi=te("[Dead Clicks]"),Wd=()=>!0,Yd=e=>{var t;let i=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(Un)),s=e.instance.config.capture_dead_clicks;return xe(s)?s:!!L(s)||i},ro=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Un]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Ho()}):this.stop()}zo(e){var t,i,s;!((t=C.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(i=C.__PosthogExtensions__)===null||i===void 0||(s=i.loadExternalDependency)===null||s===void 0||s.call(i,this.instance,"dead-clicks-autocapture",n=>{n?Mi.error("failed to load script",n):e()})}Ho(){var e;if(E){if(!this.Bo&&(!((e=C.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){let t=L(this.instance.config.capture_dead_clicks)?v({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Bo=C.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Bo.start(E),Mi.info("starting...")}}else Mi.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,Mi.info("stopping..."))}},Xt=te("[SegmentIntegration]");function oo(e,t,i=!0){let s=e.config.segment;if(!s)return t();let{analytics:n,filterProperties:r}=(a=>oe(a.register))(o=s)?{analytics:o}:o;var o;(function(a,l,c,u){let h=p=>{let f=()=>p.anonymousId()||Le();a.config.get_device_id=f,u&&p.id()&&(a.register({distinct_id:p.id(),$device_id:f()}),a.persistence.set_property(we,Ni)),c(u?void 0:p.anonymousId()||void 0)},d=l.user();"then"in d&&oe(d.then)?d.then(h):h(d)})(e,n,a=>{n.register(((l,c,{filterProperties:u}={})=>{typeof Promise<"u"&&Promise.resolve||Xt.warn("This browser does not have Promise support, and can not use the segment integration");let h=(d,p)=>{if(!p)return d;let f=!!c&&d.event.anonymousId===c&&!d.event.userId;f||d.event.userId||d.event.anonymousId===l.get_distinct_id()||(Xt.info("No userId set, resetting PostHog"),l.reset()),f||(c=void 0),d.event.userId&&d.event.userId!==l.get_distinct_id()&&(Xt.info("UserId set, identifying with PostHog"),l.identify(d.event.userId));let _=l.calculateEventProperties(p,d.event.properties);if(!R(u)){let g=d.event.properties||{},y={};for(let w of Object.keys(_))Rn.call(g,w)||(y[w]=_[w]);let m=((w,$)=>{let P=I(w)?w:[w],k=v({},$);for(let M of P)try{if(k=M(k),R(k))return null}catch(T){return Xt.error("Error in Segment filterProperties:",T),null}return k})(u,y);if(R(m))return d;_=m}return d.event.properties=Object.assign({},_,d.event.properties),d};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(d){return h(d,d.event.event)},page(d){return h(d,Yn)},identify(d){return h(d,xl)},screen(d){return h(d,"$screen")}}})(e,a,{filterProperties:r})).then(()=>{t()},l=>{Xt.error("Failed to register the Segment integration",l),t()})},i)}var Cl="posthog-js";function Rl(e,{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,h;if(n!=="*"&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});let d=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));let p=((a=o.exception)===null||a===void 0?void 0:a.values)||[],f=p.map(y=>v(v({},y),{},{stacktrace:y.stacktrace?v(v({},y.stacktrace),{},{type:"raw",frames:(y.stacktrace.frames||[]).map(m=>v(v({},m),{},{platform:"web:javascript"}))}):void 0})),_={$exception_message:((l=p[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(c=p[0])===null||c===void 0?void 0:c.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((u=p[0])===null||u===void 0?void 0:u.value)||o.message,$sentry_exception_type:(h=p[0])===null||h===void 0?void 0:h.type,$sentry_tags:o.tags};var g;return t&&i&&(_.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&((g=e.exceptions)===null||g===void 0||g.sendExceptionEvent(_)),o}}var Kd=class{constructor(e,t,i,s,n,r){this.name=Cl,this.setupOnce=function(o){o(Rl(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:r==null||r}))}}},ao=class{constructor(e){this.Uo=(t,i,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength||s.crossTabAdoption)&&(S.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:s}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Vo()}Vo(){var e;this.Go=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Uo)}destroy(){var e;(e=this.Go)===null||e===void 0||e.call(this),this.Go=void 0}doPageView(e,t){var i;let s=this.Qo(e,t);return this.Wo={pathname:(i=b?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.Qo(e,(t=this.Wo)===null||t===void 0?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Wo)===null||e===void 0?void 0:e.pageViewId}}Qo(e,t){let i=this.Wo;if(!i)return{$pageview_id:t};let s={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:r,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=n;if(!(x(r)||x(o)||x(a)||x(l)||x(c)||x(u))){r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);let h=r>1?Ue(o/r,0,1,S):1,d=r>1?Ue(a/r,0,1,S):1,p=l>1?Ue(c/l,0,1,S):1,f=l>1?Ue(u/l,0,1,S):1;s=Q(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:f})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},Zt=["flags","surveys"],Jd={[ld]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[cd]:{exposure:"hidden"},[vn]:{exposure:"hidden"},[Lt]:{exposure:"hidden"},[ci]:{exposure:"hidden"},[el]:{exposure:"event"},[fn]:{exposure:"hidden"},[il]:{exposure:"hidden"},[gn]:{exposure:"event"},[tl]:{exposure:"hidden"},[_n]:{exposure:"event"},[mn]:{exposure:"event"},[Un]:{exposure:"event"},[qn]:{exposure:"hidden"},[sl]:{exposure:"event"},[ui]:{exposure:"hidden"},[ud]:{exposure:"hidden"},[Ft]:{exposure:"hidden"},[nl]:{exposure:"event"},[dd]:{exposure:"event",shouldSkipFromEventProperties:e=>ne(e)},[gd]:{exposure:"event"},[_d]:{exposure:"event"},[md]:{exposure:"event"},[yd]:{exposure:"event"},[bd]:{exposure:"hidden"},[Re]:{exposure:"hidden",storageGroup:"flags"},[We]:{exposure:"hidden",storageGroup:"flags"},[pn]:{exposure:"hidden"},[yt]:{exposure:"hidden",storageGroup:"flags"},[at]:{exposure:"hidden",storageGroup:"flags"},[bt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[li]:{exposure:"hidden",storageGroup:"flags"},[Be]:{exposure:"hidden"},[_t]:{exposure:"hidden"},[rt]:{exposure:"hidden"},[nt]:{exposure:"hidden"},[ni]:{exposure:"hidden",storageGroup:"surveys"},[Qi]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[ol]:{exposure:"event"},[al]:{exposure:"hidden"},[ll]:{exposure:"hidden"},[yn]:{exposure:"hidden"},[wd]:{exposure:"hidden"},[xd]:{exposure:"hidden"},[kd]:{exposure:"event"},[Ed]:{exposure:"event"},[$d]:{exposure:"event"},[Sd]:{exposure:"event"},[ot]:{exposure:"hidden"},[si]:{exposure:"hidden"},[rl]:{exposure:"event"},[yi]:{exposure:"hidden"},[lt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[we]:{exposure:"hidden"},[bn]:{exposure:"hidden"},[Pd]:{exposure:"hidden"},[cl]:{exposure:"hidden"},[ul]:{exposure:"hidden"},[It]:{exposure:"hidden"},[zn]:{exposure:"hidden"},[hd]:{exposure:"event"},[pd]:{exposure:"event"},[vd]:{exposure:"event"},[fd]:{exposure:"event"},[hl]:{exposure:"event"},[pl]:{exposure:"event"},[Gn]:{exposure:"hidden"},[Vn]:{exposure:"hidden"},[vl]:{exposure:"hidden"},[fl]:{exposure:"hidden"},[gl]:{exposure:"hidden"},[_l]:{exposure:"hidden"},[ml]:{exposure:"hidden"},[yl]:{exposure:"hidden"},[bl]:{exposure:"hidden"},[Td]:{exposure:"event"}},Xd=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],de=e=>{let t=Jd[e];if(t)return t;for(let[i,s]of Xd)if(e.indexOf(i)===0)return s};function Ll(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}var Dl=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},Nl=(e,t)=>e>=t&&Dl(),jl=(e,t,i,s)=>{if(e===0){if(Dl()){let n=t+1;return n===i&&s(),n}return t}return 0},Ct=(e,t)=>{try{let i;return JSON.stringify(e,(s,n)=>{var r;return Vt(n)?((r=i)!==null&&r!==void 0||(i=new WeakMap),i.has(n)||i.set(n,kl(n)),i.get(n)):typeof n=="bigint"?n.toString():n},t)}catch{return Xo(e)}},Je=e=>{let t=E?.createElement("a");return x(t)?null:(t.href=e,t)},Ut=function(e,t){let i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s;for(let n=0;i.length>n;n++){let r=i[n].split("=");if(r[0]===t){s=r;break}}if(!I(s)||2>s.length)return"";{let n=s[1];try{n=decodeURIComponent(n)}catch{S.error("Skipping decoding for malformed query param: "+n)}return n.replace(/\+/g," ")}},xi=function(e,t,i){if(!e||!t||!t.length)return e;let s=e.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let h=0;l.length>h;h++){let d=l[h].split("=");I(d)&&(t.includes(d[0])?c.push(d[0]+"="+i):c.push(l[h]))}let u=a;return o!=null&&(u+="?"+c.join("&")),n!=null&&(u+="#"+n),u},is=function(e,t){let i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},qt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],Zd=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...qt],ki="<masked>",Qd=["li_fat_id"];function Bl(e,t,i){if(!E)return{};let s=t?[...qt,...i||[]]:[],n=Hl(xi(E.URL,s,ki),e),r=(function(){let o={};return W(Qd,function(a){let l=di(a);o[a]=l||null}),o})();return Q(r,n)}function Hl(e,t){let i=Zd.concat(t||[]),s={};return W(i,function(n){let r=Ut(e,n);s[n]=r||null}),s}function Ul(e){let t=(function(n){return n?n.search("https?://(.*)google.([^/?]*)")===0?"google":n.search("https?://(.*)bing.com")===0?"bing":n.search("https?://(.*)yahoo.com")===0?"yahoo":n.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(e),i=t!="yahoo"?"q":"p",s={};if(!ne(t)){s.$search_engine=t;let n=E?Ut(E.referrer,i):"";n.length&&(s.ph_keyword=n)}return s}function ql(){return navigator.language||navigator.userLanguage}function eh(){let e=ql();return typeof e=="string"?e.split("-")[0]:void 0}var ss="$direct";function zl(){return E?.referrer||ss}function Gl(e,t,i=!1){let s=e?[...qt,...t||[]]:[],n=i?ct(Z?.href):Z?.href,r=n?.substring(0,1e3);return{r:zl().substring(0,1e3),u:r?xi(r,s,ki):void 0}}function Vl(e,t=!1){var i;let{r:s,u:n}=e,r=t?ct(n):n,o={$referrer:s,$referring_domain:s==null?void 0:s==ss?ss:(i=Je(s))===null||i===void 0?void 0:i.host};if(r){o.$current_url=r;let a=Je(r);o.$host=a?.host,o.$pathname=a?.pathname;let l=Hl(r);Q(o,l)}if(s){let a=Ul(s);Q(o,a)}return o}function th(){try{return new Date().getTimezoneOffset()}catch{return}}var ih={flags:lt,surveys:Qi},sh=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Oi=e=>`${e}_cookie_identity_change_pending`,Fi=e=>{let t="",i=0;for(let s of e){let n=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+n>1e3)break;t+=s,i+=n}return t},le="main",Ve=[Re,We,yt,at,bt,lt,li,rt],Cs=e=>Ve.indexOf(e)!==-1,Wl=[Lt,ci],lo=e=>Wl.indexOf(e)!==-1,tt=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},St=e=>{if(!e)return{};let t=JSON.parse(e);return L(t)?t:{}},co=(e,t)=>{W(e,(i,s)=>{let n=de(s);n&&n.exposure!=="event"||{}.hasOwnProperty.call(t,s)||delete e[s]})},Rs=class{constructor(e,t,i=!0,s=!e.cookieless_mode){if(this.Zo={},this.Jo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Mr=e,this.aa=i,this.props={},this.la=void 0,this.ua=(n=>{let r="";return n.token&&(r=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+r+"_posthog"})(e),this.hi=e.disable_persistence||!!t,this.No=this.ca(e),this.Xo=this.ha(e),this.load(s),this.da(),e.debug&&S.info("Persistence loaded",e.persistence,v({},this.props)),this.update_config(e,e,t),this.save(),b){let n=()=>this.flush();G(b,"beforeunload",n,{capture:!1}),G(b,"pagehide",n,{capture:!1}),this.va=r=>{if(this.Jo&&(!r.storageArea||r.storageArea===b?.localStorage)&&r.key)if(r.key!==this.ua){if(this.Xo){let o=Zt.find(a=>r.key===this.fa(a));o&&this.pa(r.key,o)}}else this.pa(r.key,le)},G(b,"storage",this.va)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,i])=>{let s=this.ea.get(t);if(!Cs(t)||s===!0)return;if(i===!0)return void this.ga(t,!0);let n=new Set(s||[]);i.forEach(r=>n.add(r)),n.size&&this.ga(t,n)})}onCrossTabFeatureFlagChange(e){return this.oa.add(e),()=>this.oa.delete(e)}destroy(){this.va&&b&&(b.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(e,t,i=!0){if(this.hi)return!1;let s,n;try{if(n=H.Ot(e),ne(n)){let a=this.ma(t);return a.storageValue=null,t!==le&&(a.persisted=!1),!1}s=St(n)}catch{return!1}let r=t===le?s:H.Dt(this.ua);if(r&&this.ya(r))return!1;let o=this.ba(s,t,i);return t===le&&this.Xo&&!tt(this._a().main,s)||this.wa(s,t,!0,n),o}ya(e){let t=this.props[Ce],i=e[Ce];return!x(t)&&!x(i)&&t!==i}wa(e,t,i,s){let n=this.ma(t);n.storageValue=s,t!==le&&(n.persisted=i);try{n.fingerprint=this.ka(e,t)}catch{n.fingerprint=void 0}}ba(e,t,i){let s=!1;return Ve.forEach(n=>{var r;let o=(r=de(n))===null||r===void 0?void 0:r.storageGroup;if(t===le&&this.Xo&&o||t!==le&&o!==t)return;let a=n in e,l=this.Sa(n,a?e[n]:void 0),c=this.ea.has(n)?n in this.props:a;c===n in this.props&&tt(l,this.props[n])||(c?this.xa(n,l,!1):this.$a(n,!1),s=!0)}),s&&i&&this.oa.forEach(n=>n()),s}Ca(){if(!this.Jo)return!1;try{this.sa=!1;let e=H.Ot(this.ua),t=this.ma(le),i,s=!1,n=!1;if(e!==t.storageValue)if(ne(e))t.storageValue=null;else{if(i=St(e),this.sa=!this.na&&this.ya(i),this.sa)return!1;n=this.ba(i,le,!1),!this.Xo||tt(this._a().main,i)?this.wa(i,le,!0,e):t.storageValue=e,s=!0}return this.Xo&&Zt.forEach(r=>{let o=H.Ot(this.fa(r)),a=this.ma(r),l=i||{},c=s&&Ve.some(h=>{var d;return((d=de(h))===null||d===void 0?void 0:d.storageGroup)===r&&h in l});if(o===a.storageValue&&!c)return;if(ne(o))return a.storageValue=null,a.persisted=!1,void(c&&(n=this.ba(l,r,!1)||n));let u=St(o);n=this.ba(u,r,!1)||n,this.wa(u,r,!0,o)}),n}catch{return!1}}ga(e,t){this.ea.set(e,t);let i=de(e);i?.volatile||(this.ma((this.Xo?i?.storageGroup:void 0)||le).fingerprint=void 0,this.Ta(e))}Ia(){Ve.forEach(e=>this.ea.set(e,!0))}da(){if(this.Jo)try{let e=H.Ot(this.ua),t=St(e);this.ma(le).storageValue=e,Ve.forEach(i=>{var s;let n=this.Xo?(s=de(i))===null||s===void 0?void 0:s.storageGroup:void 0,r=n?H.Ot(this.fa(n)):null;if(n){let a=this.ma(n);a.storageValue=r,a.persisted=!ne(r)}let o=n&&!ne(r)?St(r):t;i in this.props?this.Ma(i,o[i],this.props[i]):i in o&&this.ga(i,!0)})}catch{}}Sa(e,t){let i=this.ea.get(e);if(!i)return t;if(i===!0)return this.props[e];if(e==="$active_feature_flags"){let r=new Set(I(t)?t:[]),o=new Set(I(this.props[e])?this.props[e]:[]);return i.forEach(a=>o.has(a)?r.add(a):r.delete(a)),Array.from(r)}let s=L(t)?v({},t):{},n=L(this.props[e])?this.props[e]:{};return i.forEach(r=>{r in n?s[r]=n[r]:delete s[r]}),s}Ma(e,t,i){if(!Cs(e))return;let s=this.ea.get(e);if(s===!0)return;let n=t;if(this.Jo)try{var r;let a=this.Xo?(r=de(e))===null||r===void 0?void 0:r.storageGroup:void 0,l=a?this.fa(a):this.ua;n=St(H.Ot(l))[e]}catch{}let o=new Set(s||[]);if(e==="$active_feature_flags"){if(!x(t)&&!I(t)||!x(n)&&!I(n)||!I(i))return void this.ga(e,!0);let a=new Set(t||[]),l=new Set(n||[]),c=new Set(i);new Set([...a,...c]).forEach(u=>{a.has(u)!==c.has(u)&&o.add(u)}),o.forEach(u=>{l.has(u)===c.has(u)&&o.delete(u)})}else{if(!L(i))return void(tt(n,i)?this.ea.delete(e):this.ga(e,!0));{if(!x(t)&&!L(t)||x(t)&&Se(i)&&x(n))return void this.ga(e,!0);let a=L(t)?t:{},l=L(n)?n:{};new Set([...Object.keys(a),...Object.keys(i)]).forEach(c=>{c in a==c in i&&tt(a[c],i[c])||o.add(c)}),o.forEach(c=>{c in l==c in i&&tt(l[c],i[c])&&o.delete(c)})}}o.size?this.ga(e,o):this.ea.delete(e)}Ea(){var e;let t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return re(t)&&t>0?t:0}Pa(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{let t=Os(e,this.Mr.cookie_persisted_properties||[]),i=Vr(t,this.Mr.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),n=se.Ot(this.ua)||void 0;n&&Fs(this.ua,n)===s&&(this.Ra=s,this.Aa=n)}catch{}else try{let t=se.Ot(this.ua)||void 0;this.Ra=t?Fs(this.ua,t):void 0,this.Aa=t}catch{}}syncCookieProperties(){return this.Fa(this.Mr)}Fa(e,t=!1){if(this.hi&&!t||this.ta||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let i;try{i=se.Ot(this.ua)||void 0}catch{}if(!i||i===this.Aa)return!1;let s=Fs(this.ua,i),n;try{n=Ms(JSON.parse(i))}catch{return!1}if((se.Ot(this.ua)||void 0)!==i)return!1;this.Ra=s,this.Aa=i;let r=Wr(this.ua,i),o=[...mt,...r.properties],a={};if(Object.keys(n).forEach(_=>{let g=n[_];(x(g)||ne(g)||g===""||_==="$user_state"&&g!=="anonymous"&&g!=="identified")&&(a[_]=!0,delete n[_])}),Se(n))return!1;let l="distinct_id"in n||n.$user_state==="anonymous"||n.$user_state==="identified",c=this.props,u=c[Ce],h=c[we],d=Q({},c);[...mt,...e.cookie_persisted_properties||[]].forEach(_=>{if(o.indexOf(_)!==-1&&!(_ in n)&&!a[_]&&(l||_!=="distinct_id"&&_!=="$user_state")){let g=d[_];(r.isValid||mt.indexOf(_)===-1||g!==!1&&g!==0)&&delete d[_]}}),this.props=Q(d,n),Ve.forEach(_=>{let g=_ in this.props;_ in c===g&&tt(c[_],this.props[_])||(g?this.Ma(_,c[_],this.props[_]):this.ga(_,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this.xa(we,Ye);let p=this.props[Ce],f=this.props[we];return!l||p===u&&f===h||(this.na=!0,this.Yo=!0,J.$t(Oi(this.ua),!0),this.$a(rt),this.$a(We),this.$a(Re),this.$a(yt),this.$a(at),this.$a(bt),this.$a(lt),this.$a(yi),this.$a(ot),f!=="anonymous"||h!=="identified"&&n.$user_state!=="anonymous"&&(x(u)||p===u)||(co(this.props,n),this.$a(nt)),f==="identified"?this.props.$user_id=p:delete this.props.$user_id,this.$a(Zi)),!0}consumeCookieIdentityChange(){let e=Oi(this.ua),t=this.Yo||!!J.Ot(e);return this.Yo=!1,t&&J.Pt(e),t}Oa(e=!1){return!(this.ta||this.hi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ta=!0,0))}Da(){this.ta&&(x(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Zo[le],this.Na(!0))}qa(e=!0){if(this.ta)try{e?this.Da():x(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ca(e){sh.indexOf(e.persistence.toLowerCase())===-1&&(S.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");let t=((o=[],a=!1,l=()=>!1)=>{let c=[...mt,...o];return v(v({},H),{},{Dt(u){try{let d,p={};try{d=se.Ot(u)||void 0,p=d?Ms(JSON.parse(d)):{}}catch{}let f=JSON.parse(H.Ot(u)||"{}"),_;if(a){let g=Wr(u,d),y=[...mt,...g.properties],m={};Object.keys(p).forEach($=>{let P=p[$];ne(P)||P===""||$==="$user_state"&&P!=="anonymous"&&P!=="identified"||(m[$]=P)});let w="distinct_id"in m||m.$user_state==="anonymous"||m.$user_state==="identified";if(Object.keys(m).length>0){var h;let $=f[Ce],P=(h=f.$user_state)!==null&&h!==void 0?h:Ye;c.forEach(k=>{if(y.indexOf(k)!==-1&&!(k in p)&&(w||k!=="distinct_id"&&k!=="$user_state")){let M=f[k];(g.isValid||mt.indexOf(k)===-1||M!==!1&&M!==0)&&delete f[k]}}),!w||"$user_state"in p||"$user_state"in f||(f[we]=Ye),!w||("distinct_id"in m?m[Ce]:f[Ce])===$&&("$user_state"in m?m[we]:f[we])===P||(Ts.forEach(k=>delete f[k]),m.$user_state==="identified"&&"distinct_id"in m?f.$user_id=m[Ce]:delete f.$user_id,m.$user_state!=="identified"&&(delete f[rl],delete f[nt]),delete f.__alias)}_=Q(f,m)}else _=Q(p,f);return l()||H.$t(u,_),_}catch{}return null},$t(u,h,d,p,f,_){let g=H.$t(u,h,void 0,void 0,_);try{let y=Os(h,o);if(Object.keys(y).length){if(a){let m=ts(u),w=Vr(y,o);if(se.$t(m,w,d,p,f,_),se.Ot(m)!==JSON.stringify(w)){se.Pt(m,p);let $=Os(h);return se.$t(u,$,d,p,f,_),g}}se.$t(u,y,d,p,f,_)}}catch(y){H.Lt(y)}return g},Pt(u,h){try{b?.localStorage.removeItem(u),se.Pt(u,h),se.Pt(ts(u),h)}catch(d){H.Lt(d)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi),i,s=!1,n=!1,r=e.persistence.toLowerCase();return r==="localstorage"&&H.At()?(i=H,n=!0):r==="localstorage+cookie"&&t.At()?(i=t,n=!0,s=!0):r==="sessionstorage"&&J.At()?i=J:r==="memory"?i=kn:r==="cookie"&&se.At()?(i=se,s=!0):t.At()?(i=t,n=!0,s=!0):se.At()?(i=se,s=!0):i=kn,this.Jo=n,this.Ko=s,i}fa(e){return`${this.ua}__${e}`}ha(e){return this.Jo&&!!e.split_storage}properties(){let e={};return W(this.props,(t,i)=>{let s=de(i);if(!s||s.exposure==="event"){var n;if(!(s==null||(n=s.shouldSkipFromEventProperties)===null||n===void 0)&&n.call(s,t))return;e[i]=t}}),e}load(e=!1){if(this.hi&&!e)return;let t=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",i=t?H.Dt(this.ua):null,s={};if(t)try{s=Ms(se.Dt(this.ua)),W(s,(a,l)=>{(x(a)||ne(a)||a==="")&&delete s[l]})}catch{}let n=this.No.Dt(this.ua);if(n&&(this.props=Q({},n)),this.Xo&&this.ja(),t&&n){var r,o;let a=i?.[Ce],l=(r=i?.$user_state)!==null&&r!==void 0?r:Ye,c=n[Ce],u=(o=n.$user_state)!==null&&o!==void 0?o:Ye;if(c!==a||u!==l){this.Yo=!0,this.hi||J.$t(Oi(this.ua),!0);let h=Q({},this.props);Ts.forEach(p=>delete h[p]),u!=="anonymous"||l!=="identified"&&s.$user_state!=="anonymous"&&(x(a)||c===a)||(co(h,s),delete h[nt]),this.props=h;let d=new Set;Ts.forEach(p=>{var f;let _=(f=de(p))===null||f===void 0?void 0:f.storageGroup;_&&d.add(_)}),d.forEach(p=>{if(this.hi)return;let f={};W(this.props,(_,g)=>{var y;((y=de(g))===null||y===void 0?void 0:y.storageGroup)===p&&(f[g]=_)}),Se(f)?(H.Pt(this.fa(p)),this.Zo[p]={}):H.$t(this.fa(p),f)&&(this.Zo[p]={persisted:!0,fingerprint:this.ka(f,p)})})}}J.Ot(Oi(this.ua))&&(this.Yo=!0)}ja(){for(let e of Zt){let t=H.Dt(this.fa(e));if(t&&!Se(t)){let i=this.ma(e);i.persisted=!0,this.Ba(e)||(i.fingerprint=this.ka(t,e)),this.za(e,t)||Q(this.props,t)}}}Ba(e){return Object.keys(this.props).some(t=>{var i;return((i=de(t))===null||i===void 0?void 0:i.storageGroup)===e})}za(e,t){let i=ih[e];if(!i)return!1;let s=t[i],n=this.props[i];return re(s)&&re(n)&&n>s}refreshKey(e){var t;if(this.hi||this.ra.has(e))return;let i=this.Xo?(t=de(e))===null||t===void 0?void 0:t.storageGroup:void 0,s=i?H.Dt(this.fa(i)):this.No.Dt(this.ua);if(s&&e in s)this.xa(e,s[e],!1);else{if(i){let n=this.No.Dt(this.ua);if(n&&e in n)return void this.xa(e,n[e],!1)}this.$a(e,!1)}}save(){if(this.hi)return;let e=this.Ea();e>0?x(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},e)):this.Na()}flush(){x(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(e=!1){if(this.hi||this.ta&&!e)return;e||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||Wl.forEach(n=>this.refreshKey(n)));let t=!e&&!this.ia;t||(this.sa=!1);let i=!!t&&this.Ca();if(this.sa)return void(this.Mr.debug&&S.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.Ha(),void(i&&this.oa.forEach(n=>n()));let s=this.Ua(this.No,this.ua,this.props,le);s==="written"&&this.Pa(this.props),s!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),i&&this.oa.forEach(n=>n())}Ha(){let{main:e,groups:t}=this._a(),i=this.Ua(this.No,this.ua,e,le);i==="written"&&this.Pa(e),i!=="failed"&&(this.na=!1,this.ra.clear(),Ve.forEach(n=>{var r;!((r=de(n))===null||r===void 0)&&r.storageGroup||this.ea.delete(n)}));for(let n of Zt){var s;let r=t[n];if(Se(r)&&!(!((s=this.Zo[n])===null||s===void 0)&&s.persisted)){Ve.forEach(a=>{var l;((l=de(a))===null||l===void 0?void 0:l.storageGroup)===n&&this.ea.delete(a)});continue}let o=this.Ua(H,this.fa(n),r,n);o!=="failed"&&Ve.forEach(a=>{let l=de(a);l?.storageGroup!==n||o!=="written"&&l.volatile||this.ea.delete(a)})}}_a(){let e={},t={flags:{},surveys:{}};return W(this.props,(i,s)=>{var n;let r=(n=de(s))===null||n===void 0?void 0:n.storageGroup;r?t[r][s]=i:e[s]=i}),{main:e,groups:t}}ka(e,t){if(t===le)return JSON.stringify(e)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;let i={};return W(e,(s,n)=>{var r;i[n]=!((r=de(n))===null||r===void 0)&&r.volatile?"__volatile__":s}),JSON.stringify(i)}Ua(e,t,i,s){let n=this.ma(s);if(s!==le&&!n.dirty&&!x(n.fingerprint))return"skipped";let r;try{if(r=this.ka(i,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return e.$t(t,i,this.Wa,this.Va,this.Ga,this.Mr.debug)?(n.dirty=!1,s!==le&&(n.persisted=!0),x(r)||(n.fingerprint=r),this.Jo&&(n.storageValue=H.Ot(t)),"written"):(this.Mr.debug&&S.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ia(),x(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Pt(this.ua,!1),this.No.Pt(this.ua,!0),!e&&this.aa)for(let t of Zt)H.Pt(this.fa(t));e?delete this.Zo[le]:this.Zo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(L(e)){this.syncCookieProperties(),x(t)&&(t="None"),this.Wa=x(i)?this.Qa:i;let s=!1;if(W(e,(n,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==t||(this.xa(r,n),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(L(e)){this.syncCookieProperties(),this.Wa=x(t)?this.Qa:t;let i=!1;if(W(e,(s,n)=>{e.hasOwnProperty(n)&&(this.props[n]!==s||L(s)||I(s))&&(this.xa(n,s),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();let t=typeof e=="string"?[e]:e,i=!1;for(let s of t)s in this.props&&(this.$a(s),i=!0);i&&this.save()}update_campaign_params(){let e=E?.URL;if(e===this.la)return;let t=Bl(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),i=!Se(Kn(t));return i&&this.register(t),this.la=e,i?t:void 0}update_search_keyword(){this.register((function(){let e=E?.referrer;return e?Ul(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:zl(),$referring_domain:E?.referrer&&((e=Je(E.referrer))===null||e===void 0?void 0:e.host)||ss},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let e=Gl(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[It]:this.Ko?{r:Fi(e.r),u:e.u?Fi(e.u):void 0}:e},void 0)}get_initial_props(){let e={};W([ul,cl],i=>{let s=this.props[i];s&&W(s,function(n,r){e["$initial_"+nn(r)]=n})});let t=this.props[It];if(t){let i=(function(s,n=!1){let r=Vl(s,n),o={};return W(r,function(a,l){o[`$initial_${nn(l)}`]=a}),o})(t,this.Mr.disable_capture_url_hashes);Q(e,i)}return e}safe_merge(e){return W(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){let s=e.persistence!==t.persistence,n=!((p,f)=>{if(p.length!==f.length)return!1;let _=[...p].sort(),g=[...f].sort();return _.every((y,m)=>y===g[m])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=s||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this.hi&&!a;a||this.Fa(t,l),this.Mr=e,!a&&(s||n||o)&&(this.Ra=void 0,this.Aa=void 0,this.Fa(v(v({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));let c=r||o?this.ca(e):this.No;this.Za();let u=this.ha(e),h=r||u!==this.Xo,d=!a&&(h||e.cross_subdomain_cookie!==this.Va||e.secure_cookie!==this.Ga)&&this.Oa(l);this.ia=h;try{if(this.Qa=this.Wa=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),h){let p=this.props;this.clear(),this.No=c,this.Xo=u,this.props=p,this.save()}else o&&(this.No=c,a||(delete this.Zo[le],this.Na()))}finally{this.ia=!1,d&&this.qa()}}Za(){let e=this.props[It];if(!this.Ko||!L(e)||typeof e.r!="string")return;let t=Fi(e.r),i=typeof e.u=="string"?Fi(e.u):e.u;t===e.r&&i===e.u||this.xa(It,v(v({},e),{},{r:t,u:i}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Va&&(this.Va=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Ga&&(this.Ga=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){let i=this.props.__timers||{};i[e]=t,this.xa(vn,i),this.save()}remove_event_timer(e){let t=this.props.__timers||{},i=t[e];return x(i)||(delete t[e],this.xa(vn,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this.xa(e,t),this.save()}xa(e,t,i=!0){var s;let n=this.props[e];this.props[e]=t,i&&(e!=="distinct_id"&&e!=="$user_state"||n===t||(this.na=!0),lo(e)&&!tt(n,t)&&this.ra.add(e),this.Ma(e,n,t),!((s=de(e))===null||s===void 0)&&s.volatile||this.Ta(e))}$a(e,t=!0){delete this.props[e],t&&(Cs(e)&&this.ga(e,!0),lo(e)&&this.ra.add(e),this.Ta(e))}Ta(e){var t;let i=(t=de(e))===null||t===void 0?void 0:t.storageGroup;i&&(this.ma(i).dirty=!0)}ma(e){return this.Zo[e]||(this.Zo[e]={})}},Me={GZipJS:"gzip-js",Base64:"base64"},Qt={Activation:"events",Cancellation:"cancelEvents"};var Ls={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"};var Te={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Ds={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Sn={Popover:"popover",Inline:"inline"};function Ns(e){let t=!0;return{dispose(){if(t){t=!1;let i=e();i&&oe(i.then)&&i.then(void 0,()=>{})}}}}var nh={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},uo={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},ho=te("[RateLimiter]"),rh=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{let i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(s=>{ho.info(`${s||"events"} is quota limited.`),this.serverLimits[s]=new Date().getTime()+6e4})}catch(s){return void ho.warn(`could not rate limit - continuing. Error: "${s?.message}"`,{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||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,i,s;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=new Date().getTime(),a=(t=(i=this.instance.persistence)===null||i===void 0?void 0:i.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);let l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){let c=(re(a.dropped)?a.dropped:0)+1;a.dropped=c,!this.lastEventRateLimited&&this.Ja(c)&&(a.dropped=0)}return this.lastEventRateLimited=l,(s=this.instance.persistence)===null||s===void 0||s.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}Ka(e){let t=this.instance.config.property_denylist;return!I(t)||!t.includes(e)}Xa(){var e;if(this.Ka("$current_url")&&this.Ka("$pathname")&&Z?.pathname)return`${(e=Z.origin)!==null&&e!==void 0?e:""}${Z.pathname}`}Ja(e){var t,i;let{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Xa(),o=this.Ka("$session_id")?(t=(i=this.instance).get_session_id)===null||t===void 0?void 0:t.call(i):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 ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){let t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},it=te("[RemoteConfig]"),Yl=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=C._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Ya(e){var t,i,s;!((t=C.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(i=C.__PosthogExtensions__)===null||i===void 0||(s=i.loadExternalDependency)===null||s===void 0||s.call(i,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}tl(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 it.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void it.warn("Remote config is disabled. Falling back to local config.");this.Ya(e=>{if(!e)return it.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(t=>{this.el(t.json,t)});this.el(e)})}catch(e){it.error("Error loading remote config",e),this.el()}}el(e,t){!e&&t&&(t.statusCode===0?t.error||it.warn("Failed to fetch remote config from PostHog."):it.error("Failed to fetch remote config from PostHog."));try{this._instance.el(e?{ok:!0,config:e}:{ok:!1})}catch(s){it.error("Error applying remote config",s)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;(i=this._instance.featureFlags)===null||i===void 0||i.ensureFlagsLoaded()}catch(s){it.error("Error loading feature flags",s)}}};var Oe=Uint8Array,ke=Uint16Array,zt=Uint32Array,tr=new Oe([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]),ir=new Oe([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]),po=new Oe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kl=function(e,t){for(var i=new ke(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var n=new zt(i[30]);for(s=1;30>s;++s)for(var r=i[s];i[s+1]>r;++r)n[r]=r-i[s]<<5|s;return[i,n]},Jl=Kl(tr,2),Pn=Jl[1];Jl[0][28]=258,Pn[258]=28;for(Tn=Kl(ir,0)[1],ns=new ke(32768),ee=0;32768>ee;++ee)ht=(43690&ee)>>>1|(21845&ee)<<1,ns[ee]=((65280&(ht=(61680&(ht=(52428&ht)>>>2|(13107&ht)<<2))>>>4|(3855&ht)<<4))>>>8|(255&ht)<<8)>>>1;var ht,Tn,ns,ee,pi=function(e,t,i){for(var s=e.length,n=0,r=new ke(t);s>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;if(i){o=new ke(1<<t);var l=15-t;for(n=0;s>n;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,d=h|(1<<u)-1;d>=h;++h)o[ns[h]>>>l]=c}else for(o=new ke(s),n=0;s>n;++n)o[n]=ns[a[e[n]-1]++]>>>15-e[n];return o},xt=new Oe(288);for(ee=0;144>ee;++ee)xt[ee]=8;for(ee=144;256>ee;++ee)xt[ee]=9;for(ee=256;280>ee;++ee)xt[ee]=7;for(ee=280;288>ee;++ee)xt[ee]=8;var rs=new Oe(32);for(ee=0;32>ee;++ee)rs[ee]=5;var oh=pi(xt,9,0),ah=pi(rs,5,0),Xl=function(e){return(e/8|0)+(7&e&&1)},Zl=function(e,t,i){(t==null||0>t)&&(t=0),(i==null||i>e.length)&&(i=e.length);var s=new(e instanceof ke?ke:e instanceof zt?zt:Oe)(i-t);return s.set(e.subarray(t,i)),s},qe=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},ei=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},js=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new Oe(0),0];if(n==1){var o=new Oe(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(P,k){return P.f-k.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[h].f>i[c].f?c++:h++],l=i[c!=u&&i[h].f>i[c].f?c++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var d=r[0].s;for(s=1;n>s;++s)r[s].s>d&&(d=r[s].s);var p=new ke(d+1),f=Mn(i[u-1],p,0);if(f>t){s=0;var _=0,g=f-t,y=1<<g;for(r.sort(function(P,k){return p[k.s]-p[P.s]||P.f-k.f});n>s;++s){var m=r[s].s;if(t>=p[m])break;_+=y-(1<<f-p[m]),p[m]=t}for(_>>>=g;_>0;){var w=r[s].s;t>p[w]?_-=1<<t-p[w]++-1:++s}for(;s>=0&&_;--s){var $=r[s].s;p[$]==t&&(--p[$],++_)}f=t}return[new Oe(p),f]},Mn=function(e,t,i){return e.s==-1?Math.max(Mn(e.l,t,i+1),Mn(e.r,t,i+1)):t[e.s]=i},vo=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ke(++t),s=0,n=e[0],r=1,o=function(l){i[s++]=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[i.subarray(0,s),t]},ti=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},Bi=function(e,t,i){var s=i.length,n=Xl(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;s>r;++r)e[n+r+4]=i[r];return 8*(n+4+s)},fo=function(e,t,i,s,n,r,o,a,l,c,u){qe(t,u++,i),++n[256];for(var h=js(n,15),d=h[0],p=h[1],f=js(r,15),_=f[0],g=f[1],y=vo(d),m=y[0],w=y[1],$=vo(_),P=$[0],k=$[1],M=new ke(19),T=0;m.length>T;++T)M[31&m[T]]++;for(T=0;P.length>T;++T)M[31&P[T]]++;for(var O=js(M,7),B=O[0],U=O[1],q=19;q>4&&!B[po[q-1]];--q);var K,F,j,N,Y=c+5<<3,z=ti(n,xt)+ti(r,rs)+o,ie=ti(n,d)+ti(r,_)+o+14+3*q+ti(M,B)+(2*M[16]+3*M[17]+7*M[18]);if(z>=Y&&ie>=Y)return Bi(t,u,e.subarray(l,l+c));if(qe(t,u,1+(z>ie)),u+=2,z>ie){K=pi(d,p,0),F=d,j=pi(_,g,0),N=_;var he=pi(B,U,0);for(qe(t,u,w-257),qe(t,u+5,k-1),qe(t,u+10,q-4),u+=14,T=0;q>T;++T)qe(t,u+3*T,B[po[T]]);u+=3*q;for(var ce=[m,P],fe=0;2>fe;++fe){var Pe=ce[fe];for(T=0;Pe.length>T;++T)qe(t,u,he[ue=31&Pe[T]]),u+=B[ue],ue>15&&(qe(t,u,Pe[T]>>>5&127),u+=Pe[T]>>>12)}}else K=oh,F=xt,j=ah,N=rs;for(T=0;a>T;++T)if(s[T]>255){var ue;ei(t,u,K[257+(ue=s[T]>>>18&31)]),u+=F[ue+257],ue>7&&(qe(t,u,s[T]>>>23&31),u+=tr[ue]);var Fe=31&s[T];ei(t,u,j[Fe]),u+=N[Fe],Fe>3&&(ei(t,u,s[T]>>>5&8191),u+=ir[Fe])}else ei(t,u,K[s[T]]),u+=F[s[T]];return ei(t,u,K[256]),u+F[256]},lh=new zt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ch=new Oe(0),uh=(function(){for(var e=new zt(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e})(),Bs=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function dh(e,t){t===void 0&&(t={});var i=(function(){var d=4294967295;return{p(p){for(var f=d,_=0;p.length>_;++_)f=uh[255&f^p[_]]^f>>>8;d=f},d(){return 4294967295^d}}})(),s=e.length;i.p(e);var n,r,o,a,l,c,u=(a=10+((n=t).filename&&n.filename.length+1||0),l=8,(function(d,p,f,_,g,y){var m=d.length,w=new Oe(_+m+5*(1+Math.floor(m/7e3))+g),$=w.subarray(_,w.length-g),P=0;if(!p||8>m)for(var k=0;m>=k;k+=65535){var M=k+65535;m>M?P=Bi($,P,d.subarray(k,M)):($[k]=y,P=Bi($,P,d.subarray(k,m)))}else{for(var T=lh[p-1],O=T>>>13,B=8191&T,U=(1<<f)-1,q=new ke(32768),K=new ke(U+1),F=Math.ceil(f/3),j=2*F,N=function(vs){return(d[vs]^d[vs+1]<<F^d[vs+2]<<j)&U},Y=new zt(25e3),z=new ke(288),ie=new ke(32),he=0,ce=0,fe=(k=0,0),Pe=0,ue=0;m>k;++k){var Fe=N(k),Xe=32767&k,Ze=K[Fe];if(q[Xe]=Ze,K[Fe]=Xe,k>=Pe){var ut=m-k;if((he>7e3||fe>24576)&&ut>423){P=fo(d,$,0,Y,z,ie,ce,fe,ue,k-ue,P),fe=he=ce=0,ue=k;for(var Ee=0;286>Ee;++Ee)z[Ee]=0;for(Ee=0;30>Ee;++Ee)ie[Ee]=0}var Ne=2,Si=0,Sc=B,Qe=Xe-Ze&32767;if(ut>2&&Fe==N(k-Qe))for(var Pc=Math.min(O,ut)-1,Tc=Math.min(32767,k),Mc=Math.min(258,ut);Tc>=Qe&&--Sc&&Xe!=Ze;){if(d[k+Ne]==d[k+Ne-Qe]){for(var et=0;Mc>et&&d[k+et]==d[k+et-Qe];++et);if(et>Ne){if(Ne=et,Si=Qe,et>Pc)break;var Oc=Math.min(Qe,et-2),rr=0;for(Ee=0;Oc>Ee;++Ee){var ps=k-Qe+Ee+32768&32767,or=ps-q[ps]+32768&32767;or>rr&&(rr=or,Ze=ps)}}}Qe+=(Xe=Ze)-(Ze=q[Xe])+32768&32767}if(Si){Y[fe++]=268435456|Pn[Ne]<<18|Tn[Si];var ar=31&Pn[Ne],lr=31&Tn[Si];ce+=tr[ar]+ir[lr],++z[257+ar],++ie[lr],Pe=k+Ne,++he}else Y[fe++]=d[k],++z[d[k]]}}P=fo(d,$,y,Y,z,ie,ce,fe,ue,k-ue,P),y||(P=Bi($,P,ch))}return Zl(w,0,_+Xl(P)+g)})(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,!c)),h=u.length;return(function(d,p){var f=p.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>p.level?4:p.level==9?2:0,d[9]=3,p.mtime!=0&&Bs(d,4,Math.floor(new Date(p.mtime||Date.now())/1e3)),f){d[3]=8;for(var _=0;f.length>=_;++_)d[_+10]=f.charCodeAt(_)}})(u,t),Bs(u,h-8,i.d()),Bs(u,h-4,s),u}var hh=!!Cn||!!_i,Ql=new WeakMap,ec="text/plain",Hs=0,Hi=!1,tc=(e,t)=>{let[i,s]=e.split("#"),[n,r]=i.split("?");if(!r)return e;let o=r.split("&").filter(a=>a.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},$i=(e,t,i=!0)=>{var s;let[n,r]=e.split("?"),o=v({},t),a=(s=r?.split("&").map(c=>{var u;let[h,d]=c.split("="),p=i&&(u=o[h])!==null&&u!==void 0?u:d;return delete o[h],`${h}=${p}`}))!==null&&s!==void 0?s:[],l=(function(c,u="&"){let h,d,p=[];return W(c,function(f,_){x(f)||x(_)||_==="undefined"||(h=encodeURIComponent((g=>g instanceof File)(f)?f.name:f.toString()),d=encodeURIComponent(_),p[p.length]=d+"="+h)}),p.join(u)})(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},Us=e=>{if(e.nl)return e.nl;let{data:t,compression:i}=e;if(!t)return;if(i===Me.GZipJS){let n=dh((function(r){var o=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new Oe(r.length+(r.length>>>1)),l=0,c=function(p){a[l++]=p},u=0;o>u;++u){if(l+5>a.length){var h=new Oe(l+8+(o-u<<1));h.set(a),a=h}var d=r.charCodeAt(u);128>d?c(d):2048>d?(c(192|d>>>6),c(128|63&d)):d>55295&&57344>d?(c(240|(d=65536+(1047552&d)|1023&r.charCodeAt(++u))>>>18),c(128|d>>>12&63),c(128|d>>>6&63),c(128|63&d)):(c(224|d>>>12),c(128|d>>>6&63),c(128|63&d))}return Zl(a,0,l)})(Ct(t)),{mtime:0});return{contentType:ec,body:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),estimatedSize:n.byteLength}}if(i===Me.Base64){let n=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Ct(t)),r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Ct(o)))(n);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}let s=Ct(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},ic=e=>{let t=()=>e.transport==="sendBeacon"?{url:$i(e.url,{compression:Me.Base64}),encodedBody:Us(v(v({},e),{},{compression:Me.Base64,nl:void 0}))}:{url:tc(e.url,"compression"),encodedBody:Us(v(v({},e),{},{compression:void 0,nl:void 0}))},i;try{i=Us(e)}catch(n){if(Ir(e.compression,Ut(e.url,"compression")))return S.error("Failed to gzip request body, sending uncompressed payload",n),t();throw n}return i&&Ir(e.compression,Ut(e.url,"compression"))&&!((s=i.body)instanceof ArrayBuffer?un(new Uint8Array(s)):ArrayBuffer.isView(s)&&un(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(Hi=!0,t()):{url:e.url,encodedBody:i};var s},sc=e=>{try{return ic(e)}catch(i){var t;return S.error(i),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:i}))}},ph=(function(){var e=X(function*(t){let i=yield(function(n){return dn.apply(this,arguments)})(Ct(t.data),$e.DEBUG,{rethrow:!0});if(!i)return t;let s=yield i.arrayBuffer();return v(v({},t),{},{nl:{contentType:ec,body:s,estimatedSize:s.byteLength}})});return function(t){return e.apply(this,arguments)}})(),vh=/Failed to fetch|NetworkError|Load failed/i,nc=e=>e?.name==="TypeError"&&vh.test(e?.message||""),rc=e=>{try{let t=(function(i,s=Date.now()){if(typeof i!="string"||!i)return;let n=i.trim(),r=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(",")).trim():n;if(/^\d+$/.test(r)){let l=1e3*Math.min(Number(r),300);return l>0?l:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;let o=/^\w{3} \w{3} /.test(r)?r+" GMT":r,a=Date.parse(o)-s;return Number.isFinite(a)&&a>0?Math.min(a,Di):void 0})(e());return x(t)?void 0:Math.min(t,3e4)}catch{return}},oc=e=>{let t=sc(e);if(!t)return;let i=new Cn;Ql.set(i,!0);let{url:s,encodedBody:n}=t;i.open(e.method||"GET",s,!0);let{contentType:r,body:o}=n??{};W(e.headers,function(a,l){i.setRequestHeader(l,a)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(i.readyState===4){var a;let l={statusCode:i.status,text:i.responseText};if(i.status===200)try{l.json=JSON.parse(i.responseText)}catch{}(a=e.callback)===null||a===void 0||a.call(e,l,rc(()=>i.getResponseHeader("Retry-After")))}},i.send(o)},ac=e=>{let t=sc(e);if(!t)return;let{url:i,encodedBody:s}=t,{contentType:n,body:r,estimatedSize:o}=s??{},a=new Headers;W(e.headers,function(f,_){a.append(_,f)}),n&&a.append("Content-Type",n);let l=null,c=!1;if(vr){let f=new vr;l={signal:f.signal,timeout:setTimeout(()=>{c=!0;try{f.abort(Fa("AbortError","PostHog request timed out"+((_=e.timeout)?` after ${_}ms`:"")))}catch(g){h(g)}var _},e.timeout)}}let u=!1,h=f=>{var _;u||(u=!0,c&&f?.name==="AbortError"||nc(f)?S.warn(f):S.error(f),(_=e.callback)===null||_===void 0||_.call(e,{statusCode:0,error:f}))},d=0,p=()=>{Hs-=d,d=0,l&&clearTimeout(l.timeout)};try{let f=v({method:e?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:l?.signal},e.fetchOptions),_=o??(x(r)?0:void 0);f.keepalive=f.method==="POST"&&!e.sl&&f.keepalive!==!1&&f.body===r&&!x(_)&&_>=0&&52428.8>Hs+_,f.keepalive&&(d=_,Hs+=d),_i(i,f).then(g=>g.text().then(y=>{var m;if(u)return;let w={statusCode:g.status,text:y};if(g.status===200)try{w.json=JSON.parse(y)}catch($){S.error($)}u=!0,p(),(m=e.callback)===null||m===void 0||m.call(e,w,rc(()=>g.headers.get("Retry-After")))})).catch(g=>{p(),h(g)}).finally(p)}catch(f){p(),h(f)}},On=e=>{try{var t;let{url:i,encodedBody:s}=ic(e),{contentType:n,body:r,estimatedSize:o}=s??{};if(!r)return;let a=r instanceof Blob?r:new Blob([r],{type:n});if(pe.sendBeacon(i,a))return;let l=I(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(I(l)&&l.length>1&&(o??0)>16384){let c=Math.ceil(l.length/2),u=h=>I(e.data)?h:v(v({},e.data),{},{batch:h});return On(v(v({},e),{},{data:u(l.slice(0,c))})),void On(v(v({},e),{},{data:u(l.slice(c))}))}S.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${_i?"fetch":"XHR"}`),_i?ac(v(v({},e),{},{sl:!0})):oc(e)}catch(i){S.warn("Beacon send failed",i)}},go=(e,t,i,s)=>{let n=s==="query"?t==="POST"?"sent_at":"_":void 0;return $i(i===Me.GZipJS?tc(e,"compression"):e,v(v({},n?{[n]:Date.now().toString()}:{}),i===Me.GZipJS?{}:{compression:i}))},fh=(()=>{let e=[];return _i&&e.push({transport:"fetch",method:ac}),Cn&&e.push({transport:"XHR",method:oc}),pe?.sendBeacon&&e.push({transport:"sendBeacon",method:On}),e})(),lc=!hh&&be?.indexOf("MSIE")===-1&&be?.indexOf("Mozilla")===-1;function cc(e,t,i){var s,n,r;i&&(t=v(v({},t),{},{callback:o=>i(o)})),e.__loaded?lc?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((n=t.callback)===null||n===void 0||n.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=v(v({},e.config.request_headers),t.headers),t.compression=t.compression==="best-available"?(s=e.compression)!==null&&s!==void 0?s:t.compressionFallback:t.compression,(x(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((o,a)=>{var l,c,u;let h=v(v({},o),{},{callback:a??(g=>{var y;return(y=o.callback)===null||y===void 0?void 0:y.call(o,g)})});h.timeout=h.timeout||6e4;let d=(l=h.transport)!==null&&l!==void 0?l:"fetch";d==="sendBeacon"&&x(h.compression)&&h.data&&(h.compression=Me.Base64),h.method==="POST"&&h.data&&(h.timestampMode==="capture-body"?h.data=(g=>{var y,m;let w=(I(g)?g:[g]).map(P=>v(v({},P),P.timestamp instanceof Date&&!isNaN(P.timestamp.getTime())?{timestamp:P.timestamp.toISOString()}:{})),$=w[0];return{api_key:(y=$==null||(m=$.properties)===null||m===void 0?void 0:m.token)!==null&&y!==void 0?y:$?.token,batch:w,sent_at:new Date().toISOString()}})(h.data):h.timestampMode==="body"&&(h.data=((g,y=new Date().toISOString())=>I(g)?g.map(m=>v(v({},m),{},{sent_at:y})):v(v({},g),{},{sent_at:y}))(h.data))),h.url=go(h.url,h.method,h.compression,h.timestampMode);let p=fh.filter(g=>!h.disableTransport||!g.transport||!h.disableTransport.includes(g.transport)),f=(c=(u=(function(g,y){for(let m=0;g.length>m;m++)if(y(g[m]))return g[m]})(p,g=>g.transport===d))===null||u===void 0?void 0:u.method)!==null&&c!==void 0?c:p[0].method;if(!f)throw new Error("No available transport method");let _=g=>{try{f(g)}catch(m){var y;nc(m)?S.warn(m):S.error(m),(y=h.callback)===null||y===void 0||y.call(h,{statusCode:0,error:m})}};d!=="sendBeacon"&&!h.preferSyncCompression&&h.data&&h.compression===Me.GZipJS&&Fc&&typeof Promise<"u"&&!Hi?ph(h).then(g=>{_(g)}).catch(g=>{if(Ar(g))return Hi=!0,void _(v(v({},h),{},{compression:void 0,url:go(o.url,o.method,void 0,o.timestampMode)}));(y=>{if(!y||typeof y!="object")return!1;let m="name"in y?String(y.name):"";return Ar(y)||m===Na})(g)&&(Hi=!0),_(h)}):_(h)})(t,(o,a)=>{var l,c,u;e.rateLimiter.checkForLimiting(o),400>o.statusCode||(l=(c=e.config).on_request_error)===null||l===void 0||l.call(c,o),i?i(o,a):(u=t.callback)===null||u===void 0||u.call(t,o)})):t.fireCallbackOnDrop&&((r=t.callback)===null||r===void 0||r.call(t,{statusCode:0}))}var gh=class{constructor(e,t){this.rl=!0,this.ol=[],this.al=Ue(t?.flush_interval_ms||3e3,250,5e3,S.createLogger("flush interval"),3e3),this.ll=e}enqueue(e){this.ol.push(e),this.ul||this.cl()}unload(){this.hl();let e=this.ol.length>0?this.dl():{},t=Object.values(e);[...t.filter(i=>i.url.indexOf("/e")===0),...t.filter(i=>i.url.indexOf("/e")!==0)].map(i=>{this.vl(v(v({},i),{},{callback:void 0}),"sendBeacon")})}enable(){this.rl=!1,this.cl()}cl(){this.rl||(this.ul=setTimeout(()=>{this.hl(),this.fl()},this.al))}fl(){if(this.ol.length>0){let e=this.dl();for(let t in e)this.vl(e[t])}}vl(e,t){try{this.ll(e,t)}catch(i){S.error(i)}}hl(){clearTimeout(this.ul),this.ul=void 0}dl(){let e={},t={};W(this.ol,i=>{var s;let n=i,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");x(e[r])&&(e[r]=v(v({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[r]=[]),(s=e[r].data)===null||s===void 0||s.push(n.data),n.callback&&t[r].push(n.callback)});for(let i in t){let s=t[i];s.length&&(e[i].callback=n=>{for(let r of s)r(n)})}return this.ol=[],e}},_h=["retriesPerformedSoFar"],mh=class{constructor(e){this._instance=e,this.pl=!1,this.gl=3e3,this.ol=[],this.ol=[],this.ml=!0,this.resume()}resume(){if(!x(b)&&"onLine"in b.navigator){if(this.ml=b.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.fl()},this.bl=()=>{this.ml=!1},G(b,"online",this.yl),G(b,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,s=ja(e,_h);Ge(i)&&(s.url=$i(s.url,{retry_count:i})),cc(this._instance,t?v(v({},s),{},{transport:t}):s,(n,r)=>{var o;if(n.statusCode!==200&&(400>n.statusCode||n.statusCode>=500)){if((n.statusCode===0?3:10)>(i??0))return void this.Ls(v({retriesPerformedSoFar:i},s),r);n.statusCode===0&&S.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${i??0} retries.`)}(o=s.callback)===null||o===void 0||o.call(s,n)})}Ls(e,t){let i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;let s=Math.max((function(o){let a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(i),t??0),n=Date.now()+s;this.ol.push({retryAt:n,requestOptions:e});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),S.warn(r),this.pl||(this.pl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.pl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.ml&&this.ol.length>0&&this.fl(),this._l()},this.gl)}fl(){let e=Date.now(),t=[],i=this.ol.filter(s=>e>s.retryAt||(t.push(s),!1));if(this.ol=t,i.length>0)for(let{requestOptions:s}of i)this.retriableRequest(s)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.pl=!1,x(b)||(this.yl&&(b.removeEventListener("online",this.yl),this.yl=void 0),this.bl&&(b.removeEventListener("offline",this.bl),this.bl=void 0));for(let{requestOptions:e}of this.ol)try{this._instance._send_request(v(v({},e),{},{callback:I(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(t){S.error(t)}this.ol=[]}},yh=class{constructor(e){this._instance=e,this.kl=()=>{var t,i,s,n;this.Sl||(this.Sl={});let r=this.scrollElement(),o=this.scrollY(),a=r?Math.max(0,r.scrollHeight-r.clientHeight):0,l=o+(r?.clientHeight||0),c=r?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(o),this.Sl.maxScrollY=Math.max(o,(t=this.Sl.maxScrollY)!==null&&t!==void 0?t:0),this.Sl.maxScrollHeight=Math.max(a,(i=this.Sl.maxScrollHeight)!==null&&i!==void 0?i:0),this.Sl.lastContentY=l,this.Sl.maxContentY=Math.max(l,(s=this.Sl.maxContentY)!==null&&s!==void 0?s:0),this.Sl.maxContentHeight=Math.max(c,(n=this.Sl.maxContentHeight)!==null&&n!==void 0?n:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){let e=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),e}startMeasuringScrollPosition(){G(b,"scroll",this.kl,{capture:!0}),G(b,"scrollend",this.kl,{capture:!0}),G(b,"resize",this.kl)}scrollElement(){if(this.xl){let i=I(this.xl)?this.xl:[this.xl];for(let s of i){var e;let n=b==null||(e=b.document)===null||e===void 0?void 0:e.querySelector(s);if(n)return n}return}var t;return b==null||(t=b.document)===null||t===void 0?void 0:t.documentElement}$l(e){var t,i;let s=e==="y"?"scrollTop":"scrollLeft";if(this.xl){let n=this.scrollElement();return n&&n[s]||0}return b?e==="y"?b.scrollY||b.pageYOffset||((t=b.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:b.scrollX||b.pageXOffset||((i=b.document)===null||i===void 0||(i=i.documentElement)===null||i===void 0?void 0:i.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}},bh=e=>Gl(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),_o=class{constructor(e,t,i,s){this.qe=n=>{let r=this.Cl();if(r&&r.sessionId===n)return;let o={sessionId:n,props:this.Tl(this._instance)};this.Il.register({[bn]:o})},this._instance=e,this.Ml=t,this.Il=i,this.Tl=s||bh,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[bn]}getSetOnceProps(){var e;let t=(e=this.Cl())===null||e===void 0?void 0:e.props;return t?"r"in t?Vl(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(){let e={};return W(Kn(this.getSetOnceProps()),(t,i)=>{i==="$current_url"&&(i="url"),e[`$session_entry_${nn(i)}`]=t}),e}},os=class{on(e,t){return this.El[e]||(this.El[e]=[]),this.El[e].push(t),()=>{this.El[e]=this.El[e].filter(i=>i!==t)}}emit(e,t){for(let i of this.El[e]||[])i(t);for(let i of this.El["*"]||[])i(e,t)}constructor(){this.El={}}},Pt=te("[SessionId]"),mo=864e5,yo=class{on(e,t){return this.Pl.on(e,t)}constructor(e,t,i){var s;if(this.Rl=null,this.Al=null,this.Fl=[],this.Ol=void 0,this.Dl=!1,this.Pl=new os,this.Ll=(r,o)=>!(!Ge(r)||!Ge(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.Mr=e.config,this.Il=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=t||Le,this.jl=i||Le;let n=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Ue(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Pt.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.zl="ph_"+n+"_window_id",this.Hl="ph_"+n+"_primary_window_exists",this.Ul()){let r=J.Dt(this.zl),o=J.Dt(this.Hl);r&&!o?this.je=r:J.Pt(this.zl),J.$t(this.Hl,!0)}!((s=this.Mr.bootstrap)===null||s===void 0)&&s.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return x(this.Fl)&&(this.Fl=[]),this.Fl.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.Fl=this.Fl.filter(t=>t!==e)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&J.At()}Vl(e){e!==this.je&&(this.je=e,this.Ul()&&J.$t(this.zl,e))}Gl(){return this.je?this.je:this.Ul()?J.Dt(this.zl):null}Ql(e){let t=this.Rl;return!ne(t)&&!ne(e)&&5e3>Math.abs(e-t)}Zl(e,t,i){let s=t!==this._sessionActivityTimestamp,n=!(e!==this.Xt||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.Xt=e,n&&!s||n&&this.Ql(t)||(this.Rl=t,this.Il.register({[Ft]:[t,e,i]}))}Jl(){var e;let t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return Ge(t)&&t>0}Kl(){this.Jl()?this.Il.refreshKey(Ft):(this.Il.flush(),this.Il.load())}Xl(){var e;if(ne(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();let[,t,i]=this.Yl();t===this.Xt&&i===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[Ft]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){let[e]=this.Yl(),t=Ge(e)?e:0,i=Ge(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}eu(e){return this.Kl(),this.Ll(e,this.tu())}Yl(){let e=this.Il.props[Ft];return I(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(e,t=!1){let i=((s,n=new Date().getTime())=>{try{let r=(o=>{let a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(s);return r>n+6e4?void Pt.error("Bootstrap sessionID cannot be in the future"):r}catch(r){return void Pt.error("Invalid sessionID in bootstrap",r)}})(e);return!x(i)&&(t?this.Nl={sessionId:e,sessionStartTimestamp:i}:this.Zl(e,new Date().getTime(),i),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Ol&&b&&(b.removeEventListener(es,this.Ol,{capture:!1}),this.Ol=void 0),this.Fl=[]}Wl(){this.Ol=()=>{this.Xl(),this.Ul()&&J.Pt(this.Hl)},G(b,es,this.Ol,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');let s=t||new Date().getTime(),n=this.Xt;if(i)this.Al=s;else if(ne(this.Al)||this.Al>s||s-this.Al>=1e3){var r,o;(r=(o=this.Il).syncCookieProperties)===null||r===void 0||r.call(o),this.Al=s}let[,a,l]=this.Yl(),c=!x(n)&&a!==n,u=this.tu(),h=this.Gl(),d=this.Nl,p=!!d&&(d.sessionStartTimestamp>s+6e4||s-d.sessionStartTimestamp>mo),f=d?p:Ge(l)&&Math.abs(s-l)>mo,_=!1,g=c,y=!a||!!d,m=a,w=!y&&!e&&this.Ll(s,u);if(w&&(w=this.eu(s),w||Pt.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Yl(),w||(y=!a||!!d)),y||w||f){g=!1;let M=d&&!p;a=M?d.sessionId:this.ql(),h=this.jl(),Pt.info("new session ID assigned",{sessionId:a,windowId:h,bootstrapped:!!M,changeReason:{noSessionId:y,activityTimeout:w,sessionPastMaximumLength:f}}),l=M?d.sessionStartTimestamp:s,this.Nl=void 0,_=!0}else h||(h=this.jl(),_=!0),g=g||a!==m,g&&(Pt.info("adopted cross-tab session id",{sessionId:a,windowId:h}),_=!0);let $=Ge(u)&&e&&!f?u:s,P=Ge(l)?l:new Date().getTime();this.Vl(h),this.Zl(a,$,P),e||this.Bl();let k={noSessionId:y,activityTimeout:w,sessionPastMaximumLength:f,crossTabAdoption:g};return _&&this.Fl.forEach(M=>M(a,h,k)),{sessionId:a,windowId:h,sessionStartTimestamp:P,changeReason:_?k:void 0,lastActivityTimestamp:u}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){let e=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:e})}else this.Bl()},1.1*this.sessionTimeoutMs))}},uc=function(e,t){if(!e)return!1;let i=e.userAgent;if(i&&_r(i,t))return!0;try{let s=e?.userAgentData;if(s?.brands&&s.brands.some(n=>_r(n?.brand,t)))return!0}catch{}return!!e.webdriver};function dc(){return(dc=X(function*(){let e=pe?.userAgentData;if(e?.getHighEntropyValues)try{let t=yield e.getHighEntropyValues(["model"]),i=t?.model;return D(i)&&i.length>0?i:void 0}catch(t){return void S.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function wh(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function hc(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)}var as=(e,t)=>{if(!(i=>{try{new RegExp(i)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Ii=e=>e.toLowerCase(),pc={exact:(e,t)=>t.some(i=>e.some(s=>i===s)),is_not:(e,t)=>t.every(i=>e.every(s=>i!==s)),regex:(e,t)=>t.some(i=>e.some(s=>as(i,s))),not_regex:(e,t)=>t.every(i=>e.every(s=>!as(i,s))),icontains:(e,t)=>t.map(Ii).some(i=>e.map(Ii).some(s=>i.includes(s))),not_icontains:(e,t)=>t.map(Ii).every(i=>e.map(Ii).every(s=>!i.includes(s))),gt:(e,t)=>t.some(i=>{let s=parseFloat(i);return!isNaN(s)&&e.some(n=>s>parseFloat(n))}),lt:(e,t)=>t.some(i=>{let s=parseFloat(i);return!isNaN(s)&&e.some(n=>s<parseFloat(n))})};function vc(e,t){return!e||Object.entries(e).every(([i,s])=>{let n=t?.[i];if(n==null)return!1;let r=pc[s.operator];return!!r&&r(s.values.map(String),[String(n)])})}function qs(e,t,i){return Ct({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Fn="custom",bo="i.posthog.com",xh=/^\/static\//,kh=["/s/","/e/","/i/"],Eh=class{constructor(e){this.nu={},this.instance=e}get apiHost(){let e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){let e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${bo}`,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.nu[this.apiHost]||(this.nu[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":Fn),this.nu[this.apiHost]}su(e){if(!xh.test(e))return;let t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}ru(e){let t=Je(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}ou(e,t,i){if(e==="ui")return i;let s=i,n=this.instance.config.rewriteRequestPath;if(n){var r;let o=((r=Je(i))===null||r===void 0?void 0:r.href)||i;s=n(new URL(o)).toString()}if(n&&e==="api"&&kh.some(o=>t.indexOf(o)===0)){let o=this.ru(s);if(o){let a=this.apiHost,l=this.au;l?.apiHost===a&&l.rewriteRequestPath===n||(l={apiHost:a,rewriteRequestPath:n,urls:new Set},this.au=l),l.urls.add(o)}}return s}isIngestionEndpoint(e){let t=this.au,i=this.ru(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t=""){if(t&&(t=t[0]==="/"?t:`/${t}`),e==="ui")return this.ou(e,t,this.uiHost+t);if(e==="flags")return this.ou(e,t,this.flagsApiHost+t);if(e==="assets"){let s=this.su(t);if(s)return this.ou(e,t,`${s}${t}`)}if(this.region===Fn)return this.ou(e,t,this.apiHost+t);let i=bo+t;switch(e){case"assets":return this.ou(e,t,`https://${this.region}-assets.${i}`);case"api":return this.ou(e,t,`https://${this.region}.${i}`)}}},V=te("[Surveys]"),fc=e=>{try{let t=(i=>((s,n)=>`seenSurvey_${(function(r){return r.current_iteration&&r.current_iteration>0?`${r.id}_${r.current_iteration}`:r.id})(n)}`)(0,i))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(t){V.error("Failed to persist survey seen state",t)}},$h=[Ls.Popover,Ls.Widget,Ls.API],Sh={ignoreConditions:!1,ignoreDelay:!1,displayType:Sn.Popover},Ph=te("[PostHog ExternalIntegrations]"),Th={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Mh=class{constructor(e){this._instance=e}zo(e,t){var i,s;(i=C.__PosthogExtensions__)===null||i===void 0||(s=i.loadExternalDependency)===null||s===void 0||s.call(i,this._instance,e,n=>{if(n)return Ph.error("failed to load script",n);t()})}startIfEnabledOrStop(){var e;for(let[n,r]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var t,i,s;r&&!(!((t=C.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[n])&&this.zo(Th[n],()=>{var o;(o=C.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[n])===null||o===void 0||o.start(this._instance)}),!r&&(!((i=C.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0)&&i[n])&&((s=C.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0||(s=s[n])===null||s===void 0||s.stop())}}},gc="autocapture",_c="featureFlags",mc="logs",yc="surveys",Oh=class{constructor(e){this._instance=e}initialize(){}get(e){let t=this._instance.persistence;if(typeof e=="string")return t?.get_property(e);let i={};for(let s of e){let n=t?.get_property(s);x(n)||(i[s]=n)}return i}set(e,t){var i;(i=this._instance.persistence)===null||i===void 0||i.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)===null||t===void 0||t.unregister(e)}},Fh=class{constructor(e){this.instance=e,this.A=S,this.kv=new Oh(e),this.onEvent=t=>Ns(this.instance._addCaptureHook((i,s)=>{if(s)try{t({event:i,properties:s.properties})}catch(n){this.A.error("Browser extension event listener failed",n)}})),this.onRemoteConfig=t=>{let i=n=>{try{t(n)}catch(r){this.A.error("Browser extension remote config listener failed",r)}},s=this.instance.lu.on("extensionsRemoteConfig",i);return this.instance.uu&&i(this.instance.uu),Ns(s)}}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){let e=this.instance.get_property(Hn);return typeof e=="string"?e:void 0}get library(){return{name:$e.LIB_NAME,version:$e.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,i,s,n;let r=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=r?.sessionId)!==null&&t!==void 0?t:"",windowId:(i=r?.windowId)!==null&&i!==void 0?i:"",sessionStartTimestamp:(s=r?.sessionStartTimestamp)!==null&&s!==void 0?s:0,lastActivityTimestamp:(n=r?.lastActivityTimestamp)!==null&&n!==void 0?n:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return oe(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case _c:case"featureFlagsCommon":t=this.instance.featureFlags;break;case mc:t=this.instance.logs;break;case yc:t=this.instance.surveys;break;case gc:t=this.instance.autocapture}return t}capture(e,t,i){i?this.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):this.instance.capture(e,t)}registerDynamicEventProperties(e){return Ns(this.instance.cu(e))}sendRequest(e){var t=this;return X(function*(i,s={}){var n;let r=(n=s.target)!==null&&n!==void 0?n:"api",o=t.instance.requestRouter.endpointFor(r,i),a=r==="api"&&i==="/i/v1/logs",l={method:s.method,url:s.query?$i(o,s.query):o,data:s.body,headers:s.headers,timeout:s.timeoutMs,fireCallbackOnDrop:!0,transport:s.transport,compression:s.compression,compressionFallback:s.target==="flags"&&s.compression==="best-available"?sn.Base64:void 0,timestampMode:s.sentAt};return a&&(l.batchKey="logs"),s.transport==="sendBeacon"?(t.instance._send_request(l),{statusCode:202}):new Promise(c=>{l.callback=c,t.instance._send_request(l)})}).apply(this,arguments)}},vi={},zs=0,fi=()=>{},wo='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Tt="Surveys module not available",xo="sanitize_properties is deprecated. Use before_send instead",bc="Invalid value for property_denylist config: ",Ih=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],Ah=["$feature_flag_called","$$heatmap","$snapshot"],ko=e=>e.charAt(0)==="$"&&!A(Ah,e),Ch=/^[A-Za-z0-9_-]{1,400}$/,Eo=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,$o=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Rh=["token","distinct_id",dl],ri="posthog",Lh=e=>{let t={};return e&&e!=="unset"&&("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0)),t},Gs=e=>{var t;return v({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Fd(E?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fi,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_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Z&&D(Z?.search)&&Z.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:(b==null||(t=b.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,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(i){S.error("Bad HTTP status: "+i.statusCode+" "+i.text)},get_device_id:i=>i,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:wl,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:fi},(i=>({rageclick:i&&i>="2026-05-30"?{content_ignorelist:Qn,ignore_text_selection:!0}:!i||"2025-11-30">i||{content_ignorelist:!0},capture_pageview:!i||"2025-05-24">i||"history_change",session_recording:Lh(i),external_scripts_inject_target:i&&i>="2026-01-30"?"head":"body",internal_or_test_user_hostname:i&&i>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:i&&i>="2026-05-30"?250:0,split_storage:!(!i||"2026-05-30">i),detect_google_search_app:!(!i||"2026-05-30">i),disable_capture_url_hashes:!(!i||"2026-06-25">i),cookieWinsOnConflict:!(!i||i==="unset"||"2026-08-29">i)}))(e))},Dh=[["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"]],So=e=>{let t={};for(let[n,r]of Dh)x(e[n])||(t[r]=e[n]);let i=Q({},t,e),s=e.__preview_external_dependency_versioned_paths;return x(s)||(x(e.strict_script_versioning)&&(i.strict_script_versioning=!!s),D(s)&&x(e.asset_host)&&(i.asset_host=s)),I(e.property_blacklist)&&(x(e.property_denylist)?i.property_denylist=e.property_blacklist:I(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:S.error(bc+e.property_denylist)),i},Nh=class{constructor(){this.__forceAllowLocalhost=!1}get hu(){return this.__forceAllowLocalhost}set hu(e){S.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},gi=class st{du(t){if(!t)return;let i=this.vu.indexOf(t);i!==-1&&this.vu.splice(i,1)}fu(t,i){var s;return this.du(t),this.vu.push(i),(s=i.initialize)===null||s===void 0||s.call(i),i}pu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}gu(){if(this.mu||this.config.reuseAnonymousId||this.config.segment||this.pu())return;let t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this.yu)return;let i,s,n;t?(i=`persistence is set to '${this.config.persistence}'`,s=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."):(i="persistence is disabled (disable_persistence is true)",s="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.mu=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${s}, 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}`)}bu(){let t=this.persistence;if(!t||this._u)return;if(this.pu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.wu(),this.ku()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.Su()||t.load(!0);let i=this.get_distinct_id();if(!i||i==="$posthog_cookieless"){let s=this.config.get_device_id(Le());this.register({distinct_id:s,$device_id:s}),t.set_property(we,Ye)}this.wu()}get decideEndpointWasHit(){var t,i;return(t=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,i;return(t=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.xu=!1,this.$u=!1,this.webPerformance=new Nh,this.Cu=!1,this.version=$e.LIB_VERSION,this.Tu=new Set,this.Iu="",this.lu=new os,this.vu=[],this.Mu=[],this.Eu=!1,this.yu=!1,this.mu=!1,this._u=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Gs(),this.SentryIntegration=Kd,this.sentryIntegration=s=>(function(n,r){let o=Rl(n,r);return{name:Cl,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Pu=!1,this.Ru=null,this.Au=null,this.Fu=null,this.scrollManager=new yh(this),this.pageViewManager=new ao(this),this.rateLimiter=new rh(this),this.requestRouter=new Eh(this),this.consent=new Nd(this),this.externalIntegrations=new Mh(this);let i=(t=st.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(s,n,r)=>{let o=D(s)?{[s]:n}:s;this.setPersonProperties(o),r?.({})},set_once:(s,n,r)=>{let o=D(s)?{[s]:n}:s;this.setPersonProperties(void 0,o),r?.({})}},this.on("eventCaptured",s=>S.info(`send "${s?.event}"`,s))}init(t,i,s){if(s&&s!==ri){var n;let r=(n=vi[s])!==null&&n!==void 0?n:new st;return r._init(t,i,s),vi[s]=r,vi[ri][s]=r,r}return this._init(t,i,s)}_init(t,i={},s){var n,r,o;let a=D(t)?t.trim():"";if(!a)return S.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=Gs(i.defaults),i.debug=this.Ou(i.debug),this.Du=i,this.Lu=[],i.person_profiles?this.Au=i.person_profiles:i.process_person&&(this.Au=i.process_person);let c=Gs(i.defaults),u=So(i),h=Q({},c,u,{name:s,token:a});L(c.rageclick)&&L(u.rageclick)&&(h.rageclick=Q({},c.rageclick,u.rageclick)),L(c.session_recording)&&L(u.session_recording)&&(h.session_recording=Q({},c.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&S.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Me.GZipJS;let d=this.Su(),p=!this.pu();if(this.persistence=new Rs(this.config,d,!0,p),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Rs(v(v({},this.config),{},{persistence:"sessionStorage"}),d,!1,p),this.Iu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&J.At()){let m=J.Dt(this.Iu);I(m)&&m.forEach(w=>{D(w)&&this.Tu.add(w)})}else J.Pt(this.Iu);let f=v({},this.persistence.props),_=v({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Nu=new gh((m,w)=>this.qu(m,w),this.config.request_queue_config),this.ju=new mh(this),this.__request_queue=[];let g=this.pu();g||(this.sessionManager=new yo(this),this.sessionPropsManager=new _o(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((m,w,$)=>{($?.activityTimeout||$?.sessionPastMaximumLength||$?.crossTabAdoption)&&this.Bu()})),this.zu(),this.config.__preview_deferred_init_extensions?(S.info("Deferring extension initialization to improve startup performance"),this.Hu=setTimeout(()=>{this.Hu=void 0,this.Uu(g)},0)):(S.info("Initializing extensions synchronously"),this.Uu(g)),$e.DEBUG=$e.DEBUG||this.config.debug,$e.DEBUG&&S.info("Starting in debug mode",{this:this,config:i,thisC:v({},this.config),p:f,s:_}),this.config.identity_distinct_id&&!(!((n=i.bootstrap)===null||n===void 0)&&n.distinctID)&&(i.bootstrap=v(v({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let y=(r=i.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.yu=!!y&&!oi(y),(o=i.bootstrap)===null||o===void 0?void 0:o.distinctID){let m=i.bootstrap.distinctID,w=this.get_distinct_id(),$=this.persistence.get_property(we);if(i.bootstrap.isIdentifiedID&&w!=null&&w!==m&&$==="anonymous")this.identify(m);else if(i.bootstrap.isIdentifiedID&&w!=null&&w!==m&&$==="identified")S.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{let P=this.config.get_device_id(Le()),k=i.bootstrap.isIdentifiedID?P:m;this.persistence.set_property(we,i.bootstrap.isIdentifiedID?Ni:Ye),this.register({distinct_id:m,$device_id:k})}}if(g)this.register_once({distinct_id:Ss,$device_id:null},"");else if(!this.get_distinct_id()){let m=this.config.get_device_id(Le());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(we,Ye)}return G(b,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),G(b,"pageshow",()=>{var m;this.xu=!1,this.$u||(m=this.ju)===null||m===void 0||m.resume()}),i.segment?oo(this,()=>this.Wu()):this.Wu(),oe(this.config._onCapture)&&this.config._onCapture!==fi&&(S.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",m=>this.config._onCapture(m.event,m))),this.config.ip&&S.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return dc.apply(this,arguments)})().then(m=>{m&&this.register({[$s]:m})}).catch(fi),this}Vu(t){let i=t;return D(i.name)&&oe(i.setup)}Gu(t,i){var s=this;this.Vu(t)?i.push(X(function*(){try{yield t.setup(s.Qu())}catch(r){S.error(`Failed to set up extension "${t.name}"`,r);try{var n;yield(n=t.dispose)===null||n===void 0?void 0:n.call(t)}catch(o){S.error(`Failed to dispose extension "${t.name}"`,o)}}})):this.vu.push(t)}zu(){var t,i,s,n=this;let r=(t=(i=this.config.__extensionClasses)===null||i===void 0?void 0:i.featureFlags)!==null&&t!==void 0?t:(s=st.__defaultExtensionClasses)===null||s===void 0?void 0:s.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||((o=this.Zu)===null||o===void 0||o.call(this),this.Zu=void 0,this.featureFlags=new r(this)),oe(this.featureFlags.onReloading)&&oe(this.featureFlags.setup)){if(!this.Zu){this.Zu=this.featureFlags.onReloading(()=>{this.lu.emit("featureFlagsReloading",!0)});let c=this.featureFlags;X(function*(){try{yield c.setup(n.Qu())}catch(u){S.error("Failed to set up feature flags",u);let h=n.Zu;n.Zu=void 0;try{h?.()}catch(d){S.error("Failed to unsubscribe feature flag reloading",d)}try{yield c.dispose()}catch(d){S.error("Failed to dispose feature flags",d)}}})()}}else(a=(l=this.featureFlags).initialize)===null||a===void 0||a.call(l)}Uu(t){let i=performance.now(),s=v(v({},st.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,h,d;s.exceptions&&this.vu.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new s.exceptions(this)),s.historyAutocapture&&this.vu.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.vu.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.vu.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this.vu.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Gu(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Gu(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new s.surveys(this),n),s.logs&&this.Gu(this.logs=(a=this.logs)!==null&&a!==void 0?a:new s.logs(this),n),s.metrics&&this.vu.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new s.metrics(this)),s.conversations&&this.vu.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new s.conversations(this)),s.productTours&&this.vu.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.vu.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.vu.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.vu.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.vu.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,Yd)),s.toolbar&&this.vu.push(this.toolbar=(u=this.toolbar)!==null&&u!==void 0?u:new s.toolbar(this)),s.experiments&&this.vu.push(this.experiments=(h=this.experiments)!==null&&h!==void 0?h:new s.experiments(this)),s.webMCP&&this.vu.push(this.webMCP=(d=this.webMCP)!==null&&d!==void 0?d:new s.webMCP(this)),this.vu.forEach(p=>{p.initialize&&n.push(()=>{var f;(f=p.initialize)===null||f===void 0||f.call(p)})}),n.push(()=>{if(this.Ju){let p=this.Ju;this.Ju=void 0,this.vu.forEach(f=>{var _;return(_=f.onRemoteConfig)===null||_===void 0?void 0:_.call(f,p)})}}),this.Ku(n,i)}Ku(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void(this.Hu=setTimeout(()=>{this.Hu=void 0,this.Ku(t,i)},0));let n=t.shift();if(n)try{n()}catch(r){S.error("Error initializing extension:",r)}}let s=Math.round(performance.now()-i);this.register_for_session({[hl]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[pl]:s}),this.config.__preview_deferred_init_extensions&&S.info(`PostHog extensions initialized (${s}ms)`)}el(t){if(!E||!E.body)return S.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ju=t),this.uu=t,this.compression=void 0,t.ok){var i;let s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=A(s.supportedCompression,Me.GZipJS)?Me.GZipJS:A(s.supportedCompression,Me.Base64)?Me.Base64:void 0),!((i=s.analytics)===null||i===void 0)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.Au?this.Au:wl}),this.lu.emit("extensionsRemoteConfig",t),this.vu.forEach(s=>{var n;return(n=s.onRemoteConfig)===null||n===void 0?void 0:n.call(s,t)})}Wu(){try{this.config.loaded(this)}catch(t){S.critical("`loaded` function failed",t)}if(this.Xu(),this.config.internal_or_test_user_hostname&&Z?.hostname){let t=Z.hostname,i=this.config.internal_or_test_user_hostname;(typeof i=="string"?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.pu())&&this.Yu()},1),this.tc=new Yl(this),this.tc.load()}Xu(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Nu)===null||t===void 0||t.enable())}_dom_loaded(){this.is_capturing()&&At(this.__request_queue,t=>this.qu(t)),this.__request_queue=[],this.Xu()}_handle_unload(){var t,i,s,n,r,o;this.xu=!0,(t=this.surveys)===null||t===void 0||(i=t.handlePageUnload)===null||i===void 0||i.call(t),(s=this.metrics)===null||s===void 0||s.flush("sendBeacon"),this.config.request_batching?(this.ec()&&this.capture(qr),(n=this.logs)===null||n===void 0||n.flushLogs("sendBeacon"),(r=this.Nu)===null||r===void 0||r.unload(),(o=this.ju)===null||o===void 0||o.unload()):this.ec()&&this.capture(qr,null,{transport:"sendBeacon"})}_send_request(t){cc(this,t)}qu(t,i){this.ju?this.ju.retriableRequest(t,i):this._send_request(i?v(v({},t),{},{transport:i}):t)}_execute_array(t){zs++;try{let i,s=[],n=[],r=[];At(t,a=>{if(a)if(i=a[0],I(i))r.push(a);else if(oe(a))try{a.call(this)}catch(l){S.error("Error executing queued PostHog call",a,l)}else I(a)&&i==="alias"?s.push(a):I(a)&&i.indexOf("capture")!==-1&&oe(this[i])?r.push(a):n.push(a)});let o=function(a,l){At(a,function(c){try{if(I(c[0])){let u=l;W(c,function(h){u=u[h[0]].apply(u,h.slice(1))})}else l[c[0]].apply(l,c.slice(1))}catch(u){S.error("Error executing queued PostHog call",c,u)}})};o(s,this),o(n,this),o(r,this)}finally{zs--}}push(t){if(zs>0&&I(t)&&D(t[0])){let i=st.prototype[t[0]];return void(oe(i)&&i.apply(this,t.slice(1)))}this._execute_array([t])}get nc(){return{property:Hr,persistenceKey:Lt,cookieName:"_fbc",pattern:Eo,register:(t,i)=>{var s;return(s=this.persistence)===null||s===void 0?void 0:s.register({[Lt]:{value:t,delivered:i}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Lt)}}}get sc(){return{property:Ur,persistenceKey:ci,cookieName:"_fbp",pattern:$o,register:(t,i)=>{var s;return(s=this.persistence)===null||s===void 0?void 0:s.register({[ci]:{value:t,delivered:i}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(ci)}}}rc(t){var i;let s=(i=this.persistence)===null||i===void 0?void 0:i.get_property(t.persistenceKey);return D(s)&&t.pattern.test(s)?{value:s,delivered:!1}:L(s)&&D(s.value)&&t.pattern.test(s.value)?{value:s.value,delivered:s.delivered===!0}:void 0}oc(t,i,s){return i===s?.value?{value:i,pending:!s.delivered}:(t.register(i,!1),{value:i,pending:!0})}ac(t){if(!this.config.save_campaign_params||this.pu())return;let i=di(t.cookieName);return D(i)&&t.pattern.test(i)?i:void 0}lc(t,i,s,n){if(!this.persistence)return;let r=this.nc;this.persistence.refreshKey(r.persistenceKey);let o=this.rc(r);if(n)return void r.unregister();if(s)return D(i)&&Eo.test(i)?this.oc(r,i,o):void r.unregister();let a=D(t)&&Ch.test(t)?t:void 0,l=this.ac(r);return l&&((c,u,h)=>{let d=c.split(".");if(u)return d[3]===u;if(!h)return!0;let p=h.value.split(".");return d[3]===p[3]||Number(d[2])>Number(p[2])})(l,a,o)?this.oc(r,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.oc(r,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}uc(t,i,s){if(!this.persistence)return;let n=this.sc;this.persistence.refreshKey(n.persistenceKey);let r=this.rc(n);if(s)return void n.unregister();if(i)return D(t)&&$o.test(t)?this.oc(n,t,r):void n.unregister();let o=this.ac(n);return o?this.oc(n,o,r):r?{value:r.value,pending:!r.delivered}:void 0}cc(t,i){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);let s=this.rc(t);s?.value!==i||s.delivered||t.register(i,!0)}capture(t,i,s){var n,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Nu))return void S.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(x(t)||!D(t))return void S.error("No event name provided to posthog.capture");if(this.bu(),t==="$snapshot"&&this.pu())return;let o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return;let a=s?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void S.critical("This capture call is ignored due to client rate limiting.");let l;i?.$current_url&&!D(i?.$current_url)&&(S.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),t!=="$exception"||s?.hc||S.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();let c=new Date,u=s?.timestamp||c,h=wr(s?.uuid,Le),d={uuid:h,event:t,properties:this.calculateEventProperties(t,i||{},u,h)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),a&&(d.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);let p=t==="$feature_flag_called"&&d.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;s?.$set&&!p&&(d.$set=s?.$set);let f=L(i?.$set)?i.$set:void 0,_=I(i?.$unset)?i.$unset:[],g=s?.$unset||[],y=F=>{var j;let N=!!s?.$set&&F in s.$set;return{hasProvided:N||!!f&&F in f,provided:N?s==null||(j=s.$set)===null||j===void 0?void 0:j[F]:f?.[F],unset:_.indexOf(F)!==-1||g.indexOf(F)!==-1}},m=y(Hr),w=y(Ur),$=[{channel:this.nc,hasProvided:m.hasProvided,update:this.lc(l?.fbclid,m.provided,m.hasProvided,m.unset)},{channel:this.sc,hasProvided:w.hasProvided,update:this.uc(w.provided,w.hasProvided,w.unset)}];for(let{channel:F,hasProvided:j,update:N}of $)N&&d.properties.$process_person_profile===!0&&N.pending&&!j&&!p&&(d.$set=v({[F.property]:N.value},d.$set));let P=s?.$unset;P&&(d.$unset=P);let k=p?void 0:this.dc(s?.$set_once,t!==zr,t===xl);if(k&&(d.$set_once=k),s?._noTruncate||(M=this.config.properties_string_max_length,d=(function(F,j){let N=new Set;return(function Y(z,ie){if(z!==Object(z))return j?j(z):z;if(N.has(z))return;let he;if(N.add(z),I(z))he=[],At(z,ce=>{he.push(Y(ce))});else{let ce={};W(Vt(z)?kl(z):z,(fe,Pe)=>{N.has(fe)||(ce[Pe]=Y(fe,Pe))}),he=ce}return he})(F)})(d,F=>D(F)?F.slice(0,M):F)),d.timestamp=u,x(s?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=c),p&&(d.properties=((F,j=[])=>{let N={},Y=z=>{F[z]!==void 0&&(N[z]=F[z])};return $u.forEach(Y),j.forEach(Y),N})(d.properties,Rh)),t===Te.DISMISSED||t===Te.SENT){let F=i?.[Ds.SURVEY_ID],j=i?.[Ds.SURVEY_ITERATION];fc({id:F,current_iteration:j}),d.$set=v(v({},d.$set),{},{[wh({id:F,current_iteration:j},t===Te.SENT?"responded":"dismissed")]:!0})}else t===Te.SHOWN&&(d.$set=v(v({},d.$set),{},{[Ds.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var M;if(t===nh.SHOWN){let F=i?.[uo.TOUR_TYPE];F&&(d.$set=v(v({},d.$set),{},{[`${uo.TOUR_LAST_SEEN_DATE}/${F}`]:new Date().toISOString()}))}let T=v(v({},d.properties.$set),d.$set);if(Se(T)||this.setPersonPropertiesForFlags(T),!R(this.config.before_send)){let F=this.Os(d);if(!F)return;d=F,d.uuid=wr(d.uuid,Le)}this.sessionRecording&&!this.Eu&&ko(t)&&(this.Eu=!0,setTimeout(()=>this.Eu=!1,3e4));let O=$.filter(({channel:F,update:j})=>{var N,Y,z;let ie=(N=(Y=d.$set)===null||Y===void 0?void 0:Y[F.property])!==null&&N!==void 0?N:L((z=d.properties)===null||z===void 0?void 0:z.$set)?d.properties.$set[F.property]:void 0;return j?.pending&&ie===j.value});this.lu.emit("eventCaptured",d);let B=(n=s?._url)!==null&&n!==void 0?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),U=s?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(B),q=v(v(v({method:"POST",url:B,data:d,compression:"best-available",preferSyncCompression:s?.send_instantly,timestampMode:U?"body":"capture-body",batchKey:s?._batchKey},U&&(!((r=d.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),s?.transport?{transport:s.transport}:{}),O.length?{fireCallbackOnDrop:!0,callback:F=>{if(F.statusCode>=200&&300>F.statusCode)for(let{channel:j,update:N}of O)this.cc(j,N.value)}}:{});if(!this.config.request_batching||s&&!s?._batchKey||s?.send_instantly){var K;let F;!q.transport&&!q.callback&&Se((K=this.config.request_headers)!==null&&K!==void 0?K:{})&&this.xu&&(F="sendBeacon"),this.qu(q,F)}else this.Nu.enqueue(q);return d}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return(i=this.vc)===null||i===void 0?void 0:i.getExtension(t)}Qu(){var t;return(t=this.vc)!==null&&t!==void 0?t:this.vc=new Fh(this)}cu(t){this.Mu.push(t);let i=!0;return()=>{if(!i)return;i=!1;let s=this.Mu.indexOf(t);s!==-1&&this.Mu.splice(s,1)}}fc(t=!0){var i,s,n;return!!(!((i=this.persistence)===null||i===void 0)&&i.consumeCookieIdentityChange())&&(this.Fu=null,this.persistence.get_property("$user_state")==="anonymous"&&((n=this.sessionPersistence)===null||n===void 0||n.clear(),this.Tu.clear(),this.gc()),(s=this.featureFlags)===null||s===void 0||s.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,i,s,n,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;this.bu(),this.persistence.syncCookieProperties(),this.fc();let o=r?void 0:this.persistence.remove_event_timer(t),a=v({},i);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.pu()&&(a[dl]=!0),t==="$snapshot"){let m=v(v({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=m.distinct_id,(!D(a.distinct_id)&&!re(a.distinct_id)||oi(a.distinct_id))&&S.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}let l=(function(m,w,$,P=!1){var k,M,T,O;if(!be)return{};let B=m?[...qt,...w||[]]:[],[U,q]=Pa(be),[K,F]=(function(ue){for(let Fe=0;br.length>Fe;Fe++){let[Xe,Ze,ut]=br[Fe],Ee=ue.match(Xe);if(Ee){let Ne=ut&&ue.match(ut)||Ee;return[Ze,Ne?.[1]||""]}}return["",""]})(be),j=(function(){let ue="u">typeof navigator?navigator:void 0;return ue?.brave?{brave:!0}:{}})(),N={};x($)||(N.detectGoogleSearchApp=$);let Y={},z=(k=navigator)===null||k===void 0||(k=k.userAgentData)===null||k===void 0?void 0:k.platform,ie=(M=navigator)===null||M===void 0?void 0:M.maxTouchPoints,he=b==null||(T=b.screen)===null||T===void 0?void 0:T.width,ce=b==null||(O=b.screen)===null||O===void 0?void 0:O.height,fe=b?.devicePixelRatio;x(z)||(Y.userAgentDataPlatform=z),x(ie)||(Y.maxTouchPoints=ie),x(he)||(Y.screenWidth=he),x(ce)||(Y.screenHeight=ce),x(fe)||(Y.devicePixelRatio=fe);let Pe=Q(Kn({$os:U,$os_version:q,$browser:Sa(be,navigator.vendor,j,N),$webview_app:K,$webview_app_version:F,$device:Ta(be),$device_type:Wc(be,Y),$timezone:Ll(),$timezone_offset:th()}),{$current_url:xi(P?ct(Z?.href):Z?.href,B,ki),$host:Z?.host,$pathname:Z?.pathname,$raw_user_agent:be.length>1e3?be.substring(0,997)+"...":be,$browser_version:Vc(be,navigator.vendor,j,N),$browser_language:ql(),$browser_language_prefix:eh(),$screen_height:b?.screen.height,$screen_width:b?.screen.width,$viewport_height:b?.innerHeight,$viewport_width:b?.innerWidth,$lib:Ke.LIB_NAME,$lib_version:Ke.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ke.SDK_DIST_CHANNEL&&(Pe.$sdk_dist_channel=Ke.SDK_DIST_CHANNEL),Pe})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){let{sessionId:m,windowId:w}=this.sessionManager.checkAndGetSessionAndWindowId(r,s.getTime(),!0);a.$session_id=m,a.$window_id=w}this.sessionPropsManager&&Q(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){let m=this.sessionRecording.sdkDebugProperties,w=!this.Eu&&ko(t);for(let $ in m)(w||A(Ih,$))&&(a[$]=m[$])}a.$sdk_debug_retry_queue_size=(c=this.ju)===null||c===void 0?void 0:c.length}catch(m){a.$sdk_debug_error_capturing_properties=String(m)}let u;if(this.requestRouter.region===Fn&&(a.$lib_custom_api_host=this.config.api_host),u=t!=="$pageview"||r?t!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,n),a=Q(a,u),t==="$pageview"&&E&&(a.title=E.title),!x(o)){let m=s.getTime()-o;a.$duration=parseFloat((m/1e3).toFixed(3))}be&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");let h=this.persistence.properties(),d=this.sessionPersistence.properties(),p=a.$groups,f=h.$groups;L(p)&&!Se(p)&&(a.$groups=v(v({},L(f)?f:{}),p)),W(["$referrer","$referring_domain"],m=>{m in h&&delete d[m]});let _={};if(this.Mu.length>0)for(let m of this.Mu.slice())try{Q(_,m())}catch(w){S.error("Failed to produce browser extension event properties",w)}a=Q({},l,h,d,v(v({},_),a)),a.$is_identified=this._isIdentified(),I(this.config.property_denylist)?W(this.config.property_denylist,function(m){delete a[m]}):S.error(bc+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);let g=this.config.sanitize_properties;g&&(S.error(xo),a=g(a,t));let y=this.mc();return a.$process_person_profile=y,y&&!r&&this.yc("_calculate_event_properties"),a}dc(t,i=!0,s=!1){var n;if(!this.persistence||!this.mc()||this.Cu&&!s)return t;let r=this.persistence.get_initial_props(),o=(n=this.sessionPropsManager)===null||n===void 0?void 0:n.getSetOnceProps(),a=Q({},r,o||{},t||{}),l=this.config.sanitize_properties;return l&&(S.error(xo),a=l(a,"$set_once")),i&&(this.Cu=!0),Se(a)?void 0:a}register(t,i){var s;(s=this.persistence)===null||s===void 0||s.register(t,i)}register_once(t,i,s){var n;(n=this.persistence)===null||n===void 0||n.register_once(t,i,s)}register_for_session(t){var i,s;(i=this.persistence)===null||i===void 0||i.syncCookieProperties(),this.fc(),(s=this.sessionPersistence)===null||s===void 0||s.register(t),Object.keys(t).forEach(n=>this.Tu.add(n)),this.gc()}unregister(t){var i;(i=this.persistence)===null||i===void 0||i.unregister(t)}unregister_for_session(t){var i;(i=this.sessionPersistence)===null||i===void 0||i.unregister(t),this.Tu.delete(t),this.gc()}bc(t,i){this.register({[t]:i})}Bu(){this.Tu.forEach(t=>{var i;(i=this.sessionPersistence)===null||i===void 0||i.unregister(t)}),this.Tu.clear(),this.gc()}gc(){var t;if(!this.Iu)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.hi||!J.At())return void J.Pt(this.Iu);let i=[];this.Tu.forEach(s=>i.push(s)),i.length>0?J.$t(this.Iu,i):J.Pt(this.Iu)}getFeatureFlag(t,i){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return(t=(i=this.featureFlags)===null||i===void 0?void 0:i.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,i){var s,n;return(s=(n=this.featureFlags)===null||n===void 0?void 0:n.isFeatureEnabled(t,i))!==null&&s!==void 0?s:i?.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)===null||t===void 0||t.reloadFeatureFlags()}updateFlags(t,i,s){var n;(n=this.featureFlags)===null||n===void 0||n.updateFlags(t,i,s)}updateEarlyAccessFeatureEnrollment(t,i,s){var n;(n=this.featureFlags)===null||n===void 0||n.updateEarlyAccessFeatureEnrollment(t,i,s)}getEarlyAccessFeatures(t,i=!1,s){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getEarlyAccessFeatures(t,i,s)}on(t,i){return this.lu.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Tt}),()=>{})}onSessionId(t){var i,s;return(i=(s=this.sessionManager)===null||s===void 0?void 0:s.onSessionId(t))!==null&&i!==void 0?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:Tt})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:Tt})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:Tt}),()=>{})}renderSurvey(t,i){var s;(s=this.surveys)===null||s===void 0||s.renderSurvey(t,i)}displaySurvey(t,i=Sh){var s;(s=this.surveys)===null||s===void 0||s.displaySurvey(t,i)}cancelPendingSurvey(t){var i;(i=this.surveys)===null||i===void 0||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,s;return(i=(s=this.surveys)===null||s===void 0?void 0:s.canRenderSurvey(t))!==null&&i!==void 0?i:{visible:!1,disabledReason:Tt}}canRenderSurveyAsync(t,i=!1){var s,n;return(s=(n=this.surveys)===null||n===void 0?void 0:n.canRenderSurveyAsync(t,i))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:Tt})}_c(t){return!t||oi(t)?(S.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(S.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(S.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,s){if(!this.__loaded||!this.persistence)return S.uninitializedWarning("posthog.identify");if(re(t)&&(t=t.toString(),S.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._c(t)||!this.yc("posthog.identify"))return;this.bu();let n=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==n,o=this.fc(!1),a=this.persistence.Oa(),l=!1;try{let u=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),t!==u&&t!==this.get_property("__alias")&&(this.unregister(Zi),this.register({distinct_id:t}));let h=(this.persistence.get_property("$user_state")||"anonymous")===Ye,d=t!==u,p=!d&&h;if(d&&h){var c;let f=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:u};this.persistence.set_property(we,Ni),this.setPersonPropertiesForFlags({$set:i||{},$set_once:s||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",f,{$set:i||{},$set_once:s||{}})&&(this.Fu=qs(t,i,s)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(p){this.persistence.set_property(we,Ni);let f=i||{},_=s||{};this.setPersonPropertiesForFlags({$set:f,$set_once:_},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:f,$set_once:_})&&(this.Fu=qs(t,i,s))}else(i||s)&&this.setPersonProperties(i,s);d||r||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ot)):p&&(i||s)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.qa(l)}}setPersonProperties(t,i){if(!t&&!i||!this.yc("posthog.setPersonProperties"))return;let s=qs(this.get_distinct_id(),t,i);this.Fu!==s?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}})&&(this.Fu=s)):S.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;let s=(I(t)?t:[t]).filter(n=>D(n)&&n.length>0);s.length!==0&&this.yc("posthog.unsetPersonProperties")&&((i=this.featureFlags)===null||i===void 0||i.unsetPersonPropertiesForFlags(s,!0),this.capture("$set",{$unset:s}),this.Fu=null)}group(t,i,s){var n;if(!t||!i)return void S.error("posthog.group requires a group type and group key");(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.fc();let r=this.getGroups(),o=r[t]!==i;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:v(v({},r),{},{[t]:i})}),(o||s)&&this.mc()){let a={$group_type:t,$group_key:i};s&&(a.$group_set=s),this.capture(zr,a)}s&&this.setGroupPropertiesForFlags({[t]:s}),o&&!s&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var s;(s=this.featureFlags)===null||s===void 0||s.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;(i=this.featureFlags)===null||i===void 0||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var s;this.yc("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)===null||s===void 0||s.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;(i=this.featureFlags)===null||i===void 0||i.resetGroupPropertiesForFlags(t)}reset(t){let i=xe(t)?t:t?.resetDeviceID,s=xe(t)||t==null?void 0:t.bootstrap;this.wc(i,!1,s)}wc(t,i=!1,s){var n,r,o,a,l,c;if(S.info("reset"),!this.__loaded)return S.uninitializedWarning("posthog.reset");let u=s?.sessionID;this.config.bootstrap=s||((n=this.Du)===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.il());let h=this.get_property(Hn),d=this.get_property($s),p=this.get_property(ui);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();let f=this.is_capturing();i||this.consent.reset(),i||!f||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");let _=(l=this.persistence)===null||l===void 0||(c=l.Oa)===null||c===void 0?void 0:c.call(l),g=this._u;this._u=g||i;let y=!1;try{var m,w,$,P,k,M,T,O,B,U,q,K,F;if((m=this.persistence)===null||m===void 0||m.clear(),(w=this.sessionPersistence)===null||w===void 0||w.clear(),this.Tu.clear(),this.gc(),x(p)||(U=this.persistence)===null||U===void 0||U.register({$session_recording_remote_config:p}),($=this.surveys)===null||$===void 0||$.reset(),(P=this.featureFlags)===null||P===void 0||P.reset(),(k=this.conversations)===null||k===void 0||k.reset(),(M=this.logs)===null||M===void 0||M.reset(),(T=this.metrics)===null||T===void 0||T.reset(),(O=this.persistence)===null||O===void 0||O.set_property("$user_state","anonymous"),(B=this.sessionManager)===null||B===void 0||B.resetSessionId(),this.Fu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Ss,$device_id:null},"");else{let Y=this.config.get_device_id(Le());this.register_once({distinct_id:Y,$device_id:t?Y:h},""),t||x(d)||this.register({[$s]:d})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),s&&(s.distinctID&&!this.pu()&&((F=this.persistence)===null||F===void 0||F.set_property("$user_state",s.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:s.distinctID})),(q=this.featureFlags)===null||q===void 0||q.initialize(),!R(u)&&!(!((K=this.sessionManager)===null||K===void 0)&&K.setBootstrapSessionId(u,!0)))){let Y=v({},s);delete Y.sessionID,this.config.bootstrap=Y}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,y=!0}finally{var j,N;this._u=g,_&&((j=this.persistence)===null||j===void 0||(N=j.qa)===null||N===void 0||N.call(j,y))}this.reloadFeatureFlags()}shutdown(t){var i=this;return X(function*(){if(!i.__loaded)return void S.uninitializedWarning("posthog.shutdown");i.$u=!0,clearTimeout(i.Hu),i.Hu=void 0;let s=i.Zu;i.Zu=void 0;for(let n of[()=>{var r;return(r=i.sessionRecording)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=i.logs)===null||r===void 0?void 0:r.flushLogs("sendBeacon")},()=>{var r;return(r=i.metrics)===null||r===void 0?void 0:r.flush("sendBeacon")},()=>{var r;return(r=i.metrics)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=i.logs)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=i.surveys)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=i.autocapture)===null||r===void 0?void 0:r.dispose()},()=>s?.(),()=>{var r;return(r=i.Nu)===null||r===void 0?void 0:r.unload()},()=>{var r;return(r=i.ju)===null||r===void 0?void 0:r.unload()},()=>{var r;return(r=i.featureFlags)===null||r===void 0?void 0:r.destroy()},()=>{var r;return(r=i.persistence)===null||r===void 0?void 0:r.destroy()},()=>{var r;return(r=i.sessionPersistence)===null||r===void 0?void 0:r.destroy()}])try{let r=n();r&&oe(r.then)&&r.then(void 0,o=>{S.error("Error during shutdown",o)})}catch(r){S.error("Error during shutdown",r)}})()}setIdentity(t,i){var s;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),(s=this.conversations)===null||s===void 0||s.kc()}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.Sc()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return(t=(i=this.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";let{sessionId:i,sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if(t?.withTimestamp&&s){var r;let o=(r=t.timestampLookBack)!==null&&r!==void 0?r:10;if(!s)return n;n+=`?t=${Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}`}return n}alias(t,i){return t===this.get_property("$people_distinct_id")?(S.critical("Attempting to create alias for existing People user - aborting."),-2):this.yc("posthog.alias")?(x(i)&&(i=this.get_distinct_id()),t!==i?(this.bc(Zi,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(S.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){let i=v({},this.config);if(L(t)){var s,n,r,o,a,l,c,u,h,d,p,f,_,g;Q(this.config,So(t));let P=this.Su();if(this.persistence){let M=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var y,m;if(M&&this.sessionPersistence!==this.persistence&&((y=this.sessionPersistence)===null||y===void 0||y.remove(),(m=this.sessionPersistence)===null||m===void 0||m.destroy()),this.persistence.update_config(this.config,i,P),M)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new Rs(v(v({},this.config),{},{persistence:"sessionStorage"}),P,!1);else{var w;(w=this.sessionPersistence)===null||w===void 0||w.update_config(v(v({},this.config),{},{persistence:"sessionStorage"}),v(v({},i),{},{persistence:"sessionStorage"}),P)}}let k=this.Ou(this.config.debug);var $;xe(k)&&(this.config.debug=k),xe(this.config.debug)&&(this.config.debug?($e.DEBUG=!0,H.At()&&H.$t("ph_debug",!0),S.info("set_config",{config:t,oldConfig:i,newConfig:v({},this.config)})):($e.DEBUG=!1,H.At()&&H.Pt("ph_debug"))),(s=this.featureFlags)===null||s===void 0||(n=s.updateConfig)===null||n===void 0||n.call(s,this.config,this.il()),(r=this.exceptionObserver)===null||r===void 0||r.onConfigChange(),(o=this.exceptions)===null||o===void 0||o.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(l=this.webMCP)===null||l===void 0||l.startIfEnabled(),(c=this.sessionRecording)===null||c===void 0||c.startIfEnabledOrStop(),(u=this.tracingHeaders)===null||u===void 0||u.startIfEnabledOrStop(),(h=this.autocapture)===null||h===void 0||h.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()),(p=this.exceptionObserver)===null||p===void 0||p.startIfEnabledOrStop(),(f=this.deadClicksAutocapture)===null||f===void 0||f.startIfEnabledOrStop(),(_=this.surveys)===null||_===void 0||_.loadIfEnabled(),this.wu(),(g=this.externalIntegrations)===null||g===void 0||g.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&oo(this,fi,!1)}}_overrideSDKInfo(t,i){$e.LIB_NAME=t,$e.LIB_VERSION=i}startSessionRecording(t){let i=t===!0,s={sampling:i||!!t?.sampling,linked_flag:i||!!t?.linked_flag,url_trigger:i||!!t?.url_trigger,event_trigger:i||!!t?.event_trigger};var n,r,o,a,l;Object.values(s).some(Boolean)&&((n=this.sessionManager)===null||n===void 0||n.checkAndGetSessionAndWindowId(),s.sampling&&((r=this.sessionRecording)===null||r===void 0||r.overrideSampling()),s.linked_flag&&((o=this.sessionRecording)===null||o===void 0||o.overrideLinkedFlag()),s.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),s.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,i){try{if(!this.exceptions)return;let s=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(v(v({},s),i))}catch{return}}addExceptionStep(t,i){var s;(s=this.exceptions)===null||s===void 0||s.addExceptionStep(t,i)}captureLog(t){var i;(i=this.logs)===null||i===void 0||i.captureLog(t)}get logger(){var t,i;return(t=(i=this.logs)===null||i===void 0?void 0:i.logger)!==null&&t!==void 0?t:st.xc}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,s;return(i=(s=this.toolbar)===null||s===void 0?void 0:s.loadToolbar(t))!==null&&i!==void 0&&i}get_property(t){var i;return(i=this.persistence)===null||i===void 0?void 0:i.props[t]}getSessionProperty(t){var i;return(i=this.sessionPersistence)===null||i===void 0?void 0:i.props[t]}toString(){var t;let i=(t=this.config.name)!==null&&t!==void 0?t:ri;return i!==ri&&(i="posthog."+i),i}_isIdentified(){var t,i;return((t=this.persistence)===null||t===void 0?void 0:t.get_property("$user_state"))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property("$user_state"))==="identified"}mc(){var t,i;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Se(this.getGroups())&&!(!((t=this.persistence)===null||t===void 0||(t=t.props)===null||t===void 0)&&t.__alias)&&!(!((i=this.persistence)===null||i===void 0||(i=i.props)===null||i===void 0)&&i.$epp))}ec(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.mc()||this.yc("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.yc("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}yc(t){return this.config.person_profiles==="never"?(S.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gu(),this.bc(zn,!0),!0)}Su(){if(this.config.cookieless_mode==="always")return!0;let t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}wu(){var t,i;let s=this.Su();var n,r,o;return this.is_capturing()||(n=this.logs)===null||n===void 0||n.$c(),((t=this.persistence)===null||t===void 0?void 0:t.hi)!==s&&((r=this.persistence)===null||r===void 0||r.set_disabled(s)),((i=this.sessionPersistence)===null||i===void 0?void 0:i.hi)!==s&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(s)),this.gc(),s}opt_in_capturing(t){var i;if(this.config.cookieless_mode!=="always"){if(this.pu()){var s,n,r,o,a,l;(s=this.sessionRecording)===null||s===void 0||s.dispose({discardBufferedEvents:!0}),this.wc(!0,!0),(n=this.sessionManager)===null||n===void 0||n.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new yo(this),this.pageViewManager=new ao(this),this.persistence&&(this.sessionPropsManager=new _o(this,this.sessionManager,this.persistence));let p=(o=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&o!==void 0?o:(l=st.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var c,u;p&&(this.sessionRecording=this.fu(this.sessionRecording,new p(this)),this.uu&&((c=this.sessionRecording)===null||c===void 0||(u=c.onRemoteConfig)===null||u===void 0||u.call(c,this.uu)))}var h,d;this.consent.optInOut(!0),this.wu(),this.Xu(),(i=this.sessionRecording)===null||i===void 0||i.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((h=this.surveys)===null||h===void 0||h.loadIfEnabled()),(x(t?.captureEventName)||t?.captureEventName)&&this.capture((d=t?.captureEventName)!==null&&d!==void 0?d:"$opt_in",t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Yu()}else S.warn(wo)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.wu(),this.config.cookieless_mode==="on_reject"&&this.ku()):S.warn(wo)}ku(){var t,i;let s=this.sessionRecording;s?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.wc(!0,!0),this.register({distinct_id:Ss,$device_id:null}),this.du(s),this.sessionRecording=void 0,(t=this.sessionManager)===null||t===void 0||t.destroy(),(i=this.pageViewManager)===null||i===void 0||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Yu(),this.Xu()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){let t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return!this._u&&(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.wu()}_is_bot(){return pe?uc(pe,this.config.custom_blocked_useragents):void 0}Yu(){E&&(E.visibilityState==="visible"?this.Pu||(this.Pu=!0,this.capture(Yn,{title:E.title},{send_instantly:!0}),this.Ru&&(E.removeEventListener(bi,this.Ru),this.Ru=null)):this.Ru||(this.Ru=this.Yu.bind(this),G(E,bi,this.Ru)))}debug(t){t===!1?(b?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(b?.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}))}il(){let t=this.Du||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(S.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(i,s,n,r,o){let a=s in i&&!R(i[s]),l=n in i&&!R(i[n]);return a?i[s]:!!l&&(o&&o.warn(`Config field '${n}' is deprecated. Please use '${s}' instead. The old field will be removed in a future major version.`),i[n])})(t,"advanced_disable_flags","advanced_disable_decide",0,S)}Os(t){var i;if(R(this.config.before_send))return t;let s=Object.keys((i=t.properties)!==null&&i!==void 0?i:{}).filter(Rc),n=I(this.config.before_send)?this.config.before_send:[this.config.before_send],r=t;for(let o of n)try{if(r=o(r),R(r)){let a=`Event '${t.event}' was rejected in beforeSend function`;return Cc(t.event)?S.warn(`${a}. This can cause unexpected behavior.`):S.info(a),null}r.properties&&!Se(r.properties)||S.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return S.error(`Error in beforeSend function for event '${t.event}':`,a),null}for(let o of s)if(r.properties&&R(r.properties[o]))return S.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.Wo)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,s){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(s)})}Ou(t){let i=xe(t)&&!t,s=H.At()&&H.Ot("ph_debug")==="true";return!i&&(!!s||t)}};gi.__defaultExtensionClasses={},gi.xc=(()=>{let e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Md(e.prototype[t[i]])})(gi,["identify"]);var wc=class{constructor(e){this.disabled=e===!1;let t=L(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;let s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Vs="$copy_autocapture",Ws=te("[AutoCapture]");function Ys(e,t){return t.length>e?t.slice(0,e)+"...":t}function jh(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!De(t));return t}function Bh(e,{e:t,maskAllElementAttributes:i,maskAllText:s,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!De(e))return{props:{}};let c=[e],u=new Set([e]),h=e;for(;h.parentNode&&!ve(h,"body")&&1e3>c.length;){if(Jn(h.parentNode)){let k=h.parentNode.host;if(u.has(k))break;u.add(k),c.push(k),h=k;continue}if(!De(h.parentNode)||u.has(h.parentNode))break;u.add(h.parentNode),c.push(h.parentNode),h=h.parentNode}let d=t.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(k=>ve(k,"button")||ve(k,"a")):-1;d>0&&(s=s||c.slice(0,d+1).some(k=>!wt(k)||Ht(k)));let p=[],f={},_,g=!1,y=!1;if(W(c,k=>{let M=wt(k);if(ve(k,"a")&&!i&&!n?.includes("href")){let T=k.getAttribute("href");g=!!(M&&T&&Dt(T))&&(o?ct(T):T)}A(Bt(k),"ph-no-capture")&&(y=!0),p.push((function(T,O,B,U,q=!1){let K=T.tagName.toLowerCase(),F={tag_name:K};Zn.indexOf(K)>-1&&!B&&(F.$el_text=K.toLowerCase()==="a"||K.toLowerCase()==="button"?Ys(1024,so(T)):Ys(1024,wi(T)));let j=Bt(T);O||U?.includes("class")||0>=j.length||(F.classes=j.filter(function(ie){return ie!==""})),W(T.attributes,function(ie){var he;if((!Ht(T)||["name","id","class","aria-label"].indexOf(ie.name)!==-1)&&!U?.includes(ie.name)&&!O&&Dt(ie.value)&&(!D(he=ie.name)||he.substring(0,10)!=="_ngcontent"&&he.substring(0,7)!=="_nghost")){let ce=ie.value;ie.name==="class"&&(ce=Xn(ce).join(" ")),F["attr__"+ie.name]=Ys(1024,ie.name==="href"&&q?ct(ce):ce)}});let N=1,Y=1,z=T;for(;z=jh(z);)N++,z.tagName===T.tagName&&Y++;return F.nth_child=N,F.nth_of_type=Y,F})(k,i,s,n,o)),W((function(T){if(!wt(T))return{};let O={};return W(T.attributes,function(B){if(B.name&&B.name.indexOf("data-ph-capture-attribute")===0){let U=B.name.replace("data-ph-capture-attribute-",""),q=B.value;U&&q&&Dt(q)&&(O[U]=q)}}),O})(k),(T,O)=>{({}).hasOwnProperty.call(f,O)||(f[O]=T)})}),y)return{props:{},explicitNoCapture:y};if(d>0&&(e=c[d],p.splice(0,d)),s||(p[0].$el_text=ve(e,"a")||ve(e,"button")?so(e):wi(e)),g){var m,w;p[0].attr__href=g;let k=(m=Je(g))===null||m===void 0?void 0:m.host,M=b==null||(w=b.location)===null||w===void 0?void 0:w.host;k&&M&&k!==M&&(_=g)}return{props:Q((P=t.type,{$event_type:P,$ce_version:1}),r?{}:{$elements:p},{$elements_chain:($=p,I($)?(function(k){return k.map(M=>{var T,O;let B="";if(M.tag_name&&(B+=M.tag_name),M.attr_class){M.attr_class.sort();for(let K of M.attr_class)B+=`.${K.replace(/"/g,"")}`}let U=v(v(v(v({},M.text?{text:M.text}:{}),{},{"nth-child":(T=M.nth_child)!==null&&T!==void 0?T:0,"nth-of-type":(O=M.nth_of_type)!==null&&O!==void 0?O:0},M.href?{href:M.href}:{}),M.attr_id?{attr_id:M.attr_id}:{}),M.attributes),q={};return ji(U).sort(([K],[F])=>(function(j,N){return N>j?-1:j>N?1:0})(K,F)).forEach(([K,F])=>q[no(K.toString())]=no(F.toString())),B+=":",B+=ji(q).map(([K,F])=>`${K}="${F}"`).join(""),B}).join(";")})((function(k){return k.map(M=>{var T,O;let B={text:(T=M.$el_text)===null||T===void 0?void 0:T.slice(0,400),tag_name:M.tag_name,href:(O=M.attr__href)===null||O===void 0?void 0:O.slice(0,2048),attr_class:Vd(M),attr_id:M.attr__id,nth_child:M.nth_child,nth_of_type:M.nth_of_type,attributes:{}};return ji(M).filter(([U])=>U.indexOf("attr__")===0).forEach(([U,q])=>B.attributes[U]=q),B})})($)):"")},!((a=p[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=p[0])===null||l===void 0?void 0:l.$el_text}:{},_&&t.type==="click"?{$external_click_url:_}:{},f),target:e};var $,P}var Hh=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(e){var t;if(!wt(e))return!0;let i=(t=this.mo().css_selector_ignorelist)!==null&&t!==void 0?t:Is,s=new Set,n=e;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);let r=n,o=Bt(r);if(A(o,"ph-no-capture")||A(o,"ph-sensitive")||Ht(r)||i.some(l=>En(r,l)))return!0;let a=n.parentNode;n=Jn(a)?a.host:a&&De(a)?a:null}return!1}yo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.do();if(e.type==="pointerdown"){this.do();let s=hi(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&s&&De(s)&&(this.vo={target:s,excluded:this.po(s),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this.bo)===null||t===void 0?void 0:t.distinctId}))}let i=this.vo;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this.do():e.type==="pointerup"&&(i.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(e){var t;let i=this.vo;this.do();let s=hi(e);if(i?.released&&i.target.isConnected&&i.distinctId===((t=this.bo)===null||t===void 0?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(ve(s,"html")||ve(s,"body"))){var n;if(i.excluded)return null;let r=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:Is;return[s,E?.documentElement,E?.body].some(o=>{if(!o)return!1;let a=Bt(o);return A(a,"ph-no-capture")||A(a,"ph-sensitive")||!wt(o)||Ht(o)||r.some(l=>En(o,l))})?null:i.target}}constructor(e){this.wo=e,this.name=gc,this.ko=!1,this.So=null,this.xo=!1,this.$o=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Mr),this.rageclicks=new wc(this.Mr.rageclick),this.Io=null}setup(e){this.Mo(),this.bo=e;let t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?t.dispose():(this.Eo=t,this.startIfEnabled())}dispose(){var e;this.To||(this.To=!0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,this.$o.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Mr),this.Mr}Mo(){var e,t;return this.mo(),this.Mr.url_allowlist=(e=this.Mr.url_allowlist)===null||e===void 0?void 0:e.map(i=>new RegExp(i)),this.Mr.url_ignorelist=(t=this.Mr.url_ignorelist)===null||t===void 0?void 0:t.map(i=>new RegExp(i)),this.Mr}Ro(){if(!this.isBrowserSupported())return void Ws.info("Disabling Automatic Event Collection because this browser is not supported");if(!b||!E)return;let e=this.Ao=t=>{t=t||b?.event;try{if(t.type==="blur")return void this.do();if(t.type.indexOf("pointer")===0)return void this.yo(t);let i=t.type==="click"?this._o(t):void 0;if(ne(i))return;this.Fo(t,"$autocapture",i)}catch(i){Ws.error("Failed to capture event",i)}};if(G(b,"blur",e),G(E,"submit",e,{capture:!0}),G(E,"change",e,{capture:!0}),G(E,"click",e,{capture:!0}),W(["pointerdown","pointermove","pointerup","pointercancel"],t=>{G(E,t,e,{capture:!0})}),this.mo().capture_copied_text){let t=this.Oo=i=>{i=i||b?.event;try{this.Fo(i,Vs)}catch(s){Ws.error("Failed to capture clipboard event",s)}};G(E,"copy",t,{capture:!0}),G(E,"cut",t,{capture:!0}),G(E,"paste",t,{capture:!0})}}Po(){this.do(),this.Ao&&(b?.removeEventListener("blur",this.Ao),W(["pointerdown","pointermove","pointerup","pointercancel"],e=>{E?.removeEventListener(e,this.Ao,!0)}),E?.removeEventListener("submit",this.Ao,!0),E?.removeEventListener("change",this.Ao,!0),E?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(E?.removeEventListener("copy",this.Oo,!0),E?.removeEventListener("cut",this.Oo,!0),E?.removeEventListener("paste",this.Oo,!0),this.Oo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(e){if(this.To)return;if(this.xo=!0,!e.ok)return void this.startIfEnabled();let t=e.config;t.elementsChainAsString&&(this.Co=t.elementsChainAsString);let i=t.autocapture_opt_out;var s;xe(i)&&((s=this.bo)===null||s===void 0||s.kv.set("$autocapture_disabled_server_side",i),this.So=i),this.startIfEnabled()}setElementSelectors(e,t=this){if(this.To)return;e.size?this.$o.set(t,new Set(e)):this.$o.delete(t);let i=new Set;this.$o.forEach(s=>{s.forEach(n=>i.add(n))}),this.Io=i}getElementSelectors(e,t){var i;let s=[];return(i=this.Io)===null||i===void 0||i.forEach(n=>{let r=E?.querySelectorAll(n);r?.forEach(o=>{e!==o&&t!==o||A(s,n)||s.push(n)})}),s}get isEnabled(){var e,t;if(this.To)return!1;let i=(e=this.bo)===null||e===void 0?void 0:e.kv.get(el),s=this.So,n=this.mo();if(!n.remoteRequestsDisabled&&!this.xo)return!1;let r=n.remoteRequestsDisabled&&!this.xo;if(ne(s)&&!xe(i)&&!r)return!1;let o=(t=this.So)!==null&&t!==void 0?t:!!i;return!!n.enabled&&!o}Fo(e,t="$autocapture",i){if(!this.isEnabled)return void this.do();let s=i||hi(e);Pl(s)&&(s=s.parentNode||null);let 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()))&&Fl(s,n.rageclick)&&this.Fo(e,"$rageclick",i);let o=t===Vs,a=o?v(v({},n),{},{dom_event_allowlist:void 0}):n;if(s&&(function(h,d,p,f,_,g){var y;if(!b||er(h)||p?.url_allowlist&&!Kr(p.url_allowlist,g)||p?.url_ignorelist&&Kr(p.url_ignorelist,g))return!1;if(p?.dom_event_allowlist){let P=p.dom_event_allowlist;if(P&&!P.some(k=>d.type===k))return!1}let{parentIsUsefulElement:m,targetElementList:w}=Il(h,f);if(!(function(P,k){let M=k?.element_allowlist;if(x(M))return!0;for(let T of P)if(M.some(O=>T.tagName.toLowerCase()===O))return!0;return!1})(w,p)||!$n(w,p?.css_selector_allowlist)||$n(w,(y=p?.css_selector_ignorelist)!==null&&y!==void 0?y:Is))return!1;try{let P=b.getComputedStyle(h);if(P&&P.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0}catch{}let $=h.tagName.toLowerCase();switch($){case"html":return!1;case"form":return(_||["submit"]).indexOf(d.type)>=0;case"input":case"select":case"textarea":return(_||["change","click"]).indexOf(d.type)>=0;default:return m?(_||["click"]).indexOf(d.type)>=0:(_||["click"]).indexOf(d.type)>=0&&(Zn.indexOf($)>-1||h.getAttribute("contenteditable")==="true")}})(s,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l;let{props:h,explicitNoCapture:d,target:p}=Bh(s,{e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(d)return!1;let f=this.getElementSelectors(s,p);if(f&&f.length>0&&(h.$element_selectors=f),t===Vs){let _=e.type||"clipboard";if(_!=="paste"){var c,u;let g=b==null||(c=b.getSelection())===null||c===void 0?void 0:c.toString(),y=Tl(g);if(!y)return!1;h.$selected_content=y,h.$clipboard_text_length=(u=g?.length)!==null&&u!==void 0?u:0}h.$copy_type=_}return(l=this.bo)===null||l===void 0||l.capture(t,h),!0}}isBrowserSupported(){return oe(E?.querySelectorAll)}},Uh=class{constructor(e){this._instance=e}refresh(e){let t=this._instance.config,i=L(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.il(),e.url_allowlist=i?.url_allowlist,e.url_ignorelist=i?.url_ignorelist,e.dom_event_allowlist=i?.dom_event_allowlist,e.element_allowlist=i?.element_allowlist,e.css_selector_allowlist=i?.css_selector_allowlist,e.css_selector_ignorelist=i?.css_selector_ignorelist,e.element_attribute_ignorelist=i?.element_attribute_ignorelist,e.capture_copied_text=i?.capture_copied_text}},ii=te("[ExceptionAutocapture]"),Po=()=>{},To=e=>{var t;if(oe(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function Gt(e,t,i){try{if(!(t in e))return Po;let s={next:e[t]},n=i(function(...r){return s.next.apply(this,r)});return oe(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=s.next);let r=e[t],o=To(r);for(;o;){if(o.next===n)return void(o.next=s.next);r=o.next,o=To(r)}}}catch{return Po}}var qh=te("[TracingHeaders]"),pt=te("[Web Vitals]"),Mo=9e5,Oo=["CLS","FCP","INP","LCP"],zh=["INP","LCP"],Gh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Ks="disabled",Fo="lazy_loading",ze=te("[SessionRecording]"),Vh=[Gn,Vn,vl,fl,gl,_l,ml,yl,bl],Wh=te("[Heatmaps]");function Js(e){return L(e)&&"clientX"in e&&"clientY"in e&&re(e.clientX)&&re(e.clientY)}var Ai=te("[Product Tours]"),Xs=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(qn))},Yh=["$set_once","$set"],je=te("[SiteApps]"),Io="Error while initializing PostHog app with config id ",sr=(e,t)=>e?.then?e.then(t):t(e),Mt="SDK is not enabled or survey functionality is not yet loaded",Ao="Disabled. Not loading surveys.",Kh=class{constructor(e,t){this.wo=e,this.Cc=t,this.name=yc,this._surveyEventReceiver=null,this._surveyManager=null,this.Tc=!1,this.Ic=!1,this.Mc=[],this.Ec=[],this.Pc=null,this.Rc=null,this.To=!1,this.Ac=new Set,this.onRemoteConfig=i=>{if(this.To||this.Mr.disableSurveys)return;if(!i.ok)return this.Ic=!0,this.Fc({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),V.warn("Remote config unavailable. Not loading surveys.");let s=i.config.surveys;if(R(s))return V.warn("Flags not loaded yet. Not loading surveys.");this.Oc=xe(s)?s:s.length>0,V.info(`flags response received, isSurveysEnabled: ${this.Oc}`),this.loadIfEnabled()},this.Fc=i=>{this.Ec.slice().forEach(s=>this.Dc(s,i))}}setup(e){if(!this.To)return this.Lc=e,sr(e.kv.initialize(),()=>{if(this.Lc!==e||this.To)return;this.Lc=void 0,this.bo=e;let t=e.onRemoteConfig(this.onRemoteConfig);this.To?t.dispose():(this.Eo=t,this.loadIfEnabled())})}dispose(){var e,t,i,s,n;this.To||(this.To=!0,this.Lc=void 0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,(t=this._surveyEventReceiver)===null||t===void 0||t.dispose(),this._surveyEventReceiver=null,(i=this._surveyManager)===null||i===void 0||(s=i.dispose)===null||s===void 0||s.call(i),this._surveyManager=null,this.Mc=[],this.Ec.forEach(r=>{r.active=!1}),this.Ec=[],(n=this.Nc)===null||n===void 0||n.call(this),this.Nc=void 0,this.Pc=null,this.Ac.forEach(r=>clearTimeout(r)),this.Ac.clear())}get Mr(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.clearInMemoryInProgressSurveyState)===null||t===void 0||t.call(e);try{var i;(i=this._surveyEventReceiver)===null||i===void 0||i.reset(),localStorage.removeItem("lastSeenSurveyDate");let s=[];for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);(r?.startsWith("seenSurvey_")||r?.startsWith("inProgressSurvey_"))&&s.push(r)}s.forEach(n=>localStorage.removeItem(n))}catch{}this.Fc()}loadIfEnabled(){if(this.To||!this.bo)return;let e=this.Mr;if(this._surveyManager)return;if(this.Tc)return void V.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void V.info(Ao);if(e.cookielessMode&&this.wo.isOptedOut())return void V.info("Not loading surveys in cookieless mode without consent.");let t=this.wo.getExtensions();if(!t)return void this.qc("PostHog Extensions not found.");if(x(this.Oc)&&!e.advancedEnableSurveys)return;let i=this.Oc||e.advancedEnableSurveys;this.Tc=!0,this.Ic=!1;try{let s=t.generateSurveys;if(s)return this.jc(s,i),void(this.Tc=!1);let n=t.loadExternalDependency;if(!n)return this.qc(Wn),void(this.Tc=!1);n(r=>{try{if(this.To)return;let o=this.wo.getExtensions();r||!o?.generateSurveys?this.qc("Could not load surveys script",r):this.jc(o.generateSurveys,i)}finally{this.Tc=!1}})}catch(s){throw this.Tc=!1,this.qc("Error initializing surveys",s),s}}jc(e,t){var i,s;if(this.To)return;this._surveyManager=e(t),this._surveyEventReceiver=this.wo.createEventReceiver(this.Fc);let n=(i=(s=this.bo)!==null&&s!==void 0?s:this.Cc)===null||i===void 0?void 0:i.kv.get(ni);n&&this.Bc(n),V.info("Surveys loaded successfully"),this.zc(),this.Fc(),this.Hc({isLoaded:!0})}qc(e,t){this.Ic=!0,V.error(e,t),this.Fc({isLoaded:!1,error:e}),this.Hc({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Mc.push(e),this._surveyManager&&this.Hc({isLoaded:!0}),()=>{this.Mc=this.Mc.filter(t=>t!==e)}}getSurveys(e,t=!1){var i;let s=(i=this.bo)!==null&&i!==void 0?i:this.Cc;if(!s||this.To)return;if(this.Mr.disableSurveys)return V.info(Ao),e([]);let n=s.kv.get(ni);if(n&&!t)return e(n,{isLoaded:!0}),void(this.Uc()&&this.getSurveys(()=>{},!0));if(this.Pc)return void this.Pc.then(({surveys:a,context:l})=>{this.To||e(a,l)}).catch(a=>V.error("Error in survey callback",a));let r=this.Wc("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(a=>{try{return this.Vc(s,a)}catch(l){return V.error("Error processing surveys response",l),this.Vc(s,{statusCode:0,error:l})}},a=>this.Vc(s,{statusCode:0,error:a}));this.Pc=r;let o=()=>{this.Pc===r&&(this.Pc=null)};r.then(a=>{o(),this.To||(this.Fc(a.context),e(a.surveys,a.context))},o).catch(a=>V.error("Error in survey callback",a))}Wc(e,t){let i=this.bo;return i?i.sendRequest(e,t):new Promise(s=>s({statusCode:0,error:new Error(Mt)}))}Vc(e,t){if(this.To)return{surveys:[],context:{isLoaded:!1,error:Mt}};let i=t.statusCode;if(i!==200||!t.json){let n=`Surveys API could not be loaded, status: ${i}`;return i!==0?V.error(n):t.error||V.warn(n),this.Rc=Date.now(),{surveys:[],context:{isLoaded:!1,error:n}}}this.Rc=null;let s=t.json.surveys||[];return e.kv.set({[ni]:s,[Qi]:Date.now()}),this.Bc(s),{surveys:s,context:{isLoaded:!0}}}Bc(e){var t;let i=e.filter(s=>(function(n){return!(!n.start_date||n.end_date)})(s)&&(hc(s)||(function(n){var r;return!!(!((r=n.conditions)===null||r===void 0||(r=r.actions)===null||r===void 0||(r=r.values)===null||r===void 0)&&r.length)})(s)));(t=this._surveyEventReceiver)===null||t===void 0||t.replace(i)}Uc(){return this.Gc()&&!this.Pc&&!this.Qc()}Gc(){var e,t;let i=(e=(t=this.bo)!==null&&t!==void 0?t:this.Cc)===null||e===void 0?void 0:e.kv.get(Qi);return re(i)&&Date.now()-i>3e5}Qc(){return re(this.Rc)&&3e5>Date.now()-this.Rc}markSurveyAsSeen(e,t){var i;let s={id:e,current_iteration:(i=t?.iteration)!==null&&i!==void 0?i:null};fc(s);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Fc()}Hc(e){for(let t of this.Mc)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){V.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t=!1){if(!R(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);V.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t,i;if(this.To)return()=>{};let s={callback:e,active:!0,revision:0};this.Ec.push(s),this.zc();let n=(t=(i=this.bo)!==null&&i!==void 0?i:this.Cc)===null||t===void 0?void 0:t.kv.get(ni);return this.Mr.disableSurveys||!this._surveyManager&&this.Ic&&!this.Tc||!n&&!R(this.Rc)&&!this.Pc?this.Dc(s,{isLoaded:!1}):this._surveyManager&&this.Dc(s),()=>{var r;s.active=!1,this.Ec=this.Ec.filter(o=>o!==s),this.Ec.length===0&&((r=this.Nc)===null||r===void 0||r.call(this),this.Nc=void 0)}}zc(){var e,t,i;this._surveyManager&&this.Ec.length>0&&((e=this.Nc)!==null&&e!==void 0||(this.Nc=(t=(i=this.wo).onMatchingConditionsChanged)===null||t===void 0?void 0:t.call(i,this.Fc)))}Dc(e,t){if(this.To||!e.active)return;let i=++e.revision,s=n=>{if(!this.To&&e.active&&i===e.revision)try{let r=t??{isLoaded:!0},o=JSON.stringify([n,r]);if(o===e.lastResult)return;e.lastResult=o,e.callback(n,r)}catch(r){V.error("Error in active matching surveys callback",r)}};try{t&&!t.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(n){V.error("Error in active matching surveys callback",n)}}Zc(e){let t=null;return this.getSurveys(i=>{var s;t=(s=i.find(n=>n.id===e))!==null&&s!==void 0?s:null}),t}Jc(e){if(R(this._surveyManager))return{eligible:!1,reason:Mt};let t=typeof e=="string"?this.Zc(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Kc(e){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(R(this._surveyManager))return{eligible:!1,reason:Mt};let t=typeof e=="string"?this.Zc(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(R(this._surveyManager))return V.warn("init was not called"),{visible:!1,disabledReason:Mt};let t=this.Kc(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return R(this._surveyManager)?(V.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Mt})):new Promise(i=>{this.getSurveys(s=>{var n;let r=(n=s.find(o=>o.id===e))!==null&&n!==void 0?n:null;if(r){let o=this.Kc(r);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s;if(!this.wo.isCapturing())return;if(R(this._surveyManager))return void V.warn("init was not called");let n=typeof e=="string"?this.Zc(e):e;if(!n?.id)return void V.warn("Survey not found");if(!$h.includes(n.type))return void V.warn(`Surveys of type ${n.type} cannot be rendered in the app`);let r=E?.querySelector(t);if(r){if(!((s=n.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds){V.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);let o=setTimeout(()=>{var a,l;this.Ac.delete(o),!this.To&&this.wo.isCapturing()&&(V.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,i),V.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.Ac.add(o)}this._surveyManager.renderSurvey(n,r,i)}else V.warn("Survey element not found")}displaySurvey(e,t){var i;if(!this.wo.isCapturing())return;if(R(this._surveyManager))return void V.warn("init was not called");let s=this.Zc(e);if(!s)return void V.warn("Survey not found");let n=s;if(!((i=s.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=v(v({},s),{},{appearance:v(v({},s.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==Sn.Popover&&t.initialResponses&&V.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){let r=this.Jc(s);if(!r.eligible)return void V.warn("Survey is not eligible to be displayed: ",r.reason)}t.displayType!==Sn.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}cancelPendingSurvey(e){R(this._surveyManager)?V.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 Ot(e,t,i){if(R(e))return!1;switch(i){case"exact":return e===t;case"contains":{let s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Jh=class{constructor(e){this._instance=e,this.Xc=new Set,this.Yc=new Set,this.th=new os,this.eh=(t,i)=>this.ih(t,i)&&this.nh(t,i)&&this.sh(t,i)&&this.rh(t,i),this.ih=(t,i)=>!i?.event||t?.event===i?.event}init(){var e,t;x((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.oh=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook((i,s)=>{this.on(i,s)}))}dispose(){var e,t;(e=this.oh)===null||e===void 0||e.call(this),this.oh=void 0,(t=this._instance)===null||t===void 0||(t=t.autocapture)===null||t===void 0||t.setElementSelectors(new Set,this),this.th=new os}register(e){var t,i;if(!x((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(s=>{var n;this.Xc.add(s),(n=s.steps)===null||n===void 0||n.forEach(r=>{this.Yc.add(r?.event||"")})}),(i=this._instance)===null||i===void 0?void 0:i.autocapture)){let s=new Set;this.Xc.forEach(n=>{var r;(r=n.steps)===null||r===void 0||r.forEach(o=>{o?.selector&&s.add(o.selector)})}),this._instance.autocapture.setElementSelectors(s,this)}}replace(e){this.Xc.clear(),this.Yc.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Yc.has(e)||this.Yc.has(t.event))&&this.Xc.forEach(i=>{this.ah(t,i)&&this.th.emit("actionCaptured",i.name)})}uh(e){this.onAction("actionCaptured",t=>e(t))}ah(e,t){if(t?.steps==null)return!1;for(let i of t.steps)if(this.eh(e,i))return!0;return!1}onAction(e,t){return this.th.on(e,t)}nh(e,t){if(t?.url){var i;let s=e==null||(i=e.properties)===null||i===void 0?void 0:i.$current_url;if(!s||typeof s!="string"||!Ot(s,t.url,t.url_matching||"contains"))return!1}return!0}sh(e,t){return!!this.hh(e,t)&&!!this.dh(e,t)&&!!this.fh(e,t)}hh(e,t){var i;if(!t?.href)return!0;let s=this.ph(e);if(s.length>0)return s.some(r=>Ot(r.href,t.href,t.href_matching||"exact"));let n=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";return!!n&&Ot((function(r){let o=r.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(n),t.href,t.href_matching||"exact")}dh(e,t){var i;if(!t?.text)return!0;let s=this.ph(e);if(s.length>0)return s.some(l=>Ot(l.text,t.text,t.text_matching||"exact")||Ot(l.$el_text,t.text,t.text_matching||"exact"));let n=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";return!!n&&(r=(function(l){let c=[],u=/(?::|")text="(.*?)"/g,h;for(;!R(h=u.exec(l));)c.includes(h[1])||c.push(h[1]);return c})(n),o=t.text,a=t.text_matching||"exact",r.some(l=>Ot(l,o,a)));var r,o,a}fh(e,t){var i,s;if(!t?.selector)return!0;let n=e==null||(i=e.properties)===null||i===void 0?void 0:i.$element_selectors;if(n?.includes(t.selector))return!0;let r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch{return!1}return!1}ph(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e?.properties.$elements}rh(e,t){return!t?.properties||t.properties.length===0||vc(t.properties.reduce((i,s)=>{let n=I(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return i[s.key]={values:n,operator:s.operator||"exact"},i},{}),e?.properties)}},Xh=class{constructor(e,t){var i,s;this.gh=[],this._instance=e,this.mh=t,this.yh=new Map,this.bh=new Map,this._h=new Map,this.wh=(i=this._instance)===null||i===void 0||(s=i.onSessionId)===null||s===void 0?void 0:s.call(i,n=>this.kh(n))}Sh(e){return!1}xh(){return null}$h(e){}Ch(){}Th(e,t){return!!e&&vc(e.propertyFilters,t?.properties)}Ih(e,t){let i=new Map;return e.forEach(s=>{var n;(n=s.conditions)===null||n===void 0||(n=n[t])===null||n===void 0||(n=n.values)===null||n===void 0||n.forEach(r=>{if(r?.name){let o=i.get(r.name)||[];o.push(s.id),i.set(r.name,o)}})}),i}Mh(e,t,i){let s=(i===Qt.Activation?this.yh:this.bh).get(e),n=[];return this.Eh(r=>{n=r.filter(o=>s?.includes(o.id))}),n.filter(r=>{var o;let a=(o=r.conditions)===null||o===void 0||(o=o[i])===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.find(l=>l.name===e);return this.Th(a,t)})}register(e){this.Ph(e,!1)}replace(e){this.Ph(e,!0)}Ph(e,t){var i;x((i=this._instance)===null||i===void 0?void 0:i._addCaptureHook)||(this.Rh(e,t),this.Ah(e,t))}Ah(e,t){let i=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 s;if(t&&this._h.clear(),i.length===0)return void(t&&((s=this.Fh)===null||s===void 0||s.replace([])));this.Fh||(this.Fh=new Jh(this._instance),this.Fh.init(),this.Fh.uh(r=>this.onAction(r)));let n=[];i.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;let c=(l=this._h.get(a.name))!==null&&l!==void 0?l:[];c.includes(r.id)||c.push(r.id),this._h.set(a.name,c)}})}),t?this.Fh.replace(n):this.Fh.register(n)}Oh(e,t){t.forEach((i,s)=>{var n;let r=(n=e.get(s))!==null&&n!==void 0?n:[];i.forEach(o=>{r.includes(o)||r.push(o)}),e.set(s,r)})}Rh(e,t){var i,s;let n=e.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.events)&&((u=l.conditions)===null||u===void 0||(u=u.events)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),r=e.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.cancelEvents)&&((u=l.conditions)===null||u===void 0||(u=u.cancelEvents)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),o=this.Ih(e,Qt.Activation),a=this.Ih(e,Qt.Cancellation);t?(this.yh=o,this.bh=a):(this.Oh(this.yh,o),this.Oh(this.bh,a)),(n.length!==0||r.length!==0||e.some(l=>{var c;return(c=l.conditions)===null||c===void 0||(c=c.actions)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length}))&&((i=this.oh)!==null&&i!==void 0||(this.oh=(s=this._instance)===null||s===void 0?void 0:s._addCaptureHook((l,c)=>{this.onEvent(l,c)})))}onEvent(e,t){var i,s;let n=this.Dh(),r=(t==null||(i=t.properties)===null||i===void 0?void 0:i.$survey_id)||(t==null||(s=t.properties)===null||s===void 0?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){let a=this.Lh(e,r,t);if(a==="consume")return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this.Nh([r]);if(a==="persist")return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this.qh(r),void this.jh([r])}if(this.bh.has(e)){let a=this.Mh(e,t,Qt.Cancellation);a.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(l=>l.id)}),this.Nh(a.map(l=>l.id)),a.forEach(l=>this.Bh(l.id)))}if(!this.yh.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this.yh.get(e)});let o=this.Mh(e,t,Qt.Activation);this.zh(o.map(a=>a.id))}onAction(e){this._h.has(e)&&this.zh(this._h.get(e)||[])}zh(e){var t,i;if(e.length===0)return;let s=!!(!((t=this._instance)===null||t===void 0||(i=t.get_session_id)===null||i===void 0)&&i.call(t)),n=[];for(let r of e)s&&this.Sh(r)?this.qh(r)&&this.Hh(r):n.push(r);n.length>0&&(this.gh=[...new Set([...this.gh,...n])]),this.Dh().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Uh()}qh(e){this.gh=this.gh.filter(i=>i!==e);let t=this.Wh();return!t.includes(e)&&(this.Vh([...t,e]),this.Gh(),!0)}Nh(e){let t=new Set(e);this.gh=this.gh.filter(n=>!t.has(n));let i=this.Qh(),s=i.filter(n=>!t.has(n));s.length!==i.length&&(this.Vh(s),s.length===0&&this.Zh()),this.jh(e),this.Uh()}Uh(){try{var e;(e=this.mh)===null||e===void 0||e.call(this)}catch(t){this.Dh().error("Error while handling activated items change",t)}}Jh(){var e;let t=this.xh();if(!t)return{};let i=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t];return i&&typeof i=="object"?i:{}}Hh(e){if(!this.xh())return;let t=this.Jh();this.$h(v(v({},t),{},{[e]:Date.now()}))}jh(e){if(!this.xh())return;let t=this.Jh(),i={},s=!1;for(let[n,r]of Object.entries(t))e.includes(n)?s=!0:i[n]=r;s&&(Se(i)?this.Ch():this.$h(i))}Kh(){this.xh()&&this.Ch()}getActivationTimestamp(e){if(!this.Wh().includes(e))return;let t=this.Jh()[e];return re(t)?t:void 0}Qh(){var e;let t=this.Xh();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t])||[]}Wh(){var e,t,i;let s=this.Qh();if(s.length===0)return[];let n=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.Yh()],r=(t=this._instance)===null||t===void 0||(i=t.get_session_id)===null||i===void 0?void 0:i.call(t);return r&&n===r?s:[]}Gh(){var e,t;let i=(e=this._instance)===null||e===void 0||(t=e.get_session_id)===null||t===void 0?void 0:t.call(e);i&&this.td(i)}Zh(){this.ed()}kh(e){var t;let i=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.Yh()];if(i&&i!==e){let s=this.Qh(),n=this.Jh();s.length>0&&(this.Vh([]),s.filter(r=>re(n[r])).forEach(r=>this.Bh(r))),this.Zh(),this.Kh(),s.length>0&&this.Uh()}}getActivatedIds(){return[...new Set([...this.Wh(),...this.gh])].filter(e=>!this.nd(e))}dispose(){var e,t,i;(e=this.wh)===null||e===void 0||e.call(this),this.wh=void 0,(t=this.oh)===null||t===void 0||t.call(this),this.oh=void 0,(i=this.Fh)===null||i===void 0||i.dispose(),this.Fh=void 0}reset(){this.gh=[],this.Qh().length>0&&this.Vh([]),this.Zh(),this.Kh(),this.Uh()}getEventToItemsMap(){return this.yh}sd(){return this.Fh}},Zh=class extends Xh{constructor(e,t){super(e,t)}Xh(){return ol}Yh(){return al}xh(){return ll}$h(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_timestamps:e})}Ch(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}Sh(e){var t;let i;this.Eh(n=>{i=n.find(r=>r.id===e)});let s=i==null||(t=i.appearance)===null||t===void 0?void 0:t.surveyPopupDelaySeconds;return re(s)&&s>0}rd(){return Te.SHOWN}Eh(e){var t;(t=this._instance)===null||t===void 0||t.getSurveys(e)}Bh(e){var t;(t=this._instance)===null||t===void 0||t.cancelPendingSurvey(e)}Dh(){return V}Vh(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated:e})}td(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_session:e})}ed(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}nd(){return!1}Lh(e,t,i){var s;if(e===Te.SENT&&(i==null||(s=i.properties)===null||s===void 0?void 0:s.$survey_completed)===!1)return"ignore";let n;return this.Eh(r=>{n=r.find(o=>o.id===t)}),!n||(function(r){var o;return hc(r)&&!!(!((o=r.conditions)===null||o===void 0||(o=o.events)===null||o===void 0)&&o.repeatedActivation)||r.schedule==="always"})(n)?e===Te.SHOWN?"consume":"ignore":e===Te.SHOWN?"persist":e===Te.DISMISSED||e===Te.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Qh=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);let t={};for(let i of e){let s=this._instance.get_property(i);x(s)||(t[i]=s)}return t}set(e,t){this._instance.register(typeof e=="string"?{[e]:t}:e)}remove(e){typeof e!="string"?e.forEach(t=>this._instance.unregister(t)):this._instance.unregister(e)}},ep=class{constructor(e){this._instance=e}get(){let e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){let e=C?.__PosthogExtensions__;if(!e)return;let{generateSurveys:t,loadExternalDependency:i}=e;return{generateSurveys:t?s=>t(this._instance,s):void 0,loadExternalDependency:i?s=>i(this._instance,"surveys",s):void 0}}createEventReceiver(e){return new Zh(this._instance,e)}onMatchingConditionsChanged(e){let t=this._instance._addCaptureHook(r=>{r!=="$pageview"&&r!==Te.SHOWN&&r!==Te.DISMISSED&&r!==Te.SENT||e()}),i=()=>e();G(b,"PHSurveyShown",i);let s=!1,n=this._instance.onFeatureFlags(()=>{s&&e()});return s=!0,()=>{s=!1,t(),n(),b?.removeEventListener("PHSurveyShown",i)}}},tp=b?.location?is(b.location.hash,"__posthog")||is(location.hash,"state"):null,Co="_postHogToolbarParams",Ro=te("[Toolbar]"),Lo=te("[FeatureFlags]"),vt=te("[FeatureFlags]",{debugEnabled:!0}),Zs=`" failed. Feature flags didn't load in time.`,ip=[502,504],Do=["click","keydown","wheel","touchstart","pointerdown"],No="connection_error",jo=e=>{let t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},Bo=e=>{let t={};for(let[i,s]of ji(e||{}))s&&(t[i]=s);return t},sp=class{constructor(e){this.name="featureFlags",this.od=!1,this.featureFlagEventHandlers=[],this.A=Lo,this.ad={},this.ld={},this.ud=[],this.hd=new Set,this.dd=new Set,this.vd=!1,this.fd=!1,this.pd=0,this.gd=!1,this.md=!1,this.yd=!1,this.bd=!1,this._d=0,this.wd=!1,this.rn=()=>{let t=this.kd();this._d=0,t&&this.reloadFeatureFlags()},this.Sd=()=>{var t,i;let s=this.xd,n=(t=this.$d)!==null&&t!==void 0?t:s;x(s)||x(n)||this.Mr.remoteRequestsDisabled||!this.Cd||this.Cd.visibilityState==="hidden"||Date.now()-((i=this.Td)!==null&&i!==void 0?i:0)<n||(this.$d=this.wd||!this.Mr.idleRefreshBackoff?s:Math.min(2*n,36e5),this.wd=!1,this.reloadFeatureFlags(),this.Id())},this.Md=()=>{this.wd&&this.$d===this.xd||this.Ed()},this.sn=()=>{var t;((t=this.Cd)===null||t===void 0?void 0:t.visibilityState)==="visible"&&this.Ed()},this.wo=e}get Pd(){}Rd(){this.bo&&this.Ad()}setup(e){try{this.Fd=typeof window>"u"?void 0:window,this.Cd=typeof document>"u"?void 0:document}catch{this.Fd=void 0,this.Cd=void 0}return this.Lc=e,this.A=e.logger.createLogger("[FeatureFlags]"),sr(e.kv.initialize(),()=>{this.Lc===e&&(this.Lc=void 0,this.bo=e,this.Od(e))})}Od(e){var t;if(this.bo===e)return this.Fd&&G(this.Fd,"online",this.rn),this.Ad(),this.Dd=e.registerDynamicEventProperties(()=>this.Ld()?this.ad:this.ld),this.Nd=(t=this.Pd)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.qd(),this.jd(),this.Bd()}),this.jd(),this.initialize()}Ed(){this.wd=!0,this.$d=this.xd,this.Sd()}Ad(){var e;let t=this.Mr.refreshIntervalMs,i=!this.Mr.remoteRequestsDisabled&&this.Cd&&!x(t)&&t>0?t:void 0;this.Mr.idleRefreshBackoff||(this.$d=i),i!==this.xd&&(this.zd(),x(i)||(this.xd=i,this.$d=i,this.Id(),!((e=this.Cd)===null||e===void 0)&&e.addEventListener&&(G(this.Cd,bi,this.sn),At(Do,s=>{G(this.Cd,s,this.Md,{capture:!0})}))))}Id(){x(this.xd)||(x(this.Hd)||clearInterval(this.Hd),this.Td=Date.now(),this.Hd=setInterval(this.Sd,this.xd))}zd(){var e,t;x(this.Hd)||(clearInterval(this.Hd),this.Hd=void 0,(e=this.Cd)===null||e===void 0||(t=e.removeEventListener)===null||t===void 0||t.call(e,"visibilitychange",this.sn),At(Do,i=>{var s,n;(s=this.Cd)===null||s===void 0||(n=s.removeEventListener)===null||n===void 0||n.call(s,i,this.Md,{capture:!0})})),this.xd=void 0,this.$d=void 0,this.wd=!1,this.Td=void 0}destroy(){this.Ud()}dispose(){this.Ud()}Ud(){var e,t,i;this.zd(),this.pd++,this.md=!1,this.Lc=void 0,this.Wd(this.hd,"cancelled"),this.Wd(this.dd,"cancelled"),this.bo&&(this.Vd(),(e=this.Dd)===null||e===void 0||e.dispose(),this.Dd=void 0,(t=this.Nd)===null||t===void 0||t.call(this),this.Nd=void 0,this.ud=[],(i=this.Fd)===null||i===void 0||i.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Gd(e){var t;return this.Qd&&e in this.Qd?this.Qd[e]:(t=this.bo)===null||t===void 0?void 0:t.kv.get(e)}qd(){return!!this.Qd&&(this.Qd=void 0,!0)}Zd(){var e;return!x((e=this.bo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.qd()}$t(e){this.Jd(()=>{var t;return(t=this.bo)===null||t===void 0?void 0:t.kv.set(e)})}Kd(e,t,i){if(!this.Pd||!e.$enabled_feature_flags)return;let s=this.Gd("$enabled_feature_flags")||{},n=e.$enabled_feature_flags||{},r=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,g])=>!g?.failed).map(([g])=>g):[],a=!!t.errorsWhileComputingFlags&&!!t.flags,l=a?o:i&&!I(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),c=this.Gd("$feature_flag_payloads")||{},u=e.$feature_flag_payloads||{},h=a||i?l:Array.from(new Set([...Object.keys(c),...Object.keys(u)])),d=!a&&!i,p=!!d||l,f=!!d||h,_={[We]:p,[Re]:p,[at]:f};e.$feature_flag_details&&(_[yt]=p);for(let g of[bt,lt,li])x(e[g])||(_[g]=!0);this.Pd.markCrossTabFeatureFlagChanges(_)}Pt(e){this.Jd(()=>{var t;return(t=this.bo)===null||t===void 0?void 0:t.kv.remove(e)})}Jd(e){try{e()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}jd(){let e={};for(let s of[We,at,bt,Be]){let n=this.Gd(s);x(n)||(e[s]=n)}this.ad=e;let t=v({},e),i=this.Gd(Re);if(i)for(let[s,n]of Object.entries(i))t[`$feature/${s}`]=n;this.ld=t}Ld(){let e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;let t=this.Gd(lt);return typeof t!="number"||Date.now()-t>e}Xd(){return!!this.Ld()&&(this.bd||this.fd||(this.bd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Yd(){let e=this.Mr.evaluationContexts;return e?.length?e.filter(t=>{let i=t&&typeof t=="string"&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}tv(){let e=this.Mr.flagKeys;if(!x(e))return e.filter(t=>{let i=t&&typeof t=="string"&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var e,t;let i=this.Mr,s=(e=(t=i.bootstrap)===null||t===void 0?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(s).length){var n,r;let o=(n=(r=i.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads)!==null&&n!==void 0?n:{},a=Object.keys(s).filter(c=>!x(s[c])).reduce((c,u)=>(c[u]=s[u],c),{}),l=Object.keys(o).filter(c=>a[c]).reduce((c,u)=>(c[u]=o[u],c),{});return this.ev({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,i){var s,n;let r=i?.merge&&(s=this.Gd("$enabled_feature_flags"))!==null&&s!==void 0?s:{},o=i?.merge&&(n=this.Gd("$feature_flag_payloads"))!==null&&n!==void 0?n:{},a=v(v({},r),e),l=v(v({},o),t),c={};for(let[u,h]of Object.entries(a))c[u]={key:u,enabled:Or(h),variant:Fr(h),reason:void 0,metadata:x(l?.[u])?void 0:{id:0,version:void 0,description:void 0,payload:l[u]}};this.ev({flags:c})}get hasLoadedFlags(){return this.vd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let e=this.Gd(yt),t=this.Gd(Be),i=this.Gd(_t);if(!i&&!t)return e||{};let s=Q({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(let a of n){var r,o;let l=s[a],c=t?.[a],u=x(c)?(r=l?.enabled)!==null&&r!==void 0&&r:!!c,h=x(c)?l?.variant:typeof c=="string"?c:void 0,d=i?.[a],p=v(v({},l),{},{enabled:u,variant:u?h??l?.variant:void 0});u!==l?.enabled&&(p.original_enabled=l?.enabled),h!==l?.variant&&(p.original_variant=l?.variant),d&&(p.metadata=v(v({},l?.metadata),{},{payload:d,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),s[a]=p}return this.od||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this.od=!0),s}getAllFeatureFlags(){let e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{let s=e[i];return{key:i,enabled:Or(s),variant:Fr(s),payload:Mr(t[i])}})}getFlagVariants(){let e=this.Gd(Re),t=this.Gd(Be);if(!t)return e||{};let i=Q({},e||{}),s=Object.keys(t);for(let n=0;s.length>n;n++)i[s[n]]=t[s[n]];return this.od||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.od=!0),i}getFlagPayloads(){let e=this.Gd(at),t=this.Gd(_t);if(!t)return e||{};let i=Q({},e||{}),s=Object.keys(t);for(let n=0;s.length>n;n++)i[s[n]]=t[s[n]];return this.od||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.od=!0),i}reloadFeatureFlags(){this.gd||this.Mr.featureFlagsDisabled||this.kd()||(this.fd&&(this.md=!0),this.iv||(this.ud.slice().forEach(e=>{try{e()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.iv=setTimeout(()=>{this.nv()},5)))}reloadFeatureFlagsAsync(){return!this.bo||this.gd||this.Mr.featureFlagsDisabled||this.Mr.remoteRequestsDisabled||this.kd()?Promise.resolve({status:"skipped"}):new Promise(e=>{this.hd.add(e),this.reloadFeatureFlags()})}Wd(e,t){e.forEach(i=>i({status:t})),e.clear()}Vd(){clearTimeout(this.iv),this.iv=void 0}onReloading(e){return this.ud.push(e),()=>{this.ud=this.ud.filter(t=>t!==e)}}ensureFlagsLoaded(){this.vd||this.fd||this.iv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.gd=e}resetFlagCallReported(){this.Pt(ot)}nv(e){var t;this.Vd();let i=this.bo;if(!i||this.Mr.remoteRequestsDisabled||this.kd())return void this.Wd(this.hd,"skipped");if(this.fd)return void(this.md=!0);let s={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:v(v(v({},i.initialPersonProperties),this.Gd("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.Gd(nt),timezone:Ll()};x(i.deviceId)||(s.$device_id=i.deviceId),(e?.disableFlags||this.Mr.featureFlagsDisabled)&&(s.disable_flags=!0);let n=this.Yd();n.length&&(s.evaluation_contexts=n);let r=this.tv();x(r)||(s.flag_keys=r);let o=this.Mr.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.pd,c=this.hd;this.hd=new Set,this.dd=c,this.fd=!0;let u=()=>{this.md&&(this.md=!1,this.nv())},h=g=>{var y,m;let w=(y=g.json)!==null&&y!==void 0?y:{},$=g.statusCode!==200;if(this.fd=!1,l!==this.pd)return void u();if(this.sv(g.statusCode),$||this.md||(this.$anon_distinct_id=void 0),s.disable_flags&&!this.md)return void this.Wd(c,"skipped");this.yd=!$;let P=[];g.error?P.push(g.error instanceof Error&&g.error.name==="AbortError"?"timeout":g.error instanceof Error?No:"unknown_error"):g.statusCode!==200&&P.push(`api_error_${g.statusCode}`),w.errorsWhileComputingFlags&&P.push("errors_while_computing_flags");let k=!!(!((m=w.quotaLimited)===null||m===void 0)&&m.includes("feature_flags"));k&&P.push("quota_limited"),this.$t({[yi]:P}),k?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):s.disable_flags||this.ev(w,$,{partialResponse:o}),this.Wd(c,s.disable_flags?"skipped":P.length||!w.flags&&!w.featureFlags?"error":"loaded"),u()},d=g=>{this.fd=!1,l===this.pd&&(this.$t({[yi]:[No]}),this.A.error("Feature flag request failed",g),this.Zd()&&this.Bd(!0),this.Wd(c,"error")),u()},p=(t=this.Mr.requestMaxRetries)!==null&&t!==void 0?t:1,f=()=>p>0&&l===this.pd,_=()=>{if(l!==this.pd||!this.bo||this.Mr.remoteRequestsDisabled)return this.fd=!1,this.Wd(c,"skipped"),void u();try{i.sendRequest(a,{target:"flags",method:"POST",body:s,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(g=>{if((y=>ip.includes(y.statusCode)||(m=>m.statusCode===0&&m.error instanceof Error&&m.error.name==="AbortError")(y))(g)&&f())return p--,void setTimeout(_,500);h(g)}).catch(d)}catch(g){d(g)}};_()}kd(){return Nl(this._d,3)}sv(e){this._d=jl(e,this._d,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var i;if(t.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+e+Zs);if(this.Xd())return;let s=this.getFeatureFlagResult(e,t);return(i=s?.variant)!==null&&i!==void 0?i:s?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){let t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+e+Zs);if(this.Xd())return;let i=this.getFlagVariants(),s=e in i,n=i[e],r=this.getFlagPayloads()[e],o=String(n),a=this.Gd("$feature_flag_request_id")||void 0,l=this.Gd("$feature_flag_evaluated_at")||void 0,c,u=this.Gd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var h;let O=(h=this.bo)===null||h===void 0||(h=h.session)===null||h===void 0?void 0:h.sessionId,B=this.Gd(si);O&&O!==B&&(u={},c=O)}if(!t.send_event&&"send_event"in t)c&&this.$t({[ot]:u,[si]:c});else if(e in u&&u[e].includes(o))c&&this.$t({[ot]:u,[si]:c});else{var d,p,f,_,g,y,m,w,$,P,k,M,T;I(u[e])?u[e].push(o):u[e]=[o],this.$t(v({[ot]:u},c?{[si]:c}:{}));let O=this.getFeatureFlagDetails(e),B=[...(d=this.Gd("$feature_flag_errors"))!==null&&d!==void 0?d:[]];x(n)&&B.push("flag_missing");let U={$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:(p=(f=this.Mr.bootstrap)===null||f===void 0||(f=f.featureFlags)===null||f===void 0?void 0:f[e])!==null&&p!==void 0?p:null,$feature_flag_bootstrapped_payload:(_=(g=this.Mr.bootstrap)===null||g===void 0||(g=g.featureFlagPayloads)===null||g===void 0?void 0:g[e])!==null&&_!==void 0?_:null,$used_bootstrap_value:!this.yd};x(O==null||(y=O.metadata)===null||y===void 0?void 0:y.has_experiment)||(U.$feature_flag_has_experiment=O.metadata.has_experiment),x(O==null||(m=O.metadata)===null||m===void 0?void 0:m.version)||(U.$feature_flag_version=O.metadata.version);let q=(w=O==null||($=O.reason)===null||$===void 0?void 0:$.description)!==null&&w!==void 0?w:O==null||(P=O.reason)===null||P===void 0?void 0:P.code;q&&(U.$feature_flag_reason=q),!(O==null||(k=O.metadata)===null||k===void 0)&&k.id&&(U.$feature_flag_id=O.metadata.id),x(O?.original_variant)&&x(O?.original_enabled)||(U.$feature_flag_original_response=x(O.original_variant)?O.original_enabled:O.original_variant),!(O==null||(M=O.metadata)===null||M===void 0)&&M.original_payload&&(U.$feature_flag_original_payload=O==null||(T=O.metadata)===null||T===void 0?void 0:T.original_payload),B.length&&(U.$feature_flag_error=B.join(",")),this.rv(U)}return s?{key:e,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:Mr(r)}:void 0}rv(e){try{var t;(t=this.bo)===null||t===void 0||t.capture("$feature_flag_called",e)}catch(i){this.A.error("Failed to capture feature flag call",i)}}getRemoteConfigPayload(e,t){this.ov(e,t)}ov(e,t){var i=this;return X(function*(){let s=i.bo;if(!s)return;let n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=i.Yd();r.length&&(n.evaluation_contexts=r);let o=i.tv(),a;x(o)||(n.flag_keys=o);try{var l;let c=(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i.Mr.compression,sentAt:"body",timeoutMs:i.Mr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=c?.[e]||void 0}catch(c){return void i.A.error("Remote config feature flag request failed",c)}try{t(a)}catch(c){i.A.error("Remote config feature flag callback failed",c)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.yd)return t.defaultValue;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+e+Zs),t.defaultValue;let i=this.getFeatureFlag(e,t);return x(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this.ev(e,t,i)}ev(e,t,i){if(!this.bo)return;this.vd=!0;let s=((n,r={},o={},a={},l,c=Lo)=>{let u=((w,$)=>{let P=w.flags;if(P){let k=Object.fromEntries(Object.keys(P).map(T=>{var O;return[T,(O=P[T].variant)!==null&&O!==void 0?O:P[T].enabled]})),M=Object.fromEntries(Object.keys(P).filter(T=>P[T].enabled).filter(T=>{var O;return!x((O=P[T].metadata)===null||O===void 0?void 0:O.payload)}).map(T=>{var O;return[T,(O=P[T].metadata)===null||O===void 0?void 0:O.payload]}));return v(v({},w),{},{featureFlags:k,featureFlagPayloads:M})}return w.featureFlags&&$.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),w})(n,c),h=u.flags,d=u.featureFlags,p=u.featureFlagPayloads;if(!d)return;let f=n.requestId,_=n.evaluatedAt;if(I(d)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");let w={};if(d)for(let $=0;d.length>$;$++)w[d[$]]=!0;return{[We]:d,[Re]:w,[li]:!1}}let g=d,y=p,m=h;if(l?.partialResponse){let w=Object.keys(g),$=y||{};g=v(v({},r),g),y=v(v({},o),$),w.forEach(P=>{P in $||y==null||delete y[P]}),m=v(v({},a),m)}else if(n.errorsWhileComputingFlags)if(h){let w=new Set(Object.keys(h).filter(P=>{var k;return!(!((k=h[P])===null||k===void 0)&&k.failed)}));g=v(v({},r),Object.fromEntries(Object.entries(g).filter(([P])=>w.has(P))));let $=Object.fromEntries(Object.entries(y||{}).filter(([P])=>w.has(P)));y=v(v({},o),$),w.forEach(P=>{P in $||y==null||delete y[P]}),m=v(v({},a),Object.fromEntries(Object.entries(m||{}).filter(([P])=>w.has(P))))}else g=v(v({},r),g),y=v(v({},o),y),m=v(v({},a),m);return v(v({[We]:Object.keys(Bo(g)),[Re]:g||{},[at]:y||{},[yt]:m||{},[li]:n.minimalFlagCalledEvents===!0},f?{[bt]:f}:{}),_?{[lt]:_}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this.A);if(s)if(i?.persist===!1){let n=!x(this.bo.kv.get(Re));this.Qd=s,n||this.$t(s)}else this.qd(),this.Kd(s,e,!!i?.partialResponse),this.$t(s);else t&&this.Zd();t||(this.bd=!1),this.Bd(t)}override(e,t=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.av(e)}av(e){if(this.bo){if(e===!1)return this.Pt([Be,_t]),this.Bd(),void vt.info("All overrides cleared");if(I(e))return this.$t({[Be]:jo(e)}),this.Bd(),void vt.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;let i=e;this.od=!!((t=i.suppressWarning)!==null&&t!==void 0&&t);let s={},n=i.flags,r=i.payloads;return n&&(s[Be]=I(n)?jo(n):n),r&&(s[_t]=r),Object.keys(s).length&&this.$t(s),n===!1&&r===!1?this.Pt([Be,_t]):n===!1?this.Pt(Be):r===!1&&this.Pt(_t),this.Bd(),n===!1?vt.info("Flag overrides cleared"):n&&vt.info("Flag overrides set",{flags:n}),void(r===!1?vt.info("Payload overrides cleared"):r&&vt.info("Payload overrides set",{payloads:r}))}if(e&&typeof e=="object")return this.$t({[Be]:e}),this.Bd(),void vt.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.vd){let{flags:t,flagVariants:i}=this.lv();try{e(t,i)}catch(s){this.A.error("Error while running feature flags callback",s)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;let n=(this.Gd("$early_access_features")||[]).find(c=>c.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i);let a=v(v({},this.getFlagVariants()),{},{[e]:t});(s=this.Pd)===null||s===void 0||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this.$t({[We]:Object.keys(Bo(a)),[Re]:a,[rt]:v(v({},this.Gd("$stored_person_properties")||{}),r)}),this.Bd();try{var l;(l=this.bo)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(c){this.A.error("Failed to capture early access feature enrollment",c)}}getEarlyAccessFeatures(e,t=!1,i){let s=this.Gd(pn);!s||t?this.uv(e,i):e(s)}uv(e,t){var i=this;return X(function*(){let s=i.bo;if(!s)return;let n=t?`&${t.map(o=>`stage=${o}`).join("&")}`:"",r;try{let o=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,i.$t({[pn]:r})}catch(o){return void i.A.error("Early access feature request failed",o)}try{e(r)}catch(o){i.A.error("Early access feature callback failed",o)}})()}lv(){let e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(i=>t[i]),flagVariants:Object.keys(t).filter(i=>t[i]).reduce((i,s)=>(i[s]=t[s],i),{})}}Bd(e){this.jd();let{flags:t,flagVariants:i}=this.lv();this.featureFlagEventHandlers.forEach(s=>{try{s(t,i,{errorsLoading:e})}catch(n){this.A.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(e,t=!0){this.hv(e,t)}hv(e,t=!0){let i=this.Gd("$stored_person_properties")||{},s=e?.$set||(e?.$set_once?{}:e),n=e?.$set_once,r={};if(n)for(let o in n)({}).hasOwnProperty.call(n,o)&&(o in i||(r[o]=n[o]));this.$t({[rt]:v(v(v({},i),r),s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){let i=v({},this.Gd("$stored_person_properties")||{});e.forEach(s=>{delete i[s]}),this.$t({[rt]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Pt(rt),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){let i=this.Gd("$stored_group_properties")||{},s=v({},i);for(let n of Object.keys(e))s[n]=v(v({},i[n]),e[n]);this.$t({[nt]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){let t=this.Gd("$stored_group_properties")||{};this.$t({[nt]:v(v({},t),{},{[e]:{}})})}else this.Pt(nt)}reset(){this.pd++,this.Wd(this.hd,"cancelled"),this.Wd(this.dd,"cancelled"),this.md=!1,this.ad={},this.ld={},this.Qd=void 0,this.vd=!1,this.gd=!1,this.yd=!1,this.$anon_distinct_id=void 0,this.Vd(),this.od=!1,this._d=0}},Ho=te("[FeatureFlags]"),np=class{constructor(e,t=!1){this.dv=!1,this.update(e,t)}update(e,t){this.vv=((i,s)=>{var n,r,o,a,l,c,u,h;return{bootstrap:{featureFlags:(n=(r=i.bootstrap)===null||r===void 0?void 0:r.featureFlags)!==null&&n!==void 0?n:void 0,featureFlagPayloads:(o=(a=i.bootstrap)===null||a===void 0?void 0:a.featureFlagPayloads)!==null&&o!==void 0?o:void 0},remoteRequestsDisabled:s,featureFlagsDisabled:!!i.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!i.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!i.advanced_feature_flags_dedup_per_session,cacheTtlMs:i.feature_flag_cache_ttl_ms,refreshIntervalMs:(l=i.remote_config_refresh_interval_ms)!==null&&l!==void 0?l:3e5,idleRefreshBackoff:x(i.remote_config_refresh_interval_ms),requestTimeoutMs:i.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(c=i.feature_flag_request_max_retries)!==null&&c!==void 0?c:1),compression:i.disable_compression?void 0:"best-available",evaluationContexts:(u=(h=i.evaluation_contexts)!==null&&h!==void 0?h:i.evaluation_environments)!==null&&u!==void 0?u:[],flagKeys:I(i.flag_keys)?i.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.dv||(Ho.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.dv=!0),x(e.flag_keys)||I(e.flag_keys)||Ho.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.vv}},Uo=e=>Vt(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Ae=te("[Error tracking]"),In="webkit-masked-url:",rp=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],op=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",In],ap=["__firefox__","__gCrWeb"],qo="Refusing to render web experiment since the viewer is a likely bot",lp={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>as(t,e),not_regex:(e,t)=>!as(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Ie=te("[Conversations]"),ft="Conversations not available yet.";function zo(e,t){var i,s,n,r,o,a,l;let c=(i=e?.flushIntervalMs)!==null&&i!==void 0?i:3e3,u=(s=e?.maxBufferSize)!==null&&s!==void 0?s:100,h=t?.consoleCapture?void 0:(n=e?.maxLogsPerInterval)!==null&&n!==void 0?n:1e3,d=x(h)?Math.max(u,2048):Math.max(u,h),p=v(v({},(function(){let f="",_="";try{var g;let y="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,m=y==null||(g=y.navigator)===null||g===void 0?void 0:g.userAgent;m&&([f,_]=Pa(m))}catch{}return(function(y,m){let w=(function($){if($)return{}.hasOwnProperty.call(Dr,$)?Dr[$]:$})(y);return v(v({},w?{"os.name":w}:{}),m?{"os.version":m}:{})})(f,_)})()),e?.resourceAttributes);return{serviceName:(r=(o=p?.["service.name"])!==null&&o!==void 0?o:e?.serviceName)!==null&&r!==void 0?r:t?.serviceNameDefault,serviceVersion:(a=p?.["service.version"])!==null&&a!==void 0?a:e?.serviceVersion,environment:(l=p?.["deployment.environment"])!==null&&l!==void 0?l:e?.environment,resourceAttributes:p,beforeSend:e?.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var cp=["debug","log","warn","error","info"],up=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},Go="console",xc="__posthogHandledLogsRequestError",Qs=(e,t)=>{let i=e instanceof Error?e:new Error(t);return i[xc]=!0,i},Vo=e=>!!e&&typeof e=="object"&&e[xc]===!0,dp=class{get fv(){return v(v({},this.A),{},{error:(...e)=>{e.some(Vo)||this.A.error(...e)}})}constructor(e,t){var i;this.wo=e,this.pv=t,this.name="logs",this.gv=!1,this.mv=!1,this.yv=!1,this.A=te("[logs]"),this.ol=[],this.bv=[],this._d=0,this._v=!1,this.To=!1,this.wv=[],this.Sv=[],this.xv=!1,this.$v=!1,this.Cv=!1,this.Tv=()=>{var s,n;this.To||(this._d=0,(s=this.Iv)===null||s===void 0||s.onReconnect(),(n=this.Mv)===null||n===void 0||n.onReconnect())},this.gv=!!(!((i=e.get())===null||i===void 0)&&i.captureConsoleLogs)}get Ev(){return!0}Pv(){}Rv(){if(!this.Cv){try{this.Fd=typeof window>"u"?void 0:window}catch{this.Fd=void 0}this.Fd&&(G(this.Fd,"online",this.Tv),this.Cv=!0)}}Av(e,t,i,s){this.Rv();let n=zo(this.wo.get(),i);return[new rd(this.Fv(e,t),n,this.fv,()=>this.pv(),r=>r(),void 0,s),n]}Ov(){let e=this.wo.get();var t;return this.Iv&&this.Dv===e||((t=this.Iv)===null||t===void 0||t.reset(),this.Dv=e,[this.Iv,this.Lv]=this.Av(()=>this.ol,i=>{this.ol=i})),this.Iv}Nv(){let e=this.wo.get();var t;return this.Mv&&this.qv===e||((t=this.Mv)===null||t===void 0||t.reset(),this.qv=e,[this.Mv,this.jv]=this.Av(()=>this.bv,i=>{this.bv=i},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Go)),this.Mv}setup(e){if(!this.To&&!this._v)return this._v=!0,this.bo=e,this.A=e.logger.createLogger("[logs]"),sr(e.kv.initialize(),()=>{this.To||this.Od(e)})}Od(e){var t;this.Rv(),!((t=this.wo.get())===null||t===void 0)&&t.captureConsoleLogs&&(this.gv=!0),(this.gv||this.wo.remoteConfigWillArrive&&e.kv.get(this.wo.captureHintKey))&&this.Bv();let i=!1,s=e.onRemoteConfig(n=>{var r;i=n.ok&&((r=n.config.logs)===null||r===void 0?void 0:r.captureConsoleLogs)===!0,this.onRemoteConfig(n)});this.To?s.dispose():(this.Eo=s,i||this.loadIfEnabled())}dispose(){var e,t,i,s,n,r,o;this.To||(this.To=!0,this.zv(),(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,this.bo=void 0,this.yv=!1,(t=this.Fd)===null||t===void 0||t.removeEventListener("online",this.Tv),(i=this.Hv)===null||i===void 0||i.call(this),this.Hv=void 0,(s=this.Iv)===null||s===void 0||s.clearQueue(),(n=this.Mv)===null||n===void 0||n.clearQueue(),(r=this.Iv)===null||r===void 0||r.reset(),(o=this.Mv)===null||o===void 0||o.reset())}onRemoteConfig(e){var t,i;if(this.To)return;let s=e.ok?(t=e.config.logs)===null||t===void 0?void 0:t.captureConsoleLogs:void 0;R(s)?this.Uv():((i=this.bo)===null||i===void 0||i.kv.set(this.wo.captureHintKey,!!s),s?(this.gv=!0,this.mv||this.Bv(),this.loadIfEnabled()):this.Uv())}reset(){var e,t,i,s;this.zv(),(e=this.Iv)===null||e===void 0||e.clearQueue(),this.ol=[],(t=this.Iv)===null||t===void 0||t.reset(),(i=this.Mv)===null||i===void 0||i.clearQueue(),this.bv=[],(s=this.Mv)===null||s===void 0||s.reset(),this._d=0}captureLog(e){!this.To&&this.bo&&this.Ov().captureLog(e)}captureConsoleLog(e){!this.To&&this.bo&&this.Nv().captureLog(e)}captureBufferedConsoleLog(e,t,i){!this.To&&this.bo&&this.Nv().captureLog(e,{context:t,occurredAtMs:i})}$c(){var e;this.zv(),(e=this.Mv)===null||e===void 0||e.clearQueue(),this.bv=[]}Uv(){this.gv||this.zv()}Bv(){var e;if(this.xv||!(!((e=this.Fd)===null||e===void 0)&&e.console))return;let t=zo(this.wo.get()).maxBufferSize,i=!0;this.Sv.push(()=>{i=!1});for(let s of cp){let n;try{n=up(this.Fd.console[s])}catch{continue}n&&this.Sv.push(Gt(this.Fd.console,s,r=>{let o=(...a)=>{try{i&&this.Wv(s,a,t)}catch{}return r.apply(this.Fd.console,a)};return o.__rrweb_original__=n,o}))}this.xv=!0,this.Vv=setTimeout(()=>{this.zv()},3e4)}Wv(e,t,i){var s;if(this.xv&&!this.$v&&t.length!==0)if(!((s=this.bo)===null||s===void 0)&&s.canCapture){if(i>this.wv.length){this.$v=!0;try{this.wv.push({level:e,args:t,occurredAtMs:Date.now(),context:this.pv()})}finally{this.$v=!1}}}else this.zv()}zv(){if(this.wv=[],this.xv){this.xv=!1,this.Vv&&(clearTimeout(this.Vv),this.Vv=void 0);for(let e of this.Sv)e();this.Sv=[]}}Gv(){let e=this.wv;return this.zv(),e}get logger(){return this.Qv||(this.Qv={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.Qv}flushLogs(e){this.bo&&(e?this.Zv(e):(this.Iv&&this.Iv.flush().catch(t=>this.Jv(t)),this.Mv&&this.Mv.flush().catch(t=>this.Jv(t))))}flush(){var e=this;return X(function*(){var t,i;let s=(t=e.Iv)===null||t===void 0?void 0:t.flush().catch(r=>e.Jv(r)),n=(i=e.Mv)===null||i===void 0?void 0:i.flush().catch(r=>e.Jv(r));yield s,yield n})()}Jv(e){Vo(e)||this.A.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.To||!this.gv||this.mv||this.yv)return;let e=this.Pv();if(e){this.yv=!0;try{e((t,i)=>{if(this.yv=!1,!this.To&&this.gv)if(t||!i)this.A.error("Could not load logs script",t),this.zv();else{let s=this.Gv();this.Hv=i.initialize(this.bo),this.mv=!0,s.length>0&&i.replay(this.bo,s)}})}catch(t){throw this.yv=!1,t}}else this.zv()}Fv(e,t){let i=this.bo;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:s=>s===He.LogsQueue?e():void 0,setPersistedProperty(s,n){s===He.LogsQueue&&t(n??[])},js:s=>this.js(s),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}js(e){return new Promise(t=>{if(Nl(this._d,3))return void t({kind:"fatal",error:Qs(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1,s=o=>{i||(i=!0,clearTimeout(n),t(o))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Qs(void 0,"logs request timed out")})},9e4),r=this.Ev;this.bo.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.bo.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(o=>{var a;let l=o.statusCode;this.Kv(l,r),l>=200&&300>l?s({kind:"ok"}):l===413?s({kind:"too-large"}):l!==0&&l!==408&&l!==429&&500>l?s({kind:"fatal",error:new Error(`logs request failed with status ${l}`)}):l===0?(o.error||this.A.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Qs(o.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${l}`)})},o=>{s({kind:"retry-later",error:o})})})}Kv(e,t){(e!==0||t)&&(this._d=jl(e,this._d,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Zv(e){this.ol.length>0&&this.Xv(e,this.ol,this.Lv,this.bo.library.name,t=>{this.ol=t}),this.bv.length>0&&this.Xv(e,this.bv,this.jv,Go,t=>{this.bv=t})}Xv(e,t,i,s,n){if(t.length===0)return;let r=t.map(a=>a.record);n([]);let o=Ka(r,Ya(i,this.bo.library.name,this.bo.library.version),s,this.bo.library.version);this.bo.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.bo.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(a=>this.Jv(a))}},ls=te("[NetworkMetrics]"),nr=()=>{var e;return!(b==null||(e=b.performance)===null||e===void 0)&&e.now?b.performance.now():Date.now()},hp={"http:":80,"https:":443},pp=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),kc=(e,t)=>{var i;let s=String(t);return{method:String(e).toUpperCase(),url:((i=Je(s))===null||i===void 0?void 0:i.href)||s}},An=(e,t,i,s,n,r,o=!1)=>{try{var a,l;let c=n();if(!c)return;let u=i||void 0,h=nr()-s,d=Je(t.url);if(d&&d.protocol!=="http:"&&d.protocol!=="https:")return;let p={url:d?.href||t.url,method:t.method},f=oe(c.name)?c.name(p):D(c.name)?c.name:"http.client.request.duration";if(!f)return;let _=o&&!u?void 0:((y,m)=>y?400>y?void 0:String(y):m?.name||"_OTHER")(u,r),g=v(v(v(v(v({},(y=>{let m=pp.has(y)?y:"_OTHER";return v({"http.request.method":m},m==="_OTHER"&&y!==m?{"http.request.method_original":y}:{})})(p.method)),d?(y=>{return{"server.address":y.hostname.startsWith("[")&&y.hostname.endsWith("]")?y.hostname.slice(1,-1):y.hostname,"server.port":Number(y.port)||hp[y.protocol],"url.scheme":y.protocol.slice(0,-1),"url.template":(m=y.pathname,m.split("/").map(w=>($=>/^\d+$/.test($)||$.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test($))(w)?":id":w).join("/"))};var m})(d):{}),u?{"http.response.status_code":u}:{}),_?{"error.type":_}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,p,{status:u,durationMs:h}));(l=e.metrics)===null||l===void 0||l.histogram(f,h,{unit:"ms",attributes:g})}catch(c){ls.error("Failed to record network metric",c)}},Ec=()=>{},vp=(e,t)=>oe(b?.fetch)?Gt(b,"fetch",i=>function(...s){let n=nr(),r=i.apply(this,s);if(!t())return r;try{var o,a,l;let[c,u]=s,h=kc((o=(a=u?.method)!==null&&a!==void 0?a:c?.method)!==null&&o!==void 0?o:"GET",(l=c?.url)!==null&&l!==void 0?l:c);return r.then(d=>(An(e,h,d?.status,n,t,void 0,!0),d),d=>{throw An(e,h,void 0,n,t,d),d})}catch(c){return ls.error("Failed to observe fetch",c),r}}):Ec,fp=(e,t)=>{var i;let s=b==null||(i=b.XMLHttpRequest)===null||i===void 0?void 0:i.prototype;if(!s)return Ec;let n=new WeakMap,r=Gt(s,"open",a=>function(...l){try{Ql.has(this)||n.set(this,kc(l[0],l[1]))}catch(c){ls.error("Failed to observe XHR open",c)}return a.apply(this,l)}),o=Gt(s,"send",a=>function(...l){let c;try{let u=n.get(this);if(u&&t()){let h=nr();c=()=>{this.removeEventListener("loadend",c),An(e,u,this.status,h,t)},G(this,"loadend",c)}}catch(u){ls.error("Failed to observe XHR send",u)}try{return a.apply(this,l)}catch(u){throw c&&this.removeEventListener("loadend",c),u}});return()=>{r(),o()}},Wo=new WeakMap,gp=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),_p={maxStringLength:2048,truncationSuffix:"..."};function Yo(e){if(e)return e===!0?{intent:!0,model:!0}:{intent:e.intent!==!1,model:e.model!==!1}}function en(e,t){return{}.hasOwnProperty.call(e,t)}function tn(e,t){let i=Object.create(e);return t&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),i}function Ko(e,t,i=!1){if(!D(e))return;let s=e.trim();return s?(i?Ju(s,_p):s).slice(0,t):void 0}function Jo(e){try{return L(e)&&e.isError===!0}catch{return!1}}var hs={featureFlags:class extends sp{constructor(e){let t=new np(e.config,e.il());super(t),this.name=_c,this._instance=e,this.Yv=t}get Pd(){return this._instance.persistence}updateConfig(e,t){this.Yv.update(e,t),this.Rd()}}},mp={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var e;return!!(!((e=this.tf)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.ef==="awaiting_config"||this.ef==="missing_config"?this.ef:(e=(t=this.tf)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.ef}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.ef=Ks,this.if=void 0,this.nf=!1,this.Je=(()=>{var t,i;if(!E?.visibilityState||E.visibilityState==="visible")return!0;let s=b==null||(t=b.performance)===null||t===void 0||(i=t.getEntriesByType)===null||i===void 0?void 0:i.call(t,"visibility-state");return!s?.length||s.some(n=>n.name==="visible")})(),this.sn=()=>{var t,i;E?.visibilityState==="visible"&&(this.Je=!0,(t=this.tf)===null||t===void 0||(i=t.setDocumentWasEverVisible)===null||i===void 0||i.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.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');E?.addEventListener&&G(E,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.nf=!0,E==null||(t=E.removeEventListener)===null||t===void 0||t.call(E,"visibilitychange",this.sn),e?this.sf(!0):this.stopRecording()}get rf(){var e;let t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),i=!this.Mr.disable_session_recording,s=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return b&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(this.nf||this.rf&&(!((t=this.tf)===null||t===void 0)&&t.isStarted))return;let i=!x(Object.assign)&&!x(Array.from);this.rf&&i?(this.af(e),ze.info("starting")):(this.ef=Ks,this.stopRecording())}af(e){var t,i;if(this.rf)if(this.ef!=="awaiting_config"&&this.ef!=="missing_config"&&(this.ef=Fo),(C==null||(t=C.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((i=C.__PosthogExtensions__)===null||i===void 0?void 0:i.initSessionRecording))this.lf(e);else{var s,n;let r=this._instance.sessionManager;(s=C.__PosthogExtensions__)===null||s===void 0||(n=s.loadExternalDependency)===null||n===void 0||n.call(s,this._instance,this.uf,o=>{if(!this.nf&&this.rf&&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.lf(e);this.ef="disabled"})}}stopRecording(){var e,t;(e=this.if)===null||e===void 0||e.call(this),this.if=void 0,(t=this.tf)===null||t===void 0||t.stop()}sf(e=!1){var t,i;(t=this.if)===null||t===void 0||t.call(this),this.if=void 0,(i=this.tf)===null||i===void 0||i.discard({discardProducerEvents:e})}cf(){var e,t;(e=this.Il)===null||e===void 0||e.unregister("$session_is_sampled"),(t=this.Il)===null||t===void 0||t.unregister("$replay_sample_rate")}hf(e,t){if(R(e))return null;let i=re(e)?e:parseFloat(e);return typeof(s=i)!="number"||!Number.isFinite(s)||0>s||s>1?(ze.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var s}df(e){if(this.Il){var t,i;let s=this.Il,n=()=>{var r;let o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.hf((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),l=this.hf(o?.sampleRate,"remote config sampleRate"),c=a??l;R(c)&&this.cf();let u=o?.minimumDurationMilliseconds;s.register({[ui]:v(v({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:v({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:x(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};n(),(t=this.if)===null||t===void 0||t.call(this),this.if=(i=this._instance.sessionManager)===null||i===void 0?void 0:i.onSessionId(n)}}onRemoteConfig(e){let t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.df(t),void this.sf()):(this.df(t),void this.startIfEnabledOrStop()):(this.ef==="awaiting_config"&&(this.ef="missing_config",this._instance.register_for_session({[Vn]:!0}),ze.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;!((i=this.tf)===null||i===void 0)&&i.log?this.tf.log(e,t):ze.warn("log called before recorder was ready")}get uf(){var e,t;let i=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(ui);return(i==null||(t=i.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}vf(){let e=this._instance.get_property(ui);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(i){return ze.warn("persisted remote config for session recording is invalid and will be ignored",i),!1}return!R(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}lf(e){var t,i,s;if(!this.nf&&this.rf&&this._instance.sessionManager){if(!(!((t=C.__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({[Gn]:!0});var n;if(this.tf||(this.tf=(n=C.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording(this._instance,this.Je),this.tf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.vf())return this.ef==="missing_config"||this.ef==="awaiting_config"?void 0:(this.ef="awaiting_config",ze.info("persisted remote config is stale, requesting fresh config before starting"),void new Yl(this._instance).load());this.ef=Fo,(i=(s=this.tf).setDocumentWasEverVisible)===null||i===void 0||i.call(s,this.Je),this.tf.start(e)}else this.ef=Ks}onRRwebEmit(e){var t,i;(t=this.tf)===null||t===void 0||(i=t.onRRwebEmit)===null||i===void 0||i.call(t,e)}overrideLinkedFlag(){var e,t;this.tf||(t=this.Il)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.tf)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.tf||(t=this.Il)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.tf)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,i;this.tf||(i=this.Il)===null||i===void 0||i.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.tf)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;let t={};for(let s of Vh){var i;let n=(i=this._instance.sessionPersistence)===null||i===void 0?void 0:i.get_property(s);x(n)||(t[s]=n)}return v(v({},t),((e=this.tf)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var i;return!!(!((i=this.tf)===null||i===void 0)&&i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.tf)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},yp={autocapture:class extends Hh{constructor(e){super(new Uh(e)),this.instance=e}},historyAutocapture:class{constructor(e){this.ff=!1,this._instance=e,this.pf=this.gf()}initialize(){this.startIfEnabled()}get isEnabled(){let e=this.mf();return!!(e.path||e.search||this.yf(e))}startIfEnabled(){this.isEnabled&&(S.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.pf=this.gf(),this.startIfEnabled()}stop(){this.bf&&this.bf(),this.bf=void 0,this._f&&this._f(),this._f=void 0,S.info("History API monitoring stopped")}monitorHistoryChanges(){b&&b.history&&(this.wf("pushState"),this.wf("replaceState"),this.kf(),this.yf()&&this.Sf())}wf(e){var t;if(!b||!((t=b.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;let i=this;Gt(b.history,e,s=>function(n,r,o){var a;i.xf(o)&&i.$f(),s.call(this,n,r,o),i.Cf(e,!i.ff&&(b==null||(a=b.event)===null||a===void 0?void 0:a.type)!=="popstate")})}gf(){let e=b?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}mf(){let e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:L(e)?e:{}}yf(e=this.mf()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}Tf(e){let t=this.mf(),i=this.pf;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this.yf(t)&&e.hash!==i.hash))}Cf(e,t=!1){try{t||this.$f();let i=this.gf();if(!i)return;if(this.Tf(i)){let s=()=>this._instance.capture(Yn,{navigation_type:e});t?(this.If=s,Promise.resolve().then(()=>this.$f())):s()}this.pf=i}catch(i){S.error(`Error capturing ${e} pageview`,i)}}xf(e){var t,i;return!(R(e)||!b)&&((t=Je(String(e)))===null||t===void 0?void 0:t.href)!==((i=b.location)===null||i===void 0?void 0:i.href)}$f(){let e=this.If;if(e){this.If=void 0,this.ff=!0;try{e()}catch(t){S.error("Error capturing deferred pageview",t)}finally{this.ff=!1}this.pf=this.gf()}}kf(){if(this.bf)return;let e=()=>{this.Cf("popstate")};G(b,"popstate",e),this.bf=()=>{b&&b.removeEventListener("popstate",e)}}Sf(){if(this._f)return;let e=()=>{this.Cf("hashchange")};G(b,"hashchange",e),this._f=()=>{b&&b.removeEventListener("hashchange",e)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(e){var t;this.Mf=!1,this.ko=!1,this.Ef=null,this.instance=e,this.Mf=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[fn]),this.rageclicks=new wc(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return L(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return R(this.Mr.capture_heatmaps)?R(this.Mr.enable_heatmaps)?this.Mf:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;Wh.info("starting..."),this.Pf(),this.sn()}else{var e;clearInterval((e=this.Ef)!==null&&e!==void 0?e:void 0),this.Rf(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!("heatmaps"in t))return;let i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[fn]:i}),this.Mf=i,this.startIfEnabled()}getAndClearBuffer(){let e=this.Rt;return this.Rt=void 0,e}Af(e){Js(e.originalEvent)&&this.Ir(e.originalEvent,"deadclick")}sn(){this.Ef&&clearInterval(this.Ef),this.Ef=E?.visibilityState==="visible"?setInterval(this.fl.bind(this),this.flushIntervalMilliseconds):null}Pf(){b&&E&&(this.Ff=this.fl.bind(this),G(b,es,this.Ff),this.Of=e=>this.Ir(e||b?.event),G(E,"click",this.Of,{capture:!0}),this.Df=e=>this.Lf(e||b?.event),G(E,"mousemove",this.Df,{capture:!0}),this.Nf=new ro(this.instance,Wd,this.Af.bind(this)),this.Nf.startIfEnabledOrStop(),this.qf=this.sn.bind(this),G(E,bi,this.qf),this.ko=!0)}Rf(){var e;b&&E&&(this.Ff&&b.removeEventListener(es,this.Ff),this.Of&&E.removeEventListener("click",this.Of,{capture:!0}),this.Df&&E.removeEventListener("mousemove",this.Df,{capture:!0}),this.qf&&E.removeEventListener(bi,this.qf),clearTimeout(this.jf),(e=this.Nf)===null||e===void 0||e.stop(),this.ko=!1)}Bf(e,t){let i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(o,a,l){let c=o;for(;c&&De(c)&&!ve(c,"body");){if(c===l)return!1;let p;try{var u,h,d;p=(u=(h=(d=c.ownerDocument)===null||d===void 0?void 0:d.defaultView)!==null&&h!==void 0?h:b)===null||u===void 0?void 0:u.getComputedStyle(c).position}catch{return!1}if(A(a,p))return!0;c=Ml(c)}return!1})(hi(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:s),y:e.clientY+(r?0:i),target_fixed:r,type:t}}Ir(e,t="click"){var i;if(Yr(e.target)||!Js(e))return;let s=this.Bf(e,t);!((i=this.rageclicks)===null||i===void 0)&&i.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Fl(hi(e),this.instance.config.rageclick)&&this.Qs(v(v({},s),{},{type:"rageclick"})),this.Qs(s)}Lf(e){!Yr(e.target)&&Js(e)&&(clearTimeout(this.jf),this.jf=setTimeout(()=>{this.Qs(this.Bf(e,"mousemove"))},500))}Qs(e){if(!b)return;let t=this.Mr.disable_capture_url_hashes?ct(b.location.href):b.location.href,i=this.Mr.custom_personal_data_properties,s=this.Mr.mask_personal_data_properties?[...qt,...i||[]]:[],n=xi(t,s,ki);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(e)}fl(){this.Rt&&!Se(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ro,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.Mf=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.zf=()=>{clearTimeout(this.Hf),this.Hf=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",v({$current_url:this.Rt.url},this.Rt.metrics.reduce((i,s)=>v(v({},i),{},{[`$web_vitals_${s.name}_event`]:v({},s),[`$web_vitals_${s.name}_value`]:s.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Uf=i=>{var s;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},R(i?.name)||R(i?.value))return void pt.error("Invalid metric received",i);let n=typeof i.navigationURL=="string"?i.navigationURL:void 0,r=this.Wf(n);if(x(r))return;let o=re(i.navigationId)||typeof i.navigationId=="string"?`navigation:${i.navigationId}`:`url:${r}`;if(this.Vf&&i.value>=this.Vf)return void pt.error("Ignoring metric with value >= "+this.Vf,i);this.Rt.navigationKey!==o&&(this.zf(),this.Hf=setTimeout(this.zf,this.flushToCaptureTimeoutMs)),x(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=r),this.Rt.firstMetricTimestamp=x(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;let a=(s=this._instance.sessionManager)===null||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0),l=v(v(v({},i),n?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete l.entries,L(i.attribution)&&this.attributionMetrics.indexOf(i.name)>-1){let c={};for(let u of Gh){let h=u==="url"&&typeof i.attribution[u]=="string"?this.Wf(i.attribution[u]):i.attribution[u];x(h)||(c[u]=h)}l.attribution=c}else delete l.attribution;x(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.zf()},this.Gf=()=>{if(this.ko)return;let i,s,n,r,o=!1,a=C.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,c=l?.[this.Qf]||(this.Qf==="web-vitals"&&x(l)?a?.postHogWebVitalsCallbacks:void 0);if(!x(c)){let d=c.withoutAttribution,p=this.attributionMetrics;o=!x(d),i=p.indexOf("LCP")>-1?c.onLCP:d?.onLCP||c.onLCP,s=p.indexOf("CLS")>-1?c.onCLS:d?.onCLS||c.onCLS,n=p.indexOf("FCP")>-1?c.onFCP:d?.onFCP||c.onFCP,r=p.indexOf("INP")>-1?c.onINP:d?.onINP||c.onINP}if(!(i&&s&&n&&r))return void pt.error("web vitals callbacks not loaded - not starting");let u={reportSoftNavs:this.useSoftNavs},h=o&&this.attributionMetrics.indexOf("INP")>-1?v(v({},u),{},{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&i(this.Uf.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&s(this.Uf.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&n(this.Uf.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&r(this.Uf.bind(this),h),this.ko=!0},this.Mf=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[mn]),this.startIfEnabled()}get Zf(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;let i=L(this.Zf)?(e=this.Zf)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return R(i)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||Oo:i}get flushToCaptureTimeoutMs(){return(L(this.Zf)?this.Zf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let e=L(this.Zf)?this.Zf.web_vitals_attribution:void 0;return xe(e)?e?Oo:[]:I(e)?e:zh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let e=L(this.Zf)?this.Zf.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Vf(){let e=L(this.Zf)&&re(this.Zf.__web_vitals_max_value)?this.Zf.__web_vitals_max_value:Mo;return e>0&&6e4>=e?Mo:e}get isEnabled(){let e=Z?.protocol;if(e!=="http:"&&e!=="https:")return pt.info("Web Vitals are disabled on non-http/https protocols"),!1;let t=L(this.Zf)?this.Zf.web_vitals:xe(this.Zf)?this.Zf:void 0;return xe(t)?t:this.Mf}startIfEnabled(){this.isEnabled&&!this.ko&&(pt.info("enabled, starting..."),this.zo(this.Gf))}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!("capturePerformance"in t))return;let i=L(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=L(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[mn]:i}),this._instance.persistence.register({[sl]:s})),this.Mf=i,this.startIfEnabled()}get Qf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}zo(e){var t;let i=C.__PosthogExtensions__,s=this.Qf,n=i?.postHogWebVitalsCallbacksByFlavor;n?.[s]||s==="web-vitals"&&x(n)&&i?.postHogWebVitalsCallbacks?e():i==null||(t=i.loadExternalDependency)===null||t===void 0||t.call(i,this._instance,s,r=>{r?pt.error("failed to load script",r):e()})}Wf(e){let t=e||b?.location.href;if(!t)return void pt.error("Could not determine current URL");let i=this._instance.config.disable_capture_url_hashes?ct(t):t,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...qt,...s||[]]:[];return xi(i,n,ki)}}},bp={exceptionObserver:class{constructor(e){var t;this.Gf=()=>{var i;if(!b||!this.isEnabled||!(!((i=C.__PosthogExtensions__)===null||i===void 0)&&i.errorWrappingFunctions))return;let s=C.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=C.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=C.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Jf&&this.Mr.capture_unhandled_errors&&(this.Jf=s(this.captureException.bind(this))),!this.Kf&&this.Mr.capture_unhandled_rejections&&(this.Kf=n(this.captureException.bind(this))),!this.Xf&&this.Mr.capture_console_errors&&(this.Xf=r(this.captureException.bind(this)))}catch(o){ii.error("failed to start",o),this.Yf()}},this._instance=e,this.tp=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[gn]),this.wt=new jc(v(v({},(function(i={}){var s,n,r,o;return{refillRate:(s=(n=i.exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:i.__exceptionRateLimiterRefillRate)!==null&&s!==void 0?s:1,bucketSize:(r=(o=i.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:i.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:ii})),this.Mr=this.ep(),this.startIfEnabledOrStop()}ep(){let e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return L(e)?t=v(v({},t),e):(x(e)?this.tp:e)&&(t=v(v({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ii.info("enabled"),this.Yf(),this.zo(this.Gf)):this.Yf()}zo(e){var t,i,s;!((t=C.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(i=C.__PosthogExtensions__)===null||i===void 0||(s=i.loadExternalDependency)===null||s===void 0||s.call(i,this._instance,"exception-autocapture",n=>{if(n)return ii.error("failed to load script",n);e()})}Yf(){var e,t,i;(e=this.Jf)===null||e===void 0||e.call(this),this.Jf=void 0,(t=this.Kf)===null||t===void 0||t.call(this),this.Kf=void 0,(i=this.Xf)===null||i===void 0||i.call(this),this.Xf=void 0}onRemoteConfig(e){if(!e.ok)return;let t=e.config;"autocaptureExceptions"in t&&(this.tp=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[gn]:this.tp}),this.Mr=this.ep(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.ep()}captureException(e){try{var t,i,s;let n=(t=e==null||(i=e.$exception_list)===null||i===void 0||(i=i[0])===null||i===void 0?void 0:i.type)!==null&&t!==void 0?t:"Exception";if(this.wt.consumeRateLimit(n))return void ii.info("Skipping exception capture because of client rate limiting.",{exception:n});(s=this._instance.exceptions)===null||s===void 0||s.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){var t,i;this.np=[],this.sp=new Xc([new hu,new wu,new vu,new pu,new yu,new mu,new gu,new bu],(function(s,...n){return(r,o=0)=>{let a=[],l=r.split(`
4
+ `),c=Math.min(l.length,o+1e3),u=[];for(let p=o;c>p;p++){let f=l[p];if(f.length>1024)continue;let _=Tr.test(f)?f.replace(Tr,"$1"):f;if(!_.match(/\S*Error: /)){for(let g of n){let y=g(_,s);if(y){a.push(y);let m=lu(a);if(m){for(let w=u.length-1;w>=0;w--){let $=u[w];if(m.start>=$.start+$.length)break;u.pop()}u.push(m)}break}}if(uu(a,u)>=50)break}}let h=[...u].sort((p,f)=>f.start-p.start),d=h[h.length-1];if(d){let p=Ra(a,d);a.splice(d.start-p,p);for(let f of h)f.start-=p}for(let p of h)cu(a,p);return u.some(p=>p.start===0&&a.length===p.length)&&(function(p){let f=p.map(g=>`${g.function}|${g.filename}|${g.lineno}|${g.colno}|${g.module}`),_=0;for(let g=1;f.length>g;g++)du(f,g,_)&&(_=g);p.push(...p.splice(0,_))})(a),(function(p){if(!p.length)return[];let f=Array.from(p);return f.reverse(),f.slice(0,50).map(_=>{return v(v({},_),{},{filename:_.filename||(g=f,g[g.length-1]||{}).filename,function:_.function||"?"});var g})})(a)}})("web:javascript",nu,au)),this._instance=e,this.np=(t=(i=this._instance.persistence)===null||i===void 0?void 0:i.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.rp=Yi(this.op()),this.ap=new ku(this.rp)}onConfigChange(){this.rp=Yi(this.op()),this.ap.setConfig(this.rp)}onRemoteConfig(e){var t,i,s;if(!e.ok)return;let n=e.config;if(!("errorTracking"in n))return;let r=(t=(i=n.errorTracking)===null||i===void 0?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],o=(s=n.errorTracking)===null||s===void 0?void 0:s.captureExtensionExceptions;this.np=r,this._instance.persistence&&this._instance.persistence.register({[tl]:this.np,[_n]:o})}get lp(){var e;let t=!!this._instance.get_property(_n),i=this._instance.config.error_tracking.captureExtensionExceptions;return(e=i??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.sp.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.rp.enabled)try{if(!D(e)||e.trim().length===0)return void Ae.warn("Ignoring exception step because message must be a non-empty string");let{sanitizedProperties:i,droppedKeys:s}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};let r=[];return{sanitizedProperties:Object.keys(n).reduce((o,a)=>xu.has(a)?(r.push(a),o):(o[a]=n[a],o),{}),droppedKeys:r}})(this.up(t));s.length>0&&Ae.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.ap.add(v({[Vi]:e,[Wi]:new Date().toISOString()},i))}catch(i){Ae.error("Failed to add exception step. Ignoring breadcrumb.",i)}}sendExceptionEvent(e){try{let t=e.$exception_list;if(this.cp(t)){if(this.hp(t))return this.dp("Exception dropped: matched a suppression rule"),void Ae.info("Skipping exception capture because a suppression rule matched");if(!this.lp&&this.vp(t))return this.dp("Exception dropped: thrown by a browser extension"),void Ae.info("Skipping exception capture because it was thrown by an extension");if(!this.lp&&this.fp(t))return this.dp("Exception dropped: thrown by an injected browser script"),void Ae.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.pp(t))return this.dp("Exception dropped: thrown by the PostHog SDK"),void Ae.info("Skipping exception capture because it was thrown by the PostHog SDK")}let i=this.rp.enabled&&R(e.$exception_steps)?this.gp(e):e,s=(function(){if("u">typeof process){var n;let o=(n=process.env.POSTHOG_RELEASE_ID)===null||n===void 0?void 0:n.trim();if(o)return o}let r=globalThis._posthogReleaseId;return typeof r=="string"&&r.length>0?r:void 0})();s&&(i.$release_id=s);try{let n=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",hc:!0});return n&&this.ap.clear(),n}catch(n){return Uo(n)||Ae.error("Failed to capture exception event. Dropping this exception.",n),void this.ap.clear()}}catch(t){return void(Uo(t)||Ae.error("Failed to process exception event. Ignoring this exception.",t))}}gp(e){try{let t=this.ap.getAttachable();return t.length===0?e:v(v({},e),{},{$exception_steps:t})}catch(t){return Ae.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}dp(e){this.rp.enabled&&this.ap.add({[Vi]:e,[Wi]:new Date().toISOString()})}up(e){return L(e)?v({},e):{}}op(){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:{}}hp(e){if(e.length===0)return!1;try{let t=e.reduce((i,{type:s,value:n})=>(D(s)&&s.length>0&&i.$exception_types.push(s),D(n)&&n.length>0&&i.$exception_values.push(n),i),{$exception_types:[],$exception_values:[]});return this.np.some(i=>{let s=i.values.map(n=>{let r=pc[n.operator],o=t[n.key];if(!r||!o)return!1;let a=I(n.value)?n.value:[n.value];return a.length>0&&r(a,o)});return i.type==="OR"?s.some(Boolean):s.every(Boolean)})}catch(t){return Ae.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}vp(e){let t=e.flatMap(s=>{var n,r;return(n=(r=s.stacktrace)===null||r===void 0?void 0:r.frames)!==null&&n!==void 0?n:[]}),i=t.filter(({filename:s})=>!!s&&op.some(n=>s.startsWith(n)));return i.length!==0&&(!i.every(({filename:s})=>!!s&&s.startsWith(In))||e.some(({type:s,value:n})=>s==="NoResponse"||D(n)&&rp.some(({value:r,exact:o})=>o?n===r:n.includes(r)))&&!t.some(({in_app:s,filename:n})=>s&&!n?.startsWith(In)))}fp(e){return e.some(({value:t})=>D(t)&&ap.some(i=>t.includes(i)))}pp(e){if(e.length>0){var t,i,s,n;let r=(t=(i=e[0].stacktrace)===null||i===void 0?void 0:i.frames)!==null&&t!==void 0?t:[],o=r[r.length-1];return(s=o==null||(n=o.filename)===null||n===void 0?void 0:n.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}cp(e){return!R(e)&&I(e)}}},wp=v({productTours:class{get Il(){return this._instance.persistence}constructor(e){this.mp=null,this.yp=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if("productTours"in t){var i,s;if(this.Il&&this.Il.register({[qn]:!!t.productTours}),!Xs(this._instance))return!this.mp&&R((i=this.Il)===null||i===void 0?void 0:i.props.ph_product_tours)||Ai.info("product tours disabled; stopping and clearing cached tours"),(s=this.mp)===null||s===void 0||s.stop(),this.mp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.mp&&Xs(this._instance)&&this.zo(()=>this.bp())}zo(e){var t,i,s;!((t=C.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(i=C.__PosthogExtensions__)===null||i===void 0||(s=i.loadExternalDependency)===null||s===void 0||s.call(i,this._instance,"product-tours",n=>{n?Ai.error("Could not load product tours script",n):e()})}bp(){var e;!this.mp&&(!((e=C.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.mp=C.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(I(this.yp)&&!t)return void e(this.yp,{isLoaded:!0});let i=this.Il;if(i){let s=i.props[yn];if(I(s)&&!t)return this.yp=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:s=>{if(!Xs(this._instance))return void e([],{isLoaded:!0});let n=s.statusCode;if(n!==200||!s.json){let o=`Product Tours API could not be loaded, status: ${n}`;return n===0?s.error||Ai.warn(o):Ai.error(o),void e([],{isLoaded:!1,error:o})}let r=I(s.json.product_tours)?s.json.product_tours:[];this.yp=r,i&&i.register({[yn]:r}),e(r,{isLoaded:!0})}})}getActiveProductTours(e){R(this.mp)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.mp.getActiveProductTours(e)}showProductTour(e){var t;(t=this.mp)===null||t===void 0||t.showTourById(e)}previewTour(e){this.mp?this.mp.previewTour(e):this.zo(()=>{var t;this.bp(),(t=this.mp)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.mp)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.mp)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.mp)===null||e===void 0||e.previousStep()}clearCache(){var e;this.yp=null,(e=this.Il)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.mp)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.mp)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.mp)===null||t===void 0||t.cancelPendingTour(e)}}},hs),xp={siteApps:class{constructor(e){this._instance=e,this._p=0,this.wp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}kp(e,t){if(!t)return;let i=this.globalsForEvent(t);this.wp.push(i),this.wp.length>1e3&&(this.wp=this.wp.slice(10))}get siteAppLoaders(){var e;return(e=C._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){let e=this._instance._addCaptureHook(this.kp.bind(this));this.Sp=()=>{e(),this.wp=[],this.Sp=void 0}}}globalsForEvent(e){var t,i,s,n,r,o,a;if(!e)throw new Error("Event payload is required");let l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(let[p,f]of Object.entries(u))l[p]={id:c[p],type:p,properties:f};let{$set_once:h,$set:d}=e;return{event:v(v({},ja(e,Yh)),{},{properties:v(v(v({},e.properties),d?{$set:v(v({},(t=(i=e.properties)===null||i===void 0?void 0:i.$set)!==null&&t!==void 0?t:{}),d)}:{}),h?{$set_once:v(v({},(s=(n=e.properties)===null||n===void 0?void 0:n.$set_once)!==null&&s!==void 0?s:{}),h)}:{}),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}}xp(e){var t;let i=(t=e.tagName)===null||t===void 0?void 0:t.toLowerCase();return i==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(je.error("prepare_external_dependency_stylesheet returned null"),null):i==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(je.error("prepare_external_dependency_script returned null"),null):e}$p(){var e,t,i,s,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let l=E?.defaultView,c=l==null||(e=l.Node)===null||e===void 0?void 0:e.prototype;if(!l||!c)return()=>{};if(this._p++,this.Cp)return this.Tp();let u=[],h=this,d=new WeakSet,p=(g,y,m)=>{if(!g?.[y])return;let w=g[y];g[y]=m(w),u.push(()=>{g[y]=w})},f=g=>{if(d.has(g))return g;let y=h.xp(g);return y&&d.add(y),y},_=g=>g.map(y=>typeof y=="string"?y:f(y)).filter(y=>!ne(y));return p(c,"appendChild",g=>function(y){let m=f(y);return m?g.call(this,m):y}),p(c,"insertBefore",g=>function(y,m){let w=f(y);return w?g.call(this,w,m):y}),p(c,"replaceChild",g=>function(y,m){let w=f(y);return w?g.call(this,w,m):m}),[(t=l.Element)===null||t===void 0?void 0:t.prototype,(i=l.Document)===null||i===void 0?void 0:i.prototype,(s=l.DocumentFragment)===null||s===void 0?void 0:s.prototype].forEach(g=>{p(g,"append",y=>function(...m){return y.apply(this,_(m))}),p(g,"prepend",y=>function(...m){return y.apply(this,_(m))})}),[(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(g=>{p(g,"before",y=>function(...m){return y.apply(this,_(m))}),p(g,"after",y=>function(...m){return y.apply(this,_(m))}),p(g,"replaceWith",y=>function(...m){let w=_(m);return m.length&&!w.length?void 0:y.apply(this,w)})}),p((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",g=>function(y,m){let w=f(m);return w?g.call(this,y,w):null}),this.Cp=()=>{u.forEach(g=>g()),this.Cp=void 0},this.Tp()}Tp(){let e=!1;return()=>{var t;e||(e=!0,this._p--,this._p===0&&((t=this.Cp)===null||t===void 0||t.call(this)))}}Ip(e,t=!0){let i=this.$p();try{let s=e(i);return t&&i(),s}catch(s){throw i(),s}}setupSiteApp(e){let t=this.apps[e.id],i=()=>{var r;!t.errored&&this.wp.length&&(je.info(`Processing ${this.wp.length} events for site app with id ${e.id}`),this.wp.forEach(o=>this.Ip(()=>{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.Sp)===null||r===void 0||r.call(this))},s=!1,n=r=>{t.errored=!r,t.loaded=!0,je.info(`Site app with id ${e.id} ${r?"loaded":"errored"}`),s&&i()};try{let{processEvent:r}=this.Ip(o=>e.init({posthog:this._instance,callback(a){o(),n(a)}}),!1);r&&(t.processEvent=r),s=!0}catch(r){je.error(Io+e.id,r),n(!1)}if(s&&t.loaded)try{i()}catch(r){je.error(`Error while processing buffered events PostHog app with config id ${e.id}`,r),t.errored=!0}}Mp(){let e=this.siteAppLoaders||[];for(let t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(let t of e)this.setupSiteApp(t)}Ep(e){if(Object.keys(this.apps).length===0)return;let t=this.globalsForEvent(e);for(let i of Object.values(this.apps))try{this.Ip(()=>{var s;return(s=i.processEvent)===null||s===void 0?void 0:s.call(i,t)})}catch(s){je.error(`Error while processing event ${e.event} for site app ${i.id}`,s)}}onRemoteConfig(e){var t,i,s;if(!((t=this.siteAppLoaders)===null||t===void 0)&&t.length)return this.isEnabled?(this.Mp(),void this._instance.on("eventCaptured",a=>this.Ep(a))):void je.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Sp)===null||i===void 0||i.call(this),!e.ok)return;let n=e.config;if(!((s=n.siteApps)===null||s===void 0)&&s.length)if(this.isEnabled)for(let{id:a,url:l}of n.siteApps){var r,o;C[`__$$ph_site_app_${a}`]=this._instance,(r=C.__PosthogExtensions__)===null||r===void 0||(o=r.loadSiteApp)===null||o===void 0||o.call(r,this._instance,l,c=>{if(c)return je.error(Io+a,c)})}else je.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},kp={tracingHeaders:class{constructor(e){this._instance=e,this.Pp=void 0,this.Rp=void 0,this.Ap=void 0,this.Gf=()=>{let t=this.Fp();var i,s;t?(x(this.Pp)&&(this.Pp=(i=C.__PosthogExtensions__)===null||i===void 0||(i=i.tracingHeadersPatchFns)===null||i===void 0?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),x(this.Rp)&&(this.Rp=(s=C.__PosthogExtensions__)===null||s===void 0||(s=s.tracingHeadersPatchFns)===null||s===void 0?void 0:s._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Yf()}}initialize(){this.startIfEnabledOrStop()}zo(e){var t,i,s;!((t=C.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(i=C.__PosthogExtensions__)===null||i===void 0||(s=i.loadExternalDependency)===null||s===void 0||s.call(i,this._instance,"tracing-headers",n=>{if(n)return qh.error("failed to load script",n);e()})}Op(){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}Fp(){let e=this.Op();return I(e)?(I(this.Ap)?this.Ap.splice(0,this.Ap.length,...e):this.Ap=[...e],e.length>0?this.Ap:void 0):(I(this.Ap)&&this.Ap.splice(0),this.Ap=e||void 0,this.Ap)}Yf(){var e,t;(e=this.Pp)===null||e===void 0||e.call(this),(t=this.Rp)===null||t===void 0||t.call(this),this.Pp=void 0,this.Rp=void 0}startIfEnabledOrStop(){this.Fp()?this.zo(this.Gf):this.Yf()}}},Ep=v({surveys:class extends Kh{constructor(e){var t;super(new ep(e),(t=e,{get projectToken(){return t.config.token},kv:new Qh(t)})),this._instance=e}Wc(e,t){let i=t.query?$i(e,t.query):e;return new Promise(s=>{var n;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((n=t.target)!==null&&n!==void 0?n:"api",i),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:s})})}}},hs),$p={toolbar:class{constructor(e){this.instance=e}Dp(e){C.ph_toolbar_state=e}Lp(){var e;return(e=C.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,i=void 0){var s,n;if(wn(this.instance.config)||!b||!E)return!1;e=(s=e)!==null&&s!==void 0?s:b.location,i=(n=i)!==null&&n!==void 0?n:b.history;try{if(!t){try{b.localStorage.setItem("test","test"),b.localStorage.removeItem("test")}catch{return!1}t=b?.localStorage}let r=tp||is(e.hash,"__posthog")||is(e.hash,"state"),o,a=r?xr(()=>JSON.parse(atob(decodeURIComponent(r))))||xr(()=>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:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):(o=JSON.parse(t.getItem(Co)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Np(e){let t=C.ph_load_toolbar||C.ph_load_editor;!R(t)&&oe(t)?t(e,this.instance):Ro.warn("No toolbar load function found")}loadToolbar(e){let t=!!E?.getElementById("__POSTHOG_TOOLBAR__");if(!b||t)return!1;let i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=v(v({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(b.localStorage.setItem(Co,JSON.stringify(v(v({},s),{},{source:void 0}))),this.Lp()===2)this.Np(s);else if(this.Lp()===0){var n,r;this.Dp(1),(n=C.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,"toolbar",o=>{if(o)return Ro.error("[Toolbar] Failed to load",o),void this.Dp(0);this.Dp(2),this.Np(s)}),G(b,"turbolinks:load",()=>{this.Dp(0),this.loadToolbar(s)})}return!0}qp(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},Sp=v({experiments:class ye{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(i=!1)=>{this.getWebExperiments(s=>{ye.jp("retrieved web experiments from the server"),this.Bp=new Map,s.forEach(n=>{if(n.feature_flag_key){var r;this.Bp&&(ye.jp("setting flag key ",n.feature_flag_key," to web experiment ",n),(r=this.Bp)===null||r===void 0||r.set(n.feature_flag_key,n));let o=this._instance.getFeatureFlag(n.feature_flag_key);D(o)&&n.variants[o]&&this.zp(n.name,o,n.variants[o].transforms)}else if(n.variants)for(let o in n.variants){let a=n.variants[o];ye.Hp(a,this._instance)&&this.zp(n.name,o,a.transforms)}})},i)},this._instance.onFeatureFlags(i=>{this.onFeatureFlags(i)})}initialize(){}onFeatureFlags(t){if(this._is_bot())ye.jp(qo);else if(!this.Mr.disable_web_experiments){if(R(this.Bp))return this.Bp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ye.jp("applying feature flags",t),t.forEach(i=>{var s;if(this.Bp&&(!((s=this.Bp)===null||s===void 0)&&s.has(i))){var n;let r=this._instance.getFeatureFlag(i),o=(n=this.Bp)===null||n===void 0?void 0:n.get(i);r&&o?.variants[r]&&this.zp(o.name,r,o.variants[r].transforms)}})}}previewWebExperiment(){let t=ye.getWindowLocation();if(t?.search){let i=Ut(t?.search,"__experiment_id"),s=Ut(t?.search,"__experiment_variant");i&&s&&(ye.jp(`previewing web experiments ${i} && ${s}`),this.getWebExperiments(n=>{this.Up(parseInt(i),s,n)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,s){if(this.Mr.disable_web_experiments&&!s)return t([]);let n=this._instance.get_property("$web_experiments");if(n&&!i)return t(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:r=>t(r.statusCode===200&&r.json&&r.json.experiments||[])})}Up(t,i,s){let n=s.filter(r=>r.id===t);n&&n.length>0&&(ye.jp(`Previewing web experiment [${n[0].name}] with variant [${i}]`),this.zp(n[0].name,i,n[0].variants[i].transforms))}static Hp(t,i){return!R(t.conditions)&&ye.Wp(t,i)&&ye.Vp(t)}static Wp(t,i){var s;if(R(t.conditions)||R((s=t.conditions)===null||s===void 0?void 0:s.url))return!0;let n=ye.getWindowLocation();if(n){var r,o,a;let l=Sl(i,n.href);return!(!((r=t.conditions)===null||r===void 0)&&r.url)||lp[(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 b?.location}static Vp(t){var i;if(R(t.conditions)||R((i=t.conditions)===null||i===void 0?void 0:i.utm))return!0;let s=Bl();if(s.utm_source){var n,r,o,a,l,c,u,h;let d=!(!((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)==s.utm_campaign,p=!(!((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)==s.utm_source,f=!(!((l=t.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((c=t.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0?void 0:c.utm_medium)==s.utm_medium,_=!(!((u=t.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0)&&u.utm_term)||((h=t.conditions)===null||h===void 0||(h=h.utm)===null||h===void 0?void 0:h.utm_term)==s.utm_term;return d&&f&&_&&p}return!1}static jp(t,...i){S.info(`[WebExperiments] ${t}`,i)}zp(t,i,s){this._is_bot()?ye.jp(qo):i!=="control"?s.forEach(n=>{if(n.selector){var r;ye.jp(`applying transform of variant ${i} for experiment ${t} `,n);let o=(r=document)===null||r===void 0?void 0:r.querySelectorAll(n.selector);o?.forEach(a=>{let l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)})}}):ye.jp("Control variants leave the page unmodified.")}_is_bot(){return pe&&this._instance?uc(pe,this.Mr.custom_blocked_useragents):void 0}}},hs),Pp={conversations:class{constructor(e){this._instance=e,this.Gp=void 0,this._conversationsManager=null,this.Qp=!1,this.ne=null,this.Zp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Jp=e.ok,!e.ok))return;let t=e.config.conversations;R(t)||(xe(t)?this.Gp=t:(this.Gp=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this.Gp=void 0,this.ne=null,this.Jp=void 0,this.Zp=!1}loadIfEnabled(){if(this._conversationsManager||this.Qp||this._instance.config.disable_conversations||wn(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let e=C?.__PosthogExtensions__;if(e&&!x(this.Gp)&&this.Gp)if(this.ne&&this.ne.token){this.Qp=!0;try{let t=e.initConversations;if(t)return this.Kp(t),void(this.Qp=!1);let i=e.loadExternalDependency;if(!i)return void this.Xp(Wn);i(this._instance,"conversations",s=>{s||!e.initConversations?this.Xp("Could not load conversations script",s):this.Kp(e.initConversations),this.Qp=!1})}catch(t){this.Xp("Error initializing conversations",t),this.Qp=!1}}else Ie.error("Conversations enabled but missing token in remote config.")}Kp(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.Zp=!1,Ie.info("Conversations loaded successfully")}catch(t){this.Xp("Error completing conversations initialization",t)}else Ie.error("Cannot complete initialization: remote config is null")}Xp(e,t){Ie.error(e,t),this._conversationsManager=null,this.Qp=!1,this.Zp=!0}show(){this._conversationsManager?this._conversationsManager.show():Ie.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Gp===!0&&!ne(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":wn(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Jp===!1?"remote_config_failed":x(this.Gp)?this.Jp?"disabled_in_project":"remote_config_pending":this.Gp?R(this.ne)||!this.ne.token?"missing_token":C?.__PosthogExtensions__?this.Qp?"initializing":this.Zp?"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,i){var s=this;return X(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(Ie.warn(ft),null)})()}getMessages(e,t){var i=this;return X(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Ie.warn(ft),null)})()}markAsRead(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Ie.warn(ft),null)})()}getTickets(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Ie.warn(ft),null)})()}requestRestoreLink(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Ie.warn(ft),null)})()}restoreFromToken(e){var t=this;return X(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Ie.warn(ft),null)})()}restoreFromUrlToken(){var e=this;return X(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Ie.warn(ft),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}kc(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}Sc(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},Tp={logs:class extends dp{constructor(e){super({get(){var t;return e==null||(t=e.config)===null||t===void 0?void 0:t.logs},captureHintKey:il,get remoteConfigWillArrive(){var t,i;return!(!((t=e.il)===null||t===void 0)&&t.call(e))||!!(!((i=C._POSTHOG_REMOTE_CONFIG)===null||i===void 0||(i=i[e.config.token])===null||i===void 0)&&i.config)}},()=>(function(t){var i;let s={};if(s.distinctId=t.get_distinct_id(),t.sessionManager){let{sessionId:n,windowId:r,sessionStartTimestamp:o,lastActivityTimestamp:a}=t.sessionManager.checkAndGetSessionAndWindowId(!0);s.sessionId=n,s.windowId=r,R(o)||(s.sessionStartTimestamp=o),R(a)||(s.lastActivityTimestamp=a)}if(!(C==null||(i=C.location)===null||i===void 0)&&i.href&&(s.currentUrl=t.config.disable_capture_url_hashes?ct(C.location.href):C.location.href),t.featureFlags){let n=t.featureFlags.getFlags();n&&n.length>0&&(s.activeFeatureFlags=n)}return s})(e)),this._instance=e,this.name=mc,this.Rv()}get Ev(){return this._instance.__loaded}Pv(){let e=te("[logs]"),t=C?.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");let i=t.loadExternalDependency;if(i)return s=>{i(this._instance,"logs",n=>{let r=t.logs;s(n,r?.initializeLogs?{initialize:o=>r.initializeLogs(o),replay(o,a){var l;return(l=r.replayConsoleBuffer)===null||l===void 0?void 0:l.call(r,o,a)}}:void 0)})};e.error(Wn)}}},Mp={metrics:class{constructor(e){this._instance=e,this.A=te("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this.To)return;let t=!!(!((e=this._instance.config.metrics)===null||e===void 0)&&e.network);t&&!this.Yp?this.Yp=(i=>{let s=!0,n=()=>s?(a=>{var l;let c=(l=a.config.metrics)===null||l===void 0?void 0:l.network;return c===!0?{}:c||void 0})(i):void 0,r=vp(i,n),o=fp(i,n);return()=>{s=!1,r(),o()}})(this._instance):!t&&this.Yp&&(this.Yp(),this.Yp=void 0)}Ov(){var e;let t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.metrics;var i;return this.Iv&&this.Dv===t||((i=this.Iv)===null||i===void 0||i.reset(),this.Dv=t,this.Iv=new od(this.Fv(),(function(s){var n,r,o,a,l;let c=s?.resourceAttributes;return{serviceName:(n=c?.["service.name"])!==null&&n!==void 0?n:s?.serviceName,serviceVersion:(r=c?.["service.version"])!==null&&r!==void 0?r:s?.serviceVersion,environment:(o=c?.["deployment.environment"])!==null&&o!==void 0?o:s?.environment,resourceAttributes:c,beforeSend:s?.beforeSend,flushIntervalMs:(a=s?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=s?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(t),this.A)),this.Iv}count(e,t=1,i){this.Ov().count(e,t,i)}gauge(e,t,i){this.Ov().gauge(e,t,i)}histogram(e,t,i){this.Ov().histogram(e,t,i)}flush(e){if(!this.Iv)return Promise.resolve();if(e){let t=this.Iv.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this.Iv.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this.Iv)===null||e===void 0||e.reset()}dispose(){var e,t;this.To=!0,(e=this.Yp)===null||e===void 0||e.call(this),this.Yp=void 0,(t=this.Iv)===null||t===void 0||t.reset()}Fv(){let e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:i=>t.Ys(i),getLibraryId:()=>$e.LIB_NAME,getLibraryVersion:()=>$e.LIB_VERSION}}Ys(e,t){return new Promise(i=>{let s=!1,n=o=>{s||(s=!0,clearTimeout(r),i(o))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(v(v({method:"POST",url:this.tg(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(o){let 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}`)})}}}))})}tg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Op={webMCP:class{constructor(e){this._instance=e,this.eg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.eg)return;let e=E?.modelContext;if(!e||!oe(e.registerTool))return;let t=Wo.get(e);if(t)return t.instances.add(this._instance),void(this.eg=!0);let i={instances:new Set([this._instance])},s=e.registerTool,n=this;Gt(e,"registerTool",r=>{let o=r;return function(a,...l){let c=a;try{c=n.ig(a,i)}catch{return o.call(this,a,...l)}return o.call(this,c,...l)}}),e.registerTool!==s&&(Wo.set(e,i),this.eg=!0)}ig(e,t){if(!e||!oe(e.execute))return e;let i=e.execute,s=this,{tool:n,injected:r}=(function(o,a){let l={intent:!1,model:!1},c=o.inputSchema;if(!(function(f){return!!x(f)||L(f)&&Object.keys(f).every(_=>gp.has(_)||_.startsWith("x-"))&&f.additionalProperties!==!0&&!L(f.additionalProperties)&&(!f.type||f.type==="object")&&(!f.properties||L(f.properties))&&(!f.required||I(f.required))})(c))return{tool:tn(o),injected:l};let u=c?.properties||{},h=f=>en(u,f)||I(c?.required)&&c.required.includes(f);if(l.intent=a.intent&&!h("context"),l.model=a.model&&!h("llm_model"),!l.intent&&!l.model)return{tool:tn(o),injected:l};let d=v({},u),p=I(c?.required)?[...c.required]:[];return l.intent&&(d.context={type:"string",description:`Explain why this tool is called and how it supports the user's goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".`},p.includes("context")||p.push("context")),l.model&&(d.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},p.includes("llm_model")||p.push("llm_model")),{tool:tn(o,v(v({},c),{},{type:c?.type||"object",properties:d,required:p})),injected:l}})(e,(function(o){let a={intent:!1,model:!1};for(let l of o.instances){let c=Yo(l.config.capture_webmcp);a.intent||(a.intent=c?.intent===!0),a.model||(a.model=c?.model===!0)}return a})(t));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){let a=new Date,l=(function(d,p){if(!L(d))return{};try{let f=p.intent?Ko(d.context,2048,!0):void 0,_=p.model?Ko(d.llm_model,256):void 0;return v(v({},f&&f!=="{}"?{intent:f}:{}),_&&_.toLowerCase()!=="unknown"?{model:_}:{})}catch{return{}}})(o[0],r),c=(function(d,p){let f=d[0];if(!L(f))return d;try{let _=p.intent&&en(f,"context"),g=p.model&&en(f,"llm_model");if(!_&&!g)return d;let y=v({},f);return _&&delete y.context,g&&delete y.llm_model,[y,...d.slice(1)]}catch{return d}})(o,r),u;try{u=i.apply(this===n?e:this,c)}catch(d){throw s.ng(t,n,a,!0,l),d}return(h=u)&&typeof h.then=="function"?Promise.resolve(u).then(d=>(s.ng(t,n,a,Jo(d),l),d),d=>{throw s.ng(t,n,a,!0,l),d}):(s.ng(t,n,a,Jo(u),l),u);var h}}),n}ng(e,t,i,s,n){let r=Date.now()-i.getTime();for(let o of e.instances){let a=Yo(o.config.capture_webmcp);if(a)try{o.capture("$mcp_tool_call",v(v({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:Z?.hostname,$mcp_duration_ms:r,$mcp_is_error:s},a.intent&&n.intent?{$mcp_intent:n.intent,$mcp_intent_source:"context_parameter"}:{}),a.model&&n.model?{$mcp_llm_model:n.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:i})}catch{continue}}}}};gi.__defaultExtensionClasses=v({},v(v(v(v(v(v(v(v(v(v(v(v(v(v({},hs),mp),yp),bp),wp),xp),Ep),kp),$p),Sp),Pp),Tp),Mp),Op));var Fp=(function(){$e.SDK_DIST_CHANNEL="npm";let e=vi[ri]=new gi;return(function(){function t(){t.done||(t.done=!0,lc=!1,W(vi,function(i){i._dom_loaded()}))}E?.addEventListener?E.readyState==="complete"?t():G(E,"DOMContentLoaded",t,{capture:!1}):b&&S.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})(),ae=Fp;var me=class me{constructor(t,i=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=hr("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=t=>{if(typeof document>"u"||typeof window>"u")return;let i=`ph_${t}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==i);if(s.length===0)return;let n=window.location.hostname,r=n.split("."),o=r.length>=2?`.${r.slice(-2).join(".")}`:n;s.forEach(a=>{[o,n,""].forEach(c=>{let u=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${u}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(c=>c.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:t,api_host:i,config:s={}}=this.options;if(!t){console.warn("Posthog: No API key provided");return}if(me._hasLoaded||ae.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(t);let n=i||ur();this.log("init | loading PostHog SDK",{api_host:n});let r={api_host:n,ui_host:cr,autocapture:{dom_event_allowlist:["click"],element_allowlist:["button","a"]},rageclick:!0,capture_dead_clicks:!0,rate_limiting:{events_per_second:10,events_burst_limit:100},...s,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...s.session_recording,recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0},before_send:o=>{if(typeof window>"u"||!o)return null;if(o.timestamp){let c=o.timestamp.getTime(),u=Date.now();if(c<u-6048e5||c>u+6048e5)return this.log("init | before_send dropped event with bad timestamp",{event:o.event,timestamp:o.timestamp.toISOString()}),null}let a=window.location.hostname;if(a!=="localhost"&&a!=="127.0.0.1"&&!dr.some(c=>a.endsWith(`.${c}`)||a===c))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(s.before_send){let l=Array.isArray(s.before_send)?s.before_send:[s.before_send],c=o;for(let u of l)c=c?u(c):null;return c}return o}};ae.init(t,r),this.options.app_version&&ae.register({app_version:this.options.app_version}),me._hasLoaded=!0,this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(t){console.error("Posthog: Failed to initialize",t)}};this.resetIfStaleId=(t,i,s)=>{me.isAnonymousId(t)||(this.log(`${s} | stale identified user, resetting`,{previous:t,next:i}),ae.reset())};this.identifyEvent=(t,i={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!t||!t.trim()||me.ILLEGAL_IDS.has(t.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:t});return}let s=ae.get_distinct_id();if(s===t){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:t});return}this.resetIfStaleId(s,t,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:t,traits:i}),ae.identify(t,{...i,client_id:t}),this.has_identified=!0}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),ae.reset(),this.has_identified=!1}catch(t){console.error("Posthog: Failed to reset",t)}};this.backfillPersonProperties=({user_id:t,email:i,language:s,country_of_residence:n})=>{if(!(!this.has_initialized||!t)){if(!t.trim()||me.ILLEGAL_IDS.has(t.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:t});return}try{let r=ae.get_distinct_id(),o=r===t;o||this.resetIfStaleId(r,t,"backfillPersonProperties");let a={};if(ae.get_property("client_id")||(a.client_id=t),i&&ae.get_property("is_internal")==null&&(a.is_internal=pr(i)),s&&!ae.get_property("language")&&(a.language=s),n&&!ae.get_property("country_of_residence")&&(a.country_of_residence=n),o){if(Object.keys(a).length===0){this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:t});return}this.log("backfillPersonProperties | backfilling person properties",{user_id:t,updates:a}),ae.setPersonProperties(a)}else a.client_id||(a.client_id=t),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:t,updates:a}),ae.identify(t,a),this.has_identified=!0}catch(r){console.error("Posthog: Failed to backfill person properties",r)}}};this.capture=(t,i)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:t,properties:i}),ae.capture(t,i)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.isFeatureEnabled=t=>{if(this.has_initialized)try{let i=ae.isFeatureEnabled(t);return this.log("isFeatureEnabled",{key:t,result:i}),i}catch(i){console.error("Posthog: Failed to check feature flag",i);return}};this.getFeatureFlag=t=>{if(this.has_initialized)try{let i=ae.getFeatureFlag(t);return this.log("getFeatureFlag",{key:t,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag",i);return}};this.getFeatureFlagPayload=t=>{if(this.has_initialized)try{let i=ae.getFeatureFlagResult(t)?.payload;return this.log("getFeatureFlagPayload",{key:t,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag payload",i);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let t=ae.featureFlags?.getFlagVariants()??{},i=Object.fromEntries(Object.entries(t).filter(s=>s[1]!=null));return this.log("getAllFlags",{result:i}),i}catch(t){return console.error("Posthog: Failed to get all feature flags",t),{}}};this.onFeatureFlags=t=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let i=ae.onFeatureFlags(t);return typeof i=="function"?i:()=>{}}catch(i){return console.error("Posthog: Failed to subscribe to feature flags",i),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),ae.reloadFeatureFlags()}catch(t){console.error("Posthog: Failed to reload feature flags",t)}};this.options=t,this.debug=i,this.init()}};me._hasLoaded=!1,me.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),me.getPosthogInstance=(t,i=!1)=>(me._instance?t.apiKey&&t.apiKey!==me._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):me._instance=new me(t,i),me._instance),me.isAnonymousId=t=>t?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t):!0;var $c=me;export{$c as Posthog};
5
+ //# sourceMappingURL=posthog-NG27XP3H.mjs.map