posthog-js 1.418.11 → 1.418.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:t,i=null==e?void 0:e.navigator,r=null==e?void 0:e.document,s=null==e?void 0:e.location,n=null==e?void 0:e.fetch,o=null!=e&&e.XMLHttpRequest&&"withCredentials"in new e.XMLHttpRequest?e.XMLHttpRequest:void 0,a=null==e?void 0:e.AbortController,l=null==e?void 0:e.CompressionStream,u=null==i?void 0:i.userAgent;function h(){return!(!t||!1===t.navigator.onLine)}var d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});var v=null!=t?t:{},c={DEBUG:!1,LIB_VERSION:"0.5.0",LIB_NAME:"browser-common"};function f(t,e,i,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(r,s)}function p(t){return function(){var e=this,i=arguments;return new Promise((function(r,s){var n=t.apply(e,i);function o(t){f(n,r,s,o,a,"next",t)}function a(t){f(n,r,s,o,a,"throw",t)}o(void 0)}))}}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},_.apply(null,arguments)}function g(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}var m=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function y(t){return"string"==typeof t||t}function b(t){return"string"==typeof t?t:void 0}var w,x=["$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"],S=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),E=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),k=["$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"],T=["token"],P="NativeGzipValidationError",R=t=>t.length>=2&&31===t[0]&&139===t[1],O=(t,e)=>t===E.GZipJS||e===E.GZipJS||"gzip"===e,C=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),I=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=P,e},A=function(){var t=p((function*(t,e){18>t.size&&I("too-short");var i=new Uint8Array(yield t.slice(0,10).arrayBuffer());R(i)&&8===i[2]||I("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var e=(()=>{if(w)return w;w=[];for(var t=0;256>t;t++){for(var e=t,i=0;8>i;i++)e=1&e?3988292384^e>>>1:e>>>1;w[t]=e>>>0}return w})(),i=4294967295,r=0;t.length>r;r++)i=e[255&(i^t[r])]^i>>>8;return(4294967295^i)>>>0})(e)&&I("invalid-crc");var s=e.length>>>0;r.getUint32(4,!0)!==s&&I("invalid-size")}));return function(e,i){return t.apply(this,arguments)}}();function F(){return F=p((function*(t,e,i){void 0===e&&(e=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),n=s.writable.getWriter(),o=n.write(r).then((()=>n.close())).catch(function(){var t=p((function*(t){try{yield n.abort(t)}catch(t){}throw t}));return function(e){return t.apply(this,arguments)}}()),a=new Response(s.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield A(l,r),l}catch(t){if(null!=i&&i.rethrow)throw t;return e&&console.error("Failed to gzip compress data",t),null}})),F.apply(this,arguments)}var M=20,D=1e3,N=1e4,U="[Circular]",L="[Truncated]",j="[Unserializable]",B="[Function]";function z(t){for(var e="",i=0;t.length>i;i++){var r=t.charCodeAt(i);if(55296>r||r>56319)e+=56320>r||r>57343?t[i]:"�";else{var s=t.charCodeAt(i+1);56320>s||s>57343?e+="�":(e+=t[i]+t[i+1],i++)}}return e}var q=["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"],H=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return q.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function V(t,e){return-1!==t.indexOf(e)}var W=function(t){return t.trim()},G=function(t){return t.replace(/^\$/,"")};function K(t){var e,i=[];return null!==(e=JSON.stringify(t,(function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(e))return"[Circular]";i.push(e)}return e}})))&&void 0!==e?e:"null"}var J=Object.prototype,Y=J.hasOwnProperty,Q=J.toString,X=Array.isArray||function(t){return"[object Array]"===Q.call(t)},Z=t=>"function"==typeof t,tt=t=>t===Object(t)&&!X(t),et=t=>{if(tt(t)){for(var e in t)if(Y.call(t,e))return!1;return!0}return!1},it=t=>void 0===t,rt=t=>"[object String]"==Q.call(t),st=t=>rt(t)&&0===t.trim().length,nt=t=>null===t,ot=t=>it(t)||nt(t),at=t=>"[object Number]"==Q.call(t)&&t==t,lt=t=>at(t)&&t>0,ut=t=>"[object Boolean]"===Q.call(t),ht=t=>t instanceof FormData,dt=t=>V(k,t),vt=t=>V(T,t);function ct(t){return null===t||"object"!=typeof t}function ft(t,e){return{}.toString.call(t)==="[object "+e+"]"}function pt(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return gt(t,Error)}}function _t(t){return"undefined"!=typeof Event&&gt(t,Event)}function gt(t,e){try{return t instanceof e}catch(t){return!1}}var mt=[!0,"true",1,"1","yes"],yt=t=>V(mt,t),bt=[!1,"false",0,"0","no"];function wt(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),at(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),wt(s||i,e,i,r))}class xt{constructor(t){this.k={},this.S=t.S,this.C=wt(t.bucketSize,0,100,t.I),this.R=wt(t.refillRate,0,this.C,t.I),this.A=wt(t.refillInterval,0,864e5,t.I)}O(t,e){var i=Math.floor((e-t.lastAccess)/this.A);i>0&&(t.tokens=Math.min(t.tokens+i*this.R,this.C),t.lastAccess=t.lastAccess+i*this.A)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.k[r];return s?this.O(s,i):this.k[r]=s={tokens:this.C,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.S)||e.call(this,t)),0===s.tokens)}stop(){this.k={}}}var St="Mobile",Et="iOS",kt="Android",$t="Tablet",Tt=kt+" "+$t,Pt="iPad",Rt="Apple",Ot=Rt+" Watch",Ct="Safari",It="BlackBerry",At="Samsung",Ft=At+"Browser",Mt=At+" Internet",Dt="Chrome",Nt=Dt+" OS",Ut=Dt+" "+Et,Lt="Internet Explorer",jt=Lt+" "+St,Bt="Opera",zt=Bt+" Mini",qt="Edge",Ht="Microsoft "+qt,Vt="Firefox",Wt=Vt+" "+Et,Gt="Nintendo",Kt="PlayStation",Jt="Xbox",Yt=kt+" "+St,Qt=St+" "+Ct,Xt="Windows",Zt=Xt+" Phone",te="Nokia",ee="Ouya",ie="Generic",re=ie+" "+St.toLowerCase(),se=ie+" "+$t.toLowerCase(),ne="Konqueror",oe="Oculus Browser",ae="Vivaldi",le="Yandex",ue="Whale",he="DuckDuckGo",de="Pale Moon",ve="Waterfox",ce="Brave",fe="Google Search App",pe="(\\d+(\\.\\d+)?)",_e=new RegExp("Version/"+pe),ge=new RegExp(Jt,"i"),me=new RegExp(Kt+" \\w+","i"),ye=new RegExp(Gt+" \\w+","i"),be=new RegExp(It+"|PlayBook|BB10","i"),we={"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"},xe=function(t,e,i,r){e=e||"";var s=function(t){return null!=t&&t.brave?ce:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&V(t,"GSA/")?fe:V(t," OPR/")&&V(t,"Mini")?zt:V(t," OPR/")?Bt:be.test(t)?It:V(t,"IE"+St)||V(t,"WPDesktop")?jt:V(t,"OculusBrowser")?oe:V(t,Ft)?Mt:V(t,qt)||V(t,"Edg/")?Ht:V(t,ae+"/")?ae:V(t,"YaBrowser/")?le:V(t,ue+"/")?ue:V(t,he+"/")||V(t,"Ddg/")?he:V(t,"FBIOS")?"Facebook "+St:V(t,"UCWEB")||V(t,"UCBrowser")?"UC Browser":V(t,"CriOS")?Ut:V(t,"CrMo")||V(t,Dt)?Dt:V(t,kt)&&V(t,Ct)?Yt:V(t,"FxiOS")?Wt:V(t.toLowerCase(),ne.toLowerCase())?ne:V(t,ce+"/")?ce:((t,e)=>e&&V(e,Rt)||function(t){return V(t,Ct)&&!V(t,Dt)&&!V(t,kt)}(t))(t,e)?V(t,St)?Qt:Ct:V(t,"PaleMoon/")?de:V(t,ve+"/")?ve:V(t,Vt)?Vt:V(t,"MSIE")||V(t,"Trident/")?Lt:V(t,"Gecko")?Vt:"")},Se={[jt]:[new RegExp("rv:"+pe)],[Ht]:[new RegExp(qt+"?\\/"+pe)],[Dt]:[new RegExp("("+Dt+"|CrMo)\\/"+pe)],[Ut]:[new RegExp("CriOS\\/"+pe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+pe)],[Ct]:[_e],[Qt]:[_e],[Bt]:[new RegExp("(Opera|OPR)\\/"+pe)],[Vt]:[new RegExp(Vt+"\\/"+pe)],[Wt]:[new RegExp("FxiOS\\/"+pe)],[ne]:[new RegExp("Konqueror[:/]?"+pe,"i")],[It]:[new RegExp(It+" "+pe),_e],[Yt]:[new RegExp("android\\s"+pe,"i")],[Mt]:[new RegExp(Ft+"\\/"+pe)],[oe]:[new RegExp("OculusBrowser\\/"+pe)],[ae]:[new RegExp(ae+"\\/"+pe)],[le]:[new RegExp("YaBrowser\\/"+pe)],[ue]:[new RegExp(ue+"\\/"+pe)],[ce]:[new RegExp(ce+"\\/"+pe)],[he]:[new RegExp("(DuckDuckGo|Ddg)\\/"+pe)],[de]:[new RegExp("PaleMoon\\/"+pe)],[ve]:[new RegExp(ve+"\\/"+pe)],[fe]:[new RegExp("GSA\\/"+pe)],[Lt]:[new RegExp("(rv:|MSIE )"+pe)],Mozilla:[new RegExp("rv:"+pe)]},Ee=function(t,e,i,r){var s=xe(t,e,i,r),n=Se[s];if(it(n))return null;for(var o=0;n.length>o;o++){var a=t.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},ke=[[new RegExp(Jt+"; "+Jt+" (.*?)[);]","i"),t=>[Jt,t&&t[1]||""]],[new RegExp(Gt,"i"),[Gt,""]],[new RegExp(Kt,"i"),[Kt,""]],[be,[It,""]],[new RegExp(Xt,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Zt,""];if(new RegExp(St).test(e)&&!/IEMobile\b/.test(e))return[Xt+" "+St,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=we[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[Xt,r]}return[Xt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Et,[t[3],t[4],t[5]||"0"].join(".")]:[Et,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=it(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+kt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+kt+")","i"),t=>t&&t[2]?[kt,[t[2],t[3],t[4]||"0"].join(".")]:[kt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Nt,""]],[/Linux|debian/i,["Linux",""]]],$e=function(t){return ye.test(t)?Gt:me.test(t)?Kt:ge.test(t)?Jt:new RegExp(ee,"i").test(t)?ee:new RegExp("("+Zt+"|WPDesktop)","i").test(t)?Zt:/iPad/.test(t)?Pt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ot:be.test(t)?It:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(te,"i").test(t)?te:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(St).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?kt:Tt:new RegExp("(pda|"+St+")","i").test(t)?re:new RegExp($t,"i").test(t)&&!new RegExp($t+" pc","i").test(t)?se:""},Te=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Pe(t,e){return"string"==typeof(i=t)&&Te.test(i)?t:e();var i}function Re(t){return t?t.split("#")[0]:t}function Oe(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function Ce(t,e,i){return Ie.apply(this,arguments)}function Ie(){return(Ie=p((function*(t,e,i){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=Oe((()=>{try{null==i||i(),t()}catch(t){s(t)}}),e)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Ae={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}},Fe=Ae.info,Me=0x8000000000000000,De={}.propertyIsEnumerable;function Ne(t,e){try{return je(t,e,{ancestors:new WeakSet,remainingNodes:N},0)}catch(t){return[]}}function Ue(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:L};if(i.remainingNodes--,ut(t))return{boolValue:t};if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if("undefined"==typeof BigInt)return{stringValue:String(t)};var s=BigInt(t).toString();return t>=Me||-Me>t?(null==e||e.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:z(t)};if("function"==typeof t)return{stringValue:B};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(i.ancestors.has(t))return{stringValue:U};if(r>=M)return{stringValue:L};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof o?z(o):String(o)}}i.ancestors.add(t);try{try{var a=t.toJSON;if("function"==typeof a)return Ue(a.call(t),e,i,r+1)}catch(t){}return X(t)?{arrayValue:{values:Le(t,e,i,r+1)}}:{kvlistValue:{values:je(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:z(String(t))}}function Le(t,e,i,r){for(var s=[],n=Math.min(t.length,D),o=0;n>o&&i.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(ot(a))continue;s.push(Ue(a,e,i,r))}catch(t){s.push({stringValue:j})}return t.length>o&&s.push({stringValue:L}),s}function je(t,e,i,r){var s=[];for(var n in t)if(De.call(t,n)){if(s.length>=D||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(nt(o)||it(o))continue;s.push({key:z(n),value:Ue(o,e,i,r)})}catch(t){s.push({key:z(n),value:{stringValue:j}})}}return s}function Be(t){try{return z(String(t))}catch(t){return j}}function ze(t,e,i){var r=Ae[t.level||"info"]||Fe,s=r.text,n=r.number,o=String(Date.now())+"000000",a={};e.distinctId&&(a.posthogDistinctId=e.distinctId),e.sessionId&&(a.sessionId=e.sessionId),e.windowId&&(a["window.id"]=e.windowId),ot(e.sessionStartTimestamp)||(a.sessionStartTimestamp=String(e.sessionStartTimestamp)),ot(e.lastActivityTimestamp)||(a.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(a["url.full"]=e.currentUrl),e.screenName&&(a["screen.name"]=e.screenName),e.appState&&(a["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(a.feature_flags=e.activeFeatureFlags);var l=_({},a),u=t.attributes;if(u){var h=[];try{h=Object.keys(u)}catch(t){h=[]}for(var d of h){var v=void 0;try{v=u[d]}catch(t){v=j}Object.defineProperty(l,d,{value:v,enumerable:!0,writable:!0,configurable:!0})}}var c={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:s,body:{stringValue:Be(t.body)},attributes:Ne(l,i)};return t.trace_id&&(c.traceId=t.trace_id),t.span_id&&(c.spanId=t.span_id),it(t.trace_flags)||(c.flags=t.trace_flags),c}function qe(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}function He(t,e,i,r){return{resourceLogs:[{resource:{attributes:Ne(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let Ve=class{constructor(t,e,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Di=e,this.I=i,this.tn=r,this.en=s,this.rn=n,this.nn=o,this.sn=null,this.an=0,this.ln=0,this.un=0,this.hn=0,this.dn=!1,this.vn=e.maxBufferSize,this.cn=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.fn=e.flushIntervalMs,this.pn=e.maxBatchRecordsPerPost,this.gn=e.rateCapWindowMs,this.mn=e.maxLogsPerInterval}reset(){this.yn(),this.sn=null,this.un=0,this.hn=0,this.dn=!1,this.an=0,this.ln=0,this.pn=this.Di.maxBatchRecordsPerPost}onReconnect(){this.ln=0,this.bn()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this._n(t);if(null!==e)if(e.body){if(this.wn()){var i={record:ze(e,this.tn(),this.I)};this.en((()=>this.kn(i)))}}else this.I.info("Log was rejected in beforeSend function")}}_n(t){var e=this.Di.beforeSend;if(!e)return t;var i=X(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for log:",t),null}return r}wn(){if(void 0===this.mn)return!0;var t=Date.now(),e=t-this.un;return this.gn>e&&e>=0||(this.un=t,this.hn=0,this.dn=!1),this.mn>this.hn?(this.hn++,!0):(this.dn||(this.I.warn("captureLog dropping logs: exceeded "+this.mn+" logs per "+this.gn+"ms"),this.dn=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.sn||(t.sn=t.Sn().finally((()=>{t.sn=null}))),t.sn}))()}Sn(){var t=this;return p((function*(){var e;t.yn();var i=null!==(e=t._instance.getPersistedProperty(S.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,o;t.an=0;var a=Math.min(i.length,t.pn),l=i.slice(0,a),u=He(l.map((t=>t.record)),t.xn(),null!==(n=t.nn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.Cn(u);if("too-large"===h.kind&&l.length>1)t.pn=Math.max(1,Math.floor(l.length/2)),t.I.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+t.pn);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===h.kind&&t.Di.maxBatchRecordsPerPost>t.pn&&(t.pn=Math.min(t.Di.maxBatchRecordsPerPost,t.pn+1)),yield t.Tn(l.length),i=null!==(o=t._instance.getPersistedProperty(S.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===h.kind)throw h.error}}}))()}Tn(t){var e=this;return p((function*(){var i,r=Math.max(0,t-e.an),s=null!==(i=e._instance.getPersistedProperty(S.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(S.LogsQueue,s.slice(r)),yield e.rn()}))()}xn(){return qe(this.Di,this._instance.getLibraryId(),this._instance.getLibraryVersion())}kn(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(S.LogsQueue))&&void 0!==e?e:[];this.cn>i.length||(i.shift(),this.an++,this.I.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(S.LogsQueue,i),this.vn>i.length?this.Mn():this.bn()}}Mn(t){void 0===t&&(t=this.fn),this.En||(this.En=Oe((()=>{this.En=void 0,this.bn()}),t))}In(){var t=Math.min(Math.max(0,this.ln-1),6);return this.fn*Math.pow(2,t)}Rn(){var t=this._instance.getPersistedProperty(S.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return p((function*(){e.yn();var i=e.flush().catch((()=>{}));void 0!==t?yield Ce(i,t):yield i}))()}flushWithTimeout(t){var e=this;return p((function*(){var i=e.flush();yield Ce(i,t,(()=>{i.catch((()=>{}))}))}))()}bn(){this.flush().then((()=>{this.ln=0}),(t=>{this.ln++,this.I.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Rn()&&this.Mn(this.In())}))}yn(){this.En&&(clearTimeout(this.En),this.En=void 0)}};var We=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ge(t){return String(t)+"000000"}function Ke(t,e,i,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+s}let Je=class{constructor(t,e,i){this._instance=t,this.Di=e,this.I=i,this.Pn=new Map,this.sn=null,this.An=!1,this.Fn=new Map,this.On=new Set,this.Ln=0}count(t,e,i){void 0===e&&(e=1),this.$n({name:t,type:"count",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(t,e,i){this.$n({name:t,type:"gauge",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(t,e,i){this.$n({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var t=this,e=this.sn,i=function(){var i=p((function*(){e&&(yield e.catch((()=>{}))),yield t.Dn()}));return function(){return i.apply(this,arguments)}}(),r=i().finally((()=>{this.sn===r&&(this.sn=null)}));return this.sn=r,r}drainWindow(){if(0===this.Pn.size)return null;var t=this.Pn;return this.Pn=new Map,this.An=!1,this.Fn=new Map,this.On=new Set,this.Nn(t)}reset(){this.Ln++,this.yn(),this.Pn=new Map,this.sn=null,this.An=!1,this.Fn=new Map,this.On=new Set}$n(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this._n(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.I.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=e.attributes?_({},e.attributes):void 0,r=Ke(e.type,e.name,e.unit,i)}catch(t){return void this.I.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var s=this.Pn.get(r);if(!s){if(!this.qn())return;s={name:e.name,type:e.type,unit:e.unit,attributes:i,windowStartMs:Date.now()},this.Pn.set(r,s)}var n=this.Fn.get(e.name);void 0===n?this.Fn.set(e.name,e.type):n===e.type||this.On.has(e.name)||(this.On.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.jn(s,e.value),this.Mn()}else this.I.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}qn(){return this.Di.maxSeriesPerFlush>this.Pn.size||(this.An||(this.An=!0,this.I.warn("Metric series cap reached ("+this.Di.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}jn(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(We.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,We)]+=1}}_n(t){var e=this.Di.beforeSend;if(!e)return t;var i=X(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for metric:",t),null}return r}Mn(){this.En||(this.En=Oe((()=>{this.En=void 0,this.flush().catch((t=>{this.I.error("Metrics flush failed:",t)}))}),this.Di.flushIntervalMs))}yn(){this.En&&(clearTimeout(this.En),this.En=void 0)}Dn(){var t=this;return p((function*(){if(0!==t.Pn.size){var e=t.Pn;t.Pn=new Map,t.An=!1,t.Fn=new Map,t.On=new Set;var i=t.Ln,r=yield t._instance.Bn(t.Nn(e));if(i===t.Ln)switch(r.kind){case"ok":return;case"retry-later":return t.Hn(e),void t.Mn();case"too-large":return void t.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.I.error("Failed to send metrics batch:",r.error)}}}))()}Nn(t){return e=this.Un(t),i=function(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}(this.Di,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ne(i)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,i,r,s}Un(t){var e=Ge(Date.now()),i=new Map;for(var r of t.values()){var s,n=Ke(r.type,r.name,r.unit,void 0),o=i.get(n);o||(o=_({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},i.set(n,o));var a=Ne(null!==(s=r.attributes)&&void 0!==s?s:{},this.I),l=Ge(r.windowStartMs);if("count"===r.type){var u,h={attributes:a,startTimeUnixNano:l,timeUnixNano:e,asDouble:null!==(u=r.total)&&void 0!==u?u:0};o.sum.dataPoints.push(h)}else if("gauge"===r.type){var d,v={attributes:a,timeUnixNano:e,asDouble:null!==(d=r.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(v)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:e,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:We})}return Array.from(i.values())}Hn(t){var e,i;for(var r of t){var s=r[0],n=r[1],o=this.Pn.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.qn()&&this.Pn.set(s,n)}}};var Ye,Qe,Xe;function Ze(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Xe&&i.length===Qe||(Qe=i.length,Xe=i.reduce(((i,r)=>{Ye||(Ye={});var s=Ye[r];if(s)i[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=e[r];if(l&&u){i[l]=u,Ye[r]=[l,u];break}}return i}),{})),Xe}}class ti{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var e=this;return p((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&X(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var i,r;return null!=t.cause&&(i=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),_({},t,{cause:i,stack:r})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return p((function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i}))()}convertToExceptionList(t,e){var i,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(i=e.type)&&void 0!==i?i:"generic",handled:null===(r=e.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,_({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:Ze(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,i){void 0===i&&(i=0);var r=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return _({},e,{syntheticException:0==i?e.syntheticException:void 0,mechanism:t,apply:t=>r(t,i),next:t=>r(t,i+1)})}}var ei="?";function ii(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?ei:i,in_app:!(null!=e&&e.startsWith("webkit-masked-url://"))&&"<anonymous>"!==e};return it(r)||(n.lineno=r),it(s)||(n.colno=s),n}var ri=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:ei,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},si=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ni=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,oi=/\((\S*)(?::(\d+))(?::(\d+))\)/,ai=(t,e)=>{var i=si.exec(t);if(i)return ii(e,i[1],ei,+i[2],+i[3]);var r=ni.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=oi.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=ri(r[1]||ei,r[2]);return ii(e,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},li=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ui=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,hi=(t,e)=>{var i=li.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ui.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||ei,o=ri(n,s);return ii(e,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},di=/\(error: (.*)\)/;class vi{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=rt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return ft(t,"DOMException")}isDOMError(t){return ft(t,"DOMError")}}class ci{match(t){return pt(t)}coerce(t,e){var i,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,e),stack:null!=r?r:null==(i=e.syntheticException)?void 0:i.stack,cause:t.cause?e.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class fi{constructor(){}match(t){return!!ft(t,"ErrorEvent")&&(null!=t.error||this.di(t))}coerce(t,e){var i;if(null!=t.error)return e.apply(t.error);var r=e.apply(t.message);return _({},r,{stack:null!==(i=this.vi(t))&&void 0!==i?i:r.stack,synthetic:!0})}di(t){return rt(t.message)&&t.message.length>0}vi(t){var e,i,r=t,s=null!==(e=r.lineno)&&void 0!==e?e:0,n=null!==(i=r.colno)&&void 0!==i?i:0;if(rt(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var pi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class _i{match(t){return"string"==typeof t}coerce(t,e){var i,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(pi);return r&&(e=r[1],i=r[2]),[e,i]}}var gi=["fatal","error","warning","log","info","debug"];function mi(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class yi{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,s=this.getErrorPropertyFromObject(t);return s?e.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(_t(t))return t.constructor.name;var e="name"in t?t.name:void 0;return rt(e)&&!st(e)?e:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+mi(t)}isSeverityLevel(t){return rt(t)&&!st(t)&&gi.indexOf(t)>=0}getStack(t){try{return rt(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:rt(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(pt(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class bi{match(t){return _t(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+mi(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class wi{match(t){return ct(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class xi{match(t){return ft(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!_t(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return ct(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Si="$message",Ei="$timestamp",ki=new Set([Si,Ei]),$i={enabled:!0,max_bytes:32768};function Ti(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:$i.enabled,max_bytes:Ri(t.max_bytes,$i.max_bytes)}:_({},$i)}class Pi{constructor(t){this.zn=[],this.Wn=0,this.Di=Ti(t)}setConfig(t){this.Di=Ti(t),this.Vn()}add(t){var e=function(t){var e;try{e=K(t)}catch(t){return}try{var i=JSON.parse(e);if(!tt(i))return;var r=i,s=r[Si],n=r[Ei];if(!rt(s)||0===s.trim().length)return;if(!rt(n)&&!at(n))return;return{step:r,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Di.max_bytes||(this.zn.push({step:e.step,bytes:i}),this.Wn+=i,this.Vn())}}getAttachable(){return this.zn.map((t=>t.step))}clear(){this.zn=[],this.Wn=0}size(){return this.zn.length}Vn(){for(;this.Wn>this.Di.max_bytes&&this.zn.length>0;){var t=this.zn.shift();t&&(this.Wn-=t.bytes)}}}function Ri(t,e){if(!at(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var Oi=function(e,i){var r=(void 0===i?{}:i).debugEnabled,s={F(i){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!it(t.console)&&t.console){for(var s=("__rrweb_original__"in t.console[i]?t.console[i].__rrweb_original__:t.console[i]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];s(e,...o)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("error",...e)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(t){s.error("You must initialize PostHog before calling "+t)},createLogger:(t,i)=>Oi(e+" "+t,i)};return s},Ci=Oi("[PostHog.js]"),Ii=Ci.createLogger,Ai=Ii("[ExternalScriptsLoader]"),Fi=t=>{var e=null==r?void 0:r.querySelectorAll("script");if(e)for(var i=0;e.length>i;i++)if(e[i].src===t||e[i].getAttribute("src")===t)return e[i]},Mi=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return Ai.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=Fi(e);if(s){if(s.__posthog_loading_callback_fired)return i();var n=s.__posthog_loading_error;return n?i(n):(s.addEventListener("load",(t=>{s.__posthog_loading_callback_fired=!0,i(void 0,t)})),void s.addEventListener("error",(t=>{s.__posthog_loading_error=t,i(t)})))}var o=()=>{if(!r)return i("document not found");if(Fi(e))return Mi(t,e,i);var s=r.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=e,s.onload=t=>{s.__posthog_loading_callback_fired=!0,i(void 0,t)},s.onerror=t=>{s.__posthog_loading_error=t,i(t)},t.config.prepare_external_dependency_script&&(s=t.config.prepare_external_dependency_script(s)),!s)return i("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)r.head.appendChild(s);else{var n,o=r.querySelectorAll("body > script");o.length>0?null==(n=o[0].parentNode)||n.insertBefore(s,o[0]):r.body.appendChild(s)}};null!=r&&r.body?o():null==r||r.addEventListener("DOMContentLoaded",o)},Di={},Ni=(t,e)=>{var i="/static/"+e+".js?v="+t.version;if("toolbar"===e){var r=3e5;i=i+"&t="+Math.floor(Date.now()/r)*r}return t.requestRouter.endpointFor("assets",i)};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if("remote-config"!==e){var r=t.config.strict_script_versioning;if(r){var s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js"),n=Di[s];if("fallback"===r&&n){if(Fi(n))return void Mi(t,n,i);delete Di[s]}Mi(t,s,"fallback"===r?(r,n)=>{if(r)if("string"==typeof r)i(r);else{var o,a=Ni(t,e);Di[s]=a;var l=Fi(s);null==l||null==(o=l.parentNode)||o.removeChild(l),Mi(t,a,i)}else i(void 0,n)}:i)}else Mi(t,Ni(t,e),i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");Mi(t,o,i)}},v.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var r=t.requestRouter.endpointFor("api",e);Mi(t,r,i)};c.DEBUG=!1,c.LIB_VERSION="1.418.11",c.LIB_NAME="web";var Ui="$people_distinct_id",Li="distinct_id",ji="$device_id",Bi="$device_model",zi="__alias",qi="__timers",Hi="$autocapture_disabled_server_side",Vi="$heatmaps_enabled_server_side",Wi="$exception_capture_enabled_server_side",Gi="$error_tracking_suppression_rules",Ki="$error_tracking_capture_extension_exceptions",Ji="$web_vitals_enabled_server_side",Yi="$dead_clicks_enabled_server_side",Qi="$product_tours_enabled_server_side",Xi="$web_vitals_allowed_metrics",Zi="$session_recording_remote_config",tr="$replay_sample_rate",er="$replay_override_sampling",ir="$replay_override_linked_flag",rr="$replay_override_url_trigger",sr="$replay_override_event_trigger",nr="$sesid",or="$session_is_sampled",ar="$enabled_feature_flags",lr="$active_feature_flags",ur="$early_access_features",hr="$feature_flag_details",dr="$feature_flag_payloads",vr="$feature_flag_request_id",cr="$minimal_flag_called_events",fr="$override_feature_flags",pr="$override_feature_flag_payloads",_r="$stored_person_properties",gr="$stored_group_properties",mr="$groups",yr="$surveys",br="$surveys_loaded_at",wr="$surveys_activated",xr="$surveys_activated_session",Sr="$surveys_activated_timestamps",Er="ph_product_tours",kr="$flag_call_reported",$r="$flag_call_reported_session_id",Tr="$feature_flag_errors",Pr="$feature_flag_evaluated_at",Rr="$user_state",Or="$client_session_props",Cr="$capture_rate_limit",Ir="$initial_campaign_params",Ar="$initial_referrer_info",Fr="$initial_person_info",Mr="$epp",Dr="$posthog_cookieless",Nr="$cookieless_mode",Ur="$sdk_debug_extensions_init_method",Lr="$sdk_debug_extensions_init_time_ms",jr="$sdk_debug_recording_script_not_loaded",Br="PostHog loadExternalDependency extension not found.",zr="on_reject",qr="always",Hr="anonymous",Vr="identified",Wr="identified_only",Gr="visibilitychange",Kr="beforeunload",Jr="$pageview",Yr="$pageleave",Qr="$identify",Xr="$groupidentify";function Zr(t,e){X(t)&&t.forEach(e)}function ts(t,e){if(!ot(t))if(X(t))t.forEach(e);else if(ht(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)Y.call(t,i)&&e(t[i],i)}var es=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function is(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var rs=function(t){try{return t()}catch(t){return}},ss=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,i)}catch(t){Ci.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ci.critical(t)}}},ns=function(t){var e={};return ts(t,(function(t,i){(rt(t)&&t.length>0||at(t))&&(e[i]=t)})),e};var os=["herokuapp.com","vercel.app","netlify.app"];function as(t){var e=null==t?void 0:t.hostname;if(!rt(e))return!1;var i=e.split(".").slice(-2).join(".");for(var r of os)if(i===r)return!1;return!0}function ls(t,e,i,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(e,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function us(t){return"ph_toolbar_internal"===t.name}var hs=t=>{if(r){try{for(var e=t+"=",i=r.cookie.split(";").filter((t=>t.length)),s=0;i.length>s;s++){for(var n=i[s];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return at(t)&&isFinite(t)&&Math.floor(t)===t});class ds{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|e>>>8,s[7]=e,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new ds(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new ds(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class vs{generate(){var t=this.generateOrAbort();if(!it(t))return t;this.Rr=0;var e=this.generateOrAbort();if(it(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t=Date.now();if(t>this.Rr)this.Rr=t,this.Ar();else{if(this.Rr>=t+1e4)return;this.Lr++,this.Lr>4398046511103&&(this.Rr++,this.Ar())}return ds.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 ps}}var cs,fs=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!it(t.crypto)&&crypto.getRandomValues&&(fs=t=>crypto.getRandomValues(t));class ps{nextUint32(){return this.ft.length>this.Fr||(fs(this.ft),this.Fr=0),this.ft[this.Fr++]}constructor(){this.ft=new Uint32Array(8),this.Fr=1/0}}var _s=()=>gs().toString(),gs=()=>(cs||(cs=new vs)).generate(),ms="",ys=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var bs={Nr:()=>!!r,jr(t){Ci.error("cookieStore error: "+t)},Pr:hs,Br(t){var e;try{e=JSON.parse(bs.Pr(t))||{}}catch(t){}return e},Dr(t,e,i,s,n){if(!r)return!1;try{var o="",a="",l=function(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=r),ms)return ms;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),s=Math.min(i.length,8),n="dmn_chk_"+_s();!ms&&s--;){var o=i.slice(s).join("."),a=n+"=1;domain=."+o+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(n)&&(e.cookie=a+";max-age=0",ms=o)}return ms}(t);if(!i){var s=(t=>{var e=t.match(ys);return e?e[0]:""})(t);s!==i&&Ci.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(r.location.hostname,s);if(i){var u=new Date;u.setTime(u.getTime()+864e5*i),o="; expires="+u.toUTCString()}n&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(e))+o+"; SameSite=Lax; path=/"+l+a;return h.length>3686.4&&Ci.warn("cookieStore warning: large cookie, len="+h.length),r.cookie=h,!0}catch(t){return!1}},qr(t,e){if(null!=r&&r.cookie)try{bs.Dr(t,"",-1,e)}catch(t){return}}},ws=null,xs={Nr(){if(!nt(ws))return ws;var e=!0;if(it(t))e=!1;else try{var i="__mplssupport__";xs.Dr(i,"xyz"),'"xyz"'!==xs.Pr(i)&&(e=!1),xs.qr(i)}catch(t){e=!1}return e||Ci.error("localStorage unsupported; falling back to cookie store"),ws=e,e},jr(t){Ci.error("localStorage error: "+t)},Pr(e){try{return null==t?void 0:t.localStorage.getItem(e)}catch(t){xs.jr(t)}return null},Br(t){try{return JSON.parse(xs.Pr(t))||{}}catch(t){}return null},Dr(e,i){try{return null==t||t.localStorage.setItem(e,JSON.stringify(i)),!0}catch(t){xs.jr(t)}return!1},qr(e){try{null==t||t.localStorage.removeItem(e)}catch(t){xs.jr(t)}}},Ss=[_r,lr,ar,hr,dr,vr,Pr,Tr,kr],Es=[ji,Li,nr,or,Mr,Fr,Rr],ks=t=>t+"_cpm",$s=["__proto__","constructor","prototype"],Ts=t=>{if(!tt(t))return{};var e={};return Object.keys(t).forEach((i=>{-1===$s.indexOf(i)&&(e[i]=t[i])})),e},Ps=function(t,e){void 0===e&&(e=[]);var i={};return[...Es,...e].forEach((e=>{var r=t[e];it(r)||nt(r)||""===r||(i[e]=r)})),i},Rs=t=>{for(var e=5381,i=2166136261,r=0;t.length>r;r++){var s=t.charCodeAt(r);e=33*e^s,i=Math.imul(i^s,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(i>>>0).toString(36)},Os=(t,e)=>({p:e,f:Rs(JSON.stringify(t))}),Cs=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{var i=bs.Br(ks(t)),r=(null==i?void 0:i.f)===Rs(e)&&X(i.p);return{properties:r?i.p:[],isValid:r}}catch(t){return{properties:[],isValid:!1}}},Is=(t,e)=>e+"|"+(bs.Pr(ks(t))||""),As={},Fs={Nr:()=>!0,jr(t){Ci.error("memoryStorage error: "+t)},Pr:t=>As[t]||null,Br:t=>As[t]||null,Dr:(t,e)=>(As[t]=e,!0),qr(t){delete As[t]}},Ms=null,Ds={Nr(){if(!nt(Ms))return Ms;if(Ms=!0,it(t))Ms=!1;else try{var e="__support__";Ds.Dr(e,"xyz"),'"xyz"'!==Ds.Pr(e)&&(Ms=!1),Ds.qr(e)}catch(t){Ms=!1}return Ms},jr(t){Ci.error("sessionStorage error: ",t)},Pr(e){try{return null==t?void 0:t.sessionStorage.getItem(e)}catch(t){Ds.jr(t)}return null},Br(t){try{return JSON.parse(Ds.Pr(t))||null}catch(t){}return null},Dr(e,i){try{return null==t||t.sessionStorage.setItem(e,JSON.stringify(i)),!0}catch(t){Ds.jr(t)}return!1},qr(e){try{null==t||t.sessionStorage.removeItem(e)}catch(t){Ds.jr(t)}}};class Ns{constructor(t){this._instance=t}get Di(){return this._instance.config}get consent(){return this.Gn()?0:this.Zn}isOptedOut(){return this.Di.cookieless_mode===qr||this.isRejected()||-1===this.consent&&this.Di.cookieless_mode===zr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Di.opt_out_capturing_by_default}optInOut(t){this.Qn.Dr(this.Jn,t?1:0,this.Di.cookie_expiration,this.Di.cross_subdomain_cookie,this.Di.secure_cookie)}reset(){this.Qn.qr(this.Jn,this.Di.cross_subdomain_cookie)}get Jn(){var t=this._instance.config,e=t.token,i=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(i?i+e:"__ph_opt_in_out_"+e)}get Zn(){var t=this.Qn.Pr(this.Jn);return yt(t)?1:V(bt,t)?0:-1}get Qn(){var t=this.Di.opt_out_capturing_persistence_type,e="localStorage"===t?xs:bs;if(!this.Kn||this.Kn!==e){this.Kn=e;var i="localStorage"===t?bs:xs;i.Pr(this.Jn)&&(this.Kn.Pr(this.Jn)||this.optInOut(yt(i.Pr(this.Jn))),i.qr(this.Jn,this.Di.cross_subdomain_cookie))}return this.Kn}Gn(){return!!this.Di.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,v.doNotTrack].some((t=>yt(t)))}}function Us(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!Z(r))return e;try{var s=r(e);return rt(s)&&s?s:e}catch(t){return Ci.error("Error in get_current_url, falling back to window.location.href",t),e}}var Ls="__POSTHOG_TOOLBAR__",js=1,Bs=3,zs=11;function qs(t){return t instanceof Element&&(t.id===Ls||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Hs(t){return!!t&&t.nodeType===js}function Vs(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Ws(t){return!!t&&t.nodeType===Bs}function Gs(t){return!!t&&t.nodeType===zs&&Hs(t.host)}var Ks=1e3;function Js(t){return t?W(t).split(/\s+/):[]}function Ys(e,i){var r=function(e){var i,r=null==t||null==(i=t.location)?void 0:i.href;return it(r)?void 0:Us(e,r)}(i);return!!(r&&e&&e.some((t=>r.match(t))))}function Qs(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Js(e)}function Xs(t){return ot(t)?null:W(t).split(/(\s+)/).filter((t=>Sn(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Zs(t){var e="";return fn(t)&&!pn(t)&&t.childNodes&&t.childNodes.length&&ts(t.childNodes,(function(t){var i;Ws(t)&&t.textContent&&(e+=null!==(i=Xs(t.textContent))&&void 0!==i?i:"")})),W(e)}function tn(t){var e;return it(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var en=["a","button","form","input","select","textarea","label"];function rn(t,e){if(it(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function sn(t){var e=t.parentNode;return!(!e||!Hs(e))&&e}var nn=[".ph-no-autocapture","[data-ph-no-autocapture]"],on=["next","previous","prev",">","<"],an=[...on,"+","-","−","–"],ln=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,un=[".ph-no-rageclick",".ph-no-capture"],hn=["","text","search","email","password","url","tel","number"];function dn(e,i){if(!t||vn(e))return!1;var r,s,n,o,a;if(ut(i)?(r=!!i&&un,s=void 0,n=!1):(r=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:un,s=null==i?void 0:i.content_ignorelist,n=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===r)return!1;if(n&&function(t){return!(!t||!Hs(t))&&(!!Vs(t,"textarea")||(Vs(t,"input")?V(hn,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(e))return!1;var l=cn(e,!1).targetElementList;return!function(t,e){if(!1===t||it(t))return!1;var i;if(!0===t)i=on;else{if(!X(t))return!1;if(t.length>10)return Ci.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var e=t.safeText,r=t.ariaLabel;return i.some((t=>ln(e,t)||ln(r,t)))}))}(s,l.map((t=>{var e;return{safeText:Zs(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!rn(l,r)}var vn=t=>!t||Vs(t,"html")||!Hs(t),cn=(e,i)=>{if(!t||vn(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[e],n=e;n.parentNode&&!Vs(n,"body");)if(Gs(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=sn(n);if(!o)break;if(i||en.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=!0)}catch(t){}s.push(o),n=o}return{parentIsUsefulElement:r,targetElementList:s}};function fn(t){for(var e=new Set,i=0,r=t;r.parentNode&&!Vs(r,"body");r=r.parentNode){if(i++>=Ks||e.has(r))return!1;e.add(r);var s=Qs(r);if(V(s,"ph-sensitive")||V(s,"ph-no-capture"))return!1}if(V(Qs(t),"ph-include"))return!0;var n=t.type||"";if(rt(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!rt(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function pn(t){return!!(Vs(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Vs(t,"select")||Vs(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var _n=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}))$"),gn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,mn=[16,15,14,13],yn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),bn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),wn=/[0-9A-Za-z_]/;function xn(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;i&&(s*=2)>9&&(s-=9),e+=s,i=!i}return e%10==0}function Sn(t,e){if(void 0===e&&(e=!0),ot(t))return!1;if(rt(t)){t=W(t);var i=e?_n.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(gn.lastIndex=0;e=gn.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of mn){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(_n.test(a)&&xn(a))return!0}}}return!1}(t);if(i)return!1;var r=e?yn.test(t):function(t){var e;for(bn.lastIndex=0;e=bn.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&wn.test(i)&&wn.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function En(t){var e=Zs(t);return Sn(e=(e+" "+kn(t)).trim())?e:""}function kn(t){var e="";return t&&t.childNodes&&t.childNodes.length&&ts(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Zs(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+kn(t)).trim())}catch(t){Ci.error("[AutoCapture]",t)}})),e}function $n(t){return t.replace(/"|\\"/g,'\\"')}function Tn(t){var e=t.attr__class;if(e)return X(e)?e:Js(e)}var Pn=Ii("[Dead Clicks]"),Rn=()=>!0,On=t=>{var e,i=!(null==(e=t.instance.persistence)||!e.get_property(Yi)),r=t.instance.config.capture_dead_clicks;return ut(r)?r:!!tt(r)||i};class Cn{get lazyLoadedDeadClicksAutocapture(){return this.Yn}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Yi]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Xn((()=>{this.ts()})):this.stop()}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?Pn.error("failed to load script",e):t()}))}ts(){var t;if(r){if(!this.Yn&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=tt(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Yn=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Yn.start(r),Pn.info("starting...")}}else Pn.error("`document` not found. Cannot start.")}stop(){this.Yn&&(this.Yn.stop(),this.Yn=void 0,Pn.info("stopping..."))}}var In=Ii("[SegmentIntegration]");var An="posthog-js";function Fn(t,e){var i=void 0===e?{}:e,r=i.organization,s=i.projectId,n=i.prefix,o=i.severityAllowList,a=void 0===o?["error"]:o,l=i.sendExceptionsToPostHog,u=void 0===l||l;return e=>{var i,o,l,h,d;if("*"!==a&&!a.includes(e.level)||!t.__loaded)return e;e.tags||(e.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());e.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(e.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var c,f=(null==(i=e.exception)?void 0:i.values)||[],p=f.map((t=>_({},t,{stacktrace:t.stacktrace?_({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>_({},t,{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null==(o=f[0])?void 0:o.value)||e.message,$exception_type:null==(l=f[0])?void 0:l.type,$exception_level:e.level,$exception_list:p,$sentry_event_id:e.event_id,$sentry_exception:e.exception,$sentry_exception_message:(null==(h=f[0])?void 0:h.value)||e.message,$sentry_exception_type:null==(d=f[0])?void 0:d.type,$sentry_tags:e.tags};return r&&s&&(g.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+e.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(g)),e}}class Mn{constructor(t,e,i,r,s,n){this.name=An,this.setupOnce=function(o){o(Fn(t,{organization:e,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Dn{constructor(t){this.es=(t,e,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Ci.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.rs=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.ns()}ns(){var t;this.ss=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.es)}destroy(){var t;null==(t=this.ss)||t.call(this),this.ss=void 0}doPageView(e,i){var r,s=this.os(e,i);return this.rs={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var e;return this.os(t,null==(e=this.rs)?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.rs)?void 0:t.pageViewId}}os(t,e){var i=this.rs;if(!i)return{$pageview_id:e};var r={$pageview_id:e,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,u=s.lastContentY,h=s.maxContentY;if(!(it(n)||it(o)||it(a)||it(l)||it(u)||it(h))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),h=Math.ceil(h);var d=n>1?wt(o/n,0,1,Ci):1,v=n>1?wt(a/n,0,1,Ci):1,c=l>1?wt(u/l,0,1,Ci):1,f=l>1?wt(h/l,0,1,Ci):1;r=es(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:f})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(t.getTime()-i.timestamp.getTime())/1e3),r}}var Nn=["flags","surveys"],Un={[Ui]:{exposure:"hidden"},[zi]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[qi]:{exposure:"hidden"},[Hi]:{exposure:"event"},[Vi]:{exposure:"hidden"},[Wi]:{exposure:"event"},[Gi]:{exposure:"hidden"},[Ki]:{exposure:"event"},[Ji]:{exposure:"event"},[Yi]:{exposure:"event"},[Qi]:{exposure:"hidden"},[Xi]:{exposure:"event"},[Zi]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[nr]:{exposure:"hidden"},[or]:{exposure:"event"},[tr]:{exposure:"event",shouldSkipFromEventProperties:t=>nt(t)},$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"},[ar]:{exposure:"hidden",storageGroup:"flags"},[lr]:{exposure:"hidden",storageGroup:"flags"},[ur]:{exposure:"hidden"},[hr]:{exposure:"hidden",storageGroup:"flags"},[dr]:{exposure:"hidden",storageGroup:"flags"},[vr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[cr]:{exposure:"hidden",storageGroup:"flags"},[fr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[_r]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[yr]:{exposure:"hidden",storageGroup:"surveys"},[br]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[wr]:{exposure:"event"},[xr]:{exposure:"hidden"},[Sr]:{exposure:"hidden"},[Er]:{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"},[kr]:{exposure:"hidden"},[$r]:{exposure:"hidden"},[mr]:{exposure:"event"},[Tr]:{exposure:"hidden"},[Pr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Rr]:{exposure:"hidden"},[Or]:{exposure:"hidden"},[Cr]:{exposure:"hidden"},[Ir]:{exposure:"hidden"},[Ar]:{exposure:"hidden"},[Fr]:{exposure:"hidden"},[Mr]:{exposure:"hidden"},[er]:{exposure:"event"},[ir]:{exposure:"event"},[rr]:{exposure:"event"},[sr]:{exposure:"event"},[Ur]:{exposure:"event"},[Lr]:{exposure:"event"},[jr]:{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"},$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"}},Ln=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],jn=t=>{var e=Un[t];if(e)return e;for(var i of Ln){var r=i[1];if(0===t.indexOf(i[0]))return r}},Bn=(t,e)=>{try{return JSON.stringify(t,((t,e)=>"bigint"==typeof e?e.toString():e),e)}catch(e){return K(t)}},zn=t=>{var e=null==r?void 0:r.createElement("a");return it(e)?null:(e.href=t,e)},qn=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!X(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(t){Ci.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Hn=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],h=0;l.length>h;h++){var d=l[h].split("=");X(d)&&(e.includes(d[0])?u.push(d[0]+"="+i):u.push(l[h]))}var v=a;return null!=o&&(v+="?"+u.join("&")),null!=s&&(v+="#"+s),v},Vn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Wn=(t,e)=>t>=e&&h(),Gn=(t,e,i,r)=>{if(0===t){if(h()){var s=e+1;return s===i&&r(),s}return e}return 0},Kn="https?://(.*)",Jn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Yn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Jn],Qn="<masked>",Xn=["li_fat_id"];function Zn(t,e,i){if(!r)return{};var s,n=e?[...Jn,...i||[]]:[],o=to(Hn(r.URL,n,Qn),t),a=(s={},ts(Xn,(function(t){var e=hs(t);s[t]=e||null})),s);return es(a,o)}function to(t,e){var i=Yn.concat(e||[]),r={};return ts(i,(function(e){var i=qn(t,e);r[e]=i||null})),r}function eo(t){var e=function(t){return t?0===t.search(Kn+"google.([^/?]*)")?"google":0===t.search(Kn+"bing.com")?"bing":0===t.search(Kn+"yahoo.com")?"yahoo":0===t.search(Kn+"duckduckgo.com")?"duckduckgo":null:null}(t),i="yahoo"!=e?"q":"p",s={};if(!nt(e)){s.$search_engine=e;var n=r?qn(r.referrer,i):"";n.length&&(s.ph_keyword=n)}return s}function io(){return navigator.language||navigator.userLanguage}var ro="$direct";function so(){return(null==r?void 0:r.referrer)||ro}function no(t,e,i){void 0===i&&(i=!1);var r=t?[...Jn,...e||[]]:[],n=i?Re(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:so().substring(0,1e3),u:o?Hn(o,r,Qn):void 0}}function oo(t,e){var i;void 0===e&&(e=!1);var r=t.r,s=t.u,n=e?Re(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==ro?ro:null==(i=zn(r))?void 0:i.host};if(n){o.$current_url=n;var a=zn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=to(n);es(o,l)}if(r){var u=eo(r);es(o,u)}return o}function ao(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function lo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var uo={flags:Pr,surveys:br},ho=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],vo=t=>t+"_cookie_identity_change_pending",co="main",fo=(t,e)=>{ts(t,((i,r)=>{var s=jn(r);s&&"event"!==s.exposure||{}.hasOwnProperty.call(e,r)||delete t[r]}))};class po{constructor(e,i,r){if(void 0===r&&(r=!0),this.ls={},this.us=!1,this.hs=!1,this.ds=!1,this.vs=!1,this.Di=e,this.cs=r,this.props={},this.fs=void 0,this.ps=(t=>{var e="";return t.token&&(e=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+e+"_posthog"})(e),this.Qn=this.gs(e),this.hs=this.ys(e),this.load(),e.debug&&Ci.info("Persistence loaded",e.persistence,_({},this.props)),this.update_config(e,e,i),this.save(),t){var s=()=>this.flush();ls(t,"beforeunload",s,{capture:!1}),ls(t,"pagehide",s,{capture:!1})}}bs(){var t,e=null==(t=this.Di)?void 0:t.persistence_save_debounce_ms;return at(e)&&e>0?e:0}_s(t){if(this.Di.cookieWinsOnConflict&&"localstorage+cookie"===this.Di.persistence.toLowerCase())if(t)try{var e=Ps(t,this.Di.cookie_persisted_properties||[]),i=Os(e,this.Di.cookie_persisted_properties||[]),r=JSON.stringify(e)+"|"+JSON.stringify(i),s=bs.Pr(this.ps)||void 0;s&&Is(this.ps,s)===r&&(this.ws=r,this.ks=s)}catch(t){}else try{var n=bs.Pr(this.ps)||void 0;this.ws=n?Is(this.ps,n):void 0,this.ks=n}catch(t){}}syncCookieProperties(){return this.Ss(this.Di)}Ss(t,e){if(void 0===e&&(e=!1),this.xs&&!e||this.vs||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;var i;try{i=bs.Pr(this.ps)||void 0}catch(t){}if(!i||i===this.ks)return!1;var r,s=Is(this.ps,i);try{r=Ts(JSON.parse(i))}catch(t){return!1}if((bs.Pr(this.ps)||void 0)!==i)return!1;this.ws=s,this.ks=i;var n=Cs(this.ps,i),o=[...Es,...n.properties],a={};if(Object.keys(r).forEach((t=>{var e=r[t];(it(e)||nt(e)||""===e||t===Rr&&e!==Hr&&e!==Vr)&&(a[t]=!0,delete r[t])})),et(r))return!1;var l=Li in r||r[Rr]===Hr||r[Rr]===Vr,u=this.props[Li],h=this.props[Rr],d=es({},this.props);[...Es,...t.cookie_persisted_properties||[]].forEach((t=>{if(-1!==o.indexOf(t)&&!(t in r)&&!a[t]&&(l||t!==Li&&t!==Rr)){var e=d[t];!n.isValid&&-1!==Es.indexOf(t)&&(!1===e||0===e)||delete d[t]}})),this.props=es(d,r),!l||Rr in r||Rr in this.props||this.Cs(Rr,Hr);var v=this.props[Li],c=this.props[Rr];return!l||v===u&&c===h||(this.ds=!0,Ds.Dr(vo(this.ps),!0),this.Ts(_r),this.Ts(lr),this.Ts(ar),this.Ts(hr),this.Ts(dr),this.Ts(vr),this.Ts(Pr),this.Ts(Tr),this.Ts(kr),c===Hr&&(h===Vr||r[Rr]===Hr||!it(u)&&v!==u)&&(fo(this.props,r),this.Ts(gr)),c===Vr?this.props.$user_id=v:delete this.props.$user_id,this.Ts(zi)),!0}consumeCookieIdentityChange(){var t=vo(this.ps),e=this.ds||!!Ds.Pr(t);return this.ds=!1,e&&Ds.qr(t),e}Ms(t){return void 0===t&&(t=!1),!(this.vs||this.xs&&!t||!this.Di.cookieWinsOnConflict||"localstorage+cookie"!==this.Di.persistence.toLowerCase()||(this.vs=!0,0))}Es(){this.vs&&(it(this.Is)||(clearTimeout(this.Is),this.Is=void 0),delete this.ls[co],this.Rs(!0))}Ps(t){if(void 0===t&&(t=!0),this.vs)try{t?this.Es():it(this.Is)||(clearTimeout(this.Is),this.Is=void 0)}finally{this.vs=!1}}isDisabled(){return!!this.xs}gs(e){-1===ho.indexOf(e.persistence.toLowerCase())&&(Ci.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i,r=function(e,i){void 0===e&&(e=[]),void 0===i&&(i=!1);var r=[...Es,...e];return _({},xs,{Br(t){try{var e,s={};try{e=bs.Pr(t)||void 0,s=e?Ts(JSON.parse(e)):{}}catch(t){}var n,o=JSON.parse(xs.Pr(t)||"{}");if(i){var a=Cs(t,e),l=[...Es,...a.properties],u={};Object.keys(s).forEach((t=>{var e=s[t];nt(e)||""===e||t===Rr&&e!==Hr&&e!==Vr||(u[t]=e)}));var h=Li in u||u[Rr]===Hr||u[Rr]===Vr;if(Object.keys(u).length>0){var d,v=o[Li],c=null!==(d=o[Rr])&&void 0!==d?d:Hr;r.forEach((t=>{if(-1!==l.indexOf(t)&&!(t in s)&&(h||t!==Li&&t!==Rr)){var e=o[t];!a.isValid&&-1!==Es.indexOf(t)&&(!1===e||0===e)||delete o[t]}})),!h||Rr in s||Rr in o||(o[Rr]=Hr),!h||(Li in u?u[Li]:o[Li])===v&&(Rr in u?u[Rr]:o[Rr])===c||(Ss.forEach((t=>delete o[t])),u[Rr]===Vr&&Li in u?o.$user_id=u[Li]:delete o.$user_id,u[Rr]!==Vr&&(delete o[mr],delete o[gr]),delete o.__alias)}n=es(o,u)}else n=es(s,o);return xs.Dr(t,n),n}catch(t){}return null},Dr(t,r,s,n,o,a){var l=xs.Dr(t,r,void 0,void 0,a);try{var u=Ps(r,e);if(Object.keys(u).length){if(i){var h=ks(t),d=Os(u,e);if(bs.Dr(h,d,s,n,o,a),bs.Pr(h)!==JSON.stringify(d)){bs.qr(h,n);var v=Ps(r);return bs.Dr(t,v,s,n,o,a),l}}bs.Dr(t,u,s,n,o,a)}}catch(t){xs.jr(t)}return l},qr(e,i){try{null==t||t.localStorage.removeItem(e),bs.qr(e,i),bs.qr(ks(e),i)}catch(t){xs.jr(t)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&xs.Nr()?(i=xs,s=!0):"localstorage+cookie"===n&&r.Nr()?(i=r,s=!0):"sessionstorage"===n&&Ds.Nr()?i=Ds:"memory"===n?i=Fs:"cookie"===n?i=bs:r.Nr()?(i=r,s=!0):i=bs,this.us=s,i}As(t){return this.ps+"__"+t}ys(t){return this.us&&!!t.split_storage}properties(){var t={};return ts(this.props,((e,i)=>{var r=jn(i);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e))return;t[i]=e}})),t}load(t){if(void 0===t&&(t=!1),!this.xs||t){var e=this.Di.cookieWinsOnConflict&&"localstorage+cookie"===this.Di.persistence.toLowerCase(),i=e?xs.Br(this.ps):null,r={};if(e)try{ts(r=Ts(bs.Br(this.ps)),((t,e)=>{(it(t)||nt(t)||""===t)&&delete r[e]}))}catch(t){}var s=this.Qn.Br(this.ps);if(s&&(this.props=es({},s)),this.hs&&this.Fs(),e&&s){var n,o,a=null==i?void 0:i[Li],l=null!==(n=null==i?void 0:i[Rr])&&void 0!==n?n:Hr,u=s[Li],h=null!==(o=s[Rr])&&void 0!==o?o:Hr;if(u!==a||h!==l){this.ds=!0,Ds.Dr(vo(this.ps),!0);var d=es({},this.props);Ss.forEach((t=>delete d[t])),h===Hr&&(l===Vr||r[Rr]===Hr||!it(a)&&u!==a)&&(fo(d,r),delete d[gr]),this.props=d;var v=new Set;Ss.forEach((t=>{var e,i=null==(e=jn(t))?void 0:e.storageGroup;i&&v.add(i)})),v.forEach((t=>{var e={};ts(this.props,((i,r)=>{var s;(null==(s=jn(r))?void 0:s.storageGroup)===t&&(e[r]=i)})),et(e)?(xs.qr(this.As(t)),this.ls[t]={}):xs.Dr(this.As(t),e)&&(this.ls[t]={persisted:!0,fingerprint:this.Os(e,t)})}))}}Ds.Pr(vo(this.ps))&&(this.ds=!0)}}Fs(){for(var t of Nn){var e=xs.Br(this.As(t));if(e&&!et(e)){var i=this.Ls(t);i.persisted=!0,this.$s(t)||(i.fingerprint=this.Os(e,t)),this.Ds(t,e)||es(this.props,e)}}}$s(t){return Object.keys(this.props).some((e=>{var i;return(null==(i=jn(e))?void 0:i.storageGroup)===t}))}Ds(t,e){var i=uo[t];if(!i)return!1;var r=e[i],s=this.props[i];return at(r)&&at(s)&&s>r}refreshKey(t){var e;if(!this.xs){var i=this.hs?null==(e=jn(t))?void 0:e.storageGroup:void 0,r=i?xs.Br(this.As(i)):this.Qn.Br(this.ps);if(r&&t in r)this.Cs(t,r[t]);else{if(i){var s=this.Qn.Br(this.ps);if(s&&t in s)return void this.Cs(t,s[t])}this.Ts(t)}}}save(){if(!this.xs){var t=this.bs();t>0?it(this.Is)&&(this.Is=setTimeout((()=>{this.Is=void 0,this.Rs()}),t)):this.Rs()}}flush(){it(this.Is)||(clearTimeout(this.Is),this.Is=void 0,this.Rs())}Rs(t){void 0===t&&(t=!1),this.xs||this.vs&&!t||(t||this.syncCookieProperties(),this.hs?this.Ns():this.qs(this.Qn,this.ps,this.props,co)&&this._s(this.props))}Ns(){var t=this.js(),e=t.main,i=t.groups;for(var r of(this.qs(this.Qn,this.ps,e,co)&&this._s(e),Nn)){var s,n=i[r];(!et(n)||null!=(s=this.ls[r])&&s.persisted)&&this.qs(xs,this.As(r),n,r)}}js(){var t={},e={flags:{},surveys:{}};return ts(this.props,((i,r)=>{var s,n=null==(s=jn(r))?void 0:s.storageGroup;n?e[n][r]=i:t[r]=i})),{main:t,groups:e}}Os(t,e){if(e===co)return JSON.stringify(t)+"|"+this.Bs+"|"+this.Hs+"|"+this.Us;var i={};return ts(t,((t,e)=>{var r;i[e]=null!=(r=jn(e))&&r.volatile?"__volatile__":t})),JSON.stringify(i)}qs(t,e,i,r){var s,n=this.Ls(r);if(r!==co&&!n.dirty&&!it(n.fingerprint))return!1;try{if((s=this.Os(i,r))===n.fingerprint)return n.dirty=!1,!1}catch(t){s=void 0}return t.Dr(e,i,this.Bs,this.Hs,this.Us,this.Di.debug)?(n.dirty=!1,r!==co&&(n.persisted=!0),it(s)||(n.fingerprint=s),!0):(this.Di.debug&&Ci.warn('failed to persist storage entry "'+e+'"; will retry on next save'),!1)}remove(t){var e=(void 0===t?{}:t).keepGroupEntries,i=void 0!==e&&e;if(it(this.Is)||(clearTimeout(this.Is),this.Is=void 0),this.Qn.qr(this.ps,!1),this.Qn.qr(this.ps,!0),!i&&this.cs)for(var r of Nn)xs.qr(this.As(r));i?delete this.ls[co]:this.ls={},this.ws=void 0,this.ks=void 0}clear(){this.remove(),this.props={}}register_once(t,e,i){if(tt(t)){this.syncCookieProperties(),it(e)&&(e="None"),this.Bs=it(i)?this.zs:i;var r=!1;if(ts(t,((t,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==e||(this.Cs(i,t),r=!0)})),r)return this.save(),!0}return!1}register(t,e){if(tt(t)){this.syncCookieProperties(),this.Bs=it(e)?this.zs:e;var i=!1;if(ts(t,((e,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==e||tt(e)||X(e))&&(this.Cs(r,e),i=!0)})),i)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var e="string"==typeof t?[t]:t,i=!1;for(var r of e)r in this.props&&(this.Ts(r),i=!0);i&&this.save()}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.fs){var e=Zn(this.Di.custom_campaign_params,this.Di.mask_personal_data_properties,this.Di.custom_personal_data_properties);et(ns(e))||this.register(e),this.fs=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?eo(t):{})}update_referrer_info(){var t;this.register_once({$referrer:so(),$referring_domain:null!=r&&r.referrer&&(null==(t=zn(r.referrer))?void 0:t.host)||ro},void 0)}set_initial_person_info(){this.props[Ir]||this.props[Ar]||this.register_once({[Fr]:no(this.Di.mask_personal_data_properties,this.Di.custom_personal_data_properties,this.Di.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};ts([Ar,Ir],(e=>{var i=this.props[e];i&&ts(i,(function(e,i){t["$initial_"+G(i)]=e}))}));var e=this.props[Fr];if(e){var i=function(t,e){void 0===e&&(e=!1);var i=oo(t,e),r={};return ts(i,(function(t,e){r["$initial_"+G(e)]=t})),r}(e,this.Di.disable_capture_url_hashes);es(t,i)}return t}safe_merge(t){return ts(this.props,(function(e,i){i in t||(t[i]=e)})),t}update_config(t,e,i){var r=t.persistence!==e.persistence,s=!((t,e)=>{if(t.length!==e.length)return!1;var i=[...t].sort(),r=[...e].sort();return i.every(((t,e)=>t===r[e]))})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),n=r||s,o=t.cookieWinsOnConflict!==e.cookieWinsOnConflict,a=t.disable_persistence||!!i,l=!!this.xs&&!a;a||this.Ss(e,l),this.Di=t,!a&&(r||s||o)&&(this.ws=void 0,this.ks=void 0,this.Ss(_({},t,{cookie_persisted_properties:e.cookie_persisted_properties}),l));var u=n||o?this.gs(t):this.Qn,h=this.ys(t),d=n||h!==this.hs,v=!a&&(d||t.cross_subdomain_cookie!==this.Hs||t.secure_cookie!==this.Us)&&this.Ms(l);try{if(this.zs=this.Bs=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){var c=this.props;this.clear(),this.Qn=u,this.hs=h,this.props=c,this.save()}else o&&(this.Qn=u,a||(delete this.ls[co],this.Rs()))}finally{v&&this.Ps()}}set_disabled(t){this.xs=t,this.xs?this.remove():this.save()}set_cross_subdomain(t){t!==this.Hs&&(this.Hs=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Us&&(this.Us=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var i=this.props[qi]||{};i[t]=e,this.Cs(qi,i),this.save()}remove_event_timer(t){var e=this.props[qi]||{},i=e[t];return it(i)||(delete e[t],this.Cs(qi,e),this.save()),i}get_property(t){return this.props[t]}set_property(t,e){this.Cs(t,e),this.save()}Cs(t,e){var i;this.props[t]=e,null!=(i=jn(t))&&i.volatile||this.Ws(t)}Ts(t){delete this.props[t],this.Ws(t)}Ws(t){var e,i=null==(e=jn(t))?void 0:e.storageGroup;i&&(this.Ls(i).dirty=!0)}Ls(t){return this.ls[t]||(this.ls[t]={})}}function _o(t){var e=!0;return{dispose(){if(e){e=!1;var i=t();i&&Z(i.then)&&i.then(void 0,(()=>{}))}}}}var go={GZipJS:"gzip-js",Base64:"base64"},mo={Activation:"events",Cancellation:"cancelEvents"},yo={Button:"button",Tab:"tab",Selector:"selector"},bo={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},wo={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},xo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},So={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},Eo={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ko={Once:"once",Recurring:"recurring",Always:"always"},$o={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},To={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Po={Popover:"popover",Inline:"inline"},Ro={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},Oo={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Co={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Io=Ii("[RateLimiter]");class Ao{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var e=t.text;if(e&&e.length)try{(JSON.parse(e).quota_limited||[]).forEach((t=>{Io.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void Io.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:e})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var e,i,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(e=null==(i=this.instance.persistence)?void 0:i.get_property(Cr))&&void 0!==e?e:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var u=(at(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Vs(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(Cr,a),{isRateLimited:l,remainingTokens:a.tokens}}Gs(t){var e=this.instance.config.property_denylist;return!X(e)||!e.includes(t)}Zs(){var t;if(this.Gs("$current_url")&&this.Gs("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}Vs(t){var e,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.Zs(),o=this.Gs("$session_id")?null==(e=(i=this.instance).get_session_id)?void 0:e.call(i):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var e=this.serverLimits[t||"events"]||!1;return!1!==e&&(new Date).getTime()<e}}var Fo=Ii("[RemoteConfig]");class Mo{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Qs(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Js(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Fo.info("Using preloaded remote config",this.remoteConfig),this.Ks(this.remoteConfig),void this.Ys();if(this._instance.Xs())return void Fo.warn("Remote config is disabled. Falling back to local config.");this.Qs((t=>{if(!t)return Fo.info("No config found after loading remote JS config. Falling back to JSON."),void this.Js((t=>{this.Ks(t.json,t),this.Ys()}));this.Ks(t),this.Ys()}))}catch(t){Fo.error("Error loading remote config",t),this.Ks()}}stop(){this.ta&&(clearInterval(this.ta),this.ta=void 0)}refresh(){!this._instance.Xs()&&r&&"hidden"!==r.visibilityState&&this._instance.reloadFeatureFlags()}Ys(){var t;if(!this.ta){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.ta=setInterval((()=>{this.refresh()}),e))}}Ks(t,e){!t&&e&&(0===e.statusCode?e.error||Fo.warn("Failed to fetch remote config from PostHog."):Fo.error("Failed to fetch remote config from PostHog."));try{this._instance.Ks(t?{ok:!0,config:t}:{ok:!1})}catch(t){Fo.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){Fo.error("Error loading feature flags",t)}}}var Do=["fatal","error","warning","log","info","debug"],No=Uint8Array,Uo=Uint16Array,Lo=Uint32Array,jo=new No([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]),Bo=new No([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]),zo=new No([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qo=function(t,e){for(var i=new Uo(31),r=0;31>r;++r)i[r]=e+=1<<t[r-1];var s=new Lo(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},Ho=qo(jo,2),Vo=Ho[1];Ho[0][28]=258,Vo[258]=28;for(var Wo=qo(Bo,0)[1],Go=new Uo(32768),Ko=0;32768>Ko;++Ko){var Jo=(43690&Ko)>>>1|(21845&Ko)<<1;Go[Ko]=((65280&(Jo=(61680&(Jo=(52428&Jo)>>>2|(13107&Jo)<<2))>>>4|(3855&Jo)<<4))>>>8|(255&Jo)<<8)>>>1}var Yo=function(t,e,i){for(var r=t.length,s=0,n=new Uo(e);r>s;++s)++n[t[s]-1];var o,a=new Uo(e);for(s=0;e>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Uo(1<<e);var l=15-e;for(s=0;r>s;++s)if(t[s])for(var u=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<<h,v=d|(1<<h)-1;v>=d;++d)o[Go[d]>>>l]=u}else for(o=new Uo(r),s=0;r>s;++s)o[s]=Go[a[t[s]-1]++]>>>15-t[s];return o},Qo=new No(288);for(Ko=0;144>Ko;++Ko)Qo[Ko]=8;for(Ko=144;256>Ko;++Ko)Qo[Ko]=9;for(Ko=256;280>Ko;++Ko)Qo[Ko]=7;for(Ko=280;288>Ko;++Ko)Qo[Ko]=8;var Xo=new No(32);for(Ko=0;32>Ko;++Ko)Xo[Ko]=5;var Zo=Yo(Qo,9,0),ta=Yo(Xo,5,0),ea=function(t){return(t/8>>0)+(7&t&&1)},ia=function(t,e,i){(null==i||i>t.length)&&(i=t.length);var r=new(t instanceof Uo?Uo:t instanceof Lo?Lo:No)(i-e);return r.set(t.subarray(e,i)),r},ra=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8},sa=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8,t[r+2]|=i>>>16},na=function(t,e){for(var i=[],r=0;t.length>r;++r)t[r]&&i.push({s:r,f:t[r]});var s=i.length,n=i.slice();if(!s)return[new No(0),0];if(1==s){var o=new No(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(t,e){return t.f-e.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,h=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=h&&i[d].f>i[u].f?u++:d++],i[h++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new Uo(v+1),f=oa(i[h-1],c,0);if(f>e){r=0;var p=0,_=f-e,g=1<<_;for(n.sort((function(t,e){return c[e.s]-c[t.s]||t.f-e.f}));s>r;++r){var m=n[r].s;if(e>=c[m])break;p+=g-(1<<f-c[m]),c[m]=e}for(p>>>=_;p>0;){var y=n[r].s;e>c[y]?p-=1<<e-c[y]++-1:++r}for(;r>=0&&p;--r){var b=n[r].s;c[b]==e&&(--c[b],++p)}f=e}return[new No(c),f]},oa=function(t,e,i){return-1==t.s?Math.max(oa(t.l,e,i+1),oa(t.r,e,i+1)):e[t.s]=i},aa=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Uo(++e),r=0,s=t[0],n=1,o=function(t){i[r++]=t},a=1;e>=a;++a)if(t[a]==s&&a!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[i.subarray(0,r),e]},la=function(t,e){for(var i=0,r=0;e.length>r;++r)i+=t[r]*e[r];return i},ua=function(t,e,i){var r=i.length,s=ea(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=i[n];return 8*(s+4+r)},ha=function(t,e,i,r,s,n,o,a,l,u,h){ra(e,h++,i),++s[256];for(var d=na(s,15),v=d[0],c=d[1],f=na(n,15),p=f[0],_=f[1],g=aa(v),m=g[0],y=g[1],b=aa(p),w=b[0],x=b[1],S=new Uo(19),E=0;m.length>E;++E)S[31&m[E]]++;for(E=0;w.length>E;++E)S[31&w[E]]++;for(var k=na(S,7),T=k[0],P=k[1],R=19;R>4&&!T[zo[R-1]];--R);var O,C,I,A,F=u+5<<3,M=la(s,Qo)+la(n,Xo)+o,D=la(s,v)+la(n,p)+o+14+3*R+la(S,T)+(2*S[16]+3*S[17]+7*S[18]);if(M>=F&&D>=F)return ua(e,h,t.subarray(l,l+u));if(ra(e,h,1+(M>D)),h+=2,M>D){O=Yo(v,c,0),C=v,I=Yo(p,_,0),A=p;var N=Yo(T,P,0);for(ra(e,h,y-257),ra(e,h+5,x-1),ra(e,h+10,R-4),h+=14,E=0;R>E;++E)ra(e,h+3*E,T[zo[E]]);h+=3*R;for(var U=[m,w],L=0;2>L;++L){var j=U[L];for(E=0;j.length>E;++E)ra(e,h,N[B=31&j[E]]),h+=T[B],B>15&&(ra(e,h,j[E]>>>5&127),h+=j[E]>>>12)}}else O=Zo,C=Qo,I=ta,A=Xo;for(E=0;a>E;++E)if(r[E]>255){var B;sa(e,h,O[257+(B=r[E]>>>18&31)]),h+=C[B+257],B>7&&(ra(e,h,r[E]>>>23&31),h+=jo[B]);var z=31&r[E];sa(e,h,I[z]),h+=A[z],z>3&&(sa(e,h,r[E]>>>5&8191),h+=Bo[z])}else sa(e,h,O[r[E]]),h+=C[r[E]];return sa(e,h,O[256]),h+C[256]},da=new Lo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),va=function(){for(var t=new Lo(256),e=0;256>e;++e){for(var i=e,r=9;--r;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),ca=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function fa(t,e){void 0===e&&(e={});var i=function(){var t=4294967295;return{p(e){for(var i=t,r=0;e.length>r;++r)i=va[255&i^e[r]]^i>>>8;t=i},d(){return 4294967295^t}}}(),r=t.length;i.p(t);var s,n,o,a,l,u=(a=10+((s=e).filename&&s.filename.length+1||0),l=8,function(t,e,i,r,s,n){var o=t.length,a=new No(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!e||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=ua(l,u,t.subarray(h,d)):(l[h]=!0,u=ua(l,u,t.subarray(h,o)))}else{for(var v=da[e-1],c=v>>>13,f=8191&v,p=(1<<i)-1,_=new Uo(32768),g=new Uo(p+1),m=Math.ceil(i/3),y=2*m,b=function(e){return(t[e]^t[e+1]<<m^t[e+2]<<y)&p},w=new Lo(25e3),x=new Uo(288),S=new Uo(32),E=0,k=0,T=(h=0,0),P=0,R=0;o>h;++h){var O=b(h),C=32767&h,I=g[O];if(_[C]=I,g[O]=C,h>=P){var A=o-h;if((E>7e3||T>24576)&&A>423){u=ha(t,l,0,w,x,S,k,T,R,h-R,u),T=E=k=0,R=h;for(var F=0;286>F;++F)x[F]=0;for(F=0;30>F;++F)S[F]=0}var M=2,D=0,N=f,U=C-I&32767;if(A>2&&O==b(h-U))for(var L=Math.min(c,A)-1,j=Math.min(32767,h),B=Math.min(258,A);j>=U&&--N&&C!=I;){if(t[h+M]==t[h+M-U]){for(var z=0;B>z&&t[h+z]==t[h+z-U];++z);if(z>M){if(M=z,D=U,z>L)break;var q=Math.min(U,z-2),H=0;for(F=0;q>F;++F){var V=h-U+F+32768&32767,W=V-_[V]+32768&32767;W>H&&(H=W,I=V)}}}U+=(C=I)-(I=_[C])+32768&32767}if(D){w[T++]=268435456|Vo[M]<<18|Wo[D];var G=31&Vo[M],K=31&Wo[D];k+=jo[G]+Bo[K],++x[257+G],++S[K],P=h+M,++E}else w[T++]=t[h],++x[t[h]]}}u=ha(t,l,!0,w,x,S,k,T,R,h-R,u)}return ia(a,0,r+ea(u)+s)}(n=t,null==(o=e).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),h=u.length;return function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>e.level?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&ca(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;i.length>=r;++r)t[r+10]=i.charCodeAt(r)}}(u,e),ca(u,h-8,i.d()),ca(u,h-4,r),u}var pa=!!o||!!n,_a="text/plain",ga=!1,ma=(t,e)=>{var i=t.split("#"),r=i[1],s=i[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter((t=>t.split("=")[0]!==e)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},ya=function(t,e,i){var r;void 0===i&&(i=!0);var s=t.split("?"),n=s[0],o=s[1],a=_({},e),l=null!==(r=null==o?void 0:o.split("&").map((t=>{var e,r=t.split("="),s=r[0],n=i&&null!==(e=a[s])&&void 0!==e?e:r[1];return delete a[s],s+"="+n})))&&void 0!==r?r:[],u=function(t,e){var i,r;void 0===e&&(e="&");var s=[];return ts(t,(function(t,e){it(t)||it(e)||"undefined"===e||(i=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(e),s[s.length]=r+"="+i)})),s.join(e)}(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},ba=t=>{if(t.ea)return t.ea;var e=t.data,i=t.compression;if(e){if(i===go.GZipJS){var r=fa(function(t,e){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new No(t.length+(t.length>>>1)),s=0,n=function(t){r[s++]=t},o=0;i>o;++o){if(s+5>r.length){var a=new No(s+8+(i-o<<1));a.set(r),r=a}var l=t.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return ia(r,0,s)}(Bn(e)),{mtime:0});return{contentType:_a,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===go.Base64){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(parseInt(e,16))))):t}(Bn(e)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:Bn(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Bn(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},wa=t=>{var e,i,r=()=>"sendBeacon"===t.transport?{url:ya(t.url,{compression:go.Base64}),encodedBody:ba(_({},t,{compression:go.Base64,ea:void 0}))}:{url:ma(t.url,"compression"),encodedBody:ba(_({},t,{compression:void 0,ea:void 0}))};try{e=ba(t)}catch(e){if(O(t.compression,qn(t.url,"compression")))return Ci.error("Failed to gzip request body, sending uncompressed payload",e),r();throw e}return e&&O(t.compression,qn(t.url,"compression"))&&!((i=e.body)instanceof ArrayBuffer?R(new Uint8Array(i)):ArrayBuffer.isView(i)&&R(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(ga=!0,r()):{url:t.url,encodedBody:e}},xa=t=>{try{return wa(t)}catch(e){return Ci.error(e),void(null==t.callback||t.callback({statusCode:0,error:e}))}},Sa=function(){var t=p((function*(t){var e=Bn(t.data),i=yield function(t,e,i){return F.apply(this,arguments)}(e,c.DEBUG,{rethrow:!0});if(!i)return t;var r=yield i.arrayBuffer();return _({},t,{ea:{contentType:_a,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}}(),Ea=/Failed to fetch|NetworkError|Load failed/i,ka=t=>"TypeError"===(null==t?void 0:t.name)&&Ea.test((null==t?void 0:t.message)||""),$a=t=>{var e=xa(t);if(e){var i=e.url,r=e.encodedBody,s=null!=r?r:{},o=s.contentType,l=s.body,u=s.estimatedSize,h=new Headers;ts(t.headers,(function(t,e){h.append(e,t)})),o&&h.append("Content-Type",o);var d=null,v=!1;if(a){var c=new a;d={signal:c.signal,timeout:setTimeout((()=>{var e,i;v=!0,c.abort((e=t.timeout,(i=new Error("PostHog request timed out"+(e?" after "+e+"ms":""))).name="AbortError",i))}),t.timeout)}}var f=e=>{v&&"AbortError"===(null==e?void 0:e.name)||ka(e)?Ci.warn(e):Ci.error(e),null==t.callback||t.callback({statusCode:0,error:e})};try{var p;n(i,_({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.ia&&52428.8>(u||0),body:l,signal:null==(p=d)?void 0:p.signal},t.fetchOptions)).then((e=>e.text().then((i=>{var r={statusCode:e.status,text:i};if(200===e.status)try{r.json=JSON.parse(i)}catch(t){Ci.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Ta=t=>{try{var e,r=wa(t),s=r.url,n=r.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(i.sendBeacon(s,u))return;var h=X(t.data)?t.data:null==(e=t.data)?void 0:e.batch;if(X(h)&&h.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(h.length/2),v=e=>X(t.data)?e:_({},t.data,{batch:e});return Ta(_({},t,{data:v(h.slice(0,d))})),void Ta(_({},t,{data:v(h.slice(d))}))}Ci.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),$a(_({},t,{ia:!0}))}catch(t){Ci.warn("Beacon send failed",t)}},Pa=(t,e,i,r)=>{var s="query"===r?"POST"===e?"sent_at":"_":void 0;return ya(i===go.GZipJS?ma(t,"compression"):t,_({},s?{[s]:Date.now().toString()}:{},i===go.GZipJS?{}:{compression:i}))},Ra=[];n&&Ra.push({transport:"fetch",method:$a}),o&&Ra.push({transport:"XHR",method(t){var e=xa(t);if(e){var i=new o,r=e.encodedBody;i.open(t.method||"GET",e.url,!0);var s=null!=r?r:{},n=s.contentType,a=s.body;ts(t.headers,(function(t,e){i.setRequestHeader(e,t)})),n&&i.setRequestHeader("Content-Type",n),t.timeout&&(i.timeout=t.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var e={statusCode:i.status,text:i.responseText};if(200===i.status)try{e.json=JSON.parse(i.responseText)}catch(t){}null==t.callback||t.callback(e)}},i.send(a)}}}),null!=i&&i.sendBeacon&&Ra.push({transport:"sendBeacon",method:Ta});var Oa=3e3;class Ca{constructor(t,e){this.ra=!0,this.na=[],this.sa=wt((null==e?void 0:e.flush_interval_ms)||Oa,250,5e3,Ci.createLogger("flush interval"),Oa),this.aa=t}enqueue(t){this.na.push(t),this.oa||this.la()}unload(){this.ua();var t=this.na.length>0?this.ha():{},e=Object.values(t);[...e.filter((t=>0===t.url.indexOf("/e"))),...e.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.da(_({},t,{transport:"sendBeacon"}))}))}enable(){this.ra=!1,this.la()}la(){var t=this;this.ra||(this.oa=setTimeout((()=>{if(this.ua(),this.na.length>0){var e=this.ha(),i=function(){var i=e[r],s=(new Date).getTime();i.data&&X(i.data)&&ts(i.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.da(i)};for(var r in e)i()}}),this.sa))}da(t){try{this.aa(t)}catch(t){Ci.error(t)}}ua(){clearTimeout(this.oa),this.oa=void 0}ha(){var t={};return ts(this.na,(e=>{var i,r=e,s=(r?r.batchKey:null)||r.url;it(t[s])&&(t[s]=_({},r,{data:[]})),null==(i=t[s].data)||i.push(r.data)})),this.na=[],t}}var Ia=["retriesPerformedSoFar"];class Aa{constructor(e){this.va=!1,this.ca=3e3,this.na=[],this._instance=e,this.na=[],this.fa=!0,!it(t)&&"onLine"in t.navigator&&(this.fa=t.navigator.onLine,this.pa=()=>{this.fa=!0,this.ga()},this.ma=()=>{this.fa=!1},ls(t,"online",this.pa),ls(t,"offline",this.ma))}get length(){return this.na.length}retriableRequest(t){var e=t.retriesPerformedSoFar,i=g(t,Ia);lt(e)&&(i.url=ya(i.url,{retry_count:e})),this._instance._send_request(_({},i,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.kn(_({retriesPerformedSoFar:e},i));0===t.statusCode&&Ci.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(null!=e?e:0)+" retries.")}null==i.callback||i.callback(t)}}))}kn(t){var e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;var i=function(t){var e=3e3*Math.pow(2,t),i=e/2,r=Math.min(18e5,e),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(e),r=Date.now()+i;this.na.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),Ci.warn(s),this.va||(this.va=!0,this.ya())}ya(){if(this.ba&&clearTimeout(this.ba),0===this.na.length)return this.va=!1,void(this.ba=void 0);this.ba=setTimeout((()=>{this.fa&&this.na.length>0&&this.ga(),this.ya()}),this.ca)}ga(){var t=Date.now(),e=[],i=this.na.filter((i=>t>i.retryAt||(e.push(i),!1)));if(this.na=e,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.ba&&(clearTimeout(this.ba),this.ba=void 0),this.va=!1,it(t)||(this.pa&&(t.removeEventListener("online",this.pa),this.pa=void 0),this.ma&&(t.removeEventListener("offline",this.ma),this.ma=void 0)),this.na)){var i=e.requestOptions;try{this._instance._send_request(_({},i,{transport:"sendBeacon"}))}catch(t){Ci.error(t)}}this.na=[]}}class Fa{constructor(t){this._a=()=>{var t,e,i,r;this.wa||(this.wa={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.wa.lastScrollY=Math.ceil(n),this.wa.maxScrollY=Math.max(n,null!==(t=this.wa.maxScrollY)&&void 0!==t?t:0),this.wa.maxScrollHeight=Math.max(o,null!==(e=this.wa.maxScrollHeight)&&void 0!==e?e:0),this.wa.lastContentY=a,this.wa.maxContentY=Math.max(a,null!==(i=this.wa.maxContentY)&&void 0!==i?i:0),this.wa.maxContentHeight=Math.max(l,null!==(r=this.wa.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get ka(){return this._instance.config.scroll_root_selector}getContext(){return this.wa}resetContext(){var t=this.wa;return setTimeout(this._a,0),t}startMeasuringScrollPosition(){ls(t,"scroll",this._a,{capture:!0}),ls(t,"scrollend",this._a,{capture:!0}),ls(t,"resize",this._a)}scrollElement(){if(!this.ka)return null==t?void 0:t.document.documentElement;var e=X(this.ka)?this.ka:[this.ka];for(var i of e){var r=null==t?void 0:t.document.querySelector(i);if(r)return r}}Sa(e){var i="y"===e?"scrollTop":"scrollLeft";if(this.ka){var r=this.scrollElement();return r&&r[i]||0}return t?"y"===e?t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop||0:t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft||0:0}scrollY(){return this.Sa("y")}scrollX(){return this.Sa("x")}}var Ma=t=>no(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);class Da{constructor(t,e,i,r){this.ot=t=>{var e=this.xa();if(!e||e.sessionId!==t){var i={sessionId:t,props:this.Ca(this._instance)};this.Ta.register({[Or]:i})}},this._instance=t,this.Ma=e,this.Ta=i,this.Ca=r||Ma,this.Ma.onSessionId(this.ot)}xa(){return this.Ta.props[Or]}getSetOnceProps(){var t,e=null==(t=this.xa())?void 0:t.props;return e?"r"in e?oo(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var t={};return ts(ns(this.getSetOnceProps()),((e,i)=>{"$current_url"===i&&(i="url"),t["$session_entry_"+G(i)]=e})),t}}class Na{on(t,e){return this.Ea[t]||(this.Ea[t]=[]),this.Ea[t].push(e),()=>{this.Ea[t]=this.Ea[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Ea[t]||[])i(e);for(var r of this.Ea["*"]||[])r(t,e)}constructor(){this.Ea={}}}var Ua=Ii("[SessionId]"),La=864e5;class ja{on(t,e){return this.Ia.on(t,e)}constructor(t,e,i){var r;if(this.Ra=null,this.Pa=null,this.Aa=[],this.Fa=void 0,this.Oa=!1,this.Ia=new Na,this.La=(t,e)=>!(!lt(t)||!lt(e))&&Math.abs(t-e)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===qr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Di=t.config,this.Ta=t.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.$a=void 0,this._sessionActivityTimestamp=null,this.Da=e||_s,this.Na=i||_s;var s=this.Di.persistence_name||this.Di.token;if(this._sessionTimeoutMs=1e3*wt(this.Di.session_idle_timeout_seconds||1800,60,36e3,Ua.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.qa(),this.ja="ph_"+s+"_window_id",this.Ba="ph_"+s+"_primary_window_exists",this.Ha()){var n=Ds.Br(this.ja),o=Ds.Br(this.Ba);n&&!o?this.st=n:Ds.qr(this.ja),Ds.Dr(this.Ba,!0)}null!=(r=this.Di.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.Di.bootstrap.sessionID),this.Ua()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return it(this.Aa)&&(this.Aa=[]),this.Aa.push(t),this._e&&t(this._e,this.st),()=>{this.Aa=this.Aa.filter((e=>e!==t))}}Ha(){return"memory"!==this.Di.persistence&&!this.Ta.xs&&Ds.Nr()}za(t){t!==this.st&&(this.st=t,this.Ha()&&Ds.Dr(this.ja,t))}Wa(){return this.st?this.st:this.Ha()?Ds.Br(this.ja):null}Va(t){var e=this.Ra;return!nt(e)&&!nt(t)&&5e3>Math.abs(t-e)}Ga(t,e,i){var r=e!==this._sessionActivityTimestamp,s=!(t!==this._e||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=e,this._e=t,s&&!r||s&&this.Va(e)||(this.Ra=e,this.Ta.register({[nr]:[e,t,i]}))}Za(){var t,e=null==(t=this.Di)?void 0:t.persistence_save_debounce_ms;return lt(e)&&e>0}Qa(){this.Za()?this.Ta.refreshKey(nr):(this.Ta.flush(),this.Ta.load())}Ja(){var t;if(!nt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Ra){this.Qa();var e=this.Ka();e[1]===this._e&&e[2]===this._sessionStartTimestamp&&(this.Ra=this._sessionActivityTimestamp,this.Ta.register({[nr]:[this._sessionActivityTimestamp,null!==(t=this._e)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Ta.flush())}}Ya(){var t=this.Ka()[0],e=lt(t)?t:0,i=lt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,i)}Xa(t){return this.Qa(),this.La(t,this.Ya())}Ka(){var t=this.Ta.props[nr];return X(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Ra=null,this.$a=void 0,clearTimeout(this.eo),this.eo=void 0,this.Ga(null,null,null)}setBootstrapSessionId(t,e){void 0===e&&(e=!1);var i=function(t,e){void 0===e&&(e=(new Date).getTime());try{var i=(t=>{var e=t.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})(t);return i>e+6e4?void Ua.error("Bootstrap sessionID cannot be in the future"):i}catch(t){return void Ua.error("Invalid sessionID in bootstrap",t)}}(t);return!it(i)&&(e?this.$a={sessionId:t,sessionStartTimestamp:i}:this.Ga(t,(new Date).getTime(),i),!0)}destroy(){this.Oa=!0,this.Ja(),clearTimeout(this.eo),this.eo=void 0,this.Fa&&t&&(t.removeEventListener(Kr,this.Fa,{capture:!1}),this.Fa=void 0),this.Aa=[]}Ua(){this.Fa=()=>{this.Ja(),this.Ha()&&Ds.qr(this.Ba)},ls(t,Kr,this.Fa,{capture:!1})}checkAndGetSessionAndWindowId(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=!1),this.Di.cookieless_mode===qr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=e||(new Date).getTime(),s=this._e;if(i)this.Pa=r;else if(nt(this.Pa)||this.Pa>r||r-this.Pa>=1e3){var n,o;null==(n=(o=this.Ta).syncCookieProperties)||n.call(o),this.Pa=r}var a=this.Ka(),l=a[1],u=a[2],h=!it(s)&&l!==s,d=this.Ya(),v=this.Wa(),c=this.$a,f=!!c&&(c.sessionStartTimestamp>r+6e4||r-c.sessionStartTimestamp>La),p=c?f:lt(u)&&Math.abs(r-u)>La,_=!1,g=h,m=!l||!!c,y=l,b=!m&&!t&&this.La(r,d);if(b){(b=this.Xa(r))||Ua.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this.Ka();l=w[1],u=w[2]}if(m||b||p){g=!1;var x=c&&!f;l=x?c.sessionId:this.Da(),v=this.Na(),Ua.info("new session ID assigned",{sessionId:l,windowId:v,bootstrapped:!!x,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p}}),u=x?c.sessionStartTimestamp:r,this.$a=void 0,_=!0}else v||(v=this.Na(),_=!0),(g=g||l!==y)&&(Ua.info("adopted cross-tab session id",{sessionId:l,windowId:v}),_=!0);var S=lt(d)&&t&&!p?d:r,E=lt(u)?u:(new Date).getTime();this.za(v),this.Ga(l,S,E),t||this.qa();var k={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p,crossTabAdoption:g};return _&&this.Aa.forEach((t=>t(l,v,k))),{sessionId:l,windowId:v,sessionStartTimestamp:E,changeReason:_?k:void 0,lastActivityTimestamp:d}}qa(){this.Oa||(clearTimeout(this.eo),this.eo=setTimeout((()=>{if(!this.Oa)if(this.Xa((new Date).getTime())){var t=this._e;this.resetSessionId(),this.Ia.emit("forcedIdleReset",{idleSessionId:t})}else this.qa()}),1.1*this.sessionTimeoutMs))}}var Ba=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&H(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>H(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver};function za(){return(za=p((function*(){var t=null==i?void 0:i.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),r=null==e?void 0:e.model;return rt(r)&&r.length>0?r:void 0}catch(t){return void Ci.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}var qa=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}};function Ha(t,e,i){return Bn({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}var Va={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>qa(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!qa(e,t))))),icontains:(t,e)=>e.map(Wa).some((e=>t.map(Wa).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(Wa).every((e=>t.map(Wa).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},Wa=t=>t.toLowerCase();function Ga(t,e){return!t||Object.entries(t).every((t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(it(r)||nt(r))return!1;var s=[String(r)],n=Va[i.operator];return!!n&&n(i.values,s)}))}var Ka="custom",Ja="i.posthog.com",Ya=/^\/static\//,Qa=["/s/","/e/","/i/"];class Xa{constructor(t){this.io={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,e=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace("."+Ja,".posthog.com")),"https://app.posthog.com"===e?"https://us.posthog.com":e}get region(){return this.io[this.apiHost]||(this.io[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":Ka),this.io[this.apiHost]}ro(t){if(Ya.test(t)){var e=this.instance.config.asset_host;if("string"==typeof e)return e.trim().replace(/\/$/,"")||void 0}}no(t){var e=zn(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}so(t,e,i){if("ui"===t)return i;var r=i,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=zn(i))?void 0:n.href)||i;r=s(new URL(o)).toString()}if(s&&"api"===t&&Qa.some((t=>0===e.indexOf(t)))){var a=this.no(r);if(a){var l,u=this.apiHost,h=this.ao;(null==(l=h)?void 0:l.apiHost)===u&&h.rewriteRequestPath===s||(h={apiHost:u,rewriteRequestPath:s,urls:new Set},this.ao=h),h.urls.add(a)}}return r}isIngestionEndpoint(t){var e=this.ao,i=this.no(t);return(null==e?void 0:e.apiHost)===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&e.urls.has(i)}endpointFor(t,e){if(void 0===e&&(e=""),e&&(e="/"===e[0]?e:"/"+e),"ui"===t)return this.so(t,e,this.uiHost+e);if("flags"===t)return this.so(t,e,this.flagsApiHost+e);if("assets"===t){var i=this.ro(e);if(i)return this.so(t,e,""+i+e)}if(this.region===Ka)return this.so(t,e,this.apiHost+e);var r=Ja+e;switch(t){case"assets":return this.so(t,e,"https://"+this.region+"-assets."+r);case"api":return this.so(t,e,"https://"+this.region+"."+r)}}}function Za(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var tl=Ii("[Surveys]"),el="seenSurvey_",il=t=>{try{var e=(t=>((t,e)=>""+el+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){tl.error("Failed to persist survey seen state",t)}},rl=[xo.Popover,xo.Widget,xo.API],sl={ignoreConditions:!1,ignoreDelay:!1,displayType:Po.Popover},nl=Ii("[PostHog ExternalIntegrations]"),ol={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class al{constructor(t){this._instance=t}Xn(t,e){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,t,(t=>{if(t)return nl.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var t=this,e=function(){var e,r,s,n=i[0],o=i[1];!o||null!=(e=v.__PosthogExtensions__)&&null!=(e=e.integrations)&&e[n]||t.Xn(ol[n],(()=>{var e;null==(e=v.__PosthogExtensions__)||null==(e=e.integrations)||null==(e=e[n])||e.start(t._instance)})),!o&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=v.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var i of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;e()}}}class ll{constructor(t,e){this.I=t,this.oo=e,this.lo=new Map,this.uo=!1}add(t){var e=this;return p((function*(){if(e.uo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.lo.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.lo.set(t.name,t);try{var i=t.setup(e.oo);i&&(yield i)}catch(i){var r=e.lo.get(t.name)===t;r&&e.lo.delete(t.name),e.I.error('Failed to set up browser extension "'+t.name+'"',i),r&&e.ho(t)}}))()}dispose(){if(!this.uo){this.uo=!0;var t=Array.from(this.lo.values()).reverse();for(var e of(this.lo.clear(),t))this.ho(e)}}ho(t){try{var e=null==t.dispose?void 0:t.dispose();e&&Z(e.then)&&e.then(void 0,(e=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',e)}))}catch(e){this.I.error('Failed to dispose browser extension "'+t.name+'"',e)}}}class ul{constructor(t){this._instance=t}initialize(){}get(t){var e=this._instance.persistence;if("string"==typeof t)return null==e?void 0:e.get_property(t);var i={};for(var r of t){var s=null==e?void 0:e.get_property(r);it(s)||(i[r]=s)}return i}set(t,e){var i;null==(i=this._instance.persistence)||i.register("string"==typeof t?{[t]:e}:t)}remove(t){var e;null==(e=this._instance.persistence)||e.unregister(t)}}var hl="extensionsRemoteConfig";class dl{constructor(t){this.uo=!1,this.instance=t,this.I=Ci,this.do=t.vo,this.kv=new ul(t),this.onEvent=t=>_o(this.instance.on("eventCaptured",(e=>{try{t({event:e.event,properties:e.properties})}catch(t){this.I.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.uo)return _o((()=>{}));var e=e=>{try{t(e)}catch(t){this.I.error("Browser extension remote config listener failed",t)}},i=this.instance.co.on(hl,e);return this.do&&e(this.do),_o(i)},this.fo=new ll(Ci.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property(ji))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property(ji);return"string"==typeof t?t:void 0}get library(){return{name:c.LIB_NAME,version:c.LIB_VERSION}}get initialPersonProperties(){var t,e;return null!==(t=null==(e=this.instance.persistence)?void 0:e.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,e,i,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(e=null==s?void 0:s.sessionId)&&void 0!==e?e:"",windowId:null!==(i=null==s?void 0:s.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.fo.add(t)}capture(t,e,i){var r=this;return p((function*(){i?r.instance.capture(t,e,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):r.instance.capture(t,e)}))()}registerDynamicEventProperties(t){return _o(this.instance.po(t))}handleRemoteConfig(t){this.uo||(this.do=t,this.instance.co.emit(hl,t))}sendRequest(t,e){var i=this;return p((function*(){var r;void 0===e&&(e={});var s=i.instance.requestRouter.endpointFor(null!==(r=e.target)&&void 0!==r?r:"api",t),n={method:e.method,url:e.query?ya(s,e.query):s,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt};return"sendBeacon"===e.transport?(i.instance._send_request(n),{statusCode:202}):new Promise((t=>{n.callback=t,i.instance._send_request(n)}))}))()}dispose(){this.uo||(this.uo=!0,this.fo.dispose())}}var vl={},cl=0,fl=()=>{},pl='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',_l="Surveys module not available",gl="sanitize_properties is deprecated. Use before_send instead",ml="Invalid value for property_denylist config: ",yl=["token","distinct_id",Nr],bl="posthog",wl=!pa&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla")),xl=e=>{var i;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:as(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:s&&rt(null==s?void 0:s.search)&&-1!==s.search.indexOf("__posthog_debug=true")||!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:"https:"===(null==t||null==(i=t.location)?void 0:i.protocol),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){Ci.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:Wr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Oa},error_tracking:{},_onCapture:fl},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:an,ignore_text_selection:!0}:!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||"unset"===t||"2026-08-29">t)}))(e))},Sl=[["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"]],El=t=>{var e={};for(var i of Sl){var r=i[0],s=i[1];it(t[r])||(e[s]=t[r])}var n=es({},e,t),o=t.__preview_external_dependency_versioned_paths;return it(o)||(it(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),rt(o)&&it(t.asset_host)&&(n.asset_host=o)),X(t.property_blacklist)&&(it(t.property_denylist)?n.property_denylist=t.property_blacklist:X(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:Ci.error(ml+t.property_denylist)),n};class kl{constructor(){this.__forceAllowLocalhost=!1}get mo(){return this.__forceAllowLocalhost}set mo(t){Ci.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class $l{yo(t,e){if(t){var i=this.lo.indexOf(t);-1!==i&&this.lo.splice(i,1)}return this.lo.push(e),null==e.initialize||e.initialize(),e}bo(){return this.config.cookieless_mode===qr||this.config.cookieless_mode===zr&&this.consent.isRejected()}_o(){if(!this.bo()&&this.get_distinct_id()===Dr){var t=this.persistence;if(t){this.wo()||t.load(!0);var e=this.get_distinct_id();if(!e||e===Dr){var i=this.config.get_device_id(_s());this.register({distinct_id:i,$device_id:i}),t.set_property(Rr,Hr)}this.ko()}}}get decideEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.webPerformance=new kl,this.So=!1,this.version=c.LIB_VERSION,this.xo=new Set,this.Co="",this.co=new Na,this.lo=[],this.To=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=xl(),this.SentryIntegration=Mn,this.sentryIntegration=t=>function(t,e){var i=Fn(t,e);return{name:An,processEvent:t=>i(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Mo=!1,this.Eo=null,this.Io=null,this.Ro=null,this.scrollManager=new Fa(this),this.pageViewManager=new Dn(this),this.rateLimiter=new Ao(this),this.requestRouter=new Xa(this),this.consent=new Ns(this),this.externalIntegrations=new al(this);var e=null!==(t=$l.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(t,e,i)=>{var r=rt(t)?{[t]:e}:t;this.setPersonProperties(r),null==i||i({})},set_once:(t,e,i)=>{var r=rt(t)?{[t]:e}:t;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(t=>Ci.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,e,i){if(i&&i!==bl){var r,s=null!==(r=vl[i])&&void 0!==r?r:new $l;return s._init(t,e,i),vl[i]=s,vl[bl][i]=s,s}return this._init(t,e,i)}_init(e,i,r){var s,n;void 0===i&&(i={});var o,a=rt(e)?e.trim():"";if(!a)return Ci.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 a!==(null==(o=this.config)?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=xl(i.defaults),i.debug=this.Po(i.debug),this.Ao=i,this.Fo=[],i.person_profiles?this.Io=i.person_profiles:i.process_person&&(this.Io=i.process_person);var l=xl(i.defaults),u=El(i),h=es({},l,u,{name:r,token:a});tt(l.rageclick)&&tt(u.rageclick)&&(h.rageclick=es({},l.rageclick,u.rageclick)),tt(l.session_recording)&&tt(u.session_recording)&&(h.session_recording=es({},l.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&Ci.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:go.GZipJS;var d=this.wo();if(this.persistence=new po(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new po(_({},this.config,{persistence:"sessionStorage"}),d,!1),this.Co="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!d&&Ds.Nr()){var v=Ds.Br(this.Co);X(v)&&v.forEach((t=>{rt(t)&&this.xo.add(t)}))}else Ds.qr(this.Co);var f=_({},this.persistence.props),p=_({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Oo=new Ca((t=>this.Lo(t)),this.config.request_queue_config),this.$o=new Aa(this),this.__request_queue=[];var g=this.bo();if(g||(this.sessionManager=new ja(this),this.sessionPropsManager=new Da(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((t,e,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this.Do()}))),this.No(),this.config.__preview_deferred_init_extensions?(Ci.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.qo(g)}),0)):(Ci.info("Initializing extensions synchronously"),this.qo(g)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&Ci.info("Starting in debug mode",{this:this,config:i,thisC:_({},this.config),p:f,s:p}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=_({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(n=i.bootstrap)?void 0:n.distinctID)){var m=i.bootstrap.distinctID,y=this.get_distinct_id(),b=this.persistence.get_property(Rr);if(i.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Hr)this.identify(m);else if(i.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Vr)Ci.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 w=this.config.get_device_id(_s()),x=i.bootstrap.isIdentifiedID?w:m;this.persistence.set_property(Rr,i.bootstrap.isIdentifiedID?Vr:Hr),this.register({distinct_id:m,$device_id:x})}}if(g)this.register_once({distinct_id:Dr,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(_s());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(Rr,Hr)}return ls(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?function(t,e){var i=t.config.segment;if(!i)return e();!function(t,e){var i=t.config.segment;if(!i)return e();var r=i=>{var r=()=>i.anonymousId()||_s();t.config.get_device_id=r,i.id()&&(t.register({distinct_id:i.id(),$device_id:r()}),t.persistence.set_property(Rr,Vr)),e()},s=i.user();"then"in s&&Z(s.then)?s.then(r):r(s)}(t,(()=>{i.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||In.warn("This browser does not have Promise support, and can not use the segment integration");var e=(e,i)=>{if(!i)return e;e.event.userId||e.event.anonymousId===t.get_distinct_id()||(In.info("No userId set, resetting PostHog"),t.reset()),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(In.info("UserId set, identifying with PostHog"),t.identify(e.event.userId));var r=t.calculateEventProperties(i,e.event.properties);return e.event.properties=Object.assign({},r,e.event.properties),e};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:t=>e(t,t.event.event),page:t=>e(t,Jr),identify:t=>e(t,Qr),screen:t=>e(t,"$screen")}})(t)).then((()=>{e()}))}))}(this,(()=>this.jo())):this.jo(),Z(this.config._onCapture)&&this.config._onCapture!==fl&&(Ci.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&Ci.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 za.apply(this,arguments)}().then((t=>{t&&this.register({[Bi]:t})})).catch(fl),this}No(){var t,e,i,r,s,n,o=null!==(t=null==(e=this.config.__extensionClasses)?void 0:e.featureFlags)&&void 0!==t?t:null==(i=$l.__defaultExtensionClasses)?void 0:i.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||(null==(r=this.Bo)||r.call(this),this.Bo=void 0,this.featureFlags=new o(this)),Z(this.featureFlags.onReloading)&&Z(this.featureFlags.setup)?this.Bo||(this.Bo=this.featureFlags.onReloading((()=>{this.co.emit("featureFlagsReloading",!0)})),this.Ho().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}qo(t){var e,i,r,s,n,o,a,l=performance.now(),u=_({},$l.__defaultExtensionClasses,this.config.__extensionClasses),h=[];u.exceptions&&this.lo.push(this.exceptions=null!==(e=this.exceptions)&&void 0!==e?e:new u.exceptions(this)),u.historyAutocapture&&this.lo.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.lo.push(this.tracingHeaders=new u.tracingHeaders(this)),u.siteApps&&this.lo.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!t&&this.lo.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),u.autocapture&&this.lo.push(this.autocapture=new u.autocapture(this)),u.surveys&&this.lo.push(this.surveys=null!==(i=this.surveys)&&void 0!==i?i:new u.surveys(this)),u.logs&&this.lo.push(this.logs=null!==(r=this.logs)&&void 0!==r?r:new u.logs(this)),u.metrics&&this.lo.push(this.metrics=null!==(s=this.metrics)&&void 0!==s?s:new u.metrics(this)),u.conversations&&this.lo.push(this.conversations=null!==(n=this.conversations)&&void 0!==n?n:new u.conversations(this)),u.productTours&&this.lo.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.lo.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.lo.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.lo.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.lo.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,On)),u.toolbar&&this.lo.push(this.toolbar=null!==(o=this.toolbar)&&void 0!==o?o:new u.toolbar(this)),u.experiments&&this.lo.push(this.experiments=null!==(a=this.experiments)&&void 0!==a?a:new u.experiments(this)),this.lo.forEach((t=>{t.initialize&&h.push((()=>{null==t.initialize||t.initialize()}))})),h.push((()=>{if(this.Uo){var t=this.Uo;this.Uo=void 0,this.lo.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}})),this.zo(h,l)}zo(t,e){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-e>=30&&t.length>0)return void setTimeout((()=>{this.zo(t,e)}),0);var i=t.shift();if(i)try{i()}catch(t){Ci.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-e);this.register_for_session({[Ur]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Lr]:r}),this.config.__preview_deferred_init_extensions&&Ci.info("PostHog extensions initialized ("+r+"ms)")}Ks(t){var e;if(!r||!r.body)return Ci.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Ks(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Uo=t),this.vo=t,this.compression=void 0,t.ok){var i,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=V(s.supportedCompression,go.GZipJS)?go.GZipJS:V(s.supportedCompression,go.Base64)?go.Base64:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.Io?this.Io:Wr}),null==(e=this.Wo)||e.handleRemoteConfig(t),this.lo.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}jo(){try{this.config.loaded(this)}catch(t){Ci.critical("`loaded` function failed",t)}if(this.Vo(),this.config.internal_or_test_user_hostname&&null!=s&&s.hostname){var t=s.hostname,e=this.config.internal_or_test_user_hostname;("string"==typeof e?t===e:e.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.bo())&&this.Go()}),1),this.Zo=new Mo(this),this.Zo.load()}Vo(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.Oo)||t.enable())}_dom_loaded(){this.is_capturing()&&Zr(this.__request_queue,(t=>this.Lo(t))),this.__request_queue=[],this.Vo()}_handle_unload(){var t,e,i,r,s;null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(e=this.metrics)||e.flush("sendBeacon"),this.config.request_batching?(this.Qo()&&this.capture(Yr),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this.Oo)||r.unload(),null==(s=this.$o)||s.unload()):this.Qo()&&this.capture(Yr,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?wl?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=_({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?this.compression:t.compression,(it(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var e,i,r,s=_({},t);s.timeout=s.timeout||6e4;var n,o,a,u,h,d=null!==(e=s.transport)&&void 0!==e?e:"fetch";"sendBeacon"===d&&it(s.compression)&&s.data&&(s.compression=go.Base64),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(h=(u=(X(n=s.data)?n:[n]).map((t=>_({},t,t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{}))))[0])||null==(a=h.properties)?void 0:a.token)&&void 0!==o?o:null==h?void 0:h.token,batch:u,sent_at:(new Date).toISOString()}:"body"===s.timestampMode&&(s.data=function(t,e){return void 0===e&&(e=(new Date).toISOString()),X(t)?t.map((t=>_({},t,{sent_at:e}))):_({},t,{sent_at:e})}(s.data))),s.url=Pa(s.url,s.method,s.compression,s.timestampMode);var v=Ra.filter((t=>!s.disableTransport||!t.transport||!s.disableTransport.includes(t.transport))),c=null!==(i=null==(r=function(t,e){for(var i=0;t.length>i;i++)if(t[i].transport===d)return t[i]}(v))?void 0:r.method)&&void 0!==i?i:v[0].method;if(!c)throw new Error("No available transport method");var f=t=>{try{c(t)}catch(t){ka(t)?Ci.warn(t):Ci.error(t),null==s.callback||s.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&s.data&&s.compression===go.GZipJS&&l&&"undefined"!=typeof Promise&&!ga?Sa(s).then((t=>{f(t)})).catch((e=>{if(C(e))return ga=!0,void f(_({},s,{compression:void 0,url:Pa(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var e="name"in t?String(t.name):"";return C(t)||e===P})(e)&&(ga=!0),f(s)})):c(s)})(_({},t,{callback:e=>{var i,r;this.rateLimiter.checkForLimiting(e),400>e.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,e),null==t.callback||t.callback(e)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}Lo(t){this.$o?this.$o.retriableRequest(t):this._send_request(t)}_execute_array(t){cl++;try{var e,i=[],r=[],s=[];Zr(t,(t=>{if(t)if(X(e=t[0]))s.push(t);else if(Z(t))try{t.call(this)}catch(e){Ci.error("Error executing queued PostHog call",t,e)}else X(t)&&"alias"===e?i.push(t):X(t)&&-1!==e.indexOf("capture")&&Z(this[e])?s.push(t):r.push(t)}));var n=function(t,e){Zr(t,(function(t){try{if(X(t[0])){var i=e;ts(t,(function(t){i=i[t[0]].apply(i,t.slice(1))}))}else e[t[0]].apply(e,t.slice(1))}catch(e){Ci.error("Error executing queued PostHog call",t,e)}}))};n(i,this),n(r,this),n(s,this)}finally{cl--}}push(t){if(cl>0&&X(t)&&rt(t[0])){var e=$l.prototype[t[0]];Z(e)&&e.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,e,i){var r,s,n,o,a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Oo){if(this.is_capturing())if(!it(t)&&rt(t)){this._o();var l=!this.config.opt_out_useragent_filter&&this._is_bot();if(!l||this.config.__preview_capture_bot_pageviews){var u=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==u||!u.isRateLimited){null!=e&&e.$current_url&&!rt(null==e?void 0:e.$current_url)&&(Ci.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==e||delete e.$current_url),"$exception"!==t||null!=i&&i.Jo||Ci.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 h=new Date,d=(null==i?void 0:i.timestamp)||h,v=Pe(null==i?void 0:i.uuid,_s),c={uuid:v,event:t,properties:this.calculateEventProperties(t,e||{},d,v)};t===Jr&&this.config.__preview_capture_bot_pageviews&&l&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),u&&(c.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);var f="$feature_flag_called"===t&&!1===c.properties.$feature_flag_has_experiment&&!0===this.get_property(cr);(null==i?void 0:i.$set)&&!f&&(c.$set=null==i?void 0:i.$set);var p=null==i?void 0:i.$unset;p&&(c.$unset=p);var g,m,y,b=f?void 0:this.Ko(null==i?void 0:i.$set_once,t!==Xr,t===Qr);if(b&&(c.$set_once=b),null!=i&&i._noTruncate||(s=this.config.properties_string_max_length,n=c,o=t=>rt(t)?t.slice(0,s):t,a=new Set,c=function t(e,i){if(e!==Object(e))return o?o(e):e;if(!a.has(e)){var r;if(a.add(e),X(e))r=[],Zr(e,(e=>{r.push(t(e))}));else{var s={};ts(e,((e,i)=>{a.has(e)||(s[i]=t(e,i))})),r=s}return r}}(n)),c.timestamp=d,it(null==i?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=h),f&&(c.properties=function(t,e){void 0===e&&(e=[]);var i={},r=e=>{void 0!==t[e]&&(i[e]=t[e])};return x.forEach(r),e.forEach(r),i}(c.properties,yl)),t===$o.DISMISSED||t===$o.SENT){var w=null==e?void 0:e[To.SURVEY_ID],S=null==e?void 0:e[To.SURVEY_ITERATION];il({id:w,current_iteration:S}),c.$set=_({},c.$set,{[(g={id:w,current_iteration:S},m=t===$o.SENT?"responded":"dismissed",y="$survey_"+m+"/"+g.id,g.current_iteration&&g.current_iteration>0&&(y="$survey_"+m+"/"+g.id+"/"+g.current_iteration),y)]:!0})}else t===$o.SHOWN&&(c.$set=_({},c.$set,{[To.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(t===Oo.SHOWN){var E=null==e?void 0:e[Co.TOUR_TYPE];E&&(c.$set=_({},c.$set,{[Co.TOUR_LAST_SEEN_DATE+"/"+E]:(new Date).toISOString()}))}var k=_({},c.properties.$set,c.$set);if(et(k)||this.setPersonPropertiesForFlags(k),!ot(this.config.before_send)){var T=this._n(c);if(!T)return;(c=T).uuid=Pe(c.uuid,_s)}this.co.emit("eventCaptured",c);var P=null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),R={method:"POST",url:P,data:c,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(P)?"body":"capture-body",batchKey:null==i?void 0:i._batchKey,transport:null==i?void 0:i.transport};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.Lo(R):this.Oo.enqueue(R),c}Ci.critical("This capture call is ignored due to client rate limiting.")}}else Ci.error("No event name provided to posthog.capture")}else Ci.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(e=>t(e.event,e)))}Ho(){var t;return null!==(t=this.Wo)&&void 0!==t?t:this.Wo=new dl(this)}po(t){this.To.push(t);var e=!0;return()=>{if(e){e=!1;var i=this.To.indexOf(t);-1!==i&&this.To.splice(i,1)}}}Yo(t){var e,i,r;return void 0===t&&(t=!0),!(null==(e=this.persistence)||!e.consumeCookieIdentityChange())&&(this.Ro=null,this.persistence.get_property(Rr)===Hr&&(null==(r=this.sessionPersistence)||r.clear(),this.xo.clear(),this.Xo()),null==(i=this.featureFlags)||i.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,i,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this.Yo();var l=a?void 0:this.persistence.remove_event_timer(e),h=_({},i);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.bo()&&(h[Nr]=!0),"$snapshot"===e){var d=_({},this.persistence.properties(),this.sessionPersistence.properties());return h.distinct_id=d.distinct_id,(!rt(h.distinct_id)&&!at(h.distinct_id)||st(h.distinct_id))&&Ci.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}var v,f=function(e,i,r,n){var o,a,l,h;if(void 0===n&&(n=!1),!u)return{};var d,v=e?[...Jn,...i||[]]:[],f=function(t){for(var e=0;ke.length>e;e++){var i=ke[e],r=i[1],s=i[0].exec(t),n=s&&(Z(r)?r(s,t):r);if(n)return n}return["",""]}(u),p=f[0],_=f[1],g=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};it(r)||(m.detectGoogleSearchApp=r);var y={},b=null==(o=navigator)||null==(o=o.userAgentData)?void 0:o.platform,w=null==(a=navigator)?void 0:a.maxTouchPoints,x=null==t||null==(l=t.screen)?void 0:l.width,S=null==t||null==(h=t.screen)?void 0:h.height,E=null==t?void 0:t.devicePixelRatio;it(b)||(y.userAgentDataPlatform=b),it(w)||(y.maxTouchPoints=w),it(x)||(y.screenWidth=x),it(S)||(y.screenHeight=S),it(E)||(y.devicePixelRatio=E);var k,T,P,R,O,C,I,A,F=es(ns({$os:p,$os_version:_,$browser:xe(u,navigator.vendor,g,m),$device:$e(u),$device_type:(T=u,P=y,A=$e(T),A===Pt||A===Tt||"Kobo"===A||"Kindle Fire"===A||A===se?$t:A===Gt||A===Jt||A===Kt||A===ee?"Console":A===Ot?"Wearable":A?St:"Android"===(null==P?void 0:P.userAgentDataPlatform)&&(null!==(R=null==P?void 0:P.maxTouchPoints)&&void 0!==R?R:0)>0?600>Math.min(null!==(O=null==P?void 0:P.screenWidth)&&void 0!==O?O:0,null!==(C=null==P?void 0:P.screenHeight)&&void 0!==C?C:0)/(null!==(I=null==P?void 0:P.devicePixelRatio)&&void 0!==I?I:1)?St:$t:"Desktop"),$timezone:ao(),$timezone_offset:lo()}),{$current_url:Hn(n?Re(null==s?void 0:s.href):null==s?void 0:s.href,v,Qn),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:Ee(u,navigator.vendor,g,m),$browser_language:io(),$browser_language_prefix:(k=io(),"string"==typeof k?k.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return c.SDK_DIST_CHANNEL&&(F.$sdk_dist_channel=c.SDK_DIST_CHANNEL),F}(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 p=this.sessionManager.checkAndGetSessionAndWindowId(a,n.getTime(),!0),g=p.windowId;h.$session_id=p.sessionId,h.$window_id=g}this.sessionPropsManager&&es(h,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&es(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null==(m=this.$o)?void 0:m.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===Ka&&(h.$lib_custom_api_host=this.config.api_host),v=e!==Jr||a?e!==Yr||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),h=es(h,v),e===Jr&&r&&(h.title=r.title),!it(l)){var y=n.getTime()-l;h.$duration=parseFloat((y/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");var b=this.persistence.properties(),w=this.sessionPersistence.properties();ts(["$referrer","$referring_domain"],(t=>{t in b&&delete w[t]}));var x={};if(this.To.length>0)for(var S of this.To.slice())try{es(x,S())}catch(t){Ci.error("Failed to produce browser extension event properties",t)}(h=es({},f,b,w,_({},x,h))).$is_identified=this._isIdentified(),X(this.config.property_denylist)?ts(this.config.property_denylist,(function(t){delete h[t]})):Ci.error(ml+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var E=this.config.sanitize_properties;E&&(Ci.error(gl),h=E(h,e));var k=this.tl();return h.$process_person_profile=k,k&&!a&&this.el("_calculate_event_properties"),h}Ko(t,e,i){var r;if(void 0===e&&(e=!0),void 0===i&&(i=!1),!this.persistence||!this.tl())return t;if(this.So&&!i)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=es({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(Ci.error(gl),o=a(o,"$set_once")),e&&(this.So=!0),et(o)?void 0:o}register(t,e){var i;null==(i=this.persistence)||i.register(t,e)}register_once(t,e,i){var r;null==(r=this.persistence)||r.register_once(t,e,i)}register_for_session(t){var e,i;null==(e=this.persistence)||e.syncCookieProperties(),this.Yo(),null==(i=this.sessionPersistence)||i.register(t),Object.keys(t).forEach((t=>this.xo.add(t))),this.Xo()}unregister(t){var e;null==(e=this.persistence)||e.unregister(t)}unregister_for_session(t){var e;null==(e=this.sessionPersistence)||e.unregister(t),this.xo.delete(t),this.Xo()}il(t,e){this.register({[t]:e})}Do(){this.xo.forEach((t=>{var e;null==(e=this.sessionPersistence)||e.unregister(t)})),this.xo.clear(),this.Xo()}Xo(){var t;if(this.Co)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.xs||!Ds.Nr())Ds.qr(this.Co);else{var e=[];this.xo.forEach((t=>e.push(t))),e.length>0?Ds.Dr(this.Co,e):Ds.qr(this.Co)}}getFeatureFlag(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(t,e)}getFeatureFlagPayload(t){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagPayload(t)}getFeatureFlagResult(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(t,e)}getAllFeatureFlags(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,e){var i,r;return null!==(i=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,e))&&void 0!==i?i:null==e?void 0:e.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,e,i){var r;null==(r=this.featureFlags)||r.updateFlags(t,e,i)}updateEarlyAccessFeatureEnrollment(t,e,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,e,i)}getEarlyAccessFeatures(t,e,i){var r;return void 0===e&&(e=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,e,i)}on(t,e){return this.co.on(t,e)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:_l}),()=>{})}onSessionId(t){var e,i;return null!==(e=null==(i=this.sessionManager)?void 0:i.onSessionId(t))&&void 0!==e?e:()=>{}}getSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getSurveys(t,e):t([],{isLoaded:!1,error:_l})}getActiveMatchingSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,e):t([],{isLoaded:!1,error:_l})}renderSurvey(t,e){var i;null==(i=this.surveys)||i.renderSurvey(t,e)}displaySurvey(t,e){var i;void 0===e&&(e=sl),null==(i=this.surveys)||i.displaySurvey(t,e)}cancelPendingSurvey(t){var e;null==(e=this.surveys)||e.cancelPendingSurvey(t)}canRenderSurvey(t){var e,i;return null!==(e=null==(i=this.surveys)?void 0:i.canRenderSurvey(t))&&void 0!==e?e:{visible:!1,disabledReason:_l}}canRenderSurveyAsync(t,e){var i,r;return void 0===e&&(e=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,e))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:_l})}rl(t){return!t||st(t)?(Ci.critical("Unique user id has not been set in posthog.identify"),!1):t===Dr?(Ci.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Ci.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,e,i){if(!this.__loaded||!this.persistence)return Ci.uninitializedWarning("posthog.identify");if(at(t)&&(t=t.toString(),Ci.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.rl(t)&&this.el("posthog.identify")){this._o();var r=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,n=this.Yo(!1),o=this.persistence.Ms(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:t}),this.get_property(ji)||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),t!==l&&t!==this.get_property(zi)&&(this.unregister(zi),this.register({distinct_id:t}));var u,h=(this.persistence.get_property(Rr)||Hr)===Hr,d=t!==l,v=!d&&h;if(d&&h)this.persistence.set_property(Rr,Vr),this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Es(),this.capture(Qr,{distinct_id:t,$anon_distinct_id:l},{$set:e||{},$set_once:i||{}}),this.Ro=Ha(t,e,i),null==(u=this.featureFlags)||u.setAnonymousDistinctId(l);else if(v){this.persistence.set_property(Rr,Vr);var c=e||{},f=i||{};this.setPersonPropertiesForFlags({$set:c,$set_once:f},!1),this.config.cookieWinsOnConflict&&this.persistence.Es(),this.capture("$set",{$set:c,$set_once:f}),this.Ro=Ha(t,e,i)}else(e||i)&&this.setPersonProperties(e,i);d||s||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(kr)):v&&(e||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.Ps(a)}}}setPersonProperties(t,e){if((t||e)&&this.el("posthog.setPersonProperties")){var i=Ha(this.get_distinct_id(),t,e);this.Ro!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:e||{}},!0),this.capture("$set",{$set:t||{},$set_once:e||{}}),this.Ro=i):Ci.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var e,i=(X(t)?t:[t]).filter((t=>rt(t)&&t.length>0));0!==i.length&&this.el("posthog.unsetPersonProperties")&&(null==(e=this.featureFlags)||e.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Ro=null)}group(t,e,i){var r;if(t&&e){null==(r=this.persistence)||r.syncCookieProperties(),this.Yo();var s=this.getGroups(),n=s[t]!==e;if(n&&this.resetGroupPropertiesForFlags(t),this.register({$groups:_({},s,{[t]:e})}),n||i){var o={$group_type:t,$group_key:e};i&&(o.$group_set=i),this.capture(Xr,o)}i&&this.setGroupPropertiesForFlags({[t]:i}),n&&!i&&this.reloadFeatureFlags()}else Ci.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(t,e)}resetPersonPropertiesForFlags(t){var e;void 0===t&&(t=!0),null==(e=this.featureFlags)||e.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),this.el("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(t,e))}resetGroupPropertiesForFlags(t){var e;null==(e=this.featureFlags)||e.resetGroupPropertiesForFlags(t)}reset(t){var e=ut(t)?t:null==t?void 0:t.resetDeviceID,i=ut(t)||null==t?void 0:t.bootstrap;this.nl(e,!1,i)}nl(t,e,i){var r,s,n;if(void 0===e&&(e=!1),Ci.info("reset"),!this.__loaded)return Ci.uninitializedWarning("posthog.reset");var o=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null==(r=this.Ao)?void 0:r.bootstrap)||{},null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.Xs());var a=this.get_property(ji),l=this.get_property(Bi),u=this.get_property(Zi),h=this.is_capturing();this.consent.reset(),e||!h||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 d=null==(n=this.persistence)||null==n.Ms?void 0:n.Ms(),v=!1;try{var c,f,p,g,m,y,b,w,x,S,E,k,T,P;if(null==(c=this.persistence)||c.clear(),null==(f=this.sessionPersistence)||f.clear(),this.xo.clear(),this.Xo(),it(u)||null==(E=this.persistence)||E.register({[Zi]:u}),null==(p=this.surveys)||p.reset(),null==(g=this.Zo)||g.stop(),null==(m=this.featureFlags)||m.reset(),null==(y=this.conversations)||y.reset(),null==(b=this.logs)||b.reset(),null==(w=this.metrics)||w.reset(),null==(x=this.persistence)||x.set_property(Rr,Hr),null==(S=this.sessionManager)||S.resetSessionId(),this.Ro=null,this.config.cookieless_mode===qr)this.register_once({distinct_id:Dr,$device_id:null},"");else{var R=this.config.get_device_id(_s());this.register_once({distinct_id:R,$device_id:t?R:a},""),t||it(l)||this.register({[Bi]:l})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(void 0===i.distinctID||this.bo()||(null==(P=this.persistence)||P.set_property(Rr,i.isIdentifiedID?Vr:Hr),this.register({distinct_id:i.distinctID})),null==(k=this.featureFlags)||k.initialize(),!(it(o)||null!=(T=this.sessionManager)&&T.setBootstrapSessionId(o,!0))){var O=_({},i);delete O.sessionID,this.config.bootstrap=O}delete this.config.identity_distinct_id,delete this.config.identity_hash,v=!0}finally{var C;d&&(null==(C=this.persistence)||null==C.Ps||C.Ps(v))}this.reloadFeatureFlags()}shutdown(t){var e=this;return p((function*(){var t,i,r,s,n,o,a;if(e.__loaded){null==(t=e.Zo)||t.stop(),null==(i=e.Wo)||i.dispose(),null==(r=e.sessionRecording)||r.dispose(),null==(s=e.logs)||s.flushLogs("sendBeacon"),null==(n=e.metrics)||n.flush("sendBeacon"),null==(o=e.Oo)||o.unload(),null==(a=e.$o)||a.unload();try{var l;null==(l=e.featureFlags)||l.destroy()}catch(t){Ci.error("Error while destroying feature flags",t)}}else Ci.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,e){var i;this.config.identity_distinct_id=t,this.config.identity_hash=e,this.alias(t),null==(i=this.conversations)||i.sl()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.al()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,e;return null!==(t=null==(e=this.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var e=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=e.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+e.sessionId);if(null!=t&&t.withTimestamp&&i){var s,n=null!==(s=t.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(t,e){return t===this.get_property(Ui)?(Ci.critical("Attempting to create alias for existing People user - aborting."),-2):this.el("posthog.alias")?(it(e)&&(e=this.get_distinct_id()),t!==e?(this.il(zi,t),this.capture("$create_alias",{alias:t,distinct_id:e})):(Ci.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var e=_({},this.config);if(tt(t)){var i,r,s,n,o,a,l,u,h,d,v,f;es(this.config,El(t));var p=this.wo();null==(i=this.persistence)||i.update_config(this.config,e,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new po(_({},this.config,{persistence:"sessionStorage"}),p,!1);var g=this.Po(this.config.debug);ut(g)&&(this.config.debug=g),ut(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,xs.Nr()&&xs.Dr("ph_debug",!0),Ci.info("set_config",{config:t,oldConfig:e,newConfig:_({},this.config)})):(c.DEBUG=!1,xs.Nr()&&xs.qr("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this.Xs()),null==(s=this.exceptionObserver)||s.onConfigChange(),null==(n=this.exceptions)||n.onConfigChange(),null==(o=this.sessionRecording)||o.startIfEnabledOrStop(),null==(a=this.tracingHeaders)||a.startIfEnabledOrStop(),null==(l=this.autocapture)||l.startIfEnabled(),null==(u=this.heatmaps)||u.startIfEnabled(),null==(h=this.exceptionObserver)||h.startIfEnabledOrStop(),null==(d=this.deadClicksAutocapture)||d.startIfEnabledOrStop(),null==(v=this.surveys)||v.loadIfEnabled(),this.ko(),null==(f=this.externalIntegrations)||f.startIfEnabledOrStop()}}_overrideSDKInfo(t,e){c.LIB_NAME=t,c.LIB_VERSION=e}startSessionRecording(t){var e,i,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(e=this.sessionManager)||e.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,e){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(_({},r,e))}}addExceptionStep(t,e){var i;null==(i=this.exceptions)||i.addExceptionStep(t,e)}captureLog(t){var e;null==(e=this.logs)||e.captureLog(t)}get logger(){var t,e;return null!==(t=null==(e=this.logs)?void 0:e.logger)&&void 0!==t?t:$l.ol}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var e,i;return null!==(e=null==(i=this.toolbar)?void 0:i.loadToolbar(t))&&void 0!==e&&e}get_property(t){var e;return null==(e=this.persistence)?void 0:e.props[t]}getSessionProperty(t){var e;return null==(e=this.sessionPersistence)?void 0:e.props[t]}toString(){var t,e=null!==(t=this.config.name)&&void 0!==t?t:bl;return e!==bl&&(e=bl+"."+e),e}_isIdentified(){var t,e;return(null==(t=this.persistence)?void 0:t.get_property(Rr))===Vr||(null==(e=this.sessionPersistence)?void 0:e.get_property(Rr))===Vr}tl(){var t,e;return!("never"===this.config.person_profiles||this.config.person_profiles===Wr&&!this._isIdentified()&&et(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[zi])&&(null==(e=this.persistence)||null==(e=e.props)||!e[Mr]))}Qo(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.tl()||this.el("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.el("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}el(t){return"never"===this.config.person_profiles?(Ci.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.il(Mr,!0),!0)}wo(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==zr)}ko(){var t,e,i,r,s=this.wo();return(null==(t=this.persistence)?void 0:t.xs)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(e=this.sessionPersistence)?void 0:e.xs)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s&&(this.xo.clear(),this.Xo()),s}opt_in_capturing(t){var e;if(this.config.cookieless_mode!==qr){if(this.bo()){var i,r,s,n,o;this.nl(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new ja(this),this.pageViewManager=new Dn(this),this.persistence&&(this.sessionPropsManager=new Da(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=$l.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.yo(this.sessionRecording,new l(this)),this.vo&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.vo)))}var u,h;this.consent.optInOut(!0),this.ko(),this.Vo(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),this.config.cookieless_mode==zr&&(null==(u=this.surveys)||u.loadIfEnabled()),(it(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(h=null==t?void 0:t.captureEventName)&&void 0!==h?h:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Go()}else Ci.warn(pl)}opt_out_capturing(){var t,e,i;this.config.cookieless_mode!==qr?(this.config.cookieless_mode===zr&&this.consent.isOptedIn()&&this.nl(!0,!0),this.consent.optInOut(!1),this.ko(),this.config.cookieless_mode===zr&&(this.register({distinct_id:Dr,$device_id:null}),null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Go(),this.Vo())):Ci.warn(pl)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===qr||(this.config.cookieless_mode===zr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.ko()}_is_bot(){return i?Ba(i,this.config.custom_blocked_useragents):void 0}Go(){r&&("visible"===r.visibilityState?this.Mo||(this.Mo=!0,this.capture(Jr,{title:r.title},{send_instantly:!0}),this.Eo&&(r.removeEventListener(Gr,this.Eo),this.Eo=null)):this.Eo||(this.Eo=this.Go.bind(this),ls(r,Gr,this.Eo)))}debug(e){!1===e?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}Xs(){var t=this.Ao||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ci.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,e,i,r,s){var n=e in t&&!ot(t[e]),o=i in t&&!ot(t[i]);return n?t[e]:!!o&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+e+"' instead. The old field will be removed in a future major version."),t[i])}(t,"advanced_disable_flags","advanced_disable_decide",0,Ci)}_n(t){var e;if(ot(this.config.before_send))return t;var i=Object.keys(null!==(e=t.properties)&&void 0!==e?e:{}).filter(vt),r=X(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r)try{if(s=n(s),ot(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return dt(t.event)?Ci.warn(o+". This can cause unexpected behavior."):Ci.info(o),null}s.properties&&!et(s.properties)||Ci.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(e){return Ci.error("Error in beforeSend function for event '"+t.event+"':",e),null}for(var a of i)if(s.properties&&ot(s.properties[a]))return Ci.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.rs)?void 0:t.pageViewId}captureTraceFeedback(t,e){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:e})}captureTraceMetric(t,e,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:e,$ai_metric_value:String(i)})}Po(t){var e=ut(t)&&!t,i=xs.Nr()&&"true"===xs.Pr("ph_debug");return!e&&(!!i||t)}}$l.__defaultExtensionClasses={},$l.ol=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=ss(t.prototype[e[i]])}($l,["identify"]);class Tl{constructor(t){this.disabled=!1===t;var e=tt(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var Pl="$copy_autocapture",Rl=Ii("[AutoCapture]");function Ol(t,e){return e.length>t?e.slice(0,t)+"...":e}function Cl(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!Hs(e));return e}function Il(e,i){var r,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!Hs(e))return{props:{}};for(var d=[e],v=new Set([e]),c=e;c.parentNode&&!Vs(c,"body")&&Ks>d.length;)if(Gs(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!Hs(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,g,m=[],y={},b=!1,w=!1;if(ts(d,(t=>{var e=fn(t);if(Vs(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Sn(i))&&(h?Re(i):i)}V(Qs(t),"ph-no-capture")&&(w=!0),m.push(function(t,e,i,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};en.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ol(1024,En(t)):Ol(1024,Zs(t)));var a=Qs(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),ts(t.attributes,(function(i){var n;if((!pn(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Sn(i.value)&&(!rt(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=Js(a).join(" ")),o["attr__"+i.name]=Ol(1024,"href"===i.name&&s?Re(a):a)}}));for(var l=1,u=1,h=t;h=Cl(h);)l++,h.tagName===t.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(t,o,a,l,h));var r=function(t){if(!fn(t))return{};var e={};return ts(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&Sn(r)&&(e[i]=r)}})),e}(t);es(y,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=Vs(e,"a")||Vs(e,"button")?En(e):Zs(e)),b){var x,S;m[0].attr__href=b;var E=null==(x=zn(b))?void 0:x.host,k=null==t||null==(S=t.location)?void 0:S.host;E&&k&&E!==k&&(p=b)}return{props:es({$event_type:n.type,$ce_version:1},u?{}:{$elements:m},{$elements_chain:(g=m,function(t){return t.map((t=>{var e,i,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=_({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(i=t.nth_of_type)&&void 0!==i?i:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return is(n).sort(((t,e)=>t[0].localeCompare(e[0]))).forEach((t=>{var e=t[1];return o[$n(t[0].toString())]=$n(e.toString())})),(r+=":")+is(o).map((t=>t[0]+'="'+t[1]+'"')).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Tn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return is(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=m[0])&&r.$el_text?{$el_text:null==(s=m[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},y)}}var Al=Ii("[ExceptionAutocapture]"),Fl=()=>{},Ml=Ii("[TracingHeaders]"),Dl=Ii("[Web Vitals]"),Nl=9e5,Ul="disabled",Ll="lazy_loading",jl="awaiting_config",Bl="missing_config";Ii("[SessionRecording]"),Ii("[SessionRecording]");var zl="[SessionRecording]",ql=Ii(zl),Hl=Ii("[Heatmaps]");function Vl(t){return tt(t)&&"clientX"in t&&"clientY"in t&&at(t.clientX)&&at(t.clientY)}var Wl=Ii("[Product Tours]"),Gl=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Qi))},Kl=["$set_once","$set"],Jl=Ii("[SiteApps]"),Yl="Error while initializing PostHog app with config id ";function Ql(t,e,i){if(ot(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class Xl{constructor(t){this.ll=new Na,this.ul=(t,e)=>this.hl(t,e)&&this.dl(t,e)&&this.vl(t,e)&&this.cl(t,e),this.hl=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.fl=new Set,this.pl=new Set}init(){var t,e;it(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!it(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.pl)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.fl)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.fl.has(t)||this.fl.has(e.event))&&this.pl&&(null==(i=this.pl)?void 0:i.size)>0&&this.pl.forEach((t=>{this.gl(e,t)&&this.ll.emit("actionCaptured",t.name)}))}ml(t){this.onAction("actionCaptured",(e=>t(e)))}gl(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.ul(t,i))return!0;return!1}onAction(t,e){return this.ll.on(t,e)}dl(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ql(r,e.url,e.url_matching||"contains"))return!1}return!0}vl(t,e){return!!this.yl(t,e)&&!!this.bl(t,e)&&!!this._l(t,e)}yl(t,e){var i;if(null==e||!e.href)return!0;var r=this.wl(t);if(r.length>0)return r.some((t=>Ql(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Ql((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}bl(t,e){var i;if(null==e||!e.text)return!0;var r=this.wl(t);if(r.length>0)return r.some((t=>Ql(t.text,e.text,e.text_matching||"exact")||Ql(t.$el_text,e.text,e.text_matching||"exact")));var s,n,o,a=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!ot(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(a),n=e.text,o=e.text_matching||"exact",s.some((t=>Ql(t,n,o))))}_l(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}wl(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}cl(t,e){return null==e||!e.properties||0===e.properties.length||Ga(e.properties.reduce(((t,e)=>{var i=X(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class Zl{constructor(t){var e;this.kl=[],this._instance=t,this.Sl=new Map,this.xl=new Map,this.Cl=new Map,null==(e=this._instance)||null==e.onSessionId||e.onSessionId((t=>this.Tl(t)))}Ml(t){return!1}El(){return null}Il(t){}Rl(){}Pl(t,e){return!!t&&Ga(t.propertyFilters,null==e?void 0:e.properties)}Al(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}Fl(t,e,i){var r=(i===mo.Activation?this.Sl:this.xl).get(t),s=[];return this.Ol((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Pl(n,e)}))}register(t){var e;it(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Ll(t),this.$l(t))}$l(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.Dl&&(this.Dl=new Xl(this._instance),this.Dl.init(),this.Dl.ml((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Dl)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.Cl.get(e.name);i&&i.push(t.id),this.Cl.set(e.name,i||[t.id])}})))})))}Ll(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.Sl=this.Al(t,mo.Activation),this.xl=this.Al(t,mo.Cancellation))}onEvent(t,e){var i,r,s=this.Nl(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.ql(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.jl([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Bl(n),void this.Hl([n])}if(this.xl.has(t)){var a=this.Fl(t,e,mo.Cancellation);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.jl(a.map((t=>t.id))),a.forEach((t=>this.Ul(t.id))))}if(this.Sl.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.Sl.get(t)});var l=this.Fl(t,e,mo.Activation);this.zl(l.map((t=>t.id)))}}onAction(t){this.Cl.has(t)&&this.zl(this.Cl.get(t)||[])}zl(t){var e;if(0!==t.length){var i=!(null==(e=this._instance)||null==e.get_session_id||!e.get_session_id()),r=[];for(var s of t)i&&this.Ml(s)?this.Bl(s)&&this.Wl(s):r.push(s);r.length>0&&(this.kl=[...new Set([...this.kl,...r])]),this.Nl().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Bl(t){this.kl=this.kl.filter((e=>e!==t));var e=this.Vl();return!e.includes(t)&&(this.Gl([...e,t]),this.Zl(),!0)}jl(t){var e=new Set(t);this.kl=this.kl.filter((t=>!e.has(t)));var i=this.Ql(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&(this.Gl(r),0===r.length&&this.Jl()),this.Hl(t)}Kl(){var t,e=this.El();if(!e)return{};var i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e];return i&&"object"==typeof i?i:{}}Wl(t){if(this.El()){var e=this.Kl();this.Il(_({},e,{[t]:Date.now()}))}}Hl(t){if(this.El()){var e=this.Kl(),i={},r=!1;for(var s of Object.entries(e)){var n=s[0],o=s[1];t.includes(n)?r=!0:i[n]=o}r&&(et(i)?this.Rl():this.Il(i))}}Yl(){this.El()&&this.Rl()}getActivationTimestamp(t){if(this.Vl().includes(t)){var e=this.Kl()[t];return at(e)?e:void 0}}Ql(){var t,e=this.Xl();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}Vl(){var t,e,i=this.Ql();if(0===i.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.tu()],s=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();return s&&r===s?i:[]}Zl(){var t,e=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();e&&this.eu(e)}Jl(){this.iu()}Tl(t){var e,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this.tu()];if(i&&i!==t){var r=this.Ql(),s=this.Kl();r.length>0&&(this.Gl([]),r.filter((t=>at(s[t]))).forEach((t=>this.Ul(t)))),this.Jl(),this.Yl()}}getActivatedIds(){return[...new Set([...this.Vl(),...this.kl])].filter((t=>!this.ru(t)))}reset(){this.kl=[],this.Ql().length>0&&this.Gl([]),this.Jl(),this.Yl()}getEventToItemsMap(){return this.Sl}nu(){return this.Dl}}class tu extends Zl{constructor(t){super(t)}Xl(){return wr}tu(){return xr}El(){return Sr}Il(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[Sr]:t})}Rl(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Sr)}Ml(t){var e,i;this.Ol((e=>{i=e.find((e=>e.id===t))}));var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return at(r)&&r>0}su(){return $o.SHOWN}Ol(t){var e;null==(e=this._instance)||e.getSurveys(t)}Ul(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Nl(){return tl}Gl(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[wr]:t})}eu(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[xr]:t})}iu(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(xr)}ru(){return!1}ql(t,e){var i;this.Ol((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e;return Za(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(i);return r?t===$o.SHOWN?"consume":"ignore":t===$o.SHOWN?"persist":t===$o.DISMISSED||t===$o.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var eu="SDK is not enabled or survey functionality is not yet loaded",iu="Disabled. Not loading surveys.",ru=null!=t&&t.location?Vn(t.location.hash,"__posthog")||Vn(location.hash,"state"):null,su="_postHogToolbarParams",nu=Ii("[Toolbar]"),ou=Ii("[FeatureFlags]");class au{constructor(t,e){void 0===e&&(e=!1),this.au=!1,this.update(t,e)}update(t,e){this.ou=((t,e)=>{var i,r,s,n;return{bootstrap:{featureFlags:null==(i=t.bootstrap)?void 0:i.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:e,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?"none":"base64",evaluationContexts:null!==(s=null!==(n=t.evaluation_contexts)&&void 0!==n?n:t.evaluation_environments)&&void 0!==s?s:[],flagKeys:X(t.flag_keys)?t.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.au||(ou.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.au=!0),it(t.flag_keys)||X(t.flag_keys)||ou.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.ou}}var lu=Ii("[FeatureFlags]"),uu=Ii("[FeatureFlags]",{debugEnabled:!0}),hu="\" failed. Feature flags didn't load in time.",du="connection_error",vu=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},cu=t=>{var e={};for(var i of is(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},fu=Ii("[Error tracking]"),pu=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],_u="Refusing to render web experiment since the viewer is a likely bot",gu={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>qa(e,t),not_regex:(t,e)=>!qa(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class mu{get Di(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{mu.lu("retrieved web experiments from the server"),e.uu=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.uu&&(mu.lu("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.uu)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);rt(r)&&t.variants[r]&&e.hu(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];mu.du(n,e._instance)&&e.hu(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())mu.lu(_u);else if(!this.Di.disable_web_experiments){if(ot(this.uu))return this.uu=new Map,this.loadIfEnabled(),void this.previewWebExperiment();mu.lu("applying feature flags",t),t.forEach((t=>{var e;if(this.uu&&null!=(e=this.uu)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.uu)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.hu(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=mu.getWindowLocation();if(null!=t&&t.search){var e=qn(null==t?void 0:t.search,"__experiment_id"),i=qn(null==t?void 0:t.search,"__experiment_variant");e&&i&&(mu.lu("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.vu(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Di.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Di.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Di.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}vu(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(mu.lu("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.hu(r[0].name,e,r[0].variants[e].transforms))}static du(t,e){return!ot(t.conditions)&&mu.cu(t,e)&&mu.fu(t)}static cu(t,e){var i;if(ot(t.conditions)||ot(null==(i=t.conditions)?void 0:i.url))return!0;var r=mu.getWindowLocation();if(r){var s,n,o,a=Us(e,r.href);return null==(s=t.conditions)||!s.url||gu[null!==(n=null==(o=t.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,a)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static fu(t){var e;if(ot(t.conditions)||ot(null==(e=t.conditions)?void 0:e.utm))return!0;var i=Zn();if(i.utm_source){var r,s,n,o,a,l,u,h,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return d&&c&&f&&v}return!1}static lu(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];Ci.info("[WebExperiments] "+t,i)}hu(t,e,i){this._is_bot()?mu.lu(_u):"control"!==e?i.forEach((i=>{if(i.selector){var r;mu.lu("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):mu.lu("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?Ba(i,this.Di.custom_blocked_useragents):void 0}}var yu=Ii("[Conversations]"),bu="Conversations not available yet.",wu="console",xu="__posthogHandledLogsRequestError",Su=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[xu]=!0,i},Eu=t=>!!t&&"object"==typeof t&&!0===t[xu],ku={featureFlags:class{constructor(t){this.name="featureFlags",this.pu=!1,this.featureFlagEventHandlers=[],this.I=lu,this.gu={},this.mu={},this.yu=[],this.bu=!1,this._u=!1,this.wu=0,this.ku=!1,this.Su=!1,this.xu=!1,this.Cu=!1,this.Tu=0,this.Tt=()=>{var t=this.Mu();this.Tu=0,t&&this.reloadFeatureFlags()},"get"in t?this.Eu=t:(this.Iu=new au(t.config,t.Xs()),this.Eu=this.Iu)}updateConfig(t,e){var i;null==(i=this.Iu)||i.update(t,e)}setup(t){return this.Ru=t,this.I=t.logger.createLogger("[FeatureFlags]"),i=()=>{this.Ru===t&&(this.Ru=void 0,this.oo=t,this.Pu(t))},null!=(e=t.kv.initialize())&&e.then?e.then(i):i();var e,i}Pu(e){if(this.oo===e)return t&&ls(t,"online",this.Tt),this.Au=e.registerDynamicEventProperties((()=>this.Fu()?this.gu:this.mu)),this.Ou(),this.initialize()}destroy(){null==t||t.removeEventListener("online",this.Tt)}dispose(){var e;this.wu++,this.Su=!1,this.Ru=void 0,this.oo&&(this.Lu(),null==(e=this.Au)||e.dispose(),this.Au=void 0,this.yu=[],null==t||t.removeEventListener("online",this.Tt),this.oo=void 0)}get Di(){return this.Eu.get()}$u(t){var e;return null==(e=this.oo)?void 0:e.kv.get(t)}Dr(t){this.Du((()=>{var e;return null==(e=this.oo)?void 0:e.kv.set(t)}))}qr(t){this.Du((()=>{var e;return null==(e=this.oo)?void 0:e.kv.remove(t)}))}Du(t){try{t()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}Ou(){var t={};for(var e of[lr,dr,vr,fr]){var i=this.$u(e);it(i)||(t[e]=i)}this.gu=t;var r=_({},t),s=this.$u(ar);if(s)for(var n of Object.entries(s))r["$feature/"+n[0]]=n[1];this.mu=r}Fu(){var t=this.Di.cacheTtlMs;if(!t||0>=t)return!1;var e=this.$u(Pr);return"number"!=typeof e||Date.now()-e>t}Nu(){return!!this.Fu()&&(this.Cu||this._u||(this.Cu=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}qu(){var t=this.Di.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}ju(){var t=this.Di.flagKeys;if(!it(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),e}))}initialize(){var t,e,i=this.Di,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(o).filter((t=>a[t])).reduce(((t,e)=>(t[e]=o[e],t)),{});return this.Bu({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var r,s,n=null!=i&&i.merge&&null!==(r=this.$u(ar))&&void 0!==r?r:{},o=null!=i&&i.merge&&null!==(s=this.$u(dr))&&void 0!==s?s:{},a=_({},n,t),l=_({},o,e),u={};for(var h of Object.entries(a)){var d=h[0],v=h[1];u[d]={key:d,enabled:y(v),variant:b(v),reason:void 0,metadata:it(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Bu({flags:u})}get hasLoadedFlags(){return this.bu}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.$u(hr),e=this.$u(fr),i=this.$u(pr);if(!i&&!e)return t||{};var r=es({},t||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of s){var o,a,l=r[n],u=null==e?void 0:e[n],h=it(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=it(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==i?void 0:i[n],c=_({},l,{enabled:h,variant:h?null!=d?d:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=_({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=c}return this.pu||(this.I.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:r}),this.pu=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((i=>{var r=t[i];return{key:i,enabled:y(r),variant:b(r),payload:m(e[i])}}))}getFlagVariants(){var t=this.$u(ar),e=this.$u(fr);if(!e)return t||{};for(var i=es({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.pu||(this.I.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.pu=!0),i}getFlagPayloads(){var t=this.$u(dr),e=this.$u(pr);if(!e)return t||{};for(var i=es({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.pu||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.pu=!0),i}reloadFeatureFlags(){this.ku||this.Di.featureFlagsDisabled||this.Mu()||this.Hu||(this.yu.slice().forEach((t=>{try{t()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}})),this.Hu=setTimeout((()=>{this.Uu()}),5))}Lu(){clearTimeout(this.Hu),this.Hu=void 0}onReloading(t){return this.yu.push(t),()=>{this.yu=this.yu.filter((e=>e!==t))}}ensureFlagsLoaded(){this.bu||this._u||this.Hu||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ku=t}resetFlagCallReported(){this.qr(kr)}Uu(t){this.Lu();var e=this.oo;if(e&&!this.Di.remoteRequestsDisabled&&!this.Mu())if(this._u)this.Su=!0;else{var i={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:_({},e.initialPersonProperties,this.$u(_r)||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.$u(gr),timezone:ao()};it(e.deviceId)||(i.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.Di.featureFlagsDisabled)&&(i.disable_flags=!0);var r=this.qu();r.length&&(i.evaluation_contexts=r);var s=this.ju();it(s)||(i.flag_keys=s);var n=this.Di.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.wu;this._u=!0;var l=()=>{this.Su&&(this.Su=!1,this.Uu())},u=t=>{this._u=!1,a===this.wu?(this.Dr({[Tr]:[du]}),this.I.error("Feature flag request failed",t),l()):l()};try{e.sendRequest(o,{target:"flags",method:"POST",body:i,compression:"base64"===this.Di.compression?go.Base64:void 0,sentAt:"body",timeoutMs:this.Di.requestTimeoutMs}).then((t=>{var e,r,s=null!==(e=t.json)&&void 0!==e?e:{},o=200!==t.statusCode;if(this._u=!1,a===this.wu){if(this.zu(t.statusCode),o||this.Su||(this.$anon_distinct_id=void 0),!i.disable_flags||this.Su){this.xu=!o;var u=[];t.error?u.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?du:"unknown_error"):200!==t.statusCode&&u.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&u.push("errors_while_computing_flags");var h=!(null==(r=s.quotaLimited)||!r.includes("feature_flags"));h&&u.push("quota_limited"),this.Dr({[Tr]:u}),h?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."):i.disable_flags||this.Bu(s,o,{partialResponse:n}),l()}}else l()})).catch(u)}catch(t){u(t)}}}Mu(){return Wn(this.Tu,3)}zu(t){this.Tu=Gn(t,this.Tu,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(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.xu)if(this.bu||this.getFlags()&&this.getFlags().length>0){if(!this.Nu()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+t+hu)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.xu)if(this.bu||this.getFlags()&&this.getFlags().length>0){if(!this.Nu()){var i,r=this.getFlagVariants(),s=t in r,n=r[t],o=this.getFlagPayloads()[t],a=String(n),l=this.$u(vr)||void 0,u=this.$u(Pr)||void 0,h=this.$u(kr)||{};if(this.Di.deduplicateCallsPerSession){var d,v=null==(d=this.oo)?void 0:d.session.sessionId,c=this.$u($r);v&&v!==c&&(h={},i=v)}if(e.send_event||!("send_event"in e))if(t in h&&h[t].includes(a))i&&this.Dr({[kr]:h,[$r]:i});else{var f,p,g,y,b,w,x,S,E,k,T,P;X(h[t])?h[t].push(a):h[t]=[a],this.Dr(_({[kr]:h},i?{[$r]:i}:{}));var R=this.getFeatureFlagDetails(t),O=[...null!==(f=this.$u(Tr))&&void 0!==f?f:[]];it(n)&&O.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:null!==(p=null==(g=this.Di.bootstrap)||null==(g=g.featureFlags)?void 0:g[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(y=null==(b=this.Di.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.xu};it(null==R||null==(w=R.metadata)?void 0:w.has_experiment)||(C.$feature_flag_has_experiment=R.metadata.has_experiment),it(null==R||null==(x=R.metadata)?void 0:x.version)||(C.$feature_flag_version=R.metadata.version);var I,A=null!==(S=null==R||null==(E=R.reason)?void 0:E.description)&&void 0!==S?S:null==R||null==(k=R.reason)?void 0:k.code;A&&(C.$feature_flag_reason=A),null!=R&&null!=(T=R.metadata)&&T.id&&(C.$feature_flag_id=R.metadata.id),it(null==R?void 0:R.original_variant)&&it(null==R?void 0:R.original_enabled)||(C.$feature_flag_original_response=it(R.original_variant)?R.original_enabled:R.original_variant),null!=R&&null!=(P=R.metadata)&&P.original_payload&&(C.$feature_flag_original_payload=null==R||null==(I=R.metadata)?void 0:I.original_payload),O.length&&(C.$feature_flag_error=O.join(",")),this.Wu(C)}else i&&this.Dr({[kr]:h,[$r]:i});if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:m(o)}}}else this.I.warn('getFeatureFlagResult for key "'+t+hu)}Wu(t){try{var e;null==(e=this.oo)||e.capture("$feature_flag_called",t).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(t,e){this.Vu(t,e)}Vu(t,e){var i=this;return p((function*(){var r=i.oo;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=i.qu();n.length&&(s.evaluation_contexts=n);var o,a=i.ju();it(a)||(s.flag_keys=a);try{var l,u=null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:"base64"===i.Di.compression?go.Base64:void 0,sentAt:"body",timeoutMs:i.Di.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;o=(null==u?void 0:u[t])||void 0}catch(t){return void i.I.error("Remote config feature flag request failed",t)}try{e(o)}catch(t){i.I.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.xu)return e.defaultValue;if(!(this.bu||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+t+hu),e.defaultValue;var i=this.getFeatureFlag(t,e);return it(i)?e.defaultValue:!!i}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){this.Bu(t,e,i)}Bu(t,e,i){if(this.oo){this.bu=!0;var r=function(t,e,i,r,s,n){void 0===e&&(e={}),void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n=lu);var o=((t,e)=>{var i=t.flags;return i?_({},t,{featureFlags:Object.fromEntries(Object.keys(i).map((t=>{var e;return[t,null!==(e=i[t].variant)&&void 0!==e?e:i[t].enabled]}))),featureFlagPayloads:Object.fromEntries(Object.keys(i).filter((t=>i[t].enabled)).filter((t=>{var e;return null==(e=i[t].metadata)?void 0:e.payload})).map((t=>{var e;return[t,null==(e=i[t].metadata)?void 0:e.payload]})))}):(t.featureFlags&&e.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,n),a=o.flags,l=o.featureFlags,u=o.featureFlagPayloads;if(l){var h=t.requestId,d=t.evaluatedAt;if(X(l)){n.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var v={};if(l)for(var c=0;l.length>c;c++)v[l[c]]=!0;return{[lr]:l,[ar]:v,[cr]:!1}}var f=l,p=u,g=a;if(null!=s&&s.partialResponse)f=_({},e,f),p=_({},i,p),g=_({},r,g);else if(t.errorsWhileComputingFlags)if(a){var m=new Set(Object.keys(a).filter((t=>{var e;return!(null!=(e=a[t])&&e.failed)})));f=_({},e,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=_({},i,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),g=_({},r,Object.fromEntries(Object.entries(g||{}).filter((t=>m.has(t[0])))))}else f=_({},e,f),p=_({},i,p),g=_({},r,g);return _({[lr]:Object.keys(cu(f)),[ar]:f||{},[dr]:p||{},[hr]:g||{},[cr]:!0===t.minimalFlagCalledEvents},h?{[vr]:h}:{},d?{[Pr]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this.I);r&&this.Dr(r),e||(this.Cu=!1),this.Gu(e)}}override(t,e){void 0===e&&(e=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.Zu(t)}Zu(t){if(this.oo){if(!1===t)return this.qr([fr,pr]),this.Gu(),void uu.info("All overrides cleared");if(X(t))return this.Dr({[fr]:vu(t)}),this.Gu(),void uu.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.pu=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},s=i.flags,n=i.payloads;return s&&(r[fr]=X(s)?vu(s):s),n&&(r[pr]=n),Object.keys(r).length&&this.Dr(r),!1===s&&!1===n?this.qr([fr,pr]):!1===s?this.qr(fr):!1===n&&this.qr(pr),this.Gu(),!1===s?uu.info("Flag overrides cleared"):s&&uu.info("Flag overrides set",{flags:s}),void(!1===n?uu.info("Payload overrides cleared"):n&&uu.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Dr({[fr]:t}),this.Gu(),void uu.info("Flag overrides set",{flags:t});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.bu){var e=this.Qu(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.I.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var r=(this.$u(ur)||[]).find((e=>e.flagKey===t)),s={["$feature_enrollment/"+t]:e},n={$feature_flag:t,$feature_enrollment:e,$set:s};r&&(n.$early_access_feature_name=r.name),i&&(n.$feature_enrollment_stage=i);var o=_({},this.getFlagVariants(),{[t]:e});this.Dr({[lr]:Object.keys(cu(o)),[ar]:o,[_r]:_({},this.$u(_r)||{},s)}),this.Gu();try{var a;null==(a=this.oo)||a.capture("$feature_enrollment_update",n).catch((t=>{this.I.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.I.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.$u(ur);!r||e?this.Ju(t,i):t(r)}Ju(t,e){var i=this;return p((function*(){var r=i.oo;if(r){var s,n=e?"&"+e.map((t=>"stage="+t)).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;i.Dr({[ur]:s=o.json.earlyAccessFeatures})}catch(t){return void i.I.error("Early access feature request failed",t)}try{t(s)}catch(t){i.I.error("Early access feature callback failed",t)}}}))()}Qu(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}Gu(t){this.Ou();var e=this.Qu(),i=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.I.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Ku(t,e)}Ku(t,e){void 0===e&&(e=!0);var i=this.$u(_r)||{},r=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,n={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in i||(n[o]=s[o]));this.Dr({[_r]:_({},i,n,r)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=_({},this.$u(_r)||{});t.forEach((t=>{delete i[t]})),this.Dr({[_r]:i}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.qr(_r),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.$u(gr)||{},r=_({},i);for(var s of Object.keys(t))r[s]=_({},i[s],t[s]);this.Dr({[gr]:r}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.$u(gr)||{};this.Dr({[gr]:_({},e,{[t]:{}})})}else this.qr(gr)}reset(){this.wu++,this.Su=!1,this.gu={},this.mu={},this.bu=!1,this.ku=!1,this.xu=!1,this.$anon_distinct_id=void 0,this.Lu(),this.pu=!1,this.Tu=0}}},$u={sessionRecording:class{get Di(){return this._instance.config}get Ta(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Yu)||!t.isStarted)}get status(){var t,e;return this.Xu===jl||this.Xu===Bl?this.Xu:null!==(t=null==(e=this.Yu)?void 0:e.status)&&void 0!==t?t:this.Xu}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Xu=Ul,this.th=void 0,this.eh=!1,this.kt=(()=>{var e;if(null==r||!r.visibilityState||"visible"===r.visibilityState)return!0;var i=null==t||null==(e=t.performance)||null==e.getEntriesByType?void 0:e.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some((t=>"visible"===t.name))})(),this.It=()=>{var t;"visible"===(null==r?void 0:r.visibilityState)&&(this.kt=!0,null==(t=this.Yu)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw ql.error("started without valid sessionManager"),new Error(zl+" started without valid sessionManager. This is a bug.");if(this.Di.cookieless_mode===qr)throw new Error(zl+' cannot be used with cookieless_mode="always"');null!=r&&r.addEventListener&&ls(r,"visibilitychange",this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.eh=!0,null==r||null==r.removeEventListener||r.removeEventListener("visibilitychange",this.It),this.stopRecording()}get ih(){var e,i=!(null==(e=this._instance.get_property(Zi))||!e.enabled),r=!this.Di.disable_session_recording,s=this.Di.disable_session_recording||this._instance.consent.isOptedOut();return t&&i&&r&&!s}startIfEnabledOrStop(t){var e;if(!(this.eh||this.ih&&null!=(e=this.Yu)&&e.isStarted)){var i=!it(Object.assign)&&!it(Array.from);this.ih&&i?(this.rh(t),ql.info("starting")):(this.Xu=Ul,this.stopRecording())}}rh(t){var e,i,r;this.ih&&(this.Xu!==jl&&this.Xu!==Bl&&(this.Xu=Ll),null!=v&&null!=(e=v.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this.nh(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.sh,(e=>{if(e)return this._instance.register_for_session({[jr]:!0}),ql.error("could not load recorder",e);this.nh(t)})))}stopRecording(){var t,e;null==(t=this.th)||t.call(this),this.th=void 0,null==(e=this.Yu)||e.stop()}ah(){var t,e;null==(t=this.th)||t.call(this),this.th=void 0,null==(e=this.Yu)||e.discard()}oh(){var t,e;null==(t=this.Ta)||t.unregister(or),null==(e=this.Ta)||e.unregister(tr)}lh(t,e){if(ot(t))return null;var i,r=at(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(ql.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}uh(t){if(this.Ta){var e,i,r=this.Ta,s=()=>{var e,i=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.lh(null==(e=this.Di.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),n=this.lh(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:n;ot(o)&&this.oh();var a=null==i?void 0:i.minimumDurationMilliseconds;r.register({[Zi]:_({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:_({capturePerformance:t.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:it(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};s(),null==(e=this.th)||e.call(this),this.th=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?!1===e.sessionRecording?(this.uh(e),void this.ah()):(this.uh(e),void this.startIfEnabledOrStop()):(this.Xu===jl&&(this.Xu=Bl,ql.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Yu)&&i.log?this.Yu.log(t,e):ql.warn("log called before recorder was ready")}get sh(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Zi);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}hh(){var t,e=this._instance.get_property(Zi);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return ql.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!ot(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}nh(t){var e,i,r;if(!this.eh){if(null==(e=v.__PosthogExtensions__)||!e.initSessionRecording)return ql.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[jr]:!0});var s;if(this.Yu||(this.Yu=null==(s=v.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.kt),this.Yu._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.hh()){if(this.Xu===Bl||this.Xu===jl)return;return this.Xu=jl,ql.info("persisted remote config is stale, requesting fresh config before starting"),void new Mo(this._instance).load()}this.Xu=Ll,null==(i=(r=this.Yu).setDocumentWasEverVisible)||i.call(r,this.kt),this.Yu.start(t)}}onRRwebEmit(t){var e;null==(e=this.Yu)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Yu||null==(e=this.Ta)||e.register({[ir]:!0}),null==(t=this.Yu)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Yu||null==(e=this.Ta)||e.register({[er]:!0}),null==(t=this.Yu)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Yu||null==(i=this.Ta)||i.register({["url"===t?rr:sr]:!0}),null==(e=this.Yu)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Yu)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Yu)||!i.tryAddCustomEvent(t,e))}}},Tu={autocapture:class{constructor(t){this.dh=!1,this.fh=null,this.ph=!1,this.gh=!1,this.instance=t,this.rageclicks=new Tl(t.config.rageclick),this.mh=null}initialize(){this.startIfEnabled()}get Di(){var t,e,i=tt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}yh(){if(this.isBrowserSupported()){if(t&&r){var e=e=>{e=e||(null==t?void 0:t.event);try{this.bh(e)}catch(t){Rl.error("Failed to capture event",t)}};if(ls(r,"submit",e,{capture:!0}),ls(r,"change",e,{capture:!0}),ls(r,"click",e,{capture:!0}),this.Di.capture_copied_text){var i=e=>{e=e||(null==t?void 0:t.event);try{this.bh(e,Pl)}catch(t){Rl.error("Failed to capture copy/cut event",t)}};ls(r,"copy",i,{capture:!0}),ls(r,"cut",i,{capture:!0})}}}else Rl.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.dh&&(this.yh(),this.dh=!0)}onRemoteConfig(t){if(this.ph=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.gh=e.elementsChainAsString);var i=e.autocapture_opt_out;ut(i)&&(this.instance.persistence&&this.instance.persistence.register({[Hi]:i}),this.fh=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.mh=t}getElementSelectors(t){var e,i=[];return null==(e=this.mh)||e.forEach((e=>{var s=null==r?void 0:r.querySelectorAll(e);null==s||s.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Hi],r=this.fh,s=this.instance.Xs()&&!this.ph;if(nt(r)&&!ut(i)&&!s)return!1;var n=null!==(e=this.fh)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!n}bh(e,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r,s=tn(e);Ws(s)&&(s=s.parentNode||null),"$autocapture"===i&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&dn(s,this.instance.config.rageclick)&&this.bh(e,"$rageclick");var n=i===Pl;if(s&&function(e,i,r,s,n,o){var a;if(!t||vn(e))return!1;if(null!=r&&r.url_allowlist&&!Ys(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&Ys(r.url_ignorelist,o))return!1;if(null!=r&&r.dom_event_allowlist){var l=r.dom_event_allowlist;if(l&&!l.some((t=>i.type===t)))return!1}var u=cn(e,s),h=u.parentIsUsefulElement,d=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(it(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(d,r))return!1;if(!rn(d,null==r?void 0:r.css_selector_allowlist))return!1;if(rn(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:nn))return!1;try{var v=t.getComputedStyle(e);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return h?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(en.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this.Di,n,n?["copy","cut"]:void 0,this.instance)){var o=Il(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Di.element_attribute_ignorelist,elementsChainAsString:this.gh,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=o.props;if(o.explicitNoCapture)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(a.$element_selectors=l),i===Pl){var u,h=Xs(null==t||null==(u=t.getSelection())?void 0:u.toString()),d=e.type||"clipboard";if(!h)return!1;a.$selected_content=h,a.$copy_type=d}return this.instance.capture(i,a),!0}}}isBrowserSupported(){return Z(null==r?void 0:r.querySelectorAll)}},historyAutocapture:class{constructor(e){var i;this._instance=e,this._h=(null==t||null==(i=t.location)?void 0:i.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ci.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.wh&&this.wh(),this.wh=void 0,Ci.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.kh("pushState"),this.kh("replaceState"),this.Sh())}kh(e){var i;if(t&&(null==(i=t.history[e])||!i.__posthog_wrapped__)){var r=this;!function(t,e,i){try{if(!(e in t))return Fl;var r={next:t[e]},s=i((function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)}));return Z(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=s,()=>{if(t[e]!==s)for(var i=t[e];Z(i)&&i.__posthog_layer__;){var n=i.__posthog_layer__;if(n.next===s)return void(n.next=r.next);i=n.next}else t[e]=r.next}}catch(t){return Fl}}(t.history,e,(t=>function(i,s,n){t.call(this,i,s,n),r.xh(e)}))}}xh(e){try{var i,r=null==t||null==(i=t.location)?void 0:i.pathname;if(!r)return;r!==this._h&&this.isEnabled&&this._instance.capture(Jr,{navigation_type:e}),this._h=r}catch(t){Ci.error("Error capturing "+e+" pageview",t)}}Sh(){if(!this.wh){var e=()=>{this.xh("popstate")};ls(t,"popstate",e),this.wh=()=>{t&&t.removeEventListener("popstate",e)}}}},heatmaps:class{get Di(){return this.instance.config}constructor(t){var e;this.Ch=!1,this.dh=!1,this.Th=null,this.instance=t,this.Ch=!(null==(e=this.instance.persistence)||!e.props[Vi]),this.rageclicks=new Tl(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return tt(this.Di.capture_heatmaps)&&this.Di.capture_heatmaps.flush_interval_milliseconds&&(t=this.Di.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return ot(this.Di.capture_heatmaps)?ot(this.Di.enable_heatmaps)?this.Ch:this.Di.enable_heatmaps:!1!==this.Di.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.dh)return;Hl.info("starting..."),this.Mh(),this.It()}else{var t;clearInterval(null!==(t=this.Th)&&void 0!==t?t:void 0),this.Eh(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Vi]:i}),this.Ch=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.ft;return this.ft=void 0,t}Ih(t){Vl(t.originalEvent)&&this.bi(t.originalEvent,"deadclick")}It(){this.Th&&clearInterval(this.Th),this.Th="visible"===(null==r?void 0:r.visibilityState)?setInterval(this.ga.bind(this),this.flushIntervalMilliseconds):null}Mh(){t&&r&&(this.Rh=this.ga.bind(this),ls(t,Kr,this.Rh),this.Ph=e=>this.bi(e||(null==t?void 0:t.event)),ls(r,"click",this.Ph,{capture:!0}),this.Ah=e=>this.Fh(e||(null==t?void 0:t.event)),ls(r,"mousemove",this.Ah,{capture:!0}),this.Oh=new Cn(this.instance,Rn,this.Ih.bind(this)),this.Oh.startIfEnabledOrStop(),this.Lh=this.It.bind(this),ls(r,Gr,this.Lh),this.dh=!0)}Eh(){var e;t&&r&&(this.Rh&&t.removeEventListener(Kr,this.Rh),this.Ph&&r.removeEventListener("click",this.Ph,{capture:!0}),this.Ah&&r.removeEventListener("mousemove",this.Ah,{capture:!0}),this.Lh&&r.removeEventListener(Gr,this.Lh),clearTimeout(this.$h),null==(e=this.Oh)||e.stop(),this.dh=!1)}Dh(e,i){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,i,r){for(var s=e;s&&Hs(s)&&!Vs(s,"body");){if(s===r)return!1;var n=void 0;try{var o,a,l;n=null==(o=null!==(a=null==(l=s.ownerDocument)?void 0:l.defaultView)&&void 0!==a?a:t)?void 0:o.getComputedStyle(s).position}catch(t){return!1}if(V(i,n))return!0;s=sn(s)}return!1}(tn(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:r),target_fixed:o,type:i}}bi(t,e){var i;if(void 0===e&&(e="click"),!qs(t.target)&&Vl(t)){var r=this.Dh(t,e);null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&dn(tn(t),this.instance.config.rageclick)&&this.$n(_({},r,{type:"rageclick"})),this.$n(r)}}Fh(t){!qs(t.target)&&Vl(t)&&(clearTimeout(this.$h),this.$h=setTimeout((()=>{this.$n(this.Dh(t,"mousemove"))}),500))}$n(e){if(t){var i=this.Di.disable_capture_url_hashes?Re(t.location.href):t.location.href,r=this.Di.custom_personal_data_properties,s=this.Di.mask_personal_data_properties?[...Jn,...r||[]]:[],n=Hn(i,s,Qn);this.ft=this.ft||{},this.ft[n]||(this.ft[n]=[]),this.ft[n].push(e)}}ga(){this.ft&&!et(this.ft)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Cn,webVitalsAutocapture:class{constructor(t){var e;this.Ch=!1,this.dh=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Nh=()=>{clearTimeout(this.qh),this.qh=void 0,0!==this.ft.metrics.length&&(this._instance.capture("$web_vitals",_({$current_url:this.ft.url},this.ft.metrics.reduce(((t,e)=>_({},t,{["$web_vitals_"+e.name+"_event"]:_({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.jh=t=>{var e;if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},ot(null==t?void 0:t.name)||ot(null==t?void 0:t.value))Dl.error("Invalid metric received",t);else{var i="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.Bh(i);if(!it(r)){var s=at(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.Hh||this.Hh>t.value){this.ft.navigationKey!==s&&(this.Nh(),this.qh=setTimeout(this.Nh,this.flushToCaptureTimeoutMs)),it(this.ft.navigationKey)&&(this.ft.navigationKey=s,this.ft.url=r),this.ft.firstMetricTimestamp=it(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var n=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=_({},t,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});it(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.ft.metrics.push(o),this.ft.metrics.length===this.allowedMetrics.length&&this.Nh()}else Dl.error("Ignoring metric with value >= "+this.Hh,t)}}},this.Uh=()=>{if(!this.dh){var t,e,i,r,s=v.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this.zh])||("web-vitals"===this.zh&&it(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(it(o)||(t=o.onLCP,e=o.onCLS,i=o.onFCP,r=o.onINP),t&&e&&i&&r){var a={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.jh.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&e(this.jh.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this.jh.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this.jh.bind(this),a),this.dh=!0}else Dl.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Ch=!(null==(e=this._instance.persistence)||!e.props[Ji]),this.startIfEnabled()}get Wh(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=tt(this.Wh)?null==(t=this.Wh)?void 0:t.web_vitals_allowed_metrics:void 0;return ot(i)?(null==(e=this._instance.persistence)?void 0:e.props[Xi])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(tt(this.Wh)?this.Wh.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=tt(this.Wh)?this.Wh.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=tt(this.Wh)?this.Wh.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Hh(){var t=tt(this.Wh)&&at(this.Wh.__web_vitals_max_value)?this.Wh.__web_vitals_max_value:Nl;return t>0&&6e4>=t?Nl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return Dl.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=tt(this.Wh)?this.Wh.web_vitals:ut(this.Wh)?this.Wh:void 0;return ut(e)?e:this.Ch}startIfEnabled(){this.isEnabled&&!this.dh&&(Dl.info("enabled, starting..."),this.Xn(this.Uh))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=tt(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=tt(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ji]:i}),this._instance.persistence.register({[Xi]:r})),this.Ch=i,this.startIfEnabled()}}}get zh(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Xn(t){var e=v.__PosthogExtensions__,i=this.zh,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&it(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,(e=>{e?Dl.error("failed to load script",e):t()}))}Bh(e){var i=e||(null==t?void 0:t.location.href);if(i){var r=this._instance.config.disable_capture_url_hashes?Re(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Jn,...s||[]]:[];return Hn(r,n,Qn)}Dl.error("Could not determine current URL")}}},Pu={exceptionObserver:class{constructor(e){var i;this.Uh=()=>{var e;if(t&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var i=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Vh&&this.Di.capture_unhandled_errors&&(this.Vh=i(this.captureException.bind(this))),!this.Gh&&this.Di.capture_unhandled_rejections&&(this.Gh=r(this.captureException.bind(this))),!this.Zh&&this.Di.capture_console_errors&&(this.Zh=s(this.captureException.bind(this)))}catch(t){Al.error("failed to start",t),this.Qh()}}},this._instance=e,this.Jh=!(null==(i=this._instance.persistence)||!i.props[Wi]),this.oe=new xt(_({},function(t){var e,i,r,s;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:Al})),this.Di=this.Kh(),this.startIfEnabledOrStop()}Kh(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return tt(t)?e=_({},e,t):(it(t)?this.Jh:t)&&(e=_({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Di.capture_console_errors||this.Di.capture_unhandled_errors||this.Di.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Al.info("enabled"),this.Qh(),this.Xn(this.Uh)):this.Qh()}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return Al.error("failed to load script",e);t()}))}Qh(){var t,e,i;null==(t=this.Vh)||t.call(this),this.Vh=void 0,null==(e=this.Gh)||e.call(this),this.Gh=void 0,null==(i=this.Zh)||i.call(this),this.Zh=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Jh=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Wi]:this.Jh}),this.Di=this.Kh(),this.startIfEnabledOrStop())}}onConfigChange(){this.Di=this.Kh()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.oe.consumeRateLimit(s)?Al.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.Yh=[],this.Xh=new ti([new vi,new xi,new fi,new ci,new bi,new yi,new _i,new wi],function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];return function(e,r){void 0===r&&(r=0);for(var s=[],n=e.split("\n"),o=r;n.length>o;o++){var a=n[o];if(1024>=a.length){var l=di.test(a)?a.replace(di,"$1"):a;if(!l.match(/\S*Error: /)){for(var u of i){var h=u(l,t);if(h){s.push(h);break}}if(s.length>=50)break}}}return function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return _({},t,{filename:t.filename||(i=e,i[i.length-1]||{}).filename,function:t.function||ei});var i}))}(s)}}("web:javascript",ai,hi)),this._instance=t,this.Yh=null!==(e=null==(i=this._instance.persistence)?void 0:i.get_property(Gi))&&void 0!==e?e:[],this.td=Ti(this.ed()),this.rd=new Pi(this.td)}onConfigChange(){this.td=Ti(this.ed()),this.rd.setConfig(this.td)}onRemoteConfig(t){var e,i,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(e=null==(i=s.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Yh=n,this._instance.persistence&&this._instance.persistence.register({[Gi]:this.Yh,[Ki]:o})}}}get nd(){var t,e=!!this._instance.get_property(Ki),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.Xh.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.td.enabled)try{if(!rt(t)||0===t.trim().length)return void fu.warn("Ignoring exception step because message must be a non-empty string");var i=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>ki.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(this.sd(e)),r=i.sanitizedProperties,s=i.droppedKeys;s.length>0&&fu.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.rd.add(_({[Si]:t,[Ei]:(new Date).toISOString()},r))}catch(t){fu.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.ad(e)){if(this.od(e))return this.ld("Exception dropped: matched a suppression rule"),void fu.info("Skipping exception capture because a suppression rule matched");if(!this.nd&&this.ud(e))return this.ld("Exception dropped: thrown by a browser extension"),void fu.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.hd(e))return this.ld("Exception dropped: thrown by the PostHog SDK"),void fu.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.td.enabled&&ot(t.$exception_steps)?this.dd(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(i.$release_id=r);try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Jo:!0});return s&&this.rd.clear(),s}catch(t){return fu.error("Failed to capture exception event. Dropping this exception.",t),void this.rd.clear()}}catch(t){return void fu.error("Failed to process exception event. Ignoring this exception.",t)}var n}dd(t){try{var e=this.rd.getAttachable();return 0===e.length?t:_({},t,{$exception_steps:e})}catch(e){return fu.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}ld(t){this.td.enabled&&this.rd.add({[Si]:t,[Ei]:(new Date).toISOString()})}sd(t){return tt(t)?_({},t):{}}ed(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}od(t){if(0===t.length)return!1;try{var e=t.reduce(((t,e)=>{var i=e.type,r=e.value;return rt(i)&&i.length>0&&t.$exception_types.push(i),rt(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Yh.some((t=>{var i=t.values.map((t=>{var i=Va[t.operator],r=e[t.key];if(!i||!r)return!1;var s=X(t.value)?t.value:[t.value];return s.length>0&&i(s,r)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}catch(t){return fu.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}ud(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>{var e=t.filename;return!!e&&pu.some((t=>e.startsWith(t)))}))}hd(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ad(t){return!ot(t)&&X(t)}}},Ru=_({productTours:class{get Ta(){return this._instance.persistence}constructor(t){this.vd=null,this.fd=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var i,r;if(this.Ta&&this.Ta.register({[Qi]:!!e.productTours}),!Gl(this._instance))return!this.vd&&ot(null==(i=this.Ta)?void 0:i.props[Er])||Wl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.vd)||r.stop(),this.vd=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.vd&&Gl(this._instance)&&this.Xn((()=>this.pd()))}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Wl.error("Could not load product tours script",e):t()}))}pd(){var t;!this.vd&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.vd=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!X(this.fd)||e){var i=this.Ta;if(i){var r=i.props[Er];if(X(r)&&!e)return this.fd=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:e=>{if(Gl(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||Wl.warn(s):Wl.error(s),void t([],{isLoaded:!1,error:s})}var n=X(e.json.product_tours)?e.json.product_tours:[];this.fd=n,i&&i.register({[Er]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.fd,{isLoaded:!0})}getActiveProductTours(t){ot(this.vd)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.vd.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.vd)||e.showTourById(t)}previewTour(t){this.vd?this.vd.previewTour(t):this.Xn((()=>{var e;this.pd(),null==(e=this.vd)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.vd)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.vd)||t.nextStep()}previousStep(){var t;null==(t=this.vd)||t.previousStep()}clearCache(){var t;this.fd=null,null==(t=this.Ta)||t.unregister(Er)}resetTour(t){var e;null==(e=this.vd)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.vd)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.vd)||e.cancelPendingTour(t)}}},ku),Ou={siteApps:class{constructor(t){this.gd=0,this._instance=t,this.md=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yd(t,e){if(e){var i=this.globalsForEvent(e);this.md.push(i),this.md.length>1e3&&(this.md=this.md.slice(10))}}get siteAppLoaders(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.yd.bind(this));this.bd=()=>{t(),this.md=[],this.bd=void 0}}}globalsForEvent(t){var e,i,r,s,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(h)){var v=d[0];l[v]={id:u[v],type:v,properties:d[1]}}var c=t.$set_once,f=t.$set;return{event:_({},g(t,Kl),{properties:_({},t.properties,f?{$set:_({},null!==(e=null==(i=t.properties)?void 0:i.$set)&&void 0!==e?e:{},f)}:{},c?{$set_once:_({},null!==(r=null==(s=t.properties)?void 0:s.$set_once)&&void 0!==r?r:{},c)}:{}),elements_chain:null!==(n=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=t.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_d(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Jl.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Jl.error("prepare_external_dependency_script returned null"),null):t}wd(){var t,e,i,s,n,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var u=null==r?void 0:r.defaultView,h=null==u||null==(t=u.Node)?void 0:t.prototype;if(!u||!h)return()=>{};if(this.gd++,this.kd)return this.Sd();var d=[],v=this,c=new WeakSet,f=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),d.push((()=>{t[e]=r}))}},p=t=>{if(c.has(t))return t;var e=v._d(t);return e&&c.add(e),e},_=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!nt(t)));return f(h,"appendChild",(t=>function(e){var i=p(e);return i?t.call(this,i):e})),f(h,"insertBefore",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):e})),f(h,"replaceChild",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):i})),[null==(e=u.Element)?void 0:e.prototype,null==(i=u.Document)?void 0:i.prototype,null==(s=u.DocumentFragment)?void 0:s.prototype].forEach((t=>{f(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))}))})),[null==(n=u.Element)?void 0:n.prototype,null==(o=u.CharacterData)?void 0:o.prototype,null==(a=u.DocumentType)?void 0:a.prototype].forEach((t=>{f(t,"before",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=_(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),f(null==(l=u.Element)?void 0:l.prototype,"insertAdjacentElement",(t=>function(e,i){var r=p(i);return r?t.call(this,e,r):null})),this.kd=()=>{d.forEach((t=>t())),this.kd=void 0},this.Sd()}Sd(){var t=!1;return()=>{var e;t||(t=!0,this.gd--,0===this.gd&&(null==(e=this.kd)||e.call(this)))}}xd(t,e){void 0===e&&(e=!0);var i=this.wd();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.md.length&&(Jl.info("Processing "+this.md.length+" events for site app with id "+t.id),this.md.forEach((t=>this.xd((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.bd)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Jl.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this.xd((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1).processEvent;n&&(e.processEvent=n),r=!0}catch(e){Jl.error(Yl+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Jl.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Cd(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Td(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.xd((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Jl.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Cd(),void this._instance.on("eventCaptured",(t=>this.Td(t)))):void Jl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.bd)||i.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,e=a.id,i=a.url;v["__$$ph_site_app_"+e]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,i,(t=>{if(t)return Jl.error(Yl+e,t)}))};for(var a of n.siteApps)o()}else Jl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Cu={tracingHeaders:class{constructor(t){this.Md=void 0,this.Ed=void 0,this.Id=void 0,this.Uh=()=>{var t,e,i=this.Rd();i?(it(this.Md)&&(this.Md=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),it(this.Ed)&&(this.Ed=null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Qh()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return Ml.error("failed to load script",e);t()}))}Pd(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Rd(){var t=this.Pd();return X(t)?(X(this.Id)?this.Id.splice(0,this.Id.length,...t):this.Id=[...t],t.length>0?this.Id:void 0):(X(this.Id)&&this.Id.splice(0),this.Id=t||void 0,this.Id)}Qh(){var t,e;null==(t=this.Md)||t.call(this),null==(e=this.Ed)||e.call(this),this.Md=void 0,this.Ed=void 0}startIfEnabledOrStop(){this.Rd()?this.Xn(this.Uh):this.Qh()}}},Iu=_({surveys:class{get Di(){return this._instance.config}constructor(t){this.Ad=void 0,this._surveyManager=null,this.Fd=!1,this.Od=[],this.Ld=null,this.$d=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Di.disable_surveys){if(!t.ok)return tl.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(ot(e))return tl.warn("Flags not loaded yet. Not loading surveys.");var i=X(e);this.Ad=i?e.length>0:e,tl.info("flags response received, isSurveysEnabled: "+this.Ad),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(el)||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.Fd)tl.info("Already initializing surveys, skipping...");else if(this.Di.disable_surveys)tl.info(iu);else if(this.Di.cookieless_mode&&this._instance.consent.isOptedOut())tl.info("Not loading surveys in cookieless mode without consent.");else{var t=null==v?void 0:v.__PosthogExtensions__;if(t){if(!it(this.Ad)||this.Di.advanced_enable_surveys){var e=this.Ad||this.Di.advanced_enable_surveys;this.Fd=!0;try{var i=t.generateSurveys;if(i)return void this.Dd(i,e);var r=t.loadExternalDependency;if(!r)return void this.Nd(Br);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.Nd("Could not load surveys script",i):this.Dd(t.generateSurveys,e)}))}catch(t){throw this.Nd("Error initializing surveys",t),t}finally{this.Fd=!1}}}else tl.error("PostHog Extensions not found.")}}Dd(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new tu(this._instance),tl.info("Surveys loaded successfully"),this.qd({isLoaded:!0})}Nd(t,e){tl.error(t,e),this.qd({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Od.push(t),this._surveyManager&&this.qd({isLoaded:!0}),()=>{this.Od=this.Od.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Di.disable_surveys)return tl.info(iu),t([]);var i,r=this._instance.get_property(yr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.jd()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.Ld?this.Ld.then((e=>t(e.surveys,e.context))):("undefined"!=typeof Promise&&(this.Ld=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Di.token),method:"GET",timestampMode:"query",timeout:this.Di.surveys_request_timeout_ms,callback:e=>{var r;this.Ld=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;0!==s?tl.error(n):e.error||tl.warn(n),this.$d=Date.now();var o={isLoaded:!1,error:n};return t([],o),void(null==i||i({surveys:[],context:o}))}this.$d=null;var a,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Za(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[yr]:l,[br]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}jd(){return this.Bd()&&!this.Ld&&!this.Hd()}Bd(){var t=this._instance.get_property(br);return at(t)&&Date.now()-t>3e5}Hd(){return at(this.$d)&&3e5>Date.now()-this.$d}markSurveyAsSeen(t,e){var i,r={id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null};il(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}qd(t){for(var e of this.Od)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){tl.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!ot(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);tl.warn("init was not called")}Ud(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}zd(t){if(ot(this._surveyManager))return{eligible:!1,reason:eu};var e="string"==typeof t?this.Ud(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Wd(t){if(ot(this._surveyManager))return{eligible:!1,reason:eu};var e="string"==typeof t?this.Ud(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(ot(this._surveyManager))return tl.warn("init was not called"),{visible:!1,disabledReason:eu};var e=this.Wd(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return ot(this._surveyManager)?(tl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:eu})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this.Wd(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(ot(this._surveyManager))tl.warn("init was not called");else{var n="string"==typeof t?this.Ud(t):t;if(null!=n&&n.id)if(rl.includes(n.type)){var o=null==r?void 0:r.querySelector(e);if(o)return null!=(s=n.appearance)&&s.surveyPopupDelaySeconds?(tl.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;tl.info("Rendering survey "+n.id+" with delay of "+(null==(t=n.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(n,o,i),tl.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,o,i);tl.warn("Survey element not found")}else tl.warn("Surveys of type "+n.type+" cannot be rendered in the app");else tl.warn("Survey not found")}}displaySurvey(t,e){var i;if(ot(this._surveyManager))tl.warn("init was not called");else{var r=this.Ud(t);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=_({},r,{appearance:_({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Po.Popover&&e.initialResponses&&tl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var n=this.zd(r);if(!n.eligible)return void tl.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==Po.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else tl.warn("Survey not found")}}cancelPendingSurvey(t){ot(this._surveyManager)?tl.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},ku),Au={toolbar:class{constructor(t){this.instance=t}Vd(t){v.ph_toolbar_state=t}Gd(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,i,s){if(void 0===e&&(e=void 0),void 0===i&&(i=void 0),void 0===s&&(s=void 0),us(this.instance.config))return!1;if(!t||!r)return!1;e=null!=e?e:t.location,s=null!=s?s:t.history;try{if(!i){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}i=null==t?void 0:t.localStorage}var n,o=ru||Vn(e.hash,"__posthog")||Vn(e.hash,"state"),a=o?rs((()=>JSON.parse(atob(decodeURIComponent(o)))))||rs((()=>JSON.parse(decodeURIComponent(o)))):null;return a&&"ph_authorize"===a.action?((n=a).source="url",n&&Object.keys(n).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):((n=JSON.parse(i.getItem(su)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}Zd(t){var e=v.ph_load_toolbar||v.ph_load_editor;!ot(e)&&Z(e)?e(t,this.instance):nu.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==r||!r.getElementById(Ls));if(!t||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=_({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(su,JSON.stringify(_({},n,{source:void 0}))),2===this.Gd())this.Zd(n);else if(0===this.Gd()){var o;this.Vd(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return nu.error("[Toolbar] Failed to load",t),void this.Vd(0);this.Vd(2),this.Zd(n)})),ls(t,"turbolinks:load",(()=>{this.Vd(0),this.loadToolbar(n)}))}return!0}Qd(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Fu=_({experiments:mu},ku),Mu={conversations:class{constructor(t){this.Jd=void 0,this._conversationsManager=null,this.Kd=!1,this.Me=null,this.Yd=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Xd=t.ok,t.ok)){var e=t.config.conversations;ot(e)||(ut(e)?this.Jd=e:(this.Jd=e.enabled,this.Me=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Jd=void 0,this.Me=null,this.Xd=void 0,this.Yd=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Kd||this._instance.config.disable_conversations||us(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!it(this.Jd)&&this.Jd)if(this.Me&&this.Me.token){this.Kd=!0;try{var e=t.initConversations;if(e)return this.tv(e),void(this.Kd=!1);var i=t.loadExternalDependency;if(!i)return void this.ev(Br);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.ev("Could not load conversations script",e):this.tv(t.initConversations),this.Kd=!1}))}catch(t){this.ev("Error initializing conversations",t),this.Kd=!1}}else yu.error("Conversations enabled but missing token in remote config.")}}tv(t){if(this.Me)try{this._conversationsManager=t(this.Me,this._instance),this.Yd=!1,yu.info("Conversations loaded successfully")}catch(t){this.ev("Error completing conversations initialization",t)}else yu.error("Cannot complete initialization: remote config is null")}ev(t,e){yu.error(t,e),this._conversationsManager=null,this.Kd=!1,this.Yd=!0}show(){this._conversationsManager?this._conversationsManager.show():yu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Jd&&!nt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":us(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Xd?"remote_config_failed":it(this.Jd)?this.Xd?"disabled_in_project":"remote_config_pending":this.Jd?ot(this.Me)||!this.Me.token?"missing_token":null!=v&&v.__PosthogExtensions__?this.Kd?"initializing":this.Yd?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,e,i){var r=this;return p((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,i):(yu.warn(bu),null)}))()}getMessages(t,e){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(yu.warn(bu),null)}))()}markAsRead(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(yu.warn(bu),null)}))()}getTickets(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(yu.warn(bu),null)}))()}requestRestoreLink(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(yu.warn(bu),null)}))()}restoreFromToken(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(yu.warn(bu),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(yu.warn(bu),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}sl(){var t;null==(t=this._conversationsManager)||t.setIdentity()}al(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},Du={logs:class{constructor(e){var i,r=this;this.iv=!1,this.rv=!1,this.I=Ii("[logs]"),this.nv=_({},this.I,{error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];e.some(Eu)||r.I.error(...e)}}),this.na=[],this.sv=[],this.Tu=0,this.av=()=>{var t,e;this.Tu=0,null==(t=this.ov)||t.onReconnect(),null==(e=this.lv)||e.onReconnect()},this._instance=e,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.iv=!0),t&&ls(t,"online",this.av)}uv(t,e,i,r){var s,n=function(t,e){var i,r,s,n,o,a,l,u=null!==(i=null==t?void 0:t.flushIntervalMs)&&void 0!==i?i:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,d=null!=e&&e.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,v=it(d)?Math.max(h,2048):Math.max(h,d),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==c?void 0:c["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==n?n:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(a=null==c?void 0:c["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,i);return[new Ve(this.hv(t,e),n,this.nv,(()=>this.dv()),(t=>t()),void 0,r),n]}vv(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.ov||this.fv!==e){var i;null==(i=this.ov)||i.reset(),this.fv=e;var r=this.uv((()=>this.na),(t=>{this.na=t}));this.ov=r[0],this.pv=r[1]}return this.ov}gv(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.lv||this.mv!==e){var i;null==(i=this.lv)||i.reset(),this.mv=e;var r=this.uv((()=>this.sv),(t=>{this.sv=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},wu);this.lv=r[0],this.yv=r[1]}return this.lv}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e;if(t.ok){var i=null==(e=t.config.logs)?void 0:e.captureConsoleLogs;!ot(i)&&i&&(this.iv=!0,this.loadIfEnabled())}}reset(){var t,e;this.na=[],null==(t=this.ov)||t.reset(),this.sv=[],null==(e=this.lv)||e.reset(),this.Tu=0}captureLog(t){this.vv().captureLog(t)}ci(t){this.gv().captureLog(t)}get logger(){return this.bv||(this.bv={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.bv}flushLogs(t){t?this._v(t):(this.ov&&this.ov.flush().catch((t=>this.wv(t))),this.lv&&this.lv.flush().catch((t=>this.wv(t))))}wv(t){Eu(t)||this.I.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.iv&&!this.rv){var t=null==v?void 0:v.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.I.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.rv=!0)})):this.I.error(Br)}else this.I.error("PostHog Extensions not found.")}}hv(t,e){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:e=>e===S.LogsQueue?t():void 0,setPersistedProperty(t,i){var r;t===S.LogsQueue&&e(null!==(r=i)&&void 0!==r?r:[])},Cn:t=>this.Cn(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Cn(t){return new Promise((e=>{if(Wn(this.Tu,3))e({kind:"fatal",error:Su(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Su(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Sv(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var e=t.statusCode;if(this.xv(e),e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;0===e?(t.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Su(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}}))}xv(t){(0!==t||this._instance.__loaded)&&(this.Tu=Gn(t,this.Tu,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."))))}_v(t){this.na.length>0&&this.Cv(t,this.na,this.pv,c.LIB_NAME,(t=>{this.na=t})),this.sv.length>0&&this.Cv(t,this.sv,this.yv,wu,(t=>{this.sv=t}))}Cv(t,e,i,r,s){if(0!==e.length){var n=e.map((t=>t.record));s([]);var o=He(n,qe(i,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Sv(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Sv(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}dv(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=i.windowId,s=i.sessionStartTimestamp,n=i.lastActivityTimestamp;e.sessionId=i.sessionId,e.windowId=r,ot(s)||(e.sessionStartTimestamp=s),ot(n)||(e.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?Re(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},Nu={metrics:class{constructor(t){this.I=Ii("[metrics]"),this._instance=t}initialize(){}vv(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.ov&&this.fv===i||(null==(e=this.ov)||e.reset(),this.fv=i,this.ov=new Je(this.hv(),function(t){var e,i,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==o?void 0:o["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this.I)),this.ov}count(t,e,i){void 0===e&&(e=1),this.vv().count(t,e,i)}gauge(t,e,i){this.vv().gauge(t,e,i)}histogram(t,e,i){this.vv().histogram(t,e,i)}flush(t){if(!this.ov)return Promise.resolve();if(t){var e=this.ov.drainWindow();return e&&this.Bn(e,t),Promise.resolve()}return this.ov.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.ov)||t.reset()}hv(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Bn:t=>e.Bn(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Bn(t,e){return new Promise((i=>{var r=!1,s=t=>{r||(r=!0,clearTimeout(n),i(t))},n=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(_({method:"POST",url:this.Tv(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)s({kind:"ok"});else if(413===e)s({kind:"too-large"});else if(0!==e&&429!==e&&500>e)s({kind:"fatal",error:new Error("metrics request failed with status "+e)});else{var i;s({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}}))}))}Tv(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Uu=_({},ku,$u,Tu,Pu,Ru,Ou,Iu,Cu,Au,Fu,Mu,Du,Nu);$l.__defaultExtensionClasses=_({},Uu);var Lu=function(){c.SDK_DIST_CHANNEL="npm";var e=vl[bl]=new $l;return function(){function e(){e.done||(e.done=!0,wl=!1,ts(vl,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?e():ls(r,"DOMContentLoaded",e,{capture:!1}):t&&Ci.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{go as Compression,Ro as DEFAULT_PRODUCT_TOUR_APPEARANCE,Po as DisplaySurveyType,$l as PostHog,Oo as ProductTourEventName,Co as ProductTourEventProperties,$o as SurveyEventName,To as SurveyEventProperties,mo as SurveyEventType,bo as SurveyPosition,Eo as SurveyQuestionBranchingType,So as SurveyQuestionType,ko as SurveySchedule,wo as SurveyTabPosition,xo as SurveyType,yo as SurveyWidgetType,Lu as default,Lu as posthog,Do as severityLevels};
1
+ var t="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:t,i=null==e?void 0:e.navigator,r=null==e?void 0:e.document,s=null==e?void 0:e.location,n=null==e?void 0:e.fetch,o=null!=e&&e.XMLHttpRequest&&"withCredentials"in new e.XMLHttpRequest?e.XMLHttpRequest:void 0,a=null==e?void 0:e.AbortController,l=null==e?void 0:e.CompressionStream,u=null==i?void 0:i.userAgent;function h(){return!(!t||!1===t.navigator.onLine)}var d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});var v=null!=t?t:{},c={DEBUG:!1,LIB_VERSION:"0.5.0",LIB_NAME:"browser-common"};function f(t,e,i,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(r,s)}function p(t){return function(){var e=this,i=arguments;return new Promise((function(r,s){var n=t.apply(e,i);function o(t){f(n,r,s,o,a,"next",t)}function a(t){f(n,r,s,o,a,"throw",t)}o(void 0)}))}}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},_.apply(null,arguments)}function g(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}var m=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function y(t){return"string"==typeof t||t}function b(t){return"string"==typeof t?t:void 0}var w,x=["$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"],S=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),E=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),k=["$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"],T=["token"],P="NativeGzipValidationError",R=t=>t.length>=2&&31===t[0]&&139===t[1],O=(t,e)=>t===E.GZipJS||e===E.GZipJS||"gzip"===e,C=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),I=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=P,e},A=function(){var t=p((function*(t,e){18>t.size&&I("too-short");var i=new Uint8Array(yield t.slice(0,10).arrayBuffer());R(i)&&8===i[2]||I("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var e=(()=>{if(w)return w;w=[];for(var t=0;256>t;t++){for(var e=t,i=0;8>i;i++)e=1&e?3988292384^e>>>1:e>>>1;w[t]=e>>>0}return w})(),i=4294967295,r=0;t.length>r;r++)i=e[255&(i^t[r])]^i>>>8;return(4294967295^i)>>>0})(e)&&I("invalid-crc");var s=e.length>>>0;r.getUint32(4,!0)!==s&&I("invalid-size")}));return function(e,i){return t.apply(this,arguments)}}();function F(){return F=p((function*(t,e,i){void 0===e&&(e=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),n=s.writable.getWriter(),o=n.write(r).then((()=>n.close())).catch(function(){var t=p((function*(t){try{yield n.abort(t)}catch(t){}throw t}));return function(e){return t.apply(this,arguments)}}()),a=new Response(s.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield A(l,r),l}catch(t){if(null!=i&&i.rethrow)throw t;return e&&console.error("Failed to gzip compress data",t),null}})),F.apply(this,arguments)}var M=20,D=1e3,N=1e4,U="[Circular]",L="[Truncated]",j="[Unserializable]",B="[Function]";function z(t){for(var e="",i=0;t.length>i;i++){var r=t.charCodeAt(i);if(55296>r||r>56319)e+=56320>r||r>57343?t[i]:"�";else{var s=t.charCodeAt(i+1);56320>s||s>57343?e+="�":(e+=t[i]+t[i+1],i++)}}return e}var q=["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"],H=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return q.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function V(t,e){return-1!==t.indexOf(e)}var W=function(t){return t.trim()},G=function(t){return t.replace(/^\$/,"")};function K(t){var e,i=[];return null!==(e=JSON.stringify(t,(function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(e))return"[Circular]";i.push(e)}return e}})))&&void 0!==e?e:"null"}var J=Object.prototype,Y=J.hasOwnProperty,Q=J.toString,X=Array.isArray||function(t){return"[object Array]"===Q.call(t)},Z=t=>"function"==typeof t,tt=t=>t===Object(t)&&!X(t),et=t=>{if(tt(t)){for(var e in t)if(Y.call(t,e))return!1;return!0}return!1},it=t=>void 0===t,rt=t=>"[object String]"==Q.call(t),st=t=>rt(t)&&0===t.trim().length,nt=t=>null===t,ot=t=>it(t)||nt(t),at=t=>"[object Number]"==Q.call(t)&&t==t,lt=t=>at(t)&&t>0,ut=t=>"[object Boolean]"===Q.call(t),ht=t=>t instanceof FormData,dt=t=>V(k,t),vt=t=>V(T,t);function ct(t){return null===t||"object"!=typeof t}function ft(t,e){return{}.toString.call(t)==="[object "+e+"]"}function pt(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return gt(t,Error)}}function _t(t){return"undefined"!=typeof Event&&gt(t,Event)}function gt(t,e){try{return t instanceof e}catch(t){return!1}}var mt=[!0,"true",1,"1","yes"],yt=t=>V(mt,t),bt=[!1,"false",0,"0","no"];function wt(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),at(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),wt(s||i,e,i,r))}class xt{constructor(t){this.k={},this.S=t.S,this.C=wt(t.bucketSize,0,100,t.I),this.R=wt(t.refillRate,0,this.C,t.I),this.A=wt(t.refillInterval,0,864e5,t.I)}O(t,e){var i=Math.floor((e-t.lastAccess)/this.A);i>0&&(t.tokens=Math.min(t.tokens+i*this.R,this.C),t.lastAccess=t.lastAccess+i*this.A)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.k[r];return s?this.O(s,i):this.k[r]=s={tokens:this.C,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.S)||e.call(this,t)),0===s.tokens)}stop(){this.k={}}}var St="Mobile",Et="iOS",kt="Android",$t="Tablet",Tt=kt+" "+$t,Pt="iPad",Rt="Apple",Ot=Rt+" Watch",Ct="Safari",It="BlackBerry",At="Samsung",Ft=At+"Browser",Mt=At+" Internet",Dt="Chrome",Nt=Dt+" OS",Ut=Dt+" "+Et,Lt="Internet Explorer",jt=Lt+" "+St,Bt="Opera",zt=Bt+" Mini",qt="Edge",Ht="Microsoft "+qt,Vt="Firefox",Wt=Vt+" "+Et,Gt="Nintendo",Kt="PlayStation",Jt="Xbox",Yt=kt+" "+St,Qt=St+" "+Ct,Xt="Windows",Zt=Xt+" Phone",te="Nokia",ee="Ouya",ie="Generic",re=ie+" "+St.toLowerCase(),se=ie+" "+$t.toLowerCase(),ne="Konqueror",oe="Oculus Browser",ae="Vivaldi",le="Yandex",ue="Whale",he="DuckDuckGo",de="Pale Moon",ve="Waterfox",ce="Brave",fe="Google Search App",pe="(\\d+(\\.\\d+)?)",_e=new RegExp("Version/"+pe),ge=new RegExp(Jt,"i"),me=new RegExp(Kt+" \\w+","i"),ye=new RegExp(Gt+" \\w+","i"),be=new RegExp(It+"|PlayBook|BB10","i"),we={"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"},xe=function(t,e,i,r){e=e||"";var s=function(t){return null!=t&&t.brave?ce:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&V(t,"GSA/")?fe:V(t," OPR/")&&V(t,"Mini")?zt:V(t," OPR/")?Bt:be.test(t)?It:V(t,"IE"+St)||V(t,"WPDesktop")?jt:V(t,"OculusBrowser")?oe:V(t,Ft)?Mt:V(t,qt)||V(t,"Edg/")?Ht:V(t,ae+"/")?ae:V(t,"YaBrowser/")?le:V(t,ue+"/")?ue:V(t,he+"/")||V(t,"Ddg/")?he:V(t,"FBIOS")?"Facebook "+St:V(t,"UCWEB")||V(t,"UCBrowser")?"UC Browser":V(t,"CriOS")?Ut:V(t,"CrMo")||V(t,Dt)?Dt:V(t,kt)&&V(t,Ct)?Yt:V(t,"FxiOS")?Wt:V(t.toLowerCase(),ne.toLowerCase())?ne:V(t,ce+"/")?ce:((t,e)=>e&&V(e,Rt)||function(t){return V(t,Ct)&&!V(t,Dt)&&!V(t,kt)}(t))(t,e)?V(t,St)?Qt:Ct:V(t,"PaleMoon/")?de:V(t,ve+"/")?ve:V(t,Vt)?Vt:V(t,"MSIE")||V(t,"Trident/")?Lt:V(t,"Gecko")?Vt:"")},Se={[jt]:[new RegExp("rv:"+pe)],[Ht]:[new RegExp(qt+"?\\/"+pe)],[Dt]:[new RegExp("("+Dt+"|CrMo)\\/"+pe)],[Ut]:[new RegExp("CriOS\\/"+pe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+pe)],[Ct]:[_e],[Qt]:[_e],[Bt]:[new RegExp("(Opera|OPR)\\/"+pe)],[Vt]:[new RegExp(Vt+"\\/"+pe)],[Wt]:[new RegExp("FxiOS\\/"+pe)],[ne]:[new RegExp("Konqueror[:/]?"+pe,"i")],[It]:[new RegExp(It+" "+pe),_e],[Yt]:[new RegExp("android\\s"+pe,"i")],[Mt]:[new RegExp(Ft+"\\/"+pe)],[oe]:[new RegExp("OculusBrowser\\/"+pe)],[ae]:[new RegExp(ae+"\\/"+pe)],[le]:[new RegExp("YaBrowser\\/"+pe)],[ue]:[new RegExp(ue+"\\/"+pe)],[ce]:[new RegExp(ce+"\\/"+pe)],[he]:[new RegExp("(DuckDuckGo|Ddg)\\/"+pe)],[de]:[new RegExp("PaleMoon\\/"+pe)],[ve]:[new RegExp(ve+"\\/"+pe)],[fe]:[new RegExp("GSA\\/"+pe)],[Lt]:[new RegExp("(rv:|MSIE )"+pe)],Mozilla:[new RegExp("rv:"+pe)]},Ee=function(t,e,i,r){var s=xe(t,e,i,r),n=Se[s];if(it(n))return null;for(var o=0;n.length>o;o++){var a=t.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},ke=[[new RegExp(Jt+"; "+Jt+" (.*?)[);]","i"),t=>[Jt,t&&t[1]||""]],[new RegExp(Gt,"i"),[Gt,""]],[new RegExp(Kt,"i"),[Kt,""]],[be,[It,""]],[new RegExp(Xt,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Zt,""];if(new RegExp(St).test(e)&&!/IEMobile\b/.test(e))return[Xt+" "+St,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=we[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[Xt,r]}return[Xt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Et,[t[3],t[4],t[5]||"0"].join(".")]:[Et,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=it(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+kt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+kt+")","i"),t=>t&&t[2]?[kt,[t[2],t[3],t[4]||"0"].join(".")]:[kt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Nt,""]],[/Linux|debian/i,["Linux",""]]],$e=function(t){return ye.test(t)?Gt:me.test(t)?Kt:ge.test(t)?Jt:new RegExp(ee,"i").test(t)?ee:new RegExp("("+Zt+"|WPDesktop)","i").test(t)?Zt:/iPad/.test(t)?Pt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ot:be.test(t)?It:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(te,"i").test(t)?te:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(St).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?kt:Tt:new RegExp("(pda|"+St+")","i").test(t)?re:new RegExp($t,"i").test(t)&&!new RegExp($t+" pc","i").test(t)?se:""},Te=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Pe(t,e){return"string"==typeof(i=t)&&Te.test(i)?t:e();var i}function Re(t){return t?t.split("#")[0]:t}function Oe(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function Ce(t,e,i){return Ie.apply(this,arguments)}function Ie(){return(Ie=p((function*(t,e,i){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=Oe((()=>{try{null==i||i(),t()}catch(t){s(t)}}),e)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Ae={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}},Fe=Ae.info,Me=0x8000000000000000,De={}.propertyIsEnumerable;function Ne(t,e){try{return je(t,e,{ancestors:new WeakSet,remainingNodes:N},0)}catch(t){return[]}}function Ue(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:L};if(i.remainingNodes--,ut(t))return{boolValue:t};if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if("undefined"==typeof BigInt)return{stringValue:String(t)};var s=BigInt(t).toString();return t>=Me||-Me>t?(null==e||e.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:z(t)};if("function"==typeof t)return{stringValue:B};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(i.ancestors.has(t))return{stringValue:U};if(r>=M)return{stringValue:L};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof o?z(o):String(o)}}i.ancestors.add(t);try{try{var a=t.toJSON;if("function"==typeof a)return Ue(a.call(t),e,i,r+1)}catch(t){}return X(t)?{arrayValue:{values:Le(t,e,i,r+1)}}:{kvlistValue:{values:je(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:z(String(t))}}function Le(t,e,i,r){for(var s=[],n=Math.min(t.length,D),o=0;n>o&&i.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(ot(a))continue;s.push(Ue(a,e,i,r))}catch(t){s.push({stringValue:j})}return t.length>o&&s.push({stringValue:L}),s}function je(t,e,i,r){var s=[];for(var n in t)if(De.call(t,n)){if(s.length>=D||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(nt(o)||it(o))continue;s.push({key:z(n),value:Ue(o,e,i,r)})}catch(t){s.push({key:z(n),value:{stringValue:j}})}}return s}function Be(t){try{return z(String(t))}catch(t){return j}}function ze(t,e,i){var r=Ae[t.level||"info"]||Fe,s=r.text,n=r.number,o=String(Date.now())+"000000",a={};e.distinctId&&(a.posthogDistinctId=e.distinctId),e.sessionId&&(a.sessionId=e.sessionId),e.windowId&&(a["window.id"]=e.windowId),ot(e.sessionStartTimestamp)||(a.sessionStartTimestamp=String(e.sessionStartTimestamp)),ot(e.lastActivityTimestamp)||(a.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(a["url.full"]=e.currentUrl),e.screenName&&(a["screen.name"]=e.screenName),e.appState&&(a["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(a.feature_flags=e.activeFeatureFlags);var l=_({},a),u=t.attributes;if(u){var h=[];try{h=Object.keys(u)}catch(t){h=[]}for(var d of h){var v=void 0;try{v=u[d]}catch(t){v=j}Object.defineProperty(l,d,{value:v,enumerable:!0,writable:!0,configurable:!0})}}var c={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:s,body:{stringValue:Be(t.body)},attributes:Ne(l,i)};return t.trace_id&&(c.traceId=t.trace_id),t.span_id&&(c.spanId=t.span_id),it(t.trace_flags)||(c.flags=t.trace_flags),c}function qe(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}function He(t,e,i,r){return{resourceLogs:[{resource:{attributes:Ne(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let Ve=class{constructor(t,e,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Di=e,this.I=i,this.tn=r,this.en=s,this.rn=n,this.nn=o,this.sn=null,this.an=0,this.ln=0,this.un=0,this.hn=0,this.dn=!1,this.vn=e.maxBufferSize,this.cn=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.fn=e.flushIntervalMs,this.pn=e.maxBatchRecordsPerPost,this.gn=e.rateCapWindowMs,this.mn=e.maxLogsPerInterval}reset(){this.yn(),this.sn=null,this.un=0,this.hn=0,this.dn=!1,this.an=0,this.ln=0,this.pn=this.Di.maxBatchRecordsPerPost}onReconnect(){this.ln=0,this.bn()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this._n(t);if(null!==e)if(e.body){if(this.wn()){var i={record:ze(e,this.tn(),this.I)};this.en((()=>this.kn(i)))}}else this.I.info("Log was rejected in beforeSend function")}}_n(t){var e=this.Di.beforeSend;if(!e)return t;var i=X(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for log:",t),null}return r}wn(){if(void 0===this.mn)return!0;var t=Date.now(),e=t-this.un;return this.gn>e&&e>=0||(this.un=t,this.hn=0,this.dn=!1),this.mn>this.hn?(this.hn++,!0):(this.dn||(this.I.warn("captureLog dropping logs: exceeded "+this.mn+" logs per "+this.gn+"ms"),this.dn=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.sn||(t.sn=t.Sn().finally((()=>{t.sn=null}))),t.sn}))()}Sn(){var t=this;return p((function*(){var e;t.yn();var i=null!==(e=t._instance.getPersistedProperty(S.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,o;t.an=0;var a=Math.min(i.length,t.pn),l=i.slice(0,a),u=He(l.map((t=>t.record)),t.xn(),null!==(n=t.nn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.Cn(u);if("too-large"===h.kind&&l.length>1)t.pn=Math.max(1,Math.floor(l.length/2)),t.I.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+t.pn);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===h.kind&&t.Di.maxBatchRecordsPerPost>t.pn&&(t.pn=Math.min(t.Di.maxBatchRecordsPerPost,t.pn+1)),yield t.Tn(l.length),i=null!==(o=t._instance.getPersistedProperty(S.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===h.kind)throw h.error}}}))()}Tn(t){var e=this;return p((function*(){var i,r=Math.max(0,t-e.an),s=null!==(i=e._instance.getPersistedProperty(S.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(S.LogsQueue,s.slice(r)),yield e.rn()}))()}xn(){return qe(this.Di,this._instance.getLibraryId(),this._instance.getLibraryVersion())}kn(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(S.LogsQueue))&&void 0!==e?e:[];this.cn>i.length||(i.shift(),this.an++,this.I.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(S.LogsQueue,i),this.vn>i.length?this.Mn():this.bn()}}Mn(t){void 0===t&&(t=this.fn),this.En||(this.En=Oe((()=>{this.En=void 0,this.bn()}),t))}In(){var t=Math.min(Math.max(0,this.ln-1),6);return this.fn*Math.pow(2,t)}Rn(){var t=this._instance.getPersistedProperty(S.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return p((function*(){e.yn();var i=e.flush().catch((()=>{}));void 0!==t?yield Ce(i,t):yield i}))()}flushWithTimeout(t){var e=this;return p((function*(){var i=e.flush();yield Ce(i,t,(()=>{i.catch((()=>{}))}))}))()}bn(){this.flush().then((()=>{this.ln=0}),(t=>{this.ln++,this.I.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Rn()&&this.Mn(this.In())}))}yn(){this.En&&(clearTimeout(this.En),this.En=void 0)}};var We=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ge(t){return String(t)+"000000"}function Ke(t,e,i,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+s}let Je=class{constructor(t,e,i){this._instance=t,this.Di=e,this.I=i,this.Pn=new Map,this.sn=null,this.An=!1,this.Fn=new Map,this.On=new Set,this.Ln=0}count(t,e,i){void 0===e&&(e=1),this.$n({name:t,type:"count",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(t,e,i){this.$n({name:t,type:"gauge",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(t,e,i){this.$n({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var t=this,e=this.sn,i=function(){var i=p((function*(){e&&(yield e.catch((()=>{}))),yield t.Dn()}));return function(){return i.apply(this,arguments)}}(),r=i().finally((()=>{this.sn===r&&(this.sn=null)}));return this.sn=r,r}drainWindow(){if(0===this.Pn.size)return null;var t=this.Pn;return this.Pn=new Map,this.An=!1,this.Fn=new Map,this.On=new Set,this.Nn(t)}reset(){this.Ln++,this.yn(),this.Pn=new Map,this.sn=null,this.An=!1,this.Fn=new Map,this.On=new Set}$n(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this._n(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.I.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=e.attributes?_({},e.attributes):void 0,r=Ke(e.type,e.name,e.unit,i)}catch(t){return void this.I.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var s=this.Pn.get(r);if(!s){if(!this.qn())return;s={name:e.name,type:e.type,unit:e.unit,attributes:i,windowStartMs:Date.now()},this.Pn.set(r,s)}var n=this.Fn.get(e.name);void 0===n?this.Fn.set(e.name,e.type):n===e.type||this.On.has(e.name)||(this.On.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.jn(s,e.value),this.Mn()}else this.I.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}qn(){return this.Di.maxSeriesPerFlush>this.Pn.size||(this.An||(this.An=!0,this.I.warn("Metric series cap reached ("+this.Di.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}jn(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(We.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,We)]+=1}}_n(t){var e=this.Di.beforeSend;if(!e)return t;var i=X(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for metric:",t),null}return r}Mn(){this.En||(this.En=Oe((()=>{this.En=void 0,this.flush().catch((t=>{this.I.error("Metrics flush failed:",t)}))}),this.Di.flushIntervalMs))}yn(){this.En&&(clearTimeout(this.En),this.En=void 0)}Dn(){var t=this;return p((function*(){if(0!==t.Pn.size){var e=t.Pn;t.Pn=new Map,t.An=!1,t.Fn=new Map,t.On=new Set;var i=t.Ln,r=yield t._instance.Bn(t.Nn(e));if(i===t.Ln)switch(r.kind){case"ok":return;case"retry-later":return t.Hn(e),void t.Mn();case"too-large":return void t.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.I.error("Failed to send metrics batch:",r.error)}}}))()}Nn(t){return e=this.Un(t),i=function(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}(this.Di,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ne(i)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,i,r,s}Un(t){var e=Ge(Date.now()),i=new Map;for(var r of t.values()){var s,n=Ke(r.type,r.name,r.unit,void 0),o=i.get(n);o||(o=_({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},i.set(n,o));var a=Ne(null!==(s=r.attributes)&&void 0!==s?s:{},this.I),l=Ge(r.windowStartMs);if("count"===r.type){var u,h={attributes:a,startTimeUnixNano:l,timeUnixNano:e,asDouble:null!==(u=r.total)&&void 0!==u?u:0};o.sum.dataPoints.push(h)}else if("gauge"===r.type){var d,v={attributes:a,timeUnixNano:e,asDouble:null!==(d=r.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(v)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:e,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:We})}return Array.from(i.values())}Hn(t){var e,i;for(var r of t){var s=r[0],n=r[1],o=this.Pn.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.qn()&&this.Pn.set(s,n)}}};var Ye,Qe,Xe;function Ze(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Xe&&i.length===Qe||(Qe=i.length,Xe=i.reduce(((i,r)=>{Ye||(Ye={});var s=Ye[r];if(s)i[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=e[r];if(l&&u){i[l]=u,Ye[r]=[l,u];break}}return i}),{})),Xe}}class ti{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var e=this;return p((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&X(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var i,r;return null!=t.cause&&(i=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),_({},t,{cause:i,stack:r})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return p((function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i}))()}convertToExceptionList(t,e){var i,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(i=e.type)&&void 0!==i?i:"generic",handled:null===(r=e.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,_({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:Ze(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,i){void 0===i&&(i=0);var r=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return _({},e,{syntheticException:0==i?e.syntheticException:void 0,mechanism:t,apply:t=>r(t,i),next:t=>r(t,i+1)})}}var ei="?";function ii(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?ei:i,in_app:!(null!=e&&e.startsWith("webkit-masked-url://"))&&"<anonymous>"!==e};return it(r)||(n.lineno=r),it(s)||(n.colno=s),n}var ri=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:ei,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},si=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ni=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,oi=/\((\S*)(?::(\d+))(?::(\d+))\)/,ai=(t,e)=>{var i=si.exec(t);if(i)return ii(e,i[1],ei,+i[2],+i[3]);var r=ni.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=oi.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=ri(r[1]||ei,r[2]);return ii(e,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},li=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ui=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,hi=(t,e)=>{var i=li.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ui.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||ei,o=ri(n,s);return ii(e,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},di=/\(error: (.*)\)/;class vi{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=rt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return ft(t,"DOMException")}isDOMError(t){return ft(t,"DOMError")}}class ci{match(t){return pt(t)}coerce(t,e){var i,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,e),stack:null!=r?r:null==(i=e.syntheticException)?void 0:i.stack,cause:t.cause?e.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class fi{constructor(){}match(t){return!!ft(t,"ErrorEvent")&&(null!=t.error||this.di(t))}coerce(t,e){var i;if(null!=t.error)return e.apply(t.error);var r=e.apply(t.message);return _({},r,{stack:null!==(i=this.vi(t))&&void 0!==i?i:r.stack,synthetic:!0})}di(t){return rt(t.message)&&t.message.length>0}vi(t){var e,i,r=t,s=null!==(e=r.lineno)&&void 0!==e?e:0,n=null!==(i=r.colno)&&void 0!==i?i:0;if(rt(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var pi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class _i{match(t){return"string"==typeof t}coerce(t,e){var i,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(pi);return r&&(e=r[1],i=r[2]),[e,i]}}var gi=["fatal","error","warning","log","info","debug"];function mi(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class yi{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,s=this.getErrorPropertyFromObject(t);return s?e.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(_t(t))return t.constructor.name;var e="name"in t?t.name:void 0;return rt(e)&&!st(e)?e:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+mi(t)}isSeverityLevel(t){return rt(t)&&!st(t)&&gi.indexOf(t)>=0}getStack(t){try{return rt(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:rt(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(pt(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class bi{match(t){return _t(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+mi(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class wi{match(t){return ct(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class xi{match(t){return ft(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!_t(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return ct(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Si="$message",Ei="$timestamp",ki=new Set([Si,Ei]),$i={enabled:!0,max_bytes:32768};function Ti(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:$i.enabled,max_bytes:Ri(t.max_bytes,$i.max_bytes)}:_({},$i)}class Pi{constructor(t){this.zn=[],this.Wn=0,this.Di=Ti(t)}setConfig(t){this.Di=Ti(t),this.Vn()}add(t){var e=function(t){var e;try{e=K(t)}catch(t){return}try{var i=JSON.parse(e);if(!tt(i))return;var r=i,s=r[Si],n=r[Ei];if(!rt(s)||0===s.trim().length)return;if(!rt(n)&&!at(n))return;return{step:r,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Di.max_bytes||(this.zn.push({step:e.step,bytes:i}),this.Wn+=i,this.Vn())}}getAttachable(){return this.zn.map((t=>t.step))}clear(){this.zn=[],this.Wn=0}size(){return this.zn.length}Vn(){for(;this.Wn>this.Di.max_bytes&&this.zn.length>0;){var t=this.zn.shift();t&&(this.Wn-=t.bytes)}}}function Ri(t,e){if(!at(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var Oi=function(e,i){var r=(void 0===i?{}:i).debugEnabled,s={F(i){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!it(t.console)&&t.console){for(var s=("__rrweb_original__"in t.console[i]?t.console[i].__rrweb_original__:t.console[i]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];s(e,...o)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.F("error",...e)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(t){s.error("You must initialize PostHog before calling "+t)},createLogger:(t,i)=>Oi(e+" "+t,i)};return s},Ci=Oi("[PostHog.js]"),Ii=Ci.createLogger,Ai=Ii("[ExternalScriptsLoader]"),Fi=t=>{var e=null==r?void 0:r.querySelectorAll("script");if(e)for(var i=0;e.length>i;i++)if(e[i].src===t||e[i].getAttribute("src")===t)return e[i]},Mi=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return Ai.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=Fi(e);if(s){if(s.__posthog_loading_callback_fired)return i();var n=s.__posthog_loading_error;return n?i(n):(s.addEventListener("load",(t=>{s.__posthog_loading_callback_fired=!0,i(void 0,t)})),void s.addEventListener("error",(t=>{s.__posthog_loading_error=t,i(t)})))}var o=()=>{if(!r)return i("document not found");if(Fi(e))return Mi(t,e,i);var s=r.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=e,s.onload=t=>{s.__posthog_loading_callback_fired=!0,i(void 0,t)},s.onerror=t=>{s.__posthog_loading_error=t,i(t)},t.config.prepare_external_dependency_script&&(s=t.config.prepare_external_dependency_script(s)),!s)return i("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)r.head.appendChild(s);else{var n,o=r.querySelectorAll("body > script");o.length>0?null==(n=o[0].parentNode)||n.insertBefore(s,o[0]):r.body.appendChild(s)}};null!=r&&r.body?o():null==r||r.addEventListener("DOMContentLoaded",o)},Di={},Ni=(t,e)=>{var i="/static/"+e+".js?v="+t.version;if("toolbar"===e){var r=3e5;i=i+"&t="+Math.floor(Date.now()/r)*r}return t.requestRouter.endpointFor("assets",i)};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if("remote-config"!==e){var r=t.config.strict_script_versioning;if(r){var s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js"),n=Di[s];if("fallback"===r&&n){if(Fi(n))return void Mi(t,n,i);delete Di[s]}Mi(t,s,"fallback"===r?(r,n)=>{if(r)if("string"==typeof r)i(r);else{var o,a=Ni(t,e);Di[s]=a;var l=Fi(s);null==l||null==(o=l.parentNode)||o.removeChild(l),Mi(t,a,i)}else i(void 0,n)}:i)}else Mi(t,Ni(t,e),i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");Mi(t,o,i)}},v.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var r=t.requestRouter.endpointFor("api",e);Mi(t,r,i)};c.DEBUG=!1,c.LIB_VERSION="1.418.12",c.LIB_NAME="web";var Ui="$people_distinct_id",Li="distinct_id",ji="$device_id",Bi="$device_model",zi="__alias",qi="__timers",Hi="$autocapture_disabled_server_side",Vi="$heatmaps_enabled_server_side",Wi="$exception_capture_enabled_server_side",Gi="$error_tracking_suppression_rules",Ki="$error_tracking_capture_extension_exceptions",Ji="$web_vitals_enabled_server_side",Yi="$dead_clicks_enabled_server_side",Qi="$product_tours_enabled_server_side",Xi="$web_vitals_allowed_metrics",Zi="$session_recording_remote_config",tr="$replay_sample_rate",er="$replay_override_sampling",ir="$replay_override_linked_flag",rr="$replay_override_url_trigger",sr="$replay_override_event_trigger",nr="$sesid",or="$session_is_sampled",ar="$enabled_feature_flags",lr="$active_feature_flags",ur="$early_access_features",hr="$feature_flag_details",dr="$feature_flag_payloads",vr="$feature_flag_request_id",cr="$minimal_flag_called_events",fr="$override_feature_flags",pr="$override_feature_flag_payloads",_r="$stored_person_properties",gr="$stored_group_properties",mr="$groups",yr="$surveys",br="$surveys_loaded_at",wr="$surveys_activated",xr="$surveys_activated_session",Sr="$surveys_activated_timestamps",Er="ph_product_tours",kr="$flag_call_reported",$r="$flag_call_reported_session_id",Tr="$feature_flag_errors",Pr="$feature_flag_evaluated_at",Rr="$user_state",Or="$client_session_props",Cr="$capture_rate_limit",Ir="$initial_campaign_params",Ar="$initial_referrer_info",Fr="$initial_person_info",Mr="$epp",Dr="$posthog_cookieless",Nr="$cookieless_mode",Ur="$sdk_debug_extensions_init_method",Lr="$sdk_debug_extensions_init_time_ms",jr="$sdk_debug_recording_script_not_loaded",Br="PostHog loadExternalDependency extension not found.",zr="on_reject",qr="always",Hr="anonymous",Vr="identified",Wr="identified_only",Gr="visibilitychange",Kr="beforeunload",Jr="$pageview",Yr="$pageleave",Qr="$identify",Xr="$groupidentify";function Zr(t,e){X(t)&&t.forEach(e)}function ts(t,e){if(!ot(t))if(X(t))t.forEach(e);else if(ht(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)Y.call(t,i)&&e(t[i],i)}var es=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function is(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var rs=function(t){try{return t()}catch(t){return}},ss=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,i)}catch(t){Ci.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ci.critical(t)}}},ns=function(t){var e={};return ts(t,(function(t,i){(rt(t)&&t.length>0||at(t))&&(e[i]=t)})),e};var os=["herokuapp.com","vercel.app","netlify.app"];function as(t){var e=null==t?void 0:t.hostname;if(!rt(e))return!1;var i=e.split(".").slice(-2).join(".");for(var r of os)if(i===r)return!1;return!0}function ls(t,e,i,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(e,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function us(t){return"ph_toolbar_internal"===t.name}var hs=t=>{if(r){try{for(var e=t+"=",i=r.cookie.split(";").filter((t=>t.length)),s=0;i.length>s;s++){for(var n=i[s];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return at(t)&&isFinite(t)&&Math.floor(t)===t});class ds{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|e>>>8,s[7]=e,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new ds(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new ds(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class vs{generate(){var t=this.generateOrAbort();if(!it(t))return t;this.Rr=0;var e=this.generateOrAbort();if(it(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t=Date.now();if(t>this.Rr)this.Rr=t,this.Ar();else{if(this.Rr>=t+1e4)return;this.Lr++,this.Lr>4398046511103&&(this.Rr++,this.Ar())}return ds.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 ps}}var cs,fs=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!it(t.crypto)&&crypto.getRandomValues&&(fs=t=>crypto.getRandomValues(t));class ps{nextUint32(){return this.ft.length>this.Fr||(fs(this.ft),this.Fr=0),this.ft[this.Fr++]}constructor(){this.ft=new Uint32Array(8),this.Fr=1/0}}var _s=()=>gs().toString(),gs=()=>(cs||(cs=new vs)).generate(),ms="",ys=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var bs={Nr:()=>!!r,jr(t){Ci.error("cookieStore error: "+t)},Pr:hs,Br(t){var e;try{e=JSON.parse(bs.Pr(t))||{}}catch(t){}return e},Dr(t,e,i,s,n){if(!r)return!1;try{var o="",a="",l=function(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=r),ms)return ms;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),s=Math.min(i.length,8),n="dmn_chk_"+_s();!ms&&s--;){var o=i.slice(s).join("."),a=n+"=1;domain=."+o+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(n)&&(e.cookie=a+";max-age=0",ms=o)}return ms}(t);if(!i){var s=(t=>{var e=t.match(ys);return e?e[0]:""})(t);s!==i&&Ci.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(r.location.hostname,s);if(i){var u=new Date;u.setTime(u.getTime()+864e5*i),o="; expires="+u.toUTCString()}n&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(e))+o+"; SameSite=Lax; path=/"+l+a;return h.length>3686.4&&Ci.warn("cookieStore warning: large cookie, len="+h.length),r.cookie=h,!0}catch(t){return!1}},qr(t,e){if(null!=r&&r.cookie)try{bs.Dr(t,"",-1,e)}catch(t){return}}},ws=null,xs={Nr(){if(!nt(ws))return ws;var e=!0;if(it(t))e=!1;else try{var i="__mplssupport__";xs.Dr(i,"xyz"),'"xyz"'!==xs.Pr(i)&&(e=!1),xs.qr(i)}catch(t){e=!1}return e||Ci.error("localStorage unsupported; falling back to cookie store"),ws=e,e},jr(t){Ci.error("localStorage error: "+t)},Pr(e){try{return null==t?void 0:t.localStorage.getItem(e)}catch(t){xs.jr(t)}return null},Br(t){try{return JSON.parse(xs.Pr(t))||{}}catch(t){}return null},Dr(e,i){try{return null==t||t.localStorage.setItem(e,JSON.stringify(i)),!0}catch(t){xs.jr(t)}return!1},qr(e){try{null==t||t.localStorage.removeItem(e)}catch(t){xs.jr(t)}}},Ss=[_r,lr,ar,hr,dr,vr,Pr,Tr,kr],Es=[ji,Li,nr,or,Mr,Fr,Rr],ks=t=>t+"_cpm",$s=["__proto__","constructor","prototype"],Ts=t=>{if(!tt(t))return{};var e={};return Object.keys(t).forEach((i=>{-1===$s.indexOf(i)&&(e[i]=t[i])})),e},Ps=function(t,e){void 0===e&&(e=[]);var i={};return[...Es,...e].forEach((e=>{var r=t[e];it(r)||nt(r)||""===r||(i[e]=r)})),i},Rs=t=>{for(var e=5381,i=2166136261,r=0;t.length>r;r++){var s=t.charCodeAt(r);e=33*e^s,i=Math.imul(i^s,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(i>>>0).toString(36)},Os=(t,e)=>({p:e,f:Rs(JSON.stringify(t))}),Cs=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{var i=bs.Br(ks(t)),r=(null==i?void 0:i.f)===Rs(e)&&X(i.p);return{properties:r?i.p:[],isValid:r}}catch(t){return{properties:[],isValid:!1}}},Is=(t,e)=>e+"|"+(bs.Pr(ks(t))||""),As={},Fs={Nr:()=>!0,jr(t){Ci.error("memoryStorage error: "+t)},Pr:t=>As[t]||null,Br:t=>As[t]||null,Dr:(t,e)=>(As[t]=e,!0),qr(t){delete As[t]}},Ms=null,Ds={Nr(){if(!nt(Ms))return Ms;if(Ms=!0,it(t))Ms=!1;else try{var e="__support__";Ds.Dr(e,"xyz"),'"xyz"'!==Ds.Pr(e)&&(Ms=!1),Ds.qr(e)}catch(t){Ms=!1}return Ms},jr(t){Ci.error("sessionStorage error: ",t)},Pr(e){try{return null==t?void 0:t.sessionStorage.getItem(e)}catch(t){Ds.jr(t)}return null},Br(t){try{return JSON.parse(Ds.Pr(t))||null}catch(t){}return null},Dr(e,i){try{return null==t||t.sessionStorage.setItem(e,JSON.stringify(i)),!0}catch(t){Ds.jr(t)}return!1},qr(e){try{null==t||t.sessionStorage.removeItem(e)}catch(t){Ds.jr(t)}}};class Ns{constructor(t){this._instance=t}get Di(){return this._instance.config}get consent(){return this.Gn()?0:this.Zn}isOptedOut(){return this.Di.cookieless_mode===qr||this.isRejected()||-1===this.consent&&this.Di.cookieless_mode===zr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Di.opt_out_capturing_by_default}optInOut(t){this.Qn.Dr(this.Jn,t?1:0,this.Di.cookie_expiration,this.Di.cross_subdomain_cookie,this.Di.secure_cookie)}reset(){this.Qn.qr(this.Jn,this.Di.cross_subdomain_cookie)}get Jn(){var t=this._instance.config,e=t.token,i=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(i?i+e:"__ph_opt_in_out_"+e)}get Zn(){var t=this.Qn.Pr(this.Jn);return yt(t)?1:V(bt,t)?0:-1}get Qn(){var t=this.Di.opt_out_capturing_persistence_type,e="localStorage"===t?xs:bs;if(!this.Kn||this.Kn!==e){this.Kn=e;var i="localStorage"===t?bs:xs;i.Pr(this.Jn)&&(this.Kn.Pr(this.Jn)||this.optInOut(yt(i.Pr(this.Jn))),i.qr(this.Jn,this.Di.cross_subdomain_cookie))}return this.Kn}Gn(){return!!this.Di.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,v.doNotTrack].some((t=>yt(t)))}}function Us(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!Z(r))return e;try{var s=r(e);return rt(s)&&s?s:e}catch(t){return Ci.error("Error in get_current_url, falling back to window.location.href",t),e}}var Ls="__POSTHOG_TOOLBAR__",js=1,Bs=3,zs=11;function qs(t){return t instanceof Element&&(t.id===Ls||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Hs(t){return!!t&&t.nodeType===js}function Vs(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Ws(t){return!!t&&t.nodeType===Bs}function Gs(t){return!!t&&t.nodeType===zs&&Hs(t.host)}var Ks=1e3;function Js(t){return t?W(t).split(/\s+/):[]}function Ys(e,i){var r=function(e){var i,r=null==t||null==(i=t.location)?void 0:i.href;return it(r)?void 0:Us(e,r)}(i);return!!(r&&e&&e.some((t=>r.match(t))))}function Qs(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Js(e)}function Xs(t){return ot(t)?null:W(t).split(/(\s+)/).filter((t=>Sn(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Zs(t){var e="";return fn(t)&&!pn(t)&&t.childNodes&&t.childNodes.length&&ts(t.childNodes,(function(t){var i;Ws(t)&&t.textContent&&(e+=null!==(i=Xs(t.textContent))&&void 0!==i?i:"")})),W(e)}function tn(t){var e;return it(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var en=["a","button","form","input","select","textarea","label"];function rn(t,e){if(it(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function sn(t){var e=t.parentNode;return!(!e||!Hs(e))&&e}var nn=[".ph-no-autocapture","[data-ph-no-autocapture]"],on=["next","previous","prev",">","<"],an=[...on,"+","-","−","–"],ln=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,un=[".ph-no-rageclick",".ph-no-capture"],hn=["","text","search","email","password","url","tel","number"];function dn(e,i){if(!t||vn(e))return!1;var r,s,n,o,a;if(ut(i)?(r=!!i&&un,s=void 0,n=!1):(r=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:un,s=null==i?void 0:i.content_ignorelist,n=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===r)return!1;if(n&&function(t){return!(!t||!Hs(t))&&(!!Vs(t,"textarea")||(Vs(t,"input")?V(hn,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(e))return!1;var l=cn(e,!1).targetElementList;return!function(t,e){if(!1===t||it(t))return!1;var i;if(!0===t)i=on;else{if(!X(t))return!1;if(t.length>10)return Ci.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var e=t.safeText,r=t.ariaLabel;return i.some((t=>ln(e,t)||ln(r,t)))}))}(s,l.map((t=>{var e;return{safeText:Zs(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!rn(l,r)}var vn=t=>!t||Vs(t,"html")||!Hs(t),cn=(e,i)=>{if(!t||vn(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[e],n=e;n.parentNode&&!Vs(n,"body");)if(Gs(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=sn(n);if(!o)break;if(i||en.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=!0)}catch(t){}s.push(o),n=o}return{parentIsUsefulElement:r,targetElementList:s}};function fn(t){for(var e=new Set,i=0,r=t;r.parentNode&&!Vs(r,"body");r=r.parentNode){if(i++>=Ks||e.has(r))return!1;e.add(r);var s=Qs(r);if(V(s,"ph-sensitive")||V(s,"ph-no-capture"))return!1}if(V(Qs(t),"ph-include"))return!0;var n=t.type||"";if(rt(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!rt(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function pn(t){return!!(Vs(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Vs(t,"select")||Vs(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var _n=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}))$"),gn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,mn=[16,15,14,13],yn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),bn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),wn=/[0-9A-Za-z_]/;function xn(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;i&&(s*=2)>9&&(s-=9),e+=s,i=!i}return e%10==0}function Sn(t,e){if(void 0===e&&(e=!0),ot(t))return!1;if(rt(t)){t=W(t);var i=e?_n.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(gn.lastIndex=0;e=gn.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of mn){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(_n.test(a)&&xn(a))return!0}}}return!1}(t);if(i)return!1;var r=e?yn.test(t):function(t){var e;for(bn.lastIndex=0;e=bn.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&wn.test(i)&&wn.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function En(t){var e=Zs(t);return Sn(e=(e+" "+kn(t)).trim())?e:""}function kn(t){var e="";return t&&t.childNodes&&t.childNodes.length&&ts(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Zs(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+kn(t)).trim())}catch(t){Ci.error("[AutoCapture]",t)}})),e}function $n(t){return t.replace(/"|\\"/g,'\\"')}function Tn(t){var e=t.attr__class;if(e)return X(e)?e:Js(e)}var Pn=Ii("[Dead Clicks]"),Rn=()=>!0,On=t=>{var e,i=!(null==(e=t.instance.persistence)||!e.get_property(Yi)),r=t.instance.config.capture_dead_clicks;return ut(r)?r:!!tt(r)||i};class Cn{get lazyLoadedDeadClicksAutocapture(){return this.Yn}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Yi]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Xn((()=>{this.ts()})):this.stop()}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?Pn.error("failed to load script",e):t()}))}ts(){var t;if(r){if(!this.Yn&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=tt(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Yn=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Yn.start(r),Pn.info("starting...")}}else Pn.error("`document` not found. Cannot start.")}stop(){this.Yn&&(this.Yn.stop(),this.Yn=void 0,Pn.info("stopping..."))}}var In=Ii("[SegmentIntegration]");var An="posthog-js";function Fn(t,e){var i=void 0===e?{}:e,r=i.organization,s=i.projectId,n=i.prefix,o=i.severityAllowList,a=void 0===o?["error"]:o,l=i.sendExceptionsToPostHog,u=void 0===l||l;return e=>{var i,o,l,h,d;if("*"!==a&&!a.includes(e.level)||!t.__loaded)return e;e.tags||(e.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());e.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(e.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var c,f=(null==(i=e.exception)?void 0:i.values)||[],p=f.map((t=>_({},t,{stacktrace:t.stacktrace?_({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>_({},t,{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null==(o=f[0])?void 0:o.value)||e.message,$exception_type:null==(l=f[0])?void 0:l.type,$exception_level:e.level,$exception_list:p,$sentry_event_id:e.event_id,$sentry_exception:e.exception,$sentry_exception_message:(null==(h=f[0])?void 0:h.value)||e.message,$sentry_exception_type:null==(d=f[0])?void 0:d.type,$sentry_tags:e.tags};return r&&s&&(g.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+e.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(g)),e}}class Mn{constructor(t,e,i,r,s,n){this.name=An,this.setupOnce=function(o){o(Fn(t,{organization:e,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Dn{constructor(t){this.es=(t,e,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Ci.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.rs=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.ns()}ns(){var t;this.ss=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.es)}destroy(){var t;null==(t=this.ss)||t.call(this),this.ss=void 0}doPageView(e,i){var r,s=this.os(e,i);return this.rs={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var e;return this.os(t,null==(e=this.rs)?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.rs)?void 0:t.pageViewId}}os(t,e){var i=this.rs;if(!i)return{$pageview_id:e};var r={$pageview_id:e,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,u=s.lastContentY,h=s.maxContentY;if(!(it(n)||it(o)||it(a)||it(l)||it(u)||it(h))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),h=Math.ceil(h);var d=n>1?wt(o/n,0,1,Ci):1,v=n>1?wt(a/n,0,1,Ci):1,c=l>1?wt(u/l,0,1,Ci):1,f=l>1?wt(h/l,0,1,Ci):1;r=es(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:f})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(t.getTime()-i.timestamp.getTime())/1e3),r}}var Nn=["flags","surveys"],Un={[Ui]:{exposure:"hidden"},[zi]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[qi]:{exposure:"hidden"},[Hi]:{exposure:"event"},[Vi]:{exposure:"hidden"},[Wi]:{exposure:"event"},[Gi]:{exposure:"hidden"},[Ki]:{exposure:"event"},[Ji]:{exposure:"event"},[Yi]:{exposure:"event"},[Qi]:{exposure:"hidden"},[Xi]:{exposure:"event"},[Zi]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[nr]:{exposure:"hidden"},[or]:{exposure:"event"},[tr]:{exposure:"event",shouldSkipFromEventProperties:t=>nt(t)},$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"},[ar]:{exposure:"hidden",storageGroup:"flags"},[lr]:{exposure:"hidden",storageGroup:"flags"},[ur]:{exposure:"hidden"},[hr]:{exposure:"hidden",storageGroup:"flags"},[dr]:{exposure:"hidden",storageGroup:"flags"},[vr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[cr]:{exposure:"hidden",storageGroup:"flags"},[fr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[_r]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[yr]:{exposure:"hidden",storageGroup:"surveys"},[br]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[wr]:{exposure:"event"},[xr]:{exposure:"hidden"},[Sr]:{exposure:"hidden"},[Er]:{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"},[kr]:{exposure:"hidden"},[$r]:{exposure:"hidden"},[mr]:{exposure:"event"},[Tr]:{exposure:"hidden"},[Pr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Rr]:{exposure:"hidden"},[Or]:{exposure:"hidden"},[Cr]:{exposure:"hidden"},[Ir]:{exposure:"hidden"},[Ar]:{exposure:"hidden"},[Fr]:{exposure:"hidden"},[Mr]:{exposure:"hidden"},[er]:{exposure:"event"},[ir]:{exposure:"event"},[rr]:{exposure:"event"},[sr]:{exposure:"event"},[Ur]:{exposure:"event"},[Lr]:{exposure:"event"},[jr]:{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"},$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"}},Ln=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],jn=t=>{var e=Un[t];if(e)return e;for(var i of Ln){var r=i[1];if(0===t.indexOf(i[0]))return r}},Bn=(t,e)=>{try{return JSON.stringify(t,((t,e)=>"bigint"==typeof e?e.toString():e),e)}catch(e){return K(t)}},zn=t=>{var e=null==r?void 0:r.createElement("a");return it(e)?null:(e.href=t,e)},qn=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!X(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(t){Ci.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Hn=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],h=0;l.length>h;h++){var d=l[h].split("=");X(d)&&(e.includes(d[0])?u.push(d[0]+"="+i):u.push(l[h]))}var v=a;return null!=o&&(v+="?"+u.join("&")),null!=s&&(v+="#"+s),v},Vn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Wn=(t,e)=>t>=e&&h(),Gn=(t,e,i,r)=>{if(0===t){if(h()){var s=e+1;return s===i&&r(),s}return e}return 0},Kn="https?://(.*)",Jn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Yn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Jn],Qn="<masked>",Xn=["li_fat_id"];function Zn(t,e,i){if(!r)return{};var s,n=e?[...Jn,...i||[]]:[],o=to(Hn(r.URL,n,Qn),t),a=(s={},ts(Xn,(function(t){var e=hs(t);s[t]=e||null})),s);return es(a,o)}function to(t,e){var i=Yn.concat(e||[]),r={};return ts(i,(function(e){var i=qn(t,e);r[e]=i||null})),r}function eo(t){var e=function(t){return t?0===t.search(Kn+"google.([^/?]*)")?"google":0===t.search(Kn+"bing.com")?"bing":0===t.search(Kn+"yahoo.com")?"yahoo":0===t.search(Kn+"duckduckgo.com")?"duckduckgo":null:null}(t),i="yahoo"!=e?"q":"p",s={};if(!nt(e)){s.$search_engine=e;var n=r?qn(r.referrer,i):"";n.length&&(s.ph_keyword=n)}return s}function io(){return navigator.language||navigator.userLanguage}var ro="$direct";function so(){return(null==r?void 0:r.referrer)||ro}function no(t,e,i){void 0===i&&(i=!1);var r=t?[...Jn,...e||[]]:[],n=i?Re(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:so().substring(0,1e3),u:o?Hn(o,r,Qn):void 0}}function oo(t,e){var i;void 0===e&&(e=!1);var r=t.r,s=t.u,n=e?Re(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==ro?ro:null==(i=zn(r))?void 0:i.host};if(n){o.$current_url=n;var a=zn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=to(n);es(o,l)}if(r){var u=eo(r);es(o,u)}return o}function ao(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function lo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var uo={flags:Pr,surveys:br},ho=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],vo=t=>t+"_cookie_identity_change_pending",co="main",fo=(t,e)=>{ts(t,((i,r)=>{var s=jn(r);s&&"event"!==s.exposure||{}.hasOwnProperty.call(e,r)||delete t[r]}))};class po{constructor(e,i,r){if(void 0===r&&(r=!0),this.ls={},this.us=!1,this.hs=!1,this.ds=!1,this.vs=!1,this.Di=e,this.cs=r,this.props={},this.fs=void 0,this.ps=(t=>{var e="";return t.token&&(e=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+e+"_posthog"})(e),this.Qn=this.gs(e),this.hs=this.ys(e),this.load(),e.debug&&Ci.info("Persistence loaded",e.persistence,_({},this.props)),this.update_config(e,e,i),this.save(),t){var s=()=>this.flush();ls(t,"beforeunload",s,{capture:!1}),ls(t,"pagehide",s,{capture:!1})}}bs(){var t,e=null==(t=this.Di)?void 0:t.persistence_save_debounce_ms;return at(e)&&e>0?e:0}_s(t){if(this.Di.cookieWinsOnConflict&&"localstorage+cookie"===this.Di.persistence.toLowerCase())if(t)try{var e=Ps(t,this.Di.cookie_persisted_properties||[]),i=Os(e,this.Di.cookie_persisted_properties||[]),r=JSON.stringify(e)+"|"+JSON.stringify(i),s=bs.Pr(this.ps)||void 0;s&&Is(this.ps,s)===r&&(this.ws=r,this.ks=s)}catch(t){}else try{var n=bs.Pr(this.ps)||void 0;this.ws=n?Is(this.ps,n):void 0,this.ks=n}catch(t){}}syncCookieProperties(){return this.Ss(this.Di)}Ss(t,e){if(void 0===e&&(e=!1),this.xs&&!e||this.vs||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;var i;try{i=bs.Pr(this.ps)||void 0}catch(t){}if(!i||i===this.ks)return!1;var r,s=Is(this.ps,i);try{r=Ts(JSON.parse(i))}catch(t){return!1}if((bs.Pr(this.ps)||void 0)!==i)return!1;this.ws=s,this.ks=i;var n=Cs(this.ps,i),o=[...Es,...n.properties],a={};if(Object.keys(r).forEach((t=>{var e=r[t];(it(e)||nt(e)||""===e||t===Rr&&e!==Hr&&e!==Vr)&&(a[t]=!0,delete r[t])})),et(r))return!1;var l=Li in r||r[Rr]===Hr||r[Rr]===Vr,u=this.props[Li],h=this.props[Rr],d=es({},this.props);[...Es,...t.cookie_persisted_properties||[]].forEach((t=>{if(-1!==o.indexOf(t)&&!(t in r)&&!a[t]&&(l||t!==Li&&t!==Rr)){var e=d[t];!n.isValid&&-1!==Es.indexOf(t)&&(!1===e||0===e)||delete d[t]}})),this.props=es(d,r),!l||Rr in r||Rr in this.props||this.Cs(Rr,Hr);var v=this.props[Li],c=this.props[Rr];return!l||v===u&&c===h||(this.ds=!0,Ds.Dr(vo(this.ps),!0),this.Ts(_r),this.Ts(lr),this.Ts(ar),this.Ts(hr),this.Ts(dr),this.Ts(vr),this.Ts(Pr),this.Ts(Tr),this.Ts(kr),c===Hr&&(h===Vr||r[Rr]===Hr||!it(u)&&v!==u)&&(fo(this.props,r),this.Ts(gr)),c===Vr?this.props.$user_id=v:delete this.props.$user_id,this.Ts(zi)),!0}consumeCookieIdentityChange(){var t=vo(this.ps),e=this.ds||!!Ds.Pr(t);return this.ds=!1,e&&Ds.qr(t),e}Ms(t){return void 0===t&&(t=!1),!(this.vs||this.xs&&!t||!this.Di.cookieWinsOnConflict||"localstorage+cookie"!==this.Di.persistence.toLowerCase()||(this.vs=!0,0))}Es(){this.vs&&(it(this.Is)||(clearTimeout(this.Is),this.Is=void 0),delete this.ls[co],this.Rs(!0))}Ps(t){if(void 0===t&&(t=!0),this.vs)try{t?this.Es():it(this.Is)||(clearTimeout(this.Is),this.Is=void 0)}finally{this.vs=!1}}isDisabled(){return!!this.xs}gs(e){-1===ho.indexOf(e.persistence.toLowerCase())&&(Ci.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i,r=function(e,i){void 0===e&&(e=[]),void 0===i&&(i=!1);var r=[...Es,...e];return _({},xs,{Br(t){try{var e,s={};try{e=bs.Pr(t)||void 0,s=e?Ts(JSON.parse(e)):{}}catch(t){}var n,o=JSON.parse(xs.Pr(t)||"{}");if(i){var a=Cs(t,e),l=[...Es,...a.properties],u={};Object.keys(s).forEach((t=>{var e=s[t];nt(e)||""===e||t===Rr&&e!==Hr&&e!==Vr||(u[t]=e)}));var h=Li in u||u[Rr]===Hr||u[Rr]===Vr;if(Object.keys(u).length>0){var d,v=o[Li],c=null!==(d=o[Rr])&&void 0!==d?d:Hr;r.forEach((t=>{if(-1!==l.indexOf(t)&&!(t in s)&&(h||t!==Li&&t!==Rr)){var e=o[t];!a.isValid&&-1!==Es.indexOf(t)&&(!1===e||0===e)||delete o[t]}})),!h||Rr in s||Rr in o||(o[Rr]=Hr),!h||(Li in u?u[Li]:o[Li])===v&&(Rr in u?u[Rr]:o[Rr])===c||(Ss.forEach((t=>delete o[t])),u[Rr]===Vr&&Li in u?o.$user_id=u[Li]:delete o.$user_id,u[Rr]!==Vr&&(delete o[mr],delete o[gr]),delete o.__alias)}n=es(o,u)}else n=es(s,o);return xs.Dr(t,n),n}catch(t){}return null},Dr(t,r,s,n,o,a){var l=xs.Dr(t,r,void 0,void 0,a);try{var u=Ps(r,e);if(Object.keys(u).length){if(i){var h=ks(t),d=Os(u,e);if(bs.Dr(h,d,s,n,o,a),bs.Pr(h)!==JSON.stringify(d)){bs.qr(h,n);var v=Ps(r);return bs.Dr(t,v,s,n,o,a),l}}bs.Dr(t,u,s,n,o,a)}}catch(t){xs.jr(t)}return l},qr(e,i){try{null==t||t.localStorage.removeItem(e),bs.qr(e,i),bs.qr(ks(e),i)}catch(t){xs.jr(t)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&xs.Nr()?(i=xs,s=!0):"localstorage+cookie"===n&&r.Nr()?(i=r,s=!0):"sessionstorage"===n&&Ds.Nr()?i=Ds:"memory"===n?i=Fs:"cookie"===n?i=bs:r.Nr()?(i=r,s=!0):i=bs,this.us=s,i}As(t){return this.ps+"__"+t}ys(t){return this.us&&!!t.split_storage}properties(){var t={};return ts(this.props,((e,i)=>{var r=jn(i);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e))return;t[i]=e}})),t}load(t){if(void 0===t&&(t=!1),!this.xs||t){var e=this.Di.cookieWinsOnConflict&&"localstorage+cookie"===this.Di.persistence.toLowerCase(),i=e?xs.Br(this.ps):null,r={};if(e)try{ts(r=Ts(bs.Br(this.ps)),((t,e)=>{(it(t)||nt(t)||""===t)&&delete r[e]}))}catch(t){}var s=this.Qn.Br(this.ps);if(s&&(this.props=es({},s)),this.hs&&this.Fs(),e&&s){var n,o,a=null==i?void 0:i[Li],l=null!==(n=null==i?void 0:i[Rr])&&void 0!==n?n:Hr,u=s[Li],h=null!==(o=s[Rr])&&void 0!==o?o:Hr;if(u!==a||h!==l){this.ds=!0,Ds.Dr(vo(this.ps),!0);var d=es({},this.props);Ss.forEach((t=>delete d[t])),h===Hr&&(l===Vr||r[Rr]===Hr||!it(a)&&u!==a)&&(fo(d,r),delete d[gr]),this.props=d;var v=new Set;Ss.forEach((t=>{var e,i=null==(e=jn(t))?void 0:e.storageGroup;i&&v.add(i)})),v.forEach((t=>{var e={};ts(this.props,((i,r)=>{var s;(null==(s=jn(r))?void 0:s.storageGroup)===t&&(e[r]=i)})),et(e)?(xs.qr(this.As(t)),this.ls[t]={}):xs.Dr(this.As(t),e)&&(this.ls[t]={persisted:!0,fingerprint:this.Os(e,t)})}))}}Ds.Pr(vo(this.ps))&&(this.ds=!0)}}Fs(){for(var t of Nn){var e=xs.Br(this.As(t));if(e&&!et(e)){var i=this.Ls(t);i.persisted=!0,this.$s(t)||(i.fingerprint=this.Os(e,t)),this.Ds(t,e)||es(this.props,e)}}}$s(t){return Object.keys(this.props).some((e=>{var i;return(null==(i=jn(e))?void 0:i.storageGroup)===t}))}Ds(t,e){var i=uo[t];if(!i)return!1;var r=e[i],s=this.props[i];return at(r)&&at(s)&&s>r}refreshKey(t){var e;if(!this.xs){var i=this.hs?null==(e=jn(t))?void 0:e.storageGroup:void 0,r=i?xs.Br(this.As(i)):this.Qn.Br(this.ps);if(r&&t in r)this.Cs(t,r[t]);else{if(i){var s=this.Qn.Br(this.ps);if(s&&t in s)return void this.Cs(t,s[t])}this.Ts(t)}}}save(){if(!this.xs){var t=this.bs();t>0?it(this.Is)&&(this.Is=setTimeout((()=>{this.Is=void 0,this.Rs()}),t)):this.Rs()}}flush(){it(this.Is)||(clearTimeout(this.Is),this.Is=void 0,this.Rs())}Rs(t){void 0===t&&(t=!1),this.xs||this.vs&&!t||(t||this.syncCookieProperties(),this.hs?this.Ns():this.qs(this.Qn,this.ps,this.props,co)&&this._s(this.props))}Ns(){var t=this.js(),e=t.main,i=t.groups;for(var r of(this.qs(this.Qn,this.ps,e,co)&&this._s(e),Nn)){var s,n=i[r];(!et(n)||null!=(s=this.ls[r])&&s.persisted)&&this.qs(xs,this.As(r),n,r)}}js(){var t={},e={flags:{},surveys:{}};return ts(this.props,((i,r)=>{var s,n=null==(s=jn(r))?void 0:s.storageGroup;n?e[n][r]=i:t[r]=i})),{main:t,groups:e}}Os(t,e){if(e===co)return JSON.stringify(t)+"|"+this.Bs+"|"+this.Hs+"|"+this.Us;var i={};return ts(t,((t,e)=>{var r;i[e]=null!=(r=jn(e))&&r.volatile?"__volatile__":t})),JSON.stringify(i)}qs(t,e,i,r){var s,n=this.Ls(r);if(r!==co&&!n.dirty&&!it(n.fingerprint))return!1;try{if((s=this.Os(i,r))===n.fingerprint)return n.dirty=!1,!1}catch(t){s=void 0}return t.Dr(e,i,this.Bs,this.Hs,this.Us,this.Di.debug)?(n.dirty=!1,r!==co&&(n.persisted=!0),it(s)||(n.fingerprint=s),!0):(this.Di.debug&&Ci.warn('failed to persist storage entry "'+e+'"; will retry on next save'),!1)}remove(t){var e=(void 0===t?{}:t).keepGroupEntries,i=void 0!==e&&e;if(it(this.Is)||(clearTimeout(this.Is),this.Is=void 0),this.Qn.qr(this.ps,!1),this.Qn.qr(this.ps,!0),!i&&this.cs)for(var r of Nn)xs.qr(this.As(r));i?delete this.ls[co]:this.ls={},this.ws=void 0,this.ks=void 0}clear(){this.remove(),this.props={}}register_once(t,e,i){if(tt(t)){this.syncCookieProperties(),it(e)&&(e="None"),this.Bs=it(i)?this.zs:i;var r=!1;if(ts(t,((t,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==e||(this.Cs(i,t),r=!0)})),r)return this.save(),!0}return!1}register(t,e){if(tt(t)){this.syncCookieProperties(),this.Bs=it(e)?this.zs:e;var i=!1;if(ts(t,((e,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==e||tt(e)||X(e))&&(this.Cs(r,e),i=!0)})),i)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var e="string"==typeof t?[t]:t,i=!1;for(var r of e)r in this.props&&(this.Ts(r),i=!0);i&&this.save()}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.fs){var e=Zn(this.Di.custom_campaign_params,this.Di.mask_personal_data_properties,this.Di.custom_personal_data_properties);et(ns(e))||this.register(e),this.fs=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?eo(t):{})}update_referrer_info(){var t;this.register_once({$referrer:so(),$referring_domain:null!=r&&r.referrer&&(null==(t=zn(r.referrer))?void 0:t.host)||ro},void 0)}set_initial_person_info(){this.props[Ir]||this.props[Ar]||this.register_once({[Fr]:no(this.Di.mask_personal_data_properties,this.Di.custom_personal_data_properties,this.Di.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};ts([Ar,Ir],(e=>{var i=this.props[e];i&&ts(i,(function(e,i){t["$initial_"+G(i)]=e}))}));var e=this.props[Fr];if(e){var i=function(t,e){void 0===e&&(e=!1);var i=oo(t,e),r={};return ts(i,(function(t,e){r["$initial_"+G(e)]=t})),r}(e,this.Di.disable_capture_url_hashes);es(t,i)}return t}safe_merge(t){return ts(this.props,(function(e,i){i in t||(t[i]=e)})),t}update_config(t,e,i){var r=t.persistence!==e.persistence,s=!((t,e)=>{if(t.length!==e.length)return!1;var i=[...t].sort(),r=[...e].sort();return i.every(((t,e)=>t===r[e]))})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),n=r||s,o=t.cookieWinsOnConflict!==e.cookieWinsOnConflict,a=t.disable_persistence||!!i,l=!!this.xs&&!a;a||this.Ss(e,l),this.Di=t,!a&&(r||s||o)&&(this.ws=void 0,this.ks=void 0,this.Ss(_({},t,{cookie_persisted_properties:e.cookie_persisted_properties}),l));var u=n||o?this.gs(t):this.Qn,h=this.ys(t),d=n||h!==this.hs,v=!a&&(d||t.cross_subdomain_cookie!==this.Hs||t.secure_cookie!==this.Us)&&this.Ms(l);try{if(this.zs=this.Bs=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){var c=this.props;this.clear(),this.Qn=u,this.hs=h,this.props=c,this.save()}else o&&(this.Qn=u,a||(delete this.ls[co],this.Rs()))}finally{v&&this.Ps()}}set_disabled(t){this.xs=t,this.xs?this.remove():this.save()}set_cross_subdomain(t){t!==this.Hs&&(this.Hs=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Us&&(this.Us=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var i=this.props[qi]||{};i[t]=e,this.Cs(qi,i),this.save()}remove_event_timer(t){var e=this.props[qi]||{},i=e[t];return it(i)||(delete e[t],this.Cs(qi,e),this.save()),i}get_property(t){return this.props[t]}set_property(t,e){this.Cs(t,e),this.save()}Cs(t,e){var i;this.props[t]=e,null!=(i=jn(t))&&i.volatile||this.Ws(t)}Ts(t){delete this.props[t],this.Ws(t)}Ws(t){var e,i=null==(e=jn(t))?void 0:e.storageGroup;i&&(this.Ls(i).dirty=!0)}Ls(t){return this.ls[t]||(this.ls[t]={})}}function _o(t){var e=!0;return{dispose(){if(e){e=!1;var i=t();i&&Z(i.then)&&i.then(void 0,(()=>{}))}}}}var go={GZipJS:"gzip-js",Base64:"base64"},mo={Activation:"events",Cancellation:"cancelEvents"},yo={Button:"button",Tab:"tab",Selector:"selector"},bo={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},wo={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},xo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},So={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},Eo={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ko={Once:"once",Recurring:"recurring",Always:"always"},$o={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},To={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Po={Popover:"popover",Inline:"inline"},Ro={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},Oo={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Co={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Io=Ii("[RateLimiter]");class Ao{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var e=t.text;if(e&&e.length)try{(JSON.parse(e).quota_limited||[]).forEach((t=>{Io.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void Io.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:e})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var e,i,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(e=null==(i=this.instance.persistence)?void 0:i.get_property(Cr))&&void 0!==e?e:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var u=(at(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Vs(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(Cr,a),{isRateLimited:l,remainingTokens:a.tokens}}Gs(t){var e=this.instance.config.property_denylist;return!X(e)||!e.includes(t)}Zs(){var t;if(this.Gs("$current_url")&&this.Gs("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}Vs(t){var e,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.Zs(),o=this.Gs("$session_id")?null==(e=(i=this.instance).get_session_id)?void 0:e.call(i):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var e=this.serverLimits[t||"events"]||!1;return!1!==e&&(new Date).getTime()<e}}var Fo=Ii("[RemoteConfig]");class Mo{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Qs(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Js(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Fo.info("Using preloaded remote config",this.remoteConfig),this.Ks(this.remoteConfig),void this.Ys();if(this._instance.Xs())return void Fo.warn("Remote config is disabled. Falling back to local config.");this.Qs((t=>{if(!t)return Fo.info("No config found after loading remote JS config. Falling back to JSON."),void this.Js((t=>{this.Ks(t.json,t),this.Ys()}));this.Ks(t),this.Ys()}))}catch(t){Fo.error("Error loading remote config",t),this.Ks()}}stop(){this.ta&&(clearInterval(this.ta),this.ta=void 0)}refresh(){!this._instance.Xs()&&r&&"hidden"!==r.visibilityState&&this._instance.reloadFeatureFlags()}Ys(){var t;if(!this.ta){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.ta=setInterval((()=>{this.refresh()}),e))}}Ks(t,e){!t&&e&&(0===e.statusCode?e.error||Fo.warn("Failed to fetch remote config from PostHog."):Fo.error("Failed to fetch remote config from PostHog."));try{this._instance.Ks(t?{ok:!0,config:t}:{ok:!1})}catch(t){Fo.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){Fo.error("Error loading feature flags",t)}}}var Do=["fatal","error","warning","log","info","debug"],No=Uint8Array,Uo=Uint16Array,Lo=Uint32Array,jo=new No([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]),Bo=new No([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]),zo=new No([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qo=function(t,e){for(var i=new Uo(31),r=0;31>r;++r)i[r]=e+=1<<t[r-1];var s=new Lo(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},Ho=qo(jo,2),Vo=Ho[1];Ho[0][28]=258,Vo[258]=28;for(var Wo=qo(Bo,0)[1],Go=new Uo(32768),Ko=0;32768>Ko;++Ko){var Jo=(43690&Ko)>>>1|(21845&Ko)<<1;Go[Ko]=((65280&(Jo=(61680&(Jo=(52428&Jo)>>>2|(13107&Jo)<<2))>>>4|(3855&Jo)<<4))>>>8|(255&Jo)<<8)>>>1}var Yo=function(t,e,i){for(var r=t.length,s=0,n=new Uo(e);r>s;++s)++n[t[s]-1];var o,a=new Uo(e);for(s=0;e>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Uo(1<<e);var l=15-e;for(s=0;r>s;++s)if(t[s])for(var u=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<<h,v=d|(1<<h)-1;v>=d;++d)o[Go[d]>>>l]=u}else for(o=new Uo(r),s=0;r>s;++s)o[s]=Go[a[t[s]-1]++]>>>15-t[s];return o},Qo=new No(288);for(Ko=0;144>Ko;++Ko)Qo[Ko]=8;for(Ko=144;256>Ko;++Ko)Qo[Ko]=9;for(Ko=256;280>Ko;++Ko)Qo[Ko]=7;for(Ko=280;288>Ko;++Ko)Qo[Ko]=8;var Xo=new No(32);for(Ko=0;32>Ko;++Ko)Xo[Ko]=5;var Zo=Yo(Qo,9,0),ta=Yo(Xo,5,0),ea=function(t){return(t/8>>0)+(7&t&&1)},ia=function(t,e,i){(null==i||i>t.length)&&(i=t.length);var r=new(t instanceof Uo?Uo:t instanceof Lo?Lo:No)(i-e);return r.set(t.subarray(e,i)),r},ra=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8},sa=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8,t[r+2]|=i>>>16},na=function(t,e){for(var i=[],r=0;t.length>r;++r)t[r]&&i.push({s:r,f:t[r]});var s=i.length,n=i.slice();if(!s)return[new No(0),0];if(1==s){var o=new No(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(t,e){return t.f-e.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,h=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=h&&i[d].f>i[u].f?u++:d++],i[h++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new Uo(v+1),f=oa(i[h-1],c,0);if(f>e){r=0;var p=0,_=f-e,g=1<<_;for(n.sort((function(t,e){return c[e.s]-c[t.s]||t.f-e.f}));s>r;++r){var m=n[r].s;if(e>=c[m])break;p+=g-(1<<f-c[m]),c[m]=e}for(p>>>=_;p>0;){var y=n[r].s;e>c[y]?p-=1<<e-c[y]++-1:++r}for(;r>=0&&p;--r){var b=n[r].s;c[b]==e&&(--c[b],++p)}f=e}return[new No(c),f]},oa=function(t,e,i){return-1==t.s?Math.max(oa(t.l,e,i+1),oa(t.r,e,i+1)):e[t.s]=i},aa=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Uo(++e),r=0,s=t[0],n=1,o=function(t){i[r++]=t},a=1;e>=a;++a)if(t[a]==s&&a!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[i.subarray(0,r),e]},la=function(t,e){for(var i=0,r=0;e.length>r;++r)i+=t[r]*e[r];return i},ua=function(t,e,i){var r=i.length,s=ea(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=i[n];return 8*(s+4+r)},ha=function(t,e,i,r,s,n,o,a,l,u,h){ra(e,h++,i),++s[256];for(var d=na(s,15),v=d[0],c=d[1],f=na(n,15),p=f[0],_=f[1],g=aa(v),m=g[0],y=g[1],b=aa(p),w=b[0],x=b[1],S=new Uo(19),E=0;m.length>E;++E)S[31&m[E]]++;for(E=0;w.length>E;++E)S[31&w[E]]++;for(var k=na(S,7),T=k[0],P=k[1],R=19;R>4&&!T[zo[R-1]];--R);var O,C,I,A,F=u+5<<3,M=la(s,Qo)+la(n,Xo)+o,D=la(s,v)+la(n,p)+o+14+3*R+la(S,T)+(2*S[16]+3*S[17]+7*S[18]);if(M>=F&&D>=F)return ua(e,h,t.subarray(l,l+u));if(ra(e,h,1+(M>D)),h+=2,M>D){O=Yo(v,c,0),C=v,I=Yo(p,_,0),A=p;var N=Yo(T,P,0);for(ra(e,h,y-257),ra(e,h+5,x-1),ra(e,h+10,R-4),h+=14,E=0;R>E;++E)ra(e,h+3*E,T[zo[E]]);h+=3*R;for(var U=[m,w],L=0;2>L;++L){var j=U[L];for(E=0;j.length>E;++E)ra(e,h,N[B=31&j[E]]),h+=T[B],B>15&&(ra(e,h,j[E]>>>5&127),h+=j[E]>>>12)}}else O=Zo,C=Qo,I=ta,A=Xo;for(E=0;a>E;++E)if(r[E]>255){var B;sa(e,h,O[257+(B=r[E]>>>18&31)]),h+=C[B+257],B>7&&(ra(e,h,r[E]>>>23&31),h+=jo[B]);var z=31&r[E];sa(e,h,I[z]),h+=A[z],z>3&&(sa(e,h,r[E]>>>5&8191),h+=Bo[z])}else sa(e,h,O[r[E]]),h+=C[r[E]];return sa(e,h,O[256]),h+C[256]},da=new Lo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),va=function(){for(var t=new Lo(256),e=0;256>e;++e){for(var i=e,r=9;--r;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),ca=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function fa(t,e){void 0===e&&(e={});var i=function(){var t=4294967295;return{p(e){for(var i=t,r=0;e.length>r;++r)i=va[255&i^e[r]]^i>>>8;t=i},d(){return 4294967295^t}}}(),r=t.length;i.p(t);var s,n,o,a,l,u=(a=10+((s=e).filename&&s.filename.length+1||0),l=8,function(t,e,i,r,s,n){var o=t.length,a=new No(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!e||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=ua(l,u,t.subarray(h,d)):(l[h]=!0,u=ua(l,u,t.subarray(h,o)))}else{for(var v=da[e-1],c=v>>>13,f=8191&v,p=(1<<i)-1,_=new Uo(32768),g=new Uo(p+1),m=Math.ceil(i/3),y=2*m,b=function(e){return(t[e]^t[e+1]<<m^t[e+2]<<y)&p},w=new Lo(25e3),x=new Uo(288),S=new Uo(32),E=0,k=0,T=(h=0,0),P=0,R=0;o>h;++h){var O=b(h),C=32767&h,I=g[O];if(_[C]=I,g[O]=C,h>=P){var A=o-h;if((E>7e3||T>24576)&&A>423){u=ha(t,l,0,w,x,S,k,T,R,h-R,u),T=E=k=0,R=h;for(var F=0;286>F;++F)x[F]=0;for(F=0;30>F;++F)S[F]=0}var M=2,D=0,N=f,U=C-I&32767;if(A>2&&O==b(h-U))for(var L=Math.min(c,A)-1,j=Math.min(32767,h),B=Math.min(258,A);j>=U&&--N&&C!=I;){if(t[h+M]==t[h+M-U]){for(var z=0;B>z&&t[h+z]==t[h+z-U];++z);if(z>M){if(M=z,D=U,z>L)break;var q=Math.min(U,z-2),H=0;for(F=0;q>F;++F){var V=h-U+F+32768&32767,W=V-_[V]+32768&32767;W>H&&(H=W,I=V)}}}U+=(C=I)-(I=_[C])+32768&32767}if(D){w[T++]=268435456|Vo[M]<<18|Wo[D];var G=31&Vo[M],K=31&Wo[D];k+=jo[G]+Bo[K],++x[257+G],++S[K],P=h+M,++E}else w[T++]=t[h],++x[t[h]]}}u=ha(t,l,!0,w,x,S,k,T,R,h-R,u)}return ia(a,0,r+ea(u)+s)}(n=t,null==(o=e).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),h=u.length;return function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>e.level?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&ca(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;i.length>=r;++r)t[r+10]=i.charCodeAt(r)}}(u,e),ca(u,h-8,i.d()),ca(u,h-4,r),u}var pa=!!o||!!n,_a="text/plain",ga=!1,ma=(t,e)=>{var i=t.split("#"),r=i[1],s=i[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter((t=>t.split("=")[0]!==e)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},ya=function(t,e,i){var r;void 0===i&&(i=!0);var s=t.split("?"),n=s[0],o=s[1],a=_({},e),l=null!==(r=null==o?void 0:o.split("&").map((t=>{var e,r=t.split("="),s=r[0],n=i&&null!==(e=a[s])&&void 0!==e?e:r[1];return delete a[s],s+"="+n})))&&void 0!==r?r:[],u=function(t,e){var i,r;void 0===e&&(e="&");var s=[];return ts(t,(function(t,e){it(t)||it(e)||"undefined"===e||(i=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(e),s[s.length]=r+"="+i)})),s.join(e)}(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},ba=t=>{if(t.ea)return t.ea;var e=t.data,i=t.compression;if(e){if(i===go.GZipJS){var r=fa(function(t,e){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new No(t.length+(t.length>>>1)),s=0,n=function(t){r[s++]=t},o=0;i>o;++o){if(s+5>r.length){var a=new No(s+8+(i-o<<1));a.set(r),r=a}var l=t.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return ia(r,0,s)}(Bn(e)),{mtime:0});return{contentType:_a,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===go.Base64){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(parseInt(e,16))))):t}(Bn(e)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:Bn(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Bn(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},wa=t=>{var e,i,r=()=>"sendBeacon"===t.transport?{url:ya(t.url,{compression:go.Base64}),encodedBody:ba(_({},t,{compression:go.Base64,ea:void 0}))}:{url:ma(t.url,"compression"),encodedBody:ba(_({},t,{compression:void 0,ea:void 0}))};try{e=ba(t)}catch(e){if(O(t.compression,qn(t.url,"compression")))return Ci.error("Failed to gzip request body, sending uncompressed payload",e),r();throw e}return e&&O(t.compression,qn(t.url,"compression"))&&!((i=e.body)instanceof ArrayBuffer?R(new Uint8Array(i)):ArrayBuffer.isView(i)&&R(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(ga=!0,r()):{url:t.url,encodedBody:e}},xa=t=>{try{return wa(t)}catch(e){return Ci.error(e),void(null==t.callback||t.callback({statusCode:0,error:e}))}},Sa=function(){var t=p((function*(t){var e=Bn(t.data),i=yield function(t,e,i){return F.apply(this,arguments)}(e,c.DEBUG,{rethrow:!0});if(!i)return t;var r=yield i.arrayBuffer();return _({},t,{ea:{contentType:_a,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}}(),Ea=/Failed to fetch|NetworkError|Load failed/i,ka=t=>"TypeError"===(null==t?void 0:t.name)&&Ea.test((null==t?void 0:t.message)||""),$a=t=>{var e=xa(t);if(e){var i=e.url,r=e.encodedBody,s=null!=r?r:{},o=s.contentType,l=s.body,u=s.estimatedSize,h=new Headers;ts(t.headers,(function(t,e){h.append(e,t)})),o&&h.append("Content-Type",o);var d=null,v=!1;if(a){var c=new a;d={signal:c.signal,timeout:setTimeout((()=>{var e,i;v=!0,c.abort((e=t.timeout,(i=new Error("PostHog request timed out"+(e?" after "+e+"ms":""))).name="AbortError",i))}),t.timeout)}}var f=e=>{v&&"AbortError"===(null==e?void 0:e.name)||ka(e)?Ci.warn(e):Ci.error(e),null==t.callback||t.callback({statusCode:0,error:e})};try{var p;n(i,_({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.ia&&52428.8>(u||0),body:l,signal:null==(p=d)?void 0:p.signal},t.fetchOptions)).then((e=>e.text().then((i=>{var r={statusCode:e.status,text:i};if(200===e.status)try{r.json=JSON.parse(i)}catch(t){Ci.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Ta=t=>{try{var e,r=wa(t),s=r.url,n=r.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(i.sendBeacon(s,u))return;var h=X(t.data)?t.data:null==(e=t.data)?void 0:e.batch;if(X(h)&&h.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(h.length/2),v=e=>X(t.data)?e:_({},t.data,{batch:e});return Ta(_({},t,{data:v(h.slice(0,d))})),void Ta(_({},t,{data:v(h.slice(d))}))}Ci.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),$a(_({},t,{ia:!0}))}catch(t){Ci.warn("Beacon send failed",t)}},Pa=(t,e,i,r)=>{var s="query"===r?"POST"===e?"sent_at":"_":void 0;return ya(i===go.GZipJS?ma(t,"compression"):t,_({},s?{[s]:Date.now().toString()}:{},i===go.GZipJS?{}:{compression:i}))},Ra=[];n&&Ra.push({transport:"fetch",method:$a}),o&&Ra.push({transport:"XHR",method(t){var e=xa(t);if(e){var i=new o,r=e.encodedBody;i.open(t.method||"GET",e.url,!0);var s=null!=r?r:{},n=s.contentType,a=s.body;ts(t.headers,(function(t,e){i.setRequestHeader(e,t)})),n&&i.setRequestHeader("Content-Type",n),t.timeout&&(i.timeout=t.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var e={statusCode:i.status,text:i.responseText};if(200===i.status)try{e.json=JSON.parse(i.responseText)}catch(t){}null==t.callback||t.callback(e)}},i.send(a)}}}),null!=i&&i.sendBeacon&&Ra.push({transport:"sendBeacon",method:Ta});var Oa=3e3;class Ca{constructor(t,e){this.ra=!0,this.na=[],this.sa=wt((null==e?void 0:e.flush_interval_ms)||Oa,250,5e3,Ci.createLogger("flush interval"),Oa),this.aa=t}enqueue(t){this.na.push(t),this.oa||this.la()}unload(){this.ua();var t=this.na.length>0?this.ha():{},e=Object.values(t);[...e.filter((t=>0===t.url.indexOf("/e"))),...e.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.da(_({},t,{transport:"sendBeacon"}))}))}enable(){this.ra=!1,this.la()}la(){var t=this;this.ra||(this.oa=setTimeout((()=>{if(this.ua(),this.na.length>0){var e=this.ha(),i=function(){var i=e[r],s=(new Date).getTime();i.data&&X(i.data)&&ts(i.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.da(i)};for(var r in e)i()}}),this.sa))}da(t){try{this.aa(t)}catch(t){Ci.error(t)}}ua(){clearTimeout(this.oa),this.oa=void 0}ha(){var t={};return ts(this.na,(e=>{var i,r=e,s=(r?r.batchKey:null)||r.url;it(t[s])&&(t[s]=_({},r,{data:[]})),null==(i=t[s].data)||i.push(r.data)})),this.na=[],t}}var Ia=["retriesPerformedSoFar"];class Aa{constructor(e){this.va=!1,this.ca=3e3,this.na=[],this._instance=e,this.na=[],this.fa=!0,!it(t)&&"onLine"in t.navigator&&(this.fa=t.navigator.onLine,this.pa=()=>{this.fa=!0,this.ga()},this.ma=()=>{this.fa=!1},ls(t,"online",this.pa),ls(t,"offline",this.ma))}get length(){return this.na.length}retriableRequest(t){var e=t.retriesPerformedSoFar,i=g(t,Ia);lt(e)&&(i.url=ya(i.url,{retry_count:e})),this._instance._send_request(_({},i,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.kn(_({retriesPerformedSoFar:e},i));0===t.statusCode&&Ci.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(null!=e?e:0)+" retries.")}null==i.callback||i.callback(t)}}))}kn(t){var e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;var i=function(t){var e=3e3*Math.pow(2,t),i=e/2,r=Math.min(18e5,e),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(e),r=Date.now()+i;this.na.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),Ci.warn(s),this.va||(this.va=!0,this.ya())}ya(){if(this.ba&&clearTimeout(this.ba),0===this.na.length)return this.va=!1,void(this.ba=void 0);this.ba=setTimeout((()=>{this.fa&&this.na.length>0&&this.ga(),this.ya()}),this.ca)}ga(){var t=Date.now(),e=[],i=this.na.filter((i=>t>i.retryAt||(e.push(i),!1)));if(this.na=e,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.ba&&(clearTimeout(this.ba),this.ba=void 0),this.va=!1,it(t)||(this.pa&&(t.removeEventListener("online",this.pa),this.pa=void 0),this.ma&&(t.removeEventListener("offline",this.ma),this.ma=void 0)),this.na)){var i=e.requestOptions;try{this._instance._send_request(_({},i,{transport:"sendBeacon"}))}catch(t){Ci.error(t)}}this.na=[]}}class Fa{constructor(t){this._a=()=>{var t,e,i,r;this.wa||(this.wa={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.wa.lastScrollY=Math.ceil(n),this.wa.maxScrollY=Math.max(n,null!==(t=this.wa.maxScrollY)&&void 0!==t?t:0),this.wa.maxScrollHeight=Math.max(o,null!==(e=this.wa.maxScrollHeight)&&void 0!==e?e:0),this.wa.lastContentY=a,this.wa.maxContentY=Math.max(a,null!==(i=this.wa.maxContentY)&&void 0!==i?i:0),this.wa.maxContentHeight=Math.max(l,null!==(r=this.wa.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get ka(){return this._instance.config.scroll_root_selector}getContext(){return this.wa}resetContext(){var t=this.wa;return setTimeout(this._a,0),t}startMeasuringScrollPosition(){ls(t,"scroll",this._a,{capture:!0}),ls(t,"scrollend",this._a,{capture:!0}),ls(t,"resize",this._a)}scrollElement(){if(!this.ka)return null==t?void 0:t.document.documentElement;var e=X(this.ka)?this.ka:[this.ka];for(var i of e){var r=null==t?void 0:t.document.querySelector(i);if(r)return r}}Sa(e){var i="y"===e?"scrollTop":"scrollLeft";if(this.ka){var r=this.scrollElement();return r&&r[i]||0}return t?"y"===e?t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop||0:t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft||0:0}scrollY(){return this.Sa("y")}scrollX(){return this.Sa("x")}}var Ma=t=>no(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);class Da{constructor(t,e,i,r){this.ot=t=>{var e=this.xa();if(!e||e.sessionId!==t){var i={sessionId:t,props:this.Ca(this._instance)};this.Ta.register({[Or]:i})}},this._instance=t,this.Ma=e,this.Ta=i,this.Ca=r||Ma,this.Ma.onSessionId(this.ot)}xa(){return this.Ta.props[Or]}getSetOnceProps(){var t,e=null==(t=this.xa())?void 0:t.props;return e?"r"in e?oo(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var t={};return ts(ns(this.getSetOnceProps()),((e,i)=>{"$current_url"===i&&(i="url"),t["$session_entry_"+G(i)]=e})),t}}class Na{on(t,e){return this.Ea[t]||(this.Ea[t]=[]),this.Ea[t].push(e),()=>{this.Ea[t]=this.Ea[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Ea[t]||[])i(e);for(var r of this.Ea["*"]||[])r(t,e)}constructor(){this.Ea={}}}var Ua=Ii("[SessionId]"),La=864e5;class ja{on(t,e){return this.Ia.on(t,e)}constructor(t,e,i){var r;if(this.Ra=null,this.Pa=null,this.Aa=[],this.Fa=void 0,this.Oa=!1,this.Ia=new Na,this.La=(t,e)=>!(!lt(t)||!lt(e))&&Math.abs(t-e)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===qr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Di=t.config,this.Ta=t.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.$a=void 0,this._sessionActivityTimestamp=null,this.Da=e||_s,this.Na=i||_s;var s=this.Di.persistence_name||this.Di.token;if(this._sessionTimeoutMs=1e3*wt(this.Di.session_idle_timeout_seconds||1800,60,36e3,Ua.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.qa(),this.ja="ph_"+s+"_window_id",this.Ba="ph_"+s+"_primary_window_exists",this.Ha()){var n=Ds.Br(this.ja),o=Ds.Br(this.Ba);n&&!o?this.st=n:Ds.qr(this.ja),Ds.Dr(this.Ba,!0)}null!=(r=this.Di.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.Di.bootstrap.sessionID),this.Ua()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return it(this.Aa)&&(this.Aa=[]),this.Aa.push(t),this._e&&t(this._e,this.st),()=>{this.Aa=this.Aa.filter((e=>e!==t))}}Ha(){return"memory"!==this.Di.persistence&&!this.Ta.xs&&Ds.Nr()}za(t){t!==this.st&&(this.st=t,this.Ha()&&Ds.Dr(this.ja,t))}Wa(){return this.st?this.st:this.Ha()?Ds.Br(this.ja):null}Va(t){var e=this.Ra;return!nt(e)&&!nt(t)&&5e3>Math.abs(t-e)}Ga(t,e,i){var r=e!==this._sessionActivityTimestamp,s=!(t!==this._e||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=e,this._e=t,s&&!r||s&&this.Va(e)||(this.Ra=e,this.Ta.register({[nr]:[e,t,i]}))}Za(){var t,e=null==(t=this.Di)?void 0:t.persistence_save_debounce_ms;return lt(e)&&e>0}Qa(){this.Za()?this.Ta.refreshKey(nr):(this.Ta.flush(),this.Ta.load())}Ja(){var t;if(!nt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Ra){this.Qa();var e=this.Ka();e[1]===this._e&&e[2]===this._sessionStartTimestamp&&(this.Ra=this._sessionActivityTimestamp,this.Ta.register({[nr]:[this._sessionActivityTimestamp,null!==(t=this._e)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Ta.flush())}}Ya(){var t=this.Ka()[0],e=lt(t)?t:0,i=lt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,i)}Xa(t){return this.Qa(),this.La(t,this.Ya())}Ka(){var t=this.Ta.props[nr];return X(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Ra=null,this.$a=void 0,clearTimeout(this.eo),this.eo=void 0,this.Ga(null,null,null)}setBootstrapSessionId(t,e){void 0===e&&(e=!1);var i=function(t,e){void 0===e&&(e=(new Date).getTime());try{var i=(t=>{var e=t.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})(t);return i>e+6e4?void Ua.error("Bootstrap sessionID cannot be in the future"):i}catch(t){return void Ua.error("Invalid sessionID in bootstrap",t)}}(t);return!it(i)&&(e?this.$a={sessionId:t,sessionStartTimestamp:i}:this.Ga(t,(new Date).getTime(),i),!0)}destroy(){this.Oa=!0,this.Ja(),clearTimeout(this.eo),this.eo=void 0,this.Fa&&t&&(t.removeEventListener(Kr,this.Fa,{capture:!1}),this.Fa=void 0),this.Aa=[]}Ua(){this.Fa=()=>{this.Ja(),this.Ha()&&Ds.qr(this.Ba)},ls(t,Kr,this.Fa,{capture:!1})}checkAndGetSessionAndWindowId(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=!1),this.Di.cookieless_mode===qr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=e||(new Date).getTime(),s=this._e;if(i)this.Pa=r;else if(nt(this.Pa)||this.Pa>r||r-this.Pa>=1e3){var n,o;null==(n=(o=this.Ta).syncCookieProperties)||n.call(o),this.Pa=r}var a=this.Ka(),l=a[1],u=a[2],h=!it(s)&&l!==s,d=this.Ya(),v=this.Wa(),c=this.$a,f=!!c&&(c.sessionStartTimestamp>r+6e4||r-c.sessionStartTimestamp>La),p=c?f:lt(u)&&Math.abs(r-u)>La,_=!1,g=h,m=!l||!!c,y=l,b=!m&&!t&&this.La(r,d);if(b){(b=this.Xa(r))||Ua.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this.Ka();l=w[1],u=w[2]}if(m||b||p){g=!1;var x=c&&!f;l=x?c.sessionId:this.Da(),v=this.Na(),Ua.info("new session ID assigned",{sessionId:l,windowId:v,bootstrapped:!!x,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p}}),u=x?c.sessionStartTimestamp:r,this.$a=void 0,_=!0}else v||(v=this.Na(),_=!0),(g=g||l!==y)&&(Ua.info("adopted cross-tab session id",{sessionId:l,windowId:v}),_=!0);var S=lt(d)&&t&&!p?d:r,E=lt(u)?u:(new Date).getTime();this.za(v),this.Ga(l,S,E),t||this.qa();var k={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p,crossTabAdoption:g};return _&&this.Aa.forEach((t=>t(l,v,k))),{sessionId:l,windowId:v,sessionStartTimestamp:E,changeReason:_?k:void 0,lastActivityTimestamp:d}}qa(){this.Oa||(clearTimeout(this.eo),this.eo=setTimeout((()=>{if(!this.Oa)if(this.Xa((new Date).getTime())){var t=this._e;this.resetSessionId(),this.Ia.emit("forcedIdleReset",{idleSessionId:t})}else this.qa()}),1.1*this.sessionTimeoutMs))}}var Ba=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&H(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>H(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver};function za(){return(za=p((function*(){var t=null==i?void 0:i.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),r=null==e?void 0:e.model;return rt(r)&&r.length>0?r:void 0}catch(t){return void Ci.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}var qa=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}};function Ha(t,e,i){return Bn({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}var Va={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>qa(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!qa(e,t))))),icontains:(t,e)=>e.map(Wa).some((e=>t.map(Wa).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(Wa).every((e=>t.map(Wa).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},Wa=t=>t.toLowerCase();function Ga(t,e){return!t||Object.entries(t).every((t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(it(r)||nt(r))return!1;var s=[String(r)],n=Va[i.operator];return!!n&&n(i.values,s)}))}var Ka="custom",Ja="i.posthog.com",Ya=/^\/static\//,Qa=["/s/","/e/","/i/"];class Xa{constructor(t){this.io={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,e=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace("."+Ja,".posthog.com")),"https://app.posthog.com"===e?"https://us.posthog.com":e}get region(){return this.io[this.apiHost]||(this.io[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":Ka),this.io[this.apiHost]}ro(t){if(Ya.test(t)){var e=this.instance.config.asset_host;if("string"==typeof e)return e.trim().replace(/\/$/,"")||void 0}}no(t){var e=zn(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}so(t,e,i){if("ui"===t)return i;var r=i,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=zn(i))?void 0:n.href)||i;r=s(new URL(o)).toString()}if(s&&"api"===t&&Qa.some((t=>0===e.indexOf(t)))){var a=this.no(r);if(a){var l,u=this.apiHost,h=this.ao;(null==(l=h)?void 0:l.apiHost)===u&&h.rewriteRequestPath===s||(h={apiHost:u,rewriteRequestPath:s,urls:new Set},this.ao=h),h.urls.add(a)}}return r}isIngestionEndpoint(t){var e=this.ao,i=this.no(t);return(null==e?void 0:e.apiHost)===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&e.urls.has(i)}endpointFor(t,e){if(void 0===e&&(e=""),e&&(e="/"===e[0]?e:"/"+e),"ui"===t)return this.so(t,e,this.uiHost+e);if("flags"===t)return this.so(t,e,this.flagsApiHost+e);if("assets"===t){var i=this.ro(e);if(i)return this.so(t,e,""+i+e)}if(this.region===Ka)return this.so(t,e,this.apiHost+e);var r=Ja+e;switch(t){case"assets":return this.so(t,e,"https://"+this.region+"-assets."+r);case"api":return this.so(t,e,"https://"+this.region+"."+r)}}}function Za(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var tl=Ii("[Surveys]"),el="seenSurvey_",il=t=>{try{var e=(t=>((t,e)=>""+el+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){tl.error("Failed to persist survey seen state",t)}},rl=[xo.Popover,xo.Widget,xo.API],sl={ignoreConditions:!1,ignoreDelay:!1,displayType:Po.Popover},nl=Ii("[PostHog ExternalIntegrations]"),ol={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class al{constructor(t){this._instance=t}Xn(t,e){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,t,(t=>{if(t)return nl.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var t=this,e=function(){var e,r,s,n=i[0],o=i[1];!o||null!=(e=v.__PosthogExtensions__)&&null!=(e=e.integrations)&&e[n]||t.Xn(ol[n],(()=>{var e;null==(e=v.__PosthogExtensions__)||null==(e=e.integrations)||null==(e=e[n])||e.start(t._instance)})),!o&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=v.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var i of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;e()}}}class ll{constructor(t,e){this.I=t,this.oo=e,this.lo=new Map,this.uo=!1}add(t){var e=this;return p((function*(){if(e.uo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.lo.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.lo.set(t.name,t);try{var i=t.setup(e.oo);i&&(yield i)}catch(i){var r=e.lo.get(t.name)===t;r&&e.lo.delete(t.name),e.I.error('Failed to set up browser extension "'+t.name+'"',i),r&&e.ho(t)}}))()}dispose(){if(!this.uo){this.uo=!0;var t=Array.from(this.lo.values()).reverse();for(var e of(this.lo.clear(),t))this.ho(e)}}ho(t){try{var e=null==t.dispose?void 0:t.dispose();e&&Z(e.then)&&e.then(void 0,(e=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',e)}))}catch(e){this.I.error('Failed to dispose browser extension "'+t.name+'"',e)}}}class ul{constructor(t){this._instance=t}initialize(){}get(t){var e=this._instance.persistence;if("string"==typeof t)return null==e?void 0:e.get_property(t);var i={};for(var r of t){var s=null==e?void 0:e.get_property(r);it(s)||(i[r]=s)}return i}set(t,e){var i;null==(i=this._instance.persistence)||i.register("string"==typeof t?{[t]:e}:t)}remove(t){var e;null==(e=this._instance.persistence)||e.unregister(t)}}var hl="extensionsRemoteConfig";class dl{constructor(t){this.uo=!1,this.instance=t,this.I=Ci,this.do=t.vo,this.kv=new ul(t),this.onEvent=t=>_o(this.instance.on("eventCaptured",(e=>{try{t({event:e.event,properties:e.properties})}catch(t){this.I.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.uo)return _o((()=>{}));var e=e=>{try{t(e)}catch(t){this.I.error("Browser extension remote config listener failed",t)}},i=this.instance.co.on(hl,e);return this.do&&e(this.do),_o(i)},this.fo=new ll(Ci.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property(ji))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property(ji);return"string"==typeof t?t:void 0}get library(){return{name:c.LIB_NAME,version:c.LIB_VERSION}}get initialPersonProperties(){var t,e;return null!==(t=null==(e=this.instance.persistence)?void 0:e.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,e,i,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(e=null==s?void 0:s.sessionId)&&void 0!==e?e:"",windowId:null!==(i=null==s?void 0:s.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.fo.add(t)}capture(t,e,i){var r=this;return p((function*(){i?r.instance.capture(t,e,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):r.instance.capture(t,e)}))()}registerDynamicEventProperties(t){return _o(this.instance.po(t))}handleRemoteConfig(t){this.uo||(this.do=t,this.instance.co.emit(hl,t))}sendRequest(t,e){var i=this;return p((function*(){var r;void 0===e&&(e={});var s=i.instance.requestRouter.endpointFor(null!==(r=e.target)&&void 0!==r?r:"api",t),n={method:e.method,url:e.query?ya(s,e.query):s,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt};return"sendBeacon"===e.transport?(i.instance._send_request(n),{statusCode:202}):new Promise((t=>{n.callback=t,i.instance._send_request(n)}))}))()}dispose(){this.uo||(this.uo=!0,this.fo.dispose())}}var vl={},cl=0,fl=()=>{},pl='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',_l="Surveys module not available",gl="sanitize_properties is deprecated. Use before_send instead",ml="Invalid value for property_denylist config: ",yl=["token","distinct_id",Nr],bl="posthog",wl=!pa&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla")),xl=e=>{var i;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:as(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:s&&rt(null==s?void 0:s.search)&&-1!==s.search.indexOf("__posthog_debug=true")||!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:"https:"===(null==t||null==(i=t.location)?void 0:i.protocol),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){Ci.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:Wr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Oa},error_tracking:{},_onCapture:fl},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:an,ignore_text_selection:!0}:!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||"unset"===t||"2026-08-29">t)}))(e))},Sl=[["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"]],El=t=>{var e={};for(var i of Sl){var r=i[0],s=i[1];it(t[r])||(e[s]=t[r])}var n=es({},e,t),o=t.__preview_external_dependency_versioned_paths;return it(o)||(it(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),rt(o)&&it(t.asset_host)&&(n.asset_host=o)),X(t.property_blacklist)&&(it(t.property_denylist)?n.property_denylist=t.property_blacklist:X(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:Ci.error(ml+t.property_denylist)),n};class kl{constructor(){this.__forceAllowLocalhost=!1}get mo(){return this.__forceAllowLocalhost}set mo(t){Ci.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class $l{yo(t,e){if(t){var i=this.lo.indexOf(t);-1!==i&&this.lo.splice(i,1)}return this.lo.push(e),null==e.initialize||e.initialize(),e}bo(){return this.config.cookieless_mode===qr||this.config.cookieless_mode===zr&&this.consent.isRejected()}_o(){if(!this.bo()&&this.get_distinct_id()===Dr){var t=this.persistence;if(t){this.wo()||t.load(!0);var e=this.get_distinct_id();if(!e||e===Dr){var i=this.config.get_device_id(_s());this.register({distinct_id:i,$device_id:i}),t.set_property(Rr,Hr)}this.ko()}}}get decideEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.webPerformance=new kl,this.So=!1,this.version=c.LIB_VERSION,this.xo=new Set,this.Co="",this.co=new Na,this.lo=[],this.To=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=xl(),this.SentryIntegration=Mn,this.sentryIntegration=t=>function(t,e){var i=Fn(t,e);return{name:An,processEvent:t=>i(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Mo=!1,this.Eo=null,this.Io=null,this.Ro=null,this.scrollManager=new Fa(this),this.pageViewManager=new Dn(this),this.rateLimiter=new Ao(this),this.requestRouter=new Xa(this),this.consent=new Ns(this),this.externalIntegrations=new al(this);var e=null!==(t=$l.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(t,e,i)=>{var r=rt(t)?{[t]:e}:t;this.setPersonProperties(r),null==i||i({})},set_once:(t,e,i)=>{var r=rt(t)?{[t]:e}:t;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(t=>Ci.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,e,i){if(i&&i!==bl){var r,s=null!==(r=vl[i])&&void 0!==r?r:new $l;return s._init(t,e,i),vl[i]=s,vl[bl][i]=s,s}return this._init(t,e,i)}_init(e,i,r){var s,n;void 0===i&&(i={});var o,a=rt(e)?e.trim():"";if(!a)return Ci.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 a!==(null==(o=this.config)?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=xl(i.defaults),i.debug=this.Po(i.debug),this.Ao=i,this.Fo=[],i.person_profiles?this.Io=i.person_profiles:i.process_person&&(this.Io=i.process_person);var l=xl(i.defaults),u=El(i),h=es({},l,u,{name:r,token:a});tt(l.rageclick)&&tt(u.rageclick)&&(h.rageclick=es({},l.rageclick,u.rageclick)),tt(l.session_recording)&&tt(u.session_recording)&&(h.session_recording=es({},l.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&Ci.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:go.GZipJS;var d=this.wo();if(this.persistence=new po(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new po(_({},this.config,{persistence:"sessionStorage"}),d,!1),this.Co="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!d&&Ds.Nr()){var v=Ds.Br(this.Co);X(v)&&v.forEach((t=>{rt(t)&&this.xo.add(t)}))}else Ds.qr(this.Co);var f=_({},this.persistence.props),p=_({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Oo=new Ca((t=>this.Lo(t)),this.config.request_queue_config),this.$o=new Aa(this),this.__request_queue=[];var g=this.bo();if(g||(this.sessionManager=new ja(this),this.sessionPropsManager=new Da(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((t,e,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this.Do()}))),this.No(),this.config.__preview_deferred_init_extensions?(Ci.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.qo(g)}),0)):(Ci.info("Initializing extensions synchronously"),this.qo(g)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&Ci.info("Starting in debug mode",{this:this,config:i,thisC:_({},this.config),p:f,s:p}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=_({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(n=i.bootstrap)?void 0:n.distinctID)){var m=i.bootstrap.distinctID,y=this.get_distinct_id(),b=this.persistence.get_property(Rr);if(i.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Hr)this.identify(m);else if(i.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Vr)Ci.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 w=this.config.get_device_id(_s()),x=i.bootstrap.isIdentifiedID?w:m;this.persistence.set_property(Rr,i.bootstrap.isIdentifiedID?Vr:Hr),this.register({distinct_id:m,$device_id:x})}}if(g)this.register_once({distinct_id:Dr,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(_s());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(Rr,Hr)}return ls(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?function(t,e){var i=t.config.segment;if(!i)return e();!function(t,e){var i=t.config.segment;if(!i)return e();var r=i=>{var r=()=>i.anonymousId()||_s();t.config.get_device_id=r,i.id()&&(t.register({distinct_id:i.id(),$device_id:r()}),t.persistence.set_property(Rr,Vr)),e()},s=i.user();"then"in s&&Z(s.then)?s.then(r):r(s)}(t,(()=>{i.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||In.warn("This browser does not have Promise support, and can not use the segment integration");var e=(e,i)=>{if(!i)return e;e.event.userId||e.event.anonymousId===t.get_distinct_id()||(In.info("No userId set, resetting PostHog"),t.reset()),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(In.info("UserId set, identifying with PostHog"),t.identify(e.event.userId));var r=t.calculateEventProperties(i,e.event.properties);return e.event.properties=Object.assign({},r,e.event.properties),e};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:t=>e(t,t.event.event),page:t=>e(t,Jr),identify:t=>e(t,Qr),screen:t=>e(t,"$screen")}})(t)).then((()=>{e()}))}))}(this,(()=>this.jo())):this.jo(),Z(this.config._onCapture)&&this.config._onCapture!==fl&&(Ci.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&Ci.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 za.apply(this,arguments)}().then((t=>{t&&this.register({[Bi]:t})})).catch(fl),this}No(){var t,e,i,r,s,n,o=null!==(t=null==(e=this.config.__extensionClasses)?void 0:e.featureFlags)&&void 0!==t?t:null==(i=$l.__defaultExtensionClasses)?void 0:i.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||(null==(r=this.Bo)||r.call(this),this.Bo=void 0,this.featureFlags=new o(this)),Z(this.featureFlags.onReloading)&&Z(this.featureFlags.setup)?this.Bo||(this.Bo=this.featureFlags.onReloading((()=>{this.co.emit("featureFlagsReloading",!0)})),this.Ho().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}qo(t){var e,i,r,s,n,o,a,l=performance.now(),u=_({},$l.__defaultExtensionClasses,this.config.__extensionClasses),h=[];u.exceptions&&this.lo.push(this.exceptions=null!==(e=this.exceptions)&&void 0!==e?e:new u.exceptions(this)),u.historyAutocapture&&this.lo.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.lo.push(this.tracingHeaders=new u.tracingHeaders(this)),u.siteApps&&this.lo.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!t&&this.lo.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),u.autocapture&&this.lo.push(this.autocapture=new u.autocapture(this)),u.surveys&&this.lo.push(this.surveys=null!==(i=this.surveys)&&void 0!==i?i:new u.surveys(this)),u.logs&&this.lo.push(this.logs=null!==(r=this.logs)&&void 0!==r?r:new u.logs(this)),u.metrics&&this.lo.push(this.metrics=null!==(s=this.metrics)&&void 0!==s?s:new u.metrics(this)),u.conversations&&this.lo.push(this.conversations=null!==(n=this.conversations)&&void 0!==n?n:new u.conversations(this)),u.productTours&&this.lo.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.lo.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.lo.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.lo.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.lo.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,On)),u.toolbar&&this.lo.push(this.toolbar=null!==(o=this.toolbar)&&void 0!==o?o:new u.toolbar(this)),u.experiments&&this.lo.push(this.experiments=null!==(a=this.experiments)&&void 0!==a?a:new u.experiments(this)),this.lo.forEach((t=>{t.initialize&&h.push((()=>{null==t.initialize||t.initialize()}))})),h.push((()=>{if(this.Uo){var t=this.Uo;this.Uo=void 0,this.lo.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}})),this.zo(h,l)}zo(t,e){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-e>=30&&t.length>0)return void setTimeout((()=>{this.zo(t,e)}),0);var i=t.shift();if(i)try{i()}catch(t){Ci.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-e);this.register_for_session({[Ur]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Lr]:r}),this.config.__preview_deferred_init_extensions&&Ci.info("PostHog extensions initialized ("+r+"ms)")}Ks(t){var e;if(!r||!r.body)return Ci.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Ks(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Uo=t),this.vo=t,this.compression=void 0,t.ok){var i,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=V(s.supportedCompression,go.GZipJS)?go.GZipJS:V(s.supportedCompression,go.Base64)?go.Base64:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.Io?this.Io:Wr}),null==(e=this.Wo)||e.handleRemoteConfig(t),this.lo.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}jo(){try{this.config.loaded(this)}catch(t){Ci.critical("`loaded` function failed",t)}if(this.Vo(),this.config.internal_or_test_user_hostname&&null!=s&&s.hostname){var t=s.hostname,e=this.config.internal_or_test_user_hostname;("string"==typeof e?t===e:e.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.bo())&&this.Go()}),1),this.Zo=new Mo(this),this.Zo.load()}Vo(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.Oo)||t.enable())}_dom_loaded(){this.is_capturing()&&Zr(this.__request_queue,(t=>this.Lo(t))),this.__request_queue=[],this.Vo()}_handle_unload(){var t,e,i,r,s;null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(e=this.metrics)||e.flush("sendBeacon"),this.config.request_batching?(this.Qo()&&this.capture(Yr),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this.Oo)||r.unload(),null==(s=this.$o)||s.unload()):this.Qo()&&this.capture(Yr,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?wl?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=_({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?this.compression:t.compression,(it(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var e,i,r,s=_({},t);s.timeout=s.timeout||6e4;var n,o,a,u,h,d=null!==(e=s.transport)&&void 0!==e?e:"fetch";"sendBeacon"===d&&it(s.compression)&&s.data&&(s.compression=go.Base64),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(h=(u=(X(n=s.data)?n:[n]).map((t=>_({},t,t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{}))))[0])||null==(a=h.properties)?void 0:a.token)&&void 0!==o?o:null==h?void 0:h.token,batch:u,sent_at:(new Date).toISOString()}:"body"===s.timestampMode&&(s.data=function(t,e){return void 0===e&&(e=(new Date).toISOString()),X(t)?t.map((t=>_({},t,{sent_at:e}))):_({},t,{sent_at:e})}(s.data))),s.url=Pa(s.url,s.method,s.compression,s.timestampMode);var v=Ra.filter((t=>!s.disableTransport||!t.transport||!s.disableTransport.includes(t.transport))),c=null!==(i=null==(r=function(t,e){for(var i=0;t.length>i;i++)if(t[i].transport===d)return t[i]}(v))?void 0:r.method)&&void 0!==i?i:v[0].method;if(!c)throw new Error("No available transport method");var f=t=>{try{c(t)}catch(t){ka(t)?Ci.warn(t):Ci.error(t),null==s.callback||s.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&s.data&&s.compression===go.GZipJS&&l&&"undefined"!=typeof Promise&&!ga?Sa(s).then((t=>{f(t)})).catch((e=>{if(C(e))return ga=!0,void f(_({},s,{compression:void 0,url:Pa(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var e="name"in t?String(t.name):"";return C(t)||e===P})(e)&&(ga=!0),f(s)})):c(s)})(_({},t,{callback:e=>{var i,r;this.rateLimiter.checkForLimiting(e),400>e.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,e),null==t.callback||t.callback(e)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}Lo(t){this.$o?this.$o.retriableRequest(t):this._send_request(t)}_execute_array(t){cl++;try{var e,i=[],r=[],s=[];Zr(t,(t=>{if(t)if(X(e=t[0]))s.push(t);else if(Z(t))try{t.call(this)}catch(e){Ci.error("Error executing queued PostHog call",t,e)}else X(t)&&"alias"===e?i.push(t):X(t)&&-1!==e.indexOf("capture")&&Z(this[e])?s.push(t):r.push(t)}));var n=function(t,e){Zr(t,(function(t){try{if(X(t[0])){var i=e;ts(t,(function(t){i=i[t[0]].apply(i,t.slice(1))}))}else e[t[0]].apply(e,t.slice(1))}catch(e){Ci.error("Error executing queued PostHog call",t,e)}}))};n(i,this),n(r,this),n(s,this)}finally{cl--}}push(t){if(cl>0&&X(t)&&rt(t[0])){var e=$l.prototype[t[0]];Z(e)&&e.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,e,i){var r,s,n,o,a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Oo){if(this.is_capturing())if(!it(t)&&rt(t)){this._o();var l=!this.config.opt_out_useragent_filter&&this._is_bot();if(!l||this.config.__preview_capture_bot_pageviews){var u=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==u||!u.isRateLimited){null!=e&&e.$current_url&&!rt(null==e?void 0:e.$current_url)&&(Ci.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==e||delete e.$current_url),"$exception"!==t||null!=i&&i.Jo||Ci.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 h=new Date,d=(null==i?void 0:i.timestamp)||h,v=Pe(null==i?void 0:i.uuid,_s),c={uuid:v,event:t,properties:this.calculateEventProperties(t,e||{},d,v)};t===Jr&&this.config.__preview_capture_bot_pageviews&&l&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),u&&(c.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);var f="$feature_flag_called"===t&&!1===c.properties.$feature_flag_has_experiment&&!0===this.get_property(cr);(null==i?void 0:i.$set)&&!f&&(c.$set=null==i?void 0:i.$set);var p=null==i?void 0:i.$unset;p&&(c.$unset=p);var g,m,y,b=f?void 0:this.Ko(null==i?void 0:i.$set_once,t!==Xr,t===Qr);if(b&&(c.$set_once=b),null!=i&&i._noTruncate||(s=this.config.properties_string_max_length,n=c,o=t=>rt(t)?t.slice(0,s):t,a=new Set,c=function t(e,i){if(e!==Object(e))return o?o(e):e;if(!a.has(e)){var r;if(a.add(e),X(e))r=[],Zr(e,(e=>{r.push(t(e))}));else{var s={};ts(e,((e,i)=>{a.has(e)||(s[i]=t(e,i))})),r=s}return r}}(n)),c.timestamp=d,it(null==i?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=h),f&&(c.properties=function(t,e){void 0===e&&(e=[]);var i={},r=e=>{void 0!==t[e]&&(i[e]=t[e])};return x.forEach(r),e.forEach(r),i}(c.properties,yl)),t===$o.DISMISSED||t===$o.SENT){var w=null==e?void 0:e[To.SURVEY_ID],S=null==e?void 0:e[To.SURVEY_ITERATION];il({id:w,current_iteration:S}),c.$set=_({},c.$set,{[(g={id:w,current_iteration:S},m=t===$o.SENT?"responded":"dismissed",y="$survey_"+m+"/"+g.id,g.current_iteration&&g.current_iteration>0&&(y="$survey_"+m+"/"+g.id+"/"+g.current_iteration),y)]:!0})}else t===$o.SHOWN&&(c.$set=_({},c.$set,{[To.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(t===Oo.SHOWN){var E=null==e?void 0:e[Co.TOUR_TYPE];E&&(c.$set=_({},c.$set,{[Co.TOUR_LAST_SEEN_DATE+"/"+E]:(new Date).toISOString()}))}var k=_({},c.properties.$set,c.$set);if(et(k)||this.setPersonPropertiesForFlags(k),!ot(this.config.before_send)){var T=this._n(c);if(!T)return;(c=T).uuid=Pe(c.uuid,_s)}this.co.emit("eventCaptured",c);var P=null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),R={method:"POST",url:P,data:c,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(P)?"body":"capture-body",batchKey:null==i?void 0:i._batchKey,transport:null==i?void 0:i.transport};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.Lo(R):this.Oo.enqueue(R),c}Ci.critical("This capture call is ignored due to client rate limiting.")}}else Ci.error("No event name provided to posthog.capture")}else Ci.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(e=>t(e.event,e)))}Ho(){var t;return null!==(t=this.Wo)&&void 0!==t?t:this.Wo=new dl(this)}po(t){this.To.push(t);var e=!0;return()=>{if(e){e=!1;var i=this.To.indexOf(t);-1!==i&&this.To.splice(i,1)}}}Yo(t){var e,i,r;return void 0===t&&(t=!0),!(null==(e=this.persistence)||!e.consumeCookieIdentityChange())&&(this.Ro=null,this.persistence.get_property(Rr)===Hr&&(null==(r=this.sessionPersistence)||r.clear(),this.xo.clear(),this.Xo()),null==(i=this.featureFlags)||i.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,i,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this.Yo();var l=a?void 0:this.persistence.remove_event_timer(e),h=_({},i);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.bo()&&(h[Nr]=!0),"$snapshot"===e){var d=_({},this.persistence.properties(),this.sessionPersistence.properties());return h.distinct_id=d.distinct_id,(!rt(h.distinct_id)&&!at(h.distinct_id)||st(h.distinct_id))&&Ci.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}var v,f=function(e,i,r,n){var o,a,l,h;if(void 0===n&&(n=!1),!u)return{};var d,v=e?[...Jn,...i||[]]:[],f=function(t){for(var e=0;ke.length>e;e++){var i=ke[e],r=i[1],s=i[0].exec(t),n=s&&(Z(r)?r(s,t):r);if(n)return n}return["",""]}(u),p=f[0],_=f[1],g=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};it(r)||(m.detectGoogleSearchApp=r);var y={},b=null==(o=navigator)||null==(o=o.userAgentData)?void 0:o.platform,w=null==(a=navigator)?void 0:a.maxTouchPoints,x=null==t||null==(l=t.screen)?void 0:l.width,S=null==t||null==(h=t.screen)?void 0:h.height,E=null==t?void 0:t.devicePixelRatio;it(b)||(y.userAgentDataPlatform=b),it(w)||(y.maxTouchPoints=w),it(x)||(y.screenWidth=x),it(S)||(y.screenHeight=S),it(E)||(y.devicePixelRatio=E);var k,T,P,R,O,C,I,A,F=es(ns({$os:p,$os_version:_,$browser:xe(u,navigator.vendor,g,m),$device:$e(u),$device_type:(T=u,P=y,A=$e(T),A===Pt||A===Tt||"Kobo"===A||"Kindle Fire"===A||A===se?$t:A===Gt||A===Jt||A===Kt||A===ee?"Console":A===Ot?"Wearable":A?St:"Android"===(null==P?void 0:P.userAgentDataPlatform)&&(null!==(R=null==P?void 0:P.maxTouchPoints)&&void 0!==R?R:0)>0?600>Math.min(null!==(O=null==P?void 0:P.screenWidth)&&void 0!==O?O:0,null!==(C=null==P?void 0:P.screenHeight)&&void 0!==C?C:0)/(null!==(I=null==P?void 0:P.devicePixelRatio)&&void 0!==I?I:1)?St:$t:"Desktop"),$timezone:ao(),$timezone_offset:lo()}),{$current_url:Hn(n?Re(null==s?void 0:s.href):null==s?void 0:s.href,v,Qn),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:Ee(u,navigator.vendor,g,m),$browser_language:io(),$browser_language_prefix:(k=io(),"string"==typeof k?k.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return c.SDK_DIST_CHANNEL&&(F.$sdk_dist_channel=c.SDK_DIST_CHANNEL),F}(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 p=this.sessionManager.checkAndGetSessionAndWindowId(a,n.getTime(),!0),g=p.windowId;h.$session_id=p.sessionId,h.$window_id=g}this.sessionPropsManager&&es(h,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&es(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null==(m=this.$o)?void 0:m.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===Ka&&(h.$lib_custom_api_host=this.config.api_host),v=e!==Jr||a?e!==Yr||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),h=es(h,v),e===Jr&&r&&(h.title=r.title),!it(l)){var y=n.getTime()-l;h.$duration=parseFloat((y/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");var b=this.persistence.properties(),w=this.sessionPersistence.properties();ts(["$referrer","$referring_domain"],(t=>{t in b&&delete w[t]}));var x={};if(this.To.length>0)for(var S of this.To.slice())try{es(x,S())}catch(t){Ci.error("Failed to produce browser extension event properties",t)}(h=es({},f,b,w,_({},x,h))).$is_identified=this._isIdentified(),X(this.config.property_denylist)?ts(this.config.property_denylist,(function(t){delete h[t]})):Ci.error(ml+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var E=this.config.sanitize_properties;E&&(Ci.error(gl),h=E(h,e));var k=this.tl();return h.$process_person_profile=k,k&&!a&&this.el("_calculate_event_properties"),h}Ko(t,e,i){var r;if(void 0===e&&(e=!0),void 0===i&&(i=!1),!this.persistence||!this.tl())return t;if(this.So&&!i)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=es({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(Ci.error(gl),o=a(o,"$set_once")),e&&(this.So=!0),et(o)?void 0:o}register(t,e){var i;null==(i=this.persistence)||i.register(t,e)}register_once(t,e,i){var r;null==(r=this.persistence)||r.register_once(t,e,i)}register_for_session(t){var e,i;null==(e=this.persistence)||e.syncCookieProperties(),this.Yo(),null==(i=this.sessionPersistence)||i.register(t),Object.keys(t).forEach((t=>this.xo.add(t))),this.Xo()}unregister(t){var e;null==(e=this.persistence)||e.unregister(t)}unregister_for_session(t){var e;null==(e=this.sessionPersistence)||e.unregister(t),this.xo.delete(t),this.Xo()}il(t,e){this.register({[t]:e})}Do(){this.xo.forEach((t=>{var e;null==(e=this.sessionPersistence)||e.unregister(t)})),this.xo.clear(),this.Xo()}Xo(){var t;if(this.Co)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.xs||!Ds.Nr())Ds.qr(this.Co);else{var e=[];this.xo.forEach((t=>e.push(t))),e.length>0?Ds.Dr(this.Co,e):Ds.qr(this.Co)}}getFeatureFlag(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(t,e)}getFeatureFlagPayload(t){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagPayload(t)}getFeatureFlagResult(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(t,e)}getAllFeatureFlags(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,e){var i,r;return null!==(i=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,e))&&void 0!==i?i:null==e?void 0:e.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,e,i){var r;null==(r=this.featureFlags)||r.updateFlags(t,e,i)}updateEarlyAccessFeatureEnrollment(t,e,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,e,i)}getEarlyAccessFeatures(t,e,i){var r;return void 0===e&&(e=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,e,i)}on(t,e){return this.co.on(t,e)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:_l}),()=>{})}onSessionId(t){var e,i;return null!==(e=null==(i=this.sessionManager)?void 0:i.onSessionId(t))&&void 0!==e?e:()=>{}}getSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getSurveys(t,e):t([],{isLoaded:!1,error:_l})}getActiveMatchingSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,e):t([],{isLoaded:!1,error:_l})}renderSurvey(t,e){var i;null==(i=this.surveys)||i.renderSurvey(t,e)}displaySurvey(t,e){var i;void 0===e&&(e=sl),null==(i=this.surveys)||i.displaySurvey(t,e)}cancelPendingSurvey(t){var e;null==(e=this.surveys)||e.cancelPendingSurvey(t)}canRenderSurvey(t){var e,i;return null!==(e=null==(i=this.surveys)?void 0:i.canRenderSurvey(t))&&void 0!==e?e:{visible:!1,disabledReason:_l}}canRenderSurveyAsync(t,e){var i,r;return void 0===e&&(e=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,e))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:_l})}rl(t){return!t||st(t)?(Ci.critical("Unique user id has not been set in posthog.identify"),!1):t===Dr?(Ci.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Ci.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,e,i){if(!this.__loaded||!this.persistence)return Ci.uninitializedWarning("posthog.identify");if(at(t)&&(t=t.toString(),Ci.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.rl(t)&&this.el("posthog.identify")){this._o();var r=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,n=this.Yo(!1),o=this.persistence.Ms(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:t}),this.get_property(ji)||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),t!==l&&t!==this.get_property(zi)&&(this.unregister(zi),this.register({distinct_id:t}));var u,h=(this.persistence.get_property(Rr)||Hr)===Hr,d=t!==l,v=!d&&h;if(d&&h)this.persistence.set_property(Rr,Vr),this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Es(),this.capture(Qr,{distinct_id:t,$anon_distinct_id:l},{$set:e||{},$set_once:i||{}}),this.Ro=Ha(t,e,i),null==(u=this.featureFlags)||u.setAnonymousDistinctId(l);else if(v){this.persistence.set_property(Rr,Vr);var c=e||{},f=i||{};this.setPersonPropertiesForFlags({$set:c,$set_once:f},!1),this.config.cookieWinsOnConflict&&this.persistence.Es(),this.capture("$set",{$set:c,$set_once:f}),this.Ro=Ha(t,e,i)}else(e||i)&&this.setPersonProperties(e,i);d||s||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(kr)):v&&(e||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.Ps(a)}}}setPersonProperties(t,e){if((t||e)&&this.el("posthog.setPersonProperties")){var i=Ha(this.get_distinct_id(),t,e);this.Ro!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:e||{}},!0),this.capture("$set",{$set:t||{},$set_once:e||{}}),this.Ro=i):Ci.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var e,i=(X(t)?t:[t]).filter((t=>rt(t)&&t.length>0));0!==i.length&&this.el("posthog.unsetPersonProperties")&&(null==(e=this.featureFlags)||e.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Ro=null)}group(t,e,i){var r;if(t&&e){null==(r=this.persistence)||r.syncCookieProperties(),this.Yo();var s=this.getGroups(),n=s[t]!==e;if(n&&this.resetGroupPropertiesForFlags(t),this.register({$groups:_({},s,{[t]:e})}),n||i){var o={$group_type:t,$group_key:e};i&&(o.$group_set=i),this.capture(Xr,o)}i&&this.setGroupPropertiesForFlags({[t]:i}),n&&!i&&this.reloadFeatureFlags()}else Ci.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(t,e)}resetPersonPropertiesForFlags(t){var e;void 0===t&&(t=!0),null==(e=this.featureFlags)||e.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),this.el("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(t,e))}resetGroupPropertiesForFlags(t){var e;null==(e=this.featureFlags)||e.resetGroupPropertiesForFlags(t)}reset(t){var e=ut(t)?t:null==t?void 0:t.resetDeviceID,i=ut(t)||null==t?void 0:t.bootstrap;this.nl(e,!1,i)}nl(t,e,i){var r,s,n;if(void 0===e&&(e=!1),Ci.info("reset"),!this.__loaded)return Ci.uninitializedWarning("posthog.reset");var o=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null==(r=this.Ao)?void 0:r.bootstrap)||{},null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.Xs());var a=this.get_property(ji),l=this.get_property(Bi),u=this.get_property(Zi),h=this.is_capturing();this.consent.reset(),e||!h||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 d=null==(n=this.persistence)||null==n.Ms?void 0:n.Ms(),v=!1;try{var c,f,p,g,m,y,b,w,x,S,E,k,T,P;if(null==(c=this.persistence)||c.clear(),null==(f=this.sessionPersistence)||f.clear(),this.xo.clear(),this.Xo(),it(u)||null==(E=this.persistence)||E.register({[Zi]:u}),null==(p=this.surveys)||p.reset(),null==(g=this.Zo)||g.stop(),null==(m=this.featureFlags)||m.reset(),null==(y=this.conversations)||y.reset(),null==(b=this.logs)||b.reset(),null==(w=this.metrics)||w.reset(),null==(x=this.persistence)||x.set_property(Rr,Hr),null==(S=this.sessionManager)||S.resetSessionId(),this.Ro=null,this.config.cookieless_mode===qr)this.register_once({distinct_id:Dr,$device_id:null},"");else{var R=this.config.get_device_id(_s());this.register_once({distinct_id:R,$device_id:t?R:a},""),t||it(l)||this.register({[Bi]:l})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(void 0===i.distinctID||this.bo()||(null==(P=this.persistence)||P.set_property(Rr,i.isIdentifiedID?Vr:Hr),this.register({distinct_id:i.distinctID})),null==(k=this.featureFlags)||k.initialize(),!(it(o)||null!=(T=this.sessionManager)&&T.setBootstrapSessionId(o,!0))){var O=_({},i);delete O.sessionID,this.config.bootstrap=O}delete this.config.identity_distinct_id,delete this.config.identity_hash,v=!0}finally{var C;d&&(null==(C=this.persistence)||null==C.Ps||C.Ps(v))}this.reloadFeatureFlags()}shutdown(t){var e=this;return p((function*(){var t,i,r,s,n,o,a;if(e.__loaded){null==(t=e.Zo)||t.stop(),null==(i=e.Wo)||i.dispose(),null==(r=e.sessionRecording)||r.dispose(),null==(s=e.logs)||s.flushLogs("sendBeacon"),null==(n=e.metrics)||n.flush("sendBeacon"),null==(o=e.Oo)||o.unload(),null==(a=e.$o)||a.unload();try{var l;null==(l=e.featureFlags)||l.destroy()}catch(t){Ci.error("Error while destroying feature flags",t)}}else Ci.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,e){var i;this.config.identity_distinct_id=t,this.config.identity_hash=e,this.alias(t),null==(i=this.conversations)||i.sl()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.al()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,e;return null!==(t=null==(e=this.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var e=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=e.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+e.sessionId);if(null!=t&&t.withTimestamp&&i){var s,n=null!==(s=t.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(t,e){return t===this.get_property(Ui)?(Ci.critical("Attempting to create alias for existing People user - aborting."),-2):this.el("posthog.alias")?(it(e)&&(e=this.get_distinct_id()),t!==e?(this.il(zi,t),this.capture("$create_alias",{alias:t,distinct_id:e})):(Ci.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var e=_({},this.config);if(tt(t)){var i,r,s,n,o,a,l,u,h,d,v,f;es(this.config,El(t));var p=this.wo();null==(i=this.persistence)||i.update_config(this.config,e,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new po(_({},this.config,{persistence:"sessionStorage"}),p,!1);var g=this.Po(this.config.debug);ut(g)&&(this.config.debug=g),ut(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,xs.Nr()&&xs.Dr("ph_debug",!0),Ci.info("set_config",{config:t,oldConfig:e,newConfig:_({},this.config)})):(c.DEBUG=!1,xs.Nr()&&xs.qr("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this.Xs()),null==(s=this.exceptionObserver)||s.onConfigChange(),null==(n=this.exceptions)||n.onConfigChange(),null==(o=this.sessionRecording)||o.startIfEnabledOrStop(),null==(a=this.tracingHeaders)||a.startIfEnabledOrStop(),null==(l=this.autocapture)||l.startIfEnabled(),null==(u=this.heatmaps)||u.startIfEnabled(),null==(h=this.exceptionObserver)||h.startIfEnabledOrStop(),null==(d=this.deadClicksAutocapture)||d.startIfEnabledOrStop(),null==(v=this.surveys)||v.loadIfEnabled(),this.ko(),null==(f=this.externalIntegrations)||f.startIfEnabledOrStop()}}_overrideSDKInfo(t,e){c.LIB_NAME=t,c.LIB_VERSION=e}startSessionRecording(t){var e,i,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(e=this.sessionManager)||e.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,e){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(_({},r,e))}}addExceptionStep(t,e){var i;null==(i=this.exceptions)||i.addExceptionStep(t,e)}captureLog(t){var e;null==(e=this.logs)||e.captureLog(t)}get logger(){var t,e;return null!==(t=null==(e=this.logs)?void 0:e.logger)&&void 0!==t?t:$l.ol}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var e,i;return null!==(e=null==(i=this.toolbar)?void 0:i.loadToolbar(t))&&void 0!==e&&e}get_property(t){var e;return null==(e=this.persistence)?void 0:e.props[t]}getSessionProperty(t){var e;return null==(e=this.sessionPersistence)?void 0:e.props[t]}toString(){var t,e=null!==(t=this.config.name)&&void 0!==t?t:bl;return e!==bl&&(e=bl+"."+e),e}_isIdentified(){var t,e;return(null==(t=this.persistence)?void 0:t.get_property(Rr))===Vr||(null==(e=this.sessionPersistence)?void 0:e.get_property(Rr))===Vr}tl(){var t,e;return!("never"===this.config.person_profiles||this.config.person_profiles===Wr&&!this._isIdentified()&&et(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[zi])&&(null==(e=this.persistence)||null==(e=e.props)||!e[Mr]))}Qo(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.tl()||this.el("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.el("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}el(t){return"never"===this.config.person_profiles?(Ci.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.il(Mr,!0),!0)}wo(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==zr)}ko(){var t,e,i,r,s=this.wo();return(null==(t=this.persistence)?void 0:t.xs)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(e=this.sessionPersistence)?void 0:e.xs)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s&&(this.xo.clear(),this.Xo()),s}opt_in_capturing(t){var e;if(this.config.cookieless_mode!==qr){if(this.bo()){var i,r,s,n,o;this.nl(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new ja(this),this.pageViewManager=new Dn(this),this.persistence&&(this.sessionPropsManager=new Da(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=$l.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.yo(this.sessionRecording,new l(this)),this.vo&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.vo)))}var u,h;this.consent.optInOut(!0),this.ko(),this.Vo(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),this.config.cookieless_mode==zr&&(null==(u=this.surveys)||u.loadIfEnabled()),(it(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(h=null==t?void 0:t.captureEventName)&&void 0!==h?h:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Go()}else Ci.warn(pl)}opt_out_capturing(){var t,e,i;this.config.cookieless_mode!==qr?(this.config.cookieless_mode===zr&&this.consent.isOptedIn()&&this.nl(!0,!0),this.consent.optInOut(!1),this.ko(),this.config.cookieless_mode===zr&&(this.register({distinct_id:Dr,$device_id:null}),null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Go(),this.Vo())):Ci.warn(pl)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===qr||(this.config.cookieless_mode===zr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.ko()}_is_bot(){return i?Ba(i,this.config.custom_blocked_useragents):void 0}Go(){r&&("visible"===r.visibilityState?this.Mo||(this.Mo=!0,this.capture(Jr,{title:r.title},{send_instantly:!0}),this.Eo&&(r.removeEventListener(Gr,this.Eo),this.Eo=null)):this.Eo||(this.Eo=this.Go.bind(this),ls(r,Gr,this.Eo)))}debug(e){!1===e?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}Xs(){var t=this.Ao||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ci.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,e,i,r,s){var n=e in t&&!ot(t[e]),o=i in t&&!ot(t[i]);return n?t[e]:!!o&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+e+"' instead. The old field will be removed in a future major version."),t[i])}(t,"advanced_disable_flags","advanced_disable_decide",0,Ci)}_n(t){var e;if(ot(this.config.before_send))return t;var i=Object.keys(null!==(e=t.properties)&&void 0!==e?e:{}).filter(vt),r=X(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r)try{if(s=n(s),ot(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return dt(t.event)?Ci.warn(o+". This can cause unexpected behavior."):Ci.info(o),null}s.properties&&!et(s.properties)||Ci.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(e){return Ci.error("Error in beforeSend function for event '"+t.event+"':",e),null}for(var a of i)if(s.properties&&ot(s.properties[a]))return Ci.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.rs)?void 0:t.pageViewId}captureTraceFeedback(t,e){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:e})}captureTraceMetric(t,e,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:e,$ai_metric_value:String(i)})}Po(t){var e=ut(t)&&!t,i=xs.Nr()&&"true"===xs.Pr("ph_debug");return!e&&(!!i||t)}}$l.__defaultExtensionClasses={},$l.ol=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=ss(t.prototype[e[i]])}($l,["identify"]);class Tl{constructor(t){this.disabled=!1===t;var e=tt(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var Pl="$copy_autocapture",Rl=Ii("[AutoCapture]");function Ol(t,e){return e.length>t?e.slice(0,t)+"...":e}function Cl(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!Hs(e));return e}function Il(e,i){var r,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!Hs(e))return{props:{}};for(var d=[e],v=new Set([e]),c=e;c.parentNode&&!Vs(c,"body")&&Ks>d.length;)if(Gs(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!Hs(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,g,m=[],y={},b=!1,w=!1;if(ts(d,(t=>{var e=fn(t);if(Vs(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Sn(i))&&(h?Re(i):i)}V(Qs(t),"ph-no-capture")&&(w=!0),m.push(function(t,e,i,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};en.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ol(1024,En(t)):Ol(1024,Zs(t)));var a=Qs(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),ts(t.attributes,(function(i){var n;if((!pn(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Sn(i.value)&&(!rt(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=Js(a).join(" ")),o["attr__"+i.name]=Ol(1024,"href"===i.name&&s?Re(a):a)}}));for(var l=1,u=1,h=t;h=Cl(h);)l++,h.tagName===t.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(t,o,a,l,h));var r=function(t){if(!fn(t))return{};var e={};return ts(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&Sn(r)&&(e[i]=r)}})),e}(t);es(y,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=Vs(e,"a")||Vs(e,"button")?En(e):Zs(e)),b){var x,S;m[0].attr__href=b;var E=null==(x=zn(b))?void 0:x.host,k=null==t||null==(S=t.location)?void 0:S.host;E&&k&&E!==k&&(p=b)}return{props:es({$event_type:n.type,$ce_version:1},u?{}:{$elements:m},{$elements_chain:(g=m,function(t){return t.map((t=>{var e,i,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=_({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(i=t.nth_of_type)&&void 0!==i?i:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return is(n).sort(((t,e)=>t[0].localeCompare(e[0]))).forEach((t=>{var e=t[1];return o[$n(t[0].toString())]=$n(e.toString())})),(r+=":")+is(o).map((t=>t[0]+'="'+t[1]+'"')).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Tn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return is(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=m[0])&&r.$el_text?{$el_text:null==(s=m[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},y)}}var Al=Ii("[ExceptionAutocapture]"),Fl=()=>{},Ml=Ii("[TracingHeaders]"),Dl=Ii("[Web Vitals]"),Nl=9e5,Ul="disabled",Ll="lazy_loading",jl="awaiting_config",Bl="missing_config";Ii("[SessionRecording]"),Ii("[SessionRecording]");var zl="[SessionRecording]",ql=Ii(zl),Hl=Ii("[Heatmaps]");function Vl(t){return tt(t)&&"clientX"in t&&"clientY"in t&&at(t.clientX)&&at(t.clientY)}var Wl=Ii("[Product Tours]"),Gl=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Qi))},Kl=["$set_once","$set"],Jl=Ii("[SiteApps]"),Yl="Error while initializing PostHog app with config id ";function Ql(t,e,i){if(ot(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class Xl{constructor(t){this.ll=new Na,this.ul=(t,e)=>this.hl(t,e)&&this.dl(t,e)&&this.vl(t,e)&&this.cl(t,e),this.hl=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.fl=new Set,this.pl=new Set}init(){var t,e;it(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!it(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.pl)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.fl)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.fl.has(t)||this.fl.has(e.event))&&this.pl&&(null==(i=this.pl)?void 0:i.size)>0&&this.pl.forEach((t=>{this.gl(e,t)&&this.ll.emit("actionCaptured",t.name)}))}ml(t){this.onAction("actionCaptured",(e=>t(e)))}gl(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.ul(t,i))return!0;return!1}onAction(t,e){return this.ll.on(t,e)}dl(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ql(r,e.url,e.url_matching||"contains"))return!1}return!0}vl(t,e){return!!this.yl(t,e)&&!!this.bl(t,e)&&!!this._l(t,e)}yl(t,e){var i;if(null==e||!e.href)return!0;var r=this.wl(t);if(r.length>0)return r.some((t=>Ql(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Ql((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}bl(t,e){var i;if(null==e||!e.text)return!0;var r=this.wl(t);if(r.length>0)return r.some((t=>Ql(t.text,e.text,e.text_matching||"exact")||Ql(t.$el_text,e.text,e.text_matching||"exact")));var s,n,o,a=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!ot(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(a),n=e.text,o=e.text_matching||"exact",s.some((t=>Ql(t,n,o))))}_l(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}wl(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}cl(t,e){return null==e||!e.properties||0===e.properties.length||Ga(e.properties.reduce(((t,e)=>{var i=X(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class Zl{constructor(t){var e;this.kl=[],this._instance=t,this.Sl=new Map,this.xl=new Map,this.Cl=new Map,null==(e=this._instance)||null==e.onSessionId||e.onSessionId((t=>this.Tl(t)))}Ml(t){return!1}El(){return null}Il(t){}Rl(){}Pl(t,e){return!!t&&Ga(t.propertyFilters,null==e?void 0:e.properties)}Al(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}Fl(t,e,i){var r=(i===mo.Activation?this.Sl:this.xl).get(t),s=[];return this.Ol((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Pl(n,e)}))}register(t){var e;it(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Ll(t),this.$l(t))}$l(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.Dl&&(this.Dl=new Xl(this._instance),this.Dl.init(),this.Dl.ml((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Dl)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.Cl.get(e.name);i&&i.push(t.id),this.Cl.set(e.name,i||[t.id])}})))})))}Ll(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.Sl=this.Al(t,mo.Activation),this.xl=this.Al(t,mo.Cancellation))}onEvent(t,e){var i,r,s=this.Nl(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.ql(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.jl([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Bl(n),void this.Hl([n])}if(this.xl.has(t)){var a=this.Fl(t,e,mo.Cancellation);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.jl(a.map((t=>t.id))),a.forEach((t=>this.Ul(t.id))))}if(this.Sl.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.Sl.get(t)});var l=this.Fl(t,e,mo.Activation);this.zl(l.map((t=>t.id)))}}onAction(t){this.Cl.has(t)&&this.zl(this.Cl.get(t)||[])}zl(t){var e;if(0!==t.length){var i=!(null==(e=this._instance)||null==e.get_session_id||!e.get_session_id()),r=[];for(var s of t)i&&this.Ml(s)?this.Bl(s)&&this.Wl(s):r.push(s);r.length>0&&(this.kl=[...new Set([...this.kl,...r])]),this.Nl().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Bl(t){this.kl=this.kl.filter((e=>e!==t));var e=this.Vl();return!e.includes(t)&&(this.Gl([...e,t]),this.Zl(),!0)}jl(t){var e=new Set(t);this.kl=this.kl.filter((t=>!e.has(t)));var i=this.Ql(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&(this.Gl(r),0===r.length&&this.Jl()),this.Hl(t)}Kl(){var t,e=this.El();if(!e)return{};var i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e];return i&&"object"==typeof i?i:{}}Wl(t){if(this.El()){var e=this.Kl();this.Il(_({},e,{[t]:Date.now()}))}}Hl(t){if(this.El()){var e=this.Kl(),i={},r=!1;for(var s of Object.entries(e)){var n=s[0],o=s[1];t.includes(n)?r=!0:i[n]=o}r&&(et(i)?this.Rl():this.Il(i))}}Yl(){this.El()&&this.Rl()}getActivationTimestamp(t){if(this.Vl().includes(t)){var e=this.Kl()[t];return at(e)?e:void 0}}Ql(){var t,e=this.Xl();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}Vl(){var t,e,i=this.Ql();if(0===i.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.tu()],s=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();return s&&r===s?i:[]}Zl(){var t,e=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();e&&this.eu(e)}Jl(){this.iu()}Tl(t){var e,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this.tu()];if(i&&i!==t){var r=this.Ql(),s=this.Kl();r.length>0&&(this.Gl([]),r.filter((t=>at(s[t]))).forEach((t=>this.Ul(t)))),this.Jl(),this.Yl()}}getActivatedIds(){return[...new Set([...this.Vl(),...this.kl])].filter((t=>!this.ru(t)))}reset(){this.kl=[],this.Ql().length>0&&this.Gl([]),this.Jl(),this.Yl()}getEventToItemsMap(){return this.Sl}nu(){return this.Dl}}class tu extends Zl{constructor(t){super(t)}Xl(){return wr}tu(){return xr}El(){return Sr}Il(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[Sr]:t})}Rl(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Sr)}Ml(t){var e,i;this.Ol((e=>{i=e.find((e=>e.id===t))}));var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return at(r)&&r>0}su(){return $o.SHOWN}Ol(t){var e;null==(e=this._instance)||e.getSurveys(t)}Ul(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Nl(){return tl}Gl(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[wr]:t})}eu(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[xr]:t})}iu(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(xr)}ru(){return!1}ql(t,e){var i;this.Ol((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e;return Za(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(i);return r?t===$o.SHOWN?"consume":"ignore":t===$o.SHOWN?"persist":t===$o.DISMISSED||t===$o.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var eu="SDK is not enabled or survey functionality is not yet loaded",iu="Disabled. Not loading surveys.",ru=null!=t&&t.location?Vn(t.location.hash,"__posthog")||Vn(location.hash,"state"):null,su="_postHogToolbarParams",nu=Ii("[Toolbar]"),ou=Ii("[FeatureFlags]");class au{constructor(t,e){void 0===e&&(e=!1),this.au=!1,this.update(t,e)}update(t,e){this.ou=((t,e)=>{var i,r,s,n;return{bootstrap:{featureFlags:null==(i=t.bootstrap)?void 0:i.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:e,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?"none":"base64",evaluationContexts:null!==(s=null!==(n=t.evaluation_contexts)&&void 0!==n?n:t.evaluation_environments)&&void 0!==s?s:[],flagKeys:X(t.flag_keys)?t.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.au||(ou.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.au=!0),it(t.flag_keys)||X(t.flag_keys)||ou.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.ou}}var lu=Ii("[FeatureFlags]"),uu=Ii("[FeatureFlags]",{debugEnabled:!0}),hu="\" failed. Feature flags didn't load in time.",du="connection_error",vu=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},cu=t=>{var e={};for(var i of is(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},fu=Ii("[Error tracking]"),pu=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],_u="Refusing to render web experiment since the viewer is a likely bot",gu={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>qa(e,t),not_regex:(t,e)=>!qa(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class mu{get Di(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{mu.lu("retrieved web experiments from the server"),e.uu=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.uu&&(mu.lu("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.uu)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);rt(r)&&t.variants[r]&&e.hu(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];mu.du(n,e._instance)&&e.hu(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())mu.lu(_u);else if(!this.Di.disable_web_experiments){if(ot(this.uu))return this.uu=new Map,this.loadIfEnabled(),void this.previewWebExperiment();mu.lu("applying feature flags",t),t.forEach((t=>{var e;if(this.uu&&null!=(e=this.uu)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.uu)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.hu(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=mu.getWindowLocation();if(null!=t&&t.search){var e=qn(null==t?void 0:t.search,"__experiment_id"),i=qn(null==t?void 0:t.search,"__experiment_variant");e&&i&&(mu.lu("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.vu(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Di.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Di.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Di.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}vu(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(mu.lu("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.hu(r[0].name,e,r[0].variants[e].transforms))}static du(t,e){return!ot(t.conditions)&&mu.cu(t,e)&&mu.fu(t)}static cu(t,e){var i;if(ot(t.conditions)||ot(null==(i=t.conditions)?void 0:i.url))return!0;var r=mu.getWindowLocation();if(r){var s,n,o,a=Us(e,r.href);return null==(s=t.conditions)||!s.url||gu[null!==(n=null==(o=t.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,a)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static fu(t){var e;if(ot(t.conditions)||ot(null==(e=t.conditions)?void 0:e.utm))return!0;var i=Zn();if(i.utm_source){var r,s,n,o,a,l,u,h,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return d&&c&&f&&v}return!1}static lu(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];Ci.info("[WebExperiments] "+t,i)}hu(t,e,i){this._is_bot()?mu.lu(_u):"control"!==e?i.forEach((i=>{if(i.selector){var r;mu.lu("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):mu.lu("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?Ba(i,this.Di.custom_blocked_useragents):void 0}}var yu=Ii("[Conversations]"),bu="Conversations not available yet.",wu="console",xu="__posthogHandledLogsRequestError",Su=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[xu]=!0,i},Eu=t=>!!t&&"object"==typeof t&&!0===t[xu],ku={featureFlags:class{constructor(t){this.name="featureFlags",this.pu=!1,this.featureFlagEventHandlers=[],this.I=lu,this.gu={},this.mu={},this.yu=[],this.bu=!1,this._u=!1,this.wu=0,this.ku=!1,this.Su=!1,this.xu=!1,this.Cu=!1,this.Tu=0,this.Tt=()=>{var t=this.Mu();this.Tu=0,t&&this.reloadFeatureFlags()},"get"in t?this.Eu=t:(this.Iu=new au(t.config,t.Xs()),this.Eu=this.Iu)}updateConfig(t,e){var i;null==(i=this.Iu)||i.update(t,e)}setup(t){return this.Ru=t,this.I=t.logger.createLogger("[FeatureFlags]"),i=()=>{this.Ru===t&&(this.Ru=void 0,this.oo=t,this.Pu(t))},null!=(e=t.kv.initialize())&&e.then?e.then(i):i();var e,i}Pu(e){if(this.oo===e)return t&&ls(t,"online",this.Tt),this.Au=e.registerDynamicEventProperties((()=>this.Fu()?this.gu:this.mu)),this.Ou(),this.initialize()}destroy(){null==t||t.removeEventListener("online",this.Tt)}dispose(){var e;this.wu++,this.Su=!1,this.Ru=void 0,this.oo&&(this.Lu(),null==(e=this.Au)||e.dispose(),this.Au=void 0,this.yu=[],null==t||t.removeEventListener("online",this.Tt),this.oo=void 0)}get Di(){return this.Eu.get()}$u(t){var e;return null==(e=this.oo)?void 0:e.kv.get(t)}Dr(t){this.Du((()=>{var e;return null==(e=this.oo)?void 0:e.kv.set(t)}))}qr(t){this.Du((()=>{var e;return null==(e=this.oo)?void 0:e.kv.remove(t)}))}Du(t){try{t()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}Ou(){var t={};for(var e of[lr,dr,vr,fr]){var i=this.$u(e);it(i)||(t[e]=i)}this.gu=t;var r=_({},t),s=this.$u(ar);if(s)for(var n of Object.entries(s))r["$feature/"+n[0]]=n[1];this.mu=r}Fu(){var t=this.Di.cacheTtlMs;if(!t||0>=t)return!1;var e=this.$u(Pr);return"number"!=typeof e||Date.now()-e>t}Nu(){return!!this.Fu()&&(this.Cu||this._u||(this.Cu=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}qu(){var t=this.Di.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}ju(){var t=this.Di.flagKeys;if(!it(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),e}))}initialize(){var t,e,i=this.Di,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(o).filter((t=>a[t])).reduce(((t,e)=>(t[e]=o[e],t)),{});return this.Bu({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var r,s,n=null!=i&&i.merge&&null!==(r=this.$u(ar))&&void 0!==r?r:{},o=null!=i&&i.merge&&null!==(s=this.$u(dr))&&void 0!==s?s:{},a=_({},n,t),l=_({},o,e),u={};for(var h of Object.entries(a)){var d=h[0],v=h[1];u[d]={key:d,enabled:y(v),variant:b(v),reason:void 0,metadata:it(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Bu({flags:u})}get hasLoadedFlags(){return this.bu}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.$u(hr),e=this.$u(fr),i=this.$u(pr);if(!i&&!e)return t||{};var r=es({},t||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of s){var o,a,l=r[n],u=null==e?void 0:e[n],h=it(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=it(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==i?void 0:i[n],c=_({},l,{enabled:h,variant:h?null!=d?d:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=_({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=c}return this.pu||(this.I.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:r}),this.pu=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((i=>{var r=t[i];return{key:i,enabled:y(r),variant:b(r),payload:m(e[i])}}))}getFlagVariants(){var t=this.$u(ar),e=this.$u(fr);if(!e)return t||{};for(var i=es({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.pu||(this.I.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.pu=!0),i}getFlagPayloads(){var t=this.$u(dr),e=this.$u(pr);if(!e)return t||{};for(var i=es({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.pu||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.pu=!0),i}reloadFeatureFlags(){this.ku||this.Di.featureFlagsDisabled||this.Mu()||this.Hu||(this.yu.slice().forEach((t=>{try{t()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}})),this.Hu=setTimeout((()=>{this.Uu()}),5))}Lu(){clearTimeout(this.Hu),this.Hu=void 0}onReloading(t){return this.yu.push(t),()=>{this.yu=this.yu.filter((e=>e!==t))}}ensureFlagsLoaded(){this.bu||this._u||this.Hu||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ku=t}resetFlagCallReported(){this.qr(kr)}Uu(t){this.Lu();var e=this.oo;if(e&&!this.Di.remoteRequestsDisabled&&!this.Mu())if(this._u)this.Su=!0;else{var i={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:_({},e.initialPersonProperties,this.$u(_r)||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.$u(gr),timezone:ao()};it(e.deviceId)||(i.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.Di.featureFlagsDisabled)&&(i.disable_flags=!0);var r=this.qu();r.length&&(i.evaluation_contexts=r);var s=this.ju();it(s)||(i.flag_keys=s);var n=this.Di.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.wu;this._u=!0;var l=()=>{this.Su&&(this.Su=!1,this.Uu())},u=t=>{this._u=!1,a===this.wu?(this.Dr({[Tr]:[du]}),this.I.error("Feature flag request failed",t),l()):l()};try{e.sendRequest(o,{target:"flags",method:"POST",body:i,compression:"base64"===this.Di.compression?go.Base64:void 0,sentAt:"body",timeoutMs:this.Di.requestTimeoutMs}).then((t=>{var e,r,s=null!==(e=t.json)&&void 0!==e?e:{},o=200!==t.statusCode;if(this._u=!1,a===this.wu){if(this.zu(t.statusCode),o||this.Su||(this.$anon_distinct_id=void 0),!i.disable_flags||this.Su){this.xu=!o;var u=[];t.error?u.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?du:"unknown_error"):200!==t.statusCode&&u.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&u.push("errors_while_computing_flags");var h=!(null==(r=s.quotaLimited)||!r.includes("feature_flags"));h&&u.push("quota_limited"),this.Dr({[Tr]:u}),h?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."):i.disable_flags||this.Bu(s,o,{partialResponse:n}),l()}}else l()})).catch(u)}catch(t){u(t)}}}Mu(){return Wn(this.Tu,3)}zu(t){this.Tu=Gn(t,this.Tu,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(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.xu)if(this.bu||this.getFlags()&&this.getFlags().length>0){if(!this.Nu()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+t+hu)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.xu)if(this.bu||this.getFlags()&&this.getFlags().length>0){if(!this.Nu()){var i,r=this.getFlagVariants(),s=t in r,n=r[t],o=this.getFlagPayloads()[t],a=String(n),l=this.$u(vr)||void 0,u=this.$u(Pr)||void 0,h=this.$u(kr)||{};if(this.Di.deduplicateCallsPerSession){var d,v=null==(d=this.oo)?void 0:d.session.sessionId,c=this.$u($r);v&&v!==c&&(h={},i=v)}if(e.send_event||!("send_event"in e))if(t in h&&h[t].includes(a))i&&this.Dr({[kr]:h,[$r]:i});else{var f,p,g,y,b,w,x,S,E,k,T,P;X(h[t])?h[t].push(a):h[t]=[a],this.Dr(_({[kr]:h},i?{[$r]:i}:{}));var R=this.getFeatureFlagDetails(t),O=[...null!==(f=this.$u(Tr))&&void 0!==f?f:[]];it(n)&&O.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:null!==(p=null==(g=this.Di.bootstrap)||null==(g=g.featureFlags)?void 0:g[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(y=null==(b=this.Di.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.xu};it(null==R||null==(w=R.metadata)?void 0:w.has_experiment)||(C.$feature_flag_has_experiment=R.metadata.has_experiment),it(null==R||null==(x=R.metadata)?void 0:x.version)||(C.$feature_flag_version=R.metadata.version);var I,A=null!==(S=null==R||null==(E=R.reason)?void 0:E.description)&&void 0!==S?S:null==R||null==(k=R.reason)?void 0:k.code;A&&(C.$feature_flag_reason=A),null!=R&&null!=(T=R.metadata)&&T.id&&(C.$feature_flag_id=R.metadata.id),it(null==R?void 0:R.original_variant)&&it(null==R?void 0:R.original_enabled)||(C.$feature_flag_original_response=it(R.original_variant)?R.original_enabled:R.original_variant),null!=R&&null!=(P=R.metadata)&&P.original_payload&&(C.$feature_flag_original_payload=null==R||null==(I=R.metadata)?void 0:I.original_payload),O.length&&(C.$feature_flag_error=O.join(",")),this.Wu(C)}else i&&this.Dr({[kr]:h,[$r]:i});if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:m(o)}}}else this.I.warn('getFeatureFlagResult for key "'+t+hu)}Wu(t){try{var e;null==(e=this.oo)||e.capture("$feature_flag_called",t).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(t,e){this.Vu(t,e)}Vu(t,e){var i=this;return p((function*(){var r=i.oo;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=i.qu();n.length&&(s.evaluation_contexts=n);var o,a=i.ju();it(a)||(s.flag_keys=a);try{var l,u=null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:"base64"===i.Di.compression?go.Base64:void 0,sentAt:"body",timeoutMs:i.Di.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;o=(null==u?void 0:u[t])||void 0}catch(t){return void i.I.error("Remote config feature flag request failed",t)}try{e(o)}catch(t){i.I.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.xu)return e.defaultValue;if(!(this.bu||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+t+hu),e.defaultValue;var i=this.getFeatureFlag(t,e);return it(i)?e.defaultValue:!!i}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){this.Bu(t,e,i)}Bu(t,e,i){if(this.oo){this.bu=!0;var r=function(t,e,i,r,s,n){void 0===e&&(e={}),void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n=lu);var o=((t,e)=>{var i=t.flags;return i?_({},t,{featureFlags:Object.fromEntries(Object.keys(i).map((t=>{var e;return[t,null!==(e=i[t].variant)&&void 0!==e?e:i[t].enabled]}))),featureFlagPayloads:Object.fromEntries(Object.keys(i).filter((t=>i[t].enabled)).filter((t=>{var e;return null==(e=i[t].metadata)?void 0:e.payload})).map((t=>{var e;return[t,null==(e=i[t].metadata)?void 0:e.payload]})))}):(t.featureFlags&&e.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,n),a=o.flags,l=o.featureFlags,u=o.featureFlagPayloads;if(l){var h=t.requestId,d=t.evaluatedAt;if(X(l)){n.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var v={};if(l)for(var c=0;l.length>c;c++)v[l[c]]=!0;return{[lr]:l,[ar]:v,[cr]:!1}}var f=l,p=u,g=a;if(null!=s&&s.partialResponse)f=_({},e,f),p=_({},i,p),g=_({},r,g);else if(t.errorsWhileComputingFlags)if(a){var m=new Set(Object.keys(a).filter((t=>{var e;return!(null!=(e=a[t])&&e.failed)})));f=_({},e,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=_({},i,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),g=_({},r,Object.fromEntries(Object.entries(g||{}).filter((t=>m.has(t[0])))))}else f=_({},e,f),p=_({},i,p),g=_({},r,g);return _({[lr]:Object.keys(cu(f)),[ar]:f||{},[dr]:p||{},[hr]:g||{},[cr]:!0===t.minimalFlagCalledEvents},h?{[vr]:h}:{},d?{[Pr]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this.I);r&&this.Dr(r),e||(this.Cu=!1),this.Gu(e)}}override(t,e){void 0===e&&(e=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.Zu(t)}Zu(t){if(this.oo){if(!1===t)return this.qr([fr,pr]),this.Gu(),void uu.info("All overrides cleared");if(X(t))return this.Dr({[fr]:vu(t)}),this.Gu(),void uu.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.pu=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},s=i.flags,n=i.payloads;return s&&(r[fr]=X(s)?vu(s):s),n&&(r[pr]=n),Object.keys(r).length&&this.Dr(r),!1===s&&!1===n?this.qr([fr,pr]):!1===s?this.qr(fr):!1===n&&this.qr(pr),this.Gu(),!1===s?uu.info("Flag overrides cleared"):s&&uu.info("Flag overrides set",{flags:s}),void(!1===n?uu.info("Payload overrides cleared"):n&&uu.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Dr({[fr]:t}),this.Gu(),void uu.info("Flag overrides set",{flags:t});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.bu){var e=this.Qu(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.I.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var r=(this.$u(ur)||[]).find((e=>e.flagKey===t)),s={["$feature_enrollment/"+t]:e},n={$feature_flag:t,$feature_enrollment:e,$set:s};r&&(n.$early_access_feature_name=r.name),i&&(n.$feature_enrollment_stage=i);var o=_({},this.getFlagVariants(),{[t]:e});this.Dr({[lr]:Object.keys(cu(o)),[ar]:o,[_r]:_({},this.$u(_r)||{},s)}),this.Gu();try{var a;null==(a=this.oo)||a.capture("$feature_enrollment_update",n).catch((t=>{this.I.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.I.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.$u(ur);!r||e?this.Ju(t,i):t(r)}Ju(t,e){var i=this;return p((function*(){var r=i.oo;if(r){var s,n=e?"&"+e.map((t=>"stage="+t)).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;i.Dr({[ur]:s=o.json.earlyAccessFeatures})}catch(t){return void i.I.error("Early access feature request failed",t)}try{t(s)}catch(t){i.I.error("Early access feature callback failed",t)}}}))()}Qu(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}Gu(t){this.Ou();var e=this.Qu(),i=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.I.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Ku(t,e)}Ku(t,e){void 0===e&&(e=!0);var i=this.$u(_r)||{},r=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,n={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in i||(n[o]=s[o]));this.Dr({[_r]:_({},i,n,r)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=_({},this.$u(_r)||{});t.forEach((t=>{delete i[t]})),this.Dr({[_r]:i}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.qr(_r),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.$u(gr)||{},r=_({},i);for(var s of Object.keys(t))r[s]=_({},i[s],t[s]);this.Dr({[gr]:r}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.$u(gr)||{};this.Dr({[gr]:_({},e,{[t]:{}})})}else this.qr(gr)}reset(){this.wu++,this.Su=!1,this.gu={},this.mu={},this.bu=!1,this.ku=!1,this.xu=!1,this.$anon_distinct_id=void 0,this.Lu(),this.pu=!1,this.Tu=0}}},$u={sessionRecording:class{get Di(){return this._instance.config}get Ta(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Yu)||!t.isStarted)}get status(){var t,e;return this.Xu===jl||this.Xu===Bl?this.Xu:null!==(t=null==(e=this.Yu)?void 0:e.status)&&void 0!==t?t:this.Xu}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Xu=Ul,this.th=void 0,this.eh=!1,this.kt=(()=>{var e;if(null==r||!r.visibilityState||"visible"===r.visibilityState)return!0;var i=null==t||null==(e=t.performance)||null==e.getEntriesByType?void 0:e.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some((t=>"visible"===t.name))})(),this.It=()=>{var t;"visible"===(null==r?void 0:r.visibilityState)&&(this.kt=!0,null==(t=this.Yu)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw ql.error("started without valid sessionManager"),new Error(zl+" started without valid sessionManager. This is a bug.");if(this.Di.cookieless_mode===qr)throw new Error(zl+' cannot be used with cookieless_mode="always"');null!=r&&r.addEventListener&&ls(r,"visibilitychange",this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.eh=!0,null==r||null==r.removeEventListener||r.removeEventListener("visibilitychange",this.It),this.stopRecording()}get ih(){var e,i=!(null==(e=this._instance.get_property(Zi))||!e.enabled),r=!this.Di.disable_session_recording,s=this.Di.disable_session_recording||this._instance.consent.isOptedOut();return t&&i&&r&&!s}startIfEnabledOrStop(t){var e;if(!(this.eh||this.ih&&null!=(e=this.Yu)&&e.isStarted)){var i=!it(Object.assign)&&!it(Array.from);this.ih&&i?(this.rh(t),ql.info("starting")):(this.Xu=Ul,this.stopRecording())}}rh(t){var e,i,r;this.ih&&(this.Xu!==jl&&this.Xu!==Bl&&(this.Xu=Ll),null!=v&&null!=(e=v.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this.nh(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.sh,(e=>{if(e)return this._instance.register_for_session({[jr]:!0}),ql.error("could not load recorder",e);this.nh(t)})))}stopRecording(){var t,e;null==(t=this.th)||t.call(this),this.th=void 0,null==(e=this.Yu)||e.stop()}ah(){var t,e;null==(t=this.th)||t.call(this),this.th=void 0,null==(e=this.Yu)||e.discard()}oh(){var t,e;null==(t=this.Ta)||t.unregister(or),null==(e=this.Ta)||e.unregister(tr)}lh(t,e){if(ot(t))return null;var i,r=at(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(ql.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}uh(t){if(this.Ta){var e,i,r=this.Ta,s=()=>{var e,i=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.lh(null==(e=this.Di.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),n=this.lh(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:n;ot(o)&&this.oh();var a=null==i?void 0:i.minimumDurationMilliseconds;r.register({[Zi]:_({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:_({capturePerformance:t.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:it(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};s(),null==(e=this.th)||e.call(this),this.th=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?!1===e.sessionRecording?(this.uh(e),void this.ah()):(this.uh(e),void this.startIfEnabledOrStop()):(this.Xu===jl&&(this.Xu=Bl,ql.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Yu)&&i.log?this.Yu.log(t,e):ql.warn("log called before recorder was ready")}get sh(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Zi);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}hh(){var t,e=this._instance.get_property(Zi);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return ql.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!ot(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}nh(t){var e,i,r;if(!this.eh){if(null==(e=v.__PosthogExtensions__)||!e.initSessionRecording)return ql.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[jr]:!0});var s;if(this.Yu||(this.Yu=null==(s=v.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.kt),this.Yu._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.hh()){if(this.Xu===Bl||this.Xu===jl)return;return this.Xu=jl,ql.info("persisted remote config is stale, requesting fresh config before starting"),void new Mo(this._instance).load()}this.Xu=Ll,null==(i=(r=this.Yu).setDocumentWasEverVisible)||i.call(r,this.kt),this.Yu.start(t)}}onRRwebEmit(t){var e;null==(e=this.Yu)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Yu||null==(e=this.Ta)||e.register({[ir]:!0}),null==(t=this.Yu)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Yu||null==(e=this.Ta)||e.register({[er]:!0}),null==(t=this.Yu)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Yu||null==(i=this.Ta)||i.register({["url"===t?rr:sr]:!0}),null==(e=this.Yu)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Yu)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Yu)||!i.tryAddCustomEvent(t,e))}}},Tu={autocapture:class{constructor(t){this.dh=!1,this.fh=null,this.ph=!1,this.gh=!1,this.instance=t,this.rageclicks=new Tl(t.config.rageclick),this.mh=null}initialize(){this.startIfEnabled()}get Di(){var t,e,i=tt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}yh(){if(this.isBrowserSupported()){if(t&&r){var e=e=>{e=e||(null==t?void 0:t.event);try{this.bh(e)}catch(t){Rl.error("Failed to capture event",t)}};if(ls(r,"submit",e,{capture:!0}),ls(r,"change",e,{capture:!0}),ls(r,"click",e,{capture:!0}),this.Di.capture_copied_text){var i=e=>{e=e||(null==t?void 0:t.event);try{this.bh(e,Pl)}catch(t){Rl.error("Failed to capture copy/cut event",t)}};ls(r,"copy",i,{capture:!0}),ls(r,"cut",i,{capture:!0})}}}else Rl.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.dh&&(this.yh(),this.dh=!0)}onRemoteConfig(t){if(this.ph=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.gh=e.elementsChainAsString);var i=e.autocapture_opt_out;ut(i)&&(this.instance.persistence&&this.instance.persistence.register({[Hi]:i}),this.fh=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.mh=t}getElementSelectors(t){var e,i=[];return null==(e=this.mh)||e.forEach((e=>{var s=null==r?void 0:r.querySelectorAll(e);null==s||s.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Hi],r=this.fh,s=this.instance.Xs()&&!this.ph;if(nt(r)&&!ut(i)&&!s)return!1;var n=null!==(e=this.fh)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!n}bh(e,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r,s=tn(e);Ws(s)&&(s=s.parentNode||null),"$autocapture"===i&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&dn(s,this.instance.config.rageclick)&&this.bh(e,"$rageclick");var n=i===Pl;if(s&&function(e,i,r,s,n,o){var a;if(!t||vn(e))return!1;if(null!=r&&r.url_allowlist&&!Ys(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&Ys(r.url_ignorelist,o))return!1;if(null!=r&&r.dom_event_allowlist){var l=r.dom_event_allowlist;if(l&&!l.some((t=>i.type===t)))return!1}var u=cn(e,s),h=u.parentIsUsefulElement,d=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(it(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(d,r))return!1;if(!rn(d,null==r?void 0:r.css_selector_allowlist))return!1;if(rn(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:nn))return!1;try{var v=t.getComputedStyle(e);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return h?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(en.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this.Di,n,n?["copy","cut"]:void 0,this.instance)){var o=Il(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Di.element_attribute_ignorelist,elementsChainAsString:this.gh,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=o.props;if(o.explicitNoCapture)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(a.$element_selectors=l),i===Pl){var u,h=Xs(null==t||null==(u=t.getSelection())?void 0:u.toString()),d=e.type||"clipboard";if(!h)return!1;a.$selected_content=h,a.$copy_type=d}return this.instance.capture(i,a),!0}}}isBrowserSupported(){return Z(null==r?void 0:r.querySelectorAll)}},historyAutocapture:class{constructor(e){var i;this._instance=e,this._h=(null==t||null==(i=t.location)?void 0:i.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ci.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.wh&&this.wh(),this.wh=void 0,Ci.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.kh("pushState"),this.kh("replaceState"),this.Sh())}kh(e){var i;if(t&&(null==(i=t.history[e])||!i.__posthog_wrapped__)){var r=this;!function(t,e,i){try{if(!(e in t))return Fl;var r={next:t[e]},s=i((function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)}));return Z(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=s,()=>{if(t[e]!==s)for(var i=t[e];Z(i)&&i.__posthog_layer__;){var n=i.__posthog_layer__;if(n.next===s)return void(n.next=r.next);i=n.next}else t[e]=r.next}}catch(t){return Fl}}(t.history,e,(t=>function(i,s,n){t.call(this,i,s,n),r.xh(e)}))}}xh(e){try{var i,r=null==t||null==(i=t.location)?void 0:i.pathname;if(!r)return;r!==this._h&&this.isEnabled&&this._instance.capture(Jr,{navigation_type:e}),this._h=r}catch(t){Ci.error("Error capturing "+e+" pageview",t)}}Sh(){if(!this.wh){var e=()=>{this.xh("popstate")};ls(t,"popstate",e),this.wh=()=>{t&&t.removeEventListener("popstate",e)}}}},heatmaps:class{get Di(){return this.instance.config}constructor(t){var e;this.Ch=!1,this.dh=!1,this.Th=null,this.instance=t,this.Ch=!(null==(e=this.instance.persistence)||!e.props[Vi]),this.rageclicks=new Tl(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return tt(this.Di.capture_heatmaps)&&this.Di.capture_heatmaps.flush_interval_milliseconds&&(t=this.Di.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return ot(this.Di.capture_heatmaps)?ot(this.Di.enable_heatmaps)?this.Ch:this.Di.enable_heatmaps:!1!==this.Di.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.dh)return;Hl.info("starting..."),this.Mh(),this.It()}else{var t;clearInterval(null!==(t=this.Th)&&void 0!==t?t:void 0),this.Eh(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Vi]:i}),this.Ch=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.ft;return this.ft=void 0,t}Ih(t){Vl(t.originalEvent)&&this.bi(t.originalEvent,"deadclick")}It(){this.Th&&clearInterval(this.Th),this.Th="visible"===(null==r?void 0:r.visibilityState)?setInterval(this.ga.bind(this),this.flushIntervalMilliseconds):null}Mh(){t&&r&&(this.Rh=this.ga.bind(this),ls(t,Kr,this.Rh),this.Ph=e=>this.bi(e||(null==t?void 0:t.event)),ls(r,"click",this.Ph,{capture:!0}),this.Ah=e=>this.Fh(e||(null==t?void 0:t.event)),ls(r,"mousemove",this.Ah,{capture:!0}),this.Oh=new Cn(this.instance,Rn,this.Ih.bind(this)),this.Oh.startIfEnabledOrStop(),this.Lh=this.It.bind(this),ls(r,Gr,this.Lh),this.dh=!0)}Eh(){var e;t&&r&&(this.Rh&&t.removeEventListener(Kr,this.Rh),this.Ph&&r.removeEventListener("click",this.Ph,{capture:!0}),this.Ah&&r.removeEventListener("mousemove",this.Ah,{capture:!0}),this.Lh&&r.removeEventListener(Gr,this.Lh),clearTimeout(this.$h),null==(e=this.Oh)||e.stop(),this.dh=!1)}Dh(e,i){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,i,r){for(var s=e;s&&Hs(s)&&!Vs(s,"body");){if(s===r)return!1;var n=void 0;try{var o,a,l;n=null==(o=null!==(a=null==(l=s.ownerDocument)?void 0:l.defaultView)&&void 0!==a?a:t)?void 0:o.getComputedStyle(s).position}catch(t){return!1}if(V(i,n))return!0;s=sn(s)}return!1}(tn(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:r),target_fixed:o,type:i}}bi(t,e){var i;if(void 0===e&&(e="click"),!qs(t.target)&&Vl(t)){var r=this.Dh(t,e);null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&dn(tn(t),this.instance.config.rageclick)&&this.$n(_({},r,{type:"rageclick"})),this.$n(r)}}Fh(t){!qs(t.target)&&Vl(t)&&(clearTimeout(this.$h),this.$h=setTimeout((()=>{this.$n(this.Dh(t,"mousemove"))}),500))}$n(e){if(t){var i=this.Di.disable_capture_url_hashes?Re(t.location.href):t.location.href,r=this.Di.custom_personal_data_properties,s=this.Di.mask_personal_data_properties?[...Jn,...r||[]]:[],n=Hn(i,s,Qn);this.ft=this.ft||{},this.ft[n]||(this.ft[n]=[]),this.ft[n].push(e)}}ga(){this.ft&&!et(this.ft)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Cn,webVitalsAutocapture:class{constructor(t){var e;this.Ch=!1,this.dh=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Nh=()=>{clearTimeout(this.qh),this.qh=void 0,0!==this.ft.metrics.length&&(this._instance.capture("$web_vitals",_({$current_url:this.ft.url},this.ft.metrics.reduce(((t,e)=>_({},t,{["$web_vitals_"+e.name+"_event"]:_({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.jh=t=>{var e;if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},ot(null==t?void 0:t.name)||ot(null==t?void 0:t.value))Dl.error("Invalid metric received",t);else{var i="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.Bh(i);if(!it(r)){var s=at(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.Hh||this.Hh>t.value){this.ft.navigationKey!==s&&(this.Nh(),this.qh=setTimeout(this.Nh,this.flushToCaptureTimeoutMs)),it(this.ft.navigationKey)&&(this.ft.navigationKey=s,this.ft.url=r),this.ft.firstMetricTimestamp=it(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var n=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=_({},t,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});it(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.ft.metrics.push(o),this.ft.metrics.length===this.allowedMetrics.length&&this.Nh()}else Dl.error("Ignoring metric with value >= "+this.Hh,t)}}},this.Uh=()=>{if(!this.dh){var t,e,i,r,s=v.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this.zh])||("web-vitals"===this.zh&&it(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(it(o)||(t=o.onLCP,e=o.onCLS,i=o.onFCP,r=o.onINP),t&&e&&i&&r){var a={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.jh.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&e(this.jh.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this.jh.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this.jh.bind(this),a),this.dh=!0}else Dl.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Ch=!(null==(e=this._instance.persistence)||!e.props[Ji]),this.startIfEnabled()}get Wh(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=tt(this.Wh)?null==(t=this.Wh)?void 0:t.web_vitals_allowed_metrics:void 0;return ot(i)?(null==(e=this._instance.persistence)?void 0:e.props[Xi])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(tt(this.Wh)?this.Wh.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=tt(this.Wh)?this.Wh.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=tt(this.Wh)?this.Wh.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Hh(){var t=tt(this.Wh)&&at(this.Wh.__web_vitals_max_value)?this.Wh.__web_vitals_max_value:Nl;return t>0&&6e4>=t?Nl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return Dl.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=tt(this.Wh)?this.Wh.web_vitals:ut(this.Wh)?this.Wh:void 0;return ut(e)?e:this.Ch}startIfEnabled(){this.isEnabled&&!this.dh&&(Dl.info("enabled, starting..."),this.Xn(this.Uh))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=tt(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=tt(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ji]:i}),this._instance.persistence.register({[Xi]:r})),this.Ch=i,this.startIfEnabled()}}}get zh(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Xn(t){var e=v.__PosthogExtensions__,i=this.zh,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&it(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,(e=>{e?Dl.error("failed to load script",e):t()}))}Bh(e){var i=e||(null==t?void 0:t.location.href);if(i){var r=this._instance.config.disable_capture_url_hashes?Re(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Jn,...s||[]]:[];return Hn(r,n,Qn)}Dl.error("Could not determine current URL")}}},Pu={exceptionObserver:class{constructor(e){var i;this.Uh=()=>{var e;if(t&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var i=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Vh&&this.Di.capture_unhandled_errors&&(this.Vh=i(this.captureException.bind(this))),!this.Gh&&this.Di.capture_unhandled_rejections&&(this.Gh=r(this.captureException.bind(this))),!this.Zh&&this.Di.capture_console_errors&&(this.Zh=s(this.captureException.bind(this)))}catch(t){Al.error("failed to start",t),this.Qh()}}},this._instance=e,this.Jh=!(null==(i=this._instance.persistence)||!i.props[Wi]),this.oe=new xt(_({},function(t){var e,i,r,s;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:Al})),this.Di=this.Kh(),this.startIfEnabledOrStop()}Kh(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return tt(t)?e=_({},e,t):(it(t)?this.Jh:t)&&(e=_({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Di.capture_console_errors||this.Di.capture_unhandled_errors||this.Di.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Al.info("enabled"),this.Qh(),this.Xn(this.Uh)):this.Qh()}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return Al.error("failed to load script",e);t()}))}Qh(){var t,e,i;null==(t=this.Vh)||t.call(this),this.Vh=void 0,null==(e=this.Gh)||e.call(this),this.Gh=void 0,null==(i=this.Zh)||i.call(this),this.Zh=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Jh=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Wi]:this.Jh}),this.Di=this.Kh(),this.startIfEnabledOrStop())}}onConfigChange(){this.Di=this.Kh()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.oe.consumeRateLimit(s)?Al.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.Yh=[],this.Xh=new ti([new vi,new xi,new fi,new ci,new bi,new yi,new _i,new wi],function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];return function(e,r){void 0===r&&(r=0);for(var s=[],n=e.split("\n"),o=r;n.length>o;o++){var a=n[o];if(1024>=a.length){var l=di.test(a)?a.replace(di,"$1"):a;if(!l.match(/\S*Error: /)){for(var u of i){var h=u(l,t);if(h){s.push(h);break}}if(s.length>=50)break}}}return function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return _({},t,{filename:t.filename||(i=e,i[i.length-1]||{}).filename,function:t.function||ei});var i}))}(s)}}("web:javascript",ai,hi)),this._instance=t,this.Yh=null!==(e=null==(i=this._instance.persistence)?void 0:i.get_property(Gi))&&void 0!==e?e:[],this.td=Ti(this.ed()),this.rd=new Pi(this.td)}onConfigChange(){this.td=Ti(this.ed()),this.rd.setConfig(this.td)}onRemoteConfig(t){var e,i,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(e=null==(i=s.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Yh=n,this._instance.persistence&&this._instance.persistence.register({[Gi]:this.Yh,[Ki]:o})}}}get nd(){var t,e=!!this._instance.get_property(Ki),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.Xh.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.td.enabled)try{if(!rt(t)||0===t.trim().length)return void fu.warn("Ignoring exception step because message must be a non-empty string");var i=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>ki.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(this.sd(e)),r=i.sanitizedProperties,s=i.droppedKeys;s.length>0&&fu.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.rd.add(_({[Si]:t,[Ei]:(new Date).toISOString()},r))}catch(t){fu.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.ad(e)){if(this.od(e))return this.ld("Exception dropped: matched a suppression rule"),void fu.info("Skipping exception capture because a suppression rule matched");if(!this.nd&&this.ud(e))return this.ld("Exception dropped: thrown by a browser extension"),void fu.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.hd(e))return this.ld("Exception dropped: thrown by the PostHog SDK"),void fu.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.td.enabled&&ot(t.$exception_steps)?this.dd(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(i.$release_id=r);try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Jo:!0});return s&&this.rd.clear(),s}catch(t){return fu.error("Failed to capture exception event. Dropping this exception.",t),void this.rd.clear()}}catch(t){return void fu.error("Failed to process exception event. Ignoring this exception.",t)}var n}dd(t){try{var e=this.rd.getAttachable();return 0===e.length?t:_({},t,{$exception_steps:e})}catch(e){return fu.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}ld(t){this.td.enabled&&this.rd.add({[Si]:t,[Ei]:(new Date).toISOString()})}sd(t){return tt(t)?_({},t):{}}ed(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}od(t){if(0===t.length)return!1;try{var e=t.reduce(((t,e)=>{var i=e.type,r=e.value;return rt(i)&&i.length>0&&t.$exception_types.push(i),rt(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Yh.some((t=>{var i=t.values.map((t=>{var i=Va[t.operator],r=e[t.key];if(!i||!r)return!1;var s=X(t.value)?t.value:[t.value];return s.length>0&&i(s,r)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}catch(t){return fu.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}ud(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>{var e=t.filename;return!!e&&pu.some((t=>e.startsWith(t)))}))}hd(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ad(t){return!ot(t)&&X(t)}}},Ru=_({productTours:class{get Ta(){return this._instance.persistence}constructor(t){this.vd=null,this.fd=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var i,r;if(this.Ta&&this.Ta.register({[Qi]:!!e.productTours}),!Gl(this._instance))return!this.vd&&ot(null==(i=this.Ta)?void 0:i.props[Er])||Wl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.vd)||r.stop(),this.vd=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.vd&&Gl(this._instance)&&this.Xn((()=>this.pd()))}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Wl.error("Could not load product tours script",e):t()}))}pd(){var t;!this.vd&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.vd=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!X(this.fd)||e){var i=this.Ta;if(i){var r=i.props[Er];if(X(r)&&!e)return this.fd=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:e=>{if(Gl(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||Wl.warn(s):Wl.error(s),void t([],{isLoaded:!1,error:s})}var n=X(e.json.product_tours)?e.json.product_tours:[];this.fd=n,i&&i.register({[Er]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.fd,{isLoaded:!0})}getActiveProductTours(t){ot(this.vd)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.vd.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.vd)||e.showTourById(t)}previewTour(t){this.vd?this.vd.previewTour(t):this.Xn((()=>{var e;this.pd(),null==(e=this.vd)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.vd)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.vd)||t.nextStep()}previousStep(){var t;null==(t=this.vd)||t.previousStep()}clearCache(){var t;this.fd=null,null==(t=this.Ta)||t.unregister(Er)}resetTour(t){var e;null==(e=this.vd)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.vd)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.vd)||e.cancelPendingTour(t)}}},ku),Ou={siteApps:class{constructor(t){this.gd=0,this._instance=t,this.md=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yd(t,e){if(e){var i=this.globalsForEvent(e);this.md.push(i),this.md.length>1e3&&(this.md=this.md.slice(10))}}get siteAppLoaders(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.yd.bind(this));this.bd=()=>{t(),this.md=[],this.bd=void 0}}}globalsForEvent(t){var e,i,r,s,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(h)){var v=d[0];l[v]={id:u[v],type:v,properties:d[1]}}var c=t.$set_once,f=t.$set;return{event:_({},g(t,Kl),{properties:_({},t.properties,f?{$set:_({},null!==(e=null==(i=t.properties)?void 0:i.$set)&&void 0!==e?e:{},f)}:{},c?{$set_once:_({},null!==(r=null==(s=t.properties)?void 0:s.$set_once)&&void 0!==r?r:{},c)}:{}),elements_chain:null!==(n=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=t.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_d(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Jl.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Jl.error("prepare_external_dependency_script returned null"),null):t}wd(){var t,e,i,s,n,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var u=null==r?void 0:r.defaultView,h=null==u||null==(t=u.Node)?void 0:t.prototype;if(!u||!h)return()=>{};if(this.gd++,this.kd)return this.Sd();var d=[],v=this,c=new WeakSet,f=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),d.push((()=>{t[e]=r}))}},p=t=>{if(c.has(t))return t;var e=v._d(t);return e&&c.add(e),e},_=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!nt(t)));return f(h,"appendChild",(t=>function(e){var i=p(e);return i?t.call(this,i):e})),f(h,"insertBefore",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):e})),f(h,"replaceChild",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):i})),[null==(e=u.Element)?void 0:e.prototype,null==(i=u.Document)?void 0:i.prototype,null==(s=u.DocumentFragment)?void 0:s.prototype].forEach((t=>{f(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))}))})),[null==(n=u.Element)?void 0:n.prototype,null==(o=u.CharacterData)?void 0:o.prototype,null==(a=u.DocumentType)?void 0:a.prototype].forEach((t=>{f(t,"before",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=_(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),f(null==(l=u.Element)?void 0:l.prototype,"insertAdjacentElement",(t=>function(e,i){var r=p(i);return r?t.call(this,e,r):null})),this.kd=()=>{d.forEach((t=>t())),this.kd=void 0},this.Sd()}Sd(){var t=!1;return()=>{var e;t||(t=!0,this.gd--,0===this.gd&&(null==(e=this.kd)||e.call(this)))}}xd(t,e){void 0===e&&(e=!0);var i=this.wd();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.md.length&&(Jl.info("Processing "+this.md.length+" events for site app with id "+t.id),this.md.forEach((t=>this.xd((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.bd)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Jl.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this.xd((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1).processEvent;n&&(e.processEvent=n),r=!0}catch(e){Jl.error(Yl+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Jl.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Cd(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Td(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.xd((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Jl.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Cd(),void this._instance.on("eventCaptured",(t=>this.Td(t)))):void Jl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.bd)||i.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,e=a.id,i=a.url;v["__$$ph_site_app_"+e]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,i,(t=>{if(t)return Jl.error(Yl+e,t)}))};for(var a of n.siteApps)o()}else Jl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Cu={tracingHeaders:class{constructor(t){this.Md=void 0,this.Ed=void 0,this.Id=void 0,this.Uh=()=>{var t,e,i=this.Rd();i?(it(this.Md)&&(this.Md=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),it(this.Ed)&&(this.Ed=null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Qh()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Xn(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return Ml.error("failed to load script",e);t()}))}Pd(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Rd(){var t=this.Pd();return X(t)?(X(this.Id)?this.Id.splice(0,this.Id.length,...t):this.Id=[...t],t.length>0?this.Id:void 0):(X(this.Id)&&this.Id.splice(0),this.Id=t||void 0,this.Id)}Qh(){var t,e;null==(t=this.Md)||t.call(this),null==(e=this.Ed)||e.call(this),this.Md=void 0,this.Ed=void 0}startIfEnabledOrStop(){this.Rd()?this.Xn(this.Uh):this.Qh()}}},Iu=_({surveys:class{get Di(){return this._instance.config}constructor(t){this.Ad=void 0,this._surveyManager=null,this.Fd=!1,this.Od=[],this.Ld=null,this.$d=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Di.disable_surveys){if(!t.ok)return tl.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(ot(e))return tl.warn("Flags not loaded yet. Not loading surveys.");var i=X(e);this.Ad=i?e.length>0:e,tl.info("flags response received, isSurveysEnabled: "+this.Ad),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(el)||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.Fd)tl.info("Already initializing surveys, skipping...");else if(this.Di.disable_surveys)tl.info(iu);else if(this.Di.cookieless_mode&&this._instance.consent.isOptedOut())tl.info("Not loading surveys in cookieless mode without consent.");else{var t=null==v?void 0:v.__PosthogExtensions__;if(t){if(!it(this.Ad)||this.Di.advanced_enable_surveys){var e=this.Ad||this.Di.advanced_enable_surveys;this.Fd=!0;try{var i=t.generateSurveys;if(i)return void this.Dd(i,e);var r=t.loadExternalDependency;if(!r)return void this.Nd(Br);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.Nd("Could not load surveys script",i):this.Dd(t.generateSurveys,e)}))}catch(t){throw this.Nd("Error initializing surveys",t),t}finally{this.Fd=!1}}}else tl.error("PostHog Extensions not found.")}}Dd(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new tu(this._instance),tl.info("Surveys loaded successfully"),this.qd({isLoaded:!0})}Nd(t,e){tl.error(t,e),this.qd({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Od.push(t),this._surveyManager&&this.qd({isLoaded:!0}),()=>{this.Od=this.Od.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Di.disable_surveys)return tl.info(iu),t([]);var i,r=this._instance.get_property(yr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.jd()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.Ld?this.Ld.then((e=>t(e.surveys,e.context))):("undefined"!=typeof Promise&&(this.Ld=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Di.token),method:"GET",timestampMode:"query",timeout:this.Di.surveys_request_timeout_ms,callback:e=>{var r;this.Ld=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;0!==s?tl.error(n):e.error||tl.warn(n),this.$d=Date.now();var o={isLoaded:!1,error:n};return t([],o),void(null==i||i({surveys:[],context:o}))}this.$d=null;var a,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Za(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[yr]:l,[br]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}jd(){return this.Bd()&&!this.Ld&&!this.Hd()}Bd(){var t=this._instance.get_property(br);return at(t)&&Date.now()-t>3e5}Hd(){return at(this.$d)&&3e5>Date.now()-this.$d}markSurveyAsSeen(t,e){var i,r={id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null};il(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}qd(t){for(var e of this.Od)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){tl.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!ot(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);tl.warn("init was not called")}Ud(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}zd(t){if(ot(this._surveyManager))return{eligible:!1,reason:eu};var e="string"==typeof t?this.Ud(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Wd(t){if(ot(this._surveyManager))return{eligible:!1,reason:eu};var e="string"==typeof t?this.Ud(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(ot(this._surveyManager))return tl.warn("init was not called"),{visible:!1,disabledReason:eu};var e=this.Wd(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return ot(this._surveyManager)?(tl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:eu})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this.Wd(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(ot(this._surveyManager))tl.warn("init was not called");else{var n="string"==typeof t?this.Ud(t):t;if(null!=n&&n.id)if(rl.includes(n.type)){var o=null==r?void 0:r.querySelector(e);if(o)return null!=(s=n.appearance)&&s.surveyPopupDelaySeconds?(tl.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;tl.info("Rendering survey "+n.id+" with delay of "+(null==(t=n.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(n,o,i),tl.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,o,i);tl.warn("Survey element not found")}else tl.warn("Surveys of type "+n.type+" cannot be rendered in the app");else tl.warn("Survey not found")}}displaySurvey(t,e){var i;if(ot(this._surveyManager))tl.warn("init was not called");else{var r=this.Ud(t);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=_({},r,{appearance:_({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Po.Popover&&e.initialResponses&&tl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var n=this.zd(r);if(!n.eligible)return void tl.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==Po.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else tl.warn("Survey not found")}}cancelPendingSurvey(t){ot(this._surveyManager)?tl.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},ku),Au={toolbar:class{constructor(t){this.instance=t}Vd(t){v.ph_toolbar_state=t}Gd(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,i,s){if(void 0===e&&(e=void 0),void 0===i&&(i=void 0),void 0===s&&(s=void 0),us(this.instance.config))return!1;if(!t||!r)return!1;e=null!=e?e:t.location,s=null!=s?s:t.history;try{if(!i){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}i=null==t?void 0:t.localStorage}var n,o=ru||Vn(e.hash,"__posthog")||Vn(e.hash,"state"),a=o?rs((()=>JSON.parse(atob(decodeURIComponent(o)))))||rs((()=>JSON.parse(decodeURIComponent(o)))):null;return a&&"ph_authorize"===a.action?((n=a).source="url",n&&Object.keys(n).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):((n=JSON.parse(i.getItem(su)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}Zd(t){var e=v.ph_load_toolbar||v.ph_load_editor;!ot(e)&&Z(e)?e(t,this.instance):nu.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==r||!r.getElementById(Ls));if(!t||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=_({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(su,JSON.stringify(_({},n,{source:void 0}))),2===this.Gd())this.Zd(n);else if(0===this.Gd()){var o;this.Vd(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return nu.error("[Toolbar] Failed to load",t),void this.Vd(0);this.Vd(2),this.Zd(n)})),ls(t,"turbolinks:load",(()=>{this.Vd(0),this.loadToolbar(n)}))}return!0}Qd(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Fu=_({experiments:mu},ku),Mu={conversations:class{constructor(t){this.Jd=void 0,this._conversationsManager=null,this.Kd=!1,this.Me=null,this.Yd=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Xd=t.ok,t.ok)){var e=t.config.conversations;ot(e)||(ut(e)?this.Jd=e:(this.Jd=e.enabled,this.Me=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Jd=void 0,this.Me=null,this.Xd=void 0,this.Yd=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Kd||this._instance.config.disable_conversations||us(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!it(this.Jd)&&this.Jd)if(this.Me&&this.Me.token){this.Kd=!0;try{var e=t.initConversations;if(e)return this.tv(e),void(this.Kd=!1);var i=t.loadExternalDependency;if(!i)return void this.ev(Br);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.ev("Could not load conversations script",e):this.tv(t.initConversations),this.Kd=!1}))}catch(t){this.ev("Error initializing conversations",t),this.Kd=!1}}else yu.error("Conversations enabled but missing token in remote config.")}}tv(t){if(this.Me)try{this._conversationsManager=t(this.Me,this._instance),this.Yd=!1,yu.info("Conversations loaded successfully")}catch(t){this.ev("Error completing conversations initialization",t)}else yu.error("Cannot complete initialization: remote config is null")}ev(t,e){yu.error(t,e),this._conversationsManager=null,this.Kd=!1,this.Yd=!0}show(){this._conversationsManager?this._conversationsManager.show():yu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Jd&&!nt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":us(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Xd?"remote_config_failed":it(this.Jd)?this.Xd?"disabled_in_project":"remote_config_pending":this.Jd?ot(this.Me)||!this.Me.token?"missing_token":null!=v&&v.__PosthogExtensions__?this.Kd?"initializing":this.Yd?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,e,i){var r=this;return p((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,i):(yu.warn(bu),null)}))()}getMessages(t,e){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(yu.warn(bu),null)}))()}markAsRead(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(yu.warn(bu),null)}))()}getTickets(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(yu.warn(bu),null)}))()}requestRestoreLink(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(yu.warn(bu),null)}))()}restoreFromToken(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(yu.warn(bu),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(yu.warn(bu),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}sl(){var t;null==(t=this._conversationsManager)||t.setIdentity()}al(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},Du={logs:class{constructor(e){var i,r=this;this.iv=!1,this.rv=!1,this.I=Ii("[logs]"),this.nv=_({},this.I,{error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];e.some(Eu)||r.I.error(...e)}}),this.na=[],this.sv=[],this.Tu=0,this.av=()=>{var t,e;this.Tu=0,null==(t=this.ov)||t.onReconnect(),null==(e=this.lv)||e.onReconnect()},this._instance=e,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.iv=!0),t&&ls(t,"online",this.av)}uv(t,e,i,r){var s,n=function(t,e){var i,r,s,n,o,a,l,u=null!==(i=null==t?void 0:t.flushIntervalMs)&&void 0!==i?i:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,d=null!=e&&e.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,v=it(d)?Math.max(h,2048):Math.max(h,d),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==c?void 0:c["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==n?n:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(a=null==c?void 0:c["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,i);return[new Ve(this.hv(t,e),n,this.nv,(()=>this.dv()),(t=>t()),void 0,r),n]}vv(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.ov||this.fv!==e){var i;null==(i=this.ov)||i.reset(),this.fv=e;var r=this.uv((()=>this.na),(t=>{this.na=t}));this.ov=r[0],this.pv=r[1]}return this.ov}gv(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.lv||this.mv!==e){var i;null==(i=this.lv)||i.reset(),this.mv=e;var r=this.uv((()=>this.sv),(t=>{this.sv=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},wu);this.lv=r[0],this.yv=r[1]}return this.lv}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e;if(t.ok){var i=null==(e=t.config.logs)?void 0:e.captureConsoleLogs;!ot(i)&&i&&(this.iv=!0,this.loadIfEnabled())}}reset(){var t,e;this.na=[],null==(t=this.ov)||t.reset(),this.sv=[],null==(e=this.lv)||e.reset(),this.Tu=0}captureLog(t){this.vv().captureLog(t)}ci(t){this.gv().captureLog(t)}get logger(){return this.bv||(this.bv={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.bv}flushLogs(t){t?this._v(t):(this.ov&&this.ov.flush().catch((t=>this.wv(t))),this.lv&&this.lv.flush().catch((t=>this.wv(t))))}wv(t){Eu(t)||this.I.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.iv&&!this.rv){var t=null==v?void 0:v.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.I.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.rv=!0)})):this.I.error(Br)}else this.I.error("PostHog Extensions not found.")}}hv(t,e){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:e=>e===S.LogsQueue?t():void 0,setPersistedProperty(t,i){var r;t===S.LogsQueue&&e(null!==(r=i)&&void 0!==r?r:[])},Cn:t=>this.Cn(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Cn(t){return new Promise((e=>{if(Wn(this.Tu,3))e({kind:"fatal",error:Su(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Su(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Sv(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var e=t.statusCode;if(this.xv(e),e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;0===e?(t.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Su(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}}))}xv(t){(0!==t||this._instance.__loaded)&&(this.Tu=Gn(t,this.Tu,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."))))}_v(t){this.na.length>0&&this.Cv(t,this.na,this.pv,c.LIB_NAME,(t=>{this.na=t})),this.sv.length>0&&this.Cv(t,this.sv,this.yv,wu,(t=>{this.sv=t}))}Cv(t,e,i,r,s){if(0!==e.length){var n=e.map((t=>t.record));s([]);var o=He(n,qe(i,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Sv(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Sv(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}dv(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=i.windowId,s=i.sessionStartTimestamp,n=i.lastActivityTimestamp;e.sessionId=i.sessionId,e.windowId=r,ot(s)||(e.sessionStartTimestamp=s),ot(n)||(e.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?Re(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},Nu={metrics:class{constructor(t){this.I=Ii("[metrics]"),this._instance=t}initialize(){}vv(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.ov&&this.fv===i||(null==(e=this.ov)||e.reset(),this.fv=i,this.ov=new Je(this.hv(),function(t){var e,i,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==o?void 0:o["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this.I)),this.ov}count(t,e,i){void 0===e&&(e=1),this.vv().count(t,e,i)}gauge(t,e,i){this.vv().gauge(t,e,i)}histogram(t,e,i){this.vv().histogram(t,e,i)}flush(t){if(!this.ov)return Promise.resolve();if(t){var e=this.ov.drainWindow();return e&&this.Bn(e,t),Promise.resolve()}return this.ov.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.ov)||t.reset()}hv(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Bn:t=>e.Bn(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Bn(t,e){return new Promise((i=>{var r=!1,s=t=>{r||(r=!0,clearTimeout(n),i(t))},n=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(_({method:"POST",url:this.Tv(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)s({kind:"ok"});else if(413===e)s({kind:"too-large"});else if(0!==e&&429!==e&&500>e)s({kind:"fatal",error:new Error("metrics request failed with status "+e)});else{var i;s({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}}))}))}Tv(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Uu=_({},ku,$u,Tu,Pu,Ru,Ou,Iu,Cu,Au,Fu,Mu,Du,Nu);$l.__defaultExtensionClasses=_({},Uu);var Lu=function(){c.SDK_DIST_CHANNEL="npm";var e=vl[bl]=new $l;return function(){function e(){e.done||(e.done=!0,wl=!1,ts(vl,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?e():ls(r,"DOMContentLoaded",e,{capture:!1}):t&&Ci.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{go as Compression,Ro as DEFAULT_PRODUCT_TOUR_APPEARANCE,Po as DisplaySurveyType,$l as PostHog,Oo as ProductTourEventName,Co as ProductTourEventProperties,$o as SurveyEventName,To as SurveyEventProperties,mo as SurveyEventType,bo as SurveyPosition,Eo as SurveyQuestionBranchingType,So as SurveyQuestionType,ko as SurveySchedule,wo as SurveyTabPosition,xo as SurveyType,yo as SurveyWidgetType,Lu as default,Lu as posthog,Do as severityLevels};
2
2
  //# sourceMappingURL=module.js.map