1var _=typeof window<"u"?window:void 0,_e=typeof globalThis<"u"?globalThis:_,be=_e==null?void 0:_e.navigator,x=_e==null?void 0:_e.document,te=_e==null?void 0:_e.location,Or=_e==null?void 0:_e.fetch,Ji=_e!=null&&_e.XMLHttpRequest&&"withCredentials"in new _e.XMLHttpRequest?_e.XMLHttpRequest:void 0,Qr=_e==null?void 0:_e.AbortController,nl=_e==null?void 0:_e.CompressionStream,Ee=be==null?void 0:be.userAgent;function pa(){return!(!_||_.navigator.onLine===!1)}var Wt=typeof globalThis<"u"?globalThis:_;Wt&&typeof self>"u"&&(Wt.self=Wt),Wt&&typeof File>"u"&&(Wt.File=function(){});var C=_??{},X={DEBUG:!1,LIB_VERSION:"0.5.1",LIB_NAME:"browser-common"};function Kr(s,e,t,i,r,n,a){try{var o=s[n](a),l=o.value}catch(h){return void t(h)}o.done?e(l):Promise.resolve(l).then(i,r)}function Q(s){return function(){var e=this,t=arguments;return new Promise(function(i,r){var n=s.apply(e,t);function a(l){Kr(n,i,r,a,o,"next",l)}function o(l){Kr(n,i,r,a,o,"throw",l)}a(void 0)})}}function y(){return y=Object.assign?Object.assign.bind():function(s){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},y.apply(null,arguments)}function fa(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}var Zr=s=>{if(typeof s!="string")return s;try{return JSON.parse(s)}catch{return s}};function en(s){return typeof s=="string"||s}function tn(s){return typeof s=="string"?s:void 0}var Jt,al=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Xe=function(s){return s.AnonymousId="anonymous_id",s.DistinctId="distinct_id",s.Props="props",s.EnablePersonProcessing="enable_person_processing",s.PersonMode="person_mode",s.FeatureFlagDetails="feature_flag_details",s.FeatureFlags="feature_flags",s.FeatureFlagPayloads="feature_flag_payloads",s.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",s.BootstrapFeatureFlags="bootstrap_feature_flags",s.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",s.OverrideFeatureFlags="override_feature_flags",s.Queue="queue",s.AiQueue="ai_queue",s.AiCaptureQueue="ai_capture_queue",s.LogsQueue="logs_queue",s.OptedOut="opted_out",s.SessionId="session_id",s.SessionStartTimestamp="session_start_timestamp",s.SessionLastTimestamp="session_timestamp",s.PersonProperties="person_properties",s.GroupProperties="group_properties",s.InstalledAppBuild="installed_app_build",s.InstalledAppVersion="installed_app_version",s.SessionReplay="session_replay",s.PushRegistered="push_registered",s.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",s.SurveyLastSeenDate="survey_last_seen_date",s.SurveysSeen="surveys_seen",s.Surveys="surveys",s.RemoteConfig="remote_config",s.FlagsEndpointWasHit="flags_endpoint_was_hit",s.DeviceId="device_id",s}({}),sn=function(s){return s.GZipJS="gzip-js",s.Base64="base64",s}({}),ol=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],ll=["token"],ga="NativeGzipValidationError",Xi=s=>s.length>=2&&s[0]===31&&s[1]===139,rn=(s,e)=>s===sn.GZipJS||e===sn.GZipJS||e==="gzip",nn=s=>!(!s||typeof s!="object")&&("name"in s?String(s.name):"")==="NotReadableError",ks=s=>{var e=new Error("Native gzip produced invalid output: "+s);throw e.name=ga,e},ul=function(){var s=Q(function*(e,t){18>e.size&&ks("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Xi(i)&&i[2]===8||ks("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(a=>{for(var o=(()=>
1{if(Jt)return Jt;Jt=[];for(var u=0;256>u;u++){for(var c=u,v=0;8>v;v++)c=1&c?3988292384^c>>>1:c>>>1;Jt[u]=c>>>0}return Jt})(),l=4294967295,h=0;a.length>h;h++)l=o[255&(l^a[h])]^l>>>8;return(4294967295^l)>>>0})(t)&&ks("invalid-crc");var n=t.length>>>0;r.getUint32(4,!0)!==n&&ks("invalid-size")});return function(e,t){return s.apply(this,arguments)}}();function Yi(){return Yi=Q(function*(s,e,t){e===void 0&&(e=!0);try{var i=new TextEncoder().encode(s),r=new globalThis.CompressionStream("gzip"),n=r.writable.getWriter(),a=n.write(i).then(()=>n.close()).catch(function(){var h=Q(function*(u){try{yield n.abort(u)}catch{}throw u});return function(u){return h.apply(this,arguments)}}()),o=new Response(r.readable).blob(),l=(yield Promise.all([o,a]))[0];return yield ul(l,i),l}catch(h){if(t!=null&&t.rethrow)throw h;return e&&console.error("Failed to gzip compress data",h),null}}),Yi.apply(this,arguments)}var hl=20,_a=1e3,cl=1e4,dl="[Circular]",Qi="[Truncated]",di="[Unserializable]",vl="[Function]";function Rt(s){for(var e="",t=0;s.length>t;t++){var i=s.charCodeAt(t);if(55296>i||i>56319)e+=56320>i||i>57343?s[t]:"�";else{var r=s.charCodeAt(t+1);56320>r||r>57343?e+="�":(e+=s[t]+s[t+1],t++)}}return e}var pl=["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","pinterest","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"],an=function(s,e){if(e===void 0&&(e=[]),!s)return!1;var t=s.toLowerCase();return pl.concat(e).some(i=>{var r=i.toLowerCase();return t.indexOf(r)!==-1})};function q(s,e){return s.indexOf(e)!==-1}var vi=function(s){return s.trim()},Ki=function(s){return s.replace(/^\$/,"")};function ma(s){var e,t=[];return(e=JSON.stringify(s,function(i,r){if(typeof r=="bigint")return r.toString();if(typeof r!="function"&&typeof r!="symbol"){if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r&&typeof r=="object"){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(r))return"[Circular]";t.push(r)}return r}}))!==null&&e!==void 0?e:"null"}var ya=Object.prototype,ba=ya.hasOwnProperty,pi=ya.toString,A=Array.isArray||function(s){return pi.call(s)==="[object Array]"},ge=s=>typeof s=="function",Y=s=>s===Object(s)&&!A(s),Le=s=>{if(Y(s)){for(var e in s)if(ba.call(s,e))return!1;return!0}return!1},w=s=>s===void 0,H=s=>pi.call(s)=="[object String]",Bs=s=>H(s)&&s.trim().length===0,de=s=>s===null,L=s=>w(s)||de(s),le=s=>pi.call(s)=="[object Number]"&&s==s,Je=s=>le(s)&&s>0,Se=s=>pi.call(s)==="[object Boolean]",fl=s=>s instanceof FormData,gl=s=>q(ol,s),_l=s=>q(ll,s);function wa(s){return s===null||typeof s!="object"}function Hs(s,e){return{}.toString.call(s)==="[object "+e+"]"}function xa(s){switch({}.toString.call(s)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return ka(s,Error)}}function Cr(s){return typeof Event<"u"&&ka(s,Event)}function ka(s,e){try{return s instanceof e}catch{return!1}}var ml=[!0,"true",1,"1","yes"],_i=s=>q(ml,s),yl=[!1,"false",0,"0","no"];function Ue(s,e,t,i,r){return e>t&&(i.warn("min cannot be greater than max."),e=t),le(s)?s>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>s?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):s:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),Ue(r||t,e,t,i))}class bl{constructor(e){this.k={},this.S=e.S,this.C=Ue(e.bucketSize,0,100,e.I),this.R=Ue(e.refillRate,0,this.C,e.I),this.A=Ue(e.refillInterval,0,864e5,e.I)}O(e,t){var i=Math.floor((t-e.lastAccess)/this.A);i>0&&(e.tokens=Math.min(e.tokens+i*this.R,this.C),e.lastAccess=e.lastAccess+i*this.A)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.k[r];return n?this.O(n,i):this.k[r]=n={tokens:this.C,lastAccess:i},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.S)==null||t.call(this,e)),n.tokens===0)}stop(){this.k={}}}var $e="Mobile",zs="iOS",et="Android",Dt="Tablet",Ea=et+" "+Dt,Sa="iPad",Ia="Apple",Pa=Ia+" Watch",as="Safari",Nt="BlackBerry",Fa="Samsung",Ta=Fa+"Browser",$a=Fa+" Internet",mt="Chrome",wl=mt+" OS",Oa=mt+" "+zs,Rr="Internet Explorer",Ca=Rr+" "+$e,Mr="Opera",xl=Mr+" Mini",qr="Edge",Ra="Microsoft "+qr,Mt="Firefox",Ma=Mt+" "+zs,ds="Nintendo",vs="PlayStation",qt="Xbox",qa=et+" "+$e,Aa=$e+" "+as,ss="Windows",Zi=ss+" Phone",on="Nokia",er="Ouya",La="Generic",kl=La+" "+$e.toLowerCase(),Da=La+" "+Dt.toLowerCase(),tr="Konqueror",Na="Oculus Browser",Vs="Vivaldi",ja="Yandex",Us="Whale",sr="DuckDuckGo",Ba="Pale Moon",Gs="Waterfox",os="Brave",Ha="Google Search App",re="(\\d+(\\.\\d+)?)",mi=new RegExp("Version/"+re),El=new RegExp(qt,"i"),Sl=new RegExp(vs+" \\w+","i"),Il=new RegExp(ds+" \\w+","i"),Ar=new RegExp(Nt+"|PlayBook|BB10","i"),Pl={"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"},za=function(s,e,t,i){e=e||"";var r=function(n){return n!=null&&n.brave?os:null}(t);return r||(i!=null&&i.detectGoogleSearchApp&&q(s,"GSA/")?Ha:q(s," OPR/")&&q(s,"Mini")?xl:q(s," OPR/")?Mr:Ar.test(s)?Nt:q(s,"IE"+$e)||q(s,"WPDesktop")?Ca:q(s,"OculusBrowser")?Na:q(s,Ta)?$a:q(s,qr)||q(s,"Edg/")?Ra:q(s,Vs+"/")?Vs:q(s,"YaBrowser/")?ja:q(s,Us+"/")?Us:q(s,sr
1+"/")||q(s,"Ddg/")?sr:q(s,"FBIOS")?"Facebook "+$e:q(s,"UCWEB")||q(s,"UCBrowser")?"UC Browser":q(s,"CriOS")?Oa:q(s,"CrMo")||q(s,mt)?mt:q(s,et)&&q(s,as)?qa:q(s,"FxiOS")?Ma:q(s.toLowerCase(),tr.toLowerCase())?tr:q(s,os+"/")?os:((n,a)=>a&&q(a,Ia)||function(o){return q(o,as)&&!q(o,mt)&&!q(o,et)}(n))(s,e)?q(s,$e)?Aa:as:q(s,"PaleMoon/")?Ba:q(s,Gs+"/")?Gs:q(s,Mt)?Mt:q(s,"MSIE")||q(s,"Trident/")?Rr:q(s,"Gecko")?Mt:"")},Fl={[Ca]:[new RegExp("rv:"+re)],[Ra]:[new RegExp(qr+"?\\/"+re)],[mt]:[new RegExp("("+mt+"|CrMo)\\/"+re)],[Oa]:[new RegExp("CriOS\\/"+re)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+re)],[as]:[mi],[Aa]:[mi],[Mr]:[new RegExp("(Opera|OPR)\\/"+re)],[Mt]:[new RegExp(Mt+"\\/"+re)],[Ma]:[new RegExp("FxiOS\\/"+re)],[tr]:[new RegExp("Konqueror[:/]?"+re,"i")],[Nt]:[new RegExp(Nt+" "+re),mi],[qa]:[new RegExp("android\\s"+re,"i")],[$a]:[new RegExp(Ta+"\\/"+re)],[Na]:[new RegExp("OculusBrowser\\/"+re)],[Vs]:[new RegExp(Vs+"\\/"+re)],[ja]:[new RegExp("YaBrowser\\/"+re)],[Us]:[new RegExp(Us+"\\/"+re)],[os]:[new RegExp(os+"\\/"+re)],[sr]:[new RegExp("(DuckDuckGo|Ddg)\\/"+re)],[Ba]:[new RegExp("PaleMoon\\/"+re)],[Gs]:[new RegExp(Gs+"\\/"+re)],[Ha]:[new RegExp("GSA\\/"+re)],[Rr]:[new RegExp("(rv:|MSIE )"+re)],Mozilla:[new RegExp("rv:"+re)]},Tl=function(s,e,t,i){var r=za(s,e,t,i),n=Fl[r];if(w(n))return null;for(var a=0;n.length>a;a++){var o=s.match(n[a]);if(o)return parseFloat(o[o.length-2])}return null},ln=[[new RegExp(qt+"; "+qt+" (.*?)[);]","i"),s=>[qt,s&&s[1]||""]],[new RegExp(ds,"i"),[ds,""]],[new RegExp(vs,"i"),[vs,""]],[Ar,[Nt,""]],[new RegExp(ss,"i"),(s,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Zi,""];if(new RegExp($e).test(e)&&!/IEMobile\b/.test(e))return[ss+" "+$e,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=Pl[t[1]]||"";return/arm/i.test(e)&&(i="RT"),[ss,i]}return[ss,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,s=>s&&s[3]?[zs,[s[3],s[4],s[5]||"0"].join(".")]:[zs,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,s=>{var e="";return s&&s.length>=3&&(e=w(s[2])?s[3]:s[2]),["watchOS",e]}],[new RegExp("("+et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+et+")","i"),s=>s&&s[2]?[et,[s[2],s[3],s[4]||"0"].join(".")]:[et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,s=>{var e=["Mac OS X",""];return s&&s[1]&&(e[1]=[s[1],s[2],s[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[wl,""]],[/Linux|debian/i,["Linux",""]]],un=function(s){return Il.test(s)?ds:Sl.test(s)?vs:El.test(s)?qt:new RegExp(er,"i").test(s)?er:new RegExp("("+Zi+"|WPDesktop)","i").test(s)?Zi:/iPad/.test(s)?Sa:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?Pa:Ar.test(s)?Nt:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(on,"i").test(s)?on:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":/(Android|ZTE)/i.test(s)?new RegExp($e).test(s)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)||/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?et:Ea:new RegExp("(pda|"+$e+")","i").test(s)?kl:new RegExp(Dt,"i").test(s)&&!new RegExp(Dt+" pc","i").test(s)?Da:""},$l=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function hn(s,e){return typeof(t=s)=="string"&&$l.test(t)?s:e();var t}function rt(s){return s&&s.split("#")[0]}function Lr(s,e){var t=setTimeout(s,e);return t!=null&&t.unref&&(t==null||t.unref()),t}function cn(s,e,t){return Va.apply(this,arguments)}function Va(){return(Va=Q(function*(s,e,t){var i;try{return yield Promise.race([s,new Promise((r,n)=>{i=Lr(()=>{try{t==null||t(),r()}catch(a){n(a)}},e)})])}finally{clearTimeout(i)}})).apply(this,arguments)}var Ua={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}},Ol=Ua.info,dn=9223372036854776e3,Cl={}.propertyIsEnumerable;function Ws(s,e){try{return Ga(s,e,{ancestors:new WeakSet,remainingNodes:cl},0)}catch{return[]}}function Dr(s,e,t,i){if(0>=t.remainingNodes)return{stringValue:Qi};if(t.remainingNodes--,Se(s))return{boolValue:s};if(typeof s=="number"){if(!Number.isFinite(s))return{stringValue:String(s)};if(Number.isInteger(s)){if(Number.isSafeInteger(s))return{intValue:String(s)};if(typeof BigInt>"u")return{stringValue:String(s)};var r=BigInt(s).toString();return s>=dn||-dn>s?(e==null||e.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:s}}if(typeof s=="string")return{stringValue:Rt(s)};if(typeof s=="function")return{stringValue:vl};if(typeof s=="symbol")return{stringValue:String(s)};if(typeof s=="object"&&s!==null){if(t.ancestors.has(s))return{stringValue:dl};if(i>=hl)return{stringValue:Qi};if(s instanceof Date){var n=s.getTime(),a=Number.isFinite(n)?s.toISOString():String(s);
1return{stringValue:typeof a=="string"?Rt(a):String(a)}}t.ancestors.add(s);try{try{var o=s.toJSON;if(typeof o=="function")return Dr(o.call(s),e,t,i+1)}catch{}return A(s)?{arrayValue:{values:Rl(s,e,t,i+1)}}:{kvlistValue:{values:Ga(s,e,t,i+1)}}}finally{t.ancestors.delete(s)}}return{stringValue:Rt(String(s))}}function Rl(s,e,t,i){for(var r=[],n=Math.min(s.length,_a),a=0;n>a&&t.remainingNodes>0;a++)try{var o=a in s?s[a]:void 0;if(L(o))continue;r.push(Dr(o,e,t,i))}catch{r.push({stringValue:di})}return s.length>a&&r.push({stringValue:Qi}),r}function Ga(s,e,t,i){var r=[];for(var n in s)if(Cl.call(s,n)){if(r.length>=_a||0>=t.remainingNodes){e==null||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=s[n];if(de(a)||w(a))continue;r.push({key:Rt(n),value:Dr(a,e,t,i)})}catch{r.push({key:Rt(n),value:{stringValue:di}})}}return r}function Ml(s){try{return Rt(String(s))}catch{return di}}function ql(s,e,t){var i=Ua[s.level||"info"]||Ol,r=i.text,n=i.number,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),L(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),L(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var l=y({},o),h=s.attributes;if(h){var u=[];try{u=Object.keys(h)}catch{u=[]}for(var c of u){var v=void 0;try{v=h[c]}catch{v=di}Object.defineProperty(l,c,{value:v,enumerable:!0,writable:!0,configurable:!0})}}var f={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:r,body:{stringValue:Ml(s.body)},attributes:Ws(l,t)};return s.trace_id&&(f.traceId=s.trace_id),s.span_id&&(f.spanId=s.span_id),w(s.trace_flags)||(f.flags=s.trace_flags),f}function Wa(s,e,t){return y({},s.resourceAttributes,{"service.name":s.serviceName||"unknown_service"},s.environment&&{"deployment.environment":s.environment},s.serviceVersion&&{"service.version":s.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":t})}function Ja(s,e,t,i){return{resourceLogs:[{resource:{attributes:Ws(e)},scopeLogs:[{scope:{name:t,version:i},logRecords:s}]}]}}let Al=class{constructor(s,e,t,i,r,n,a){var o;n===void 0&&(n=()=>Promise.resolve()),this._instance=s,this.qi=e,this.I=t,this.rn=i,this.nn=r,this.sn=n,this.an=a,this.ln=null,this.un=0,this.hn=0,this.dn=0,this.vn=0,this.cn=!1,this.fn=e.maxBufferSize,this.pn=Math.max((o=e.maxQueueSize)!==null&&o!==void 0?o:e.maxBufferSize,e.maxBufferSize),this.gn=e.flushIntervalMs,this.mn=e.maxBatchRecordsPerPost,this.yn=e.rateCapWindowMs,this.bn=e.maxLogsPerInterval}reset(){this._n(),this.ln=null,this.dn=0,this.vn=0,this.cn=!1,this.un=0,this.hn=0,this.mn=this.qi.maxBatchRecordsPerPost}onReconnect(){this.hn=0,this.wn()}captureLog(s){if(!this._instance.isDisabled&&!this._instance.optedOut&&s!=null&&s.body){var e=this.kn(s);if(e!==null)if(e.body){if(this.Sn()){var t={record:ql(e,this.rn(),this.I)};this.nn(()=>this.xn(t))}}else this.I.info("Log was rejected in beforeSend function")}}kn(s){var e=this.qi.beforeSend;if(!e)return s;var t=A(e)?e:[e],i=s;for(var r of t)try{var n=r(i);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;i=n}catch(a){return this.I.error("Error in beforeSend function for log:",a),null}return i}Sn(){if(this.bn===void 0)return!0;var s=Date.now(),e=s-this.dn;return this.yn>e&&e>=0||(this.dn=s,this.vn=0,this.cn=!1),this.bn>this.vn?(this.vn++,!0):(this.cn||(this.I.warn("captureLog dropping logs: exceeded "+this.bn+" logs per "+this.yn+"ms"),this.cn=!0),!1)}flush(){var s=this;return Q(function*(){if(!s._instance.isDisabled)return s.ln||(s.ln=s.Cn().finally(()=>{s.ln=null})),s.ln})()}Cn(){var s=this;return Q(function*(){var e;s._n();var t=(e=s._instance.getPersistedProperty(Xe.LogsQueue))!==null&&e!==void 0?e:[];if(t.length!==0)for(var i=t.length,r=0;t.length>0&&i>r;){var n,a;s.un=0;var o=Math.min(t.length,s.mn),l=t.slice(0,o),h=Ja(l.map(c=>c.record),s.Tn(),(n=s.an)!==null&&n!==void 0?n:s._instance.getLibraryId(),s._instance.getLibraryVersion()),u=yield s._instance.Mn(h);if(u.kind==="too-large"&&l.length>1)s.mn=Math.max(1,Math.floor(l.length/2)),s.I.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+s.mn);else if(u.kind==="retry-later"||(u.kind==="too-large"?s.I.warn("Dropping a single log record after 413 with batch size 1 â the record
1is larger than the server cap and cannot be split further."):u.kind==="ok"&&s.qi.maxBatchRecordsPerPost>s.mn&&(s.mn=Math.min(s.qi.maxBatchRecordsPerPost,s.mn+1)),yield s.En(l.length),t=(a=s._instance.getPersistedProperty(Xe.LogsQueue))!==null&&a!==void 0?a:[],r+=l.length,u.kind==="fatal"))throw u.error}})()}En(s){var e=this;return Q(function*(){var t,i=Math.max(0,s-e.un),r=(t=e._instance.getPersistedProperty(Xe.LogsQueue))!==null&&t!==void 0?t:[];e._instance.setPersistedProperty(Xe.LogsQueue,r.slice(i)),yield e.sn()})()}Tn(){return Wa(this.qi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}xn(s){var e;if(!this._instance.optedOut){var t=(e=this._instance.getPersistedProperty(Xe.LogsQueue))!==null&&e!==void 0?e:[];this.pn>t.length||(t.shift(),this.un++,this.I.info("Logs queue is full, dropping oldest record.")),t.push(s),this._instance.setPersistedProperty(Xe.LogsQueue,t),this.fn>t.length?this.In():this.wn()}}In(s){s===void 0&&(s=this.gn),this.Rn||(this.Rn=Lr(()=>{this.Rn=void 0,this.wn()},s))}Pn(){var s=Math.min(Math.max(0,this.hn-1),6);return this.gn*Math.pow(2,s)}An(){var s=this._instance.getPersistedProperty(Xe.LogsQueue);return!!s&&s.length>0}shutdown(s){var e=this;return Q(function*(){e._n();var t=e.flush().catch(()=>{});s!==void 0?yield cn(t,s):yield t})()}flushWithTimeout(s){var e=this;return Q(function*(){var t=e.flush();yield cn(t,s,()=>{t.catch(()=>{})})})()}wn(){this.flush().then(()=>{this.hn=0},s=>{this.hn++,this.I.error("PostHog logs flush failed:",s)}).finally(()=>{!this._instance.isDisabled&&this.An()&&this.In(this.Pn())})}_n(){this.Rn&&(clearTimeout(this.Rn),this.Rn=void 0)}};var yi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function vn(s){return String(s)+"000000"}function pn(s,e,t,i){var r="";return i&&(r=Object.keys(i).sort().map(n=>JSON.stringify(n)+":"+JSON.stringify(i[n])).join(",")),s+"\0"+e+"\0"+(t??"")+"\0"+r}let Ll=class{constructor(s,e,t){this._instance=s,this.qi=e,this.I=t,this.Fn=new Map,this.ln=null,this.On=!1,this.Ln=new Map,this.$n=new Set,this.Dn=0}count(s,e,t){e===void 0&&(e=1),this.Nn({name:s,type:"count",value:e,unit:t==null?void 0:t.unit,attributes:t==null?void 0:t.attributes})}gauge(s,e,t){this.Nn({name:s,type:"gauge",value:e,unit:t==null?void 0:t.unit,attributes:t==null?void 0:t.attributes})}histogram(s,e,t){this.Nn({name:s,type:"histogram",value:e,unit:t==null?void 0:t.unit,attributes:t==null?void 0:t.attributes})}flush(){var s=this,e=this.ln,t=function(){var r=Q(function*(){e&&(yield e.catch(()=>{})),yield s.qn()});return function(){return r.apply(this,arguments)}}(),i=t().finally(()=>{this.ln===i&&(this.ln=null)});return this.ln=i,i}drainWindow(){if(this.Fn.size===0)return null;var s=this.Fn;return this.Fn=new Map,this.On=!1,this.Ln=new Map,this.$n=new Set,this.jn(s)}reset(){this.Dn++,this._n(),this.Fn=new Map,this.ln=null,this.On=!1,this.Ln=new Map,this.$n=new Set}Nn(s){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.kn(s);if(e!==null)if(e.name&&typeof e.name=="string")if(typeof e.value=="number"&&Number.isFinite(e.value))if(e.type==="count"&&0>e.value)this.I.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var t,i;try{t=e.attributes?y({},e.attributes):void 0,i=pn(e.type,e.name,e.unit,t)}catch(a){return void this.I.warn("Dropping metric '"+e.name+"': attributes could not be serialized",a)}var r=this.Fn.get(i);if(!r){if(!this.Bn())return;r={name:e.name,type:e.type,unit:e.unit,attributes:t,windowStartMs:Date.now()},this.Fn.set(i,r)}var n=this.Ln.get(e.name);n===void 0?this.Ln.set(e.name,e.type):n===e.type||this.$n.has(e.name)||(this.$n.add(e.name),this.I.warn("Metric name '"+e.name+"' is already used as a "+n+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Hn(r,e.value),this.In()}else this.I.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Bn(){return this.qi.maxSeriesPerFlush>this.Fn.size||(this.On||(this.On=!0,this.I.warn("Metric series cap reached ("+this.qi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Hn(s,e){var t;switch(s.type){case"count":s.total=((t=s.total)!==null&&t!==void 0?t:0)+e;break;case"gauge":s.last=e;break;case"histogram":s.hist||(s.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(yi.length+1).fill(0)});var i=s.hist;i.count+=1,i.sum+=e,i.min=Math.min(i.min,e),i.max=Math.max(i.max,e),i.bucketCounts[function(r,n){for(var a=0;n.length>a;a++)if(n[a]>=r)return a;return n.length}(e,yi)]+=1}}kn(s){var e=this.qi.beforeSend;if(!e)return s;var t=A(e)?e:[e],i=s;for(var r of t)try{var n=r(i);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;i=n}catch(a){return this.I.error("Error in beforeSend function for metric:",a),null}return i}In(){this.Rn||(this.Rn=Lr(()=>{this.Rn=void 0,this.flush().catch(s=>{this.I.error("Metrics flush failed:",s)})},this.qi.flushIntervalMs))}_n(){this.Rn&&(clearTimeout(this.Rn),this.Rn=void 0)}qn(){var s=this;return Q(function*(){if(s.Fn.size!==0){var e=s.Fn;s.Fn=new Map,s.On=!1,s.Ln=new Map,s.$n=new Set;var t=s.Dn,i=yield s._instance.Un(s.jn(e));if(t===s.Dn)switch(i.kind){case"ok":return;case"retry-later":return s.zn(e),void s.In();case"too-large":return void s.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void s.I.error("Failed to send metrics batch:",i.error)}}})()}jn(s){return e=this.Wn(s),t=function(n,a,o){return y({},n.resourceAttributes,{"service.name":n.serviceName||"unknown_service"},n.environment&&{"deployment.environment":n.environment},n.serviceVersion&&{"service.version":n.serviceVersion},{"telemetry.sdk.name":a,"telemetry.sdk.version":o})}(this.qi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ws(t)},scopeMetrics:[{scope:{name:i,version:r},metrics:e}]}]};var e,t,i,r}Wn(s){var e=vn(Date.now()),t=new Map;for(var i of s.values()){var r,n=pn(i.type,i.name,i.unit,void 0),a=t.get(n);a||(a=y({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},t.set(n,a));var o=Ws((r=i.attributes)!==null&&r!==void 0?r:{},this.I),l=vn(i.windowStartMs);if(i.type==="count"){var h,u={attributes:o,startTimeUnixNano:l,timeUnixNano:e,asDouble:(h=i.total)!==null&&h!==void 0?h:0};a.sum.dataPoints.push(u)}else if(i.type==="gauge"){var c,v={attributes:o,timeUnixNano:e,asDouble:(c=i.last)!==null&&c!==void 0?c:0};a.gauge.dataPoints.push(v)}else i.hist&&a.histogram.dataPoints.push({attributes:o,startTimeUnixNano:l,timeUnixNano:e,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:yi})}return Array.from(t.values())}zn(s){var e,t;for(var i of s){var r=i[0],n=i[1],a=this.Fn.get(r);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,n.windowStartMs),a.type){case"count":a.total=((e=a.total)!==null&&e!==void 0?e:0)+((t=n.total)!==null&&t!==void 0?t:0);break;case"gauge":break;case"histogram":if(n.hist)if(a.hist){a.hist.count+=n.hist.count,a.hist.sum+=n.hist.sum,a.hist.min=Math.min(a.hist.min,n.hist.min),a.hist.max=Math.max(a.hist.max,n.hist.max);for(var o=0;a.hist.bucketCounts.length>o;o++)a.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else a.hist=n.hist}else this.Bn()&&this.Fn.set(r,n)}}};var Es,fn,bi;function Dl(s){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return bi&&t.length===fn||(fn=t.length,bi=t.reduce((i,r)=>{Es||(Es={});var n=Es[r];if(n)i[n[0]]=n[1];else for(var a=s(r),o=a.length-1;o>=0;o--){var l=a[o],h=l==null?void 0:l.filename,u=e[r];if(h&&u){i[h]=u,Es[r]=[h,u];break}}return i},{})),bi}}class Nl{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),a=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(a,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Q(function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&A(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.ski
1pFirstLines:0),t.chunkIdMap)),y({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Q(function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i})()}convertToExceptionList(e,t){var i,r,n,a={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var o=[a];return e.cause!=null&&o.push(...this.convertToExceptionList(e.cause,y({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:Dl(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var r=(n,a)=>{if(4>=a){var o=this.buildCoercingContext(e,t,a);return this.applyCoercers(n,o)}};return y({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,i),next:n=>r(n,i+1)})}}var jt="?";function ir(s,e,t,i,r){var n={platform:s,filename:e,function:t==="<anonymous>"?jt:t,in_app:!(e!=null&&e.startsWith("webkit-masked-url://"))&&e!=="<anonymous>"};return w(i)||(n.lineno=i),w(r)||(n.colno=r),n}var Xa=(s,e)=>{var t=s.indexOf("safari-extension")!==-1,i=s.indexOf("safari-web-extension")!==-1;return t||i?[s.indexOf("@")!==-1?s.split("@")[0]:jt,t?"safari-extension:"+e:"safari-web-extension:"+e]:[s,e]},jl=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Bl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Hl=/\((\S*)(?::(\d+))(?::(\d+))\)/,zl=(s,e)=>{var t=jl.exec(s);if(t)return ir(e,t[1],jt,+t[2],+t[3]);var i=Bl.exec(s);if(i){if(i[2]&&i[2].indexOf("eval")===0){var r=Hl.exec(i[2]);r&&(i[2]=r[1],i[3]=r[2],i[4]=r[3])}var n=Xa(i[1]||jt,i[2]);return ir(e,n[1],n[0],i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},Vl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ul=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Gl=(s,e)=>{var t=Vl.exec(s);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=Ul.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],n=t[1]||jt,a=Xa(n,r);return ir(e,r=a[1],n=a[0],t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},gn=/\(error: (.*)\)/;class Wl{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=H(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Hs(e,"DOMException")}isDOMError(e){return Hs(e,"DOMError")}}class Jl{match(e){return xa(e)}coerce(e,t){var i,r=this.getStack(e),n=r===void 0;return{type:this.getType(e),value:this.getMessage(e,t),stack:r??((i=t.syntheticException)==null?void 0:i.stack),cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class Xl{constructor(){}match(e){return!!Hs(e,"ErrorEvent")&&(e.error!=null||this.fi(e))}coerce(e,t){var i;if(e.error!=null)return t.apply(e.error);var r=t.apply(e.message);return y({},r,{stack:(i=this.pi(e))!==null&&i!==void 0?i:r.stack,synthetic:!0})}fi(e){return H(e.message)&&e.message.length>0}pi(e){var t,i,r=e,n=(t=r.lineno)!==null&&t!==void 0?t:0,a=(i=r.colno)!==null&&i!==void 0?i:0;if(H(r.filename)&&r.filename.length!==0&&n!==0)return`Error 2 at `+r.filename+":"+n+":"+a}}var Yl=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Ql{match(e){return typeof e=="string"}coerce(e,t){var i,r=this.getInfos(e),n=r[0],a=r[1];return{type:n??"Error",value:a??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Yl);return r&&(t=r[1],i=r[2]),[t,i]}}var Kl=["fatal","error","warning","log","info","debug"];function Ya(s,e){e===void 0&&(e=40);var t=Object.keys(s);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var r=t.slice(0,i).join(", ");
2if(e>=r.length)return i===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}class Zl{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,r,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:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Cr(e))return e.constructor.name;var t="name"in e?e.name:void 0;return H(t)&&!Bs(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+Ya(e)}isSeverityLevel(e){return H(e)&&!Bs(e)&&Kl.indexOf(e)>=0}getStack(e){try{return H(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:H(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(xa(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}}class eu{match(e){return Cr(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Ya(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class tu{match(e){return wa(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class su{match(e){return Hs(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Cr(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return wa(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(r)}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}}var Js="$message",Xs="$timestamp",iu=new Set([Js,Xs]),wi={enabled:!0,max_bytes:32768};function Ys(s){var e;return s?{enabled:(e=s.enabled)!==null&&e!==void 0?e:wi.enabled,max_bytes:nu(s.max_bytes,wi.max_bytes)}:y({},wi)}class ru{constructor(e){this.Vn=[],this.Gn=0,this.qi=Ys(e)}setConfig(e){this.qi=Ys(e),this.Zn()}add(e){var t=function(r){var n;try{n=ma(r)}catch{return}try{var a=JSON.parse(n);if(!Y(a))return;var o=a,l=o[Js],h=o[Xs];return!H(l)||l.trim().length===0||!H(h)&&!le(h)?void 0:{step:o,json:n}}catch{return}}(e);if(t){var i=function(r){if(typeof TextEncoder<"u")return new TextEncoder().encode(r).length;for(var n=encodeURIComponent(r),a=0,o=0;n.length>o;o++)n[o]==="%"?(a+=1,o+=2):a+=1;return a}(t.json);i>this.qi.max_bytes||(this.Vn.push({step:t.step,bytes:i}),this.Gn+=i,this.Zn())}}getAttachable(){return this.Vn.map(e=>e.step)}clear(){this.Vn=[],this.Gn=0}size(){return this.Vn.length}Zn(){for(;this.Gn>this.qi.max_bytes&&this.Vn.length>0;){var e=this.Vn.shift();e&&(this.Gn-=e.bytes)}}}function nu(s,e){if(!le(s)||s===1/0||s===-1/0)return e;var t=Math.floor(s);return 0>t?e:t}var Qa=function(s,e){var t=(e===void 0?{}:e).debugEnabled,i={F(r){if(_&&(X.DEBUG||_.POSTHOG_DEBUG||t)&&!w(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],a=arguments.length,o=new Array(a>1?a-1:0),l=1;a>l;l++)o[l-1]=arguments[l];n(s,...o)}},debug(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];i.F("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];i.F("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];i.F("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];i.F("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];console.error(s,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Qa(s+" "+r,n)};return i},S=Qa("[PostHog.js]"),ee=S.createLogger,au=ee("[ExternalScriptsLoader]"),Qs=s=>{var e=x==null?void 0:x.querySelectorAll("script");
2if(e){for(var t=0;e.length>t;t++)if(e[t].src===s||e[t].getAttribute("src")===s)return e[t]}},ct=(s,e,t)=>{if(s.config.disable_external_dependency_loading)return au.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=Qs(e);if(i){if(i.__posthog_loading_callback_fired)return t();var r=i.__posthog_loading_error;return r?t(r):(i.addEventListener("load",a=>{i.__posthog_loading_callback_fired=!0,t(void 0,a)}),void i.addEventListener("error",a=>{i.__posthog_loading_error=a,t(a)}))}var n=()=>{if(!x)return t("document not found");if(Qs(e))return ct(s,e,t);var a=x.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=e,a.onload=h=>{a.__posthog_loading_callback_fired=!0,t(void 0,h)},a.onerror=h=>{a.__posthog_loading_error=h,t(h)},s.config.prepare_external_dependency_script&&(a=s.config.prepare_external_dependency_script(a)),!a)return t("prepare_external_dependency_script returned null");if(s.config.external_scripts_inject_target==="head")x.head.appendChild(a);else{var o,l=x.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)==null||o.insertBefore(a,l[0]):x.body.appendChild(a)}};x!=null&&x.body?n():x==null||x.addEventListener("DOMContentLoaded",n)},xi={},_n=(s,e)=>{var t="/static/"+e+".js?v="+s.version;if(e==="toolbar"){var i=3e5;t=t+"&t="+Math.floor(Date.now()/i)*i}return s.requestRouter.endpointFor("assets",t)};C.__PosthogExtensions__=C.__PosthogExtensions__||{},C.__PosthogExtensions__.loadExternalDependency=(s,e,t)=>{if(e!=="remote-config"){var i=s.config.strict_script_versioning;if(i){var r=s.requestRouter.endpointFor("assets","/static/"+s.version+"/"+e+".js"),n=xi[r];if(i==="fallback"&&n){if(Qs(n))return void ct(s,n,t);delete xi[r]}ct(s,r,i==="fallback"?(o,l)=>{if(o)if(typeof o=="string")t(o);else{var h,u=_n(s,e);xi[r]=u;var c=Qs(r);c==null||(h=c.parentNode)==null||h.removeChild(c),ct(s,u,t)}else t(void 0,l)}:t)}else ct(s,_n(s,e),t)}else{var a=s.requestRouter.endpointFor("assets","/array/"+s.config.token+"/config.js");ct(s,a,t)}},C.__PosthogExtensions__.loadSiteApp=(s,e,t)=>{var i=s.requestRouter.endpointFor("api",e);ct(s,i,t)};X.DEBUG=!1,X.LIB_VERSION="1.418.15",X.LIB_NAME="web";var Ka="$people_distinct_id",me="distinct_id",ps="$device_id",ki="$device_model",$t="__alias",is="__timers",rr="$autocapture_disabled_server_side",nr="$heatmaps_enabled_server_side",ar="$exception_capture_enabled_server_side",or="$error_tracking_suppression_rules",lr="$error_tracking_capture_extension_exceptions",ur="$web_vitals_enabled_server_side",Nr="$dead_clicks_enabled_server_side",jr="$product_tours_enabled_server_side",hr="$web_vitals_allowed_metrics",ft="$session_recording_remote_config",Za="$replay_sample_rate",eo="$replay_override_sampling",to="$replay_override_linked_flag",so="$replay_override_url_trigger",io="$replay_override_event_trigger",Ot="$sesid",Br="$session_is_sampled",Ye="$enabled_feature_flags",gt="$active_feature_flags",qs="$early_access_features",fs="$feature_flag_details",_t="$feature_flag_payloads",At="$feature_flag_request_id",Ks="$minimal_flag_called_events",Be="$override_feature_flags",dt="$override_feature_flag_payloads",Ae="$stored_person_properties",Ve="$stored_group_properties",ro="$groups",cr="$surveys",Zs="$surveys_loaded_at",dr="$surveys_activated",As="$surveys_activated_session",Ls="$surveys_activated_timestamps",rs="ph_product_tours",Qe="$flag_call_reported",ns="$flag_call_reported_session_id",Lt="$feature_flag_errors",yt="$feature_flag_evaluated_at",D="$user_state",vr="$client_session_props",pr="$capture_rate_limit",fr="$initial_campaign_params",gr="$initial_referrer_info",ei="$initial_person_info",ti="$epp",kt="$posthog_cookieless",no="$cookieless_mode",ao="$sdk_debug_extensions_init_method",oo="$sdk_debug_extensions_init_time_ms",_r="$sdk_debug_recording_script_not_loaded",Hr="PostHog loadExternalDependency extension not found.",vt="on_reject",Ke="always",oe="anonymous",ve="identified",mr="identified_only",si="visibilitychange",ii="beforeunload",Ft="$pageview",Ei="$pageleave",Si="$identify",mn="$groupidentify";
2function Ss(s,e){A(s)&&s.forEach(e)}function U(s,e){if(!L(s))if(A(s))s.forEach(e);else if(fl(s))s.forEach((i,r)=>e(i,r));else for(var t in s)ba.call(s,t)&&e(s[t],t)}var W=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;e>i;i++)t[i-1]=arguments[i];for(var r of t)for(var n in r)r[n]!==void 0&&(s[n]=r[n]);return s};function Ds(s){for(var e=Object.keys(s),t=e.length,i=new Array(t);t--;)i[t]=[e[t],s[e[t]]];return i}var yn=function(s){try{return s()}catch{return}},ou=function(s){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.apply(this,t)}catch(r){S.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),S.critical(r)}}},zr=function(s){var e={};return U(s,function(t,i){(H(t)&&t.length>0||le(t))&&(e[i]=t)}),e},lu=["herokuapp.com","vercel.app","netlify.app"];function uu(s){var e=s==null?void 0:s.hostname;if(!H(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of lu)if(t===i)return!1;return!0}function Z(s,e,t,i){var r=i??{},n=r.capture,a=r.passive;s==null||s.addEventListener(e,t,{capture:n!==void 0&&n,passive:a===void 0||a})}function yr(s){return s.name==="ph_toolbar_internal"}var lo=s=>{if(x){try{for(var e=s+"=",t=x.cookie.split(";").filter(n=>n.length),i=0;t.length>i;i++){for(var r=t[i];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(s){return 0>s?Math.ceil(s):Math.floor(s)}),Number.isInteger||(Number.isInteger=function(s){return le(s)&&isFinite(s)&&Math.floor(s)===s});class ri{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/256,n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new ri(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new ri(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}}class hu{generate(){var e=this.generateOrAbort();if(!w(e))return e;this.Rr=0;var t=this.generateOrAbort();if(w(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e=Date.now();if(e>this.Rr)this.Rr=e,this.Ar();else{if(this.Rr>=e+1e4)return;this.Lr++,this.Lr>4398046511103&&(this.Rr++,this.Ar())}return ri.fromFieldsV7(this.Rr,Math.trunc(this.Lr/Math.pow(2,30)),this.Lr&Math.pow(2,30)-1,this.Or.nextUint32())}Ar(){this.Lr=1024*this.Or.nextUint32()+(1023&this.Or.nextUint32())}constructor(){this.Rr=0,this.Lr=0,this.Or=new cu}}var bn,uo=s=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;s.length>e;e++)s[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return s};_&&!w(_.crypto)&&crypto.getRandomValues&&(uo=s=>crypto.getRandomValues(s));class cu{nextUint32(){return this.ft.length>this.Fr||(uo(this.ft),this.Fr=0),this.ft[this.Fr++]}constructor(){this.ft=new Uint32Array(8),this.Fr=1/0}}var ze=()=>du().toString(),du=()=>(bn||(bn=new hu)).generate(),Xt="",vu=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ue={Dr:()=>!!x,jr(s){S.error("cookieStore error: "+s)},Pr:lo,Br(s){var e;try{e=JSON.parse(ue.Pr(s))||{}}catch{}return e},Nr(s,e,t,i,r){if(!x)return!1;try{var n="",a="",o=function(u,c){if(c){var v=function(d,g){if(g===void 0&&(g=x),Xt)return Xt;if(!g||["localhost","127.0.0.1"].includes(d))return"";for(var p=d.split("."),m=Math.min(p.length,8),b="dmn_chk_"+ze();!Xt&&m--;){var E=p.slice(m).join("."),I=b+"=1;domain=."+E+";path=/";g.cookie=I+";max-age=3",g.cookie.includes(b)&&(g.cookie=I+";max-age=0",Xt=E)}return Xt}(u);if(!v){var f=(d=>{var g=d.match(vu);return g?g[0]:""})(u);f!==v&&S.info("Warning: cookie subdomain discovery mismatch",f,v),v=f}return v?"; domain=."+v:""}return""}(x.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(a="; secure");var h=s+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return h.length>3686.4&&S.warn("cookieStore warning: large cookie, len="+h.length),x.cookie=h,!0}catch{return!1}},qr(s,e){if(x!=null&&x.cookie)try{ue.Nr(s,"",-1,e)}catch{return}}},Ii=null,G={Dr(){if(!de(Ii))return Ii;var s=!0;if(w(_))s=!1;else try{var e="__mplssupport__";G.Nr(e,"xyz"),G.Pr(e)!=='"xyz"'&&(s=!1),G.qr(e)}catch{s=!1}return s||S.error("localStorage unsupported; falling back to cookie store"),Ii=s,s},jr(s){S.error("localStorage error: "+s)},Pr(s){try{return _==null?void 0:_.localStorage.getItem(s)}catch(e){G.jr(e)}return null},Br(s){try{return JSON.parse(G.Pr(s))||{}}catch{}return null},Nr(s,e){try{return _==null||_.localStorage.setItem(s,JSON.stringify(e)),!0}catch(t){G.jr(t)}return!1},qr(s){try{_==null||_.localStorage.removeItem(s)}catch(e){G.jr(e)}}},Pi=[Ae,gt,Ye,fs,_t,At,yt,Lt,Qe],pt=[ps,me,Ot,Br,ti,ei,D],ni=s=>s+"_cpm",pu=["__proto__","constructor","prototype"],Fi=s=>{if(!Y(s))return{};var e={};
2return Object.keys(s).forEach(t=>{pu.indexOf(t)===-1&&(e[t]=s[t])}),e},Ti=function(s,e){e===void 0&&(e=[]);var t={};return[...pt,...e].forEach(i=>{var r=s[i];w(r)||de(r)||r===""||(t[i]=r)}),t},ho=s=>{for(var e=5381,t=2166136261,i=0;s.length>i;i++){var r=s.charCodeAt(i);e=33*e^r,t=Math.imul(t^r,16777619)}return s.length.toString(36)+"."+(e>>>0).toString(36)+"."+(t>>>0).toString(36)},wn=(s,e)=>({p:e,f:ho(JSON.stringify(s))}),xn=(s,e)=>{if(!e)return{properties:[],isValid:!1};try{var t=ue.Br(ni(s)),i=(t==null?void 0:t.f)===ho(e)&&A(t.p);return{properties:i?t.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},$i=(s,e)=>e+"|"+(ue.Pr(ni(s))||""),Is={},fu={Dr:()=>!0,jr(s){S.error("memoryStorage error: "+s)},Pr:s=>Is[s]||null,Br:s=>Is[s]||null,Nr:(s,e)=>(Is[s]=e,!0),qr(s){delete Is[s]}},ot=null,J={Dr(){if(!de(ot))return ot;if(ot=!0,w(_))ot=!1;else try{var s="__support__";J.Nr(s,"xyz"),J.Pr(s)!=='"xyz"'&&(ot=!1),J.qr(s)}catch{ot=!1}return ot},jr(s){S.error("sessionStorage error: ",s)},Pr(s){try{return _==null?void 0:_.sessionStorage.getItem(s)}catch(e){J.jr(e)}return null},Br(s){try{return JSON.parse(J.Pr(s))||null}catch{}return null},Nr(s,e){try{return _==null||_.sessionStorage.setItem(s,JSON.stringify(e)),!0}catch(t){J.jr(t)}return!1},qr(s){try{_==null||_.sessionStorage.removeItem(s)}catch(e){J.jr(e)}}};class gu{constructor(e){this._instance=e}get qi(){return this._instance.config}get consent(){return this.cs()?0:this.fs}isOptedOut(){return this.qi.cookieless_mode===Ke||this.isRejected()||this.consent===-1&&this.qi.cookieless_mode===vt}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qi.opt_out_capturing_by_default}optInOut(e){this.ps.Nr(this.gs,e?1:0,this.qi.cookie_expiration,this.qi.cross_subdomain_cookie,this.qi.secure_cookie)}reset(){this.ps.qr(this.gs,this.qi.cross_subdomain_cookie)}get gs(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get fs(){var e=this.ps.Pr(this.gs);return _i(e)?1:q(yl,e)?0:-1}get ps(){var e=this.qi.opt_out_capturing_persistence_type,t=e==="localStorage"?G:ue;if(!this.ys||this.ys!==t){this.ys=t;var i=e==="localStorage"?ue:G;i.Pr(this.gs)&&(this.ys.Pr(this.gs)||this.optInOut(_i(i.Pr(this.gs))),i.qr(this.gs,this.qi.cross_subdomain_cookie))}return this.ys}cs(){return!!this.qi.respect_dnt&&[be==null?void 0:be.doNotTrack,be==null?void 0:be.msDoNotTrack,C.doNotTrack].some(e=>_i(e))}}function co(s,e){var t,i=s==null||(t=s.config)==null?void 0:t.get_current_url;if(!ge(i))return e;try{var r=i(e);return H(r)&&r?r:e}catch(n){return S.error("Error in get_current_url, falling back to window.location.href",n),e}}var vo="__POSTHOG_TOOLBAR__",_u=1,mu=3,yu=11;function kn(s){return s instanceof Element&&(s.id===vo||!(s.closest==null||!s.closest(".toolbar-global-fade-container")))}function nt(s){return!!s&&s.nodeType===_u}function Te(s,e){return!!s&&!!s.tagName&&s.tagName.toLowerCase()===e.toLowerCase()}function po(s){return!!s&&s.nodeType===mu}function fo(s){return!!s&&s.nodeType===yu&&nt(s.host)}var go=1e3;function Vr(s){return s?vi(s).split(/\s+/):[]}function En(s,e){var t=function(i){var r,n=_==null||(r=_.location)==null?void 0:r.href;return w(n)?void 0:co(i,n)}(e);return!!(t&&s&&s.some(i=>t.match(i)))}function ai(s){var e="";switch(typeof s.className){case"string":e=s.className;break;case"object":e=(s.className&&"baseVal"in s.className?s.className.baseVal:null)||s.getAttribute("class")||"";break;default:e=""}return Vr(e)}function _o(s){return L(s)?null:vi(s).split(/(\s+)/).filter(e=>ls(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function gs(s){var e="";return xr(s)&&!xo(s)&&s.childNodes&&s.childNodes.length&&U(s.childNodes,function(t){var i;po(t)&&t.textContent&&(e+=(i=_o(t.textContent))!==null&&i!==void 0?i:"")}),vi(e)}function br(s){var e;return w(s.target)?s.srcElement||null:(e=s.target)!=null&&e.shadowRoot?s.composedPath()[0]||null:s.target||null}var Ur=["a","button","form","input","select","textarea","label"];function wr(s,e){if(w(e))return!0;var t,i=function(n){if(e.some(a=>function(o,l){var h=o.matches||o.matchesSelector||o.msMatchesSelector||o.mozMatchesSelector||o.webkitMatchesSelector||o.oMatchesSelector;
2try{return!!h&&h.call(o,l)}catch{return!1}}(n,a)))return{v:!0}};for(var r of s)if(t=i(r))return t.v;return!1}function mo(s){var e=s.parentNode;return!(!e||!nt(e))&&e}var bu=[".ph-no-autocapture","[data-ph-no-autocapture]"],yo=["next","previous","prev",">","<"],wu=[...yo,"+","-","â","â"],Sn=(s,e)=>/[a-z0-9]/i.test(e)?s.includes(e):s===e,In=[".ph-no-rageclick",".ph-no-capture"],xu=["","text","search","email","password","url","tel","number"];function bo(s,e){if(!_||Gr(s))return!1;var t,i,r,n,a;if(Se(e)?(t=!!e&&In,i=void 0,r=!1):(t=(n=e==null?void 0:e.css_selector_ignorelist)!==null&&n!==void 0?n:In,i=e==null?void 0:e.content_ignorelist,r=(a=e==null?void 0:e.ignore_text_selection)!==null&&a!==void 0&&a),t===!1||r&&function(l){return!(!l||!nt(l))&&(!!Te(l,"textarea")||(Te(l,"input")?q(xu,(l.getAttribute("type")||"").toLowerCase()):function(h){if(h.isContentEditable)return!0;var u=h.getAttribute==null?void 0:h.getAttribute("contenteditable");return u==="true"||u===""}(l)))}(s))return!1;var o=wo(s,!1).targetElementList;return!function(l,h){if(l===!1||w(l))return!1;var u;if(l===!0)u=yo;else{if(!A(l))return!1;if(l.length>10)return S.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;u=l.map(c=>c.toLowerCase())}return h.some(c=>{var v=c.safeText,f=c.ariaLabel;return u.some(d=>Sn(v,d)||Sn(f,d))})}(i,o.map(l=>{var h;return{safeText:gs(l).toLowerCase(),ariaLabel:((h=l.getAttribute("aria-label"))==null?void 0:h.toLowerCase().trim())||""}}))&&!wr(o,t)}var Gr=s=>!s||Te(s,"html")||!nt(s),wo=(s,e)=>{if(!_||Gr(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],r=s;r.parentNode&&!Te(r,"body");)if(fo(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=mo(r);if(!n)break;if(e||Ur.indexOf(n.tagName.toLowerCase())>-1)t=!0;else try{var a=_.getComputedStyle(n);a&&a.getPropertyValue("cursor")==="pointer"&&(t=!0)}catch{}i.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:i}};function xr(s){for(var e=new Set,t=0,i=s;i.parentNode&&!Te(i,"body");i=i.parentNode){if(t++>=go||e.has(i))return!1;e.add(i);var r=ai(i);if(q(r,"ph-sensitive")||q(r,"ph-no-capture"))return!1}if(q(ai(s),"ph-include"))return!0;var n=s.type||"";if(H(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=s.name||s.id||"";return!H(a)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,""))}function xo(s){return!!(Te(s,"input")&&!["button","checkbox","submit","reset"].includes(s.type)||Te(s,"select")||Te(s,"textarea")||s.getAttribute("contenteditable")==="true")}var Pn=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}))$"),Fn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,ku=[16,15,14,13],Eu=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Tn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),$n=/[0-9A-Za-z_]/;function Su(s){for(var e=0,t=!1,i=s.length-1;i>=0;i--){var r=s.charCodeAt(i)-48;t&&(r*=2)>9&&(r-=9),e+=r,t=!t}return e%10==0}function ls(s,e){if(e===void 0&&(e=!0),L(s))return!1;if(H(s)){s=vi(s);var t=e?Pn.test((s||"").replace(/[- ]/g,"")):function(r){var n;for(Fn.lastIndex=0;n=Fn.exec(r);){var a=n[2];if(a)for(var o=a.replace(/[- ]/g,""),l=0;o.length>l;l++)for(var h of ku){var u=l+h;if(o.length>=u){var c=o.slice(l,u);if(Pn.test(c)&&Su(c))return!0}}}return!1}(s);if(t)return!1;var i=e?Eu.test(s):function(r){var n;for(Tn.lastIndex=0;n=Tn.exec(r);){var a=n[1],o=n[3];if(!(a&&o&&$n.test(a)&&$n.test(o)))return!0}return!1}(s);if(i)return!1}return!0}function On(s){var e=gs(s);return ls(e=(e+" "+ko(s)).trim())?e:""}function ko(s){var e="";return s&&s.childNodes&&s.childNodes.length&&U(s.childNodes,function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=gs(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+ko(t)).trim())}catch(n){S.error("[AutoCapture]",n)}}),e}function Cn(s){return s.replace(/"|\\"/g,'\\"')}function Iu(s){var e=s.attr__class;
2if(e)return A(e)?e:Vr(e)}var Ps=ee("[Dead Clicks]"),Pu=()=>!0,Fu=s=>{var e,t=!((e=s.instance.persistence)==null||!e.get_property(Nr)),i=s.instance.config.capture_dead_clicks;return Se(i)?i:!!Y(i)||t};class Rn{get lazyLoadedDeadClicksAutocapture(){return this.bs}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Nr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._s(()=>{this.ws()}):this.stop()}_s(e){var t,i;(t=C.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture?e():(i=C.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",r=>{r?Ps.error("failed to load script",r):e()})}ws(){var e;if(x){if(!this.bs&&(e=C.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Y(this.instance.config.capture_dead_clicks)?y({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.bs=C.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.bs.start(x),Ps.info("starting...")}}else Ps.error("`document` not found. Cannot start.")}stop(){this.bs&&(this.bs.stop(),this.bs=void 0,Ps.info("stopping..."))}}var Oi=ee("[SegmentIntegration]"),Eo="posthog-js";function So(s,e){var t=e===void 0?{}:e,i=t.organization,r=t.projectId,n=t.prefix,a=t.severityAllowList,o=a===void 0?["error"]:a,l=t.sendExceptionsToPostHog,h=l===void 0||l;return u=>{var c,v,f,d,g;if(o!=="*"&&!o.includes(u.level)||!s.__loaded)return u;u.tags||(u.tags={});var p=s.requestRouter.endpointFor("ui","/project/"+s.config.token+"/person/"+s.get_distinct_id());u.tags["PostHog Person URL"]=p,s.sessionRecordingStarted()&&(u.tags["PostHog Recording URL"]=s.get_session_replay_url({withTimestamp:!0}));var m,b=((c=u.exception)==null?void 0:c.values)||[],E=b.map(k=>y({},k,{stacktrace:k.stacktrace?y({},k.stacktrace,{type:"raw",frames:(k.stacktrace.frames||[]).map($=>y({},$,{platform:"web:javascript"}))}):void 0})),I={$exception_message:((v=b[0])==null?void 0:v.value)||u.message,$exception_type:(f=b[0])==null?void 0:f.type,$exception_level:u.level,$exception_list:E,$sentry_event_id:u.event_id,$sentry_exception:u.exception,$sentry_exception_message:((d=b[0])==null?void 0:d.value)||u.message,$sentry_exception_type:(g=b[0])==null?void 0:g.type,$sentry_tags:u.tags};return i&&r&&(I.$sentry_url=(n||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+u.event_id),h&&((m=s.exceptions)==null||m.sendExceptionEvent(I)),u}}class Tu{constructor(e,t,i,r,n,a){this.name=Eo,this.setupOnce=function(o){o(So(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:a==null||a}))}}}class Mn{constructor(e){this.ks=(t,i,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength||r.crossTabAdoption)&&(S.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.Ss=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.xs()}xs(){var e;this.Cs=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.ks)}destroy(){var e;(e=this.Cs)==null||e.call(this),this.Cs=void 0}doPageView(e,t){var i,r=this.Ts(e,t);return this.Ss={pathname:(i=_==null?void 0:_.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.Ts(e,(t=this.Ss)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Ss)==null?void 0:e.pageViewId}}Ts(e,t){var i=this.Ss;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var a=n.maxScrollHeight,o=n.lastScrollY,l=n.maxScrollY,h=n.maxContentHeight,u=n.lastContentY,c=n.maxContentY;if(!(w(a)||w(o)||w(l)||w(h)||w(u)||w(c))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),h=Math.ceil(h),u=Math.ceil(u),c=Math.ceil(c);var v=a>
21?Ue(o/a,0,1,S):1,f=a>1?Ue(l/a,0,1,S):1,d=h>1?Ue(u/h,0,1,S):1,g=h>1?Ue(c/h,0,1,S):1;r=W(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:v,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:d,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:g})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var Ci=["flags","surveys"],$u={[Ka]:{exposure:"hidden"},[$t]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[is]:{exposure:"hidden"},[rr]:{exposure:"event"},[nr]:{exposure:"hidden"},[ar]:{exposure:"event"},[or]:{exposure:"hidden"},[lr]:{exposure:"event"},[ur]:{exposure:"event"},[Nr]:{exposure:"event"},[jr]:{exposure:"hidden"},[hr]:{exposure:"event"},[ft]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Ot]:{exposure:"hidden"},[Br]:{exposure:"event"},[Za]:{exposure:"event",shouldSkipFromEventProperties:s=>de(s)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[Ye]:{exposure:"hidden",storageGroup:"flags"},[gt]:{exposure:"hidden",storageGroup:"flags"},[qs]:{exposure:"hidden"},[fs]:{exposure:"hidden",storageGroup:"flags"},[_t]:{exposure:"hidden",storageGroup:"flags"},[At]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Ks]:{exposure:"hidden",storageGroup:"flags"},[Be]:{exposure:"hidden"},[dt]:{exposure:"hidden"},[Ae]:{exposure:"hidden"},[Ve]:{exposure:"hidden"},[cr]:{exposure:"hidden",storageGroup:"surveys"},[Zs]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[dr]:{exposure:"event"},[As]:{exposure:"hidden"},[Ls]:{exposure:"hidden"},[rs]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[Qe]:{exposure:"hidden"},[ns]:{exposure:"hidden"},[ro]:{exposure:"event"},[Lt]:{exposure:"hidden"},[yt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[D]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[fr]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[ei]:{exposure:"hidden"},[ti]:{exposure:"hidden"},[eo]:{exposure:"event"},[to]:{exposure:"event"},[so]:{exposure:"event"},[io]:{exposure:"event"},[ao]:{exposure:"event"},[oo]:{exposure:"event"},[_r]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"}
2,$sdk_debug_replay_pending_trigger_conditions:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},Ou=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],He=s=>{var e=$u[s];if(e)return e;for(var t of Ou){var i=t[1];if(s.indexOf(t[0])===0)return i}},Ct=(s,e)=>{try{return JSON.stringify(s,(t,i)=>typeof i=="bigint"?i.toString():i,e)}catch{return ma(s)}},Bt=s=>{var e=x==null?void 0:x.createElement("a");return w(e)?null:(e.href=s,e)},Ht=function(s,e){for(var t,i=((s.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){t=n;break}}if(!A(t)||2>t.length)return"";var a=t[1];try{a=decodeURIComponent(a)}catch{S.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},_s=function(s,e,t){if(!s||!e||!e.length)return s;for(var i=s.split("#"),r=i[1],n=(i[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),h=[],u=0;l.length>u;u++){var c=l[u].split("=");A(c)&&(e.includes(c[0])?h.push(c[0]+"="+t):h.push(l[u]))}var v=o;return a!=null&&(v+="?"+h.join("&")),r!=null&&(v+="#"+r),v},oi=function(s,e){var t=s.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Io=(s,e)=>s>=e&&pa(),Po=(s,e,t,i)=>{if(s===0){if(pa()){var r=e+1;return r===t&&i(),r}return e}return 0},Fs="https?://(.*)",zt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Cu=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...zt],ms="<masked>",Ru=["li_fat_id"];function Fo(s,e,t){if(!x)return{};var i,r=e?[...zt,...t||[]]:[],n=To(_s(x.URL,r,ms),s),a=(i={},U(Ru,function(o){var l=lo(o);i[o]=l||null}),i);return W(a,n)}function To(s,e){var t=Cu.concat(e||[]),i={};return U(t,function(r){var n=Ht(s,r);i[r]=n||null}),i}function $o(s){var e=function(n){return n?n.search(Fs+"google.([^/?]*)")===0?"google":n.search(Fs+"bing.com")===0?"bing":n.search(Fs+"yahoo.com")===0?"yahoo":n.search(Fs+"duckduckgo.com")===0?"duckduckgo":null:null}(s),t=e!="yahoo"?"q":"p",i={};if(!de(e)){i.$search_engine=e;var r=x?Ht(x.referrer,t):"";r.length&&(i.ph_keyword=r)}return i}function qn(){return navigator.language||navigator.userLanguage}var li="$direct";function Oo(){return(x==null?void 0:x.referrer)||li}function Co(s,e,t){t===void 0&&(t=!1);var i=s?[...zt,...e||[]]:[],r=t?rt(te==null?void 0:te.href):te==null?void 0:te.href,n=r==null?void 0:r.substring(0,1e3);return{r:Oo().substring(0,1e3),u:n?_s(n,i,ms):void 0}}function Ro(s,e){var t;e===void 0&&(e=!1);var i=s.r,r=s.u,n=e?rt(r):r,a={$referrer:i,$referring_domain:i==null?void 0:i==li?li:(t=Bt(i))==null?void 0:t.host};if(n){a.$current_url=n;var o=Bt(n);a.$host=o==null?void 0:o.host,a.$pathname=o==null?void 0:o.pathname;var l=To(n);W(a,l)}if(i){var h=$o(i);W(a,h)}return a}function Mo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Mu(){try{return new Date().getTimezoneOffset()}catch{return}}var qu={flags:yt,surveys:Zs},Au=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ts=s=>s+"_cookie_identity_change_pending",st="main",An=(s,e)=>{U(s,(t,i)=>{var r=He(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(e,i)||delete s[i]})};class Ri{constructor(e,t,i){if(i===void 0&&(i=!0),this.Ms={},this.Es=!1,this.Is=!1,this.Rs=!1,this.Ps=!1,this.qi=e,this.As=i,this.props={},this.Fs=void 0,this.Os=(n=>{var a="";return n.token&&(a=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+a+"_posthog"})(e),this.ps=this.Ls(e),this.Is=this.$s(e),this.load(),e.debug&&S.info("Persistence loaded",e.persistence,y({},this.props)),this.update_config(e,e,t),this.save(),_){var r=()=>this.flush();Z(_,"beforeunload",r,{capture:!1}),Z(_,"pagehide",r,{capture:!1})}}Ds(){var e,t=(e=this.qi)==null?void 0:e.persistence_save_debounce_ms;return le(t)&&t>0?t:0}Ns(e){if(this.qi.cookieWinsOnConflict&&this.qi.persistence.toLowerCase()==="localstorage+cookie")if(e)try{var t=Ti(e,this.qi.cookie_persisted_properties||[]),i=wn(t,this.qi.cookie_persisted_properties||[]),r=J
2SON.stringify(t)+"|"+JSON.stringify(i),n=ue.Pr(this.Os)||void 0;n&&$i(this.Os,n)===r&&(this.qs=r,this.js=n)}catch{}else try{var a=ue.Pr(this.Os)||void 0;this.qs=a?$i(this.Os,a):void 0,this.js=a}catch{}}syncCookieProperties(){return this.Bs(this.qi)}Bs(e,t){if(t===void 0&&(t=!1),this.Hs&&!t||this.Ps||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;var i;try{i=ue.Pr(this.Os)||void 0}catch{}if(!i||i===this.js)return!1;var r,n=$i(this.Os,i);try{r=Fi(JSON.parse(i))}catch{return!1}if((ue.Pr(this.Os)||void 0)!==i)return!1;this.qs=n,this.js=i;var a=xn(this.Os,i),o=[...pt,...a.properties],l={};if(Object.keys(r).forEach(g=>{var p=r[g];(w(p)||de(p)||p===""||g===D&&p!==oe&&p!==ve)&&(l[g]=!0,delete r[g])}),Le(r))return!1;var h=me in r||r[D]===oe||r[D]===ve,u=this.props[me],c=this.props[D],v=W({},this.props);[...pt,...e.cookie_persisted_properties||[]].forEach(g=>{if(o.indexOf(g)!==-1&&!(g in r)&&!l[g]&&(h||g!==me&&g!==D)){var p=v[g];!a.isValid&&pt.indexOf(g)!==-1&&(p===!1||p===0)||delete v[g]}}),this.props=W(v,r),!h||D in r||D in this.props||this.Us(D,oe);var f=this.props[me],d=this.props[D];return!h||f===u&&d===c||(this.Rs=!0,J.Nr(Ts(this.Os),!0),this.zs(Ae),this.zs(gt),this.zs(Ye),this.zs(fs),this.zs(_t),this.zs(At),this.zs(yt),this.zs(Lt),this.zs(Qe),d===oe&&(c===ve||r[D]===oe||!w(u)&&f!==u)&&(An(this.props,r),this.zs(Ve)),d===ve?this.props.$user_id=f:delete this.props.$user_id,this.zs($t)),!0}
2consumeCookieIdentityChange(){var e=Ts(this.Os),t=this.Rs||!!J.Pr(e);return this.Rs=!1,t&&J.qr(e),t}Ws(e){return e===void 0&&(e=!1),!(this.Ps||this.Hs&&!e||!this.qi.cookieWinsOnConflict||this.qi.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ps=!0,0))}Vs(){this.Ps&&(w(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0),delete this.Ms[st],this.Zs(!0))}Qs(e){if(e===void 0&&(e=!0),this.Ps)try{e?this.Vs():w(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0)}finally{this.Ps=!1}}isDisabled(){return!!this.Hs}Ls(e){Au.indexOf(e.persistence.toLowerCase())===-1&&(S.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,i=function(a,o){a===void 0&&(a=[]),o===void 0&&(o=!1);var l=[...pt,...a];return y({},G,{Br(h){try{var u,c={};try{u=ue.Pr(h)||void 0,c=u?Fi(JSON.parse(u)):{}}catch{}var v,f=JSON.parse(G.Pr(h)||"{}");if(o){var d=xn(h,u),g=[...pt,...d.properties],p={};Object.keys(c).forEach(k=>{var $=c[k];de($)||$===""||k===D&&$!==oe&&$!==ve||(p[k]=$)});var m=me in p||p[D]===oe||p[D]===ve;if(Object.keys(p).length>0){var b,E=f[me],I=(b=f[D])!==null&&b!==void 0?b:oe;l.forEach(k=>{if(g.indexOf(k)!==-1&&!(k in c)&&(m||k!==me&&k!==D)){var $=f[k];!d.isValid&&pt.indexOf(k)!==-1&&($===!1||$===0)||delete f[k]}}),!m||D in c||D in f||(f[D]=oe),!m||(me in p?p[me]:f[me])===E&&(D in p?p[D]:f[D])===I||(Pi.forEach(k=>delete f[k]),p[D]===ve&&me in p?f.$user_id=p[me]:delete f.$user_id,p[D]!==ve&&(delete f[ro],delete f[Ve]),delete f.__alias)}v=W(f,p)}else v=W(c,f);return G.Nr(h,v),v}catch{}return null},Nr(h,u,c,v,f,d){var g=G.Nr(h,u,void 0,void 0,d);try{var p=Ti(u,a);if(Object.keys(p).length){if(o){var m=ni(h),b=wn(p,a);if(ue.Nr(m,b,c,v,f,d),ue.Pr(m)!==JSON.stringify(b)){ue.qr(m,v);var E=Ti(u);return ue.Nr(h,E,c,v,f,d),g}}ue.Nr(h,p,c,v,f,d)}}catch(I){G.jr(I)}return g},qr(h,u){try{_==null||_.localStorage.removeItem(h),ue.qr(h,u),ue.qr(ni(h),u)}catch(c){G.jr(c)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),r=!1,n=e.persistence.toLowerCase();return n==="localstorage"&&G.Dr()?(t=G,r=!0):n==="localstorage+cookie"&&i.Dr()?(t=i,r=!0):n==="sessionstorage"&&J.Dr()?t=J:n==="memory"?t=fu:n==="cookie"?t=ue:i.Dr()?(t=i,r=!0):t=ue,this.Es=r,t}Js(e){return this.Os+"__"+e}$s(e){return this.Es&&!!e.split_storage}properties(){var e={};return U(this.props,(t,i)=>{var r=He(i);if(!r||r.exposure==="event"){if(r!=null&&r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t))return;e[i]=t}}),e}load(e){if(e===void 0&&(e=!1),!this.Hs||e){var t=this.qi.cookieWinsOnConflict&&this.qi.persistence.toLowerCase()==="localstorage+cookie",i=t?G.Br(this.Os):null,r={};if(t)try{U(r=Fi(ue.Br(this.Os)),(d,g)=>{(w(d)||de(d)||d==="")&&delete r[g]})}catch{}var n=this.ps.Br(this.Os);if(n&&(this.props=W({},n)),this.Is&&this.Ks(),t&&n){var a,o,l=i==null?void 0:i[me],h=(a=i==null?void 0:i[D])!==null&&a!==void 0?a:oe,u=n[me],c=(o=n[D])!==null&&o!==void 0?o:oe;if(u!==l||c!==h){this.Rs=!0,J.Nr(Ts(this.Os),!0);var v=W({},this.props);Pi.forEach(d=>delete v[d]),c===oe&&(h===ve||r[D]===oe||!w(l)&&u!==l)&&(An(v,r),delete v[Ve]),this.props=v;var f=new Set;Pi.forEach(d=>{var g,p=(g=He(d))==null?void 0:g.storageGroup;p&&f.add(p)}),f.forEach(d=>{var g={};U(this.props,(p,m)=>{var b;((b=He(m))==null?void 0:b.storageGroup)===d&&(g[m]=p)}),Le(g)?(G.qr(this.Js(d)),this.Ms[d]={}):G.Nr(this.Js(d),g)&&(this.Ms[d]={persisted:!0,fingerprint:this.Ys(g,d)})})}}J.Pr(Ts(this.Os))&&(this.Rs=!0)}}Ks(){for(var e of Ci){var t=G.Br(this.Js(e));if(t&&!Le(t)){var i=this.Xs(e);i.persisted=!0,this.ta(e)||(i.fingerprint=this.Ys(t,e)),this.ea(e,t)||W(this.props,t)}}}ta(e){return Object.keys(this.props).some(t=>{var i;return((i=He(t))==null?void 0:i.storageGroup)===e})}ea(e,t){var i=qu[e];if(!i)return!1;var r=t[i],n=this.props[i];return le(r)&&le(n)&&n>r}refreshKey(e){var t;if(!this.Hs){var i=this.Is?(t=He(e))==null?void 0:t.storageGroup:void 0,r=i?G.Br(this.Js(i)):this.ps.Br(this.Os);if(r&&e in r)this.Us(e,r[e]);else{if(i){var n=this.ps.Br(this.Os);if(n&&e in n)return void this.Us(e,n[e])}this.zs(e)}}}save(){if(!this.Hs){var e=this.Ds();e>0?w(this.Gs)&&(this.Gs=setTimeout(()=>{this.Gs=void 0,this.Zs()},e)):this.Zs()}}flush(){w(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0,this.Zs())}Zs(e){e===void 0&&(e=!1),this.Hs||this.Ps&&!e||(e||this.syncCookieProperties(),this.Is?this.ia():this.ra(this.ps,this.Os,this.props,st)&&this.Ns(this.props))}ia(){var e=this.na(),t=e.main,i=e.groups;for(var r of(this.ra(this.ps,this.Os,t,st)&&this.Ns(t),Ci)){var n,a=i[r];(!Le(a)||(n=this.Ms[r])!=null&&n.persisted)&&this.ra(G,this.Js(r),a,r)}}na(){var e={},t={flags:{},surveys:{}};return U(this.props,(i,r)=>{var n,a=(n=He(r))==null?void 0:n.storageGroup;a?t[a][r]=i:e[r]=i}),{main:e,groups:t}}Ys(e,t){if(t===st)return JSON.stringify(e)+"|"+this.sa+"|"+this.aa+"|"+this.oa;var i={};return U(e,(r,n)=>{var a;i[n]=(a=He(n))!=null&&a.volatile?"__volatile__":r}),JSON.stringify(i)}ra(e,t,i,r){var n,a=this.Xs(r);if(r!==st&&!a.dirty&&!w(a.fingerprint))return!1;try{if((n=this.Ys(i,r))===a.fingerprint)return a.dirty=!1,!1}catch{n=void 0}return e.Nr(t,i,this.sa,this.aa,this.oa,this.qi.debug)?(a.dirty=!1,r!==st&&(a.persisted=!0),w(n)||(a.fingerprint=n),!0):(this.qi.debug&&S.warn('failed to persist storage entry "'+t+'"; will retry on next save'),!1)}remove(e){var t=(e===void 0?{}:e).keepGroupEntries,i=t!==void 0&&t;if(w(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0),this.ps.qr(this.Os,!1),this.ps.qr(this.Os,!0),!i&&this.As)for(var r of Ci)G.qr(this.Js(r));i?delete this.Ms[st]:this.Ms={},this.qs=void 0,this.js=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Y(e)){this.syncCookieProperties(),w(t)&&(t="None"),this.sa=w(i)?this.la:i;var r=!1;if(U(e,(n,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.Us(a,n),r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(Y(e)){this.syncCookieProperties(),this.sa=w(t)?this.la:t;var i=!1;if(U(e,(r,n)=>{e.hasOwnProperty(n)&&(this.props[n]!==r||Y(r)||A(r))&&(this.Us(n,r),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t=typeof e=="string"?[e]:e,i=!1;for(var r of t)r in this.props&&(this.zs(r),i=!0);i&&this.save()}update_campaign_params(){var e=x==null?void 0:x.URL;if(e!==this.Fs){var t=Fo(this.qi.custom_campaign_params,this.qi.mask_personal_data_properties,this.qi.custom_personal_data_properties);Le(zr(t))||this.register(t),this.Fs=e}}update_search_keyword(){var e;this.register((e=x==null?void 0:x.referrer)?$o(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Oo(),$referring_domain:x!=null&&x.referrer&&((e=Bt(x.referrer))==null?void 0:e.host)||li},void 0)}set_initial_person_info(){this.props[fr]||this.props[gr]||this.register_once({[ei]:Co(this.qi.mask_personal_data_properties,this.qi.custom_personal_data_properties,this.qi.disable_capture_url_hashes
2)},void 0)}get_initial_props(){var e={};U([gr,fr],r=>{var n=this.props[r];n&&U(n,function(a,o){e["$initial_"+Ki(o)]=a})});var t=this.props[ei];if(t){var i=function(r,n){n===void 0&&(n=!1);var a=Ro(r,n),o={};return U(a,function(l,h){o["$initial_"+Ki(h)]=l}),o}(t,this.qi.disable_capture_url_hashes);W(e,i)}return e}safe_merge(e){return U(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){var r=e.persistence!==t.persistence,n=!((g,p)=>{if(g.length!==p.length)return!1;var m=[...g].sort(),b=[...p].sort();return m.every((E,I)=>E===b[I])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,l=e.disable_persistence||!!i,h=!!this.Hs&&!l;l||this.Bs(t,h),this.qi=e,!l&&(r||n||o)&&(this.qs=void 0,this.js=void 0,this.Bs(y({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),h));var u=a||o?this.Ls(e):this.ps,c=this.$s(e),v=a||c!==this.Is,f=!l&&(v||e.cross_subdomain_cookie!==this.aa||e.secure_cookie!==this.oa)&&this.Ws(h);try{if(this.la=this.sa=e.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),v){var d=this.props;this.clear(),this.ps=u,this.Is=c,this.props=d,this.save()}else o&&(this.ps=u,l||(delete this.Ms[st],this.Zs()))}finally{f&&this.Qs()}}set_disabled(e){this.Hs=e,this.Hs?this.remove():this.save()}set_cross_subdomain(e){e!==this.aa&&(this.aa=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.oa&&(this.oa=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props[is]||{};i[e]=t,this.Us(is,i),this.save()}remove_event_timer(e){var t=this.props[is]||{},i=t[e];return w(i)||(delete t[e],this.Us(is,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this.Us(e,t),this.save()}Us(e,t){var i;this.props[e]=t,(i=He(e))!=null&&i.volatile||this.ua(e)}zs(e){delete this.props[e],this.ua(e)}ua(e){var t,i=(t=He(e))==null?void 0:t.storageGroup;i&&(this.Xs(i).dirty=!0)}Xs(e){return this.Ms[e]||(this.Ms[e]={})}}function $s(s){var e=!0;return{dispose(){if(e){e=!1;var t=s();t&&ge(t.then)&&t.then(void 0,()=>{})}}}}var ye={GZipJS:"gzip-js",Base64:"base64"},Yt={Activation:"events",Cancellation:"cancelEvents"},Mi={Popover:"popover",API:"api",Widget:"widget"},Ze={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},qi={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},kr={Popover:"popover",Inline:"inline"},Lu={SHOWN:"product tour shown"},Ln={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Dn=ee("[RateLimiter]");class Du{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(r=>{Dn.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void Dn.warn('could not rate limit - continuing. Error: "'+(r==null?void 0:r.message)+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;e===void 0&&(e=!1);var n=this.captureEventsBurstLimit,a=this.captureEventsPerSecond,o=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(pr))!==null&&t!==void 0?t:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*a,l.last=o,l.tokens>n&&(l.tokens=n);var h=1>l.tokens;if(h||e||(l.tokens=Math.max(0,l.tokens-1)),h&&!e){var u=(le(l.dropped)?l.dropped:0)+1;l.dropped=u,!this.lastEventRateLimited&&this.ha(u)&&(l.dropped=0)}return this.lastEventRateLimited=h,(r=this.instance.persistence)==null||r.set_property(pr,l),{isRateLimited:h,remainingTokens:l.tokens}}da(e){var t=this.instance.config.property_denylist;return!A(t)||!t.includes(e)}va(){var e;if(this.da("$current_url")&&this.da("$pathname")&&te!=null&&te.pathname)return""+((e=te.origin)!==null&&e!==void 0?e:"")+te.pathname}ha(e){var t,i,r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,a=this.va(),o=this.da("$session_id")?(t=(i=this.instance).get_session_id)==null?void 0:t.call(i):void 0,l=[e+" event(s) dropped since the last warning",a?"triggered on "+a:void 0,o?"session "+o:void 0].filter(
2Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+l+". Config is set to "+n+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}}var it=ee("[RemoteConfig]");class qo{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=C._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}ca(e){var t,i;(t=C.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=C.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}fa(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),this.pa(this.remoteConfig),void this.ga();if(this._instance.ma())return void it.warn("Remote config is disabled. Falling back to local config.");this.ca(e=>{if(!e)return it.info("No config found after loading remote JS config. Falling back to JSON."),void this.fa(t=>{this.pa(t.json,t),this.ga()});this.pa(e),this.ga()})}catch(e){it.error("Error loading remote config",e),this.pa()}}stop(){this.ya&&(clearInterval(this.ya),this.ya=void 0)}refresh(){!this._instance.ma()&&x&&x.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}ga(){var e;if(!this.ya){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.ya=setInterval(()=>{this.refresh()},t))}}pa(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.pa(e?{ok:!0,config:e}:{ok:!1})}catch(r){it.error("Error applying remote config",r)}if((e==null?void 0:e.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded()}catch(r){it.error("Error loading feature flags",r)}}}var Me=Uint8Array,Ie=Uint16Array,Vt=Uint32Array,Wr=new Me([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Jr=new Me([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Nn=new Me([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ao=function(s,e){for(var t=new Ie(31),i=0;31>i;++i)t[i]=e+=1<<s[i-1];var r=new Vt(t[30]);for(i=1;30>i;++i)for(var n=t[i];t[i+1]>n;++n)r[n]=n-t[i]<<5|i;return[t,r]},Lo=Ao(Wr,2),Er=Lo[1];Lo[0][28]=258,Er[258]=28;for(var jn=Ao(Jr,0)[1],Do=new Ie(32768),se=0;32768>se;++se){var Et=(43690&se)>>>1|(21845&se)<<1;Do[se]=((65280&(Et=(61680&(Et=(52428&Et)>>>2|(13107&Et)<<2))>>>4|(3855&Et)<<4))>>>8|(255&Et)<<8)>>>1}var us=function(s,e,t){for(var i=s.length,r=0,n=new Ie(e);i>r;++r)++n[s[r]-1];var a,o=new Ie(e);for(r=0;e>r;++r)o[r]=o[r-1]+n[r-1]<<1;for(a=new Ie(i),r=0;i>r;++r)a[r]=Do[o[s[r]-1]++]>>>15-s[r];return a},bt=new Me(288);for(se=0;144>se;++se)bt[se]=8;for(se=144;256>se;++se)bt[se]=9;for(se=256;280>se;++se)bt[se]=7;for(se=280;288>se;++se)bt[se]=8;var ui=new Me(32);for(se=0;32>se;++se)ui[se]=5;var Nu=us(bt,9),ju=us(ui,5),No=function(s){return(s/8>>0)+(7&s&&1)},jo=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof Ie?Ie:s instanceof Vt?Vt:Me)(t-e);return i.set(s.subarray(e,t)),i},Ge=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8},Qt=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8,s[i+2]|=t>>>16},Ai=function(s,e){for(var t=[],i=0;s.length>i;++i)s[i]&&t.push({s:i,f:s[i]});var r=t.length,n=t.slice();if(!r)return[new Me(0),0];if(r==1){var a=new Me(t[0].s+1);return a[t[0].s]=1,[a,1]}t.sort(function(k,$){return k.f-$.f}),t.push({s:-1,f:25001});var o=t[0],l=t[1],h=0,u=1,c=2;for(t[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=r-1;)o=t[t[c].f>t[h].f?h++:c++],l=t[h!=u&&t[c].f>t[h].f?h++:c++],t[u++]={s:-1,f:o.f+l.f,l:o,r:l};var v=n[0].s;for(i=1;r>i;++i)n[i].s>v&&(v=n[i].s);var f=new Ie(v+1),d=Sr(t[u-1],f,0);if(d>e){i=0;var g=0,p=d-e,m=1<<p;for(n.sort(function(k,$){return f[$.s]-f[k.s]||k.f-$.f});r>i;++i){var b=n[i].s;if(e>=f[b])break;g+=m-(1<<d-f[b]),f[b]=e}for(g>>>=p;g>0;){var E=n[i].s;e>f[E]?g-=1<<e-f[E]++-1:++i}for(;i>=0&&g;--i){var I=n[i].s;f[I]==e&&(--f[I],++g)}d=e}return[new Me(f),d]},Sr=function(s,e,t){return s.s==-1?Math.max(Sr(s.l,e,t+1),Sr(s.r,e,t+1)):e[s.s]=t},Bn=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new Ie(++e),i=0,r=s[0],n=1,a=function(l){t[i++]=l},o=1;e>=o;++o)if(s[o]==r&&o!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(r),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(r);n=1,r=s[o]}return[t.subarray(0,i),e]},Kt=function(s,e){for(var t=0,i=0;e.length>i;++i)t+=s[i]*e[i];return t},Ir=function(s,e,t){var i=t.length,r=No(e+2);s[r]=255&i,s[r+1]=i>>>8,s[r+2]=255^s[r],s[r+3]=255^s[r+1];for(var n=0;i>n;++n)s[r+n+4]=t[n];return 8*(r+4+i)},Hn=function(s,e,t,i,r,n,a,o,l,h,u){Ge(e,u++,t),++r[256];
2for(var c=Ai(r,15),v=c[0],f=c[1],d=Ai(n,15),g=d[0],p=d[1],m=Bn(v),b=m[0],E=m[1],I=Bn(g),k=I[0],$=I[1],N=new Ie(19),P=0;b.length>P;++P)N[31&b[P]]++;for(P=0;k.length>P;++P)N[31&k[P]]++;for(var T=Ai(N,7),F=T[0],R=T[1],O=19;O>4&&!F[Nn[O-1]];--O);var M,j,V,B,K=h+5<<3,ae=Kt(r,bt)+Kt(n,ui)+a,we=Kt(r,v)+Kt(n,g)+a+14+3*O+Kt(N,F)+(2*N[16]+3*N[17]+7*N[18]);if(ae>=K&&we>=K)return Ir(e,u,s.subarray(l,l+h));if(Ge(e,u,1+(ae>we)),u+=2,ae>we){M=us(v,f),j=v,V=us(g,p),B=g;var pe=us(F,R);for(Ge(e,u,E-257),Ge(e,u+5,$-1),Ge(e,u+10,O-4),u+=14,P=0;O>P;++P)Ge(e,u+3*P,F[Nn[P]]);u+=3*O;for(var xe=[b,k],Pe=0;2>Pe;++Pe){var ie=xe[Pe];for(P=0;ie.length>P;++P)Ge(e,u,pe[ce=31&ie[P]]),u+=F[ce],ce>15&&(Ge(e,u,ie[P]>>>5&127),u+=ie[P]>>>12)}}else M=Nu,j=bt,V=ju,B=ui;for(P=0;o>P;++P)if(i[P]>255){var ce;Qt(e,u,M[257+(ce=i[P]>>>18&31)]),u+=j[ce+257],ce>7&&(Ge(e,u,i[P]>>>23&31),u+=Wr[ce]);var he=31&i[P];Qt(e,u,V[he]),u+=B[he],he>3&&(Qt(e,u,i[P]>>>5&8191),u+=Jr[he])}else Qt(e,u,M[i[P]]),u+=j[i[P]];return Qt(e,u,M[256]),u+j[256]},Bu=new Vt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hu=function(){for(var s=new Vt(256),e=0;256>e;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;s[e]=t}return s}(),Li=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8};function zu(s,e){e===void 0&&(e={});var t=function(){var c=4294967295;return{p(v){for(var f=c,d=0;v.length>d;++d)f=Hu[255&f^v[d]]^f>>>8;c=f},d(){return 4294967295^c}}}(),i=s.length;t.p(s);var r,n,a,o,l,h=(o=10+((r=e).filename&&r.filename.length+1||0),l=8,function(c,v,f,d,g,p){var m=c.length,b=new Me(d+m+5*(1+Math.floor(m/7e3))+g),E=b.subarray(d,b.length-g),I=0;if(!v||8>m)for(var k=0;m>=k;k+=65535){var $=k+65535;m>$?I=Ir(E,I,c.subarray(k,$)):(E[k]=!0,I=Ir(E,I,c.subarray(k,m)))}else{for(var N=Bu[v-1],P=N>>>13,T=8191&N,F=(1<<f)-1,R=new Ie(32768),O=new Ie(F+1),M=Math.ceil(f/3),j=2*M,V=function(gi){return(c[gi]^c[gi+1]<<M^c[gi+2]<<j)&F},B=new Vt(25e3),K=new Ie(288),ae=new Ie(32),we=0,pe=0,xe=(k=0,0),Pe=0,ie=0;m>k;++k){var ce=V(k),he=32767&k,De=O[ce];if(R[he]=De,O[ce]=he,k>=Pe){var at=m-k;if((we>7e3||xe>24576)&&at>423){I=Hn(c,E,0,B,K,ae,pe,xe,ie,k-ie,I),xe=we=pe=0,ie=k;for(var ne=0;286>ne;++ne)K[ne]=0;for(ne=0;30>ne;++ne)ae[ne]=0}var qe=2,tt=0,Ut=T,Oe=he-De&32767;if(at>2&&ce==V(k-Oe))for(var ke=Math.min(P,at)-1,bs=Math.min(32767,k),ws=Math.min(258,at);bs>=Oe&&--Ut&&he!=De;){if(c[k+qe]==c[k+qe-Oe]){for(var Ce=0;ws>Ce&&c[k+Ce]==c[k+Ce-Oe];++Ce);if(Ce>qe){if(qe=Ce,tt=Oe,Ce>ke)break;var xs=Math.min(Oe,Ce-2),wt=0;for(ne=0;xs>ne;++ne){var xt=k-Oe+ne+32768&32767,Gt=xt-R[xt]+32768&32767;Gt>wt&&(wt=Gt,De=xt)}}}Oe+=(he=De)-(De=R[he])+32768&32767}if(tt){B[xe++]=268435456|Er[qe]<<18|jn[tt];var Xr=31&Er[qe],Yr=31&jn[tt];pe+=Wr[Xr]+Jr[Yr],++K[257+Xr],++ae[Yr],Pe=k+qe,++we}else B[xe++]=c[k],++K[c[k]]}}I=Hn(c,E,!0,B,K,ae,pe,xe,ie,k-ie,I)}return jo(b,0,d+No(I)+g)}(n=s,(a=e).level==null?6:a.level,a.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+a.mem,o,l)),u=h.length;return function(c,v){var f=v.filename;if(c[0]=31,c[1]=139,c[2]=8,c[8]=2>v.level?4:v.level==9?2:0,c[9]=3,v.mtime!=0&&Li(c,4,Math.floor(new Date(v.mtime||Date.now())/1e3)),f){c[3]=8;for(var d=0;f.length>=d;++d)c[d+10]=f.charCodeAt(d)}}(h,e),Li(h,u-8,t.d()),Li(h,u-4,i),h}var Vu=!!Ji||!!Or,Bo="text/plain",Ns=!1,Ho=(s,e)=>{var t=s.split("#"),i=t[1],r=t[0].split("?"),n=r[0],a=r[1];if(!a)return s;var o=a.split("&").filter(l=>l.split("=")[0]!==e).join("&");return n+(o?"?"+o:"")+(i?"#"+i:"")},ys=function(s,e,t){var i;t===void 0&&(t=!0);var r=s.split("?"),n=r[0],a=r[1],o=y({},e),l=(i=a==null?void 0:a.split("&").map(u=>{var c,v=u.split("="),f=v[0],d=t&&(c=o[f])!==null&&c!==void 0?c:v[1];return delete o[f],f+"="+d}))!==null&&i!==void 0?i:[],h=function(u,c){var v,f;c===void 0&&(c="&");var d=[];return U(u,function(g,p){w(g)||w(p)||p==="undefined"||(v=encodeURIComponent((m=>m instanceof File)(g)?g.name:g.toString()),f=encodeURIComponent(p),d[d.length]=f+"="+v)}),d.join(c)}(o);return h&&l.push(h),l.length>0?n+"?"+l.join("&"):n},Di=s=>{if(s.ba)return s.ba;var e=s.data,t=s.compression;if(e){if(t===ye.GZipJS){var i=zu(function(o,l){var h=o.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(o);for(var u=new Me(o.length+(o.length>>>1)),c=0,v=function(p){u[c++]=p},f=0;h>f;++f){if(c+5>u.length){var d=new Me(c+8+(h-f<<1));d.set(u),u=d}
2var g=o.charCodeAt(f);128>g?v(g):2048>g?(v(192|g>>>6),v(128|63&g)):g>55295&&57344>g?(v(240|(g=65536+(1047552&g)|1023&o.charCodeAt(++f))>>>18),v(128|g>>>12&63),v(128|g>>>6&63),v(128|63&g)):(v(224|g>>>12),v(128|g>>>6&63),v(128|63&g))}return jo(u,0,c)}(Ct(e)),{mtime:0});return{contentType:Bo,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(t===ye.Base64){var r=function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(l,h)=>String.fromCharCode(parseInt(h,16))))}(Ct(e)),n=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Ct(o)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var a=Ct(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},zo=s=>{var e,t,i=()=>s.transport==="sendBeacon"?{url:ys(s.url,{compression:ye.Base64}),encodedBody:Di(y({},s,{compression:ye.Base64,ba:void 0}))}:{url:Ho(s.url,"compression"),encodedBody:Di(y({},s,{compression:void 0,ba:void 0}))};try{e=Di(s)}catch(r){if(rn(s.compression,Ht(s.url,"compression")))return S.error("Failed to gzip request body, sending uncompressed payload",r),i();throw r}return e&&rn(s.compression,Ht(s.url,"compression"))&&!((t=e.body)instanceof ArrayBuffer?Xi(new Uint8Array(t)):ArrayBuffer.isView(t)&&Xi(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))?(Ns=!0,i()):{url:s.url,encodedBody:e}},Vo=s=>{try{return zo(s)}catch(e){return S.error(e),void(s.callback==null||s.callback({statusCode:0,error:e}))}},Uu=function(){var s=Q(function*(e){var t=Ct(e.data),i=yield function(n,a,o){return Yi.apply(this,arguments)}(t,X.DEBUG,{rethrow:!0});if(!i)return e;var r=yield i.arrayBuffer();return y({},e,{ba:{contentType:Bo,body:r,estimatedSize:r.byteLength}})});return function(e){return s.apply(this,arguments)}}(),Gu=/Failed to fetch|NetworkError|Load failed/i,Uo=s=>(s==null?void 0:s.name)==="TypeError"&&Gu.test((s==null?void 0:s.message)||""),Go=s=>{var e=Vo(s);if(e){var t=e.url,i=e.encodedBody,r=i??{},n=r.contentType,a=r.body,o=r.estimatedSize,l=new Headers;U(s.headers,function(d,g){l.append(g,d)}),n&&l.append("Content-Type",n);var h=null,u=!1;if(Qr){var c=new Qr;h={signal:c.signal,timeout:setTimeout(()=>{var d,g;u=!0,c.abort((d=s.timeout,(g=new Error("PostHog request timed out"+(d?" after "+d+"ms":""))).name="AbortError",g))},s.timeout)}}var v=d=>{u&&(d==null?void 0:d.name)==="AbortError"||Uo(d)?S.warn(d):S.error(d),s.callback==null||s.callback({statusCode:0,error:d})};try{var f;Or(t,y({method:(s==null?void 0:s.method)||"GET",headers:l,keepalive:s.method==="POST"&&!s._a&&52428.8>(o||0),body:a,signal:(f=h)==null?void 0:f.signal},s.fetchOptions)).then(d=>d.text().then(g=>{var p={statusCode:d.status,text:g};if(d.status===200)try{p.json=JSON.parse(g)}catch(m){S.error(m)}s.callback==null||s.callback(p)})).catch(v).finally(()=>h?clearTimeout(h.timeout):null)}catch(d){h&&clearTimeout(h.timeout),v(d)}}},Pr=s=>{try{var e,t=zo(s),i=t.url,r=t.encodedBody,n=r??{},a=n.body,o=n.estimatedSize;if(!a)return;var l=a instanceof Blob?a:new Blob([a],{type:n.contentType});if(be.sendBeacon(i,l))return;var h=A(s.data)?s.data:(e=s.data)==null?void 0:e.batch;if(A(h)&&h.length>1&&(o??0)>16384){var u=Math.ceil(h.length/2),c=v=>A(s.data)?v:y({},s.data,{batch:v});return Pr(y({},s,{data:c(h.slice(0,u))})),void Pr(y({},s,{data:c(h.slice(u))}))}S.warn("Beacon of ~"+(o??0)+" bytes was rejected by the browser, falling back to fetch"),Go(y({},s,{_a:!0}))}catch(v){S.warn("Beacon send failed",v)}},zn=(s,e,t,i)=>{var r=i==="query"?e==="POST"?"sent_at":"_":void 0;return ys(t===ye.GZipJS?Ho(s,"compression"):s,y({},r?{[r]:Date.now().toString()}:{},t===ye.GZipJS?{}:{compression:t}))},js=[];Or&&js.push({transport:"fetch",method:Go}),Ji&&js.push({transport:"XHR",method(s){var e=Vo(s);if(e){var t=new Ji,i=e.encodedBody;t.open(s.method||"GET",e.url,!0);var r=i??{},n=r.contentType,a=r.body;U(s.headers,function(o,l){t.setRequestHeader(l,o)}),n&&t.setRequestHeader("Content-Type",n),s.timeout&&(t.timeout=s.timeout),t.onreadystatechange=()=>{if(t.readyState===4){var o={statusCode:t.status,text:t.responseText};if(t.status===200)try{o.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(o)}},t.send(a)}}}),be!=null&&be.sendBeacon&&js.push({transport:"sendBeacon",method:Pr});var Fr=3e3;class Wu{constructor(e,t){this.wa=!0,this.ka=[],this.Sa=Ue((t==null?void 0:t.flush_interval_ms)||Fr,250,5e3,S.createLogger("flush interval"),Fr),this.xa=e}enqueue(e){this.ka.push(e),this.Ca||this.Ta()}unload(){this.Ma();var e=this.ka.length>0?this.Ea():{},t=Object.values(e);[...t.filter(i=>i.url.indexOf("/e")===0),...t.filter(i=>i.url.indexOf("/e")!==0)].map(i=>{this.Ia(y({},i,{transport:"sendBeacon"}))})}enable(){this.wa=!1,this.Ta()}Ta(){var e=this;this.wa||(this.Ca=setTimeout(()=>{if(this.Ma(),this.ka.length>0){var t=this.Ea(),i=function(){var n=t[r],a=new Date().getTime();n.data&&A(n.data)&&U(n.data,o=>{o.offset=Math.abs(o.timestamp-a),delete o.timestamp}),e.Ia(n)};for(var r in t)i()}},this.Sa))}Ia(e){try{this.xa(e)}catch(t){S.error(t)}}Ma(){clearTimeout(this.Ca),this.Ca=void 0}Ea(){var e={};return U(this.ka,t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;w(e[n])&&(e[n]=y({},r,{data:[]})),(i=e[n].data)==null||i.push(r.data)}),this.ka=[],e}}var Ju=["retriesPerformedSoFar"];class Xu{constructor(e){this.Ra=!1,this.Pa=3e3,this.ka=[],this._instance=e,this.ka=[],this.Aa=!0,!w(_)&&"onLine"in _.navigator&&(this.Aa=_.navigator.onLine,this.Fa=()=>{this.Aa=!0,this.Oa()},this.La=()=>{this.Aa=!1},Z(_,"online",this.Fa),Z(_,"offline",this.La))}get length(){return this.ka.length}retriableRequest(e){var t=e.retriesPerformedSoFar,i=fa(e,Ju);Je(t)&&(i.url=ys(i.url,{retry_count:t})),this._instance._send_request(y({},i,{callback:r=>{if(r.statusCode!==200&&(400>
2r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(t??0))return void this.xn(y({retriesPerformedSoFar:t},i));r.statusCode===0&&S.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(t??0)+" retries.")}i.callback==null||i.callback(r)}}))}xn(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(a){var o=3e3*Math.pow(2,a),l=o/2,h=Math.min(18e5,o),u=Math.random()-.5;return Math.ceil(h+u*(h-l))}(t),r=Date.now()+i;this.ka.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),S.warn(n),this.Ra||(this.Ra=!0,this.$a())}$a(){if(this.Da&&clearTimeout(this.Da),this.ka.length===0)return this.Ra=!1,void(this.Da=void 0);this.Da=setTimeout(()=>{this.Aa&&this.ka.length>0&&this.Oa(),this.$a()},this.Pa)}Oa(){var e=Date.now(),t=[],i=this.ka.filter(n=>e>n.retryAt||(t.push(n),!1));if(this.ka=t,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.Da&&(clearTimeout(this.Da),this.Da=void 0),this.Ra=!1,w(_)||(this.Fa&&(_.removeEventListener("online",this.Fa),this.Fa=void 0),this.La&&(_.removeEventListener("offline",this.La),this.La=void 0)),this.ka)){var t=e.requestOptions;try{this._instance._send_request(y({},t,{transport:"sendBeacon"}))}catch(i){S.error(i)}}this.ka=[]}}class Yu{constructor(e){this.Na=()=>{var t,i,r,n;this.qa||(this.qa={});var a=this.scrollElement(),o=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,h=o+((a==null?void 0:a.clientHeight)||0),u=(a==null?void 0:a.scrollHeight)||0;this.qa.lastScrollY=Math.ceil(o),this.qa.maxScrollY=Math.max(o,(t=this.qa.maxScrollY)!==null&&t!==void 0?t:0),this.qa.maxScrollHeight=Math.max(l,(i=this.qa.maxScrollHeight)!==null&&i!==void 0?i:0),this.qa.lastContentY=h,this.qa.maxContentY=Math.max(h,(r=this.qa.maxContentY)!==null&&r!==void 0?r:0),this.qa.maxContentHeight=Math.max(u,(n=this.qa.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get ja(){return this._instance.config.scroll_root_selector}getContext(){return this.qa}resetContext(){var e=this.qa;return setTimeout(this.Na,0),e}startMeasuringScrollPosition(){Z(_,"scroll",this.Na,{capture:!0}),Z(_,"scrollend",this.Na,{capture:!0}),Z(_,"resize",this.Na)}scrollElement(){if(!this.ja)return _==null?void 0:_.document.documentElement;var e=A(this.ja)?this.ja:[this.ja];for(var t of e){var i=_==null?void 0:_.document.querySelector(t);if(i)return i}}Ba(e){var t=e==="y"?"scrollTop":"scrollLeft";if(this.ja){var i=this.scrollElement();return i&&i[t]||0}return _?e==="y"?_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop||0:_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft||0:0}scrollY(){return this.Ba("y")}scrollX(){return this.Ba("x")}}var Qu=s=>Co(s==null?void 0:s.config.mask_personal_data_properties,s==null?void 0:s.config.custom_personal_data_properties,s==null?void 0:s.config.disable_capture_url_hashes);class Vn{constructor(e,t,i,r){this.ot=n=>{var a=this.Ha();if(!a||a.sessionId!==n){var o={sessionId:n,props:this.Ua(this._instance)};this.za.register({[vr]:o})}},this._instance=e,this.Wa=t,this.za=i,this.Ua=r||Qu,this.Wa.onSessionId(this.ot)}Ha(){return this.za.props[vr]}getSetOnceProps(){var e,t=(e=this.Ha())==null?void 0:e.props;return t?"r"in t?Ro(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return U(zr(this.getSetOnceProps()),(t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+Ki(i)]=t}),e}}class hi{on(e,t){return this.Va[e]||(this.Va[e]=[]),this.Va[e].push(t),()=>{this.Va[e]=this.Va[e].filter(i=>i!==t)}}emit(e,t){for(var i of this.Va[e]||[])i(t);for(var r of this.Va["*"]||[])r(e,t)}constructor(){this.Va={}}}var St=ee("[SessionId]"),Un=864e5;class Gn{on(e,t){return this.Ga.on(e,t)}constructor(e,t,i){var r;if(this.Za=null,this.Qa=null,this.Ja=[],this.Ka=void 0,this.Ya=!1,this.Ga=new hi,this.Xa=(l,h)=>!(!Je(l)||!Je(h))&&Math.abs(l-h)>
2this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Ke)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qi=e.config,this.za=e.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.eo=void 0,this._sessionActivityTimestamp=null,this.io=t||ze,this.ro=i||ze;var n=this.qi.persistence_name||this.qi.token;if(this._sessionTimeoutMs=1e3*Ue(this.qi.session_idle_timeout_seconds||1800,60,36e3,St.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.no(),this.so="ph_"+n+"_window_id",this.ao="ph_"+n+"_primary_window_exists",this.oo()){var a=J.Br(this.so),o=J.Br(this.ao);a&&!o?this.st=a:J.qr(this.so),J.Nr(this.ao,!0)}(r=this.qi.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.qi.bootstrap.sessionID),this.lo()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return w(this.Ja)&&(this.Ja=[]),this.Ja.push(e),this._e&&e(this._e,this.st),()=>{this.Ja=this.Ja.filter(t=>t!==e)}}oo(){return this.qi.persistence!=="memory"&&!this.za.Hs&&J.Dr()}uo(e){e!==this.st&&(this.st=e,this.oo()&&J.Nr(this.so,e))}ho(){return this.st?this.st:this.oo()?J.Br(this.so):null}do(e){var t=this.Za;return!de(t)&&!de(e)&&5e3>Math.abs(e-t)}vo(e,t,i){var r=t!==this._sessionActivityTimestamp,n=!(e!==this._e||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._e=e,n&&!r||n&&this.do(t)||(this.Za=t,this.za.register({[Ot]:[t,e,i]}))}co(){var e,t=(e=this.qi)==null?void 0:e.persistence_save_debounce_ms;return Je(t)&&t>0}fo(){this.co()?this.za.refreshKey(Ot):(this.za.flush(),this.za.load())}po(){var e;if(!de(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Za){this.fo();var t=this.mo();t[1]===this._e&&t[2]===this._sessionStartTimestamp&&(this.Za=this._sessionActivityTimestamp,this.za.register({[Ot]:[this._sessionActivityTimestamp,(e=this._e)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.za.flush())}}yo(){var e=this.mo()[0],t=Je(e)?e:0,i=Je(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}bo(e){return this.fo(),this.Xa(e,this.yo())}mo(){var e=this.za.props[Ot];return A(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Za=null,this.eo=void 0,clearTimeout(this._o),this._o=void 0,this.vo(null,null,null)}setBootstrapSessionId(e,t){t===void 0&&(t=!1);var i=function(r,n){n===void 0&&(n=new Date().getTime());try{var a=(o=>{var l=o.replace(/-/g,"");if(l.length!==32)throw new Error("Not a valid UUID");if(l[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(l.substring(0,12),16)})(r);return a>n+6e4?void St.error("Bootstrap sessionID cannot be in the future"):a}catch(o){return void St.error("Invalid sessionID in bootstrap",o)}}(e);return!w(i)&&(t?this.eo={sessionId:e,sessionStartTimestamp:i}:this.vo(e,new Date().getTime(),i),!0)}destroy(){this.Ya=!0,this.po(),clearTimeout(this._o),this._o=void 0,this.Ka&&_&&(_.removeEventListener(ii,this.Ka,{capture:!1}),this.Ka=void 0),this.Ja=[]}lo(){this.Ka=()=>{this.po(),this.oo()&&J.qr(this.ao)},Z(_,ii,this.Ka,{capture:!1})}checkAndGetSessionAndWindowId(e,t,i){if(e===void 0&&(e=!1),t===void 0&&(t=null),i===void 0&&(i=!1),this.qi.cookieless_mode===Ke)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),n=this._e;if(i)this.Qa=r;else if(de(this.Qa)||this.Qa>r||r-this.Qa>=1e3){var a,o;(a=(o=this.za).syncCookieProperties)==null||a.call(o),this.Qa=r}var l=this.mo(),h=l[1],u=l[2],c=!w(n)&&h!==n,v=this.yo(),f=this.ho(),d=this.eo,g=!!d&&(d.sessionStartTimestamp>r+6e4||r-d.sessionStartTimestamp>Un),p=d?g:Je(u)&&Math.abs(r-u)>Un,m=!1,b=c,E=!h||!!d,I=h,k=!E&&!e&&this.Xa(r,v);if(k){(k=this.bo(r))||St.info("cross-tab refresh kept the session alive",{sessionId:h});var $=this.mo();h=$[1],u=$[2]}if(E||k||p){b=!1;var N=d&&!g;h=N?d.sessionId:this.io(),f=this.ro(),St.info("new session ID assigned",{sessionId:h,windowId:f,bootstrapped:!!N,changeReason:{noSessionId:E,activityTimeout:k,sessionPastMaximumLength:p}}),u=N?d.sessionStartTimestamp:r,this.eo=void 0,m=!0}else f||(f=this.ro(),m=!0),(b=b||h!==I)&&(St.info("adopted cross-tab session id",{sessionId:h,windowId:f}),m=!0);var P=Je(v)&&e&&!p?v:r,T=Je(u)?u:new Date().getTime();this.uo(f),this.vo(h,P,T),e||this.no();var F={noSessionId:E,activityTimeout:k,sessionPastMaximumLength:p,crossTabAdoption:b};return m&&this.Ja.forEach(R=>R(h,f,F)),{sessionId:h,windowId:f,sessionStartTimestamp:T,changeReason:m?F:void 0,lastActivityTimestamp:v}}no(){this.Ya||(clearTimeout(this._o),this._o=setTimeout(()=>{if(!this.Ya)if(this.bo(new Date().getTime())){var e=this._e;this.resetSessionId(),this.Ga.emit("forcedIdleReset",{idleSessionId:e})}else this.no()},1.1*this.sessionTimeoutMs))}}var Wo=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&an(t,e))return!0;try{var i=s==null?void 0:s.userAgentData;if(i!=null&&i.brands&&i.brands.some(r=>an(r==null?void 0:r.brand,e)))return!0}catch{}return!!s.webdriver};function Jo(){return(Jo=Q(function*(){var s=be==null?void 0:be.userAgentData;if(s!=null&&s.getHighEntropyValues)try{var e=yield s.getHighEntropyValues(["model"]),t=e==null?void 0:e.model;return H(t)&&t.length>0?t:void 0}catch(i){return void S.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",i)}})).apply(this,arguments)}var ci=function(s,e){if(!function(t){try{new RegExp(t)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};function Ni(s,e,t){return Ct({distinct_id:s,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Xo={exact:(s,e)=>e.some(t=>s.some(i=>t===i)),is_not:(s,e)=>e.every(t=>s.every(i=>t!==i)),regex:(s,e)=>e.some(t=>s.some(i=>ci(t,i))),not_regex:(s,e)=>e.every(t=>s.every(i=>!ci(t,i))),icontains:(s,e)=>e.map(Os).some(t=>s.map(Os).some(i=>t.includes(i))),not_icontains:(s,e)=>e.map(Os).every(t=>s.map(Os).every(i=>!t.includes(i))),gt:(s,e)=>e.some(t=>{var i=parseFloat(t);return!isNaN(i)&&s.some(r=>i>parseFloat(r))}),lt:(s,e)=>e.some(t=>{var i=parseFloat(t);return!isNaN(i)&&s.some(r=>i<parseFloat(r))})},Os=s=>s.toLowerCase();function Yo(s,e){return!s||Object.entries(s).every(t=>{var i=t[1],r=e==null?void 0:e[t[0]];if(w(r)||de(r))return!1;var n=[String(r)],a=Xo[i.operator];return!!a&&a(i.values,n)})}var Tr="custom",Wn="i.posthog.com",Ku=/^\/static\//,Zu=["/s/","/e/","/i/"];class eh{constructor(e){this.wo={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Wn,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.wo[this.apiHost]||(this.wo[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":Tr),this.wo[this.apiHost]}ko(e){if(Ku.test(e)){var t=this.instance.config.asset_host;if(typeof t=="string")return t.trim().replace(/\/$/,"")||void 0}}So(e){var t=Bt(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}xo(e,t,i){if(e==="ui")return i;var r=i,n=this.instance.config.rewriteRequestPath;if(n){var a,o=((a=Bt(i))==null?void 0:a.href)||i;r=n(new URL(o)).toString()}if(n&&e==="api"&&Zu.some(v=>t.indexOf(v)===0)){var l=this.So(r);if(l){var h,u=this.apiHost,c=this.Co;((h=c)==null?void 0:h.apiHost)===u&&c.rewriteRequestPath===n||(c={apiHost:u,rewriteRequestPath:n,urls:new Set},this.Co=c),c.urls.add(l)}}return r}isIngestionEndpoint(e){var t=this.Co,i=this.So(e);return(t==null?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.xo(e,t,this.uiHost+t);if(e==="flags")return this.xo(e,t,this.flagsApiHost+t);if(e==="assets"){var i=this.ko(t);if(i)return this.xo(e,t,""+i+t)}if(this.region===Tr)return this.xo(e,t,this.apiHost+t);var r=Wn+t;switch(e){case"assets":return this.xo(e,t,"https://"+this.region+"-assets."+r);case"api":return this.xo(e,t,"https://"+this.region+"."+r)}}}function Qo(s){var e;return!((e=s.conditions)==null||(e=e.events)==null||(e=e.values)==null||!e.length)}var z=ee("[Surveys]"),Ko="seenSurvey_",Zo=s=>{try{var e=(t=>((i,r)=>""+Ko+function(n){return n.current_iteration&&n.current_iteration>0?n.id+"_"+n.current_iteration:n.id}(r))(0,t))(s);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){z.error("Failed to persist survey seen state",t)}},th=[Mi.Popover,Mi.Widget,Mi.API],sh={ignoreConditions:!1,ignoreDelay:!1,displayType:kr.Popover}
2,ih=ee("[PostHog ExternalIntegrations]"),rh={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class nh{constructor(e){this._instance=e}_s(e,t){var i;(i=C.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,r=>{if(r)return ih.error("failed to load script",r);t()})}startIfEnabledOrStop(){var e=this,t=function(){var n,a,o,l=i[0],h=i[1];!h||(n=C.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[l]||e._s(rh[l],()=>{var u;(u=C.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[l])==null||u.start(e._instance)}),!h&&(a=C.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[l]&&((o=C.__PosthogExtensions__)==null||(o=o.integrations)==null||(o=o[l])==null||o.stop())};for(var i of Object.entries((r=this._instance.config.integrations)!==null&&r!==void 0?r:{})){var r;t()}}}class ah{constructor(e,t){this.I=e,this.ns=t,this.To=new Map,this.Xn=!1}add(e){var t=this;return Q(function*(){if(t.Xn)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.To.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t.To.set(e.name,e);try{var i=e.setup(t.ns);i&&(yield i)}catch(n){var r=t.To.get(e.name)===e;r&&t.To.delete(e.name),t.I.error('Failed to set up browser extension "'+e.name+'"',n),r&&t.Mo(e)}})()}dispose(){if(!this.Xn){this.Xn=!0;var e=Array.from(this.To.values()).reverse();for(var t of(this.To.clear(),e))this.Mo(t)}}Mo(e){try{var t=e.dispose==null?void 0:e.dispose();t&&ge(t.then)&&t.then(void 0,i=>{this.I.error('Failed to dispose browser extension "'+e.name+'"',i)})}catch(i){this.I.error('Failed to dispose browser extension "'+e.name+'"',i)}}}class oh{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if(typeof e=="string")return t==null?void 0:t.get_property(e);var i={};for(var r of e){var n=t==null?void 0:t.get_property(r);w(n)||(i[r]=n)}return i}set(e,t){var i;(i=this._instance.persistence)==null||i.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}}var Jn="extensionsRemoteConfig";class lh{constructor(e){this.Xn=!1,this.instance=e,this.I=S,this.Eo=e.Io,this.kv=new oh(e),this.onEvent=t=>$s(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(r){this.I.error("Browser extension event listener failed",r)}})),this.onRemoteConfig=t=>{if(this.Xn)return $s(()=>{});var i=n=>{try{t(n)}catch(a){this.I.error("Browser extension remote config listener failed",a)}},r=this.instance.Ro.on(Jn,i);return this.Eo&&i(this.Eo),$s(r)},this.Po=new ah(S.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property(ps))!==null&&e!==void 0?e:this.distinctId}get deviceId(){var e=this.instance.get_property(ps);return typeof e=="string"?e:void 0}get library(){return{name:X.LIB_NAME,version:X.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)==null?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,r,n=(e=this.instance.sessionManager)==null?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=n==null?void 0:n.sessionId)!==null&&t!==void 0?t:"",windowId:(i=n==null?void 0:n.windowId)!==null&&i!==void 0?i:"",sessionStartTimestamp:(r=n==null?void 0:n.sessionStartTimestamp)!==null&&r!==void 0?r:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(e){return this.Po.add(e)}capture(e,t,i){var r=this;return Q(function*(){i?r.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):r.instance.capture(e,t)})()}registerDynamicEventProperties(e){return $s(this.instance.Ao(e))}handleRemoteConfig(e){this.Xn||(this.Eo=e,this.instance.Ro.emit(Jn,e))}sendRequest(e,t){var i=this;return Q(function*(){var r;t===void 0&&(t={});var n=i.instance.requestRouter.endpointFor((r=t.target)!==null&&r!==void 0?r:"api",e),a={method:t.method,url:t.query?ys(n,t.query):n,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt};return t.transport==="sendBeacon"?(i.instance._send_request(a),{statusCode:202}):new Promise(o=>{a.callback=o,i.instance._send_request(a)})})()}dispose(){this.Xn||(this.Xn=!0,this.Po.dispose())}}var hs={},ji=0,cs=()=>{}
2,Xn='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Zt="Surveys module not available",Yn="sanitize_properties is deprecated. Use before_send instead",el="Invalid value for property_denylist config: ",uh=["token","distinct_id",no],Tt="posthog",tl=!Vu&&(Ee==null?void 0:Ee.indexOf("MSIE"))===-1&&(Ee==null?void 0:Ee.indexOf("Mozilla"))===-1,Bi=s=>{var e;return y({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:uu(x==null?void 0:x.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:cs,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:te&&H(te==null?void 0:te.search)&&te.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,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){S.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:mr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Fr},error_tracking:{},_onCapture:cs},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:wu,ignore_text_selection:!0}
2:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:t&&t>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||t==="unset"||"2026-08-29">t)}))(s))},hh=[["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"]],Qn=s=>{var e={};for(var t of hh){var i=t[0],r=t[1];w(s[i])||(e[r]=s[i])}var n=W({},e,s),a=s.__preview_external_dependency_versioned_paths;return w(a)||(w(s.strict_script_versioning)&&(n.strict_script_versioning=!!a),H(a)&&w(s.asset_host)&&(n.asset_host=a)),A(s.property_blacklist)&&(w(s.property_denylist)?n.property_denylist=s.property_blacklist:A(s.property_denylist)?n.property_denylist=[...s.property_blacklist,...s.property_denylist]:S.error(el+s.property_denylist)),n};class ch{constructor(){this.__forceAllowLocalhost=!1}get Fo(){return this.__forceAllowLocalhost}set Fo(e){S.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Fe{Oo(e,t){if(e){var i=this.To.indexOf(e);i!==-1&&this.To.splice(i,1)}return this.To.push(t),t.initialize==null||t.initialize(),t}Lo(){return this.config.cookieless_mode===Ke||this.config.cookieless_mode===vt&&this.consent.isRejected()}$o(){if(!this.Lo()&&this.get_distinct_id()===kt){var e=this.persistence;if(e){this.Do()||e.load(!0);var t=this.get_distinct_id();if(!t||t===kt){var i=this.config.get_device_id(ze());this.register({distinct_id:i,$device_id:i}),e.set_property(D,oe)}this.No()}}}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new ch,this.qo=!1,this.version=X.LIB_VERSION,this.jo=new Set,this.Bo="",this.Ro=new hi,this.To=[],this.Ho=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Bi(),this.SentryIntegration=Tu,this.sentryIntegration=i=>function(r,n){var a=So(r,n);return{name:Eo,processEvent:o=>a(o)}}(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Uo=!1,this.zo=null,this.Wo=null,this.Vo=null,this.scrollManager=new Yu(this),this.pageViewManager=new Mn(this),this.rateLimiter=new Du(this),this.requestRouter=new eh(this),this.consent=new gu(this),this.externalIntegrations=new nh(this);var t=(e=Fe.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.metrics=t.metrics&&new t.metrics(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(i,r,n)=>{var a=H(i)?{[i]:r}:i;this.setPersonProperties(a),n==null||n({})},set_once:(i,r,n)=>{var a=H(i)?{[i]:r}:i;this.setPersonProperties(void 0,a),n==null||n({})}},this.on("eventCaptured",i=>S.info('send "'+(i==null?void 0:i.event)+'"',i))}init(e,t,i){if(i&&i!==Tt){var r,n=(r=hs[i])!==null&&r!==void 0?r:new Fe;return n._init(e,t,i),hs[i]=n,hs[Tt][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r,n;t===void 0&&(t={});var a,o=H(e)?e.trim():"";if(!o)return S.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return o!==((a=this.config)==null?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+o+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Bi(t.defaults),t.debug=this.Go(t.debug),this.Zo=t,this.Qo=[],t.person_profiles?this.Wo=t.person_profiles:t.process_person&&(this.Wo=t.process_person);var l=Bi(t.defaults),h=Qn(t),u=W({},l,h,{name:i,token:o});Y(l.rageclick)&&Y(h.rageclick)&&(u.rageclick=W({},l.rageclick,h.rageclick)),Y(l.session_recording)&&Y(h.session_recording)&&(u.session_recording=W({},l.session_recording,h.session_recording)),this.set_config(u),this.config.on_xhr_error&&S.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ye.GZipJS;var c=this.Do();if(this.persistence=new Ri(this.config,c),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ri(y({},this.config,{persistence:"sessionStorage"}),c,!1),this.Bo="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!c&&J.Dr()){var v=J.Br(this.Bo);A(v)&&v.forEach($=>{H($)&&this.jo.add($)})}else J.qr(this.Bo);var f=y({},this.persistence.props),d=y({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Jo=new Wu($=>this.Ko($),this.config.request_queue_config),this.Yo=new Xu(this),this.__request_queue=[];var g=this.Lo();if(g||(this.sessionManager=new Gn(this),this.sessionPropsManager=new Vn(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(($,N,P)=>{(P!=null&&P.activityTimeout||P!=null&&P.sessionPastMaximumLength||P!=null&&P.crossTabAdoption)&&this.Xo()})),this.tl(),this.config.__preview_deferred_init_extensions?(S.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.el(g)},0)):(S.info("Initializing extensions synchronously"),this.el(g)),X.DEBUG=X.DEBUG||this.config.debug,X.DEBUG&&S.info("Starting in debug mode",{this:this,config:t,thisC:y({},this.config),p:f,s:d}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=y({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((n=t.bootstrap)==null?void 0:n.distinctID)!==void 0){var p=t.bootstrap.distinctID,m=this.get_distinct_id(),b=this.persistence.get_property(D);if(t.bootstrap.isIdentifiedID&&m!=null&&m!==p&&b===oe)this.identify(p);else if(t.bootstrap.isIdentifiedID&&m!=null&&m!==p&&b===ve)S.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var E=this.config.get_device_id(ze()),I=t.bootstrap.isIdentifiedID?E:p;this.persistence.set_property(D,t.bootstrap.isIdentifiedID?ve:oe),this.register({distinct_id:p,$device_id:I})}}if(g)this.register_once({distinct_id:kt,$device_id:null},"");else if(!this.get_distinct_id()){var k=this.config.get_device_id(ze());this.register_once({distinct_id:k,$device_id:k},""),this.persistence.set_property(D,oe)}return Z(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function($,N){var P=$.config.segment;if(!P)return N();(function(T,F){var R=T.config.segment;if(!R)return F();var O=j=>{var V=()=>j.anonymousId()||ze();T.config.get_device_id=V,j.id()&&(T.register({distinct_id:j.id(),$device_id:V()}),T.persistence.set_property(D,ve)),F()},M=R.user();"then"in M&&ge(M.then)?M.then(O):O(M)})($,()=>{P.register((T=>{typeof Promise<"u"&&Promise.resolve||Oi.warn("This browser does not have Promise support, and can not use the segment integration");var F=(R,O)=>{if(!O)return R;R.event.userId||R.event.anonymousId===T.get_distinct_id()||(Oi.info("No userId set, resetting PostHog"),T.reset()),R.event.userId&&R.event.userId!==T.get_distinct_id()&&(Oi.info("UserId set, identifying with PostHog"),T.identify(R.event.userId)
2);var M=T.calculateEventProperties(O,R.event.properties);return R.event.properties=Object.assign({},M,R.event.properties),R};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:R=>F(R,R.event.event),page:R=>F(R,Ft),identify:R=>F(R,Si),screen:R=>F(R,"$screen")}})($)).then(()=>{N()})})}(this,()=>this.il()):this.il(),ge(this.config._onCapture)&&this.config._onCapture!==cs&&(S.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",$=>this.config._onCapture($.event,$))),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 Jo.apply(this,arguments)}().then($=>{$&&this.register({[ki]:$})}).catch(cs),this}rl(e){var t=e;return H(t.name)&&ge(t.setup)}nl(e,t){this.rl(e)?t.push(()=>{this.sl().add(e).catch(cs)}):this.To.push(e)}tl(){var e,t,i,r,n,a,o=(e=(t=this.config.__extensionClasses)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:(i=Fe.__defaultExtensionClasses)==null?void 0:i.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||((r=this.al)==null||r.call(this),this.al=void 0,this.featureFlags=new o(this)),ge(this.featureFlags.onReloading)&&ge(this.featureFlags.setup)?this.al||(this.al=this.featureFlags.onReloading(()=>{this.Ro.emit("featureFlagsReloading",!0)}),this.sl().add(this.featureFlags)):(n=(a=this.featureFlags).initialize)==null||n.call(a))}el(e){var t,i,r,n,a,o,l,h=performance.now(),u=y({},Fe.__defaultExtensionClasses,this.config.__extensionClasses),c=[];u.exceptions&&this.To.push(this.exceptions=(t=this.exceptions)!==null&&t!==void 0?t:new u.exceptions(this)),u.historyAutocapture&&this.To.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.To.push(this.tracingHeaders=new u.tracingHeaders(this)),u.siteApps&&this.To.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!e&&this.To.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||c.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),u.autocapture&&this.nl(this.autocapture=new u.autocapture(this),c),u.surveys&&this.nl(this.surveys=(i=this.surveys)!==null&&i!==void 0?i:new u.surveys(this),c),u.logs&&this.To.push(this.logs=(r=this.logs)!==null&&r!==void 0?r:new u.logs(this)),u.metrics&&this.To.push(this.metrics=(n=this.metrics)!==null&&n!==void 0?n:new u.metrics(this)),u.conversations&&this.To.push(this.conversations=(a=this.conversations)!==null&&a!==void 0?a:new u.conversations(this)),u.productTours&&this.To.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.To.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.To.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.To.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.To.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,Fu)),u.toolbar&&this.To.push(this.toolbar=(o=this.toolbar)!==null&&o!==void 0?o:new u.toolbar(this)),u.experiments&&this.To.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new u.experiments(this)),this.To.forEach(v=>{v.initialize&&c.push(()=>{v.initialize==null||v.initialize()})}),c.push(()=>{if(this.ol){var v=this.ol;this.ol=void 0,this.To.forEach(f=>f.onRemoteConfig==null?void 0:f.onRemoteConfig(v))}}),this.ll(c,h)}ll(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.ll(e,t)},0);var i=e.shift();if(i)try{i()}catch(n){S.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({[ao]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[oo]:r}),this.config.__preview_deferred_init_extensions&&S.info("PostHog extensions initialized ("+r+"ms)")}pa(e){var t;if(!x||!x.body)return S.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.pa(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.ol=e),this.Io=e,this.compression=void 0,e.ok){var i,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=q(r.supportedCompression,ye.GZipJS)?ye.GZipJS:q(r.supportedCompression,ye.Base64)?ye.Base64:void 0),(i=r.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.Wo?this.Wo:mr}),(t=this.ul)==null||t.handleRemoteConfig(e),this.To.forEach(n=>n.onRemoteConfig==null?void 0:n.onRemoteConfig(e))}il(){try{this.config.loaded(this)}catch(i){S.critical("`loaded` function failed",i)}if(this.hl(),this.config.internal_or_test_user_hostname&&te!=null&&te.hostname){var e=te.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Lo())&&this.dl()},1),this.vl=new qo(this),this.vl.load()}hl(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Jo)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Ss(this.__request_queue,e=>this.Ko(e)),this.__request_queue=[],this.hl()}_handle_unload(){var e,t,i,r,n;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(t=this.metrics)==null||t.flush("sendBeacon"),this.config.request_batching?(this.cl()&&this.capture(Ei),(i=this.logs)==null||i.flushLogs("sendBeacon"),(r=this.Jo)==null||r.unload(),(n=this.Yo)==null||n.unload()):this.cl()&&this.capture(Ei,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?tl?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=y({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,(w(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,
2(t=>{var i,r,n,a=y({},t);a.timeout=a.timeout||6e4;var o,l,h,u,c,v=(i=a.transport)!==null&&i!==void 0?i:"fetch";v==="sendBeacon"&&w(a.compression)&&a.data&&(a.compression=ye.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(l=(c=(u=(A(o=a.data)?o:[o]).map(p=>y({},p,p.timestamp instanceof Date&&!isNaN(p.timestamp.getTime())?{timestamp:p.timestamp.toISOString()}:{})))[0])==null||(h=c.properties)==null?void 0:h.token)!==null&&l!==void 0?l:c==null?void 0:c.token,batch:u,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=function(p,m){return m===void 0&&(m=new Date().toISOString()),A(p)?p.map(b=>y({},b,{sent_at:m})):y({},p,{sent_at:m})}(a.data))),a.url=zn(a.url,a.method,a.compression,a.timestampMode);var f=js.filter(p=>!a.disableTransport||!p.transport||!a.disableTransport.includes(p.transport)),d=(r=(n=function(p,m){for(var b=0;p.length>b;b++)if(p[b].transport===v)return p[b]}(f))==null?void 0:n.method)!==null&&r!==void 0?r:f[0].method;if(!d)throw new Error("No available transport method");var g=p=>{try{d(p)}catch(m){Uo(m)?S.warn(m):S.error(m),a.callback==null||a.callback({statusCode:0,error:m})}};v!=="sendBeacon"&&a.data&&a.compression===ye.GZipJS&&nl&&typeof Promise<"u"&&!Ns?Uu(a).then(p=>{g(p)}).catch(p=>{if(nn(p))return Ns=!0,void g(y({},a,{compression:void 0,url:zn(t.url,t.method,void 0,t.timestampMode)}));(m=>{if(!m||typeof m!="object")return!1;var b="name"in m?String(m.name):"";return nn(m)||b===ga})(p)&&(Ns=!0),g(a)}):d(a)})(y({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(i=(r=this.config).on_request_error)==null||i.call(r,t),e.callback==null||e.callback(t)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}Ko(e){this.Yo?this.Yo.retriableRequest(e):this._send_request(e)}_execute_array(e){ji++;try{var t,i=[],r=[],n=[];Ss(e,o=>{if(o)if(A(t=o[0]))n.push(o);else if(ge(o))try{o.call(this)}catch(l){S.error("Error executing queued PostHog call",o,l)}else A(o)&&t==="alias"?i.push(o):A(o)&&t.indexOf("capture")!==-1&&ge(this[t])?n.push(o):r.push(o)});var a=function(o,l){Ss(o,function(h){try{if(A(h[0])){var u=l;U(h,function(c){u=u[c[0]].apply(u,c.slice(1))})}else l[h[0]].apply(l,h.slice(1))}catch(c){S.error("Error executing queued PostHog call",h,c)}})};a(i,this),a(r,this),a(n,this)}finally{ji--}}push(e){if(ji>0&&A(e)&&H(e[0])){var t=Fe.prototype[e[0]];ge(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var r,n,a,o,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Jo){if(this.is_capturing())if(!w(e)&&H(e)){this.$o();var h=!this.config.opt_out_useragent_filter&&this._is_bot();if(!h||this.config.__preview_capture_bot_pageviews){var u=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(u==null||!u.isRateLimited){t!=null&&t.$current_url&&!H(t==null?void 0:t.$current_url)&&(S.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||i!=null&&i.fl||S.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var c=new Date,v=(i==null?void 0:i.timestamp)||c,f=hn(i==null?void 0:i.uuid,ze),d={uuid:f,event:e,properties:this.calculateEventProperties(e,t||{},v,f)};e===Ft&&this.config.__preview_capture_bot_pageviews&&h&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),u&&(d.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);var g=e==="$feature_flag_called"&&d.properties.$feature_flag_has_experiment===!1&&this.get_property(Ks)===!0;i!=null&&i.$set&&!g&&(d.$set=i==null?void 0:i.$set);var p=i==null?void 0:i.$unset;p&&(d.$unset=p);var m,b,E,I=g?void 0:this.pl(i==null?void 0:i.$set_once,e!==mn,e===Si);if(I&&(d.$set_once=I),i!=null&&i._noTruncate||(n=this.config.properties_string_max_length,a=d,o=O=>
2H(O)?O.slice(0,n):O,l=new Set,d=function O(M,j){if(M!==Object(M))return o?o(M):M;if(!l.has(M)){var V;if(l.add(M),A(M))V=[],Ss(M,K=>{V.push(O(K))});else{var B={};U(M,(K,ae)=>{l.has(K)||(B[ae]=O(K))}),V=B}return V}}(a)),d.timestamp=v,w(i==null?void 0:i.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=c),g&&(d.properties=function(O,M){M===void 0&&(M=[]);var j={},V=B=>{O[B]!==void 0&&(j[B]=O[B])};return al.forEach(V),M.forEach(V),j}(d.properties,uh)),e===Ze.DISMISSED||e===Ze.SENT){var k=t==null?void 0:t[qi.SURVEY_ID],$=t==null?void 0:t[qi.SURVEY_ITERATION];Zo({id:k,current_iteration:$}),d.$set=y({},d.$set,{[(m={id:k,current_iteration:$},b=e===Ze.SENT?"responded":"dismissed",E="$survey_"+b+"/"+m.id,m.current_iteration&&m.current_iteration>0&&(E="$survey_"+b+"/"+m.id+"/"+m.current_iteration),E)]:!0})}else e===Ze.SHOWN&&(d.$set=y({},d.$set,{[qi.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Lu.SHOWN){var N=t==null?void 0:t[Ln.TOUR_TYPE];N&&(d.$set=y({},d.$set,{[Ln.TOUR_LAST_SEEN_DATE+"/"+N]:new Date().toISOString()}))}var P=y({},d.properties.$set,d.$set);if(Le(P)||this.setPersonPropertiesForFlags(P),!L(this.config.before_send)){var T=this.kn(d);if(!T)return;(d=T).uuid=hn(d.uuid,ze)}this.Ro.emit("eventCaptured",d);var F=(r=i==null?void 0:i._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),R={method:"POST",url:F,data:d,compression:"best-available",timestampMode:(i==null?void 0:i._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(F)?"body":"capture-body",batchKey:i==null?void 0:i._batchKey,transport:i==null?void 0:i.transport};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Ko(R):this.Jo.enqueue(R),d}S.critical("This capture call is ignored due to client rate limiting.")}}else S.error("No event name provided to posthog.capture")}else S.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}sl(){var e;return(e=this.ul)!==null&&e!==void 0?e:this.ul=new lh(this)}Ao(e){this.Ho.push(e);var t=!0;return()=>{if(t){t=!1;var i=this.Ho.indexOf(e);i!==-1&&this.Ho.splice(i,1)}}}gl(e){var t,i,r;return e===void 0&&(e=!0),!((t=this.persistence)==null||!t.consumeCookieIdentityChange())&&(this.Vo=null,this.persistence.get_property(D)===oe&&((r=this.sessionPersistence)==null||r.clear(),this.jo.clear(),this.ml()),(i=this.featureFlags)==null||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;this.persistence.syncCookieProperties(),this.gl();var a=n?void 0:this.persistence.remove_event_timer(e),o=y({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.Lo()&&(o[no]=!0),e==="$snapshot"){var l=y({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=l.distinct_id,(!H(o.distinct_id)&&!le(o.distinct_id)||Bs(o.distinct_id))&&S.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var h,u=function(k,$,N,P){var T,F,R,O;if(P===void 0&&(P=!1),!Ee)return{};var M,j=k?[...zt,...$||[]]:[],V=function(ws){for(var Ce=0;ln.length>Ce;Ce++){var xs=ln[Ce],wt=xs[1],xt=xs[0].exec(ws),Gt=xt&&(ge(wt)?wt(xt,ws):wt);if(Gt)return Gt}return["",""]}(Ee),B=V[0],K=V[1],ae=(M=typeof navigator<"u"?navigator:void 0)!=null&&M.brave?{brave:!0}:{},we={};w(N)||(we.detectGoogleSearchApp=N);var pe={},xe=(T=navigator)==null||(T=T.userAgentData)==null?void 0:T.platform,Pe=(F=navigator)==null?void 0:F.maxTouchPoints,ie=_==null||(R=_.screen)==null?void 0:R.width,ce=_==null||(O=_.screen)==null?void 0:O.height,he=_==null?void 0:_.devicePixelRatio;w(xe)||(pe.userAgentDataPlatform=xe),w(Pe)||(pe.maxTouchPoints=Pe),w(ie)||(pe.screenWidth=ie),w(ce)||(pe.screenHeight=ce),w(he)||(pe.devicePixelRatio=he);var De,at,ne,qe,tt,Ut,Oe,ke,bs=W(zr({$os:B,$os_version:K,$browser:za(Ee,navigator.vendor,ae,we),$device:un(Ee),$device_type:(at=Ee,ne=pe,ke=un(at),ke===Sa||ke===Ea||ke==="Kobo"||ke==="Kindle Fire"||ke===Da?Dt:ke
2===ds||ke===qt||ke===vs||ke===er?"Console":ke===Pa?"Wearable":ke?$e:(ne==null?void 0:ne.userAgentDataPlatform)==="Android"&&((qe=ne==null?void 0:ne.maxTouchPoints)!==null&&qe!==void 0?qe:0)>0?600>Math.min((tt=ne==null?void 0:ne.screenWidth)!==null&&tt!==void 0?tt:0,(Ut=ne==null?void 0:ne.screenHeight)!==null&&Ut!==void 0?Ut:0)/((Oe=ne==null?void 0:ne.devicePixelRatio)!==null&&Oe!==void 0?Oe:1)?$e:Dt:"Desktop"),$timezone:Mo(),$timezone_offset:Mu()}),{$current_url:_s(P?rt(te==null?void 0:te.href):te==null?void 0:te.href,j,ms),$host:te==null?void 0:te.host,$pathname:te==null?void 0:te.pathname,$raw_user_agent:Ee.length>1e3?Ee.substring(0,997)+"...":Ee,$browser_version:Tl(Ee,navigator.vendor,ae,we),$browser_language:qn(),$browser_language_prefix:(De=qn(),typeof De=="string"?De.split("-")[0]:void 0),$screen_height:_==null?void 0:_.screen.height,$screen_width:_==null?void 0:_.screen.width,$viewport_height:_==null?void 0:_.innerHeight,$viewport_width:_==null?void 0:_.innerWidth,$lib:X.LIB_NAME,$lib_version:X.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return X.SDK_DIST_CHANNEL&&(bs.$sdk_dist_channel=X.SDK_DIST_CHANNEL),bs}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var c=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0),v=c.windowId;o.$session_id=c.sessionId,o.$window_id=v}this.sessionPropsManager&&W(o,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&W(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=(f=this.Yo)==null?void 0:f.length}catch(k){o.$sdk_debug_error_capturing_properties=String(k)}if(this.requestRouter.region===Tr&&(o.$lib_custom_api_host=this.config.api_host),h=e!==Ft||n?e!==Ei||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),o=W(o,h),e===Ft&&x&&(o.title=x.title),!w(a)){var d=i.getTime()-a;o.$duration=parseFloat((d/1e3).toFixed(3))}Ee&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser");var g=this.persistence.properties(),p=this.sessionPersistence.properties();U(["$referrer","$referring_domain"],k=>{k in g&&delete p[k]});var m={};if(this.Ho.length>0)for(var b of this.Ho.slice())try{W(m,b())}catch(k){S.error("Failed to produce browser extension event properties",k)}(o=W({},u,g,p,y({},m,o))).$is_identified=this._isIdentified(),A(this.config.property_denylist)?U(this.config.property_denylist,function(k){delete o[k]}):S.error(el+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var E=this.config.sanitize_properties;E&&(S.error(Yn),o=E(o,e));var I=this.yl();return o.$process_person_profile=I,I&&!n&&this.bl("_calculate_event_properties"),o}pl(e,t,i){var r;if(t===void 0&&(t=!0),i===void 0&&(i=!1),!this.persistence||!this.yl()||this.qo&&!i)return e;var n=this.persistence.get_initial_props(),a=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=W({},n,a||{},e||{}),l=this.config.sanitize_properties;return l&&(S.error(Yn),o=l(o,"$set_once")),t&&(this.qo=!0),Le(o)?void 0:o}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var r;(r=this.persistence)==null||r.register_once(e,t,i)}register_for_session(e){var t,i;(t=this.persistence)==null||t.syncCookieProperties(),this.gl(),(i=this.sessionPersistence)==null||i.register(e),Object.keys(e).forEach(r=>this.jo.add(r)),this.ml()}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e),this.jo.delete(e),this.ml()}_l(e,t){this.register({[e]:t})}Xo(){this.jo.forEach(e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)}),this.jo.clear(),this.ml()}ml(){var e;if(this.Bo)if(this.config.persistence==="memory"||(e=this.sessionPersistence)!=null&&e.Hs||!J.Dr())J.qr(this.Bo);else{var t=[];this.jo.forEach(i=>t.push(i)),t.length>0?J.Nr(this.Bo,t):J.qr(this.Bo)}}getFeatureFlag(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,t){var i,r;return(i=(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(e,t))!==null&&i!==void 0?i:t==null?void 0:t.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.Ro.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Zt}),()=>{})}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Zt})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Zt})}renderSurvey(e,t){var i;(i=this.surveys)==null||i.renderSurvey(e,t)}displaySurvey(e,t){var i;t===void 0&&(t=sh),(i=this.surveys)==null||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return(t=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:Zt}}canRenderSurveyAsync(e,t){var i,r;return t===void 0&&(t=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:Zt})}wl(e){return!e||Bs(e)?(S.critical("Unique user id has not been set in posthog.identify"),!1):e===kt?(S.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(S.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and n
2ot a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return S.uninitializedWarning("posthog.identify");if(le(e)&&(e=e.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.wl(e)&&this.bl("posthog.identify")){this.$o();var r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this.gl(!1),o=this.persistence.Ws(),l=!1;try{var h=this.get_distinct_id();this.register({$user_id:e}),this.get_property(ps)||this.register_once({$had_persisted_distinct_id:!0,$device_id:h},""),e!==h&&e!==this.get_property($t)&&(this.unregister($t),this.register({distinct_id:e}));var u,c=(this.persistence.get_property(D)||oe)===oe,v=e!==h,f=!v&&c;if(v&&c)this.persistence.set_property(D,ve),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Vs(),this.capture(Si,{distinct_id:e,$anon_distinct_id:h},{$set:t||{},$set_once:i||{}}),this.Vo=Ni(e,t,i),(u=this.featureFlags)==null||u.setAnonymousDistinctId(h);else if(f){this.persistence.set_property(D,ve);var d=t||{},g=i||{};this.setPersonPropertiesForFlags({$set:d,$set_once:g},!1),this.config.cookieWinsOnConflict&&this.persistence.Vs(),this.capture("$set",{$set:d,$set_once:g}),this.Vo=Ni(e,t,i)}else(t||i)&&this.setPersonProperties(t,i);v||n||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Qe)):f&&(t||i)&&this.reloadFeatureFlags(),l=!0}finally{o&&this.persistence.Qs(l)}}}setPersonProperties(e,t){if((e||t)&&this.bl("posthog.setPersonProperties")){var i=Ni(this.get_distinct_id(),e,t);this.Vo!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Vo=i):S.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(A(e)?e:[e]).filter(r=>H(r)&&r.length>0);i.length!==0&&this.bl("posthog.unsetPersonProperties")&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Vo=null)}group(e,t,i){var r;if(e&&t){(r=this.persistence)==null||r.syncCookieProperties(),this.gl();var n=this.getGroups(),a=n[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:y({},n,{[e]:t})}),a||i){var o={$group_type:e,$group_key:t};i&&(o.$group_set=i),this.capture(mn,o)}i&&this.setGroupPropertiesForFlags({[e]:i}),a&&!i&&this.reloadFeatureFlags()}else S.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;e===void 0&&(e=!0),(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),this.bl("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t=Se(e)?e:e==null?void 0:e.resetDeviceID,i=Se(e)||e==null?void 0:e.bootstrap;this.kl(t,!1,i)}kl(e,t,i){var r,n,a;if(t===void 0&&(t=!1),S.info("reset"),!this.__loaded)return S.uninitializedWarning("posthog.reset");var o=i==null?void 0:i.sessionID;this.config.bootstrap=i||((r=this.Zo)==null?void 0:r.bootstrap)||{},(n=this.featureFlags)==null||n.updateConfig==null||n.updateConfig(this.config,this.ma());var l=this.get_property(ps),h=this.get_property(ki),u=this.get_property(ft),c=this.is_capturing();this.consent.reset(),t||!c||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var v=(a=this.persistence)==null||a.Ws==null?void 0:a.Ws(),f=!1;try{var d,g,p,m,b,E,I,k,$,N,P,T,F,R;if((d=this.persistence)==null||d.clear(),(g=this.sessionPersistence)==null||g.clear(),this.jo.clear(),this.ml(),w(u)||(P=this.persistence)==null||P.register({[ft]:u}),(p=this.surveys)==null||p.reset(),(m=this.vl)==null||m.stop(),(b=this.featureFlags)==null||b.reset(),(E=this.conversations)==null||E.reset(),(I=this.logs)==null||I.reset(),(k=this.metrics)==null||k.reset(),($=this.persistence)==null||$.set_property(D,oe),(N=this.sessionManager)==null||N.resetSessionId(),this.Vo=null,this.config.cookieless_mode===Ke)this.register_once({distinct_id:kt,$device_id:null},"");else{var O=this.config.get_device_id(ze());this.register_once({distinct_id:O,$device_id:e?O:l},""),e||w(h)||this.register({[ki]:h})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID===void 0||this.Lo()||((R=this.persistence)==null||R.set_property(D,i.isIdentifiedID?ve:oe),this.register({distinct_id:i.distinctID})),(T=this.featureFlags)==null||T.initialize(),!(w(o)||(F=this.sessionManager)!=null&&F.setBootstrapSessionId(o,!0)))){var M=y({},i);delete M.sessionID,this.config.bootstrap=M}delete this.config.identity_distinct_id,delete this.config.identity_hash,f=!0}finally{var j;v&&((j=this.persistence)==null||j.Qs==null||j.Qs(f))}this.reloadFeatureFlags()}shutdown(e){var t=this;return Q(function*(){var i,r,n,a,o,l;if(t.__loaded){(i=t.vl)==null||i.stop(),t.sl().dispose(),(r=t.sessionRecording)==null||r.dispose(),(n=t.logs)==null||n.flushLogs("sendBeacon"),(a=t.metrics)==null||a.flush("sendBeacon"),(o=t.Jo)==null||o.unload(),(l=t.Yo)==null||l.unload();try{var h;(h=t.featureFlags)==null||h.destroy()}catch(u){S.error("Error while destroying feature flags",u)}}else S.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(i=this.conversations)==null||i.Sl()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.xl()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(e!=null&&e.withTimestamp&&i){var n,a=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;
2r+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-a,0)}return r}alias(e,t){return e===this.get_property(Ka)?(S.critical("Attempting to create alias for existing People user - aborting."),-2):this.bl("posthog.alias")?(w(t)&&(t=this.get_distinct_id()),e!==t?(this._l($t,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(S.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=y({},this.config);if(Y(e)){var i,r,n,a,o,l,h,u,c,v,f,d;W(this.config,Qn(e));var g=this.Do();(i=this.persistence)==null||i.update_config(this.config,t,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Ri(y({},this.config,{persistence:"sessionStorage"}),g,!1);var p,m=this.Go(this.config.debug);Se(m)&&(this.config.debug=m),Se(this.config.debug)&&(this.config.debug?(X.DEBUG=!0,G.Dr()&&G.Nr("ph_debug",!0),S.info("set_config",{config:e,oldConfig:t,newConfig:y({},this.config)})):(X.DEBUG=!1,G.Dr()&&G.qr("ph_debug"))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.ma()),(n=this.exceptionObserver)==null||n.onConfigChange(),(a=this.exceptions)==null||a.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(h=this.autocapture)==null||h.startIfEnabled(),(u=this.heatmaps)==null||u.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((p=this.historyAutocapture)==null||p.startIfEnabledOrStop()),(c=this.exceptionObserver)==null||c.startIfEnabledOrStop(),(v=this.deadClicksAutocapture)==null||v.startIfEnabledOrStop(),(f=this.surveys)==null||f.loadIfEnabled(),this.No(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){X.LIB_NAME=e,X.LIB_VERSION=t}startSessionRecording(e){var t,i,r,n,a,o=e===!0,l={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(y({},r,t))}}addExceptionStep(e,t){var i;(i=this.exceptions)==null||i.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){var e,t;return(e=(t=this.logs)==null?void 0:t.logger)!==null&&e!==void 0?e:Fe.Cl}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return(t=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Tt;return t!==Tt&&(t=Tt+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(D))===ve||((t=this.sessionPersistence)==null?void 0:t.get_property(D))===ve}yl(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===mr&&!this._isIdentified()&&Le(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[$t])&&((t=this.persistence)==null||(t=t.props)==null||!t[ti]))}cl(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.yl()||this.bl("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bl("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}bl(e){return this.config.person_profiles==="never"?(S.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._l(ti,!0),!0)}Do(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==vt)}No(){var e,t,i,r,n=this.Do();return((e=this.persistence)==null?void 0:e.Hs)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.Hs)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n&&(this.jo.clear(),this.ml()),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==Ke){if(this.Lo()){var i,r,n,a,o;this.kl(!0,!0),(i=this.sessionManager)==null||i.destroy(),(r=this.pageViewM
2anager)==null||r.destroy(),this.sessionManager=new Gn(this),this.pageViewManager=new Mn(this),this.persistence&&(this.sessionPropsManager=new Vn(this,this.sessionManager,this.persistence));var l,h=(n=(a=this.config.__extensionClasses)==null?void 0:a.sessionRecording)!==null&&n!==void 0?n:(o=Fe.__defaultExtensionClasses)==null?void 0:o.sessionRecording;h&&(this.sessionRecording=this.Oo(this.sessionRecording,new h(this)),this.Io&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.Io)))}var u,c;this.consent.optInOut(!0),this.No(),this.hl(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==vt&&((u=this.surveys)==null||u.loadIfEnabled()),(w(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((c=e==null?void 0:e.captureEventName)!==null&&c!==void 0?c:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.dl()}else S.warn(Xn)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==Ke?(this.config.cookieless_mode===vt&&this.consent.isOptedIn()&&this.kl(!0,!0),this.consent.optInOut(!1),this.No(),this.config.cookieless_mode===vt&&(this.register({distinct_id:kt,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.dl(),this.hl())):S.warn(Xn)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Ke||(this.config.cookieless_mode===vt?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.No()}_is_bot(){return be?Wo(be,this.config.custom_blocked_useragents):void 0}dl(){x&&(x.visibilityState==="visible"?this.Uo||(this.Uo=!0,this.capture(Ft,{title:x.title},{send_instantly:!0}),this.zo&&(x.removeEventListener(si,this.zo),this.zo=null)):this.zo||(this.zo=this.dl.bind(this),Z(x,si,this.zo)))}debug(e){e===!1?(_==null||_.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_==null||_.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}))}ma(){var e=this.Zo||{};return"advanced_disable_flags"in e?!!e.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(t,i,r,n,a){var o=i in t&&!L(t[i]),l=r in t&&!L(t[r]);return o?t[i]:!!l&&(a&&a.warn("Config field '"+r+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),t[r])}(e,"advanced_disable_flags","advanced_disable_decide",0,S)}kn(e){var t;if(L(this.config.before_send))return e;var i=Object.keys((t=e.properties)!==null&&t!==void 0?t:{}).filter(_l),r=A(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var a of r)try{if(n=a(n),L(n)){var o="Event '"+e.event+"' was rejected in beforeSend function";return gl(e.event)?S.warn(o+". This can cause unexpected behavior."):S.info(o),null}n.properties&&!Le(n.properties)||S.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(h){return S.error("Error in beforeSend function for event '"+e.event+"':",h),null}for(var l of i)if(n.properties&&L(n.properties[l]))return S.warn("Event '"+e.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return n}getPageViewId(){var e;
2return(e=this.pageViewManager.Ss)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Go(e){var t=Se(e)&&!e,i=G.Dr()&&G.Pr("ph_debug")==="true";return!t&&(!!i||e)}}Fe.__defaultExtensionClasses={},Fe.Cl=(()=>{var s=()=>{};return{trace:s,debug:s,info:s,warn:s,error:s,fatal:s}})(),function(s,e){for(var t=0;e.length>t;t++)s.prototype[e[t]]=ou(s.prototype[e[t]])}(Fe,["identify"]);class sl{constructor(e){this.disabled=e===!1;var t=Y(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.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}}var Hi="$copy_autocapture",Cs=ee("[AutoCapture]");function zi(s,e){return e.length>s?e.slice(0,s)+"...":e}function dh(s){if(s.previousElementSibling)return s.previousElementSibling;var e=s;do e=e.previousSibling;while(e&&!nt(e));return e}function vh(s,e){var t,i,r=e.e,n=e.maskAllElementAttributes,a=e.maskAllText,o=e.elementAttributeIgnoreList,l=e.elementsChainAsString,h=e.disableCaptureUrlHashes;if(!nt(s))return{props:{}};for(var u=[s],c=new Set([s]),v=s;v.parentNode&&!Te(v,"body")&&go>u.length;)if(fo(v.parentNode)){var f=v.parentNode.host;if(c.has(f))break;c.add(f),u.push(f),v=f}else{if(!nt(v.parentNode)||c.has(v.parentNode))break;c.add(v.parentNode),u.push(v.parentNode),v=v.parentNode}var d,g,p=[],m={},b=!1,E=!1;if(U(u,P=>{var T=xr(P);if(Te(P,"a")){var F=P.getAttribute("href");b=!!(T&&F&&ls(F))&&(h?rt(F):F)}q(ai(P),"ph-no-capture")&&(E=!0),p.push(function(O,M,j,V,B){B===void 0&&(B=!1);var K=O.tagName.toLowerCase(),ae={tag_name:K};Ur.indexOf(K)>-1&&!j&&(ae.$el_text=K.toLowerCase()==="a"||K.toLowerCase()==="button"?zi(1024,On(O)):zi(1024,gs(O)));var we=ai(O);we.length>0&&(ae.classes=we.filter(function(ie){return ie!==""})),U(O.attributes,function(ie){var ce;if((!xo(O)||["name","id","class","aria-label"].indexOf(ie.name)!==-1)&&(V==null||!V.includes(ie.name))&&!M&&ls(ie.value)&&(!H(ce=ie.name)||ce.substring(0,10)!=="_ngcontent"&&ce.substring(0,7)!=="_nghost")){var he=ie.value;ie.name==="class"&&(he=Vr(he).join(" ")),ae["attr__"+ie.name]=zi(1024,ie.name==="href"&&B?rt(he):he)}});for(var pe=1,xe=1,Pe=O;Pe=dh(Pe);)pe++,Pe.tagName===O.tagName&&xe++;return ae.nth_child=pe,ae.nth_of_type=xe,ae}(P,n,a,o,h));var R=function(O){if(!xr(O))return{};var M={};return U(O.attributes,function(j){if(j.name&&j.name.indexOf("data-ph-capture-attribute")===0){var V=j.name.replace("data-ph-capture-attribute-",""),B=j.value;V&&B&&ls(B)&&(M[V]=B)}}),M}(P);W(m,R)}),E)return{props:{},explicitNoCapture:E};if(a||(p[0].$el_text=Te(s,"a")||Te(s,"button")?On(s):gs(s)),b){var I,k;p[0].attr__href=b;var $=(I=Bt(b))==null?void 0:I.host,N=_==null||(k=_.location)==null?void 0:k.host;$&&N&&$!==N&&(d=b)}return{props:W({$event_type:r.type,$ce_version:1},l?{}:{$elements:p},{$elements_chain:(g=p,function(P){return P.map(T=>{var F,R,O="";if(T.tag_name&&(O+=T.tag_name),T.attr_class)for(var M of(T.attr_class.sort(),T.attr_class))O+="."+M.replace(/"/g,"");var j=y({},T.text?{text:T.text}:{},{"nth-child":(F=T.nth_child)!==null&&F!==void 0?F:0,"nth-of-type":(R=T.nth_of_type)!==null&&R!==void 0?R:0},T.href?{href:T.href}:{},T.attr_id?{attr_id:T.attr_id}:{},T.attributes),V={};return Ds(j).sort((B,K)=>B[0].localeCompare(K[0])).forEach(B=>{var K=B[1];return V[Cn(B[0].toString())]=Cn(K.toString())}),(O+=":")+Ds(V).map(B=>B[0]+'="'+B[1]+'"').join("")}).join(";")}(function(P){return P.map(T=>{var F,R,O={text:(F=T.$el_text)==null?void 0:F.slice(0,400),tag_name:T.tag_name,href:(R=T.attr__href)==null?void 0:R.slice(0,2048),attr_class:Iu(T),attr_id:T.attr__id,nth_child:T.nth_child,nth_of_type:T.nth_of_type,attributes:{}};return Ds(T).filter(M=>
2M[0].indexOf("attr__")===0).forEach(M=>O.attributes[M[0]]=M[1]),O})}(g)))},(t=p[0])!=null&&t.$el_text?{$el_text:(i=p[0])==null?void 0:i.$el_text}:{},d&&r.type==="click"?{$external_click_url:d}:{},m)}}class ph{constructor(e){this.name="autocapture",this.Qn=!1,this.Jn=null,this.Kn=!1,this.Yn=!1,this.qi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Xn=!1,this.ts=e,this.ts.refresh(this.qi),this.rageclicks=new sl(this.qi.rageclick),this.es=null}setup(e){this.rs(),this.ns=e;var t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.Xn?t.dispose():(this.ss=t,this.startIfEnabled())}dispose(){var e;this.Xn||(this.Xn=!0,this.ns=void 0,(e=this.ss)==null||e.dispose(),this.ss=void 0,this.os())}ls(){return this.ts.refresh(this.qi),this.qi}rs(){var e,t;return this.ls(),this.qi.url_allowlist=(e=this.qi.url_allowlist)==null?void 0:e.map(i=>new RegExp(i)),this.qi.url_ignorelist=(t=this.qi.url_ignorelist)==null?void 0:t.map(i=>new RegExp(i)),this.qi}us(){if(this.isBrowserSupported()){if(_&&x){var e=this.hs=i=>{i=i||(_==null?void 0:_.event);try{this.ds(i)}catch(r){Cs.error("Failed to capture event",r)}};if(Z(x,"submit",e,{capture:!0}),Z(x,"change",e,{capture:!0}),Z(x,"click",e,{capture:!0}),this.ls().capture_copied_text){var t=this.vs=i=>{i=i||(_==null?void 0:_.event);try{this.ds(i,Hi)}catch(r){Cs.error("Failed to capture copy/cut event",r)}};Z(x,"copy",t,{capture:!0}),Z(x,"cut",t,{capture:!0})}}}else Cs.info("Disabling Automatic Event Collection because this browser is not supported")}os(){this.hs&&(x==null||x.removeEventListener("submit",this.hs,!0),x==null||x.removeEventListener("change",this.hs,!0),x==null||x.removeEventListener("click",this.hs,!0),this.hs=void 0),this.vs&&(x==null||x.removeEventListener("copy",this.vs,!0),x==null||x.removeEventListener("cut",this.vs,!0),this.vs=void 0),this.Qn=!1}startIfEnabled(){!this.Xn&&this.ns&&this.isEnabled&&!this.Qn&&(this.us(),this.Qn=!0)}onRemoteConfig(e){if(!this.Xn)if(this.Kn=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this.Yn=t.elementsChainAsString);var i,r=t.autocapture_opt_out;Se(r)&&((i=this.ns)==null||i.kv.set(rr,r),this.Jn=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this.es=e}getElementSelectors(e){var t,i=[];return(t=this.es)==null||t.forEach(r=>{var n=x==null?void 0:x.querySelectorAll(r);n==null||n.forEach(a=>{e===a&&i.push(r)})}),i}get isEnabled(){var e,t;if(this.Xn)return!1;var i=(e=this.ns)==null?void 0:e.kv.get(rr),r=this.Jn,n=this.ls(),a=n.remoteRequestsDisabled&&!this.Kn;if(de(r)&&!Se(i)&&!a)return!1;var o=(t=this.Jn)!==null&&t!==void 0?t:!!i;return!!n.enabled&&!o}ds(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var i=br(e);po(i)&&(i=i.parentNode||null);var r,n=this.rs();t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&n.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&bo(i,n.rageclick)&&this.ds(e,"$rageclick");var a=t===Hi;if(i&&function(d,g,p,m,b,E){var I;if(!_||Gr(d)||p!=null&&p.url_allowlist&&!En(p.url_allowlist,E)||p!=null&&p.url_ignorelist&&En(p.url_ignorelist,E))return!1;if(p!=null&&p.dom_event_allowlist){var k=p.dom_event_allowlist;if(k&&!k.some(R=>g.type===R))return!1}var $=wo(d,m),N=$.parentIsUsefulElement,P=$.targetElementList;if(!function(R,O){var M=O==null?void 0:O.element_allowlist;if(w(M))return!0;var j,V=function(K){if(M.some(ae=>K.tagName.toLowerCase()===ae))return{v:!0}};for(var B of R)if(j=V(B))return j.v;return!1}(P,p)||!wr(P,p==null?void 0:p.css_selector_allowlist)||wr(P,(I=p==null?void 0:p.css_selector_ignorelist)!==null&&I!==void 0?I:bu))return!1;try{var T=_.getComputedStyle(d);if(T&&T.getPropertyValue("cursor")==="pointer"&&g.type==="click")return!0}catch{}var F=d.tagName.toLowerCase();switch(F){case"html":return!1;case"form":return(b||["submit"]).indexOf(g.type)>=0;case"input":case"select":case"textarea":return(b||["change","click"]).indexOf(g.type)>=0;default:return N?(b||["click"]).indexOf(g.type)>=0:(b||["click"]).indexOf(g.type)>=0&&(Ur.indexOf(F)>-1||d.getAttribute("contenteditable")==="true")}}(i,e,n,a,a?["copy","cut"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var o,l=vh(i,{e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsC
2hainAsString:this.Yn,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),h=l.props;if(l.explicitNoCapture)return!1;var u=this.getElementSelectors(i);if(u&&u.length>0&&(h.$element_selectors=u),t===Hi){var c,v=_o(_==null||(c=_.getSelection())==null?void 0:c.toString()),f=e.type||"clipboard";if(!v)return!1;h.$selected_content=v,h.$copy_type=f}return(o=this.ns)==null||o.capture(t,h).catch(d=>Cs.error("Failed to capture event",d)),!0}}}isBrowserSupported(){return ge(x==null?void 0:x.querySelectorAll)}}class fh{constructor(e){this._instance=e}refresh(e){var t=this._instance.config,i=Y(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.ma(),e.url_allowlist=i==null?void 0:i.url_allowlist,e.url_ignorelist=i==null?void 0:i.url_ignorelist,e.dom_event_allowlist=i==null?void 0:i.dom_event_allowlist,e.element_allowlist=i==null?void 0:i.element_allowlist,e.css_selector_allowlist=i==null?void 0:i.css_selector_allowlist,e.css_selector_ignorelist=i==null?void 0:i.css_selector_ignorelist,e.element_attribute_ignorelist=i==null?void 0:i.element_attribute_ignorelist,e.capture_copied_text=i==null?void 0:i.capture_copied_text}}var es=ee("[ExceptionAutocapture]"),Kn=()=>{},gh=ee("[TracingHeaders]"),lt=ee("[Web Vitals]"),Zn=9e5,ea="disabled",ta="lazy_loading",ts="awaiting_config",Rs="missing_config";ee("[SessionRecording]"),ee("[SessionRecording]");var $r="[SessionRecording]",We=ee($r),_h=ee("[Heatmaps]");function Vi(s){return Y(s)&&"clientX"in s&&"clientY"in s&&le(s.clientX)&&le(s.clientY)}var Ms=ee("[Product Tours]"),Ui=s=>{var e;return!s.config.disable_product_tours&&!((e=s.persistence)==null||!e.get_property(jr))},mh=["$set_once","$set"],Ne=ee("[SiteApps]"),sa="Error while initializing PostHog app with config id ",il=(s,e)=>s!=null&&s.then?s.then(e):e(s),It="SDK is not enabled or survey functionality is not yet loaded",ia="Disabled. Not loading surveys.";class yh{constructor(e,t){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Tl=!1,this.Ml=[],this.El=null,this.Il=null,this.Xn=!1,this.Rl=new Set,this.onRemoteConfig=i=>{if(!this.Xn&&!this.qi.disableSurveys){if(!i.ok)return z.warn("Remote config unavailable. Not loading surveys.");var r=i.config.surveys;if(L(r))return z.warn("Flags not loaded yet. Not loading surveys.");this.Pl=Se(r)?r:r.length>0,z.info("flags response received, isSurveysEnabled: "+this.Pl),this.loadIfEnabled()}},this.ts=e,this.Al=t}setup(e){if(!this.Xn)return this.Fl=e,il(e.kv.initialize(),()=>{if(this.Fl===e&&!this.Xn){this.Fl=void 0,this.ns=e;var t=e.onRemoteConfig(this.onRemoteConfig);this.Xn?t.dispose():(this.ss=t,this.loadIfEnabled())}})}dispose(){var e,t,i;this.Xn||(this.Xn=!0,this.Fl=void 0,this.ns=void 0,(e=this.ss)==null||e.dispose(),this.ss=void 0,(t=this._surveyEventReceiver)==null||t.dispose(),this._surveyEventReceiver=null,(i=this._surveyManager)==null||i.dispose==null||i.dispose(),this._surveyManager=null,this.Ml=[],this.El=null,this.Rl.forEach(r=>clearTimeout(r)),this.Rl.clear())}get qi(){return this.ts.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(r!=null&&r.startsWith(Ko)||r!=null&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach(n=>localStorage.removeItem(n))}catch{}}loadIfEnabled(){if(!this.Xn&&this.ns){var e=this.qi;if(!this._surveyManager)if(this.Tl)z.info("Already initializing surveys, skipping...");else if(e.disableSurveys)z.info(ia);else if(e.cookielessMode&&this.ts.isOptedOut())z.info("Not loading surveys in cookieless mode without consent.");else{var t=this.ts.getExtensions();if(t){if(!w(this.Pl)||e.advancedEnableSurveys){var i=this.Pl||e.advancedEnableSurveys;this.Tl=!0;try{var r=t.generateSurveys;if(r)return this.Ol(r,i),void(this.Tl=!1);var n=t.loadExternalDependency;if(!n)return this.Ll(Hr),void(this.Tl=!1);n(a=>{try{if(this.Xn)return;var o=this.ts.getExtensions();a||o==null||!o.generateSurveys?this.Ll("Could not load surveys script",a):this.Ol(o.generateSurveys,i)}finally{this.Tl=!1}})}catch(a){throw this.Tl=!1,this.Ll("Error initializing surveys",a),a}}}else z.error("PostHog Extensions not found.")}}}Ol(e,t){this.Xn||(this._surveyManager=e(t),this._surveyEventReceiver=this.ts.createEventReceiver(),z.info("Surveys loaded successfully"),this.$l({isLoaded:!0}))}Ll(e,t){z.error(e,t),this.$l({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Ml.push(e),this._surveyManager&&this.$l({isLoaded:!0}),()=>{this.Ml=this.Ml.filter(t=>t!==e)}}getSurveys(e,t){var i;t===void 0&&(t=!1);var r=(i=this.ns)!==null&&i!==void 0?i:this.Al;if(r&&!this.Xn){if(this.qi.disableSurveys)return z.info(ia),e([]);var n=r.kv.get(cr);if(n&&!t)return e(n,{isLoaded:!0}
2),void(this.Dl()&&this.getSurveys(()=>{},!0));if(this.El)this.El.then(l=>{this.Xn||e(l.surveys,l.context)}).catch(l=>z.error("Error in survey callback",l));else{var a=this.Nl("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.qi.requestTimeoutMs}).then(l=>{try{return this.ql(r,l)}catch(h){return z.error("Error processing surveys response",h),this.ql(r,{statusCode:0,error:h})}},l=>this.ql(r,{statusCode:0,error:l}));this.El=a;var o=()=>{this.El===a&&(this.El=null)};a.then(l=>{o(),this.Xn||e(l.surveys,l.context)},o).catch(l=>z.error("Error in survey callback",l))}}}Nl(e,t){var i=this.ns;return i?i.sendRequest(e,t):new Promise(r=>r({statusCode:0,error:new Error(It)}))}ql(e,t){if(this.Xn)return{surveys:[],context:{isLoaded:!1,error:It}};var i=t.statusCode;if(i!==200||!t.json){var r="Surveys API could not be loaded, status: "+i;return i!==0?z.error(r):t.error||z.warn(r),this.Il=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Il=null;var n,a=t.json.surveys||[],o=a.filter(l=>function(h){return!(!h.start_date||h.end_date)}(l)&&(Qo(l)||function(h){var u;return!((u=h.conditions)==null||(u=u.actions)==null||(u=u.values)==null||!u.length)}(l)));return o.length>0&&((n=this._surveyEventReceiver)==null||n.register(o)),e.kv.set({[cr]:a,[Zs]:Date.now()}),{surveys:a,context:{isLoaded:!0}}}Dl(){return this.jl()&&!this.El&&!this.Bl()}jl(){var e,t,i=(e=(t=this.ns)!==null&&t!==void 0?t:this.Al)==null?void 0:e.kv.get(Zs);return le(i)&&Date.now()-i>3e5}Bl(){return le(this.Il)&&3e5>Date.now()-this.Il}markSurveyAsSeen(e,t){var i,r={id:e,current_iteration:(i=t==null?void 0:t.iteration)!==null&&i!==void 0?i:null};Zo(r);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}$l(e){for(var t of this.Ml)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){z.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!L(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);z.warn("init was not called")}Hl(e){var t=null;return this.getSurveys(i=>{var r;t=(r=i.find(n=>n.id===e))!==null&&r!==void 0?r:null}),t}Ul(e){if(L(this._surveyManager))return{eligible:!1,reason:It};var t=typeof e=="string"?this.Hl(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}zl(e){if(L(this._surveyManager))return{eligible:!1,reason:It};var t=typeof e=="string"?this.Hl(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(L(this._surveyManager))return z.warn("init was not called"),{visible:!1,disabledReason:It};var t=this.zl(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return L(this._surveyManager)?(z.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:It})):new Promise(i=>{this.getSurveys(r=>{var n,a=(n=r.find(l=>l.id===e))!==null&&n!==void 0?n:null;if(a){var o=this.zl(a);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var r;if(L(this._surveyManager))z.warn("init was not called");else{var n=typeof e=="string"?this.Hl(e):e;if(n!=null&&n.id)if(th.includes(n.type)){var a=x==null?void 0:x.querySelector(t);if(a)if((r=n.appearance)!=null&&r.surveyPopupDelaySeconds){z.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var l,h;this.Rl.delete(o),this.Xn||(z.info("Rendering survey "+n.id+" with delay of "+((l=n.appearance)==null?void 0:l.surveyPopupDelaySeconds)+" seconds"),(h=this._surveyManager)==null||h.renderSurvey(n,a,i),z.info("Survey "+n.id+" rendered"))},1e3*n.appearance.surveyPopupDelaySeconds);this.Rl.add(o)}else this._surveyManager.renderSurvey(n,a,i);else z.warn("Survey element not found")}else z.warn("Surveys of type "+n.type+" cannot be rendered in the app");else z.warn("Survey not found")}}displaySurvey(e,t){var i;if(L(this._surveyManager))z.warn("init was not called");else{var r=this.Hl(e);if(r){var n=r;if((i=r.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=y({},r,{appearance:y({},r.appearance,{surveyPopupDelaySeconds:0})}
2)),t.displayType!==kr.Popover&&t.initialResponses&&z.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var a=this.Ul(r);if(!a.eligible)return void z.warn("Survey is not eligible to be displayed: ",a.reason)}t.displayType!==kr.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else z.warn("Survey not found")}}cancelPendingSurvey(e){L(this._surveyManager)?z.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload==null||e.handlePageUnload()}}function Pt(s,e,t){if(L(s))return!1;switch(t){case"exact":return s===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(s);case"regex":try{return new RegExp(e).test(s)}catch{return!1}default:return!1}}class bh{constructor(e){this.Wl=new Set,this.Vl=new Set,this.Gl=new hi,this.Zl=(t,i)=>this.Ql(t,i)&&this.Jl(t,i)&&this.Kl(t,i)&&this.Yl(t,i),this.Ql=(t,i)=>i==null||!i.event||(t==null?void 0:t.event)===(i==null?void 0:i.event),this._instance=e}init(){var e,t;w((e=this._instance)==null?void 0:e._addCaptureHook)||(this.Xl=(t=this._instance)==null?void 0:t._addCaptureHook((i,r)=>{this.on(i,r)}))}dispose(){var e;(e=this.Xl)==null||e.call(this),this.Xl=void 0,this.Gl=new hi}register(e){var t,i;if(!w((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach(n=>{var a;this.Wl.add(n),(a=n.steps)==null||a.forEach(o=>{this.Vl.add((o==null?void 0:o.event)||"")})}),(i=this._instance)!=null&&i.autocapture)){var r=new Set;this.Wl.forEach(n=>{var a;(a=n.steps)==null||a.forEach(o=>{o!=null&&o.selector&&r.add(o.selector)})}),this._instance.autocapture.setElementSelectors(r)}}replace(e){this.Wl.clear(),this.Vl.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Vl.has(e)||this.Vl.has(t.event))&&this.Wl.forEach(i=>{this.tu(t,i)&&this.Gl.emit("actionCaptured",i.name)})}eu(e){this.onAction("actionCaptured",t=>e(t))}tu(e,t){if((t==null?void 0:t.steps)==null)return!1;for(var i of t.steps)if(this.Zl(e,i))return!0;return!1}onAction(e,t){return this.Gl.on(e,t)}Jl(e,t){if(t!=null&&t.url){var i,r=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!r||typeof r!="string"||!Pt(r,t.url,t.url_matching||"contains"))return!1}return!0}Kl(e,t){return!!this.iu(e,t)&&!!this.ru(e,t)&&!!this.nu(e,t)}iu(e,t){var i;if(t==null||!t.href)return!0;var r=this.su(e);if(r.length>0)return r.some(o=>Pt(o.href,t.href,t.href_matching||"exact"));var n,a=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!a&&Pt((n=a.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}ru(e,t){var i;if(t==null||!t.text)return!0;var r=this.su(e);if(r.length>0)return r.some(h=>Pt(h.text,t.text,t.text_matching||"exact")||Pt(h.$el_text,t.text,t.text_matching||"exact"));var n,a,o,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=function(h){for(var u,c=[],v=/(?::|")text="(.*?)"/g;!L(u=v.exec(h));)c.includes(u[1])||c.push(u[1]);return c}(l),a=t.text,o=t.text_matching||"exact",n.some(h=>Pt(h,a,o)))}nu(e,t){var i,r;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}su(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e==null?void 0:e.properties.$elements}Yl(e,t){return t==null||!t.properties||t.properties.length===0||Yo(t.properties.reduce((i,r)=>{var n=A(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return i[r.key]={values:n,operator:r.operator||"exact"},i},{}),e==null?void 0:e.properties)}}class wh{constructor(e){var t;this.au=[],this._instance=e,this.ou=new Map,this.lu=new Map,this.uu=new Map,this.hu=(t=this._instance)==null||t.onSessionId==null?void 0:t.onSessionId(i=>this.du(i))}vu(e){return!1}cu(){return null}fu(e){}pu(){}gu(e,t){return!!e&&Yo(e.propertyFilters,t==null?void 0:t.properties)}mu(e,t){var i=new Map;return e.forEach(r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEac
2h(a=>{if(a!=null&&a.name){var o=i.get(a.name)||[];o.push(r.id),i.set(a.name,o)}})}),i}yu(e,t,i){var r=(i===Yt.Activation?this.ou:this.lu).get(e),n=[];return this.bu(a=>{n=a.filter(o=>r==null?void 0:r.includes(o.id))}),n.filter(a=>{var o,l=(o=a.conditions)==null||(o=o[i])==null||(o=o.values)==null?void 0:o.find(h=>h.name===e);return this.gu(l,t)})}register(e){this._u(e,!1)}replace(e){this._u(e,!0)}_u(e,t){var i;w((i=this._instance)==null?void 0:i._addCaptureHook)||(this.wu(e,t),this.ku(e,t))}ku(e,t){var i=e.filter(a=>{var o;return(o=a.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length});if(t&&this.uu.clear(),i.length!==0){this.Su||(this.Su=new bh(this._instance),this.Su.init(),this.Su.eu(a=>this.onAction(a)));var r=[];i.forEach(a=>{var o;(o=a.conditions)==null||(o=o.actions)==null||o.values.forEach(l=>{if(r.push(l),l.name){var h,u=(h=this.uu.get(l.name))!==null&&h!==void 0?h:[];u.includes(a.id)||u.push(a.id),this.uu.set(l.name,u)}})}),t?this.Su.replace(r):this.Su.register(r)}else{var n;t&&((n=this.Su)==null||n.replace([]))}}xu(e,t){t.forEach((i,r)=>{var n,a=(n=e.get(r))!==null&&n!==void 0?n:[];i.forEach(o=>{a.includes(o)||a.push(o)}),e.set(r,a)})}wu(e,t){var i,r,n=e.filter(h=>{var u,c;return((u=h.conditions)==null?void 0:u.events)&&((c=h.conditions)==null||(c=c.events)==null||(c=c.values)==null?void 0:c.length)>0}),a=e.filter(h=>{var u,c;return((u=h.conditions)==null?void 0:u.cancelEvents)&&((c=h.conditions)==null||(c=c.cancelEvents)==null||(c=c.values)==null?void 0:c.length)>0}),o=this.mu(e,Yt.Activation),l=this.mu(e,Yt.Cancellation);t?(this.ou=o,this.lu=l):(this.xu(this.ou,o),this.xu(this.lu,l)),(n.length!==0||a.length!==0)&&((i=this.Xl)!==null&&i!==void 0||(this.Xl=(r=this._instance)==null?void 0:r._addCaptureHook((h,u)=>{this.onEvent(h,u)})))}onEvent(e,t){var i,r,n=this.Cu(),a=(t==null||(i=t.properties)==null?void 0:i.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var o=this.Tu(e,a);if(o==="consume")return n.info("event consumed activated item, removing it",{event:e,itemId:a}),void this.Mu([a]);if(o==="persist")return n.info("shown item promoted to persisted activation",{event:e,itemId:a}),this.Eu(a),void this.Iu([a])}if(this.lu.has(e)){var l=this.yu(e,t,Yt.Cancellation);l.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:l.map(u=>u.id)}),this.Mu(l.map(u=>u.id)),l.forEach(u=>this.Ru(u.id)))}if(this.ou.has(e)){n.info("event name matched",{event:e,eventPayload:t,items:this.ou.get(e)});var h=this.yu(e,t,Yt.Activation);this.Pu(h.map(u=>u.id))}}onAction(e){this.uu.has(e)&&this.Pu(this.uu.get(e)||[])}Pu(e){var t;if(e.length!==0){var i=!((t=this._instance)==null||t.get_session_id==null||!t.get_session_id()),r=[];for(var n of e)i&&this.vu(n)?this.Eu(n)&&this.Au(n):r.push(n);r.length>0&&(this.au=[...new Set([...this.au,...r])]),this.Cu().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Eu(e){this.au=this.au.filter(i=>i!==e);var t=this.Fu();return!t.includes(e)&&(this.Ou([...t,e]),this.Lu(),!0)}Mu(e){var t=new Set(e);this.au=this.au.filter(n=>!t.has(n));var i=this.$u(),r=i.filter(n=>!t.has(n));r.length!==i.length&&(this.Ou(r),r.length===0&&this.Du()),this.Iu(e)}Nu(){var e,t=this.cu();if(!t)return{};var i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i&&typeof i=="object"?i:{}}Au(e){if(this.cu()){var t=this.Nu();this.fu(y({},t,{[e]:Date.now()}))}}Iu(e){if(this.cu()){var t=this.Nu(),i={},r=!1;for(var n of Object.entries(t)){var a=n[0],o=n[1];e.includes(a)?r=!0:i[a]=o}r&&(Le(i)?this.pu():this.fu(i))}}qu(){this.cu()&&this.pu()}getActivationTimestamp(e){if(this.Fu().includes(e)){var t=this.Nu()[e];return le(t)?t:void 0}}$u(){var e,t=this.ju();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}Fu(){var e,t,i=this.$u();if(i.length===0)return[];var r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.Bu()],n=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();return n&&r===n?i:[]}Lu(){var e,t=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();t&&this.Hu(t)}Du(){this.Uu()}du(e){var t,i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Bu()];if(i&&i!==e){var r=this.$u(),n=this.Nu();r.length>0&&(this.Ou([]),r.filter(a=>
2le(n[a])).forEach(a=>this.Ru(a))),this.Du(),this.qu()}}getActivatedIds(){return[...new Set([...this.Fu(),...this.au])].filter(e=>!this.zu(e))}dispose(){var e,t,i;(e=this.hu)==null||e.call(this),this.hu=void 0,(t=this.Xl)==null||t.call(this),this.Xl=void 0,(i=this.Su)==null||i.dispose(),this.Su=void 0}reset(){this.au=[],this.$u().length>0&&this.Ou([]),this.Du(),this.qu()}getEventToItemsMap(){return this.ou}Wu(){return this.Su}}class xh extends wh{constructor(e){super(e)}ju(){return dr}Bu(){return As}cu(){return Ls}fu(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Ls]:e})}pu(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Ls)}vu(e){var t,i;this.bu(n=>{i=n.find(a=>a.id===e)});var r=(t=i)==null||(t=t.appearance)==null?void 0:t.surveyPopupDelaySeconds;return le(r)&&r>0}Vu(){return Ze.SHOWN}bu(e){var t;(t=this._instance)==null||t.getSurveys(e)}Ru(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Cu(){return z}Ou(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[dr]:e})}Hu(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[As]:e})}Uu(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(As)}zu(){return!1}Tu(e,t){var i;this.bu(n=>{i=n.find(a=>a.id===t)});var r=!i||function(n){var a;return Qo(n)&&!((a=n.conditions)==null||(a=a.events)==null||!a.repeatedActivation)||n.schedule==="always"}(i);return r?e===Ze.SHOWN?"consume":"ignore":e===Ze.SHOWN?"persist":e===Ze.DISMISSED||e===Ze.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class kh{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);var t={};for(var i of e){var r=this._instance.get_property(i);w(r)||(t[i]=r)}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)}}class Eh{constructor(e){this._instance=e}get(){var e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var e=C==null?void 0:C.__PosthogExtensions__;if(e){var t=e.generateSurveys,i=e.loadExternalDependency;return{generateSurveys:t?r=>t(this._instance,r):void 0,loadExternalDependency:i?r=>i(this._instance,"surveys",r):void 0}}}createEventReceiver(){return new xh(this._instance)}}var Sh=_!=null&&_.location?oi(_.location.hash,"__posthog")||oi(location.hash,"state"):null,ra="_postHogToolbarParams",na=ee("[Toolbar]"),aa=ee("[FeatureFlags]");class Ih{constructor(e,t){t===void 0&&(t=!1),this.Gu=!1,this.update(e,t)}update(e,t){this.Zu=((i,r)=>{var n,a,o,l;return{bootstrap:{featureFlags:(n=i.bootstrap)==null?void 0:n.featureFlags,featureFlagPayloads:(a=i.bootstrap)==null?void 0:a.featureFlagPayloads},remoteRequestsDisabled:r,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,requestTimeoutMs:i.feature_flag_request_timeout_ms,compression:i.disable_compression?"none":"base64",evaluationContexts:(o=(l=i.evaluation_contexts)!==null&&l!==void 0?l:i.evaluation_environments)!==null&&o!==void 0?o:[],flagKeys:A(i.flag_keys)?i.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.Gu||(aa.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Gu=!0),w(e.flag_keys)||A(e.flag_keys)||aa.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.Zu}}var oa=ee("[FeatureFlags]"),ut=ee("[FeatureFlags]",{debugEnabled:!0}),Gi=`" failed. Feature flags didn't load in time.`,la="connection_error",ua=s=>{for(var e={},t=0;s.length>t;t++)e[s[t]]=!0;return e},ha=s=>{var e={};for(var t of Ds(s||{})){var i=t[1];i&&(e[t[0]]=i)}return e},je=ee("[Error tracking]"),Ph=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],ca="Refusing to render web experiment since the viewer is a likely bot",Fh={icontains:(s,e)=>e.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>e.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>ci(e,s),not_regex:(s,e)=>!ci(e,s),exact:(s,e)=>e===s,is_not:(s,e)=>e!==s};class fe{get qi(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments(r=>{fe.Qu("retrieved web experiments from the server"),t.Ju=new Map,r.forEach(n=>
2{if(n.feature_flag_key){var a;t.Ju&&(fe.Qu("setting flag key ",n.feature_flag_key," to web experiment ",n),(a=t.Ju)==null||a.set(n.feature_flag_key,n));var o=t._instance.getFeatureFlag(n.feature_flag_key);H(o)&&n.variants[o]&&t.Ku(n.name,o,n.variants[o].transforms)}else if(n.variants)for(var l in n.variants){var h=n.variants[l];fe.Yu(h,t._instance)&&t.Ku(n.name,l,h.transforms)}})},i)},this._instance=e,this._instance.onFeatureFlags(i=>{this.onFeatureFlags(i)})}initialize(){}onFeatureFlags(e){if(this._is_bot())fe.Qu(ca);else if(!this.qi.disable_web_experiments){if(L(this.Ju))return this.Ju=new Map,this.loadIfEnabled(),void this.previewWebExperiment();fe.Qu("applying feature flags",e),e.forEach(t=>{var i;if(this.Ju&&(i=this.Ju)!=null&&i.has(t)){var r,n=this._instance.getFeatureFlag(t),a=(r=this.Ju)==null?void 0:r.get(t);n&&a!=null&&a.variants[n]&&this.Ku(a.name,n,a.variants[n].transforms)}})}}previewWebExperiment(){var e=fe.getWindowLocation();if(e!=null&&e.search){var t=Ht(e==null?void 0:e.search,"__experiment_id"),i=Ht(e==null?void 0:e.search,"__experiment_variant");t&&i&&(fe.Qu("previewing web experiments "+t+" && "+i),this.getWebExperiments(r=>{this.Xu(parseInt(t),i,r)},!1,!0))}}loadIfEnabled(){this.qi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.qi.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.qi.token),method:"GET",timestampMode:"query",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Xu(e,t,i){var r=i.filter(n=>n.id===e);r&&r.length>0&&(fe.Qu("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ku(r[0].name,t,r[0].variants[t].transforms))}static Yu(e,t){return!L(e.conditions)&&fe.th(e,t)&&fe.eh(e)}static th(e,t){var i;if(L(e.conditions)||L((i=e.conditions)==null?void 0:i.url))return!0;var r=fe.getWindowLocation();if(r){var n,a,o,l=co(t,r.href);return(n=e.conditions)==null||!n.url||Fh[(a=(o=e.conditions)==null?void 0:o.urlMatchType)!==null&&a!==void 0?a:"icontains"](e.conditions.url,l)}return!1}
2static getWindowLocation(){return _==null?void 0:_.location}static eh(e){var t;if(L(e.conditions)||L((t=e.conditions)==null?void 0:t.utm))return!0;var i=Fo();if(i.utm_source){var r,n,a,o,l,h,u,c,v=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==i.utm_campaign,f=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_source)==i.utm_source,d=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_medium)==i.utm_medium,g=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_term)==i.utm_term;return v&&d&&g&&f}return!1}static Qu(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];S.info("[WebExperiments] "+e,i)}Ku(e,t,i){this._is_bot()?fe.Qu(ca):t!=="control"?i.forEach(r=>{if(r.selector){var n;fe.Qu("applying transform of variant "+t+" for experiment "+e+" ",r);var a=(n=document)==null?void 0:n.querySelectorAll(r.selector);a==null||a.forEach(o=>{var l=o;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)})}}):fe.Qu("Control variants leave the page unmodified.")}_is_bot(){return be&&this._instance?Wo(be,this.qi.custom_blocked_useragents):void 0}}var Re=ee("[Conversations]"),ht="Conversations not available yet.",da="console",rl="__posthogHandledLogsRequestError",Wi=(s,e)=>{var t=s instanceof Error?s:new Error(e);return t[rl]=!0,t},va=s=>!!s&&typeof s=="object"&&s[rl]===!0,fi={featureFlags:class{constructor(s){this.name="featureFlags",this.ih=!1,this.featureFlagEventHandlers=[],this.I=oa,this.rh={},this.nh={},this.sh=[],this.ah=!1,this.oh=!1,this.lh=0,this.uh=!1,this.hh=!1,this.dh=!1,this.fh=!1,this.ph=0,this.Tt=()=>{var e=this.gh();this.ph=0,e&&this.reloadFeatureFlags()},"get"in s?this.ts=s:(this.mh=new Ih(s.config,s.ma()),this.ts=this.mh)}updateConfig(s,e){var t;(t=this.mh)==null||t.update(s,e)}setup(s){return this.Fl=s,this.I=s.logger.createLogger("[FeatureFlags]"),il(s.kv.initialize(),()=>{this.Fl===s&&(this.Fl=void 0,this.ns=s,this.yh(s))})}yh(s){if(this.ns===s)return _&&Z(_,"online",this.Tt),this.bh=s.registerDynamicEventProperties(()=>this._h()?this.rh:this.nh),this.wh(),this.initialize()}destroy(){_==null||_.removeEventListener("online",this.Tt)}dispose(){var s;this.lh++,this.hh=!1,this.Fl=void 0,this.ns&&(this.kh(),(s=this.bh)==null||s.dispose(),this.bh=void 0,this.sh=[],_==null||_.removeEventListener("online",this.Tt),this.ns=void 0)}get qi(){return this.ts.get()}Sh(s){var e;return(e=this.ns)==null?void 0:e.kv.get(s)}Nr(s){this.xh(()=>{var e;return(e=this.ns)==null?void 0:e.kv.set(s)})}qr(s){this.xh(()=>{var e;return(e=this.ns)==null?void 0:e.kv.remove(s)})}xh(s){try{s()}catch(e){this.I.error("Failed to update feature flag persistence",e)}}wh(){var s={};for(var e of[gt,_t,At,Be]){var t=this.Sh(e);w(t)||(s[e]=t)}this.rh=s;var i=y({},s),r=this.Sh(Ye);if(r)for(var n of Object.entries(r))i["$feature/"+n[0]]=n[1];this.nh=i}_h(){var s=this.qi.cacheTtlMs;if(!s||0>=s)return!1;var e=this.Sh(yt);return typeof e!="number"||Date.now()-e>s}Ch(){return!!this._h()&&(this.fh||this.oh||(this.fh=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Th(){var s=this.qi.evaluationContexts;return s!=null&&s.length?s.filter(e=>{var t=e&&typeof e=="string"&&e.trim().length>0;return t||this.I.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}Mh(){var s=this.qi.flagKeys;if(!w(s))return s.filter(e=>{var t=e&&typeof e=="string"&&e.trim().length>0;return t||this.I.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var s,e,t=this.qi,i=(s=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&s!==void 0?s:{};if(Object.keys(i).length){var r,n,a=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},o=Object.keys(i).filter(h=>!!i[h]).reduce((h,u)=>(h[u]=i[u]||!1,h),{}),l=Object.keys(a).filter(h=>o[h]).reduce((h,u)=>(h[u]=a[u],h),{});return this.Eh({featureFlags:o,featureFlagPayloads:l})}}updateFlags(s,e,t){var i,r,n=t!=null&&t.merge&&(i=this.Sh(Ye))!==null&&i!==void 0?i:{},a=t!=null&&t.merge&&(r=this.Sh(_t))!==null&&r!==void 0?r:{},o=y({},n,s),l=y({},a,e),h={};for(var u of Object.entries(o)){var c=u[0],v=u[1];h[c]={key:c,enabled:en(v),variant:tn(v),reason:void 0,metadata:w(l==null?void 0:l[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}}}this.Eh({flags:h})}get hasLoadedFlags(){return this.ah}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var s=this.Sh(fs),e=this.Sh(Be),t=this.Sh(dt);if(!t&&!e)return s||{};var i=W({},s||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var a,o,l=i[n],h=e==null?void 0:e[n],u=w(h)?(a=l==null?void 0:l.enabled)!==null&&a!==void 0&&a:!!h,c=w(h)?l==null?void 0:l.variant:typeof h=="string"?h:void 0,v=t==null?void 0:t[n],f=y({},l,{enabled:u,variant:u?c??(l==null?void 0:l.variant):void 0});u!==(l==null?void 0:l.enabled)&&(f.original_enabled=l==null?void 0:l.enabled),c!==(l==null?void 0:l.variant)&&(f.original_variant=l==null?void 0:l.variant),v&&(f.metadata=y({},l==null?void 0:l.metadata,{payload:v,original_payload:l==null||(o=l.metadata)==null?void 0:o.payload})),i[n]=f}return this.ih||(this.I.warn(" Overriding feature flag details!",{flagDetails:s,overriddenPayloads:t,finalDetails:i}
2),this.ih=!0),i}getAllFeatureFlags(){var s=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(s).map(t=>{var i=s[t];return{key:t,enabled:en(i),variant:tn(i),payload:Zr(e[t])}})}getFlagVariants(){var s=this.Sh(Ye),e=this.Sh(Be);if(!e)return s||{};for(var t=W({},s||{}),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.ih||(this.I.warn(" Overriding feature flags!",{enabledFlags:s,overriddenFlags:e,finalFlags:t}),this.ih=!0),t}getFlagPayloads(){var s=this.Sh(_t),e=this.Sh(dt);if(!e)return s||{};for(var t=W({},s||{}),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.ih||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:s,overriddenPayloads:e,finalPayloads:t}),this.ih=!0),t}reloadFeatureFlags(){this.uh||this.qi.featureFlagsDisabled||this.gh()||this.Ih||(this.sh.slice().forEach(s=>{try{s()}catch(e){this.I.error("Error while running feature flags reloading callback",e)}}),this.Ih=setTimeout(()=>{this.Rh()},5))}kh(){clearTimeout(this.Ih),this.Ih=void 0}onReloading(s){return this.sh.push(s),()=>{this.sh=this.sh.filter(e=>e!==s)}}ensureFlagsLoaded(){this.ah||this.oh||this.Ih||this.reloadFeatureFlags()}setAnonymousDistinctId(s){this.$anon_distinct_id=s}setReloadingPaused(s){this.uh=s}resetFlagCallReported(){this.qr(Qe)}Rh(s){this.kh();var e=this.ns;if(e&&!this.qi.remoteRequestsDisabled&&!this.gh())if(this.oh)this.hh=!0;else{var t={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:y({},e.initialPersonProperties,this.Sh(Ae)||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Sh(Ve),timezone:Mo()};w(e.deviceId)||(t.$device_id=e.deviceId),(s!=null&&s.disableFlags||this.qi.featureFlagsDisabled)&&(t.disable_flags=!0);var i=this.Th();i.length&&(t.evaluation_contexts=i);var r=this.Mh();w(r)||(t.flag_keys=r);var n=this.qi.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),o=this.lh;this.oh=!0;var l=()=>{this.hh&&(this.hh=!1,this.Rh())},h=u=>{this.oh=!1,o===this.lh&&(this.Nr({[Lt]:[la]}),this.I.error("Feature flag request failed",u)),l()};try{e.sendRequest(a,{target:"flags",method:"POST",body:t,compression:this.qi.compression==="base64"?ye.Base64:void 0,sentAt:"body",timeoutMs:this.qi.requestTimeoutMs}).then(u=>{var c,v,f=(c=u.json)!==null&&c!==void 0?c:{},d=u.statusCode!==200;if(this.oh=!1,o===this.lh){if(this.Ph(u.statusCode),d||this.hh||(this.$anon_distinct_id=void 0),!t.disable_flags||this.hh){this.dh=!d;var g=[];u.error?g.push(u.error instanceof Error&&u.error.name==="AbortError"?"timeout":u.error instanceof Error?la:"unknown_error"):u.statusCode!==200&&g.push("api_error_"+u.statusCode),f.errorsWhileComputingFlags&&g.push("errors_while_computing_flags");var p=!((v=f.quotaLimited)==null||!v.includes("feature_flags"));p&&g.push("quota_limited"),this.Nr({[Lt]:g}),p?this.I.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."):t.disable_flags||this.Eh(f,d,{partialResponse:n}),l()}}else l()}).catch(h)}catch(u){h(u)}}}gh(){return Io(this.ph,3)}Ph(s){this.ph=Po(s,this.ph,3,()=>this.I.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(s,e){var t;if(e===void 0&&(e={}),!e.fresh||this.dh)if(this.ah||this.getFlags()&&this.getFlags().length>0){if(!this.Ch()){var i=this.getFeatureFlagResult(s,e);return(t=i==null?void 0:i.variant)!==null&&t!==void 0?t:i==null?void 0:i.enabled}}else this.I.warn('getFeatureFlag for key "'+s+Gi)}getFeatureFlagDetails(s){return this.getFlagsWithDetails()[s]}getFeatureFlagPayload(s){var e=this.getFeatureFlagResult(s,{send_event:!1});return e==null?void 0:e.payload}getFeatureFlagResult(s,e){if(e===void 0&&(e={}),!e.fresh||this.dh)if(this.ah||this.getFlags()&&this.getFlags().length>0){if(!this.Ch()){var t,i=this.getFlagVariants(),r=s in i,n=i[s],a=this.getFlagPayloads()[s],o=String(n),l=this.Sh(At)||void 0,h=this.Sh(yt)||void 0,u=this.Sh(Qe)||{};if(this.qi.deduplicateCallsPerSession){var c,v=(c=this.ns)==null?void 0:c.session.sessionId,f=this.Sh(ns);v&&v!==f&&(u={},t=v)}if(e.send_event||!("send_event"in e))if(s in u&&u[s].includes(o))t&&this.Nr({[Qe]:u,[ns]:t});else{var d,g,p,m,b,E,I,k,$,N,P,T;A(u[s])?u[s].push(o):u[s]=[o],this.Nr(y({[Qe]:u},t?{[ns]:t}:{}));var F=this.getFeatureFlagDetails(s),R=[...(d=this.Sh(Lt))!==null&&d!==void 0?d:[]];w(n)&&R.push("flag_missing");var O={$feature_flag:s,$feature_flag_response:n,$feature_flag_payload:a??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:(g=(p=this.qi.bootstrap)==null||(p=p.featureFlags)==null?void 0:p[s])!==null&&g!==void 0?g:null,$feature_flag_bootstrapped_payload:(m=(b=this.qi.bootstrap)==null||(b=b.featureFlagPayloads)==null?void 0:b[s])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.dh};w(F==null||(E=F.metadata)==null?void 0:E.has_experiment)||(O.$feature_flag_has_experiment=F.metadata.has_experiment),w(F==null||(I=F.metadata)==null?void 0:I.version)||(O.$feature_flag_version=F.metadata.version);var M,j=(k=F==null||($=F.reason)==null?void 0:$.description)!==null&&k!==void 0?k:F==null||(N=F.reason)==null?void 0:N.co
2de;j&&(O.$feature_flag_reason=j),F!=null&&(P=F.metadata)!=null&&P.id&&(O.$feature_flag_id=F.metadata.id),w(F==null?void 0:F.original_variant)&&w(F==null?void 0:F.original_enabled)||(O.$feature_flag_original_response=w(F.original_variant)?F.original_enabled:F.original_variant),F!=null&&(T=F.metadata)!=null&&T.original_payload&&(O.$feature_flag_original_payload=F==null||(M=F.metadata)==null?void 0:M.original_payload),R.length&&(O.$feature_flag_error=R.join(",")),this.Ah(O)}else t&&this.Nr({[Qe]:u,[ns]:t});if(r)return{key:s,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:Zr(a)}}}else this.I.warn('getFeatureFlagResult for key "'+s+Gi)}Ah(s){try{var e;(e=this.ns)==null||e.capture("$feature_flag_called",s).catch(t=>{this.I.error("Failed to capture feature flag call",t)})}catch(t){this.I.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(s,e){this.Fh(s,e)}Fh(s,e){var t=this;return Q(function*(){var i=t.ns;if(i){var r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=t.Th();n.length&&(r.evaluation_contexts=n);var a,o=t.Mh();w(o)||(r.flag_keys=o);try{var l,h=(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:t.qi.compression==="base64"?ye.Base64:void 0,sentAt:"body",timeoutMs:t.qi.requestTimeoutMs})).json)==null?void 0:l.featureFlagPayloads;a=(h==null?void 0:h[s])||void 0}catch(u){return void t.I.error("Remote config feature flag request failed",u)}try{e(a)}catch(u){t.I.error("Remote config feature flag callback failed",u)}}})()}isFeatureEnabled(s,e){if(e===void 0&&(e={}),e.fresh&&!this.dh)return e.defaultValue;if(!(this.ah||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+s+Gi),e.defaultValue;var t=this.getFeatureFlag(s,e);return w(t)?e.defaultValue:!!t}addFeatureFlagsHandler(s){this.featureFlagEventHandlers.push(s)}removeFeatureFlagsHandler(s){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==s)}receivedFeatureFlags(s,e,t){this.Eh(s,e,t)}Eh(s,e,t){if(this.ns){this.ah=!0;var i=function(r,n,a,o,l,h){n===void 0&&(n={}),a===void 0&&(a={}),o===void 0&&(o={}),h===void 0&&(h=oa);var u=(($,N)=>{var P=$.flags;return P?y({},$,{featureFlags:Object.fromEntries(Object.keys(P).map(T=>{var F;return[T,(F=P[T].variant)!==null&&F!==void 0?F:P[T].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(P).filter(T=>P[T].enabled).filter(T=>{var F;return(F=P[T].metadata)==null?void 0:F.payload}).map(T=>{var F;return[T,(F=P[T].metadata)==null?void 0:F.payload]}))}):($.featureFlags&&N.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),$)})(r,h),c=u.flags,v=u.featureFlags,f=u.featureFlagPayloads;if(v){var d=r.requestId,g=r.evaluatedAt;if(A(v)){h.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(v)for(var m=0;v.length>m;m++)p[v[m]]=!0;return{[gt]:v,[Ye]:p,[Ks]:!1}}var b=v,E=f,I=c;if(l!=null&&l.partialResponse)b=y({},n,b),E=y({},a,E),I=y({},o,I);else if(r.errorsWhileComputingFlags)if(c){var k=new Set(Object.keys(c).filter($=>{var N;return!((N=c[$])!=null&&N.failed)}));b=y({},n,Object.fromEntries(Object.entries(b).filter($=>k.has($[0])))),E=y({},a,Object.fromEntries(Object.entries(E||{}).filter($=>k.has($[0])))),I=y({},o,Object.fromEntries(Object.entries(I||{}).filter($=>k.has($[0]))))}else b=y({},n,b),E=y({},a,E),I=y({},o,I);return y({[gt]:Object.keys(ha(b)),[Ye]:b||{},[_t]:E||{},[fs]:I||{},[Ks]:r.minimalFlagCalledEvents===!0},d?{[At]:d}:{},g?{[yt]:g}:{})}}(s,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),t,this.I);i&&this.Nr(i),e||(this.fh=!1),this.Oh(e)}}override(s,e){e===void 0&&(e=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:s,suppressWarning:e})}overrideFeatureFlags(s){this.Lh(s)}Lh(s){if(this.ns){if(s===!1)return this.qr([Be,dt]),this.Oh(),void ut.info("All overrides cleared");if(A(s))return this.Nr({[Be]:ua(s)}),this.Oh(),void ut.info("Flag overrides set",{flags:s});if(s&&typeof s=="object"&&("flags"in s||"payloads"in s)){var e,t=s;this.ih=!!((e=t.suppressWarning)!==null&&e!==void 0&&e);var i={},r=t.flags,n=t.payloads;
2return r&&(i[Be]=A(r)?ua(r):r),n&&(i[dt]=n),Object.keys(i).length&&this.Nr(i),r===!1&&n===!1?this.qr([Be,dt]):r===!1?this.qr(Be):n===!1&&this.qr(dt),this.Oh(),r===!1?ut.info("Flag overrides cleared"):r&&ut.info("Flag overrides set",{flags:r}),void(n===!1?ut.info("Payload overrides cleared"):n&&ut.info("Payload overrides set",{payloads:n}))}if(s&&typeof s=="object")return this.Nr({[Be]:s}),this.Oh(),void ut.info("Flag overrides set",{flags:s});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:s})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(s){if(this.addFeatureFlagsHandler(s),this.ah){var e=this.$h(),t=e.flags,i=e.flagVariants;try{s(t,i)}catch(r){this.I.error("Error while running feature flags callback",r)}}return()=>this.removeFeatureFlagsHandler(s)}updateEarlyAccessFeatureEnrollment(s,e,t){var i=(this.Sh(qs)||[]).find(l=>l.flagKey===s),r={["$feature_enrollment/"+s]:e},n={$feature_flag:s,$feature_enrollment:e,$set:r};i&&(n.$early_access_feature_name=i.name),t&&(n.$feature_enrollment_stage=t);var a=y({},this.getFlagVariants(),{[s]:e});this.Nr({[gt]:Object.keys(ha(a)),[Ye]:a,[Ae]:y({},this.Sh(Ae)||{},r)}),this.Oh();try{var o;(o=this.ns)==null||o.capture("$feature_enrollment_update",n).catch(l=>{this.I.error("Failed to capture early access feature enrollment",l)})}catch(l){this.I.error("Failed to capture early access feature enrollment",l)}}getEarlyAccessFeatures(s,e,t){e===void 0&&(e=!1);var i=this.Sh(qs);!i||e?this.Dh(s,t):s(i)}Dh(s,e){var t=this;return Q(function*(){var i=t.ns;if(i){var r,n=e?"&"+e.map(o=>"stage="+o).join("&"):"";try{var a=yield i.sendRequest("/api/early_access_features/?token="+i.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;t.Nr({[qs]:r=a.json.earlyAccessFeatures})}catch(o){return void t.I.error("Early access feature request failed",o)}try{s(r)}catch(o){t.I.error("Early access feature callback failed",o)}}})()}$h(){var s=this.getFlags(),e=this.getFlagVariants();return{flags:s.filter(t=>e[t]),flagVariants:Object.keys(e).filter(t=>e[t]).reduce((t,i)=>(t[i]=e[i],t),{})}}Oh(s){this.wh();var e=this.$h(),t=e.flags,i=e.flagVariants;this.featureFlagEventHandlers.forEach(r=>{try{r(t,i,{errorsLoading:s})}catch(n){this.I.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(s,e){e===void 0&&(e=!0),this.Nh(s,e)}Nh(s,e){e===void 0&&(e=!0);var t=this.Sh(Ae)||{},i=(s==null?void 0:s.$set)||(s!=null&&s.$set_once?{}:s),r=s==null?void 0:s.$set_once,n={};if(r)for(var a in r)({}).hasOwnProperty.call(r,a)&&(a in t||(n[a]=r[a]));this.Nr({[Ae]:y({},t,n,i)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=y({},this.Sh(Ae)||{});s.forEach(i=>{delete t[i]}),this.Nr({[Ae]:t}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(s){s===void 0&&(s=!0),this.qr(Ae),s&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Sh(Ve)||{},i=y({},t);for(var r of Object.keys(s))i[r]=y({},t[r],s[r]);this.Nr({[Ve]:i}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(s){if(s){var e=this.Sh(Ve)||{};this.Nr({[Ve]:y({},e,{[s]:{}})})}else this.qr(Ve)}reset(){this.lh++,this.hh=!1,this.rh={},this.nh={},this.ah=!1,this.uh=!1,this.dh=!1,this.$anon_distinct_id=void 0,this.kh(),this.ih=!1,this.ph=0}}},Th={sessionRecording:class{get qi(){return this._instance.config}get za(){return this._instance.persistence}get started(){var s;return!((s=this.qh)==null||!s.isStarted)}get status(){var s,e;return this.jh===ts||this.jh===Rs?this.jh:(s=(e=this.qh)==null?void 0:e.status)!==null&&s!==void 0?s:this.jh}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.jh=ea,this.Bh=void 0,this.Hh=!1,this.kt=(()=>{var e;if(x==null||!x.visibilityState||x.visibilityState==="visible")return!0;var t=_==null||(e=_.performance)==null||e.getEntriesByType==null?void 0:e.getEntriesByType("visibility-state");return!(t!=null&&t.length)||t.some(i=>i.name==="visible")})(),this.It=()=>{var e;(x==null?void 0:x.visibilityState)==="visible"&&(this.kt=!0,(e=this.qh)==null||e.setDocumentWasEverVisible==null||e.setDocumentWasEverVisible(!0))},this._instance=s,!this._instance.sessionManager)throw We.error("started without valid sessionManager"),new Error($r+" started without valid sessionManager. This is a bug.");if(this.qi.cookieless_mode===Ke)throw new Error($r+' cannot be used with cookieless_mode="always"');x!=null&&x.addEventListener&&Z(x,"visibilitychange",this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.Hh=!0,x==null||x.removeEventListener==null||x.removeEventListener("visibilitychange",this.It),this.stopRecording()}get Uh(){var s,e=!((s=this._instance.get_property(ft))==null||!s.enabled),t=!this.qi.disable_session_recording,i=this.qi.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(!(this.Hh||this.Uh&&(e=this.qh)!=null&&e.isStarted)){var t=!w(Object.assign)&&!w(Array.from);this.Uh&&t?(this.zh(s),We.info("starting")):(this.jh=ea,this.stopRecording())}}zh(s){var e,t,i;this.Uh&&(this.jh!==ts&&this.jh!==Rs&&(this.jh=ta),C!=null&&(e=C.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=C.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Wh(s):(i=C.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Vh,r=>{if(r)return this._instance.register_for_session({[_r]:!0}),We.error("could not load recorder",r);this.Wh(s)}))}stopRecording(){var s,e;(s=this.Bh)==null||s.call(this),this.Bh=void 0,(e=this.qh)==null||e.stop()}Gh(){var s,e;(s=this.Bh)==null||s.call(this),this.Bh=void 0,(e=this.qh)==null||e.discard()}Zh(){var s,e;(s=this.za)==null||s.unregister(Br),(e=this.za)==null||e.unregister(Za)}Qh(s,e){if(L(s))return null;var t,i=le(s)?s:parseFloat(s);return typeof(t=i)!="number"||!Number.isFinite(t)||0>t||t>1?(We.warn(e+" must be between 0 and 1. Ignoring invalid value:",s),null):i}Jh(s){if(this.za){var e,t,i=this.za,r=()=>{var n,a=s.sessionRecording===!1?void 0:s.sessionRecording,o=this.Qh((n=this.qi.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Qh(a==null?void 0:a.sampleRate,"remote config sampleRate"),h=o??l;L(h)&&this.Zh();var u=a==null?void 0:a.minimumDurationMilliseconds;i.register({[ft]:y({cache_timestamp:Date.now(),enabled:!!a},a,{networkPayloadCapture:y({capturePerformance:s.capturePerformance},a==null?void 0:a.networkPayloadCapture),canvasRecording:{enabled:a==null?void 0:a.recordCanvas,fps:a==null?void 0:a.canvasFps,quality:a==null?void 0:a.canvasQuality},sampleRate:h,minimumDurationMilliseconds:w(u)?null:u,endpoint:a==null?void 0:a.endpoint,triggerMatchType:a==null?void 0:a.triggerMatchType,masking:a==null?void 0:a.masking,urlTriggers:a==null?void 0:a.urlTriggers,version:a==null?void 0:a.version,triggerGroups:a==null?void 0:a.triggerGroups})})};r(),(e=this.Bh)==null||e.call(this),this.Bh=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(s){var e=s.ok?s.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.Jh(e),void this.Gh()):(this.Jh(e),void this.startIfEnabledOrStop()):(this.jh===ts&&(this.jh=Rs,We.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(s,e){var t;e===void 0&&(e="log"),(t=this.qh)!=null&&t.log?this.qh.log(s,e):We.warn("log called before recorder was ready")}get Vh(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(ft);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Kh(){var s,e=this._instance.get_property(ft);
2if(!e)return!1;try{s=typeof e=="object"?e:JSON.parse(e)}catch(t){return We.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!L(s.cache_timestamp)&&36e5>=Date.now()-s.cache_timestamp}Wh(s){var e,t,i;if(!this.Hh){if((e=C.__PosthogExtensions__)==null||!e.initSessionRecording)return We.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[_r]:!0});var r;if(this.qh||(this.qh=(r=C.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance,this.kt),this.qh._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Kh())return this.jh===Rs||this.jh===ts?void 0:(this.jh=ts,We.info("persisted remote config is stale, requesting fresh config before starting"),void new qo(this._instance).load());this.jh=ta,(t=(i=this.qh).setDocumentWasEverVisible)==null||t.call(i,this.kt),this.qh.start(s)}}onRRwebEmit(s){var e;(e=this.qh)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.qh||(e=this.za)==null||e.register({[to]:!0}),(s=this.qh)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.qh||(e=this.za)==null||e.register({[eo]:!0}),(s=this.qh)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.qh||(t=this.za)==null||t.register({[s==="url"?so:io]:!0}),(e=this.qh)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.qh)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.qh)==null||!t.tryAddCustomEvent(s,e))}}},$h={autocapture:class extends ph{constructor(s){super(new fh(s)),this.instance=s}},historyAutocapture:class{constructor(s){this._instance=s,this.Yh=this.Xh()}initialize(){this.startIfEnabled()}get isEnabled(){var s=this.td();return!!(s.path||s.search||this.ed(s))}startIfEnabled(){this.isEnabled&&(S.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Yh=this.Xh(),this.startIfEnabled()}stop(){this.rd&&this.rd(),this.rd=void 0,this.nd&&this.nd(),this.nd=void 0,S.info("History API monitoring stopped")}monitorHistoryChanges(){_&&_.history&&(this.sd("pushState"),this.sd("replaceState"),this.ad(),this.ed()&&this.od())}sd(s){var e;if(_&&((e=_.history[s])==null||!e.__posthog_wrapped__)){var t=this;(function(i,r,n){try{if(!(r in i))return Kn;var a={next:i[r]},o=n(function(){for(var l=arguments.length,h=new Array(l),u=0;l>u;u++)h[u]=arguments[u];return a.next.apply(this,h)});return ge(o)&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:a}})),i[r]=o,()=>{if(i[r]!==o)for(var l=i[r];ge(l)&&l.__posthog_layer__;){var h=l.__posthog_layer__;if(h.next===o)return void(h.next=a.next);l=h.next}else i[r]=a.next}}catch{return Kn}})(_.history,s,i=>function(r,n,a){i.call(this,r,n,a),t.ld(s)})}}Xh(){var s=_==null?void 0:_.location;if(s!=null&&s.pathname)return{pathname:s.pathname,search:s.search,hash:s.hash}}td(){var s=this._instance.config.capture_pageview;return s==="history_change"?{path:!0}:Y(s)?s:{}}ed(s){return s===void 0&&(s=this.td()),!!s.hash&&!this._instance.config.disable_capture_url_hashes}ud(s){var e=this.td(),t=this.Yh;return!(!t||!(e.path&&s.pathname!==t.pathname||e.search&&s.search!==t.search||this.ed(e)&&s.hash!==t.hash))}ld(s){try{var e=this.Xh();if(!e)return;this.ud(e)&&this._instance.capture(Ft,{navigation_type:s}),this.Yh=e}catch(t){S.error("Error capturing "+s+" pageview",t)}}ad(){if(!this.rd){var s=()=>{this.ld("popstate")};Z(_,"popstate",s),this.rd=()=>{_&&_.removeEventListener("popstate",s)}}}od(){if(!this.nd){var s=()=>{this.ld("hashchange")};Z(_,"hashchange",s),this.nd=()=>{_&&_.removeEventListener("hashchange",s)}}}},heatmaps:class{get qi(){return this.instance.config}constructor(s){var e;this.hd=!1,this.Qn=!1,this.dd=null,this.instance=s,this.hd=!((e=this.instance.persistence)==null||!e.props[nr]),this.rageclicks=new sl(s.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var s=5e3;return Y(this.qi.capture_heatmaps)&&this.qi.capture_heatmaps.flush_interval_milliseconds&&(s=this.qi.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return L(this.qi.capture_heatmaps)?L(this.qi.enable_heatmaps)?this.hd:this.qi.enable_heatmaps:this.qi.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Qn)return;_h.info("starting..."),this.vd(),this.It()}else{var s;clearInterval((s=this.dd)!==null&&s!==void 0?s:void 0),this.fd(),this.getAndClearBuffer()}}onRemoteConfig(s){if(s.ok){var e=s.config;if("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[nr]:t}),this.hd=t,this.startIfEnabled()}}}getAndClearBuffer(){var s=this.ft;return this.ft=void 0,s}pd(s){Vi(s.originalEvent)&&this.ki(s.originalEvent,"deadclick")}It(){this.dd&&clearInterval(this.dd),this.dd=(x==null?void 0:x.visibilityState)==="visible"?setInterval(this.Oa.bind(this),this.flushIntervalMilliseconds):null}vd(){_&&x&&(this.gd=this.Oa.bind(this),Z(_,ii,this.gd),this.md=s=>this.ki(s||(_==null?void 0:_.event)),Z(x,"click",this.md,{capture:!0}),this.yd=s=>this.bd(s||(_==null?void 0:_.event)),Z(x,"mousemove",this.yd,{capture:!0}),this._d=new Rn(this.instance,Pu,this.pd.bind(this)),this._d.startIfEnabledOrStop(),this.wd=this.It.bind(this),Z(x,si,this.wd),this.Qn=!0)}fd(){var s;_&&x&&(this.gd&&_.removeEventListener(ii,this.gd),this.md&&x.removeEventListener("click",this.md,{capture:!0}),this.yd&&x.removeEventListener("mousemove",this.yd,{capture:!0}),this.wd&&x.removeEventListener(si,this.wd),clearTimeout(this.kd),(s=this._d)==null||s.stop(),this.Qn=!1)}Sd(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=function(a,o,l){for(var h=a;h&&nt(h)&&!Te(h,"body");){if(h===l)return!1;var u=void 0;try{var c,v,f;u=(c=(v=(f=h.ownerDocument)==null?void 0:f.defaultView)!==null&&v!==void 0?v:_)==null?void 0:c.getComputedStyle(h).position}catch{return!1}if(q(o,u))return!0;h=mo(h)}return!1}(br(s),["fixed","sticky"],r);return{x:s.clientX+(n?0:i),y:s.clientY+(n?0:t),target_fixed:n,type:e}}ki(s,e){var t;if(e===void 0&&(e="click"),!kn(s.target)&&Vi(s)){var i=this.Sd(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&bo(br(s),this.instance.config.rageclick)&&this.Nn(y({},i,{type:"rageclick"})),this.Nn(i)}}bd(s){!kn(s.target)&&Vi(s)&&(clearTimeout(this.kd),this.kd=setTimeout(()=>{this.Nn(this.Sd(s,"mousemove"))},500))}Nn(s){if(_){var e=this.qi.disable_capture_url_hashes?rt(_.location.href):_.location.href,t=this.qi.custom_personal_data_properties,i=this.qi.mask_personal_data_properties?[...zt,...t||[]]:[],r=_s(e,i,ms);this.ft=this.ft||{},this.ft[r]||(this.ft[r]=[]),this.ft[r].push(s)}}Oa(){this.ft&&!Le(this.ft)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Rn,webVitalsAutocapture:class{constructor(s){var e;this.hd=!1,this.Qn=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.xd=()=>{clearTimeout(this.Cd),this.Cd=void 0,this.ft.metrics.length!==0&&(this._instance.capture("$web_vitals",y({$current_url:this.ft.url},this.ft.metrics.reduce((t,i)=>y({},t,{["$web_vitals_"+i.name+"_event"]:y({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Td=t=>{var i;if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},L(t==null?void 0:t.name)||L(t==null?void 0:t.value))lt.error("Invalid metric received",t);
2else{var r=typeof t.navigationURL=="string"?t.navigationURL:void 0,n=this.Md(r);if(!w(n)){var a=le(t.navigationId)||typeof t.navigationId=="string"?"navigation:"+t.navigationId:"url:"+n;if(!this.Ed||this.Ed>t.value){this.ft.navigationKey!==a&&(this.xd(),this.Cd=setTimeout(this.xd,this.flushToCaptureTimeoutMs)),w(this.ft.navigationKey)&&(this.ft.navigationKey=a,this.ft.url=n),this.ft.firstMetricTimestamp=w(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var o=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0),l=y({},t,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});w(o)||(l.$session_id=o.sessionId,l.$window_id=o.windowId),this.ft.metrics.push(l),this.ft.metrics.length===this.allowedMetrics.length&&this.xd()}else lt.error("Ignoring metric with value >= "+this.Ed,t)}}},this.Id=()=>{if(!this.Qn){var t,i,r,n,a=C.__PosthogExtensions__,o=a==null?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(o==null?void 0:o[this.Rd])||(this.Rd==="web-vitals"&&w(o)?a==null?void 0:a.postHogWebVitalsCallbacks:void 0);if(w(l)||(t=l.onLCP,i=l.onCLS,r=l.onFCP,n=l.onINP),t&&i&&r&&n){var h={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.Td.bind(this),h),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Td.bind(this),h),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Td.bind(this),h),this.allowedMetrics.indexOf("INP")>-1&&n(this.Td.bind(this),h),this.Qn=!0}else lt.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.hd=!((e=this._instance.persistence)==null||!e.props[ur]),this.startIfEnabled()}get Pd(){return this._instance.config.capture_performance}get allowedMetrics(){var s,e,t=Y(this.Pd)?(s=this.Pd)==null?void 0:s.web_vitals_allowed_metrics:void 0;return L(t)?((e=this._instance.persistence)==null?void 0:e.props[hr])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(Y(this.Pd)?this.Pd.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var s=Y(this.Pd)?this.Pd.web_vitals_attribution:void 0;return s!=null&&s}get useSoftNavs(){var s=Y(this.Pd)?this.Pd.__preview_web_vitals_soft_navs:void 0;return s!=null&&s}get Ed(){var s=Y(this.Pd)&&le(this.Pd.__web_vitals_max_value)?this.Pd.__web_vitals_max_value:Zn;return s>0&&6e4>=s?Zn:s}get isEnabled(){var s=te==null?void 0:te.protocol;if(s!=="http:"&&s!=="https:")return lt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=Y(this.Pd)?this.Pd.web_vitals:Se(this.Pd)?this.Pd:void 0;return Se(e)?e:this.hd}startIfEnabled(){this.isEnabled&&!this.Qn&&(lt.info("enabled, starting..."),this._s(this.Id))}onRemoteConfig(s){if(s.ok){var e=s.config;if("capturePerformance"in e){var t=Y(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Y(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ur]:t}),this._instance.persistence.register({[hr]:i})),this.hd=t,this.startIfEnabled()}}}get Rd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_s(s){var e=C.__PosthogExtensions__,t=this.Rd,i=e==null?void 0:e.postHogWebVitalsCallbacksByFlavor;i!=null&&i[t]||t==="web-vitals"&&w(i)&&e!=null&&e.postHogWebVitalsCallbacks?s():e==null||e.loadExternalDependency==null||e.loadExternalDependency(this._instance,t,r=>{r?lt.error("failed to load script",r):s()})}Md(s){var e=s||(_==null?void 0:_.location.href);if(e){var t=this._instance.config.disable_capture_url_hashes?rt(e):e,i=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...zt,...i||[]]:[];return _s(t,r,ms)}lt.error("Could not determine current URL")}}},Oh={exceptionObserver:class{constructor(s){var e;this.Id=()=>{var t;if(_&&this.isEnabled&&(t=C.__PosthogExtensions__)!=null&&t.errorWrappingFunctions){var i=C.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=C.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=C.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Ad&&this.qi.capture_unhandled_errors&&(this.Ad=i(this.captureException.bind(this))),!this.Fd&&this.qi.capture_unhandled_rejections&&(this.Fd=r(this.captureException.bind(this))),!this.Od&&this.qi.capture_console_errors&&(this.Od=n(this.captureException.bind(this)))}catch(a){es.error("failed to start",a),this.Ld()}}},this._instance=s,this.$d=!((e=this._instance.persistence)==null||!e.props[ar]),this.oe=new bl(y({},function(t){var i,r,n,a;return t===void 0&&(t={}),{refillRate:(i=(r=t.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:t.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(n=(a=t.exceptionRateLimiterBucketSize)!==null&&a!==void 0?a:t.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}}
2(this._instance.config.error_tracking),{refillInterval:1e4,I:es})),this.qi=this.Dd(),this.startIfEnabledOrStop()}Dd(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Y(s)?e=y({},e,s):(w(s)?this.$d:s)&&(e=y({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qi.capture_console_errors||this.qi.capture_unhandled_errors||this.qi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(es.info("enabled"),this.Ld(),this._s(this.Id)):this.Ld()}_s(s){var e,t;(e=C.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?s():(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return es.error("failed to load script",i);s()})}Ld(){var s,e,t;(s=this.Ad)==null||s.call(this),this.Ad=void 0,(e=this.Fd)==null||e.call(this),this.Fd=void 0,(t=this.Od)==null||t.call(this),this.Od=void 0}onRemoteConfig(s){if(s.ok){var e=s.config;"autocaptureExceptions"in e&&(this.$d=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[ar]:this.$d}),this.qi=this.Dd(),this.startIfEnabledOrStop())}}onConfigChange(){this.qi=this.Dd()}captureException(s){var e,t,i,r=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.oe.consumeRateLimit(r)?es.info("Skipping exception capture because of client rate limiting.",{exception:r}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(s)}},exceptions:class{constructor(s){var e,t;this.Nd=[],this.qd=new Nl([new Wl,new su,new Xl,new Jl,new eu,new Zl,new Ql,new tu],function(i){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;r>a;a++)n[a-1]=arguments[a];return function(o,l){l===void 0&&(l=0);for(var h=[],u=o.split(` 3`),c=l;u.length>c;c++){var v=u[c];if(1024>=v.length){var f=gn.test(v)?v.replace(gn,"$1"):v;if(!f.match(/\S*Error: /)){for(var d of n){var g=d(f,i);if(g){h.push(g);break}}if(h.length>=50)break}}}return function(p){if(!p.length)return[];var m=Array.from(p);return m.reverse(),m.slice(0,50).map(b=>{return y({},b,{filename:b.filename||(E=m,E[E.length-1]||{}).filename,function:b.function||jt});var E})}(h)}}("web:javascript",zl,Gl)),this._instance=s,this.Nd=(e=(t=this._instance.persistence)==null?void 0:t.get_property(or))!==null&&e!==void 0?e:[],this.jd=Ys(this.Bd()),this.Hd=new ru(this.jd)}onConfigChange(){this.jd=Ys(this.Bd()),this.Hd.setConfig(this.jd)}onRemoteConfig(s){var e,t,i;if(s.ok){var r=s.config;if("errorTracking"in r){var n=(e=(t=r.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],a=(i=r.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Nd=n,this._instance.persistence&&this._instance.persistence.register({[or]:this.Nd,[lr]:a})}}}get Ud(){var s,e=!!this._instance.get_property(lr),t=this._instance.config.error_tracking.captureExtensionExceptions;return(s=t??e)!==null&&s!==void 0&&s}buildProperties(s,e){return this.qd.buildFromUnknown(s,{syntheticException:e==null?void 0:e.syntheticException,mechanism:{handled:e==null?void 0:e.handled}})}addExceptionStep(s,e){if(this.jd.enabled)try{if(!H(s)||s.trim().length===0)return void je.warn("Ignoring exception step because message must be a non-empty string");var t=function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var a=[];return{sanitizedProperties:Object.keys(n).reduce((o,l)=>iu.has(l)?(a.push(l),o):(o[l]=n[l],o),{}),droppedKeys:a}}(this.zd(e)),i=t.sanitizedProperties,r=t.droppedKeys;r.length>0&&je.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.Hd.add(y({[Js]:s,[Xs]:new Date().toISOString()},i))}catch(n){je.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(s){try{var e=s.$exception_list;if(this.Wd(e)){if(this.Vd(e))return this.Gd("Exception dropped: matched a suppression rule"),void je.info("Skipping exception capture because a suppression rule matched");if(!this.Ud&&this.Zd(e))return this.Gd("Exception dropped: thrown by a browser extension"),void je.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Qd(e))return this.Gd("Exception dropped: thrown by the PostHog SDK"),void je.info("Skipping exception capture because it was thrown by the PostHog SDK")}var t=this.jd.enabled&&L(s.$exception_steps)?this.Jd(s):s,i=typeof(n=globalThis._posthogReleaseId)=="string"&&n.length>0?n:void 0;i&&(t.$release_id=i);try{var r=this._instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",fl:!0});return r&&this.Hd.clear(),r}catch(a){return je.error("Failed to capture exception event. Dropping this exception.",a),void this.Hd.clear()}}catch(a){return void je.error("Failed to process exception event. Ignoring this exception.",a)}var n}Jd(s){try{var e=this.Hd.getAttachable();return e.length===0?s:y({},s,{$exception_steps:e})}catch(t){return je.error("Failed to read buffered exception steps. Capturing exception without steps.",t),s}}Gd(s){this.jd.enabled&&this.Hd.add({[Js]:s,[Xs]:new Date().toISOString()})}zd(s){return Y(s)?y({},s):{}}Bd(){var s,e;return(s=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&s!==void 0?s:{}}Vd(s){if(s.length===0)return!1;try{var e=s.reduce((t,i)=>{var r=i.type,n=i.value;return H(r)&&r.length>0&&t.$exception_types.push(r),H(n)&&n.length>0&&t.$exception_values.push(n),t},{$exception_types:[],$exception_values:[]});return this.Nd.some(t=>{var i=t.values.map(r=>{var n=Xo[r.operator],a=e[r.key];if(!n||!a)return!1;var o=A(r.value)?r.value:[r.value];return o.length>0&&n(o,a)});return t.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(t){return je.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Zd(s){return s.flatMap(e=>{var t,i;return(t=(i=e.stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[]}).some(e=>{var t=e.filename;return!!t&&Ph.some(i=>t.startsWith(i))})}Qd(s){if(s.length>0){var e,t,i,r,n=(e=(t=s[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],a=n[n.length-1];return(i=a==null||(r=a.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Wd(s){return!L(s)&&A(s)}}},Ch=y({productTours:class{get za(){return this._instance.persistence}constructor(s){this.Kd=null,this.Yd=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(s.ok){var e=s.config;if("productTours"in e){var t,i;if(this.za&&this.za.register({[jr]:!!e.productTours}),!Ui(this._instance))return!this.Kd&&L((t=this.za)==null?void 0:t.props[rs])||Ms.info("product tours disabled; stopping and clearing cached tours"),(i=this.Kd)==null||i.stop(),this.Kd=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Kd&&Ui(this._instance)&&this._s(()=>this.Xd())}_s(s){var e,t;(e=C.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",i=>{i?Ms.error("Could not load product tours script",i):s()})}Xd(){var s;!this.Kd&&(s=C.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.Kd=C.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!A(this.Yd)||e){var t=this.za;if(t){var i=t.props[rs];if(A(i)&&!e)return this.Yd=i,void s(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:r=>{if(Ui(this._instance)){var n=r.statusCode;if(n!==200||!r.json){var a="Product Tours API could not be loaded, status: "+n;return n===0?r.error||Ms.warn(a):Ms.error(a),void s([],{isLoaded:!1,error:a})}var o=A(r.json.product_tours)?r.json.product_tours:[];this.Yd=o,t&&t.register({[rs]:o}),s(o,{isLoaded:!0})}else s([],{isLoaded:!0})}})}else s(this.Yd,{isLoaded:!0})}getActiveProductTours(s){L(this.Kd)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.Kd.getActiveProductTours(s)}showProductTour(s){var e;(e=this.Kd)==null||e.showTourById(s)}previewTour(s){this.Kd?this.Kd.previewTour(s):this._s(()=>{var e;this.Xd(),(e=this.Kd)==null||e.previewTour(s)})}dismissProductTour(){var s;(s=this.Kd)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.Kd)==null||s.nextStep()}previousStep(){var s;(s=this.Kd)==null||s.previousStep()}clearCache(){var s;this.Yd=null,(s=this.za)==null||s.unregister(rs)}resetTour(s){var e;(e=this.Kd)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.Kd)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.Kd)==null||e.cancelPendingTour(s)}}},fi),Rh={siteApps:class{constructor(s){this.tv=0,this._instance=s,this.ev=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}iv(s,e){if(e){var t=this.globalsForEvent(e);this.ev.push(t),this.ev.length>1e3&&(this.ev=this.ev.slice(10))}}get siteAppLoaders(){var s;return(s=C._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}initialize(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.iv.bind(this));this.rv=()=>{s(),this.ev=[],this.rv=void 0}}}globalsForEvent(s){var e,t,i,r,n,a,o;if(!s)throw new Error("Event payload is required");var l={},h=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(u)){var v=c[0];l[v]={id:h[v],type:v,properties:c[1]}}var f=s.$set_once,d=s.$set;return{event:y({},fa(s,mh),{properties:y({},s.properties,d?{$set:y({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},d)}:{},f?{$set_once:y({},(i=(r=s.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},f)}:{}),elements_chain:(n=(a=s.properties)==null?void 0:a.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(o=s.properties)==null?void 0:o.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}nv(s){var e,t=(e=s.tagName)==null?void 0:e.toLowerCase();return t==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(s)||(Ne.error("prepare_external_dependency_stylesheet returned null"),null):t==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(s)||(Ne.error("prepare_external_dependency_script returned null"),null):s}sv(){var s,e,t,i,r,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=x==null?void 0:x.defaultView,h=l==null||(s=l.Node)==null?void 0:s.prototype;if(!l||!h)return()=>{};if(this.tv++,this.av)return this.ov();var u=[],c=this,v=new WeakSet,f=(p,m,b)=>{if(p!=null&&p[m]){var E=p[m];p[m]=b(E),u.push(()=>{p[m]=E})}},d=p=>{if(v.has(p))return p;var m=c.nv(p);return m&&v.add(m),m},g=p=>p.map(m=>typeof m=="string"?m:d(m)).filter(m=>!de(m));return f(h,"appendChild",p=>function(m){var b=d(m);return b?p.call(this,b):m}),f(h,"insertBefore",p=>function(m,b){var E=d(m);return E?p.call(this,E,b):m}),f(h,"replaceChild",p=>function(m,b){var E=d(m);return E?p.call(this,E,b):b}),[(e=l.Element)==null?void 0:e.prototype,(t=l.Document)==null?void 0:t.prototype,(i=l.DocumentFragment)==null?void 0:i.prototype].forEach(p=>{f(p,"append",m=>function(){for(var b=arguments.length,E=new Array(b),I=0;b>I;I++)E[I]=arguments[I];return m.apply(this,g(E))}),f(p,"prepend",m=>function(){for(var b=arguments.length,E=new Array(b),I=0;b>I;I++)E[I]=arguments[I];return m.apply(this,g(E))})}),[(r=l.Element)==null?void 0:r.prototype,(n=l.CharacterData)==null?void 0:n.prototype,(a=l.DocumentType)==null?void 0:a.prototype].forEach(p=>{f(p,"before",m=>function(){for(var b=arguments.length,E=new Array(b),I=0;b>I;I++)E[I]=arguments[I];return m.apply(this,g(E))}),f(p,"after",m=>function(){for(var b=arguments.length,E=new Array(b),I=0;b>I;I++)E[I]=arguments[I];return m.apply(this,g(E))}),f(p,"replaceWith",m=>function(){for(var b=arguments.length,E=new Array(b),I=0;b>I;I++)E[I]=arguments[I];var k=g(E);return E.length&&!k.length?void 0:m.apply(this,k)})}),f((o=l.Element)==null?void 0:o.prototype,"insertAdjacentElement",p=>function(m,b){var E=d(b);return E?p.call(this,m,E):null}),this.av=()=>{u.forEach(p=>p()),this.av=void 0},this.ov()}ov(){var s=!1;return()=>{var e;s||(s=!0,this.tv--,this.tv===0&&((e=this.av)==null||e.call(this)))}}lv(s,e){e===void 0&&(e=!0);var t=this.sv();try{var i=s(t);return e&&t(),i}catch(r){throw t(),r}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var a;!e.errored&&this.ev.length&&(Ne.info("Processing "+this.ev.length+" events for site app with id "+s.id),this.ev.forEach(o=>this.lv(()=>e.processEvent==null?void 0:e.processEvent(o))),e.processedBuffer=!0),Object.values(this.apps).every(o=>o.processedBuffer||o.errored)&&((a=this.rv)==null||a.call(this))},i=!1,r=a=>{e.errored=!a,e.loaded=!0,Ne.info("Site app with id "+s.id+" "+(a?"loaded":"errored")),i&&t()};try{var n=this.lv(a=>s.init({posthog:this._instance,callback(o){a(),r(o)}}),!1).processEvent;n&&(e.processEvent=n),i=!0}catch(a){Ne.error(sa+s.id,a),r(!1)}if(i&&e.loaded)try{t()}catch(a){Ne.error("Error while processing buffered events PostHog app with config id "+s.id,a),e.errored=!0}}uv(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}hv(s){var e=this;if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(s),i=function(n){try{e.lv(()=>n.processEvent==null?void 0:n.processEvent(t))}catch(a){Ne.error("Error while processing event "+s.event+" for site app "+n.id,a)}};for(var r of Object.values(this.apps))i(r)}}onRemoteConfig(s){var e,t,i,r=this;
3if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.uv(),void this._instance.on("eventCaptured",l=>this.hv(l))):void Ne.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.rv)==null||t.call(this),s.ok){var n=s.config;if((i=n.siteApps)!=null&&i.length)if(this.isEnabled){var a=function(){var l,h=o.id,u=o.url;C["__$$ph_site_app_"+h]=r._instance,(l=C.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(r._instance,u,c=>{if(c)return Ne.error(sa+h,c)})};for(var o of n.siteApps)a()}else Ne.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Mh={tracingHeaders:class{constructor(s){this.dv=void 0,this.vv=void 0,this.fv=void 0,this.Id=()=>{var e,t,i=this.pv();i?(w(this.dv)&&(this.dv=(e=C.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),w(this.vv)&&(this.vv=(t=C.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Ld()},this._instance=s}initialize(){this.startIfEnabledOrStop()}_s(s){var e,t;(e=C.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns?s():(t=C.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return gh.error("failed to load script",i);s()})}gv(){var s,e;return(s=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&s!==void 0?s:this._instance.config.__add_tracing_headers}pv(){var s=this.gv();return A(s)?(A(this.fv)?this.fv.splice(0,this.fv.length,...s):this.fv=[...s],s.length>0?this.fv:void 0):(A(this.fv)&&this.fv.splice(0),this.fv=s||void 0,this.fv)}Ld(){var s,e;(s=this.dv)==null||s.call(this),(e=this.vv)==null||e.call(this),this.dv=void 0,this.vv=void 0}startIfEnabledOrStop(){this.pv()?this._s(this.Id):this.Ld()}}},qh=y({surveys:class extends yh{constructor(s){var e;super(new Eh(s),{get projectToken(){return e.config.token},kv:new kh(e=s)}),this._instance=s}Nl(s,e){var t=e.query?ys(s,e.query):s;return new Promise(i=>{var r;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor((r=e.target)!==null&&r!==void 0?r:"api",t),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:i})})}}},fi),Ah={toolbar:class{constructor(s){this.instance=s}mv(s){C.ph_toolbar_state=s}yv(){var s;return(s=C.ph_toolbar_state)!==null&&s!==void 0?s:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(s,e,t){if(s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),yr(this.instance.config)||!_||!x)return!1;s=s??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_==null?void 0:_.localStorage}var i,r=Sh||oi(s.hash,"__posthog")||oi(s.hash,"state"),n=r?yn(()=>JSON.parse(atob(decodeURIComponent(r))))||yn(()=>JSON.parse(decodeURIComponent(r))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?s.hash=n.desiredHash:t?t.replaceState(t.state,"",s.pathname+s.search):s.hash="")):((i=JSON.parse(e.getItem(ra)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}bv(s){var e=C.ph_load_toolbar||C.ph_load_editor;!L(e)&&ge(e)?e(s,this.instance):na.warn("No toolbar load function found")}loadToolbar(s){var e=!(x==null||!x.getElementById(vo));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=y({token:this.instance.config.token},s,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(ra,JSON.stringify(y({},i,{source:void 0}))),this.yv()===2)this.bv(i);else if(this.yv()===0){var r;this.mv(1),(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",n=>{if(n)return na.error("[Toolbar] Failed to load",n),void this.mv(0);this.mv(2),this.bv(i)}),Z(_,"turbolinks:load",()=>{this.mv(0),this.loadToolbar(i)})}return!0}_v(s){return this.loadToolbar(s)}maybeLoadEditor(s,e,t){return s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(s,e,t)}}},Lh=y({experiments:fe},fi),Dh={conversations:class{constructor(s){this.wv=void 0,this._conversationsManager=null,this.Sv=!1,this.Me=null,this.xv=!1,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this._instance.config.disable_conversations&&(this.Cv=s.ok,s.ok)){var e=s.config.conversations;L(e)||(Se(e)?this.wv=e:(this.wv=e.enabled,this.Me=e),this.loadIfEnabled())}}reset(){var s;(s=this._conversationsManager)==null||s.reset(),this._conversationsManager=null,this.wv=void 0,this.Me=null,this.Cv=void 0,this.xv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Sv||this._instance.config.disable_conversations||yr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var s=C==null?void 0:C.__PosthogExtensions__;if(s&&!w(this.wv)&&this.wv)if(this.Me&&this.Me.token){this.Sv=!0;try{var e=s.initConversations;if(e)return this.Tv(e),void(this.Sv=!1);var t=s.loadExternalDependency;if(!t)return void this.Mv(Hr);t(this._instance,"conversations",i=>{i||!s.initConversations?this.Mv("Could not load conversations script",i):this.Tv(s.initConversations),this.Sv=!1})}catch(i){this.Mv("Error initializing conversations",i),this.Sv=!1}}else Re.error("Conversations enabled but missing token in remote config.")}}Tv(s){if(this.Me)try{this._conversationsManager=s(this.Me,this._instance),this.xv=!1,Re.info("Conversations loaded successfully")}catch(e){this.Mv("Error completing conversations initialization",e)}else Re.error("Cannot complete initialization: remote config is null")}Mv(s,e){Re.error(s,e),this._conversationsManager=null,this.Sv=!1,this.xv=!0}show(){this._conversationsManager?this._conversationsManager.show():Re.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.wv===!0&&!de(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":yr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Cv===!1?"remote_config_failed":w(this.wv)?this.Cv?"disabled_in_project":"remote_config_pending":this.wv?L(this.Me)||!this.Me.token?"missing_token":C!=null&&C.__PosthogExtensions__?this.Sv?"initializing":this.xv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&s!==void 0&&s}sendMessage(s,e,t){var i=this;return Q(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(s,e,t):(Re.warn(ht),null)})()}getMessages(s,e){var t=this;return Q(function*(){return t._conversationsManager?t._conversationsManager.getMessages(s,e):(Re.warn(ht),null)})()}markAsRead(s){var e=this;return Q(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(s):(Re.warn(ht),null)})()}getTickets(s){var e=this;return Q(function*(){return e._conversationsManager?e._conversationsManager.getTickets(s):(Re.warn(ht),null)})()}requestRestoreLink(s){var e=this;return Q(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(s):(Re.warn(ht),null)})()}restoreFromToken(s){var e=this;return Q(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(s):(Re.warn(ht),null)})()}restoreFromUrlToken(){var s=this;return Q(function*(){return s._conversationsManager?s._conversationsManager.restoreFromUrlToken():(Re.warn(ht),null)})()}getCurrentTicketId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&s!==void 0?s:null}getWidgetSessionId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&s!==void 0?s:null}Sl(){var s;(s=this._conversationsManager)==null||s.setIdentity()}xl(){var s;(s=this._conversationsManager)==null||s.clearIdentity()}}},Nh={logs:class{constructor(s){var e,t=this;this.Ev=!1,this.Iv=!1,this.I=ee("[logs]"),this.Rv=y({},this.I,{error(){for(var i=arguments.length,r=new Array(i),n=0;i>n;n++)r[n]=arguments[n];r.some(va)||t.I.error(...r)}}),this.ka=[],this.Pv=[],this.ph=0,this.Av=()=>{var i,r;this.ph=0,(i=this.Fv)==null||i.onReconnect(),(r=this.Ov)==null||r.onReconnect()},this._instance=s,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Ev=!0),_&&Z(_,"online",this.Av)}Lv(s,e,t,i){var r,n=function(a,o){var l,h,u,c,v,f,d,g=(l=a==null?void 0:a.flushIntervalMs)!==null&&l!==void 0?l:3e3,p=(h=a==null?void 0:a.maxBufferSize)!==null&&h!==void 0?h:100,m=o!=null&&o.consoleCapture?void 0:(u=a==null?void 0:a.maxLogsPerInterval)!==null&&u!==void 0?u:1e3,b=w(m)?Math.max(p,2048):Math.max(p,m),E=a==null?void 0:a.resourceAttributes;return{serviceName:(c=(v=E==null?void 0:E["service.name"])!==null&&v!==void 0?v:a==null?void 0:a.serviceName)!==null&&c!==void 0?c:o==null?void 0:o.serviceNameDefault,serviceVersion:(f=E==null?void 0:E["service.version"])!==null&&f!==void 0?f:a==null?void 0:a.serviceVersion,environment:(d=E==null?void 0:E["deployment.environment"])!==null&&d!==void 0?d:a==null?void 0:a.environment,resourceAttributes:E,beforeSend:a==null?void 0:a.beforeSend,flushIntervalMs:g,maxBufferSize:p,maxQueueSize:b,maxBatchRecordsPerPost:100,rateCapWindowMs:g,maxLogsPerInterval:m,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}((r=this._instance)==null||(r=r.config)==null?void 0:r.logs,t);return[new Al(this.$v(s,e),n,this.Rv,()=>this.Dv(),a=>a(),void 0,i),n]}Nv(){var s,e=(s=this._instance)==null||(s=s.config)==null?void 0:s.logs;if(!this.Fv||this.qv!==e){var t;(t=this.Fv)==null||t.reset(),this.qv=e;var i=this.Lv(()=>this.ka,r=>{this.ka=r});this.Fv=i[0],this.jv=i[1]}return this.Fv}Bv(){var s,e=(s=this._instance)==null||(s=s.config)==null?void 0:s.logs;if(!this.Ov||this.Hv!==e){var t;(t=this.Ov)==null||t.reset(),this.Hv=e;var i=this.Lv(()=>this.Pv,r=>{this.Pv=r},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},da);this.Ov=i[0],this.Uv=i[1]}return this.Ov}initialize(){this.loadIfEnabled()}onRemoteConfig(s){var e;if(s.ok){var t=(e=s.config.logs)==null?void 0:e.captureConsoleLogs;!L(t)&&t&&(this.Ev=!0,this.loadIfEnabled())}}reset(){var s,e;this.ka=[],(s=this.Fv)==null||s.reset(),this.Pv=[],(e=this.Ov)==null||e.reset(),this.ph=0}captureLog(s){this.Nv().captureLog(s)}vi(s){this.Bv().captureLog(s)}get logger(){return this.zv||(this.zv={trace:(s,e)=>this.captureLog({body:s,level:"trace",attributes:e}),debug:(s,e)=>this.captureLog({body:s,level:"debug",attributes:e}),info:(s,e)=>this.captureLog({body:s,level:"info",attributes:e}),warn:(s,e)=>this.captureLog({body:s,level:"warn",attributes:e}),error:(s,e)=>this.captureLog({body:s,level:"error",attributes:e}),fatal:(s,e)=>this.captureLog({body:s,level:"fatal",attributes:e})}),this.zv}flushLogs(s){s?this.Wv(s):(this.Fv&&this.Fv.flush().catch(e=>this.Vv(e)),this.Ov&&this.Ov.flush().catch(e=>this.Vv(e)))}Vv(s){va(s)||this.I.error("PostHog logs flush failed:",s)}loadIfEnabled(){if(this.Ev&&!this.Iv){var s=C==null?void 0:C.__PosthogExtensions__;if(s){var e=s.loadExternalDependency;e?e(this._instance,"logs",t=>{var i;t||(i=s.logs)==null||!i.initializeLogs?this.I.error("Could not load logs script",t):(s.logs.initializeLogs(this._instance),this.Iv=!0)}):this.I.error(Hr)}else this.I.error("PostHog Extensions not found.")}}$v(s,e){var t=this._instance;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},getPersistedProperty:i=>i===Xe.LogsQueue?s():void 0,setPersistedProperty(i,r){var n;i===Xe.LogsQueue&&e((n=r)!==null&&n!==void 0?n:[])},Mn:i=>this.Mn(i),getLibraryId:()=>X.LIB_NAME,getLibraryVersion:()=>X.LIB_VERSION}}Mn(s){return new Promise(e=>{if(Io(this.ph,3))e({kind:"fatal",error:Wi(void 0,"logs endpoint is unreachable, dropping batch")});else{var t=!1,i=n=>{t||(t=!0,clearTimeout(r),e(n))},r=setTimeout(()=>{this.I.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:Wi(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Gv(),data:s,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{var a=n.statusCode;if(this.Zv(a),a>=200&&300>a)i({kind:"ok"});else if(a===413)i({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)i({kind:"fatal",error:new Error("logs request failed with status "+a)});else{var o;a===0?(n.error||this.I.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:Wi(n.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(o=n.error)!==null&&o!==void 0?o:new Error("logs request failed with status "+a)})}}})}})}Zv(s){(s!==0||this._instance.__loaded)&&(this.ph=Po(s,this.ph,3,()=>this.I.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.")))}Wv(s){this.ka.length>
30&&this.Qv(s,this.ka,this.jv,X.LIB_NAME,e=>{this.ka=e}),this.Pv.length>0&&this.Qv(s,this.Pv,this.Uv,da,e=>{this.Pv=e})}Qv(s,e,t,i,r){if(e.length!==0){var n=e.map(o=>o.record);r([]);var a=Ja(n,Wa(t,X.LIB_NAME,X.LIB_VERSION),i,X.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Gv(),data:a,compression:"best-available",batchKey:"logs",transport:s})}}Gv(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Dv(){var s,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var t=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.windowId,r=t.sessionStartTimestamp,n=t.lastActivityTimestamp;e.sessionId=t.sessionId,e.windowId=i,L(r)||(e.sessionStartTimestamp=r),L(n)||(e.lastActivityTimestamp=n)}if(C!=null&&(s=C.location)!=null&&s.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?rt(C.location.href):C.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},jh={metrics:class{constructor(s){this.I=ee("[metrics]"),this._instance=s}initialize(){}Nv(){var s,e,t=(s=this._instance)==null||(s=s.config)==null?void 0:s.metrics;return this.Fv&&this.qv===t||((e=this.Fv)==null||e.reset(),this.qv=t,this.Fv=new Ll(this.$v(),function(i){var r,n,a,o,l,h=i==null?void 0:i.resourceAttributes;return{serviceName:(r=h==null?void 0:h["service.name"])!==null&&r!==void 0?r:i==null?void 0:i.serviceName,serviceVersion:(n=h==null?void 0:h["service.version"])!==null&&n!==void 0?n:i==null?void 0:i.serviceVersion,environment:(a=h==null?void 0:h["deployment.environment"])!==null&&a!==void 0?a:i==null?void 0:i.environment,resourceAttributes:h,beforeSend:i==null?void 0:i.beforeSend,flushIntervalMs:(o=i==null?void 0:i.flushIntervalMs)!==null&&o!==void 0?o:1e4,maxSeriesPerFlush:(l=i==null?void 0:i.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}}(t),this.I)),this.Fv}count(s,e,t){e===void 0&&(e=1),this.Nv().count(s,e,t)}gauge(s,e,t){this.Nv().gauge(s,e,t)}histogram(s,e,t){this.Nv().histogram(s,e,t)}flush(s){if(!this.Fv)return Promise.resolve();if(s){var e=this.Fv.drainWindow();return e&&this.Un(e,s),Promise.resolve()}return this.Fv.flush().catch(t=>this.I.error("PostHog metrics flush failed:",t))}reset(){var s;(s=this.Fv)==null||s.reset()}$v(){var s=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},Un:t=>e.Un(t),getLibraryId:()=>X.LIB_NAME,getLibraryVersion:()=>X.LIB_VERSION}}Un(s,e){return new Promise(t=>{var i=!1,r=a=>{i||(i=!0,clearTimeout(n),t(a))},n=setTimeout(()=>r({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(y({method:"POST",url:this.Jv(),data:s,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(a){var o=a.statusCode;if(o>=200&&300>o)r({kind:"ok"});else if(o===413)r({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)r({kind:"fatal",error:new Error("metrics request failed with status "+o)});else{var l;r({kind:"retry-later",error:(l=a.error)!==null&&l!==void 0?l:new Error("metrics request failed with status "+o)})}}}))})}Jv(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Bh=y({},fi,Th,$h,Oh,Ch,Rh,qh,Mh,Ah,Lh,Dh,Nh,jh);Fe.__defaultExtensionClasses=y({},Bh);var Hh=function(){X.SDK_DIST_CHANNEL="npm";var s=hs[Tt]=new Fe;return function(){function e(){e.done||(e.done=!0,tl=!1,U(hs,function(t){t._dom_loaded()}))}x!=null&&x.addEventListener?x.readyState==="complete"?e():Z(x,"DOMContentLoaded",e,{capture:!1}):_&&S.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),s}();export{ye as Compression,kr as DisplaySurveyType,Fe as PostHog,Lu as ProductTourEventName,Ln as ProductTourEventProperties,Ze as SurveyEventName,qi as SurveyEventProperties,Yt as SurveyEventType,Mi as SurveyType,Hh as default,Hh as posthog};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.