!function(){"use strict";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 g(){return g=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},g.apply(null,arguments)}function _(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}({}),k=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),E=["$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"],P=["token"],T="NativeGzipValidationError",F=t=>t.length>=2&&31===t[0]&&139===t[1],R=(t,e)=>t===k.GZipJS||e===k.GZipJS||"gzip"===e,C=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),M=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=T,e},I=function(){var t=p((function*(t,e){18>t.size&&M("too-short");var i=new Uint8Array(yield t.slice(0,10).arrayBuffer());F(i)&&8===i[2]||M("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)&&M("invalid-crc");var s=e.length>>>0;r.getUint32(4,!0)!==s&&M("invalid-size")}));return function(e,i){return t.apply(this,arguments)}}();function A(){return A=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 I(l,r),l}catch(t){if(null!=i&&i.rethrow)throw t;return e&&console.error("Failed to gzip compress data",t),null}})),A.apply(this,arguments)}var O=["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"],D=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return O.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function j(t,e){return-1!==t.indexOf(e)}var L=function(t){return t.trim()},N=function(t){return t.replace(/^\$/,"")};function B(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 z=Object.prototype,U=z.hasOwnProperty,q=z.toString,H=Array.isArray||function(t){return"[object Array]"===q.call(t)},G=t=>"function"==typeof t,W=t=>t===Object(t)&&!H(t),V=t=>{if(W(t)){for(var e in t)if(U.call(t,e))return!1;return!0}return!1},K=t=>void 0===t,J=t=>"[object String]"==q.call(t),Y=t=>J(t)&&0===t.trim().length,Q=t=>null===t,X=t=>K(t)||Q(t),Z=t=>"[object Number]"==q.call(t)&&t==t,tt=t=>Z(t)&&t>0,et=t=>"[object Boolean]"===q.call(t),it=t=>t instanceof FormData,rt=t=>j(E,t),st=t=>j(P,t);function nt(t){return null===t||"object"!=typeof t}function ot(t,e){return{}.toString.call(t)==="[object "+e+"]"}function at(t){return"undefined"!=typeof Event&<(t,Event)}function lt(t,e){try{return t instanceof e}catch(t){return!1}}var ut=[!0,"true",1,"1","yes"],ht=t=>j(ut,t),dt=[!1,"false",0,"0","no"];function vt(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),Z(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),vt(s||i,e,i,r))}class ct{constructor(t){this.it={},this.rt=t.rt,this.nt=vt(t.bucketSize,0,100,t.st),this.ot=vt(t.refillRate,0,this.nt,t.st),this.ut=vt(t.refillInterval,0,864e5,t.st)}ht(t,e){var i=Math.floor((e-t.lastAccess)/this.ut);i>0&&(t.tokens=Math.min(t.tokens+i*this.ot,this.nt),t.lastAccess=t.lastAccess+i*this.ut)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.it[r];return s?this.ht(s,i):this.it[r]=s={tokens:this.nt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.rt)||e.call(this,t)),0===s.tokens)}stop(){this.it={}}}var ft="Mobile",pt="iOS",gt="Android",_t="Tablet",mt=gt+" "+_t,yt="iPad",bt="Apple",wt=bt+" Watch",xt="Safari",St="BlackBerry",kt="Samsung",Et=kt+"Browser",$t=kt+" Internet",Pt="Chrome",Tt=Pt+" OS",Ft=Pt+" "+pt,Rt="Internet Explorer",Ct=Rt+" "+ft,Mt="Opera",It=Mt+" Mini",At="Edge",Ot="Microsoft "+At,Dt="Firefox",jt=Dt+" "+pt,Lt="Nintendo",Nt="PlayStation",Bt="Xbox",zt=gt+" "+ft,Ut=ft+" "+xt,qt="Windows",Ht=qt+" Phone",Gt="Nokia",Wt="Ouya",Vt="Generic",Kt=Vt+" "+ft.toLowerCase(),Jt=Vt+" "+_t.toLowerCase(),Yt="Konqueror",Qt="Oculus Browser",Xt="Vivaldi",Zt="Yandex",te="Whale",ee="DuckDuckGo",ie="Pale Moon",re="Waterfox",se="Brave",ne="Google Search App",oe="(\\d+(\\.\\d+)?)",ae=new RegExp("Version/"+oe),le=new RegExp(Bt,"i"),ue=new RegExp(Nt+" \\w+","i"),he=new RegExp(Lt+" \\w+","i"),de=new RegExp(St+"|PlayBook|BB10","i"),ve={"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"},ce=function(t,e,i,r){e=e||"";var s=function(t){return null!=t&&t.brave?se:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&j(t,"GSA/")?ne:j(t," OPR/")&&j(t,"Mini")?It:j(t," OPR/")?Mt:de.test(t)?St:j(t,"IE"+ft)||j(t,"WPDesktop")?Ct:j(t,"OculusBrowser")?Qt:j(t,Et)?$t:j(t,At)||j(t,"Edg/")?Ot:j(t,Xt+"/")?Xt:j(t,"YaBrowser/")?Zt:j(t,te+"/")?te:j(t,ee+"/")||j(t,"Ddg/")?ee:j(t,"FBIOS")?"Facebook "+ft:j(t,"UCWEB")||j(t,"UCBrowser")?"UC Browser":j(t,"CriOS")?Ft:j(t,"CrMo")||j(t,Pt)?Pt:j(t,gt)&&j(t,xt)?zt:j(t,"FxiOS")?jt:j(t.toLowerCase(),Yt.toLowerCase())?Yt:j(t,se+"/")?se:((t,e)=>e&&j(e,bt)||function(t){return j(t,xt)&&!j(t,Pt)&&!j(t,gt)}(t))(t,e)?j(t,ft)?Ut:xt:j(t,"PaleMoon/")?ie:j(t,re+"/")?re:j(t,Dt)?Dt:j(t,"MSIE")||j(t,"Trident/")?Rt:j(t,"Gecko")?Dt:"")},fe={[Ct]:[new RegExp("rv:"+oe)],[Ot]:[new RegExp(At+"?\\/"+oe)],[Pt]:[new RegExp("("+Pt+"|CrMo)\\/"+oe)],[Ft]:[new RegExp("CriOS\\/"+oe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+oe)],[xt]:[ae],[Ut]:[ae],[Mt]:[new RegExp("(Opera|OPR)\\/"+oe)],[Dt]:[new RegExp(Dt+"\\/"+oe)],[jt]:[new RegExp("FxiOS\\/"+oe)],[Yt]:[new RegExp("Konqueror[:/]?"+oe,"i")],[St]:[new RegExp(St+" "+oe),ae],[zt]:[new RegExp("android\\s"+oe,"i")],[$t]:[new RegExp(Et+"\\/"+oe)],[Qt]:[new RegExp("OculusBrowser\\/"+oe)],[Xt]:[new RegExp(Xt+"\\/"+oe)],[Zt]:[new RegExp("YaBrowser\\/"+oe)],[te]:[new RegExp(te+"\\/"+oe)],[se]:[new RegExp(se+"\\/"+oe)],[ee]:[new RegExp("(DuckDuckGo|Ddg)\\/"+oe)],[ie]:[new RegExp("PaleMoon\\/"+oe)],[re]:[new RegExp(re+"\\/"+oe)],[ne]:[new RegExp("GSA\\/"+oe)],[Rt]:[new RegExp("(rv:|MSIE )"+oe)],Mozilla:[new RegExp("rv:"+oe)]},pe=function(t,e,i,r){var s=ce(t,e,i,r),n=fe[s];if(K(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},ge=[[new RegExp(Bt+"; "+Bt+" (.*?)[);]","i"),t=>[Bt,t&&t[1]||""]],[new RegExp(Lt,"i"),[Lt,""]],[new RegExp(Nt,"i"),[Nt,""]],[de,[St,""]],[new RegExp(qt,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Ht,""];if(new RegExp(ft).test(e)&&!/IEMobile\b/.test(e))return[qt+" "+ft,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=ve[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[qt,r]}return[qt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[pt,[t[3],t[4],t[5]||"0"].join(".")]:[pt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=K(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+gt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+gt+")","i"),t=>t&&t[2]?[gt,[t[2],t[3],t[4]||"0"].join(".")]:[gt,""]],[/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/,[Tt,""]],[/Linux|debian/i,["Linux",""]]],_e=function(t){return he.test(t)?Lt:ue.test(t)?Nt:le.test(t)?Bt:new RegExp(Wt,"i").test(t)?Wt:new RegExp("("+Ht+"|WPDesktop)","i").test(t)?Ht:/iPad/.test(t)?yt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?wt:de.test(t)?St:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Gt,"i").test(t)?Gt:/(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(ft).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)?gt:mt:new RegExp("(pda|"+ft+")","i").test(t)?Kt:new RegExp(_t,"i").test(t)&&!new RegExp(_t+" pc","i").test(t)?Jt:""},me=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ye(t,e){return"string"==typeof(i=t)&&me.test(i)?t:e();var i}function be(t){return t?t.split("#")[0]:t}function we(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function xe(t,e,i){return Se.apply(this,arguments)}function Se(){return(Se=p((function*(t,e,i){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=we((()=>{try{null==i||i(),t()}catch(t){s(t)}}),e)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var ke=t=>t instanceof Error,Ee={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}},$e=Ee.info;function Pe(t){if(et(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(H(t))return{arrayValue:{values:t.map((t=>Pe(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function Te(t){var e=[];for(var i in t){var r=t[i];Q(r)||K(r)||e.push({key:i,value:Pe(r)})}return e}function Fe(t,e){var i=Ee[t.level||"info"]||$e,r=i.text,s=i.number,n=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),X(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),X(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var a=g({},o,t.attributes||{}),l={timeUnixNano:n,observedTimeUnixNano:n,severityNumber:s,severityText:r,body:{stringValue:t.body},attributes:Te(a)};return t.trace_id&&(l.traceId=t.trace_id),t.span_id&&(l.spanId=t.span_id),K(t.trace_flags)||(l.flags=t.trace_flags),l}function Re(t,e,i){return g({},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 Ce(t,e,i,r){return{resourceLogs:[{resource:{attributes:Te(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let Me=class{constructor(t,e,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.qe=e,this.st=i,this.dt=r,this.vt=s,this.ct=n,this.ft=o,this.yt=null,this.bt=0,this._t=0,this.wt=0,this.kt=0,this.xt=!1,this.St=e.maxBufferSize,this.Ct=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.Mt=e.flushIntervalMs,this.Tt=e.maxBatchRecordsPerPost,this.Et=e.rateCapWindowMs,this.It=e.maxLogsPerInterval}reset(){this.Pt(),this.yt=null,this.wt=0,this.kt=0,this.xt=!1,this.bt=0,this._t=0,this.Tt=this.qe.maxBatchRecordsPerPost}onReconnect(){this._t=0,this.Rt()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.At(t);if(null!==e)if(e.body){if(this.Ft()){var i={record:Fe(e,this.dt())};this.vt((()=>this.Lt(i)))}}else this.st.info("Log was rejected in beforeSend function")}}At(t){var e=this.qe.beforeSend;if(!e)return t;var i=H(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.st.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.st.error("Error in beforeSend function for log:",t),null}return r}Ft(){if(void 0===this.It)return!0;var t=Date.now(),e=t-this.wt;return this.Et>e&&e>=0||(this.wt=t,this.kt=0,this.xt=!1),this.It>this.kt?(this.kt++,!0):(this.xt||(this.st.warn("captureLog dropping logs: exceeded "+this.It+" logs per "+this.Et+"ms"),this.xt=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.yt||(t.yt=t.Ot().finally((()=>{t.yt=null}))),t.yt}))()}Ot(){var t=this;return p((function*(){var e;t.Pt();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.bt=0;var a=Math.min(i.length,t.Tt),l=i.slice(0,a),u=Ce(l.map((t=>t.record)),t.Dt(),null!==(n=t.ft)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.$t(u);if("too-large"===h.kind&&l.length>1)t.Tt=Math.max(1,Math.floor(l.length/2)),t.st.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+t.Tt);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.st.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.qe.maxBatchRecordsPerPost>t.Tt&&(t.Tt=Math.min(t.qe.maxBatchRecordsPerPost,t.Tt+1)),yield t.Nt(l.length),i=null!==(o=t._instance.getPersistedProperty(S.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===h.kind)throw h.error}}}))()}Nt(t){var e=this;return p((function*(){var i,r=Math.max(0,t-e.bt),s=null!==(i=e._instance.getPersistedProperty(S.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(S.LogsQueue,s.slice(r)),yield e.ct()}))()}Dt(){return Re(this.qe,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Lt(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(S.LogsQueue))&&void 0!==e?e:[];this.Ct>i.length||(i.shift(),this.bt++,this.st.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(S.LogsQueue,i),this.St>i.length?this.qt():this.Rt()}}qt(t){void 0===t&&(t=this.Mt),this.jt||(this.jt=we((()=>{this.jt=void 0,this.Rt()}),t))}Bt(){var t=Math.min(Math.max(0,this._t-1),6);return this.Mt*Math.pow(2,t)}Ht(){var t=this._instance.getPersistedProperty(S.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return p((function*(){e.Pt();var i=e.flush().catch((()=>{}));void 0!==t?yield xe(i,t):yield i}))()}flushWithTimeout(t){var e=this;return p((function*(){var i=e.flush();yield xe(i,t,(()=>{i.catch((()=>{}))}))}))()}Rt(){this.flush().then((()=>{this._t=0}),(t=>{this._t++,this.st.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Ht()&&this.qt(this.Bt())}))}Pt(){this.jt&&(clearTimeout(this.jt),this.jt=void 0)}};var Ie=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ae(t){return String(t)+"000000"}function Oe(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 De=class{constructor(t,e,i){this._instance=t,this.qe=e,this.st=i,this.Ut=new Map,this.yt=null,this.zt=!1,this.Wt=new Map,this.Vt=new Set,this.Zt=0}count(t,e,i){void 0===e&&(e=1),this.Gt({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.Gt({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.Gt({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.yt,i=function(){var i=p((function*(){e&&(yield e.catch((()=>{}))),yield t.Qt()}));return function(){return i.apply(this,arguments)}}(),r=i().finally((()=>{this.yt===r&&(this.yt=null)}));return this.yt=r,r}drainWindow(){if(0===this.Ut.size)return null;var t=this.Ut;return this.Ut=new Map,this.zt=!1,this.Wt=new Map,this.Vt=new Set,this.Kt(t)}reset(){this.Zt++,this.Pt(),this.Ut=new Map,this.yt=null,this.zt=!1,this.Wt=new Map,this.Vt=new Set}Gt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.At(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.st.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=e.attributes?g({},e.attributes):void 0,r=Oe(e.type,e.name,e.unit,i)}catch(t){return void this.st.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var s=this.Ut.get(r);if(!s){if(!this.Jt())return;s={name:e.name,type:e.type,unit:e.unit,attributes:i,windowStartMs:Date.now()},this.Ut.set(r,s)}var n=this.Wt.get(e.name);void 0===n?this.Wt.set(e.name,e.type):n===e.type||this.Vt.has(e.name)||(this.Vt.add(e.name),this.st.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.Yt(s,e.value),this.qt()}else this.st.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.st.warn("Dropping metric with empty name")}}Jt(){return this.qe.maxSeriesPerFlush>this.Ut.size||(this.zt||(this.zt=!0,this.st.warn("Metric series cap reached ("+this.qe.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Yt(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(Ie.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,Ie)]+=1}}At(t){var e=this.qe.beforeSend;if(!e)return t;var i=H(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.st.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.st.error("Error in beforeSend function for metric:",t),null}return r}qt(){this.jt||(this.jt=we((()=>{this.jt=void 0,this.flush().catch((t=>{this.st.error("Metrics flush failed:",t)}))}),this.qe.flushIntervalMs))}Pt(){this.jt&&(clearTimeout(this.jt),this.jt=void 0)}Qt(){var t=this;return p((function*(){if(0!==t.Ut.size){var e=t.Ut;t.Ut=new Map,t.zt=!1,t.Wt=new Map,t.Vt=new Set;var i=t.Zt,r=yield t._instance.Xt(t.Kt(e));if(i===t.Zt)switch(r.kind){case"ok":return;case"retry-later":return t.ti(e),void t.qt();case"too-large":return void t.st.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.st.error("Failed to send metrics batch:",r.error)}}}))()}Kt(t){return e=this.ei(t),i=function(t,e,i){return g({},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.qe,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Te(i)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,i,r,s}ei(t){var e=Ae(Date.now()),i=new Map;for(var r of t.values()){var s,n=Oe(r.type,r.name,r.unit,void 0),o=i.get(n);o||(o=g({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=Te(null!==(s=r.attributes)&&void 0!==s?s:{}),l=Ae(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:Ie})}return Array.from(i.values())}ti(t){var e,i;for(var r of t){var s=r[0],n=r[1],o=this.Ut.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.Jt()&&this.Ut.set(s,n)}}};var je,Le,Ne;function Be(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Ne&&i.length===Le||(Le=i.length,Ne=i.reduce(((i,r)=>{je||(je={});var s=je[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,je[r]=[l,u];break}}return i}),{})),Ne}}class ze{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&&H(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)),g({},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,g({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:Be(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 g({},e,{syntheticException:0==i?e.syntheticException:void 0,mechanism:t,apply:t=>r(t,i),next:t=>r(t,i+1)})}}var Ue="?";function qe(t,e,i,r,s){var n={platform:t,filename:e,function:""===i?Ue:i,in_app:!0};return K(r)||(n.lineno=r),K(s)||(n.colno=s),n}var He=(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]:Ue,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Ge=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,We=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ve=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ke=(t,e)=>{var i=Ge.exec(t);if(i)return qe(e,i[1],Ue,+i[2],+i[3]);var r=We.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=Ve.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=He(r[1]||Ue,r[2]);return qe(e,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Je=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ye=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Qe=(t,e)=>{var i=Je.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Ye.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]||Ue,o=He(n,s);return qe(e,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Xe=/\(error: (.*)\)/;class Ze{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=J(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 ot(t,"DOMException")}isDOMError(t){return ot(t,"DOMError")}}class ti{match(t){return function(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 lt(t,Error)}}(t)}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}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 ei{constructor(){}match(t){return!!ot(t,"ErrorEvent")&&(null!=t.error||this.fe(t))}coerce(t,e){var i;if(null!=t.error)return e.apply(t.error);var r=e.apply(t.message);return g({},r,{stack:null!==(i=this.pe(t))&&void 0!==i?i:r.stack,synthetic:!0})}fe(t){return J(t.message)&&t.message.length>0}pe(t){var e=t;if(J(e.filename)&&e.filename.length>0){var i,r,s=null!==(i=e.lineno)&&void 0!==i?i:0,n=null!==(r=e.colno)&&void 0!==r?r:0;return"Error\n at "+e.filename+":"+s+":"+n}}}var ii=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ri{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(ii);return r&&(e=r[1],i=r[2]),[e,i]}}var si=["fatal","error","warning","log","info","debug"];function ni(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 oi{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){return at(t)?t.constructor.name:"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: "+ni(t)}isSeverityLevel(t){return J(t)&&!Y(t)&&si.indexOf(t)>=0}getStack(t){try{return J(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:J(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(ke(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class ai{match(t){return at(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ni(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class li{match(t){return nt(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 ui{match(t){return ot(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!at(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 nt(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 hi="$message",di="$timestamp",vi=new Set([hi,di]),ci={enabled:!0,max_bytes:32768};function fi(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:ci.enabled,max_bytes:gi(t.max_bytes,ci.max_bytes)}:g({},ci)}class pi{constructor(t){this.ii=[],this.ri=0,this.qe=fi(t)}setConfig(t){this.qe=fi(t),this.ni()}add(t){var e=function(t){var e;try{e=B(t)}catch(t){return}try{var i=JSON.parse(e);if(!W(i))return;var r=i,s=r[hi],n=r[di];if(!J(s)||0===s.trim().length)return;if(!J(n)&&!Z(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.qe.max_bytes||(this.ii.push({step:e.step,bytes:i}),this.ri+=i,this.ni())}}getAttachable(){return this.ii.map((t=>t.step))}clear(){this.ii=[],this.ri=0}size(){return this.ii.length}ni(){for(;this.ri>this.qe.max_bytes&&this.ii.length>0;){var t=this.ii.shift();t&&(this.ri-=t.bytes)}}}function gi(t,e){if(!Z(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var _i=function(e,i){var r=(void 0===i?{}:i).debugEnabled,s={k(i){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!K(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.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("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)=>_i(e+" "+t,i)};return s},mi=_i("[PostHog.js]"),yi=mi.createLogger,bi=yi("[ExternalScriptsLoader]"),wi=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)return e[i]},xi=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return bi.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=wi(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(wi(e))return xi(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)},Si={},ki=(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=Si[s];if("fallback"===r&&n){if(wi(n))return void xi(t,n,i);delete Si[s]}xi(t,s,"fallback"===r?(r,n)=>{if(r)if("string"==typeof r)i(r);else{var o,a=ki(t,e);Si[s]=a;var l=wi(s);null==l||null==(o=l.parentNode)||o.removeChild(l),xi(t,a,i)}else i(void 0,n)}:i)}else xi(t,ki(t,e),i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");xi(t,o,i)}},v.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var r=t.requestRouter.endpointFor("api",e);xi(t,r,i)};c.DEBUG=!1,c.LIB_VERSION="1.417.1",c.LIB_NAME="web";var Ei="$people_distinct_id",$i="$device_id",Pi="$device_model",Ti="__alias",Fi="__timers",Ri="$autocapture_disabled_server_side",Ci="$heatmaps_enabled_server_side",Mi="$exception_capture_enabled_server_side",Ii="$error_tracking_suppression_rules",Ai="$error_tracking_capture_extension_exceptions",Oi="$web_vitals_enabled_server_side",Di="$dead_clicks_enabled_server_side",ji="$product_tours_enabled_server_side",Li="$web_vitals_allowed_metrics",Ni="$session_recording_remote_config",Bi="$replay_sample_rate",zi="$replay_override_sampling",Ui="$replay_override_linked_flag",qi="$replay_override_url_trigger",Hi="$replay_override_event_trigger",Gi="$sesid",Wi="$session_is_sampled",Vi="$enabled_feature_flags",Ki="$active_feature_flags",Ji="$early_access_features",Yi="$feature_flag_details",Qi="$feature_flag_payloads",Xi="$feature_flag_request_id",Zi="$minimal_flag_called_events",tr="$override_feature_flags",er="$override_feature_flag_payloads",ir="$stored_person_properties",rr="$stored_group_properties",sr="$surveys",nr="$surveys_loaded_at",or="$surveys_activated",ar="$surveys_activated_session",lr="$surveys_activated_timestamps",ur="ph_product_tours",hr="$flag_call_reported",dr="$flag_call_reported_session_id",vr="$feature_flag_errors",cr="$feature_flag_evaluated_at",fr="$user_state",pr="$client_session_props",gr="$capture_rate_limit",_r="$initial_campaign_params",mr="$initial_referrer_info",yr="$initial_person_info",br="$epp",wr="$posthog_cookieless",xr="$cookieless_mode",Sr="$sdk_debug_extensions_init_method",kr="$sdk_debug_extensions_init_time_ms",Er="$sdk_debug_recording_script_not_loaded",$r="PostHog loadExternalDependency extension not found.",Pr="on_reject",Tr="always",Fr="anonymous",Rr="identified",Cr="identified_only",Mr="visibilitychange",Ir="beforeunload",Ar="$pageview",Or="$pageleave",Dr="$identify",jr="$groupidentify";function Lr(t,e){H(t)&&t.forEach(e)}function Nr(t,e){if(!X(t))if(H(t))t.forEach(e);else if(it(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)U.call(t,i)&&e(t[i],i)}var Br=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 zr(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 Ur=function(t){try{return t()}catch(t){return}},qr=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){mi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),mi.critical(t)}}},Hr=function(t){var e={};return Nr(t,(function(t,i){(J(t)&&t.length>0||Z(t))&&(e[i]=t)})),e};var Gr=["herokuapp.com","vercel.app","netlify.app"];function Wr(t){var e=null==t?void 0:t.hostname;if(!J(e))return!1;var i=e.split(".").slice(-2).join(".");for(var r of Gr)if(i===r)return!1;return!0}function Vr(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 Kr(t){return"ph_toolbar_internal"===t.name}var Jr=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 Z(t)&&isFinite(t)&&Math.floor(t)===t});class Yr{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 Yr(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 Yr(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 Qr{generate(){var t=this.generateOrAbort();if(!K(t))return t;this.S=0;var e=this.generateOrAbort();if(K(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.C();else{if(this.S>=t+1e4)return;this.I++,this.I>4398046511103&&(this.S++,this.C())}return Yr.fromFieldsV7(this.S,Math.trunc(this.I/Math.pow(2,30)),this.I&Math.pow(2,30)-1,this.A.nextUint32())}C(){this.I=1024*this.A.nextUint32()+(1023&this.A.nextUint32())}constructor(){this.S=0,this.I=0,this.A=new ts}}var Xr,Zr=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&&!K(t.crypto)&&crypto.getRandomValues&&(Zr=t=>crypto.getRandomValues(t));class ts{nextUint32(){return this.R.length>this.O||(Zr(this.R),this.O=0),this.R[this.O++]}constructor(){this.R=new Uint32Array(8),this.O=1/0}}var es=()=>is().toString(),is=()=>(Xr||(Xr=new Qr)).generate(),rs="",ss=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var ns={N:()=>!!r,j(t){mi.error("cookieStore error: "+t)},P:Jr,H(t){var e;try{e=JSON.parse(ns.P(t))||{}}catch(t){}return e},F(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),rs)return rs;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_"+es();!rs&&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",rs=o)}return rs}(t);if(!i){var s=(t=>{var e=t.match(ss);return e?e[0]:""})(t);s!==i&&mi.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&&mi.warn("cookieStore warning: large cookie, len="+h.length),r.cookie=h,!0}catch(t){return!1}},q(t,e){if(null!=r&&r.cookie)try{ns.F(t,"",-1,e)}catch(t){return}}},os=null,as={N(){if(!Q(os))return os;var e=!0;if(K(t))e=!1;else try{var i="__mplssupport__";as.F(i,"xyz"),'"xyz"'!==as.P(i)&&(e=!1),as.q(i)}catch(t){e=!1}return e||mi.error("localStorage unsupported; falling back to cookie store"),os=e,e},j(t){mi.error("localStorage error: "+t)},P(e){try{return null==t?void 0:t.localStorage.getItem(e)}catch(t){as.j(t)}return null},H(t){try{return JSON.parse(as.P(t))||{}}catch(t){}return null},F(e,i){try{return null==t||t.localStorage.setItem(e,JSON.stringify(i)),!0}catch(t){as.j(t)}return!1},q(e){try{null==t||t.localStorage.removeItem(e)}catch(t){as.j(t)}}},ls=[$i,"distinct_id",Gi,Wi,br,yr,fr],us={},hs={N:()=>!0,j(t){mi.error("memoryStorage error: "+t)},P:t=>us[t]||null,H:t=>us[t]||null,F:(t,e)=>(us[t]=e,!0),q(t){delete us[t]}},ds=null,vs={N(){if(!Q(ds))return ds;if(ds=!0,K(t))ds=!1;else try{var e="__support__";vs.F(e,"xyz"),'"xyz"'!==vs.P(e)&&(ds=!1),vs.q(e)}catch(t){ds=!1}return ds},j(t){mi.error("sessionStorage error: ",t)},P(e){try{return null==t?void 0:t.sessionStorage.getItem(e)}catch(t){vs.j(t)}return null},H(t){try{return JSON.parse(vs.P(t))||null}catch(t){}return null},F(e,i){try{return null==t||t.sessionStorage.setItem(e,JSON.stringify(i)),!0}catch(t){vs.j(t)}return!1},q(e){try{null==t||t.sessionStorage.removeItem(e)}catch(t){vs.j(t)}}};class cs{constructor(t){this._instance=t}get qe(){return this._instance.config}get consent(){return this.si()?0:this.ai}isOptedOut(){return this.qe.cookieless_mode===Tr||this.isRejected()||-1===this.consent&&this.qe.cookieless_mode===Pr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.qe.opt_out_capturing_by_default}optInOut(t){this.oi.F(this.li,t?1:0,this.qe.cookie_expiration,this.qe.cross_subdomain_cookie,this.qe.secure_cookie)}reset(){this.oi.q(this.li,this.qe.cross_subdomain_cookie)}get li(){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 ai(){var t=this.oi.P(this.li);return ht(t)?1:j(dt,t)?0:-1}get oi(){var t=this.qe.opt_out_capturing_persistence_type,e="localStorage"===t?as:ns;if(!this.ui||this.ui!==e){this.ui=e;var i="localStorage"===t?ns:as;i.P(this.li)&&(this.ui.P(this.li)||this.optInOut(ht(i.P(this.li))),i.q(this.li,this.qe.cross_subdomain_cookie))}return this.ui}si(){return!!this.qe.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,v.doNotTrack].some((t=>ht(t)))}}function fs(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!G(r))return e;try{var s=r(e);return J(s)&&s?s:e}catch(t){return mi.error("Error in get_current_url, falling back to window.location.href",t),e}}var ps="__POSTHOG_TOOLBAR__",gs=1,_s=3,ms=11;function ys(t){return t instanceof Element&&(t.id===ps||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function bs(t){return!!t&&t.nodeType===gs}function ws(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function xs(t){return!!t&&t.nodeType===_s}function Ss(t){return!!t&&t.nodeType===ms&&bs(t.host)}var ks=1e3;function Es(t){return t?L(t).split(/\s+/):[]}function $s(e,i){var r=function(e){var i,r=null==t||null==(i=t.location)?void 0:i.href;return K(r)?void 0:fs(e,r)}(i);return!!(r&&e&&e.some((t=>r.match(t))))}function Ps(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 Es(e)}function Ts(t){return X(t)?null:L(t).split(/(\s+)/).filter((t=>Xs(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Fs(t){var e="";return qs(t)&&!Hs(t)&&t.childNodes&&t.childNodes.length&&Nr(t.childNodes,(function(t){var i;xs(t)&&t.textContent&&(e+=null!==(i=Ts(t.textContent))&&void 0!==i?i:"")})),L(e)}function Rs(t){var e;return K(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Cs=["a","button","form","input","select","textarea","label"];function Ms(t,e){if(K(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 Is(t){var e=t.parentNode;return!(!e||!bs(e))&&e}var As=[".ph-no-autocapture","[data-ph-no-autocapture]"],Os=["next","previous","prev",">","<"],Ds=[...Os,"+","-","−","–"],js=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Ls=[".ph-no-rageclick",".ph-no-capture"],Ns=["","text","search","email","password","url","tel","number"];function Bs(e,i){if(!t||zs(e))return!1;var r,s,n,o,a;if(et(i)?(r=!!i&&Ls,s=void 0,n=!1):(r=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Ls,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||!bs(t))&&(!!ws(t,"textarea")||(ws(t,"input")?j(Ns,(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=Us(e,!1).targetElementList;return!function(t,e){if(!1===t||K(t))return!1;var i;if(!0===t)i=Os;else{if(!H(t))return!1;if(t.length>10)return mi.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=>js(e,t)||js(r,t)))}))}(s,l.map((t=>{var e;return{safeText:Fs(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Ms(l,r)}var zs=t=>!t||ws(t,"html")||!bs(t),Us=(e,i)=>{if(!t||zs(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[e],n=e;n.parentNode&&!ws(n,"body");)if(Ss(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Is(n);if(!o)break;if(i||Cs.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 qs(t){for(var e=new Set,i=0,r=t;r.parentNode&&!ws(r,"body");r=r.parentNode){if(i++>=ks||e.has(r))return!1;e.add(r);var s=Ps(r);if(j(s,"ph-sensitive")||j(s,"ph-no-capture"))return!1}if(j(Ps(t),"ph-include"))return!0;var n=t.type||"";if(J(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!J(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 Hs(t){return!!(ws(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ws(t,"select")||ws(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Gs=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}))$"),Ws=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Vs=[16,15,14,13],Ks=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Js=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ys=/[0-9A-Za-z_]/;function Qs(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 Xs(t,e){if(void 0===e&&(e=!0),X(t))return!1;if(J(t)){t=L(t);var i=e?Gs.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(Ws.lastIndex=0;e=Ws.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Vs){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(Gs.test(a)&&Qs(a))return!0}}}return!1}(t);if(i)return!1;var r=e?Ks.test(t):function(t){var e;for(Js.lastIndex=0;e=Js.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&Ys.test(i)&&Ys.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Zs(t){var e=Fs(t);return Xs(e=(e+" "+tn(t)).trim())?e:""}function tn(t){var e="";return t&&t.childNodes&&t.childNodes.length&&Nr(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Fs(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+tn(t)).trim())}catch(t){mi.error("[AutoCapture]",t)}})),e}function en(t){return t.replace(/"|\\"/g,'\\"')}function rn(t){var e=t.attr__class;if(e)return H(e)?e:Es(e)}var sn=yi("[Dead Clicks]"),nn=()=>!0,on=t=>{var e,i=!(null==(e=t.instance.persistence)||!e.get_property(Di)),r=t.instance.config.capture_dead_clicks;return et(r)?r:!!W(r)||i};class an{get lazyLoadedDeadClicksAutocapture(){return this.hi}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({[Di]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.di((()=>{this.vi()})):this.stop()}di(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?sn.error("failed to load script",e):t()}))}vi(){var t;if(r){if(!this.hi&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=W(this.instance.config.capture_dead_clicks)?g({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.hi=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.hi.start(r),sn.info("starting...")}}else sn.error("`document` not found. Cannot start.")}stop(){this.hi&&(this.hi.stop(),this.hi=void 0,sn.info("stopping..."))}}var ln=yi("[SegmentIntegration]");var un="posthog-js";function hn(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=>g({},t,{stacktrace:t.stacktrace?g({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>g({},t,{platform:"web:javascript"})))}):void 0}))),_={$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&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+e.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(_)),e}}class dn{constructor(t,e,i,r,s,n){this.name=un,this.setupOnce=function(o){o(hn(t,{organization:e,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class vn{constructor(t){this.ci=(t,e,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(mi.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.fi=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.pi()}pi(){var t;this.gi=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.ci)}destroy(){var t;null==(t=this.gi)||t.call(this),this.gi=void 0}doPageView(e,i){var r,s=this.mi(e,i);return this.fi={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.mi(t,null==(e=this.fi)?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.fi)?void 0:t.pageViewId}}mi(t,e){var i=this.fi;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(!(K(n)||K(o)||K(a)||K(l)||K(u)||K(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?vt(o/n,0,1,mi):1,v=n>1?vt(a/n,0,1,mi):1,c=l>1?vt(u/l,0,1,mi):1,f=l>1?vt(h/l,0,1,mi):1;r=Br(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 cn=["flags","surveys"],fn={[Ei]:{exposure:"hidden"},[Ti]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[Fi]:{exposure:"hidden"},[Ri]:{exposure:"event"},[Ci]:{exposure:"hidden"},[Mi]:{exposure:"event"},[Ii]:{exposure:"hidden"},[Ai]:{exposure:"event"},[Oi]:{exposure:"event"},[Di]:{exposure:"event"},[ji]:{exposure:"hidden"},[Li]:{exposure:"event"},[Ni]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Gi]:{exposure:"hidden"},[Wi]:{exposure:"event"},[Bi]:{exposure:"event",shouldSkipFromEventProperties:t=>Q(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"},[Vi]:{exposure:"hidden",storageGroup:"flags"},[Ki]:{exposure:"hidden",storageGroup:"flags"},[Ji]:{exposure:"hidden"},[Yi]:{exposure:"hidden",storageGroup:"flags"},[Qi]:{exposure:"hidden",storageGroup:"flags"},[Xi]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Zi]:{exposure:"hidden",storageGroup:"flags"},[tr]:{exposure:"hidden"},[er]:{exposure:"hidden"},[ir]:{exposure:"hidden"},[rr]:{exposure:"hidden"},[sr]:{exposure:"hidden",storageGroup:"surveys"},[nr]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[or]:{exposure:"event"},[ar]:{exposure:"hidden"},[lr]:{exposure:"hidden"},[ur]:{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"},[hr]:{exposure:"hidden"},[dr]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[cr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[fr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[_r]:{exposure:"hidden"},[mr]:{exposure:"hidden"},[yr]:{exposure:"hidden"},[br]:{exposure:"hidden"},[zi]:{exposure:"event"},[Ui]:{exposure:"event"},[qi]:{exposure:"event"},[Hi]:{exposure:"event"},[Sr]:{exposure:"event"},[kr]:{exposure:"event"},[Er]:{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_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"}},pn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],gn=t=>{var e=fn[t];if(e)return e;for(var i of pn){var r=i[1];if(0===t.indexOf(i[0]))return r}},_n=(t,e)=>{try{return JSON.stringify(t,((t,e)=>"bigint"==typeof e?e.toString():e),e)}catch(e){return B(t)}},mn=t=>{var e=null==r?void 0:r.createElement("a");return K(e)?null:(e.href=t,e)},yn=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(!H(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(t){mi.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},bn=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("=");H(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},wn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},xn=(t,e)=>t>=e&&h(),Sn=(t,e,i,r)=>{if(0===t){if(h()){var s=e+1;return s===i&&r(),s}return e}return 0},kn="https?://(.*)",En=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],$n=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...En],Pn="",Tn=["li_fat_id"];function Fn(t,e,i){if(!r)return{};var s,n=e?[...En,...i||[]]:[],o=Rn(bn(r.URL,n,Pn),t),a=(s={},Nr(Tn,(function(t){var e=Jr(t);s[t]=e||null})),s);return Br(a,o)}function Rn(t,e){var i=$n.concat(e||[]),r={};return Nr(i,(function(e){var i=yn(t,e);r[e]=i||null})),r}function Cn(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(!Q(e)){s.$search_engine=e;var n=r?yn(r.referrer,i):"";n.length&&(s.ph_keyword=n)}return s}function Mn(){return navigator.language||navigator.userLanguage}var In="$direct";function An(){return(null==r?void 0:r.referrer)||In}function On(t,e,i){void 0===i&&(i=!1);var r=t?[...En,...e||[]]:[],n=i?be(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:An().substring(0,1e3),u:o?bn(o,r,Pn):void 0}}function Dn(t,e){var i;void 0===e&&(e=!1);var r=t.r,s=t.u,n=e?be(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==In?In:null==(i=mn(r))?void 0:i.host};if(n){o.$current_url=n;var a=mn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=Rn(n);Br(o,l)}if(r){var u=Cn(r);Br(o,u)}return o}function jn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function Ln(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var Nn={flags:cr,surveys:nr},Bn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],zn="main";class Un{constructor(e,i,r){if(void 0===r&&(r=!0),this.yi={},this.bi=!1,this.wi=!1,this.qe=e,this.ki=r,this.props={},this.xi=void 0,this.Si=(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.oi=this.Ci(e),this.wi=this.Mi(e),this.load(),e.debug&&mi.info("Persistence loaded",e.persistence,g({},this.props)),this.update_config(e,e,i),this.save(),t){var s=()=>this.flush();Vr(t,"beforeunload",s,{capture:!1}),Vr(t,"pagehide",s,{capture:!1})}}Ti(){var t,e=null==(t=this.qe)?void 0:t.persistence_save_debounce_ms;return Z(e)&&e>0?e:0}isDisabled(){return!!this.Ei}Ci(e){-1===Bn.indexOf(e.persistence.toLowerCase())&&(mi.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=[...ls,...e];return g({},as,{H(t){try{var e={};try{e=ns.H(t)||{}}catch(t){}var r,s=JSON.parse(as.P(t)||"{}");if(i){var n={};for(var o in e){var a=e[o];Q(a)||""===a||(n[o]=a)}r=Br(s,n)}else r=Br(e,s);return as.F(t,r),r}catch(t){}return null},F(t,e,i,s,n,o){var a=as.F(t,e,void 0,void 0,o);try{var l={};r.forEach((t=>{e[t]&&(l[t]=e[t])})),Object.keys(l).length&&ns.F(t,l,i,s,n,o)}catch(t){as.j(t)}return a},q(e,i){try{null==t||t.localStorage.removeItem(e),ns.q(e,i)}catch(t){as.j(t)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&as.N()?(i=as,s=!0):"localstorage+cookie"===n&&r.N()?(i=r,s=!0):"sessionstorage"===n&&vs.N()?i=vs:"memory"===n?i=hs:"cookie"===n?i=ns:r.N()?(i=r,s=!0):i=ns,this.bi=s,i}Ii(t){return this.Si+"__"+t}Mi(t){return this.bi&&!!t.split_storage}properties(){var t={};return Nr(this.props,((e,i)=>{var r=gn(i);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e))return;t[i]=e}})),t}load(){if(!this.Ei){var t=this.oi.H(this.Si);t&&(this.props=Br({},t)),this.wi&&this.Pi()}}Pi(){for(var t of cn){var e=as.H(this.Ii(t));if(e&&!V(e)){var i=this.Ri(t);i.persisted=!0,this.Ai(t)||(i.fingerprint=this.Fi(e,t)),this.Li(t,e)||Br(this.props,e)}}}Ai(t){return Object.keys(this.props).some((e=>{var i;return(null==(i=gn(e))?void 0:i.storageGroup)===t}))}Li(t,e){var i=Nn[t];if(!i)return!1;var r=e[i],s=this.props[i];return Z(r)&&Z(s)&&s>r}refreshKey(t){var e;if(!this.Ei){var i=this.wi?null==(e=gn(t))?void 0:e.storageGroup:void 0,r=i?as.H(this.Ii(i)):this.oi.H(this.Si);if(r&&t in r)this.Oi(t,r[t]);else{if(i){var s=this.oi.H(this.Si);if(s&&t in s)return void this.Oi(t,s[t])}this.Di(t)}}}save(){if(!this.Ei){var t=this.Ti();t>0?K(this.$i)&&(this.$i=setTimeout((()=>{this.$i=void 0,this.Ni()}),t)):this.Ni()}}flush(){K(this.$i)||(clearTimeout(this.$i),this.$i=void 0,this.Ni())}Ni(){this.Ei||(this.wi?this.qi():this.ji(this.oi,this.Si,this.props,zn))}qi(){var t=this.Bi(),e=t.main,i=t.groups;for(var r of(this.ji(this.oi,this.Si,e,zn),cn)){var s,n=i[r];(!V(n)||null!=(s=this.yi[r])&&s.persisted)&&this.ji(as,this.Ii(r),n,r)}}Bi(){var t={},e={flags:{},surveys:{}};return Nr(this.props,((i,r)=>{var s,n=null==(s=gn(r))?void 0:s.storageGroup;n?e[n][r]=i:t[r]=i})),{main:t,groups:e}}Fi(t,e){if(e===zn)return JSON.stringify(t)+"|"+this.Hi+"|"+this.Ui+"|"+this.zi;var i={};return Nr(t,((t,e)=>{var r;i[e]=null!=(r=gn(e))&&r.volatile?"__volatile__":t})),JSON.stringify(i)}ji(t,e,i,r){var s=this.Ri(r);if(r===zn||s.dirty||K(s.fingerprint)){var n;try{if((n=this.Fi(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(t){n=void 0}t.F(e,i,this.Hi,this.Ui,this.zi,this.qe.debug)?(s.dirty=!1,r!==zn&&(s.persisted=!0),K(n)||(s.fingerprint=n)):this.qe.debug&&mi.warn('failed to persist storage entry "'+e+'"; will retry on next save')}}remove(t){var e=(void 0===t?{}:t).keepGroupEntries,i=void 0!==e&&e;if(K(this.$i)||(clearTimeout(this.$i),this.$i=void 0),this.oi.q(this.Si,!1),this.oi.q(this.Si,!0),!i&&this.ki)for(var r of cn)as.q(this.Ii(r));i?delete this.yi[zn]:this.yi={}}clear(){this.remove(),this.props={}}register_once(t,e,i){if(W(t)){K(e)&&(e="None"),this.Hi=K(i)?this.Wi:i;var r=!1;if(Nr(t,((t,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==e||(this.Oi(i,t),r=!0)})),r)return this.save(),!0}return!1}register(t,e){if(W(t)){this.Hi=K(e)?this.Wi:e;var i=!1;if(Nr(t,((e,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==e||W(e)||H(e))&&(this.Oi(r,e),i=!0)})),i)return this.save(),!0}return!1}unregister(t){var e="string"==typeof t?[t]:t,i=!1;for(var r of e)r in this.props&&(this.Di(r),i=!0);i&&this.save()}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.xi){var e=Fn(this.qe.custom_campaign_params,this.qe.mask_personal_data_properties,this.qe.custom_personal_data_properties);V(Hr(e))||this.register(e),this.xi=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?Cn(t):{})}update_referrer_info(){var t;this.register_once({$referrer:An(),$referring_domain:null!=r&&r.referrer&&(null==(t=mn(r.referrer))?void 0:t.host)||In},void 0)}set_initial_person_info(){this.props[_r]||this.props[mr]||this.register_once({[yr]:On(this.qe.mask_personal_data_properties,this.qe.custom_personal_data_properties,this.qe.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};Nr([mr,_r],(e=>{var i=this.props[e];i&&Nr(i,(function(e,i){t["$initial_"+N(i)]=e}))}));var e=this.props[yr];if(e){var i=function(t,e){void 0===e&&(e=!1);var i=Dn(t,e),r={};return Nr(i,(function(t,e){r["$initial_"+N(e)]=t})),r}(e,this.qe.disable_capture_url_hashes);Br(t,i)}return t}safe_merge(t){return Nr(this.props,(function(e,i){i in t||(t[i]=e)})),t}update_config(t,e,i){this.Wi=this.Hi=t.cookie_expiration,this.set_disabled(t.disable_persistence||!!i),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie);var r=t.persistence!==e.persistence||!((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||[]),s=r?this.Ci(t):this.oi,n=this.Mi(t);if(r||n!==this.wi){var o=this.props;this.clear(),this.oi=s,this.wi=n,this.props=o,this.save()}}set_disabled(t){this.Ei=t,this.Ei?this.remove():this.save()}set_cross_subdomain(t){t!==this.Ui&&(this.Ui=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.zi&&(this.zi=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var i=this.props[Fi]||{};i[t]=e,this.Oi(Fi,i),this.save()}remove_event_timer(t){var e=this.props[Fi]||{},i=e[t];return K(i)||(delete e[t],this.Oi(Fi,e),this.save()),i}get_property(t){return this.props[t]}set_property(t,e){this.Oi(t,e),this.save()}Oi(t,e){var i;this.props[t]=e,null!=(i=gn(t))&&i.volatile||this.Vi(t)}Di(t){delete this.props[t],this.Vi(t)}Vi(t){var e,i=null==(e=gn(t))?void 0:e.storageGroup;i&&(this.Ri(i).dirty=!0)}Ri(t){return this.yi[t]||(this.yi[t]={})}}function qn(t){var e=!0;return{dispose(){if(e){e=!1;var i=t();i&&G(i.then)&&i.then(void 0,(()=>{}))}}}}var Hn="gzip-js",Gn="base64",Wn="events",Vn="cancelEvents",Kn="survey shown",Jn="survey dismissed",Yn="survey sent",Qn="popover",Xn=yi("[RateLimiter]");class Zn{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=>{Xn.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void Xn.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(gr))&&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=(Z(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Zi(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(gr,a),{isRateLimited:l,remainingTokens:a.tokens}}Gi(t){var e=this.instance.config.property_denylist;return!H(e)||!e.includes(t)}Qi(){var t;if(this.Gi("$current_url")&&this.Gi("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}Zi(t){var e,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.Qi(),o=this.Gi("$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()t(this.remoteConfig))):t()}Ji(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 to.info("Using preloaded remote config",this.remoteConfig),this.Yi(this.remoteConfig),void this.Xi();if(this._instance.tr())return void to.warn("Remote config is disabled. Falling back to local config.");this.Ki((t=>{if(!t)return to.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ji((t=>{this.Yi(t.json,t),this.Xi()}));this.Yi(t),this.Xi()}))}catch(t){to.error("Error loading remote config",t),this.Yi()}}stop(){this.er&&(clearInterval(this.er),this.er=void 0)}refresh(){!this._instance.tr()&&r&&"hidden"!==r.visibilityState&&this._instance.reloadFeatureFlags()}Xi(){var t;if(!this.er){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.er=setInterval((()=>{this.refresh()}),e))}}Yi(t,e){!t&&e&&(0===e.statusCode?e.error||to.warn("Failed to fetch remote config from PostHog."):to.error("Failed to fetch remote config from PostHog."));try{this._instance.Yi(t?{ok:!0,config:t}:{ok:!1})}catch(t){to.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){to.error("Error loading feature flags",t)}}}var io=Uint8Array,ro=Uint16Array,so=Uint32Array,no=new io([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]),oo=new io([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]),ao=new io([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lo=function(t,e){for(var i=new ro(31),r=0;31>r;++r)i[r]=e+=1<r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},uo=lo(no,2),ho=uo[1];uo[0][28]=258,ho[258]=28;for(var vo=lo(oo,0)[1],co=new ro(32768),fo=0;32768>fo;++fo){var po=(43690&fo)>>>1|(21845&fo)<<1;co[fo]=((65280&(po=(61680&(po=(52428&po)>>>2|(13107&po)<<2))>>>4|(3855&po)<<4))>>>8|(255&po)<<8)>>>1}var go=function(t,e,i){for(var r=t.length,s=0,n=new ro(e);r>s;++s)++n[t[s]-1];var o,a=new ro(e);for(s=0;e>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new ro(1<s;++s)if(t[s])for(var u=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<=d;++d)o[co[d]>>>l]=u}else for(o=new ro(r),s=0;r>s;++s)o[s]=co[a[t[s]-1]++]>>>15-t[s];return o},_o=new io(288);for(fo=0;144>fo;++fo)_o[fo]=8;for(fo=144;256>fo;++fo)_o[fo]=9;for(fo=256;280>fo;++fo)_o[fo]=7;for(fo=280;288>fo;++fo)_o[fo]=8;var mo=new io(32);for(fo=0;32>fo;++fo)mo[fo]=5;var yo=go(_o,9,0),bo=go(mo,5,0),wo=function(t){return(t/8>>0)+(7&t&&1)},xo=function(t,e,i){(null==i||i>t.length)&&(i=t.length);var r=new(t instanceof ro?ro:t instanceof so?so:io)(i-e);return r.set(t.subarray(e,i)),r},So=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8},ko=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8,t[r+2]|=i>>>16},Eo=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 io(0),0];if(1==s){var o=new io(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 ro(v+1),f=$o(i[h-1],c,0);if(f>e){r=0;var p=0,g=f-e,_=1<r;++r){var m=n[r].s;if(e>=c[m])break;p+=_-(1<>>=g;p>0;){var y=n[r].s;e>c[y]?p-=1<=0&&p;--r){var b=n[r].s;c[b]==e&&(--c[b],++p)}f=e}return[new io(c),f]},$o=function(t,e,i){return-1==t.s?Math.max($o(t.l,e,i+1),$o(t.r,e,i+1)):e[t.s]=i},Po=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new ro(++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]},To=function(t,e){for(var i=0,r=0;e.length>r;++r)i+=t[r]*e[r];return i},Fo=function(t,e,i){var r=i.length,s=wo(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)},Ro=function(t,e,i,r,s,n,o,a,l,u,h){So(e,h++,i),++s[256];for(var d=Eo(s,15),v=d[0],c=d[1],f=Eo(n,15),p=f[0],g=f[1],_=Po(v),m=_[0],y=_[1],b=Po(p),w=b[0],x=b[1],S=new ro(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=Eo(S,7),P=E[0],T=E[1],F=19;F>4&&!P[ao[F-1]];--F);var R,C,M,I,A=u+5<<3,O=To(s,_o)+To(n,mo)+o,D=To(s,v)+To(n,p)+o+14+3*F+To(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(O>=A&&D>=A)return Fo(e,h,t.subarray(l,l+u));if(So(e,h,1+(O>D)),h+=2,O>D){R=go(v,c,0),C=v,M=go(p,g,0),I=p;var j=go(P,T,0);for(So(e,h,y-257),So(e,h+5,x-1),So(e,h+10,F-4),h+=14,k=0;F>k;++k)So(e,h+3*k,P[ao[k]]);h+=3*F;for(var L=[m,w],N=0;2>N;++N){var B=L[N];for(k=0;B.length>k;++k)So(e,h,j[z=31&B[k]]),h+=P[z],z>15&&(So(e,h,B[k]>>>5&127),h+=B[k]>>>12)}}else R=yo,C=_o,M=bo,I=mo;for(k=0;a>k;++k)if(r[k]>255){var z;ko(e,h,R[257+(z=r[k]>>>18&31)]),h+=C[z+257],z>7&&(So(e,h,r[k]>>>23&31),h+=no[z]);var U=31&r[k];ko(e,h,M[U]),h+=I[U],U>3&&(ko(e,h,r[k]>>>5&8191),h+=oo[U])}else ko(e,h,R[r[k]]),h+=C[r[k]];return ko(e,h,R[256]),h+C[256]},Co=new so([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Mo=function(){for(var t=new so(256),e=0;256>e;++e){for(var i=e,r=9;--r;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),Io=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function Ao(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=Mo[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 io(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=Fo(l,u,t.subarray(h,d)):(l[h]=!0,u=Fo(l,u,t.subarray(h,o)))}else{for(var v=Co[e-1],c=v>>>13,f=8191&v,p=(1<h;++h){var R=b(h),C=32767&h,M=_[R];if(g[C]=M,_[R]=C,h>=T){var I=o-h;if((k>7e3||P>24576)&&I>423){u=Ro(t,l,0,w,x,S,E,P,F,h-F,u),P=k=E=0,F=h;for(var A=0;286>A;++A)x[A]=0;for(A=0;30>A;++A)S[A]=0}var O=2,D=0,j=f,L=C-M&32767;if(I>2&&R==b(h-L))for(var N=Math.min(c,I)-1,B=Math.min(32767,h),z=Math.min(258,I);B>=L&&--j&&C!=M;){if(t[h+O]==t[h+O-L]){for(var U=0;z>U&&t[h+U]==t[h+U-L];++U);if(U>O){if(O=U,D=L,U>N)break;var q=Math.min(L,U-2),H=0;for(A=0;q>A;++A){var G=h-L+A+32768&32767,W=G-g[G]+32768&32767;W>H&&(H=W,M=G)}}}L+=(C=M)-(M=g[C])+32768&32767}if(D){w[P++]=268435456|ho[O]<<18|vo[D];var V=31&ho[O],K=31&vo[D];E+=no[V]+oo[K],++x[257+V],++S[K],T=h+O,++k}else w[P++]=t[h],++x[t[h]]}}u=Ro(t,l,!0,w,x,S,E,P,F,h-F,u)}return xo(a,0,r+wo(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&&Io(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),Io(u,h-8,i.d()),Io(u,h-4,r),u}var Oo=!!o||!!n,Do="text/plain",jo=!1,Lo=(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:"")},No=function(t,e,i){var r;void 0===i&&(i=!0);var s=t.split("?"),n=s[0],o=s[1],a=g({},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 Nr(t,(function(t,e){K(t)||K(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},Bo=t=>{if(t.ir)return t.ir;var e=t.data,i=t.compression;if(e){if(i===Hn){var r=Ao(function(t,e){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new io(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 io(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 xo(r,0,s)}(_n(e)),{mtime:0});return{contentType:Do,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Gn){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(parseInt(e,16))))):t}(_n(e)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:_n(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=_n(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},zo=t=>{var e,i,r=()=>"sendBeacon"===t.transport?{url:No(t.url,{compression:Gn}),encodedBody:Bo(g({},t,{compression:Gn,ir:void 0}))}:{url:Lo(t.url,"compression"),encodedBody:Bo(g({},t,{compression:void 0,ir:void 0}))};try{e=Bo(t)}catch(e){if(R(t.compression,yn(t.url,"compression")))return mi.error("Failed to gzip request body, sending uncompressed payload",e),r();throw e}return e&&R(t.compression,yn(t.url,"compression"))&&!((i=e.body)instanceof ArrayBuffer?F(new Uint8Array(i)):ArrayBuffer.isView(i)&&F(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(jo=!0,r()):{url:t.url,encodedBody:e}},Uo=t=>{try{return zo(t)}catch(e){return mi.error(e),void(null==t.callback||t.callback({statusCode:0,error:e}))}},qo=function(){var t=p((function*(t){var e=_n(t.data),i=yield function(t,e,i){return A.apply(this,arguments)}(e,c.DEBUG,{rethrow:!0});if(!i)return t;var r=yield i.arrayBuffer();return g({},t,{ir:{contentType:Do,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}}(),Ho=/Failed to fetch|NetworkError|Load failed/i,Go=t=>"TypeError"===(null==t?void 0:t.name)&&Ho.test((null==t?void 0:t.message)||""),Wo=t=>{var e=Uo(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;Nr(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)||Go(e)?mi.warn(e):mi.error(e),null==t.callback||t.callback({statusCode:0,error:e})};try{var p;n(i,g({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.rr&&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){mi.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Vo=t=>{try{var e,r=zo(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=H(t.data)?t.data:null==(e=t.data)?void 0:e.batch;if(H(h)&&h.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(h.length/2),v=e=>H(t.data)?e:g({},t.data,{batch:e});return Vo(g({},t,{data:v(h.slice(0,d))})),void Vo(g({},t,{data:v(h.slice(d))}))}mi.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Wo(g({},t,{rr:!0}))}catch(t){mi.warn("Beacon send failed",t)}},Ko=(t,e,i,r)=>{var s="query"===r?"POST"===e?"sent_at":"_":void 0;return No(i===Hn?Lo(t,"compression"):t,g({},s?{[s]:Date.now().toString()}:{},i===Hn?{}:{compression:i}))},Jo=[];n&&Jo.push({transport:"fetch",method:Wo}),o&&Jo.push({transport:"XHR",method(t){var e=Uo(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;Nr(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&&Jo.push({transport:"sendBeacon",method:Vo});var Yo=3e3;class Qo{constructor(t,e){this.nr=!0,this.sr=[],this.ar=vt((null==e?void 0:e.flush_interval_ms)||Yo,250,5e3,mi.createLogger("flush interval"),Yo),this.lr=t}enqueue(t){this.sr.push(t),this.ur||this.hr()}unload(){this.dr();var t=this.sr.length>0?this.vr():{},e=Object.values(t);[...e.filter((t=>0===t.url.indexOf("/e"))),...e.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.cr(g({},t,{transport:"sendBeacon"}))}))}enable(){this.nr=!1,this.hr()}hr(){var t=this;this.nr||(this.ur=setTimeout((()=>{if(this.dr(),this.sr.length>0){var e=this.vr(),i=function(){var i=e[r],s=(new Date).getTime();i.data&&H(i.data)&&Nr(i.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.cr(i)};for(var r in e)i()}}),this.ar))}cr(t){try{this.lr(t)}catch(t){mi.error(t)}}dr(){clearTimeout(this.ur),this.ur=void 0}vr(){var t={};return Nr(this.sr,(e=>{var i,r=e,s=(r?r.batchKey:null)||r.url;K(t[s])&&(t[s]=g({},r,{data:[]})),null==(i=t[s].data)||i.push(r.data)})),this.sr=[],t}}var Xo=["retriesPerformedSoFar"];class Zo{constructor(e){this.pr=!1,this.gr=3e3,this.sr=[],this._instance=e,this.sr=[],this.mr=!0,!K(t)&&"onLine"in t.navigator&&(this.mr=t.navigator.onLine,this.yr=()=>{this.mr=!0,this.br()},this._r=()=>{this.mr=!1},Vr(t,"online",this.yr),Vr(t,"offline",this._r))}get length(){return this.sr.length}retriableRequest(t){var e=t.retriesPerformedSoFar,i=_(t,Xo);tt(e)&&(i.url=No(i.url,{retry_count:e})),this._instance._send_request(g({},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.Lt(g({retriesPerformedSoFar:e},i));0===t.statusCode&&mi.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)}}))}Lt(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.sr.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),mi.warn(s),this.pr||(this.pr=!0,this.wr())}wr(){if(this.kr&&clearTimeout(this.kr),0===this.sr.length)return this.pr=!1,void(this.kr=void 0);this.kr=setTimeout((()=>{this.mr&&this.sr.length>0&&this.br(),this.wr()}),this.gr)}br(){var t=Date.now(),e=[],i=this.sr.filter((i=>t>i.retryAt||(e.push(i),!1)));if(this.sr=e,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.kr&&(clearTimeout(this.kr),this.kr=void 0),this.pr=!1,K(t)||(this.yr&&(t.removeEventListener("online",this.yr),this.yr=void 0),this._r&&(t.removeEventListener("offline",this._r),this._r=void 0)),this.sr)){var i=e.requestOptions;try{this._instance._send_request(g({},i,{transport:"sendBeacon"}))}catch(t){mi.error(t)}}this.sr=[]}}class ta{constructor(t){this.Sr=()=>{var t,e,i,r;this.Cr||(this.Cr={});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.Cr.lastScrollY=Math.ceil(n),this.Cr.maxScrollY=Math.max(n,null!==(t=this.Cr.maxScrollY)&&void 0!==t?t:0),this.Cr.maxScrollHeight=Math.max(o,null!==(e=this.Cr.maxScrollHeight)&&void 0!==e?e:0),this.Cr.lastContentY=a,this.Cr.maxContentY=Math.max(a,null!==(i=this.Cr.maxContentY)&&void 0!==i?i:0),this.Cr.maxContentHeight=Math.max(l,null!==(r=this.Cr.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get Mr(){return this._instance.config.scroll_root_selector}getContext(){return this.Cr}resetContext(){var t=this.Cr;return setTimeout(this.Sr,0),t}startMeasuringScrollPosition(){Vr(t,"scroll",this.Sr,{capture:!0}),Vr(t,"scrollend",this.Sr,{capture:!0}),Vr(t,"resize",this.Sr)}scrollElement(){if(!this.Mr)return null==t?void 0:t.document.documentElement;var e=H(this.Mr)?this.Mr:[this.Mr];for(var i of e){var r=null==t?void 0:t.document.querySelector(i);if(r)return r}}Tr(e){var i="y"===e?"scrollTop":"scrollLeft";if(this.Mr){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.Tr("y")}scrollX(){return this.Tr("x")}}var ea=t=>On(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 ia{constructor(t,e,i,r){this.Er=t=>{var e=this.Ir();if(!e||e.sessionId!==t){var i={sessionId:t,props:this.Pr(this._instance)};this.Rr.register({[pr]:i})}},this._instance=t,this.Ar=e,this.Rr=i,this.Pr=r||ea,this.Ar.onSessionId(this.Er)}Ir(){return this.Rr.props[pr]}getSetOnceProps(){var t,e=null==(t=this.Ir())?void 0:t.props;return e?"r"in e?Dn(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 Nr(Hr(this.getSetOnceProps()),((e,i)=>{"$current_url"===i&&(i="url"),t["$session_entry_"+N(i)]=e})),t}}class ra{on(t,e){return this.Fr[t]||(this.Fr[t]=[]),this.Fr[t].push(e),()=>{this.Fr[t]=this.Fr[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Fr[t]||[])i(e);for(var r of this.Fr["*"]||[])r(t,e)}constructor(){this.Fr={}}}var sa=yi("[SessionId]"),na=864e5;class oa{on(t,e){return this.Lr.on(t,e)}constructor(t,e,i){var r;if(this.Or=null,this.Dr=[],this.$r=void 0,this.Nr=!1,this.Lr=new ra,this.qr=(t,e)=>!(!tt(t)||!tt(e))&&Math.abs(t-e)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===Tr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qe=t.config,this.Rr=t.persistence,this.jr=void 0,this.Br=void 0,this._sessionStartTimestamp=null,this.Hr=void 0,this._sessionActivityTimestamp=null,this.Ur=e||es,this.zr=i||es;var s=this.qe.persistence_name||this.qe.token;if(this._sessionTimeoutMs=1e3*vt(this.qe.session_idle_timeout_seconds||1800,60,36e3,sa.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Wr(),this.Vr="ph_"+s+"_window_id",this.Zr="ph_"+s+"_primary_window_exists",this.Gr()){var n=vs.H(this.Vr),o=vs.H(this.Zr);n&&!o?this.jr=n:vs.q(this.Vr),vs.F(this.Zr,!0)}null!=(r=this.qe.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.qe.bootstrap.sessionID),this.Qr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return K(this.Dr)&&(this.Dr=[]),this.Dr.push(t),this.Br&&t(this.Br,this.jr),()=>{this.Dr=this.Dr.filter((e=>e!==t))}}Gr(){return"memory"!==this.qe.persistence&&!this.Rr.Ei&&vs.N()}Kr(t){t!==this.jr&&(this.jr=t,this.Gr()&&vs.F(this.Vr,t))}Jr(){return this.jr?this.jr:this.Gr()?vs.H(this.Vr):null}Yr(t){var e=this.Or;return!Q(e)&&!Q(t)&&5e3>Math.abs(t-e)}Xr(t,e,i){var r=e!==this._sessionActivityTimestamp,s=!(t!==this.Br||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=e,this.Br=t,s&&!r||s&&this.Yr(e)||(this.Or=e,this.Rr.register({[Gi]:[e,t,i]}))}tn(){var t,e=null==(t=this.qe)?void 0:t.persistence_save_debounce_ms;return tt(e)&&e>0}en(){this.tn()?this.Rr.refreshKey(Gi):(this.Rr.flush(),this.Rr.load())}rn(){var t;if(!Q(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Or){this.en();var e=this.nn();e[1]===this.Br&&e[2]===this._sessionStartTimestamp&&(this.Or=this._sessionActivityTimestamp,this.Rr.register({[Gi]:[this._sessionActivityTimestamp,null!==(t=this.Br)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Rr.flush())}}sn(){var t=this.nn()[0],e=tt(t)?t:0,i=tt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,i)}an(t){return this.en(),this.qr(t,this.sn())}nn(){var t=this.Rr.props[Gi];return H(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Or=null,this.Hr=void 0,clearTimeout(this.ln),this.ln=void 0,this.Xr(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 sa.error("Bootstrap sessionID cannot be in the future"):i}catch(t){return void sa.error("Invalid sessionID in bootstrap",t)}}(t);return!K(i)&&(e?this.Hr={sessionId:t,sessionStartTimestamp:i}:this.Xr(t,(new Date).getTime(),i),!0)}destroy(){this.Nr=!0,this.rn(),clearTimeout(this.ln),this.ln=void 0,this.$r&&t&&(t.removeEventListener(Ir,this.$r,{capture:!1}),this.$r=void 0),this.Dr=[]}Qr(){this.$r=()=>{this.rn(),this.Gr()&&vs.q(this.Zr)},Vr(t,Ir,this.$r,{capture:!1})}checkAndGetSessionAndWindowId(t,e){if(void 0===t&&(t=!1),void 0===e&&(e=null),this.qe.cookieless_mode===Tr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=e||(new Date).getTime(),r=this.nn(),s=r[1],n=r[2],o=this.sn(),a=this.Jr(),l=this.Hr,u=!!l&&(l.sessionStartTimestamp>i+6e4||i-l.sessionStartTimestamp>na),h=l?u:tt(n)&&Math.abs(i-n)>na,d=!1,v=!1,c=!s||!!l,f=s,p=!c&&!t&&this.qr(i,o);if(p){(p=this.an(i))||sa.info("cross-tab refresh kept the session alive",{sessionId:s});var g=this.nn();s=g[1],n=g[2]}if(c||p||h){var _=l&&!u;s=_?l.sessionId:this.Ur(),a=this.zr(),sa.info("new session ID assigned",{sessionId:s,windowId:a,bootstrapped:!!_,changeReason:{noSessionId:c,activityTimeout:p,sessionPastMaximumLength:h}}),n=_?l.sessionStartTimestamp:i,this.Hr=void 0,d=!0}else a||(a=this.zr(),d=!0),(v=s!==f)&&(sa.info("adopted cross-tab session id",{sessionId:s,windowId:a}),d=!0);var m=tt(o)&&t&&!h?o:i,y=tt(n)?n:(new Date).getTime();this.Kr(a),this.Xr(s,m,y),t||this.Wr();var b={noSessionId:c,activityTimeout:p,sessionPastMaximumLength:h,crossTabAdoption:v};return d&&this.Dr.forEach((t=>t(s,a,b))),{sessionId:s,windowId:a,sessionStartTimestamp:y,changeReason:d?b:void 0,lastActivityTimestamp:o}}Wr(){this.Nr||(clearTimeout(this.ln),this.ln=setTimeout((()=>{if(!this.Nr)if(this.an((new Date).getTime())){var t=this.Br;this.resetSessionId(),this.Lr.emit("forcedIdleReset",{idleSessionId:t})}else this.Wr()}),1.1*this.sessionTimeoutMs))}}var aa=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&D(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>D(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver};function la(){return(la=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 J(r)&&r.length>0?r:void 0}catch(t){return void mi.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}var ua=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 _n({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}var da={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=>ua(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!ua(e,t))))),icontains:(t,e)=>e.map(va).some((e=>t.map(va).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(va).every((e=>t.map(va).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=>it.toLowerCase();function ca(t,e){return!t||Object.entries(t).every((t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(K(r)||Q(r))return!1;var s=[String(r)],n=da[i.operator];return!!n&&n(i.values,s)}))}var fa="custom",pa="i.posthog.com",ga=/^\/static\//,_a=["/s/","/e/","/i/"];class ma{constructor(t){this.un={},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("."+pa,".posthog.com")),"https://app.posthog.com"===e?"https://us.posthog.com":e}get region(){return this.un[this.apiHost]||(this.un[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":fa),this.un[this.apiHost]}hn(t){if(ga.test(t)){var e=this.instance.config.asset_host;if("string"==typeof e)return e.trim().replace(/\/$/,"")||void 0}}dn(t){var e=mn(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}vn(t,e,i){if("ui"===t)return i;var r=i,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=mn(i))?void 0:n.href)||i;r=s(new URL(o)).toString()}if(s&&"api"===t&&_a.some((t=>0===e.indexOf(t)))){var a=this.dn(r);if(a){var l,u=this.apiHost,h=this.cn;(null==(l=h)?void 0:l.apiHost)===u&&h.rewriteRequestPath===s||(h={apiHost:u,rewriteRequestPath:s,urls:new Set},this.cn=h),h.urls.add(a)}}return r}isIngestionEndpoint(t){var e=this.cn,i=this.dn(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.vn(t,e,this.uiHost+e);if("flags"===t)return this.vn(t,e,this.flagsApiHost+e);if("assets"===t){var i=this.hn(e);if(i)return this.vn(t,e,""+i+e)}if(this.region===fa)return this.vn(t,e,this.apiHost+e);var r=pa+e;switch(t){case"assets":return this.vn(t,e,"https://"+this.region+"-assets."+r);case"api":return this.vn(t,e,"https://"+this.region+"."+r)}}}function ya(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var ba=yi("[Surveys]"),wa="seenSurvey_",xa=t=>{try{var e=(t=>((t,e)=>""+t+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(wa,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){ba.error("Failed to persist survey seen state",t)}},Sa=["popover","widget","api"],ka={ignoreConditions:!1,ignoreDelay:!1,displayType:Qn},Ea=yi("[PostHog ExternalIntegrations]"),$a={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Pa{constructor(t){this._instance=t}di(t,e){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,t,(t=>{if(t)return Ea.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.di($a[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 Ta{constructor(t,e){this.st=t,this.fn=e,this.pn=new Map,this.gn=!1}add(t){var e=this;return p((function*(){if(e.gn)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.pn.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.pn.set(t.name,t);try{var i=t.setup(e.fn);i&&(yield i)}catch(i){var r=e.pn.get(t.name)===t;r&&e.pn.delete(t.name),e.st.error('Failed to set up browser extension "'+t.name+'"',i),r&&e.mn(t)}}))()}dispose(){if(!this.gn){this.gn=!0;var t=Array.from(this.pn.values()).reverse();for(var e of(this.pn.clear(),t))this.mn(e)}}mn(t){try{var e=null==t.dispose?void 0:t.dispose();e&&G(e.then)&&e.then(void 0,(e=>{this.st.error('Failed to dispose browser extension "'+t.name+'"',e)}))}catch(e){this.st.error('Failed to dispose browser extension "'+t.name+'"',e)}}}class Fa{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);K(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 Ra="extensionsRemoteConfig";class Ca{constructor(t){this.gn=!1,this.instance=t,this.st=mi,this.yn=t.bn,this.kv=new Fa(t),this.onEvent=t=>qn(this.instance.on("eventCaptured",(e=>{try{t({event:e.event,properties:e.properties})}catch(t){this.st.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.gn)return qn((()=>{}));var e=e=>{try{t(e)}catch(t){this.st.error("Browser extension remote config listener failed",t)}},i=this.instance._n.on(Ra,e);return this.yn&&e(this.yn),qn(i)},this.wn=new Ta(mi.createLogger("[BrowserExtensions]"),this)}get logger(){return this.st}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property($i))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property($i);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.wn.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 qn(this.instance.kn(t))}handleRemoteConfig(t){this.gn||(this.yn=t,this.instance._n.emit(Ra,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?No(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.gn||(this.gn=!0,this.wn.dispose())}}var Ma={},Ia=0,Aa=()=>{},Oa='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Da="Surveys module not available",ja="sanitize_properties is deprecated. Use before_send instead",La="Invalid value for property_denylist config: ",Na=["token","distinct_id",xr],Ba="posthog",za=!Oo&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla")),Ua=e=>{var i;return g({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Wr(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Aa,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&&J(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){mi.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:Cr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Yo},error_tracking:{},_onCapture:Aa},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Ds,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)}))(e))},qa=[["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"]],Ha=t=>{var e={};for(var i of qa){var r=i[0],s=i[1];K(t[r])||(e[s]=t[r])}var n=Br({},e,t),o=t.__preview_external_dependency_versioned_paths;return K(o)||(K(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),J(o)&&K(t.asset_host)&&(n.asset_host=o)),H(t.property_blacklist)&&(K(t.property_denylist)?n.property_denylist=t.property_blacklist:H(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:mi.error(La+t.property_denylist)),n};class Ga{constructor(){this.__forceAllowLocalhost=!1}get xn(){return this.__forceAllowLocalhost}set xn(t){mi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Wa{Sn(t,e){if(t){var i=this.pn.indexOf(t);-1!==i&&this.pn.splice(i,1)}return this.pn.push(e),null==e.initialize||e.initialize(),e}Cn(){return this.config.cookieless_mode===Tr||this.config.cookieless_mode===Pr&&this.consent.isRejected()}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 Ga,this.Mn=!1,this.version=c.LIB_VERSION,this.Tn=new Set,this.En="",this._n=new ra,this.pn=[],this.In=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ua(),this.SentryIntegration=dn,this.sentryIntegration=t=>function(t,e){var i=hn(t,e);return{name:un,processEvent:t=>i(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Pn=!1,this.Rn=null,this.An=null,this.Fn=null,this.scrollManager=new ta(this),this.pageViewManager=new vn(this),this.rateLimiter=new Zn(this),this.requestRouter=new ma(this),this.consent=new cs(this),this.externalIntegrations=new Pa(this);var e=null!==(t=Wa.__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=J(t)?{[t]:e}:t;this.setPersonProperties(r),null==i||i({})},set_once:(t,e,i)=>{var r=J(t)?{[t]:e}:t;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(t=>mi.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,e,i){if(i&&i!==Ba){var r,s=null!==(r=Ma[i])&&void 0!==r?r:new Wa;return s._init(t,e,i),Ma[i]=s,Ma[Ba][i]=s,s}return this._init(t,e,i)}_init(e,i,r){var s,n;void 0===i&&(i={});var o,a=J(e)?e.trim():"";if(!a)return mi.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=Ua(i.defaults),i.debug=this.Ln(i.debug),this.On=i,this.Dn=[],i.person_profiles?this.An=i.person_profiles:i.process_person&&(this.An=i.process_person);var l=Ua(i.defaults),u=Ha(i),h=Br({},l,u,{name:r,token:a});W(l.rageclick)&&W(u.rageclick)&&(h.rageclick=Br({},l.rageclick,u.rageclick)),W(l.session_recording)&&W(u.session_recording)&&(h.session_recording=Br({},l.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&mi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Hn;var d=this.$n();if(this.persistence=new Un(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Un(g({},this.config,{persistence:"sessionStorage"}),d,!1),this.En="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!d&&vs.N()){var v=vs.H(this.En);H(v)&&v.forEach((t=>{J(t)&&this.Tn.add(t)}))}else vs.q(this.En);var f=g({},this.persistence.props),p=g({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Nn=new Qo((t=>this.qn(t)),this.config.request_queue_config),this.jn=new Zo(this),this.__request_queue=[];var _=this.Cn();if(_||(this.sessionManager=new oa(this),this.sessionPropsManager=new ia(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((t,e,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this.Bn()}))),this.Hn(),this.config.__preview_deferred_init_extensions?(mi.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Un(_)}),0)):(mi.info("Initializing extensions synchronously"),this.Un(_)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&mi.info("Starting in debug mode",{this:this,config:i,thisC:g({},this.config),p:f,s:p}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=g({},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(fr);if(i.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Fr)this.identify(m);else if(i.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Rr)mi.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(es()),x=i.bootstrap.isIdentifiedID?w:m;this.persistence.set_property(fr,i.bootstrap.isIdentifiedID?Rr:Fr),this.register({distinct_id:m,$device_id:x})}}if(_)this.register_once({distinct_id:wr,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(es());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(fr,Fr)}return Vr(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()||es();t.config.get_device_id=r,i.id()&&(t.register({distinct_id:i.id(),$device_id:r()}),t.persistence.set_property(fr,Rr)),e()},s=i.user();"then"in s&&G(s.then)?s.then(r):r(s)}(t,(()=>{i.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||ln.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()||(ln.info("No userId set, resetting PostHog"),t.reset()),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(ln.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,Ar),identify:t=>e(t,Dr),screen:t=>e(t,"$screen")}})(t)).then((()=>{e()}))}))}(this,(()=>this.zn())):this.zn(),G(this.config._onCapture)&&this.config._onCapture!==Aa&&(mi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&mi.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 la.apply(this,arguments)}().then((t=>{t&&this.register({[Pi]:t})})).catch(Aa),this}Hn(){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=Wa.__defaultExtensionClasses)?void 0:i.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||(null==(r=this.Wn)||r.call(this),this.Wn=void 0,this.featureFlags=new o(this)),G(this.featureFlags.onReloading)&&G(this.featureFlags.setup)?this.Wn||(this.Wn=this.featureFlags.onReloading((()=>{this._n.emit("featureFlagsReloading",!0)})),this.Vn().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}Un(t){var e,i,r,s,n,o,a,l=performance.now(),u=g({},Wa.__defaultExtensionClasses,this.config.__extensionClasses),h=[];u.exceptions&&this.pn.push(this.exceptions=null!==(e=this.exceptions)&&void 0!==e?e:new u.exceptions(this)),u.historyAutocapture&&this.pn.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.pn.push(this.tracingHeaders=new u.tracingHeaders(this)),u.siteApps&&this.pn.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!t&&this.pn.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),u.autocapture&&this.pn.push(this.autocapture=new u.autocapture(this)),u.surveys&&this.pn.push(this.surveys=null!==(i=this.surveys)&&void 0!==i?i:new u.surveys(this)),u.logs&&this.pn.push(this.logs=null!==(r=this.logs)&&void 0!==r?r:new u.logs(this)),u.metrics&&this.pn.push(this.metrics=null!==(s=this.metrics)&&void 0!==s?s:new u.metrics(this)),u.conversations&&this.pn.push(this.conversations=null!==(n=this.conversations)&&void 0!==n?n:new u.conversations(this)),u.productTours&&this.pn.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.pn.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.pn.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.pn.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.pn.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,on)),u.toolbar&&this.pn.push(this.toolbar=null!==(o=this.toolbar)&&void 0!==o?o:new u.toolbar(this)),u.experiments&&this.pn.push(this.experiments=null!==(a=this.experiments)&&void 0!==a?a:new u.experiments(this)),this.pn.forEach((t=>{t.initialize&&h.push((()=>{null==t.initialize||t.initialize()}))})),h.push((()=>{if(this.Zn){var t=this.Zn;this.Zn=void 0,this.pn.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}})),this.Gn(h,l)}Gn(t,e){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-e>=30&&t.length>0)return void setTimeout((()=>{this.Gn(t,e)}),0);var i=t.shift();if(i)try{i()}catch(t){mi.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-e);this.register_for_session({[Sr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[kr]:r}),this.config.__preview_deferred_init_extensions&&mi.info("PostHog extensions initialized ("+r+"ms)")}Yi(t){var e;if(!r||!r.body)return mi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Yi(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Zn=t),this.bn=t,this.compression=void 0,t.ok){var i,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=j(s.supportedCompression,Hn)?Hn:j(s.supportedCompression,Gn)?Gn:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.An?this.An:Cr}),null==(e=this.Qn)||e.handleRemoteConfig(t),this.pn.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}zn(){try{this.config.loaded(this)}catch(t){mi.critical("`loaded` function failed",t)}if(this.Kn(),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.Cn())&&this.Jn()}),1),this.Yn=new eo(this),this.Yn.load()}Kn(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.Nn)||t.enable())}_dom_loaded(){this.is_capturing()&&Lr(this.__request_queue,(t=>this.qn(t))),this.__request_queue=[],this.Kn()}_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.Xn()&&this.capture(Or),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this.Nn)||r.unload(),null==(s=this.jn)||s.unload()):this.Xn()&&this.capture(Or,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?za?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=g({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?this.compression:t.compression,(K(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=g({},t);s.timeout=s.timeout||6e4;var n,o,a,u,h,d=null!==(e=s.transport)&&void 0!==e?e:"fetch";"sendBeacon"===d&&K(s.compression)&&s.data&&(s.compression=Gn),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(h=(u=(H(n=s.data)?n:[n]).map((t=>g({},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()),H(t)?t.map((t=>g({},t,{sent_at:e}))):g({},t,{sent_at:e})}(s.data))),s.url=Ko(s.url,s.method,s.compression,s.timestampMode);var v=Jo.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){Go(t)?mi.warn(t):mi.error(t),null==s.callback||s.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&s.data&&s.compression===Hn&&l&&"undefined"!=typeof Promise&&!jo?qo(s).then((t=>{f(t)})).catch((e=>{if(C(e))return jo=!0,void f(g({},s,{compression:void 0,url:Ko(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===T})(e)&&(jo=!0),f(s)})):c(s)})(g({},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}))}qn(t){this.jn?this.jn.retriableRequest(t):this._send_request(t)}_execute_array(t){Ia++;try{var e,i=[],r=[],s=[];Lr(t,(t=>{if(t)if(H(e=t[0]))s.push(t);else if(G(t))try{t.call(this)}catch(e){mi.error("Error executing queued PostHog call",t,e)}else H(t)&&"alias"===e?i.push(t):H(t)&&-1!==e.indexOf("capture")&&G(this[e])?s.push(t):r.push(t)}));var n=function(t,e){Lr(t,(function(t){try{if(H(t[0])){var i=e;Nr(t,(function(t){i=i[t[0]].apply(i,t.slice(1))}))}else e[t[0]].apply(e,t.slice(1))}catch(e){mi.error("Error executing queued PostHog call",t,e)}}))};n(i,this),n(r,this),n(s,this)}finally{Ia--}}push(t){if(Ia>0&&H(t)&&J(t[0])){var e=Wa.prototype[t[0]];G(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.Nn){if(this.is_capturing())if(!K(t)&&J(t)){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&&!J(null==e?void 0:e.$current_url)&&(mi.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.ts||mi.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=ye(null==i?void 0:i.uuid,es),c={uuid:v,event:t,properties:this.calculateEventProperties(t,e||{},d,v)};t===Ar&&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(Zi);(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 _,m,y,b=f?void 0:this.es(null==i?void 0:i.$set_once,t!==jr,t===Dr);if(b&&(c.$set_once=b),null!=i&&i._noTruncate||(s=this.config.properties_string_max_length,n=c,o=t=>J(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),H(e))r=[],Lr(e,(e=>{r.push(t(e))}));else{var s={};Nr(e,((e,i)=>{a.has(e)||(s[i]=t(e,i))})),r=s}return r}}(n)),c.timestamp=d,K(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,Na)),t===Jn||t===Yn){var w=null==e?void 0:e.$survey_id,S=null==e?void 0:e.$survey_iteration;xa({id:w,current_iteration:S}),c.$set=g({},c.$set,{[(_={id:w,current_iteration:S},m=t===Yn?"responded":"dismissed",y="$survey_"+m+"/"+_.id,_.current_iteration&&_.current_iteration>0&&(y="$survey_"+m+"/"+_.id+"/"+_.current_iteration),y)]:!0})}else t===Kn&&(c.$set=g({},c.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===t){var k=null==e?void 0:e.$product_tour_type;k&&(c.$set=g({},c.$set,{["$product_tour_last_seen_date/"+k]:(new Date).toISOString()}))}var E=g({},c.properties.$set,c.$set);if(V(E)||this.setPersonPropertiesForFlags(E),!X(this.config.before_send)){var P=this.At(c);if(!P)return;(c=P).uuid=ye(c.uuid,es)}this._n.emit("eventCaptured",c);var T=null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),F={method:"POST",url:T,data:c,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(T)?"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.qn(F):this.Nn.enqueue(F),c}mi.critical("This capture call is ignored due to client rate limiting.")}}else mi.error("No event name provided to posthog.capture")}else mi.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(e=>t(e.event,e)))}Vn(){var t;return null!==(t=this.Qn)&&void 0!==t?t:this.Qn=new Ca(this)}kn(t){this.In.push(t);var e=!0;return()=>{if(e){e=!1;var i=this.In.indexOf(t);-1!==i&&this.In.splice(i,1)}}}calculateEventProperties(e,i,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return i;var l=a?void 0:this.persistence.remove_event_timer(e),h=g({},i);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.Cn()&&(h[xr]=!0),"$snapshot"===e){var d=g({},this.persistence.properties(),this.sessionPersistence.properties());return h.distinct_id=d.distinct_id,(!J(h.distinct_id)&&!Z(h.distinct_id)||Y(h.distinct_id))&&mi.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?[...En,...i||[]]:[],f=function(t){for(var e=0;ge.length>e;e++){var i=ge[e],r=i[1],s=i[0].exec(t),n=s&&(G(r)?r(s,t):r);if(n)return n}return["",""]}(u),p=f[0],g=f[1],_=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};K(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,k=null==t?void 0:t.devicePixelRatio;K(b)||(y.userAgentDataPlatform=b),K(w)||(y.maxTouchPoints=w),K(x)||(y.screenWidth=x),K(S)||(y.screenHeight=S),K(k)||(y.devicePixelRatio=k);var E,P,T,F,R,C,M,I,A=Br(Hr({$os:p,$os_version:g,$browser:ce(u,navigator.vendor,_,m),$device:_e(u),$device_type:(P=u,T=y,I=_e(P),I===yt||I===mt||"Kobo"===I||"Kindle Fire"===I||I===Jt?_t:I===Lt||I===Bt||I===Nt||I===Wt?"Console":I===wt?"Wearable":I?ft:"Android"===(null==T?void 0:T.userAgentDataPlatform)&&(null!==(F=null==T?void 0:T.maxTouchPoints)&&void 0!==F?F:0)>0?600>Math.min(null!==(R=null==T?void 0:T.screenWidth)&&void 0!==R?R:0,null!==(C=null==T?void 0:T.screenHeight)&&void 0!==C?C:0)/(null!==(M=null==T?void 0:T.devicePixelRatio)&&void 0!==M?M:1)?ft:_t:"Desktop"),$timezone:jn(),$timezone_offset:Ln()}),{$current_url:bn(n?be(null==s?void 0:s.href):null==s?void 0:s.href,v,Pn),$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:pe(u,navigator.vendor,_,m),$browser_language:Mn(),$browser_language_prefix:(E=Mn(),"string"==typeof E?E.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&&(A.$sdk_dist_channel=c.SDK_DIST_CHANNEL),A}(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()),_=p.windowId;h.$session_id=p.sessionId,h.$window_id=_}this.sessionPropsManager&&Br(h,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&Br(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null==(m=this.jn)?void 0:m.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===fa&&(h.$lib_custom_api_host=this.config.api_host),v=e!==Ar||a?e!==Or||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),h=Br(h,v),e===Ar&&r&&(h.title=r.title),!K(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();Nr(["$referrer","$referring_domain"],(t=>{t in b&&delete w[t]}));var x={};if(this.In.length>0)for(var S of this.In.slice())try{Br(x,S())}catch(t){mi.error("Failed to produce browser extension event properties",t)}(h=Br({},f,b,w,g({},x,h))).$is_identified=this._isIdentified(),H(this.config.property_denylist)?Nr(this.config.property_denylist,(function(t){delete h[t]})):mi.error(La+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var k=this.config.sanitize_properties;k&&(mi.error(ja),h=k(h,e));var E=this.rs();return h.$process_person_profile=E,E&&!a&&this.ns("_calculate_event_properties"),h}es(t,e,i){var r;if(void 0===e&&(e=!0),void 0===i&&(i=!1),!this.persistence||!this.rs())return t;if(this.Mn&&!i)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=Br({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(mi.error(ja),o=a(o,"$set_once")),e&&(this.Mn=!0),V(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;null==(e=this.sessionPersistence)||e.register(t),Object.keys(t).forEach((t=>this.Tn.add(t))),this.ss()}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.Tn.delete(t),this.ss()}os(t,e){this.register({[t]:e})}Bn(){this.Tn.forEach((t=>{var e;null==(e=this.sessionPersistence)||e.unregister(t)})),this.Tn.clear(),this.ss()}ss(){var t;if(this.En)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.Ei||!vs.N())vs.q(this.En);else{var e=[];this.Tn.forEach((t=>e.push(t))),e.length>0?vs.F(this.En,e):vs.q(this.En)}}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._n.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:Da}),()=>{})}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:Da})}getActiveMatchingSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,e):t([],{isLoaded:!1,error:Da})}renderSurvey(t,e){var i;null==(i=this.surveys)||i.renderSurvey(t,e)}displaySurvey(t,e){var i;void 0===e&&(e=ka),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:Da}}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:Da})}ls(t){return!t||Y(t)?(mi.critical("Unique user id has not been set in posthog.identify"),!1):t===wr?(mi.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())||(mi.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 mi.uninitializedWarning("posthog.identify");if(Z(t)&&(t=t.toString(),mi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.ls(t)&&this.ns("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:t}),this.get_property($i)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),t!==r&&t!==this.get_property(Ti)&&(this.unregister(Ti),this.register({distinct_id:t}));var s,n=(this.persistence.get_property(fr)||Fr)===Fr,o=t!==r,a=!o&&n;if(o&&n)this.persistence.set_property(fr,Rr),this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!1),this.capture(Dr,{distinct_id:t,$anon_distinct_id:r},{$set:e||{},$set_once:i||{}}),this.Fn=ha(t,e,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r);else if(a){this.persistence.set_property(fr,Rr);var l=e||{},u=i||{};this.setPersonPropertiesForFlags({$set:l,$set_once:u},!1),this.capture("$set",{$set:l,$set_once:u}),this.Fn=ha(t,e,i)}else(e||i)&&this.setPersonProperties(e,i);o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(hr)):a&&(e||i)&&this.reloadFeatureFlags()}}setPersonProperties(t,e){if((t||e)&&this.ns("posthog.setPersonProperties")){var i=ha(this.get_distinct_id(),t,e);this.Fn!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:e||{}},!0),this.capture("$set",{$set:t||{},$set_once:e||{}}),this.Fn=i):mi.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var e,i=(H(t)?t:[t]).filter((t=>J(t)&&t.length>0));0!==i.length&&this.ns("posthog.unsetPersonProperties")&&(null==(e=this.featureFlags)||e.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Fn=null)}group(t,e,i){if(t&&e){var r=this.getGroups(),s=r[t]!==e;if(s&&this.resetGroupPropertiesForFlags(t),this.register({$groups:g({},r,{[t]:e})}),s||i){var n={$group_type:t,$group_key:e};i&&(n.$group_set=i),this.capture(jr,n)}i&&this.setGroupPropertiesForFlags({[t]:i}),s&&!i&&this.reloadFeatureFlags()}else mi.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.ns("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=et(t)?t:null==t?void 0:t.resetDeviceID,i=et(t)||null==t?void 0:t.bootstrap;this.us(e,!1,i)}us(t,e,i){var r,s,n,o,a,l,u,h,d,v,c,f;if(void 0===e&&(e=!1),mi.info("reset"),!this.__loaded)return mi.uninitializedWarning("posthog.reset");var p=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null==(r=this.On)?void 0:r.bootstrap)||{},null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.tr());var _,m,y,b,w=this.get_property($i),x=this.get_property(Pi),S=this.get_property(Ni),k=this.is_capturing();if(this.consent.reset(),e||!k||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."),null==(n=this.persistence)||n.clear(),null==(o=this.sessionPersistence)||o.clear(),this.Tn.clear(),this.ss(),K(S)||null==(_=this.persistence)||_.register({[Ni]:S}),null==(a=this.surveys)||a.reset(),null==(l=this.Yn)||l.stop(),null==(u=this.featureFlags)||u.reset(),null==(h=this.conversations)||h.reset(),null==(d=this.logs)||d.reset(),null==(v=this.metrics)||v.reset(),null==(c=this.persistence)||c.set_property(fr,Fr),null==(f=this.sessionManager)||f.resetSessionId(),this.Fn=null,this.config.cookieless_mode===Tr)this.register_once({distinct_id:wr,$device_id:null},"");else{var E=this.config.get_device_id(es());this.register_once({distinct_id:E,$device_id:t?E:w},""),t||K(x)||this.register({[Pi]:x})}if((this.register({$last_posthog_reset:(new Date).toISOString()},1),i)&&(void 0===i.distinctID||this.Cn()||(null==(b=this.persistence)||b.set_property(fr,i.isIdentifiedID?Rr:Fr),this.register({distinct_id:i.distinctID})),null==(m=this.featureFlags)||m.initialize(),!(K(p)||null!=(y=this.sessionManager)&&y.setBootstrapSessionId(p,!0)))){var P=g({},i);delete P.sessionID,this.config.bootstrap=P}delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(t){var e=this;return p((function*(){var t,i,r,s,n,o,a;if(e.__loaded){null==(t=e.Yn)||t.stop(),null==(i=e.Qn)||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.Nn)||o.unload(),null==(a=e.jn)||a.unload();try{var l;null==(l=e.featureFlags)||l.destroy()}catch(t){mi.error("Error while destroying feature flags",t)}}else mi.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.hs()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.ds()}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(Ei)?(mi.critical("Attempting to create alias for existing People user - aborting."),-2):this.ns("posthog.alias")?(K(e)&&(e=this.get_distinct_id()),t!==e?(this.os(Ti,t),this.capture("$create_alias",{alias:t,distinct_id:e})):(mi.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var e=g({},this.config);if(W(t)){var i,r,s,n,o,a,l,u,h,d,v,f;Br(this.config,Ha(t));var p=this.$n();null==(i=this.persistence)||i.update_config(this.config,e,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Un(g({},this.config,{persistence:"sessionStorage"}),p,!1);var _=this.Ln(this.config.debug);et(_)&&(this.config.debug=_),et(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,as.N()&&as.F("ph_debug",!0),mi.info("set_config",{config:t,oldConfig:e,newConfig:g({},this.config)})):(c.DEBUG=!1,as.N()&&as.q("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this.tr()),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.vs(),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(g({},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:Wa.cs}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:Ba;return e!==Ba&&(e=Ba+"."+e),e}_isIdentified(){var t,e;return(null==(t=this.persistence)?void 0:t.get_property(fr))===Rr||(null==(e=this.sessionPersistence)?void 0:e.get_property(fr))===Rr}rs(){var t,e;return!("never"===this.config.person_profiles||this.config.person_profiles===Cr&&!this._isIdentified()&&V(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[Ti])&&(null==(e=this.persistence)||null==(e=e.props)||!e[br]))}Xn(){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.rs()||this.ns("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ns("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ns(t){return"never"===this.config.person_profiles?(mi.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.os(br,!0),!0)}$n(){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!==Pr)}vs(){var t,e,i,r,s=this.$n();return(null==(t=this.persistence)?void 0:t.Ei)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(e=this.sessionPersistence)?void 0:e.Ei)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s&&(this.Tn.clear(),this.ss()),s}opt_in_capturing(t){var e;if(this.config.cookieless_mode!==Tr){if(this.Cn()){var i,r,s,n,o;this.us(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new oa(this),this.pageViewManager=new vn(this),this.persistence&&(this.sessionPropsManager=new ia(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=Wa.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.Sn(this.sessionRecording,new l(this)),this.bn&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.bn)))}var u,h;this.consent.optInOut(!0),this.vs(),this.Kn(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),this.config.cookieless_mode==Pr&&(null==(u=this.surveys)||u.loadIfEnabled()),(K(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.Jn()}else mi.warn(Oa)}opt_out_capturing(){var t,e,i;this.config.cookieless_mode!==Tr?(this.config.cookieless_mode===Pr&&this.consent.isOptedIn()&&this.us(!0,!0),this.consent.optInOut(!1),this.vs(),this.config.cookieless_mode===Pr&&(this.register({distinct_id:wr,$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.Jn(),this.Kn())):mi.warn(Oa)}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===Tr||(this.config.cookieless_mode===Pr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.vs()}_is_bot(){return i?aa(i,this.config.custom_blocked_useragents):void 0}Jn(){r&&("visible"===r.visibilityState?this.Pn||(this.Pn=!0,this.capture(Ar,{title:r.title},{send_instantly:!0}),this.Rn&&(r.removeEventListener(Mr,this.Rn),this.Rn=null)):this.Rn||(this.Rn=this.Jn.bind(this),Vr(r,Mr,this.Rn)))}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}))}tr(){var t=this.On||{};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?(mi.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&&!X(t[e]),o=i in t&&!X(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,mi)}At(t){var e;if(X(this.config.before_send))return t;var i=Object.keys(null!==(e=t.properties)&&void 0!==e?e:{}).filter(st),r=H(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r){if(s=n(s),X(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return rt(t.event)?mi.warn(o+". This can cause unexpected behavior."):mi.info(o),null}s.properties&&!V(s.properties)||mi.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&X(s.properties[a]))return mi.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.fi)?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)})}Ln(t){var e=et(t)&&!t,i=as.N()&&"true"===as.P("ph_debug");return!e&&(!!i||t)}}Wa.__defaultExtensionClasses={},Wa.cs=(()=>{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]]=qr(t.prototype[e[i]])}(Wa,["identify"]);class Va{constructor(t){this.disabled=!1===t;var e=W(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)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 Ka="$copy_autocapture",Ja=yi("[AutoCapture]");function Ya(t,e){return e.length>t?e.slice(0,t)+"...":e}function Qa(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!bs(e));return e}function Xa(e,i){var r,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!bs(e))return{props:{}};for(var d=[e],v=new Set([e]),c=e;c.parentNode&&!ws(c,"body")&&ks>d.length;)if(Ss(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!bs(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,_,m=[],y={},b=!1,w=!1;if(Nr(d,(t=>{var e=qs(t);if(ws(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Xs(i))&&(h?be(i):i)}j(Ps(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};Cs.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ya(1024,Zs(t)):Ya(1024,Fs(t)));var a=Ps(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),Nr(t.attributes,(function(i){var n;if((!Hs(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Xs(i.value)&&(!J(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=Es(a).join(" ")),o["attr__"+i.name]=Ya(1024,"href"===i.name&&s?be(a):a)}}));for(var l=1,u=1,h=t;h=Qa(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(!qs(t))return{};var e={};return Nr(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&&Xs(r)&&(e[i]=r)}})),e}(t);Br(y,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=ws(e,"a")||ws(e,"button")?Zs(e):Fs(e)),b){var x,S;m[0].attr__href=b;var k=null==(x=mn(b))?void 0:x.host,E=null==t||null==(S=t.location)?void 0:S.host;k&&E&&k!==E&&(p=b)}return{props:Br({$event_type:n.type,$ce_version:1},u?{}:{$elements:m},{$elements_chain:(_=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=g({},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 zr(n).sort(((t,e)=>t[0].localeCompare(e[0]))).forEach((t=>{var e=t[1];return o[en(t[0].toString())]=en(e.toString())})),(r+=":")+zr(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:rn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return zr(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(_)))},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 Za=yi("[ExceptionAutocapture]"),tl=()=>{},el=yi("[TracingHeaders]"),il=yi("[Web Vitals]"),rl=9e5,sl="disabled",nl="lazy_loading",ol="awaiting_config",al="missing_config";yi("[SessionRecording]"),yi("[SessionRecording]");var ll="[SessionRecording]",ul=yi(ll),hl=yi("[Heatmaps]");function dl(t){return W(t)&&"clientX"in t&&"clientY"in t&&Z(t.clientX)&&Z(t.clientY)}var vl=yi("[Product Tours]"),cl=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(ji))},fl=["$set_once","$set"],pl=yi("[SiteApps]"),gl="Error while initializing PostHog app with config id ";function _l(t,e,i){if(X(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 ml{constructor(t){this.fs=new ra,this.ps=(t,e)=>this.gs(t,e)&&this.ys(t,e)&&this.bs(t,e)&&this._s(t,e),this.gs=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.ws=new Set,this.ks=new Set}init(){var t,e;K(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(!K(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.ks)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.ws)||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.ws.has(t)||this.ws.has(e.event))&&this.ks&&(null==(i=this.ks)?void 0:i.size)>0&&this.ks.forEach((t=>{this.xs(e,t)&&this.fs.emit("actionCaptured",t.name)}))}Ss(t){this.onAction("actionCaptured",(e=>t(e)))}xs(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.ps(t,i))return!0;return!1}onAction(t,e){return this.fs.on(t,e)}ys(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(!_l(r,e.url,e.url_matching||"contains"))return!1}return!0}bs(t,e){return!!this.Cs(t,e)&&!!this.Ms(t,e)&&!!this.Ts(t,e)}Cs(t,e){var i;if(null==e||!e.href)return!0;var r=this.Es(t);if(r.length>0)return r.some((t=>_l(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&_l((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}Ms(t,e){var i;if(null==e||!e.text)return!0;var r=this.Es(t);if(r.length>0)return r.some((t=>_l(t.text,e.text,e.text_matching||"exact")||_l(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;!X(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=>_l(t,n,o))))}Ts(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}Es(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}_s(t,e){return null==e||!e.properties||0===e.properties.length||ca(e.properties.reduce(((t,e)=>{var i=H(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 yl{constructor(t){var e;this.Is=[],this._instance=t,this.Ps=new Map,this.Rs=new Map,this.As=new Map,null==(e=this._instance)||null==e.onSessionId||e.onSessionId((t=>this.Fs(t)))}Ls(t){return!1}Os(){return null}Ds(t){}$s(){}Ns(t,e){return!!t&&ca(t.propertyFilters,null==e?void 0:e.properties)}qs(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}js(t,e,i){var r=(i===Wn?this.Ps:this.Rs).get(t),s=[];return this.Bs((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.Ns(n,e)}))}register(t){var e;K(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Hs(t),this.Us(t))}Us(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.zs&&(this.zs=new ml(this._instance),this.zs.init(),this.zs.Ss((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.zs)||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.As.get(e.name);i&&i.push(t.id),this.As.set(e.name,i||[t.id])}})))})))}Hs(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.Ps=this.qs(t,Wn),this.Rs=this.qs(t,Vn))}onEvent(t,e){var i,r,s=this.Ws(),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.Vs(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Zs([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Gs(n),void this.Qs([n])}if(this.Rs.has(t)){var a=this.js(t,e,Vn);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.Zs(a.map((t=>t.id))),a.forEach((t=>this.Ks(t.id))))}if(this.Ps.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.Ps.get(t)});var l=this.js(t,e,Wn);this.Js(l.map((t=>t.id)))}}onAction(t){this.As.has(t)&&this.Js(this.As.get(t)||[])}Js(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.Ls(s)?this.Gs(s)&&this.Ys(s):r.push(s);r.length>0&&(this.Is=[...new Set([...this.Is,...r])]),this.Ws().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Gs(t){this.Is=this.Is.filter((e=>e!==t));var e=this.Xs();return!e.includes(t)&&(this.ta([...e,t]),this.ea(),!0)}Zs(t){var e=new Set(t);this.Is=this.Is.filter((t=>!e.has(t)));var i=this.ia(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&(this.ta(r),0===r.length&&this.ra()),this.Qs(t)}na(){var t,e=this.Os();if(!e)return{};var i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e];return i&&"object"==typeof i?i:{}}Ys(t){if(this.Os()){var e=this.na();this.Ds(g({},e,{[t]:Date.now()}))}}Qs(t){if(this.Os()){var e=this.na(),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&&(V(i)?this.$s():this.Ds(i))}}sa(){this.Os()&&this.$s()}getActivationTimestamp(t){if(this.Xs().includes(t)){var e=this.na()[t];return Z(e)?e:void 0}}ia(){var t,e=this.aa();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}Xs(){var t,e,i=this.ia();if(0===i.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.oa()],s=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();return s&&r===s?i:[]}ea(){var t,e=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();e&&this.la(e)}ra(){this.ua()}Fs(t){var e,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this.oa()];if(i&&i!==t){var r=this.ia(),s=this.na();r.length>0&&(this.ta([]),r.filter((t=>Z(s[t]))).forEach((t=>this.Ks(t)))),this.ra(),this.sa()}}getActivatedIds(){return[...new Set([...this.Xs(),...this.Is])].filter((t=>!this.ha(t)))}reset(){this.Is=[],this.ia().length>0&&this.ta([]),this.ra(),this.sa()}getEventToItemsMap(){return this.Ps}da(){return this.zs}}class bl extends yl{constructor(t){super(t)}aa(){return or}oa(){return ar}Os(){return lr}Ds(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[lr]:t})}$s(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(lr)}Ls(t){var e,i;this.Bs((e=>{i=e.find((e=>e.id===t))}));var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return Z(r)&&r>0}va(){return Kn}Bs(t){var e;null==(e=this._instance)||e.getSurveys(t)}Ks(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Ws(){return ba}ta(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[or]:t})}la(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[ar]:t})}ua(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(ar)}ha(){return!1}Vs(t,e){var i;this.Bs((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e;return ya(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(i);return r?t===Kn?"consume":"ignore":t===Kn?"persist":t===Jn||t===Yn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var wl="SDK is not enabled or survey functionality is not yet loaded",xl="Disabled. Not loading surveys.",Sl=null!=t&&t.location?wn(t.location.hash,"__posthog")||wn(location.hash,"state"):null,kl="_postHogToolbarParams",El=yi("[Toolbar]"),$l=yi("[FeatureFlags]");class Pl{constructor(t,e){void 0===e&&(e=!1),this.ca=!1,this.update(t,e)}update(t,e){this.fa=((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:H(t.flag_keys)?t.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.ca||($l.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ca=!0),K(t.flag_keys)||H(t.flag_keys)||$l.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.fa}}var Tl=yi("[FeatureFlags]"),Fl=yi("[FeatureFlags]",{debugEnabled:!0}),Rl="\" failed. Feature flags didn't load in time.",Cl="connection_error",Ml=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Il=t=>{var e={};for(var i of zr(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Al=yi("[Error tracking]"),Ol="Refusing to render web experiment since the viewer is a likely bot",Dl={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>ua(e,t),not_regex:(t,e)=>!ua(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class jl{get qe(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{jl.pa("retrieved web experiments from the server"),e.ga=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.ga&&(jl.pa("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.ga)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);J(r)&&t.variants[r]&&e.ma(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];jl.ya(n,e._instance)&&e.ma(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())jl.pa(Ol);else if(!this.qe.disable_web_experiments){if(X(this.ga))return this.ga=new Map,this.loadIfEnabled(),void this.previewWebExperiment();jl.pa("applying feature flags",t),t.forEach((t=>{var e;if(this.ga&&null!=(e=this.ga)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.ga)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.ma(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=jl.getWindowLocation();if(null!=t&&t.search){var e=yn(null==t?void 0:t.search,"__experiment_id"),i=yn(null==t?void 0:t.search,"__experiment_variant");e&&i&&(jl.pa("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ba(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.qe.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.qe.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.qe.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ba(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(jl.pa("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.ma(r[0].name,e,r[0].variants[e].transforms))}static ya(t,e){return!X(t.conditions)&&jl._a(t,e)&&jl.wa(t)}static _a(t,e){var i;if(X(t.conditions)||X(null==(i=t.conditions)?void 0:i.url))return!0;var r=jl.getWindowLocation();if(r){var s,n,o,a=fs(e,r.href);return null==(s=t.conditions)||!s.url||Dl[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 wa(t){var e;if(X(t.conditions)||X(null==(e=t.conditions)?void 0:e.utm))return!0;var i=Fn();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 pa(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mi.info("[WebExperiments] "+t,i)}ma(t,e,i){this._is_bot()?jl.pa(Ol):"control"!==e?i.forEach((i=>{if(i.selector){var r;jl.pa("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)}))}})):jl.pa("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?aa(i,this.qe.custom_blocked_useragents):void 0}}var Ll=yi("[Conversations]"),Nl="Conversations not available yet.",Bl="console",zl="__posthogHandledLogsRequestError",Ul=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[zl]=!0,i},ql=t=>!!t&&"object"==typeof t&&!0===t[zl],Hl={featureFlags:class{constructor(t){this.name="featureFlags",this.ka=!1,this.featureFlagEventHandlers=[],this.st=Tl,this.xa={},this.Sa={},this.Ca=[],this.Ma=!1,this.Ta=!1,this.Ea=0,this.Ia=!1,this.Pa=!1,this.Ra=!1,this.Aa=!1,this.Fa=0,this.La=()=>{var t=this.Oa();this.Fa=0,t&&this.reloadFeatureFlags()},"get"in t?this.Da=t:(this.$a=new Pl(t.config,t.tr()),this.Da=this.$a)}updateConfig(t,e){var i;null==(i=this.$a)||i.update(t,e)}setup(t){return this.Na=t,this.st=t.logger.createLogger("[FeatureFlags]"),i=()=>{this.Na===t&&(this.Na=void 0,this.fn=t,this.qa(t))},null!=(e=t.kv.initialize())&&e.then?e.then(i):i();var e,i}qa(e){if(this.fn===e)return t&&Vr(t,"online",this.La),this.ja=e.registerDynamicEventProperties((()=>this.Ba()?this.xa:this.Sa)),this.Ha(),this.initialize()}destroy(){null==t||t.removeEventListener("online",this.La)}dispose(){var e;this.Ea++,this.Pa=!1,this.Na=void 0,this.fn&&(this.Ua(),null==(e=this.ja)||e.dispose(),this.ja=void 0,this.Ca=[],null==t||t.removeEventListener("online",this.La),this.fn=void 0)}get qe(){return this.Da.get()}za(t){var e;return null==(e=this.fn)?void 0:e.kv.get(t)}F(t){this.Wa((()=>{var e;return null==(e=this.fn)?void 0:e.kv.set(t)}))}q(t){this.Wa((()=>{var e;return null==(e=this.fn)?void 0:e.kv.remove(t)}))}Wa(t){try{t()}catch(t){this.st.error("Failed to update feature flag persistence",t)}}Ha(){var t={};for(var e of[Ki,Qi,Xi,tr]){var i=this.za(e);K(i)||(t[e]=i)}this.xa=t;var r=g({},t),s=this.za(Vi);if(s)for(var n of Object.entries(s))r["$feature/"+n[0]]=n[1];this.Sa=r}Ba(){var t=this.qe.cacheTtlMs;if(!t||0>=t)return!1;var e=this.za(cr);return"number"!=typeof e||Date.now()-e>t}Va(){return!!this.Ba()&&(this.Aa||this.Ta||(this.Aa=!0,this.st.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Za(){var t=this.qe.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.st.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}Ga(){var t=this.qe.flagKeys;if(!K(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.st.error("Invalid flag key found:",t,"Expected non-empty string"),e}))}initialize(){var t,e,i=this.qe,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.Qa({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var r,s,n=null!=i&&i.merge&&null!==(r=this.za(Vi))&&void 0!==r?r:{},o=null!=i&&i.merge&&null!==(s=this.za(Qi))&&void 0!==s?s:{},a=g({},n,t),l=g({},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:K(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Qa({flags:u})}get hasLoadedFlags(){return this.Ma}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.za(Yi),e=this.za(tr),i=this.za(er);if(!i&&!e)return t||{};var r=Br({},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=K(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=K(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==i?void 0:i[n],c=g({},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=g({},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.ka||(this.st.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:r}),this.ka=!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.za(Vi),e=this.za(tr);if(!e)return t||{};for(var i=Br({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.ka||(this.st.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.ka=!0),i}getFlagPayloads(){var t=this.za(Qi),e=this.za(er);if(!e)return t||{};for(var i=Br({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.ka||(this.st.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.ka=!0),i}reloadFeatureFlags(){this.Ia||this.qe.featureFlagsDisabled||this.Oa()||this.Ka||(this.Ca.slice().forEach((t=>{try{t()}catch(t){this.st.error("Error while running feature flags reloading callback",t)}})),this.Ka=setTimeout((()=>{this.Ja()}),5))}Ua(){clearTimeout(this.Ka),this.Ka=void 0}onReloading(t){return this.Ca.push(t),()=>{this.Ca=this.Ca.filter((e=>e!==t))}}ensureFlagsLoaded(){this.Ma||this.Ta||this.Ka||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Ia=t}resetFlagCallReported(){this.q(hr)}Ja(t){this.Ua();var e=this.fn;if(e&&!this.qe.remoteRequestsDisabled&&!this.Oa())if(this.Ta)this.Pa=!0;else{var i={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:g({},e.initialPersonProperties,this.za(ir)||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.za(rr),timezone:jn()};K(e.deviceId)||(i.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.qe.featureFlagsDisabled)&&(i.disable_flags=!0);var r=this.Za();r.length&&(i.evaluation_contexts=r);var s=this.Ga();K(s)||(i.flag_keys=s);var n=this.qe.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.Ea;this.Ta=!0;var l=()=>{this.Pa&&(this.Pa=!1,this.Ja())},u=t=>{this.Ta=!1,a===this.Ea?(this.F({[vr]:[Cl]}),this.st.error("Feature flag request failed",t),l()):l()};try{e.sendRequest(o,{target:"flags",method:"POST",body:i,compression:"base64"===this.qe.compression?Gn:void 0,sentAt:"body",timeoutMs:this.qe.requestTimeoutMs}).then((t=>{var e,r,s=null!==(e=t.json)&&void 0!==e?e:{},o=200!==t.statusCode;if(this.Ta=!1,a===this.Ea){if(this.Ya(t.statusCode),o||this.Pa||(this.$anon_distinct_id=void 0),!i.disable_flags||this.Pa){this.Ra=!o;var u=[];t.error?u.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Cl:"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.F({[vr]:u}),h?this.st.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.Qa(s,o,{partialResponse:n}),l()}}else l()})).catch(u)}catch(t){u(t)}}}Oa(){return xn(this.Fa,3)}Ya(t){this.Fa=Sn(t,this.Fa,3,(()=>this.st.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.Ra)if(this.Ma||this.getFlags()&&this.getFlags().length>0){if(!this.Va()){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.st.warn('getFeatureFlag for key "'+t+Rl)}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.Ra)if(this.Ma||this.getFlags()&&this.getFlags().length>0){if(!this.Va()){var i,r=this.getFlagVariants(),s=t in r,n=r[t],o=this.getFlagPayloads()[t],a=String(n),l=this.za(Xi)||void 0,u=this.za(cr)||void 0,h=this.za(hr)||{};if(this.qe.deduplicateCallsPerSession){var d,v=null==(d=this.fn)?void 0:d.session.sessionId,c=this.za(dr);v&&v!==c&&(h={},i=v)}if(e.send_event||!("send_event"in e))if(t in h&&h[t].includes(a))i&&this.F({[hr]:h,[dr]:i});else{var f,p,_,y,b,w,x,S,k,E,P,T;H(h[t])?h[t].push(a):h[t]=[a],this.F(g({[hr]:h},i?{[dr]:i}:{}));var F=this.getFeatureFlagDetails(t),R=[...null!==(f=this.za(vr))&&void 0!==f?f:[]];K(n)&&R.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==(_=this.qe.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(y=null==(b=this.qe.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.Ra};K(null==F||null==(w=F.metadata)?void 0:w.has_experiment)||(C.$feature_flag_has_experiment=F.metadata.has_experiment),K(null==F||null==(x=F.metadata)?void 0:x.version)||(C.$feature_flag_version=F.metadata.version);var M,I=null!==(S=null==F||null==(k=F.reason)?void 0:k.description)&&void 0!==S?S:null==F||null==(E=F.reason)?void 0:E.code;I&&(C.$feature_flag_reason=I),null!=F&&null!=(P=F.metadata)&&P.id&&(C.$feature_flag_id=F.metadata.id),K(null==F?void 0:F.original_variant)&&K(null==F?void 0:F.original_enabled)||(C.$feature_flag_original_response=K(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(T=F.metadata)&&T.original_payload&&(C.$feature_flag_original_payload=null==F||null==(M=F.metadata)?void 0:M.original_payload),R.length&&(C.$feature_flag_error=R.join(",")),this.Xa(C)}else i&&this.F({[hr]:h,[dr]:i});if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:m(o)}}}else this.st.warn('getFeatureFlagResult for key "'+t+Rl)}Xa(t){try{var e;null==(e=this.fn)||e.capture("$feature_flag_called",t).catch((t=>{this.st.error("Failed to capture feature flag call",t)}))}catch(t){this.st.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,e){this.eo(t,e)}eo(t,e){var i=this;return p((function*(){var r=i.fn;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=i.Za();n.length&&(s.evaluation_contexts=n);var o,a=i.Ga();K(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.qe.compression?Gn:void 0,sentAt:"body",timeoutMs:i.qe.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;o=(null==u?void 0:u[t])||void 0}catch(t){return void i.st.error("Remote config feature flag request failed",t)}try{e(o)}catch(t){i.st.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.Ra)return e.defaultValue;if(!(this.Ma||this.getFlags()&&this.getFlags().length>0))return this.st.warn('isFeatureEnabled for key "'+t+Rl),e.defaultValue;var i=this.getFeatureFlag(t,e);return K(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.Qa(t,e,i)}Qa(t,e,i){if(this.fn){this.Ma=!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=Tl);var o=((t,e)=>{var i=t.flags;return i?g({},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(H(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{[Ki]:l,[Vi]:v,[Zi]:!1}}var f=l,p=u,_=a;if(null!=s&&s.partialResponse)f=g({},e,f),p=g({},i,p),_=g({},r,_);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=g({},e,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=g({},i,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),_=g({},r,Object.fromEntries(Object.entries(_||{}).filter((t=>m.has(t[0])))))}else f=g({},e,f),p=g({},i,p),_=g({},r,_);return g({[Ki]:Object.keys(Il(f)),[Vi]:f||{},[Qi]:p||{},[Yi]:_||{},[Zi]:!0===t.minimalFlagCalledEvents},h?{[Xi]:h}:{},d?{[cr]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this.st);r&&this.F(r),e||(this.Aa=!1),this.io(e)}}override(t,e){void 0===e&&(e=!1),this.st.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.ro(t)}ro(t){if(this.fn){if(!1===t)return this.q([tr,er]),this.io(),void Fl.info("All overrides cleared");if(H(t))return this.F({[tr]:Ml(t)}),this.io(),void Fl.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.ka=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},s=i.flags,n=i.payloads;return s&&(r[tr]=H(s)?Ml(s):s),n&&(r[er]=n),Object.keys(r).length&&this.F(r),!1===s&&!1===n?this.q([tr,er]):!1===s?this.q(tr):!1===n&&this.q(er),this.io(),!1===s?Fl.info("Flag overrides cleared"):s&&Fl.info("Flag overrides set",{flags:s}),void(!1===n?Fl.info("Payload overrides cleared"):n&&Fl.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.F({[tr]:t}),this.io(),void Fl.info("Flag overrides set",{flags:t});this.st.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.st.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Ma){var e=this.no(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.st.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var r=(this.za(Ji)||[]).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=g({},this.getFlagVariants(),{[t]:e});this.F({[Ki]:Object.keys(Il(o)),[Vi]:o,[ir]:g({},this.za(ir)||{},s)}),this.io();try{var a;null==(a=this.fn)||a.capture("$feature_enrollment_update",n).catch((t=>{this.st.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.st.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.za(Ji);!r||e?this.so(t,i):t(r)}so(t,e){var i=this;return p((function*(){var r=i.fn;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.F({[Ji]:s=o.json.earlyAccessFeatures})}catch(t){return void i.st.error("Early access feature request failed",t)}try{t(s)}catch(t){i.st.error("Early access feature callback failed",t)}}}))()}no(){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)),{})}}io(t){this.Ha();var e=this.no(),i=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.st.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.ao(t,e)}ao(t,e){void 0===e&&(e=!0);var i=this.za(ir)||{},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.F({[ir]:g({},i,n,r)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=g({},this.za(ir)||{});t.forEach((t=>{delete i[t]})),this.F({[ir]:i}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.q(ir),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.za(rr)||{},r=g({},i);for(var s of Object.keys(t))r[s]=g({},i[s],t[s]);this.F({[rr]:r}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.za(rr)||{};this.F({[rr]:g({},e,{[t]:{}})})}else this.q(rr)}reset(){this.Ea++,this.Pa=!1,this.Ha(),this.Ma=!1,this.Ia=!1,this.Ra=!1,this.$anon_distinct_id=void 0,this.Ua(),this.ka=!1,this.Fa=0}}},Gl={sessionRecording:class{get qe(){return this._instance.config}get Rr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.oo)||!t.isStarted)}get status(){var t,e;return this.lo===ol||this.lo===al?this.lo:null!==(t=null==(e=this.oo)?void 0:e.status)&&void 0!==t?t:this.lo}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.lo=sl,this.uo=void 0,this.ho=!1,this.do=(()=>{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.Ee=()=>{var t;"visible"===(null==r?void 0:r.visibilityState)&&(this.do=!0,null==(t=this.oo)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw ul.error("started without valid sessionManager"),new Error(ll+" started without valid sessionManager. This is a bug.");if(this.qe.cookieless_mode===Tr)throw new Error(ll+' cannot be used with cookieless_mode="always"');null!=r&&r.addEventListener&&Vr(r,"visibilitychange",this.Ee)}initialize(){this.startIfEnabledOrStop()}dispose(){this.ho=!0,null==r||null==r.removeEventListener||r.removeEventListener("visibilitychange",this.Ee),this.stopRecording()}get vo(){var e,i=!(null==(e=this._instance.get_property(Ni))||!e.enabled),r=!this.qe.disable_session_recording,s=this.qe.disable_session_recording||this._instance.consent.isOptedOut();return t&&i&&r&&!s}startIfEnabledOrStop(t){var e;if(!(this.ho||this.vo&&null!=(e=this.oo)&&e.isStarted)){var i=!K(Object.assign)&&!K(Array.from);this.vo&&i?(this.co(t),ul.info("starting")):(this.lo=sl,this.stopRecording())}}co(t){var e,i,r;this.vo&&(this.lo!==ol&&this.lo!==al&&(this.lo=nl),null!=v&&null!=(e=v.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this.fo(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.po,(e=>{if(e)return ul.error("could not load recorder",e);this.fo(t)})))}stopRecording(){var t,e;null==(t=this.uo)||t.call(this),this.uo=void 0,null==(e=this.oo)||e.stop()}mo(){var t,e;null==(t=this.uo)||t.call(this),this.uo=void 0,null==(e=this.oo)||e.discard()}yo(){var t,e;null==(t=this.Rr)||t.unregister(Wi),null==(e=this.Rr)||e.unregister(Bi)}bo(t,e){if(X(t))return null;var i,r=Z(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(ul.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}_o(t){if(this.Rr){var e,i,r=this.Rr,s=()=>{var e,i=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.bo(null==(e=this.qe.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),n=this.bo(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:n;X(o)&&this.yo();var a=null==i?void 0:i.minimumDurationMilliseconds;r.register({[Ni]:g({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:g({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:K(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.uo)||e.call(this),this.uo=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._o(e),void this.mo()):(this._o(e),void this.startIfEnabledOrStop()):(this.lo===ol&&(this.lo=al,ul.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.oo)&&i.log?this.oo.log(t,e):ul.warn("log called before recorder was ready")}get po(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Ni);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}wo(){var t,e=this._instance.get_property(Ni);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return ul.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!X(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}fo(t){var e,i,r;if(!this.ho){if(null==(e=v.__PosthogExtensions__)||!e.initSessionRecording)return ul.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Er]:!0});var s;if(this.oo||(this.oo=null==(s=v.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.do),this.oo._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.wo()){if(this.lo===al||this.lo===ol)return;return this.lo=ol,ul.info("persisted remote config is stale, requesting fresh config before starting"),void new eo(this._instance).load()}this.lo=nl,null==(i=(r=this.oo).setDocumentWasEverVisible)||i.call(r,this.do),this.oo.start(t)}}onRRwebEmit(t){var e;null==(e=this.oo)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.oo||null==(e=this.Rr)||e.register({[Ui]:!0}),null==(t=this.oo)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.oo||null==(e=this.Rr)||e.register({[zi]:!0}),null==(t=this.oo)||t.overrideSampling()}overrideTrigger(t){var e,i;this.oo||null==(i=this.Rr)||i.register({["url"===t?qi:Hi]:!0}),null==(e=this.oo)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.oo)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.oo)||!i.tryAddCustomEvent(t,e))}}},Wl={autocapture:class{constructor(t){this.ko=!1,this.xo=null,this.So=!1,this.Co=!1,this.instance=t,this.rageclicks=new Va(t.config.rageclick),this.Mo=null}initialize(){this.startIfEnabled()}get qe(){var t,e,i=W(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}To(){if(this.isBrowserSupported()){if(t&&r){var e=e=>{e=e||(null==t?void 0:t.event);try{this.Eo(e)}catch(t){Ja.error("Failed to capture event",t)}};if(Vr(r,"submit",e,{capture:!0}),Vr(r,"change",e,{capture:!0}),Vr(r,"click",e,{capture:!0}),this.qe.capture_copied_text){var i=e=>{e=e||(null==t?void 0:t.event);try{this.Eo(e,Ka)}catch(t){Ja.error("Failed to capture copy/cut event",t)}};Vr(r,"copy",i,{capture:!0}),Vr(r,"cut",i,{capture:!0})}}}else Ja.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ko&&(this.To(),this.ko=!0)}onRemoteConfig(t){if(this.So=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Co=e.elementsChainAsString);var i=e.autocapture_opt_out;et(i)&&(this.instance.persistence&&this.instance.persistence.register({[Ri]:i}),this.xo=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Mo=t}getElementSelectors(t){var e,i=[];return null==(e=this.Mo)||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[Ri],r=this.xo,s=this.instance.tr()&&!this.So;if(Q(r)&&!et(i)&&!s)return!1;var n=null!==(e=this.xo)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!n}Eo(e,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r,s=Rs(e);xs(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())&&Bs(s,this.instance.config.rageclick)&&this.Eo(e,"$rageclick");var n=i===Ka;if(s&&function(e,i,r,s,n,o){var a;if(!t||zs(e))return!1;if(null!=r&&r.url_allowlist&&!$s(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&$s(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=Us(e,s),h=u.parentIsUsefulElement,d=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(K(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(!Ms(d,null==r?void 0:r.css_selector_allowlist))return!1;if(Ms(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:As))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&&(Cs.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this.qe,n,n?["copy","cut"]:void 0,this.instance)){var o=Xa(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qe.element_attribute_ignorelist,elementsChainAsString:this.Co,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===Ka){var u,h=Ts(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 G(null==r?void 0:r.querySelectorAll)}},historyAutocapture:class{constructor(e){var i;this._instance=e,this.Io=(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&&(mi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Po&&this.Po(),this.Po=void 0,mi.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Ro("pushState"),this.Ro("replaceState"),this.Ao())}Ro(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 tl;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 G(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];G(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 tl}}(t.history,e,(t=>function(i,s,n){t.call(this,i,s,n),r.Fo(e)}))}}Fo(e){try{var i,r=null==t||null==(i=t.location)?void 0:i.pathname;if(!r)return;r!==this.Io&&this.isEnabled&&this._instance.capture(Ar,{navigation_type:e}),this.Io=r}catch(t){mi.error("Error capturing "+e+" pageview",t)}}Ao(){if(!this.Po){var e=()=>{this.Fo("popstate")};Vr(t,"popstate",e),this.Po=()=>{t&&t.removeEventListener("popstate",e)}}}},heatmaps:class{get qe(){return this.instance.config}constructor(t){var e;this.Lo=!1,this.ko=!1,this.Oo=null,this.instance=t,this.Lo=!(null==(e=this.instance.persistence)||!e.props[Ci]),this.rageclicks=new Va(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return W(this.qe.capture_heatmaps)&&this.qe.capture_heatmaps.flush_interval_milliseconds&&(t=this.qe.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return X(this.qe.capture_heatmaps)?X(this.qe.enable_heatmaps)?this.Lo:this.qe.enable_heatmaps:!1!==this.qe.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ko)return;hl.info("starting..."),this.Do(),this.Ee()}else{var t;clearInterval(null!==(t=this.Oo)&&void 0!==t?t:void 0),this.$o(),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({[Ci]:i}),this.Lo=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}No(t){dl(t.originalEvent)&&this.ke(t.originalEvent,"deadclick")}Ee(){this.Oo&&clearInterval(this.Oo),this.Oo=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(r)?setInterval(this.br.bind(this),this.flushIntervalMilliseconds):null}Do(){t&&r&&(this.qo=this.br.bind(this),Vr(t,Ir,this.qo),this.jo=e=>this.ke(e||(null==t?void 0:t.event)),Vr(r,"click",this.jo,{capture:!0}),this.Bo=e=>this.Ho(e||(null==t?void 0:t.event)),Vr(r,"mousemove",this.Bo,{capture:!0}),this.Uo=new an(this.instance,nn,this.No.bind(this)),this.Uo.startIfEnabledOrStop(),this.zo=this.Ee.bind(this),Vr(r,Mr,this.zo),this.ko=!0)}$o(){var e;t&&r&&(this.qo&&t.removeEventListener(Ir,this.qo),this.jo&&r.removeEventListener("click",this.jo,{capture:!0}),this.Bo&&r.removeEventListener("mousemove",this.Bo,{capture:!0}),this.zo&&r.removeEventListener(Mr,this.zo),clearTimeout(this.Wo),null==(e=this.Uo)||e.stop(),this.ko=!1)}Vo(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&&bs(s)&&!ws(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(j(i,n))return!0;s=Is(s)}return!1}(Rs(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:r),target_fixed:o,type:i}}ke(t,e){var i;if(void 0===e&&(e="click"),!ys(t.target)&&dl(t)){var r=this.Vo(t,e);null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Bs(Rs(t),this.instance.config.rageclick)&&this.Gt(g({},r,{type:"rageclick"})),this.Gt(r)}}Ho(t){!ys(t.target)&&dl(t)&&(clearTimeout(this.Wo),this.Wo=setTimeout((()=>{this.Gt(this.Vo(t,"mousemove"))}),500))}Gt(e){if(t){var i=this.qe.disable_capture_url_hashes?be(t.location.href):t.location.href,r=this.qe.custom_personal_data_properties,s=this.qe.mask_personal_data_properties?[...En,...r||[]]:[],n=bn(i,s,Pn);this.R=this.R||{},this.R[n]||(this.R[n]=[]),this.R[n].push(e)}}br(){this.R&&!V(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:an,webVitalsAutocapture:class{constructor(t){var e;this.Lo=!1,this.ko=!1,this.R={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Zo=()=>{clearTimeout(this.Go),this.Go=void 0,0!==this.R.metrics.length&&(this._instance.capture("$web_vitals",g({$current_url:this.R.url},this.R.metrics.reduce(((t,e)=>g({},t,{["$web_vitals_"+e.name+"_event"]:g({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{}))),this.R={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Qo=t=>{var e;if(this.R=this.R||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},X(null==t?void 0:t.name)||X(null==t?void 0:t.value))il.error("Invalid metric received",t);else{var i="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.Ko(i);if(!K(r)){var s=Z(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.Jo||this.Jo>t.value){this.R.navigationKey!==s&&(this.Zo(),this.Go=setTimeout(this.Zo,this.flushToCaptureTimeoutMs)),K(this.R.navigationKey)&&(this.R.navigationKey=s,this.R.url=r),this.R.firstMetricTimestamp=K(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var n=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=g({},t,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});K(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.R.metrics.push(o),this.R.metrics.length===this.allowedMetrics.length&&this.Zo()}else il.error("Ignoring metric with value >= "+this.Jo,t)}}},this.Yo=()=>{if(!this.ko){var t,e,i,r,s=v.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this.Xo])||("web-vitals"===this.Xo&&K(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(K(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.Qo.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&e(this.Qo.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this.Qo.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this.Qo.bind(this),a),this.ko=!0}else il.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Lo=!(null==(e=this._instance.persistence)||!e.props[Oi]),this.startIfEnabled()}get tl(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=W(this.tl)?null==(t=this.tl)?void 0:t.web_vitals_allowed_metrics:void 0;return X(i)?(null==(e=this._instance.persistence)?void 0:e.props[Li])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(W(this.tl)?this.tl.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=W(this.tl)?this.tl.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=W(this.tl)?this.tl.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Jo(){var t=W(this.tl)&&Z(this.tl.__web_vitals_max_value)?this.tl.__web_vitals_max_value:rl;return t>0&&6e4>=t?rl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return il.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=W(this.tl)?this.tl.web_vitals:et(this.tl)?this.tl:void 0;return et(e)?e:this.Lo}startIfEnabled(){this.isEnabled&&!this.ko&&(il.info("enabled, starting..."),this.di(this.Yo))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=W(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=W(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Oi]:i}),this._instance.persistence.register({[Li]:r})),this.Lo=i,this.startIfEnabled()}}}get Xo(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}di(t){var e=v.__PosthogExtensions__,i=this.Xo,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&K(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,(e=>{e?il.error("failed to load script",e):t()}))}Ko(e){var i=e||(null==t?void 0:t.location.href);if(i){var r=this._instance.config.disable_capture_url_hashes?be(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...En,...s||[]]:[];return bn(r,n,Pn)}il.error("Could not determine current URL")}}},Vl={exceptionObserver:class{constructor(e){var i;this.Yo=()=>{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.el&&this.qe.capture_unhandled_errors&&(this.el=i(this.captureException.bind(this))),!this.il&&this.qe.capture_unhandled_rejections&&(this.il=r(this.captureException.bind(this))),!this.rl&&this.qe.capture_console_errors&&(this.rl=s(this.captureException.bind(this)))}catch(t){Za.error("failed to start",t),this.nl()}}},this._instance=e,this.sl=!(null==(i=this._instance.persistence)||!i.props[Mi]),this.al=new ct(g({},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,st:Za})),this.qe=this.ol(),this.startIfEnabledOrStop()}ol(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return W(t)?e=g({},e,t):(K(t)?this.sl:t)&&(e=g({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qe.capture_console_errors||this.qe.capture_unhandled_errors||this.qe.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Za.info("enabled"),this.nl(),this.di(this.Yo)):this.nl()}di(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 Za.error("failed to load script",e);t()}))}nl(){var t,e,i;null==(t=this.el)||t.call(this),this.el=void 0,null==(e=this.il)||e.call(this),this.il=void 0,null==(i=this.rl)||i.call(this),this.rl=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.sl=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Mi]:this.sl}),this.qe=this.ol(),this.startIfEnabledOrStop())}}onConfigChange(){this.qe=this.ol()}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.al.consumeRateLimit(s)?Za.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.ll=[],this.ul=new ze([new Ze,new ui,new ei,new ti,new ai,new oi,new ri,new li],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=Xe.test(a)?a.replace(Xe,"$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 g({},t,{filename:t.filename||(i=e,i[i.length-1]||{}).filename,function:t.function||Ue});var i}))}(s)}}("web:javascript",Ke,Qe)),this._instance=t,this.ll=null!==(e=null==(i=this._instance.persistence)?void 0:i.get_property(Ii))&&void 0!==e?e:[],this.hl=fi(this.dl()),this.vl=new pi(this.hl)}onConfigChange(){this.hl=fi(this.dl()),this.vl.setConfig(this.hl)}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.ll=n,this._instance.persistence&&this._instance.persistence.register({[Ii]:this.ll,[Ai]:o})}}}get cl(){var t,e=!!this._instance.get_property(Ai),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.ul.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.hl.enabled)try{if(!J(t)||0===t.trim().length)return void Al.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)=>vi.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(this.fl(e)),r=i.sanitizedProperties,s=i.droppedKeys;s.length>0&&Al.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.vl.add(g({[hi]:t,[di]:(new Date).toISOString()},r))}catch(t){Al.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.pl(e)){if(this.gl(e))return this.ml("Exception dropped: matched a suppression rule"),void Al.info("Skipping exception capture because a suppression rule matched");if(!this.cl&&this.yl(e))return this.ml("Exception dropped: thrown by a browser extension"),void Al.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.bl(e))return this.ml("Exception dropped: thrown by the PostHog SDK"),void Al.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.hl.enabled&&X(t.$exception_steps)?this._l(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",ts:!0});return s&&this.vl.clear(),s}catch(t){return Al.error("Failed to capture exception event. Dropping this exception.",t),void this.vl.clear()}}catch(t){return void Al.error("Failed to process exception event. Ignoring this exception.",t)}var n}_l(t){try{var e=this.vl.getAttachable();return 0===e.length?t:g({},t,{$exception_steps:e})}catch(e){return Al.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}ml(t){this.hl.enabled&&this.vl.add({[hi]:t,[di]:(new Date).toISOString()})}fl(t){return W(t)?g({},t):{}}dl(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}gl(t){if(0===t.length)return!1;try{var e=t.reduce(((t,e)=>{var i=e.type,r=e.value;return J(i)&&i.length>0&&t.$exception_types.push(i),J(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.ll.some((t=>{var i=t.values.map((t=>{var i=da[t.operator],r=e[t.key];if(!i||!r)return!1;var s=H(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 Al.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}yl(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=>t.filename&&t.filename.startsWith("chrome-extension://")))}bl(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}pl(t){return!X(t)&&H(t)}}},Kl=g({productTours:class{get Rr(){return this._instance.persistence}constructor(t){this.wl=null,this.kl=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.Rr&&this.Rr.register({[ji]:!!e.productTours}),!cl(this._instance))return!this.wl&&X(null==(i=this.Rr)?void 0:i.props[ur])||vl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.wl)||r.stop(),this.wl=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.wl&&cl(this._instance)&&this.di((()=>this.xl()))}di(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?vl.error("Could not load product tours script",e):t()}))}xl(){var t;!this.wl&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.wl=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!H(this.kl)||e){var i=this.Rr;if(i){var r=i.props[ur];if(H(r)&&!e)return this.kl=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(cl(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||vl.warn(s):vl.error(s),void t([],{isLoaded:!1,error:s})}var n=H(e.json.product_tours)?e.json.product_tours:[];this.kl=n,i&&i.register({[ur]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.kl,{isLoaded:!0})}getActiveProductTours(t){X(this.wl)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.wl.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.wl)||e.showTourById(t)}previewTour(t){this.wl?this.wl.previewTour(t):this.di((()=>{var e;this.xl(),null==(e=this.wl)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.wl)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.wl)||t.nextStep()}previousStep(){var t;null==(t=this.wl)||t.previousStep()}clearCache(){var t;this.kl=null,null==(t=this.Rr)||t.unregister(ur)}resetTour(t){var e;null==(e=this.wl)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.wl)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.wl)||e.cancelPendingTour(t)}}},Hl),Jl={siteApps:class{constructor(t){this.Sl=0,this._instance=t,this.Cl=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Ml(t,e){if(e){var i=this.globalsForEvent(e);this.Cl.push(i),this.Cl.length>1e3&&(this.Cl=this.Cl.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.Ml.bind(this));this.Tl=()=>{t(),this.Cl=[],this.Tl=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,fl),{properties:g({},t.properties,f?{$set:g({},null!==(e=null==(i=t.properties)?void 0:i.$set)&&void 0!==e?e:{},f)}:{},c?{$set_once:g({},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}}El(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)||(pl.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)||(pl.error("prepare_external_dependency_script returned null"),null):t}Il(){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.Sl++,this.Pl)return this.Rl();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.El(t);return e&&c.add(e),e},g=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!Q(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,g(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,g(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,g(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,g(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=g(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.Pl=()=>{d.forEach((t=>t())),this.Pl=void 0},this.Rl()}Rl(){var t=!1;return()=>{var e;t||(t=!0,this.Sl--,0===this.Sl&&(null==(e=this.Pl)||e.call(this)))}}Al(t,e){void 0===e&&(e=!0);var i=this.Il();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.Cl.length&&(pl.info("Processing "+this.Cl.length+" events for site app with id "+t.id),this.Cl.forEach((t=>this.Al((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Tl)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,pl.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this.Al((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1).processEvent;n&&(e.processEvent=n),r=!0}catch(e){pl.error(gl+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){pl.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Fl(){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)}Ll(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Al((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){pl.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.Fl(),void this._instance.on("eventCaptured",(t=>this.Ll(t)))):void pl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Tl)||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 pl.error(gl+e,t)}))};for(var a of n.siteApps)o()}else pl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Yl={tracingHeaders:class{constructor(t){this.Ol=void 0,this.Dl=void 0,this.$l=void 0,this.Yo=()=>{var t,e,i=this.Nl();i?(K(this.Ol)&&(this.Ol=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),K(this.Dl)&&(this.Dl=null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.nl()},this._instance=t}initialize(){this.startIfEnabledOrStop()}di(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 el.error("failed to load script",e);t()}))}ql(){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}Nl(){var t=this.ql();return H(t)?(H(this.$l)?this.$l.splice(0,this.$l.length,...t):this.$l=[...t],t.length>0?this.$l:void 0):(H(this.$l)&&this.$l.splice(0),this.$l=t||void 0,this.$l)}nl(){var t,e;null==(t=this.Ol)||t.call(this),null==(e=this.Dl)||e.call(this),this.Ol=void 0,this.Dl=void 0}startIfEnabledOrStop(){this.Nl()?this.di(this.Yo):this.nl()}}},Ql=g({surveys:class{get qe(){return this._instance.config}constructor(t){this.jl=void 0,this._surveyManager=null,this.Bl=!1,this.Hl=[],this.Ul=null,this.zl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qe.disable_surveys){if(!t.ok)return ba.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(X(e))return ba.warn("Flags not loaded yet. Not loading surveys.");var i=H(e);this.jl=i?e.length>0:e,ba.info("flags response received, isSurveysEnabled: "+this.jl),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;ilocalStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.Bl)ba.info("Already initializing surveys, skipping...");else if(this.qe.disable_surveys)ba.info(xl);else if(this.qe.cookieless_mode&&this._instance.consent.isOptedOut())ba.info("Not loading surveys in cookieless mode without consent.");else{var t=null==v?void 0:v.__PosthogExtensions__;if(t){if(!K(this.jl)||this.qe.advanced_enable_surveys){var e=this.jl||this.qe.advanced_enable_surveys;this.Bl=!0;try{var i=t.generateSurveys;if(i)return void this.Wl(i,e);var r=t.loadExternalDependency;if(!r)return void this.Vl($r);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.Vl("Could not load surveys script",i):this.Wl(t.generateSurveys,e)}))}catch(t){throw this.Vl("Error initializing surveys",t),t}finally{this.Bl=!1}}}else ba.error("PostHog Extensions not found.")}}Wl(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new bl(this._instance),ba.info("Surveys loaded successfully"),this.Zl({isLoaded:!0})}Vl(t,e){ba.error(t,e),this.Zl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Hl.push(t),this._surveyManager&&this.Zl({isLoaded:!0}),()=>{this.Hl=this.Hl.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.qe.disable_surveys)return ba.info(xl),t([]);var i,r=this._instance.get_property(sr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.Gl()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.Ul?this.Ul.then((e=>t(e.surveys,e.context))):("undefined"!=typeof Promise&&(this.Ul=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qe.token),method:"GET",timestampMode:"query",timeout:this.qe.surveys_request_timeout_ms,callback:e=>{var r;this.Ul=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;0!==s?ba.error(n):e.error||ba.warn(n),this.zl=Date.now();var o={isLoaded:!1,error:n};return t([],o),void(null==i||i({surveys:[],context:o}))}this.zl=null;var a,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(ya(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({[sr]:l,[nr]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}Gl(){return this.Ql()&&!this.Ul&&!this.Kl()}Ql(){var t=this._instance.get_property(nr);return Z(t)&&Date.now()-t>3e5}Kl(){return Z(this.zl)&&3e5>Date.now()-this.zl}markSurveyAsSeen(t,e){var i,r={id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null};xa(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}Zl(t){for(var e of this.Hl)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){ba.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!X(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ba.warn("init was not called")}Jl(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}Yl(t){if(X(this._surveyManager))return{eligible:!1,reason:wl};var e="string"==typeof t?this.Jl(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Xl(t){if(X(this._surveyManager))return{eligible:!1,reason:wl};var e="string"==typeof t?this.Jl(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(X(this._surveyManager))return ba.warn("init was not called"),{visible:!1,disabledReason:wl};var e=this.Xl(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return X(this._surveyManager)?(ba.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:wl})):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.Xl(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(X(this._surveyManager))ba.warn("init was not called");else{var n="string"==typeof t?this.Jl(t):t;if(null!=n&&n.id)if(Sa.includes(n.type)){var o=null==r?void 0:r.querySelector(e);if(o)return null!=(s=n.appearance)&&s.surveyPopupDelaySeconds?(ba.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;ba.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),ba.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,o,i);ba.warn("Survey element not found")}else ba.warn("Surveys of type "+n.type+" cannot be rendered in the app");else ba.warn("Survey not found")}}displaySurvey(t,e){var i;if(X(this._surveyManager))ba.warn("init was not called");else{var r=this.Jl(t);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=g({},r,{appearance:g({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Qn&&e.initialResponses&&ba.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var n=this.Yl(r);if(!n.eligible)return void ba.warn("Survey is not eligible to be displayed: ",n.reason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else ba.warn("Survey not found")}}cancelPendingSurvey(t){X(this._surveyManager)?ba.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},Hl),Xl={toolbar:class{constructor(t){this.instance=t}tu(t){v.ph_toolbar_state=t}eu(){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),Kr(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=Sl||wn(e.hash,"__posthog")||wn(e.hash,"state"),a=o?Ur((()=>JSON.parse(atob(decodeURIComponent(o)))))||Ur((()=>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(kl)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}iu(t){var e=v.ph_load_toolbar||v.ph_load_editor;!X(e)&&G(e)?e(t,this.instance):El.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==r||!r.getElementById(ps));if(!t||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=g({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(kl,JSON.stringify(g({},n,{source:void 0}))),2===this.eu())this.iu(n);else if(0===this.eu()){var o;this.tu(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return El.error("[Toolbar] Failed to load",t),void this.tu(0);this.tu(2),this.iu(n)})),Vr(t,"turbolinks:load",(()=>{this.tu(0),this.loadToolbar(n)}))}return!0}ru(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)}}},Zl=g({experiments:jl},Hl),tu={conversations:class{constructor(t){this.nu=void 0,this._conversationsManager=null,this.su=!1,this.au=null,this.ou=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.lu=t.ok,t.ok)){var e=t.config.conversations;X(e)||(et(e)?this.nu=e:(this.nu=e.enabled,this.au=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.nu=void 0,this.au=null,this.lu=void 0,this.ou=!1}loadIfEnabled(){if(!(this._conversationsManager||this.su||this._instance.config.disable_conversations||Kr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!K(this.nu)&&this.nu)if(this.au&&this.au.token){this.su=!0;try{var e=t.initConversations;if(e)return this.uu(e),void(this.su=!1);var i=t.loadExternalDependency;if(!i)return void this.hu($r);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.hu("Could not load conversations script",e):this.uu(t.initConversations),this.su=!1}))}catch(t){this.hu("Error initializing conversations",t),this.su=!1}}else Ll.error("Conversations enabled but missing token in remote config.")}}uu(t){if(this.au)try{this._conversationsManager=t(this.au,this._instance),this.ou=!1,Ll.info("Conversations loaded successfully")}catch(t){this.hu("Error completing conversations initialization",t)}else Ll.error("Cannot complete initialization: remote config is null")}hu(t,e){Ll.error(t,e),this._conversationsManager=null,this.su=!1,this.ou=!0}show(){this._conversationsManager?this._conversationsManager.show():Ll.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.nu&&!Q(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Kr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.lu?"remote_config_failed":K(this.nu)?this.lu?"disabled_in_project":"remote_config_pending":this.nu?X(this.au)||!this.au.token?"missing_token":null!=v&&v.__PosthogExtensions__?this.su?"initializing":this.ou?"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):(Ll.warn(Nl),null)}))()}getMessages(t,e){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Ll.warn(Nl),null)}))()}markAsRead(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ll.warn(Nl),null)}))()}getTickets(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ll.warn(Nl),null)}))()}requestRestoreLink(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ll.warn(Nl),null)}))()}restoreFromToken(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ll.warn(Nl),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ll.warn(Nl),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}hs(){var t;null==(t=this._conversationsManager)||t.setIdentity()}ds(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},eu={logs:class{constructor(e){var i,r=this;this.du=!1,this.vu=!1,this.st=yi("[logs]"),this.cu=g({},this.st,{error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];e.some(ql)||r.st.error(...e)}}),this.sr=[],this.fu=[],this.Fa=0,this.pu=()=>{var t,e;this.Fa=0,null==(t=this.gu)||t.onReconnect(),null==(e=this.mu)||e.onReconnect()},this._instance=e,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.du=!0),t&&Vr(t,"online",this.pu)}yu(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=K(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 Me(this.bu(t,e),n,this.cu,(()=>this._u()),(t=>t()),void 0,r),n]}wu(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.gu||this.ku!==e){var i;null==(i=this.gu)||i.reset(),this.ku=e;var r=this.yu((()=>this.sr),(t=>{this.sr=t}));this.gu=r[0],this.xu=r[1]}return this.gu}Su(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.mu||this.Cu!==e){var i;null==(i=this.mu)||i.reset(),this.Cu=e;var r=this.yu((()=>this.fu),(t=>{this.fu=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Bl);this.mu=r[0],this.Mu=r[1]}return this.mu}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e;if(t.ok){var i=null==(e=t.config.logs)?void 0:e.captureConsoleLogs;!X(i)&&i&&(this.du=!0,this.loadIfEnabled())}}reset(){var t,e;this.sr=[],null==(t=this.gu)||t.reset(),this.fu=[],null==(e=this.mu)||e.reset(),this.Fa=0}captureLog(t){this.wu().captureLog(t)}he(t){this.Su().captureLog(t)}get logger(){return this.Tu||(this.Tu={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.Tu}flushLogs(t){t?this.Eu(t):(this.gu&&this.gu.flush().catch((t=>this.Iu(t))),this.mu&&this.mu.flush().catch((t=>this.Iu(t))))}Iu(t){ql(t)||this.st.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.du&&!this.vu){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.st.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.vu=!0)})):this.st.error($r)}else this.st.error("PostHog Extensions not found.")}}bu(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:[])},$t:t=>this.$t(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}$t(t){return new Promise((e=>{if(xn(this.Fa,3))e({kind:"fatal",error:Ul(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>{this.st.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Ul(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Pu(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var e=t.statusCode;if(this.Ru(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.st.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Ul(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)})}}})}}))}Ru(t){(0!==t||this._instance.__loaded)&&(this.Fa=Sn(t,this.Fa,3,(()=>this.st.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."))))}Eu(t){this.sr.length>0&&this.Au(t,this.sr,this.xu,c.LIB_NAME,(t=>{this.sr=t})),this.fu.length>0&&this.Au(t,this.fu,this.Mu,Bl,(t=>{this.fu=t}))}Au(t,e,i,r,s){if(0!==e.length){var n=e.map((t=>t.record));s([]);var o=Ce(n,Re(i,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Pu(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Pu(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_u(){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,X(s)||(e.sessionStartTimestamp=s),X(n)||(e.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?be(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},iu={metrics:class{constructor(t){this.st=yi("[metrics]"),this._instance=t}initialize(){}wu(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.gu&&this.ku===i||(null==(e=this.gu)||e.reset(),this.ku=i,this.gu=new De(this.bu(),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.st)),this.gu}count(t,e,i){void 0===e&&(e=1),this.wu().count(t,e,i)}gauge(t,e,i){this.wu().gauge(t,e,i)}histogram(t,e,i){this.wu().histogram(t,e,i)}flush(t){if(!this.gu)return Promise.resolve();if(t){var e=this.gu.drainWindow();return e&&this.Xt(e,t),Promise.resolve()}return this.gu.flush().catch((t=>this.st.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.gu)||t.reset()}bu(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Xt:t=>e.Xt(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Xt(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(g({method:"POST",url:this.Fu(),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)})}}}))}))}Fu(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},ru=g({},Hl,Gl,Wl,Vl,Kl,Jl,Ql,Yl,Xl,Zl,tu,eu,iu);Wa.__defaultExtensionClasses=g({},ru),function(){c.SDK_DIST_CHANNEL="cdn";var e=v.posthog;if(!e||H(e._i)){var i=Ma[Ba]=new Wa;if(e){var s=[];Nr(e._i,(function(t){if(t&&H(t)){var r=i.init(t[0],t[1],t[2]),n=e[t[2]]||e;r.__loaded&&-1===s.indexOf(n)&&(s.push(n),r._execute_array.call(r.people,n.people),r._execute_array(n))}}))}i.__SV=1,v.posthog=i,function(){function e(){e.done||(e.done=!0,za=!1,Nr(Ma,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?e():Vr(r,"DOMContentLoaded",e,{capture:!1}):t&&mi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}}()}(); //# sourceMappingURL=array.js.map