posthog-js 1.412.0 → 1.412.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(){"use strict";function e(e,t,i,r,s,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s={DEBUG:!1,LIB_VERSION:"0.3.1",LIB_NAME:"browser-common"};s.DEBUG=!1,s.LIB_VERSION="1.412.0",s.LIB_NAME="web";var n="$people_distinct_id",o="$device_id",a="$device_model",l="__alias",u="__timers",c="$autocapture_disabled_server_side",d="$heatmaps_enabled_server_side",h="$exception_capture_enabled_server_side",_="$error_tracking_suppression_rules",p="$error_tracking_capture_extension_exceptions",g="$web_vitals_enabled_server_side",v="$dead_clicks_enabled_server_side",f="$product_tours_enabled_server_side",m="$web_vitals_allowed_metrics",y="$session_recording_remote_config",b="$replay_sample_rate",w="$replay_override_sampling",S="$replay_override_linked_flag",x="$replay_override_url_trigger",E="$replay_override_event_trigger",k="$sesid",P="$session_is_sampled",C="$enabled_feature_flags",I="$active_feature_flags",F="$early_access_features",T="$feature_flag_details",R="$feature_flag_payloads",A="$feature_flag_request_id",L="$minimal_flag_called_events",M="$override_feature_flags",O="$override_feature_flag_payloads",D="$stored_person_properties",B="$stored_group_properties",q="$surveys",N="$surveys_loaded_at",z="$surveys_activated",H="$surveys_activated_session",j="$surveys_activated_timestamps",U="ph_product_tours",W="$flag_call_reported",V="$flag_call_reported_session_id",G="$feature_flag_errors",K="$feature_flag_evaluated_at",Q="$user_state",J="$client_session_props",Y="$capture_rate_limit",Z="$initial_campaign_params",X="$initial_referrer_info",ee="$initial_person_info",te="$epp",ie="$posthog_cookieless",re="$cookieless_mode",se="$sdk_debug_extensions_init_method",ne="$sdk_debug_extensions_init_time_ms",oe="$sdk_debug_recording_script_not_loaded",ae="PostHog loadExternalDependency extension not found.",le="on_reject",ue="always",ce="anonymous",de="identified",he="identified_only",_e="visibilitychange",pe="beforeunload",ge="$pageview",ve="$pageleave",fe="$identify",me="$groupidentify",ye="undefined"!=typeof window?window:void 0,be="undefined"!=typeof globalThis?globalThis:ye,we=null==be?void 0:be.navigator,Se=null==be?void 0:be.document,xe=null==be?void 0:be.location,Ee=null==be?void 0:be.fetch,ke=null!=be&&be.XMLHttpRequest&&"withCredentials"in new be.XMLHttpRequest?be.XMLHttpRequest:void 0,Pe=null==be?void 0:be.AbortController,Ce=null==be?void 0:be.CompressionStream,Ie=null==we?void 0:we.userAgent;function Fe(){return!(!ye||!1===ye.navigator.onLine)}var Te="undefined"!=typeof globalThis?globalThis:ye;Te&&"undefined"==typeof self&&(Te.self=Te),Te&&"undefined"==typeof File&&(Te.File=function(){});var Re=null!=ye?ye:{},Ae=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Le(e){return"string"==typeof e||e}function Me(e){return"string"==typeof e?e:void 0}var $e,Oe=["$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"],De=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),Be=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),qe=["$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"],Ne=["token"],ze="NativeGzipValidationError",He=e=>e.length>=2&&31===e[0]&&139===e[1],je=(e,t)=>e===Be.GZipJS||t===Be.GZipJS||"gzip"===t,Ue=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),We=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=ze,t},Ve=function(){var e=t((function*(e,t){18>e.size&&We("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());He(i)&&8===i[2]||We("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if($e)return $e;$e=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;$e[e]=t>>>0}return $e})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&We("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&We("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function Ge(){return Ge=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=(new TextEncoder).encode(e),n=new globalThis.CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(s).then((()=>o.close())).catch(function(){var e=t((function*(e){try{yield o.abort(e)}catch(e){}throw e}));return function(t){return e.apply(this,arguments)}}()),l=new Response(n.readable).blob(),u=(yield Promise.all([l,a]))[0];return yield Ve(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),Ge.apply(this,arguments)}var Ke=["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"],Qe=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ke.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function Je(e,t){return-1!==e.indexOf(t)}var Ye=function(e){return e.trim()},Ze=function(e){return e.replace(/^\$/,"")};function Xe(e){var t,i=[];return null!==(t=JSON.stringify(e,(function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}})))&&void 0!==t?t:"null"}var et=Object.prototype,tt=et.hasOwnProperty,it=et.toString,rt=Array.isArray||function(e){return"[object Array]"===it.call(e)},st=e=>"function"==typeof e,nt=e=>e===Object(e)&&!rt(e),ot=e=>{if(nt(e)){for(var t in e)if(tt.call(e,t))return!1;return!0}return!1},at=e=>void 0===e,lt=e=>"[object String]"==it.call(e),ut=e=>lt(e)&&0===e.trim().length,ct=e=>null===e,dt=e=>at(e)||ct(e),ht=e=>"[object Number]"==it.call(e)&&e==e,_t=e=>ht(e)&&e>0,pt=e=>"[object Boolean]"===it.call(e),gt=e=>e instanceof FormData,vt=e=>Je(qe,e),ft=e=>Je(Ne,e);function mt(e){return null===e||"object"!=typeof e}function yt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function bt(e){return"undefined"!=typeof Event&&wt(e,Event)}function wt(e,t){try{return e instanceof t}catch(e){return!1}}var St=[!0,"true",1,"1","yes"],xt=e=>Je(St,e),Et=[!1,"false",0,"0","no"];function kt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),ht(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),kt(s||i,t,i,r))}class Pt{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=kt(e.bucketSize,0,100,e._logger),this._refillRate=kt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=kt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),s=this._buckets[r];return s?this._applyRefill(s,i):this._buckets[r]=s={tokens:this._bucketSize,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}}var Ct="Mobile",It="iOS",Ft="Android",Tt="Tablet",Rt=Ft+" "+Tt,At="iPad",Lt="Apple",Mt=Lt+" Watch",$t="Safari",Ot="BlackBerry",Dt="Samsung",Bt=Dt+"Browser",qt=Dt+" Internet",Nt="Chrome",zt=Nt+" OS",Ht=Nt+" "+It,jt="Internet Explorer",Ut=jt+" "+Ct,Wt="Opera",Vt=Wt+" Mini",Gt="Edge",Kt="Microsoft "+Gt,Qt="Firefox",Jt=Qt+" "+It,Yt="Nintendo",Zt="PlayStation",Xt="Xbox",ei=Ft+" "+Ct,ti=Ct+" "+$t,ii="Windows",ri=ii+" Phone",si="Nokia",ni="Ouya",oi="Generic",ai=oi+" "+Ct.toLowerCase(),li=oi+" "+Tt.toLowerCase(),ui="Konqueror",ci="Oculus Browser",di="Vivaldi",hi="Yandex",_i="Whale",pi="DuckDuckGo",gi="Pale Moon",vi="Waterfox",fi="Brave",mi="Google Search App",yi="(\\d+(\\.\\d+)?)",bi=new RegExp("Version/"+yi),wi=new RegExp(Xt,"i"),Si=new RegExp(Zt+" \\w+","i"),xi=new RegExp(Yt+" \\w+","i"),Ei=new RegExp(Ot+"|PlayBook|BB10","i"),ki={"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"},Pi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?fi:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&Je(e,"GSA/")?mi:Je(e," OPR/")&&Je(e,"Mini")?Vt:Je(e," OPR/")?Wt:Ei.test(e)?Ot:Je(e,"IE"+Ct)||Je(e,"WPDesktop")?Ut:Je(e,"OculusBrowser")?ci:Je(e,Bt)?qt:Je(e,Gt)||Je(e,"Edg/")?Kt:Je(e,di+"/")?di:Je(e,"YaBrowser/")?hi:Je(e,_i+"/")?_i:Je(e,pi+"/")||Je(e,"Ddg/")?pi:Je(e,"FBIOS")?"Facebook "+Ct:Je(e,"UCWEB")||Je(e,"UCBrowser")?"UC Browser":Je(e,"CriOS")?Ht:Je(e,"CrMo")||Je(e,Nt)?Nt:Je(e,Ft)&&Je(e,$t)?ei:Je(e,"FxiOS")?Jt:Je(e.toLowerCase(),ui.toLowerCase())?ui:Je(e,fi+"/")?fi:((e,t)=>t&&Je(t,Lt)||function(e){return Je(e,$t)&&!Je(e,Nt)&&!Je(e,Ft)}(e))(e,t)?Je(e,Ct)?ti:$t:Je(e,"PaleMoon/")?gi:Je(e,vi+"/")?vi:Je(e,Qt)?Qt:Je(e,"MSIE")||Je(e,"Trident/")?jt:Je(e,"Gecko")?Qt:"")},Ci={[Ut]:[new RegExp("rv:"+yi)],[Kt]:[new RegExp(Gt+"?\\/"+yi)],[Nt]:[new RegExp("("+Nt+"|CrMo)\\/"+yi)],[Ht]:[new RegExp("CriOS\\/"+yi)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+yi)],[$t]:[bi],[ti]:[bi],[Wt]:[new RegExp("(Opera|OPR)\\/"+yi)],[Qt]:[new RegExp(Qt+"\\/"+yi)],[Jt]:[new RegExp("FxiOS\\/"+yi)],[ui]:[new RegExp("Konqueror[:/]?"+yi,"i")],[Ot]:[new RegExp(Ot+" "+yi),bi],[ei]:[new RegExp("android\\s"+yi,"i")],[qt]:[new RegExp(Bt+"\\/"+yi)],[ci]:[new RegExp("OculusBrowser\\/"+yi)],[di]:[new RegExp(di+"\\/"+yi)],[hi]:[new RegExp("YaBrowser\\/"+yi)],[_i]:[new RegExp(_i+"\\/"+yi)],[fi]:[new RegExp(fi+"\\/"+yi)],[pi]:[new RegExp("(DuckDuckGo|Ddg)\\/"+yi)],[gi]:[new RegExp("PaleMoon\\/"+yi)],[vi]:[new RegExp(vi+"\\/"+yi)],[mi]:[new RegExp("GSA\\/"+yi)],[jt]:[new RegExp("(rv:|MSIE )"+yi)],Mozilla:[new RegExp("rv:"+yi)]},Ii=function(e,t,i,r){var s=Pi(e,t,i,r),n=Ci[s];if(at(n))return null;for(var o=0;n.length>o;o++){var a=e.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},Fi=[[new RegExp(Xt+"; "+Xt+" (.*?)[);]","i"),e=>[Xt,e&&e[1]||""]],[new RegExp(Yt,"i"),[Yt,""]],[new RegExp(Zt,"i"),[Zt,""]],[Ei,[Ot,""]],[new RegExp(ii,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ri,""];if(new RegExp(Ct).test(t)&&!/IEMobile\b/.test(t))return[ii+" "+Ct,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=ki[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[ii,r]}return[ii,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[It,[e[3],e[4],e[5]||"0"].join(".")]:[It,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=at(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Ft+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ft+")","i"),e=>e&&e[2]?[Ft,[e[2],e[3],e[4]||"0"].join(".")]:[Ft,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[zt,""]],[/Linux|debian/i,["Linux",""]]],Ti=function(e){return xi.test(e)?Yt:Si.test(e)?Zt:wi.test(e)?Xt:new RegExp(ni,"i").test(e)?ni:new RegExp("("+ri+"|WPDesktop)","i").test(e)?ri:/iPad/.test(e)?At:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Mt:Ei.test(e)?Ot:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(si,"i").test(e)?si:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Ct).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Ft:Rt:new RegExp("(pda|"+Ct+")","i").test(e)?ai:new RegExp(Tt,"i").test(e)&&!new RegExp(Tt+" pc","i").test(e)?li:""},Ri=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ai(e,t){return"string"==typeof(i=e)&&Ri.test(i)?e:t();var i}function Li(e){return e?e.split("#")[0]:e}function Mi(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function $i(e,t,i){return Oi.apply(this,arguments)}function Oi(){return(Oi=t((function*(e,t,i){var r;try{return yield Promise.race([e,new Promise(((e,s)=>{r=Mi((()=>{try{null==i||i(),e()}catch(e){s(e)}}),t)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Di=e=>e instanceof Error,Bi={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}},qi=Bi.info;function Ni(e){if(pt(e))return{boolValue:e};if("number"==typeof e)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if("string"==typeof e)return{stringValue:e};if(rt(e))return{arrayValue:{values:e.map((e=>Ni(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function zi(e){var t=[];for(var i in e){var r=e[i];ct(r)||at(r)||t.push({key:i,value:Ni(r)})}return t}function Hi(e,t){var r=Bi[e.level||"info"]||qi,s=r.text,n=r.number,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.windowId&&(a["window.id"]=t.windowId),dt(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),dt(t.lastActivityTimestamp)||(a.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=i({},a,e.attributes||{}),u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:s,body:{stringValue:e.body},attributes:zi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),at(e.trace_flags)||(u.flags=e.trace_flags),u}function ji(e,t,r){return i({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":r})}function Ui(e,t,i,r){return{resourceLogs:[{resource:{attributes:zi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let Wi=class{constructor(e,t,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=e,this._config=t,this._logger=i,this._getContext=r,this._onReady=s,this._waitForStoragePersist=n,this._scopeName=o,this._flushPromise=null,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}reset(){this._clearFlushTimer(),this._flushPromise=null,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushInBackground()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=e&&e.body){var t=this._runBeforeSend(e);if(null!==t)if(t.body){if(this._checkRateLimit()){var i={record:Hi(t,this._getContext())};this._onReady((()=>this._enqueue(i)))}}else this._logger.info("Log was rejected in beforeSend function")}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=rt(t)?t:[t],r=e;for(var s of i)try{var n=s(r);if(!n)return this._logger.info("Log was rejected in beforeSend function"),null;r=n}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return r}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;var e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||(this._logger.warn("captureLog dropping logs: exceeded "+this._maxLogsPerInterval+" logs per "+this._rateCapWindowMs+"ms"),this._droppedWarned=!0),!1)}flush(){var e=this;return t((function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally((()=>{e._flushPromise=null}))),e._flushPromise}))()}_flushInner(){var e=this;return t((function*(){var t;e._clearFlushTimer();var i=null!==(t=e._instance.getPersistedProperty(De.LogsQueue))&&void 0!==t?t:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,o;e._evictedSinceAdvance=0;var a=Math.min(i.length,e._maxBatchRecordsPerPost),l=i.slice(0,a),u=Ui(l.map((e=>e.record)),e._buildResourceAttributes(),null!==(n=e._scopeName)&&void 0!==n?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(u);if("too-large"===c.kind&&l.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(l.length/2)),e._logger.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+e._maxBatchRecordsPerPost);else{if("retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.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"===c.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(l.length),i=null!==(o=e._instance.getPersistedProperty(De.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===c.kind)throw c.error}}}))()}_persistQueueAdvance(e){var i=this;return t((function*(){var t,r=Math.max(0,e-i._evictedSinceAdvance),s=null!==(t=i._instance.getPersistedProperty(De.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(De.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return ji(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(De.LogsQueue))&&void 0!==t?t:[];this._maxQueueSize>i.length||(i.shift(),this._evictedSinceAdvance++,this._logger.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(De.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Mi((()=>{this._flushTimer=void 0,this._flushInBackground()}),e))}_nextFlushDelay(){var e=Math.min(Math.max(0,this._consecutiveFlushFailures-1),6);return this._flushIntervalMs*Math.pow(2,e)}_hasQueuedRecords(){var e=this._instance.getPersistedProperty(De.LogsQueue);return!!e&&e.length>0}shutdown(e){var i=this;return t((function*(){i._clearFlushTimer();var t=i.flush().catch((()=>{}));void 0!==e?yield $i(t,e):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=i.flush();yield $i(t,e,(()=>{t.catch((()=>{}))}))}))()}_flushInBackground(){this.flush().then((()=>{this._consecutiveFlushFailures=0}),(e=>{this._consecutiveFlushFailures++,this._logger.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._armFlushTimer(this._nextFlushDelay())}))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}};var Vi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Gi(e){return String(e)+"000000"}function Ki(e,t,i,r){var s="";return r&&(s=Object.keys(r).sort().map((e=>JSON.stringify(e)+":"+JSON.stringify(r[e]))).join(",")),e+"\0"+t+"\0"+(null!=i?i:"")+"\0"+s}let Qi=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._generation=0}count(e,t,i){void 0===t&&(t=1),this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var e=this,i=this._flushPromise,r=function(){var r=t((function*(){i&&(yield i.catch((()=>{}))),yield e._doFlush()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this._flushPromise===s&&(this._flushPromise=null)}));return this._flushPromise=s,s}drainWindow(){if(0===this._series.size)return null;var e=this._series;return this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._buildPayload(e)}reset(){this._generation++,this._clearFlushTimer(),this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set}_capture(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this._runBeforeSend(e);if(null!==t)if(t.name&&"string"==typeof t.name)if("number"==typeof t.value&&Number.isFinite(t.value))if("count"===t.type&&0>t.value)this._logger.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=t.attributes?i({},t.attributes):void 0,s=Ki(t.type,t.name,t.unit,r)}catch(e){return void this._logger.warn("Dropping metric '"+t.name+"': attributes could not be serialized",e)}var n=this._series.get(s);if(!n){if(!this._admitNewSeries())return;n={name:t.name,type:t.type,unit:t.unit,attributes:r,windowStartMs:Date.now()},this._series.set(s,n)}var o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn("Metric name '"+t.name+"' is already used as a "+o+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this._fold(n,t.value),this._armFlushTimer()}else this._logger.warn("Dropping metric '"+t.name+"': value must be a finite number");else this._logger.warn("Dropping metric with empty name")}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn("Metric series cap reached ("+this._config.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}_fold(e,t){var i;switch(e.type){case"count":e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(Vi.length+1).fill(0)});var r=e.hist;r.count+=1,r.sum+=t,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t),r.bucketCounts[function(e,t){for(var i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,Vi)]+=1}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=rt(t)?t:[t],r=e;for(var s of i)try{var n=s(r);if(!n)return this._logger.info("Metric was rejected in beforeSend function"),null;r=n}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return r}_armFlushTimer(){this._flushTimer||(this._flushTimer=Mi((()=>{this._flushTimer=void 0,this.flush().catch((e=>{this._logger.error("Metrics flush failed:",e)}))}),this._config.flushIntervalMs))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_doFlush(){var e=this;return t((function*(){if(0!==e._series.size){var t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;var i=e._generation,r=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(r.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._armFlushTimer();case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",r.error)}}}))()}_buildPayload(e){return t=this._buildMetrics(e),r=function(e,t,r){return i({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":r})}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:zi(r)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,r,s,n}_buildMetrics(e){var t=Gi(Date.now()),r=new Map;for(var s of e.values()){var n,o=Ki(s.type,s.name,s.unit,void 0),a=r.get(o);a||(a=i({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},r.set(o,a));var l=zi(null!==(n=s.attributes)&&void 0!==n?n:{}),u=Gi(s.windowStartMs);if("count"===s.type){var c,d={attributes:l,startTimeUnixNano:u,timeUnixNano:t,asDouble:null!==(c=s.total)&&void 0!==c?c:0};a.sum.dataPoints.push(d)}else if("gauge"===s.type){var h,_={attributes:l,timeUnixNano:t,asDouble:null!==(h=s.last)&&void 0!==h?h:0};a.gauge.dataPoints.push(_)}else s.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:t,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Vi})}return Array.from(r.values())}_mergeWindowBack(e){var t,i;for(var r of e){var s=r[0],n=r[1],o=this._series.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(t=o.total)&&void 0!==t?t: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._admitNewSeries()&&this._series.set(s,n)}}};var Ji,Yi,Zi;function Xi(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Zi&&i.length===Yi||(Yi=i.length,Zi=i.reduce(((i,r)=>{Ji||(Ji={});var s=Ji[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,Ji[r]=[l,u];break}}return i}),{})),Zi}}class er{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&rt(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var i=this;return t((function*(){var t=e;for(var r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,o={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Xi(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}var tr="?";function ir(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?tr:i,in_app:!0};return at(r)||(n.lineno=r),at(s)||(n.colno=s),n}var rr=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:tr,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},sr=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nr=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,or=/\((\S*)(?::(\d+))(?::(\d+))\)/,ar=(e,t)=>{var i=sr.exec(e);if(i)return ir(t,i[1],tr,+i[2],+i[3]);var r=nr.exec(e);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=or.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=rr(r[1]||tr,r[2]);return ir(t,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},lr=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ur=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,cr=(e,t)=>{var i=lr.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ur.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]||tr,o=rr(n,s);return ir(t,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},dr=/\(error: (.*)\)/;class hr{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=lt(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return yt(e,"DOMException")}isDOMError(e){return yt(e,"DOMError")}}class _r{match(e){return function(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return wt(e,Error)}}(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class pr{constructor(){}match(e){return!!yt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var r;if(null!=e.error)return t.apply(e.error);var s=t.apply(e.message);return i({},s,{stack:null!==(r=this._buildLocationStack(e))&&void 0!==r?r:s.stack,synthetic:!0})}_hasUsableMessage(e){return lt(e.message)&&e.message.length>0}_buildLocationStack(e){var t=e;if(lt(t.filename)&&t.filename.length>0){var i,r,s=null!==(i=t.lineno)&&void 0!==i?i:0,n=null!==(r=t.colno)&&void 0!==r?r:0;return"Error\n at "+t.filename+":"+s+":"+n}}}var gr=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class vr{match(e){return"string"==typeof e}coerce(e,t){var i,r=this.getInfos(e),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(gr);return r&&(t=r[1],i=r[2]),[t,i]}}var fr=["fatal","error","warning","log","info","debug"];function mr(e,t){void 0===t&&(t=40);var i=Object.keys(e);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(t>=s.length)return r===i.length?s:s.length>t?s.slice(0,t)+"...":s}return""}class yr{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null==(r=t.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return bt(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+mr(e)}isSeverityLevel(e){return lt(e)&&!ut(e)&&fr.indexOf(e)>=0}getStack(e){try{return lt(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:lt(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(Di(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class br{match(e){return bt(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+mr(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class wr{match(e){return mt(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Sr{match(e){return yt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!bt(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return mt(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var xr="$message",Er="$timestamp",kr=new Set([xr,Er]),Pr={enabled:!0,max_bytes:32768};function Cr(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Pr.enabled,max_bytes:Fr(e.max_bytes,Pr.max_bytes)}:i({},Pr)}class Ir{constructor(e){this._entries=[],this._totalBytes=0,this._config=Cr(e)}setConfig(e){this._config=Cr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t;try{t=Xe(e)}catch(e){return}try{var i=JSON.parse(t);if(!nt(i))return;var r=i,s=r[xr],n=r[Er];if(!lt(s)||0===s.trim().length)return;if(!lt(n)&&!ht(n))return;return{step:r,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map((e=>e.step))}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function Fr(e,t){if(!ht(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var Tr=function(e,t){var i=(void 0===t?{}:t).debugEnabled,r={_log(t){if(ye&&(s.DEBUG||ye.POSTHOG_DEBUG||i)&&!at(ye.console)&&ye.console){for(var r=("__rrweb_original__"in ye.console[t]?ye.console[t].__rrweb_original__:ye.console[t]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];r(e,...o)}},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(e){r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Tr(e+" "+t,i)};return r},Rr=Tr("[PostHog.js]"),Ar=Rr.createLogger;function Lr(e,t){rt(e)&&e.forEach(t)}function Mr(e,t){if(!dt(e))if(rt(e))e.forEach(t);else if(gt(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)tt.call(e,i)&&t(e[i],i)}var $r=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(e[n]=s[n]);return e};function Or(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Dr=function(e){try{return e()}catch(e){return}},Br=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){Rr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Rr.critical(e)}}},qr=function(e){var t={};return Mr(e,(function(e,i){(lt(e)&&e.length>0||ht(e))&&(t[i]=e)})),t};var Nr=["herokuapp.com","vercel.app","netlify.app"];function zr(e){var t=null==e?void 0:e.hostname;if(!lt(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Nr)if(i===r)return!1;return!0}function Hr(e,t,i,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==e||e.addEventListener(t,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function jr(e){return"ph_toolbar_internal"===e.name}var Ur=e=>{if(Se){try{for(var t=e+"=",i=Se.cookie.split(";").filter((e=>e.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return ht(e)&&isFinite(e)&&Math.floor(e)===e});class Wr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/256,s[5]=e,s[6]=112|t>>>8,s[7]=t,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 Wr(s)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Wr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Vr{generate(){var e=this.generateOrAbort();if(!at(e))return e;this._timestamp=0;var t=this.generateOrAbort();if(at(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Wr.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new Qr}}var Gr,Kr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ye&&!at(ye.crypto)&&crypto.getRandomValues&&(Kr=e=>crypto.getRandomValues(e));class Qr{nextUint32(){return this._buffer.length>this._cursor||(Kr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}}var Jr=()=>Yr().toString(),Yr=()=>(Gr||(Gr=new Vr)).generate(),Zr="",Xr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var es={_is_supported:()=>!!Se,_error(e){Rr.error("cookieStore error: "+e)},_get:Ur,_parse(e){var t;try{t=JSON.parse(es._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(!Se)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=Se),Zr)return Zr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+Jr();!Zr&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",Zr=n)}return Zr}(e);if(!i){var r=(e=>{var t=e.match(Xr);return t?t[0]:""})(e);r!==i&&Rr.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(Se.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&Rr.warn("cookieStore warning: large cookie, len="+u.length),Se.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=Se&&Se.cookie)try{es._set(e,"",-1,t)}catch(e){return}}},ts=null,is={_is_supported(){if(!ct(ts))return ts;var e=!0;if(at(ye))e=!1;else try{var t="__mplssupport__";is._set(t,"xyz"),'"xyz"'!==is._get(t)&&(e=!1),is._remove(t)}catch(t){e=!1}return e||Rr.error("localStorage unsupported; falling back to cookie store"),ts=e,e},_error(e){Rr.error("localStorage error: "+e)},_get(e){try{return null==ye?void 0:ye.localStorage.getItem(e)}catch(e){is._error(e)}return null},_parse(e){try{return JSON.parse(is._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==ye||ye.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){is._error(e)}return!1},_remove(e){try{null==ye||ye.localStorage.removeItem(e)}catch(e){is._error(e)}}},rs=[o,"distinct_id",k,P,te,ee,Q],ss={},ns={_is_supported:()=>!0,_error(e){Rr.error("memoryStorage error: "+e)},_get:e=>ss[e]||null,_parse:e=>ss[e]||null,_set:(e,t)=>(ss[e]=t,!0),_remove(e){delete ss[e]}},os=null,as={_is_supported(){if(!ct(os))return os;if(os=!0,at(ye))os=!1;else try{var e="__support__";as._set(e,"xyz"),'"xyz"'!==as._get(e)&&(os=!1),as._remove(e)}catch(e){os=!1}return os},_error(e){Rr.error("sessionStorage error: ",e)},_get(e){try{return null==ye?void 0:ye.sessionStorage.getItem(e)}catch(e){as._error(e)}return null},_parse(e){try{return JSON.parse(as._get(e))||null}catch(e){}return null},_set(e,t){try{return null==ye||ye.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){as._error(e)}return!1},_remove(e){try{null==ye||ye.sessionStorage.removeItem(e)}catch(e){as._error(e)}}};class ls{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===ue||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===le}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get _storedConsent(){var e=this._storage._get(this._storageKey);return xt(e)?1:Je(Et,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?is:es;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?es:is;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(xt(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==we?void 0:we.doNotTrack,null==we?void 0:we.msDoNotTrack,Re.doNotTrack].some((e=>xt(e)))}}function us(e,t){var i,r=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!st(r))return t;try{var s=r(t);return lt(s)&&s?s:t}catch(e){return Rr.error("Error in get_current_url, falling back to window.location.href",e),t}}var cs="__POSTHOG_TOOLBAR__",ds=1,hs=3,_s=11;function ps(e){return e instanceof Element&&(e.id===cs||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function gs(e){return!!e&&e.nodeType===ds}function vs(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function fs(e){return!!e&&e.nodeType===hs}function ms(e){return!!e&&e.nodeType===_s&&gs(e.host)}var ys=1e3;function bs(e){return e?Ye(e).split(/\s+/):[]}function ws(e,t){var i=function(e){var t,i=null==ye||null==(t=ye.location)?void 0:t.href;return at(i)?void 0:us(e,i)}(t);return!!(i&&e&&e.some((e=>i.match(e))))}function Ss(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return bs(t)}function xs(e){return dt(e)?null:Ye(e).split(/(\s+)/).filter((e=>Gs(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Es(e){var t="";return Bs(e)&&!qs(e)&&e.childNodes&&e.childNodes.length&&Mr(e.childNodes,(function(e){var i;fs(e)&&e.textContent&&(t+=null!==(i=xs(e.textContent))&&void 0!==i?i:"")})),Ye(t)}function ks(e){var t;return at(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var Ps=["a","button","form","input","select","textarea","label"];function Cs(e,t){if(at(t))return!0;var i,r=function(e){if(t.some((t=>function(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}(e,t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function Is(e){var t=e.parentNode;return!(!t||!gs(t))&&t}var Fs=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ts=["next","previous","prev",">","<"],Rs=[...Ts,"+","-","−","–"],As=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Ls=[".ph-no-rageclick",".ph-no-capture"],Ms=["","text","search","email","password","url","tel","number"];function $s(e,t){if(!ye||Os(e))return!1;var i,r,s,n,o;if(pt(t)?(i=!!t&&Ls,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:Ls,r=null==t?void 0:t.content_ignorelist,s=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(s&&function(e){return!(!e||!gs(e))&&(!!vs(e,"textarea")||(vs(e,"input")?Je(Ms,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var a=Ds(e,!1).targetElementList;return!function(e,t){if(!1===e||at(e))return!1;var i;if(!0===e)i=Ts;else{if(!rt(e))return!1;if(e.length>10)return Rr.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map((e=>e.toLowerCase()))}return t.some((e=>{var t=e.safeText,r=e.ariaLabel;return i.some((e=>As(t,e)||As(r,e)))}))}(r,a.map((e=>{var t;return{safeText:Es(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!Cs(a,i)}var Os=e=>!e||vs(e,"html")||!gs(e),Ds=(e,t)=>{if(!ye||Os(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!vs(s,"body");)if(ms(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Is(s);if(!n)break;if(t||Ps.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=ye.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}catch(e){}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Bs(e){for(var t=new Set,i=0,r=e;r.parentNode&&!vs(r,"body");r=r.parentNode){if(i++>=ys||t.has(r))return!1;t.add(r);var s=Ss(r);if(Je(s,"ph-sensitive")||Je(s,"ph-no-capture"))return!1}if(Je(Ss(e),"ph-include"))return!0;var n=e.type||"";if(lt(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!lt(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 qs(e){return!!(vs(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||vs(e,"select")||vs(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Ns=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}))$"),zs=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Hs=[16,15,14,13],js=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Us=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ws=/[0-9A-Za-z_]/;function Vs(e){for(var t=0,i=!1,r=e.length-1;r>=0;r--){var s=e.charCodeAt(r)-48;i&&(s*=2)>9&&(s-=9),t+=s,i=!i}return t%10==0}function Gs(e,t){if(void 0===t&&(t=!0),dt(e))return!1;if(lt(e)){e=Ye(e);var i=t?Ns.test((e||"").replace(/[- ]/g,"")):function(e){var t;for(zs.lastIndex=0;t=zs.exec(e);){var i=t[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Hs){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(Ns.test(a)&&Vs(a))return!0}}}return!1}(e);if(i)return!1;var r=t?js.test(e):function(e){var t;for(Us.lastIndex=0;t=Us.exec(e);){var i=t[1],r=t[3];if(!(i&&r&&Ws.test(i)&&Ws.test(r)))return!0}return!1}(e);if(r)return!1}return!0}function Ks(e){var t=Es(e);return Gs(t=(t+" "+Qs(e)).trim())?t:""}function Qs(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Mr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Es(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Qs(e)).trim())}catch(e){Rr.error("[AutoCapture]",e)}})),t}function Js(e){return e.replace(/"|\\"/g,'\\"')}function Ys(e){var t=e.attr__class;if(t)return rt(t)?t:bs(t)}var Zs=Ar("[Dead Clicks]"),Xs=()=>!0,en=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),r=e.instance.config.capture_dead_clicks;return pt(r)?r:!!nt(r)||i};class tn{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[v]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Zs.error("failed to load script",t):e()}))}_start(){var e;if(Se){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Re.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=nt(this.instance.config.capture_dead_clicks)?i({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=Re.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(Se),Zs.info("starting...")}}else Zs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Zs.info("stopping..."))}}var rn=Ar("[SegmentIntegration]");var sn="posthog-js";function nn(e,t){var r=void 0===t?{}:t,s=r.organization,n=r.projectId,o=r.prefix,a=r.severityAllowList,l=void 0===a?["error"]:a,u=r.sendExceptionsToPostHog,c=void 0===u||u;return t=>{var r,a,u,d,h;if("*"!==l&&!l.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var _=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=_,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p,g=(null==(r=t.exception)?void 0:r.values)||[],v=g.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),f={$exception_message:(null==(a=g[0])?void 0:a.value)||t.message,$exception_type:null==(u=g[0])?void 0:u.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(h=g[0])?void 0:h.type,$sentry_tags:t.tags};return s&&n&&(f.$sentry_url=(o||"https://sentry.io/organizations/")+s+"/issues/?project="+n+"&query="+t.event_id),c&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class on{constructor(e,t,i,r,s,n){this.name=sn,this.setupOnce=function(o){o(nn(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class an{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Rr.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,r=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==ye?void 0:ye.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$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,c=s.maxContentY;if(!(at(n)||at(o)||at(a)||at(l)||at(u)||at(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?kt(o/n,0,1,Rr):1,h=n>1?kt(a/n,0,1,Rr):1,_=l>1?kt(u/l,0,1,Rr):1,p=l>1?kt(c/l,0,1,Rr):1;r=$r(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var ln=["flags","surveys"],un={[n]:{exposure:"hidden"},[l]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"event"},[d]:{exposure:"hidden"},[h]:{exposure:"event"},[_]:{exposure:"hidden"},[p]:{exposure:"event"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[k]:{exposure:"hidden"},[P]:{exposure:"event"},[b]:{exposure:"event",shouldSkipFromEventProperties:e=>ct(e)},$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"},[C]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!nt(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[I]:{exposure:"event",storageGroup:"flags"},[F]:{exposure:"hidden"},[T]:{exposure:"hidden",storageGroup:"flags"},[R]:{exposure:"event",storageGroup:"flags"},[A]:{exposure:"event",storageGroup:"flags",volatile:!0},[L]:{exposure:"hidden",storageGroup:"flags"},[M]:{exposure:"event"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[B]:{exposure:"hidden"},[q]:{exposure:"hidden",storageGroup:"surveys"},[N]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[z]:{exposure:"event"},[H]:{exposure:"hidden"},[j]:{exposure:"hidden"},[U]:{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"},[W]:{exposure:"hidden"},[V]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Q]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[X]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[te]:{exposure:"hidden"},[w]:{exposure:"event"},[S]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[se]:{exposure:"event"},[ne]:{exposure:"event"},[oe]:{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"}},cn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],dn=e=>{var t=un[e];if(t)return t;for(var i of cn){var r=i[1];if(0===e.indexOf(i[0]))return r}},hn=(e,t)=>{try{return JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t)}catch(t){return Xe(e)}},_n=e=>{var t=null==Se?void 0:Se.createElement("a");return at(t)?null:(t.href=e,t)},pn=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!rt(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Rr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},gn=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");rt(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var h=a;return null!=o&&(h+="?"+u.join("&")),null!=s&&(h+="#"+s),h},vn=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},fn=(e,t)=>e>=t&&Fe(),mn=(e,t,i,r)=>{if(0===e){if(Fe()){var s=t+1;return s===i&&r(),s}return t}return 0},yn="https?://(.*)",bn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],wn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...bn],Sn="<masked>",xn=["li_fat_id"];function En(e,t,i){if(!Se)return{};var r,s=t?[...bn,...i||[]]:[],n=kn(gn(Se.URL,s,Sn),e),o=(r={},Mr(xn,(function(e){var t=Ur(e);r[e]=t||null})),r);return $r(o,n)}function kn(e,t){var i=wn.concat(t||[]),r={};return Mr(i,(function(t){var i=pn(e,t);r[t]=i||null})),r}function Pn(e){var t=function(e){return e?0===e.search(yn+"google.([^/?]*)")?"google":0===e.search(yn+"bing.com")?"bing":0===e.search(yn+"yahoo.com")?"yahoo":0===e.search(yn+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!ct(t)){r.$search_engine=t;var s=Se?pn(Se.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function Cn(){return navigator.language||navigator.userLanguage}var In="$direct";function Fn(){return(null==Se?void 0:Se.referrer)||In}function Tn(e,t,i){void 0===i&&(i=!1);var r=e?[...bn,...t||[]]:[],s=i?Li(null==xe?void 0:xe.href):null==xe?void 0:xe.href,n=null==s?void 0:s.substring(0,1e3);return{r:Fn().substring(0,1e3),u:n?gn(n,r,Sn):void 0}}function Rn(e,t){var i;void 0===t&&(t=!1);var r=e.r,s=e.u,n=t?Li(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==In?In:null==(i=_n(r))?void 0:i.host};if(n){o.$current_url=n;var a=_n(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=kn(n);$r(o,l)}if(r){var u=Pn(r);$r(o,u)}return o}function An(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Ln(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var Mn={flags:K,surveys:N},$n=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],On="main";class Dn{constructor(e,t,r){if(void 0===r&&(r=!0),this._slotState={},this._splitStorageEligible=!1,this._splitStorage=!1,this._config=e,this._ownsSplitStorage=r,this.props={},this._campaign_params_url=void 0,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),e.debug&&Rr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),ye){var s=()=>this.flush();Hr(ye,"beforeunload",s,{capture:!1}),Hr(ye,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return ht(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===$n.indexOf(e.persistence.toLowerCase())&&(Rr.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,r=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var r=[...rs,...e];return i({},is,{_parse(e){try{var i={};try{i=es._parse(e)||{}}catch(e){}var r,s=JSON.parse(is._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];ct(a)||""===a||(n[o]=a)}r=$r(s,n)}else r=$r(i,s);return is._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=is._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&es._set(e,l,i,s,n,o)}catch(e){is._error(e)}return a},_remove(e,t){try{null==ye||ye.localStorage.removeItem(e),es._remove(e,t)}catch(e){is._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&is._is_supported()?(t=is,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&as._is_supported()?t=as:"memory"===n?t=ns:"cookie"===n?t=es:r._is_supported()?(t=r,s=!0):t=es,this._splitStorageEligible=s,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}_isFeatureFlagCacheStale(e){var t=null!=e?e:this._config.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[K];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return Mr(this.props,((t,i)=>{var r=dn(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===C?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&$r(e,r.transformToEventProperties(t))}else if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,(()=>!1)))return;e[i]=t}})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=$r({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of ln){var t=is._parse(this._groupEntryName(e));if(t&&!ot(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||$r(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=dn(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=Mn[e];if(!i)return!1;var r=t[i],s=this.props[i];return ht(r)&&ht(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=dn(e))?void 0:t.storageGroup:void 0,r=i?is._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(r&&e in r)this._setProp(e,r[e]);else{if(i){var s=this._storage._parse(this._name);if(s&&e in s)return void this._setProp(e,s[e])}this._deleteProp(e)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?at(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){at(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(){this._disabled||(this._splitStorage?this._writeNowSplit():this._writeEntry(this._storage,this._name,this.props,On))}_writeNowSplit(){var e=this._partitionProps(),t=e.main,i=e.groups;for(var r of(this._writeEntry(this._storage,this._name,t,On),ln)){var s,n=i[r];(!ot(n)||null!=(s=this._slotState[r])&&s.persisted)&&this._writeEntry(is,this._groupEntryName(r),n,r)}}_partitionProps(){var e={},t={flags:{},surveys:{}};return Mr(this.props,((i,r)=>{var s,n=null==(s=dn(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===On)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return Mr(e,((e,t)=>{var r;i[t]=null!=(r=dn(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===On||s.dirty||at(s.fingerprint)){var n;try{if((n=this._entryFingerprint(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(e){n=void 0}e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(s.dirty=!1,r!==On&&(s.persisted=!0),at(n)||(s.fingerprint=n)):this._config.debug&&Rr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var t=(void 0===e?{}:e).keepGroupEntries,i=void 0!==t&&t;if(at(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!i&&this._ownsSplitStorage)for(var r of ln)is._remove(this._groupEntryName(r));i?delete this._slotState[On]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(nt(e)){at(t)&&(t="None"),this._expire_days=at(i)?this._default_expiry:i;var r=!1;if(Mr(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(nt(e)){this._expire_days=at(t)?this._default_expiry:t;var i=!1;if(Mr(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this._setProp(r,t),i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(this._deleteProp(e),this.save())}update_campaign_params(){var e=null==Se?void 0:Se.URL;if(e!==this._campaign_params_url){var t=En(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);ot(qr(t))||this.register(t),this._campaign_params_url=e}}update_search_keyword(){var e;this.register((e=null==Se?void 0:Se.referrer)?Pn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Fn(),$referring_domain:null!=Se&&Se.referrer&&(null==(e=_n(Se.referrer))?void 0:e.host)||In},void 0)}set_initial_person_info(){this.props[Z]||this.props[X]||this.register_once({[ee]:Tn(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};Mr([X,Z],(t=>{var i=this.props[t];i&&Mr(i,(function(t,i){e["$initial_"+Ze(i)]=t}))}));var t=this.props[ee];if(t){var i=function(e,t){void 0===t&&(t=!1);var i=Rn(e,t),r={};return Mr(i,(function(e,t){r["$initial_"+Ze(t)]=e})),r}(t,this._config.disable_capture_url_hashes);$r(e,i)}return e}safe_merge(e){return Mr(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var r=e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),s=r?this._buildStorage(e):this._storage,n=this._resolveSplitStorage(e);if(r||n!==this._splitStorage){var o=this.props;this.clear(),this._storage=s,this._splitStorage=n,this.props=o,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props[u]||{};i[e]=t,this._setProp(u,i),this.save()}remove_event_timer(e){var t=this.props[u]||{},i=t[e];return at(i)||(delete t[e],this._setProp(u,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t){var i;this.props[e]=t,null!=(i=dn(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=dn(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}function Bn(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&st(i.then)&&i.then(void 0,(()=>{}))}}}}var qn="gzip-js",Nn="base64",zn="events",Hn="cancelEvents",jn="survey shown",Un="survey dismissed",Wn="survey sent",Vn="popover",Gn=Ar("[RateLimiter]");class Kn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Gn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Gn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(Y))&&void 0!==t?t:{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||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var u=(ht(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this._captureWarning(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(Y,a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){var t=this.instance.config.property_denylist;return!rt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&null!=xe&&xe.pathname)return""+(null!==(e=xe.origin)&&void 0!==e?e:"")+xe.pathname}_captureWarning(e){var t,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null==(t=(i=this.instance).get_session_id)?void 0:t.call(i):void 0,a=[e+" 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(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Qn=Ar("[RemoteConfig]");class Jn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Re._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:e})}load(){try{if(this.remoteConfig)return Qn.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void Qn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Qn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e.json,e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){Qn.error("Error loading remote config",e),this._onRemoteConfig()}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){!this._instance._shouldDisableFlags()&&Se&&"hidden"!==Se.visibilityState&&this._instance.reloadFeatureFlags()}_startRefreshInterval(){var e;if(!this._refreshInterval){var t=null!==(e=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==e?e:3e5;0!==t&&(this._refreshInterval=setInterval((()=>{this.refresh()}),t))}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||Qn.warn("Failed to fetch remote config from PostHog."):Qn.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){Qn.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(e){Qn.error("Error loading feature flags",e)}}}var Yn=Uint8Array,Zn=Uint16Array,Xn=Uint32Array,eo=new Yn([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]),to=new Yn([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]),io=new Yn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ro=function(e,t){for(var i=new Zn(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Xn(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},so=ro(eo,2),no=so[1];so[0][28]=258,no[258]=28;for(var oo=ro(to,0)[1],ao=new Zn(32768),lo=0;32768>lo;++lo){var uo=(43690&lo)>>>1|(21845&lo)<<1;ao[lo]=((65280&(uo=(61680&(uo=(52428&uo)>>>2|(13107&uo)<<2))>>>4|(3855&uo)<<4))>>>8|(255&uo)<<8)>>>1}var co=function(e,t,i){for(var r=e.length,s=0,n=new Zn(t);r>s;++s)++n[e[s]-1];var o,a=new Zn(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Zn(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var u=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,h=d|(1<<c)-1;h>=d;++d)o[ao[d]>>>l]=u}else for(o=new Zn(r),s=0;r>s;++s)o[s]=ao[a[e[s]-1]++]>>>15-e[s];return o},ho=new Yn(288);for(lo=0;144>lo;++lo)ho[lo]=8;for(lo=144;256>lo;++lo)ho[lo]=9;for(lo=256;280>lo;++lo)ho[lo]=7;for(lo=280;288>lo;++lo)ho[lo]=8;var _o=new Yn(32);for(lo=0;32>lo;++lo)_o[lo]=5;var po=co(ho,9,0),go=co(_o,5,0),vo=function(e){return(e/8>>0)+(7&e&&1)},fo=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Zn?Zn:e instanceof Xn?Xn:Yn)(i-t);return r.set(e.subarray(t,i)),r},mo=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},yo=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},bo=function(e,t){for(var i=[],r=0;e.length>r;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new Yn(0),0];if(1==s){var o=new Yn(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(r=1;s>r;++r)n[r].s>h&&(h=n[r].s);var _=new Zn(h+1),p=wo(i[c-1],_,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return _[t.s]-_[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=_[m])break;g+=f-(1<<p-_[m]),_[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>_[y]?g-=1<<t-_[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;_[b]==t&&(--_[b],++g)}p=t}return[new Yn(_),p]},wo=function(e,t,i){return-1==e.s?Math.max(wo(e.l,t,i+1),wo(e.r,t,i+1)):t[e.s]=i},So=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Zn(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++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=e[a]}return[i.subarray(0,r),t]},xo=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},Eo=function(e,t,i){var r=i.length,s=vo(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;r>n;++n)e[s+n+4]=i[n];return 8*(s+4+r)},ko=function(e,t,i,r,s,n,o,a,l,u,c){mo(t,c++,i),++s[256];for(var d=bo(s,15),h=d[0],_=d[1],p=bo(n,15),g=p[0],v=p[1],f=So(h),m=f[0],y=f[1],b=So(g),w=b[0],S=b[1],x=new Zn(19),E=0;m.length>E;++E)x[31&m[E]]++;for(E=0;w.length>E;++E)x[31&w[E]]++;for(var k=bo(x,7),P=k[0],C=k[1],I=19;I>4&&!P[io[I-1]];--I);var F,T,R,A,L=u+5<<3,M=xo(s,ho)+xo(n,_o)+o,O=xo(s,h)+xo(n,g)+o+14+3*I+xo(x,P)+(2*x[16]+3*x[17]+7*x[18]);if(M>=L&&O>=L)return Eo(t,c,e.subarray(l,l+u));if(mo(t,c,1+(M>O)),c+=2,M>O){F=co(h,_,0),T=h,R=co(g,v,0),A=g;var D=co(P,C,0);for(mo(t,c,y-257),mo(t,c+5,S-1),mo(t,c+10,I-4),c+=14,E=0;I>E;++E)mo(t,c+3*E,P[io[E]]);c+=3*I;for(var B=[m,w],q=0;2>q;++q){var N=B[q];for(E=0;N.length>E;++E)mo(t,c,D[z=31&N[E]]),c+=P[z],z>15&&(mo(t,c,N[E]>>>5&127),c+=N[E]>>>12)}}else F=po,T=ho,R=go,A=_o;for(E=0;a>E;++E)if(r[E]>255){var z;yo(t,c,F[257+(z=r[E]>>>18&31)]),c+=T[z+257],z>7&&(mo(t,c,r[E]>>>23&31),c+=eo[z]);var H=31&r[E];yo(t,c,R[H]),c+=A[H],H>3&&(yo(t,c,r[E]>>>5&8191),c+=to[H])}else yo(t,c,F[r[E]]),c+=T[r[E]];return yo(t,c,F[256]),c+T[256]},Po=new Xn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Co=function(){for(var e=new Xn(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Io=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Fo(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,r=0;t.length>r;++r)i=Co[255&i^t[r]]^i>>>8;e=i},d(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n,o,a,l,u=(a=10+((s=t).filename&&s.filename.length+1||0),l=8,function(e,t,i,r,s,n){var o=e.length,a=new Yn(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=Eo(l,u,e.subarray(c,d)):(l[c]=!0,u=Eo(l,u,e.subarray(c,o)))}else{for(var h=Po[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Zn(32768),f=new Zn(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new Xn(25e3),S=new Zn(288),x=new Zn(32),E=0,k=0,P=(c=0,0),C=0,I=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=C){var A=o-c;if((E>7e3||P>24576)&&A>423){u=ko(e,l,0,w,S,x,k,P,I,c-I,u),P=E=k=0,I=c;for(var L=0;286>L;++L)S[L]=0;for(L=0;30>L;++L)x[L]=0}var M=2,O=0,D=p,B=T-R&32767;if(A>2&&F==b(c-B))for(var q=Math.min(_,A)-1,N=Math.min(32767,c),z=Math.min(258,A);N>=B&&--D&&T!=R;){if(e[c+M]==e[c+M-B]){for(var H=0;z>H&&e[c+H]==e[c+H-B];++H);if(H>M){if(M=H,O=B,H>q)break;var j=Math.min(B,H-2),U=0;for(L=0;j>L;++L){var W=c-B+L+32768&32767,V=W-v[W]+32768&32767;V>U&&(U=V,R=W)}}}B+=(T=R)-(R=v[T])+32768&32767}if(O){w[P++]=268435456|no[M]<<18|oo[O];var G=31&no[M],K=31&oo[O];k+=eo[G]+to[K],++S[257+G],++x[K],C=c+M,++E}else w[P++]=e[c],++S[e[c]]}}u=ko(e,l,!0,w,S,x,k,P,I,c-I,u)}return fo(a,0,r+vo(u)+s)}(n=e,null==(o=t).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)),c=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Io(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;i.length>=r;++r)e[r+10]=i.charCodeAt(r)}}(u,t),Io(u,c-8,i.d()),Io(u,c-4,r),u}var To=!!ke||!!Ee,Ro="text/plain",Ao=!1,Lo=(e,t)=>{var i=e.split("#"),r=i[1],s=i[0].split("?"),n=s[0],o=s[1];if(!o)return e;var a=o.split("&").filter((e=>e.split("=")[0]!==t)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},Mo=function(e,t,r){var s;void 0===r&&(r=!0);var n=e.split("?"),o=n[0],a=n[1],l=i({},t),u=null!==(s=null==a?void 0:a.split("&").map((e=>{var t,i=e.split("="),s=i[0],n=r&&null!==(t=l[s])&&void 0!==t?t:i[1];return delete l[s],s+"="+n})))&&void 0!==s?s:[],c=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return Mr(e,(function(e,t){at(e)||at(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)}(l);return c&&u.push(c),u.length>0?o+"?"+u.join("&"):o},$o=e=>{if(e._encodedBody)return e._encodedBody;var t=e.data,i=e.compression;if(t){if(i===qn){var r=Fo(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Yn(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},o=0;i>o;++o){if(s+5>r.length){var a=new Yn(s+8+(i-o<<1));a.set(r),r=a}var l=e.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&e.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 fo(r,0,s)}(hn(t)),{mtime:0});return{contentType:Ro,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Nn){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(hn(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:hn(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=hn(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Oo=e=>{var t,r,s=()=>"sendBeacon"===e.transport?{url:Mo(e.url,{compression:Nn}),encodedBody:$o(i({},e,{compression:Nn,_encodedBody:void 0}))}:{url:Lo(e.url,"compression"),encodedBody:$o(i({},e,{compression:void 0,_encodedBody:void 0}))};try{t=$o(e)}catch(t){if(je(e.compression,pn(e.url,"compression")))return Rr.error("Failed to gzip request body, sending uncompressed payload",t),s();throw t}return t&&je(e.compression,pn(e.url,"compression"))&&!((r=t.body)instanceof ArrayBuffer?He(new Uint8Array(r)):ArrayBuffer.isView(r)&&He(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(Ao=!0,s()):{url:e.url,encodedBody:t}},Do=e=>{try{return Oo(e)}catch(t){return Rr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},Bo=function(){var e=t((function*(e){var t=hn(e.data),r=yield function(e,t,i){return Ge.apply(this,arguments)}(t,s.DEBUG,{rethrow:!0});if(!r)return e;var n=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:Ro,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),qo=/Failed to fetch|NetworkError|Load failed/i,No=e=>{var t=Do(e);if(t){var r=t.url,s=t.encodedBody,n=null!=s?s:{},o=n.contentType,a=n.body,l=n.estimatedSize,u=new Headers;Mr(e.headers,(function(e,t){u.append(t,e)})),o&&u.append("Content-Type",o);var c=null,d=!1;if(Pe){var h=new Pe;c={signal:h.signal,timeout:setTimeout((()=>{var t,i;d=!0,h.abort((t=e.timeout,(i=new Error("PostHog request timed out"+(t?" after "+t+"ms":""))).name="AbortError",i))}),e.timeout)}}var _=t=>{d&&"AbortError"===(null==t?void 0:t.name)||(e=>"TypeError"===(null==e?void 0:e.name)&&qo.test((null==e?void 0:e.message)||""))(t)?Rr.warn(t):Rr.error(t),null==e.callback||e.callback({statusCode:0,error:t})};try{var p;Ee(r,i({method:(null==e?void 0:e.method)||"GET",headers:u,keepalive:"POST"===e.method&&!e._keepaliveDisabled&&52428.8>(l||0),body:a,signal:null==(p=c)?void 0:p.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){Rr.error(e)}null==e.callback||e.callback(r)})))).catch(_).finally((()=>c?clearTimeout(c.timeout):null))}catch(e){c&&clearTimeout(c.timeout),_(e)}}},zo=e=>{try{var t,r=Oo(e),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(we.sendBeacon(s,u))return;var c=rt(e.data)?e.data:null==(t=e.data)?void 0:t.batch;if(rt(c)&&c.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(c.length/2),h=t=>rt(e.data)?t:i({},e.data,{batch:t});return zo(i({},e,{data:h(c.slice(0,d))})),void zo(i({},e,{data:h(c.slice(d))}))}Rr.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),No(i({},e,{_keepaliveDisabled:!0}))}catch(e){Rr.warn("Beacon send failed",e)}},Ho=(e,t,r,s)=>{var n="query"===s?"POST"===t?"sent_at":"_":void 0;return Mo(r===qn?Lo(e,"compression"):e,i({},n?{[n]:Date.now().toString()}:{},r===qn?{}:{compression:r}))},jo=[];Ee&&jo.push({transport:"fetch",method:No}),ke&&jo.push({transport:"XHR",method(e){var t=Do(e);if(t){var i=new ke,r=t.encodedBody;i.open(e.method||"GET",t.url,!0);var s=null!=r?r:{},n=s.contentType,o=s.body;Mr(e.headers,(function(e,t){i.setRequestHeader(t,e)})),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(o)}}}),null!=we&&we.sendBeacon&&jo.push({transport:"sendBeacon",method:zo});var Uo=3e3;class Wo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=kt((null==t?void 0:t.flush_interval_ms)||Uo,250,5e3,Rr.createLogger("flush interval"),Uo),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequestSafely(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[r],s=(new Date).getTime();i.data&&rt(i.data)&&Mr(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequestSafely(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_sendRequestSafely(e){try{this._sendRequest(e)}catch(e){Rr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Mr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;at(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Vo=["retriesPerformedSoFar"];class Go{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!at(ye)&&"onLine"in ye.navigator&&(this._areWeOnline=ye.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Hr(ye,"online",this._onlineListener),Hr(ye,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var t=e.retriesPerformedSoFar,s=r(e,Vo);_t(t)&&(s.url=Mo(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=t?t:0))return void this._enqueue(i({retriesPerformedSoFar:t},s));0===e.statusCode&&Rr.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!=t?t:0)+" retries.")}null==s.callback||s.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),Rr.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>e>i.retryAt||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,at(ye)||(this._onlineListener&&(ye.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(ye.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue)){var t=e.requestOptions;try{this._instance._send_request(i({},t,{transport:"sendBeacon"}))}catch(e){Rr.error(e)}}this._queue=[]}}class Ko{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});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._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Hr(ye,"scroll",this._updateScrollData,{capture:!0}),Hr(ye,"scrollend",this._updateScrollData,{capture:!0}),Hr(ye,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==ye?void 0:ye.document.documentElement;var e=rt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==ye?void 0:ye.document.querySelector(t);if(i)return i}}_scrollPosition(e){var t="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var i=this.scrollElement();return i&&i[t]||0}return ye?"y"===e?ye.scrollY||ye.pageYOffset||ye.document.documentElement.scrollTop||0:ye.scrollX||ye.pageXOffset||ye.document.documentElement.scrollLeft||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}}var Qo=e=>Tn(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes);class Jo{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[J]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Qo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[J]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?Rn(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Mr(qr(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Ze(i)]=t})),e}}class Yo{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var r of this._events["*"]||[])r(e,t)}constructor(){this._events={}}}var Zo=Ar("[SessionId]");class Xo{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._lastPersistedActivityTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Yo,this._sessionHasBeenIdleTooLong=(e,t)=>!(!_t(e)||!_t(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===ue)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Jr,this._windowIdGenerator=i||Jr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*kt(this._config.session_idle_timeout_seconds||1800,60,36e3,Zo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var n=as._parse(this._window_id_storage_key),o=as._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:as._remove(this._window_id_storage_key),as._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.sessionID)try{var a=(e=>{var t=this._config.bootstrap.sessionID.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})();this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),a)}catch(e){Zo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return at(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&as._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&as._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?as._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!ct(t)&&!ct(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var r=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!r||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[k]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return _t(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(k):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!ct(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var t=this._getSessionId();t[1]===this._sessionId&&t[2]===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[k]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var e=this._getSessionId()[0],t=_t(e)?e:0,i=_t(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[k];return rt(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&ye&&(ye.removeEventListener(pe,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&as._remove(this._primary_window_exists_storage_key)},Hr(ye,pe,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===ue)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),r=this._getSessionId(),s=r[1],n=r[2],o=this._freshestActivityTimestamp(),a=this._getWindowId(),l=_t(n)&&Math.abs(i-n)>864e5,u=!1,c=!1,d=!s,h=s,_=!d&&!e&&this._sessionHasBeenIdleTooLong(i,o);if(_){(_=this._isSessionIdleAfterCrossTabRefresh(i))||Zo.info("cross-tab refresh kept the session alive",{sessionId:s});var p=this._getSessionId();s=p[1],n=p[2]}d||_||l?(s=this._sessionIdGenerator(),a=this._windowIdGenerator(),Zo.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:d,activityTimeout:_,sessionPastMaximumLength:l}}),n=i,u=!0):(a||(a=this._windowIdGenerator(),u=!0),(c=s!==h)&&(Zo.info("adopted cross-tab session id",{sessionId:s,windowId:a}),u=!0));var g=_t(o)&&e&&!l?o:i,v=_t(n)?n:(new Date).getTime();this._setWindowId(a),this._setSessionId(s,g,v),e||this._resetIdleTimer();var f={noSessionId:d,activityTimeout:_,sessionPastMaximumLength:l,crossTabAdoption:c};return u&&this._sessionIdChangedHandlers.forEach((e=>e(s,a,f))),{sessionId:s,windowId:a,sessionStartTimestamp:v,changeReason:u?f:void 0,lastActivityTimestamp:o}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()}),1.1*this.sessionTimeoutMs))}}var ea=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Qe(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Qe(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function ta(){return(ta=t((function*(){var e=null==we?void 0:we.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return lt(i)&&i.length>0?i:void 0}catch(e){return void Rr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}))).apply(this,arguments)}var ia=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function ra(e,t,i){return hn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var sa={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>ia(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!ia(t,e))))),icontains:(e,t)=>t.map(na).some((t=>e.map(na).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(na).every((t=>e.map(na).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i<parseFloat(e)))}))},na=e=>e.toLowerCase();function oa(e,t){return!e||Object.entries(e).every((e=>{var i=e[1],r=null==t?void 0:t[e[0]];if(at(r)||ct(r))return!1;var s=[String(r)],n=sa[i.operator];return!!n&&n(i.values,s)}))}var aa="custom",la="i.posthog.com",ua=/^\/static\//;class ca{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+la,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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":aa),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(ua.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return""+i+t}if(this.region===aa)return this.apiHost+t;var r=la+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}function da(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}var ha=Ar("[Surveys]"),_a="seenSurvey_",pa=e=>{try{var t=(e=>((e,t)=>""+e+function(e){return e.current_iteration&&e.current_iteration>0?e.id+"_"+e.current_iteration:e.id}(t))(_a,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){ha.error("Failed to persist survey seen state",e)}},ga=["popover","widget","api"],va={ignoreConditions:!1,ignoreDelay:!1,displayType:Vn},fa=Ar("[PostHog ExternalIntegrations]"),ma={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ya{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return fa.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(){var t,r,s,n=i[0],o=i[1];!o||null!=(t=Re.__PosthogExtensions__)&&null!=(t=t.integrations)&&t[n]||e._loadScript(ma[n],(()=>{var t;null==(t=Re.__PosthogExtensions__)||null==(t=t.integrations)||null==(t=t[n])||t.start(e._instance)})),!o&&null!=(r=Re.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=Re.__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;t()}}}class ba{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var i=this;return t((function*(){if(i._disposed)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i._extensions.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');i._extensions.set(e.name,e);try{var t=e.setup(i._client);t&&(yield t)}catch(t){var r=i._extensions.get(e.name)===e;r&&i._extensions.delete(e.name),i._logger.error('Failed to set up browser extension "'+e.name+'"',t),r&&i._disposeExtension(e)}}))()}dispose(){if(!this._disposed){this._disposed=!0;var e=Array.from(this._extensions.values()).reverse();for(var t of(this._extensions.clear(),e))this._disposeExtension(t)}}_disposeExtension(e){try{var t=null==e.dispose?void 0:e.dispose();t&&st(t.then)&&t.then(void 0,(t=>{this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}))}catch(t){this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}}}class wa{constructor(e){this._instance=e}get(e){var t;return null==(t=this._instance.persistence)?void 0:t.get_property(e)}set(e,t){var i;null==(i=this._instance.persistence)||i.set_property(e,t)}remove(e){var t;null==(t=this._instance.persistence)||t.unregister(e)}}var Sa="extensionsRemoteConfig";class xa{constructor(e){this._disposed=!1,this.instance=e,this._logger=Rr.createLogger("[BrowserExtensions]"),this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new wa(e),this.onEvent=e=>Bn(this.instance.on("eventCaptured",(t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}}))),this.onRemoteConfig=e=>{if(this._disposed)return Bn((()=>{}));var t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(Sa,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),Bn(i)},this._runtime=new ba(this._logger,this)}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property(o))&&void 0!==e?e:this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,r,s=null==(e=this.instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==s?void 0:s.sessionId)&&void 0!==t?t:"",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(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(e){return this._runtime.add(e)}capture(e,i,r){var s=this;return t((function*(){r?s.instance.capture(e,i,{timestamp:r.timestamp,uuid:r.uuid,$set:r.set,$set_once:r.setOnce}):s.instance.capture(e,i)}))()}registerDynamicEventProperties(e){return Bn(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(Sa,e))}sendRequest(e,i){var r=this;return t((function*(){var t;void 0===i&&(i={});var s=r.instance.requestRouter.endpointFor(null!==(t=i.target)&&void 0!==t?t:"api",e),n={method:i.method,url:i.query?Mo(s,i.query):s,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport};return"sendBeacon"===i.transport?(r.instance._send_request(n),{statusCode:202}):new Promise((e=>{n.callback=e,r.instance._send_request(n)}))}))()}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}}var Ea={},ka=0,Pa=()=>{},Ca='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ia="Surveys module not available",Fa="sanitize_properties is deprecated. Use before_send instead",Ta="Invalid value for property_denylist config: ",Ra=["token","distinct_id",re],Aa="posthog",La=!To&&-1===(null==Ie?void 0:Ie.indexOf("MSIE"))&&-1===(null==Ie?void 0:Ie.indexOf("Mozilla")),Ma=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:zr(null==Se?void 0:Se.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Pa,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:xe&&lt(null==xe?void 0:xe.search)&&-1!==xe.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:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==ye||null==(t=ye.location)?void 0:t.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(e){Rr.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:he,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Uo},error_tracking:{},_onCapture:Pa},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Rs,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:e&&e>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:e&&e>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e)}))(e))},$a=[["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"]],Oa=e=>{var t={};for(var i of $a){var r=i[0],s=i[1];at(e[r])||(t[s]=e[r])}var n=$r({},t,e),o=e.__preview_external_dependency_versioned_paths;return at(o)||(at(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),lt(o)&&at(e.asset_host)&&(n.asset_host=o)),rt(e.property_blacklist)&&(at(e.property_denylist)?n.property_denylist=e.property_blacklist:rt(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Rr.error(Ta+e.property_denylist)),n};class Da{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Rr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ba{_replaceExtension(e,t){if(e){var i=this._extensions.indexOf(e);-1!==i&&this._extensions.splice(i,1)}return this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return this.config.cookieless_mode===ue||this.config.cookieless_mode===le&&this.consent.isRejected()}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this.webPerformance=new Da,this._personProcessingSetOncePropertiesSent=!1,this.version=s.LIB_VERSION,this._internalEventEmitter=new Yo,this._extensions=[],this._extensionEventPropertyProducers=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ma(),this.SentryIntegration=on,this.sentryIntegration=e=>function(e,t){var i=nn(e,t);return{name:sn,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new Ko(this),this.pageViewManager=new an(this),this.rateLimiter=new Kn(this),this.requestRouter=new ca(this),this.consent=new ls(this),this.externalIntegrations=new ya(this);var t=null!==(e=Ba.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.metrics=t.metrics&&new t.metrics(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var r=lt(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=lt(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>Rr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Aa){var r,s=null!==(r=Ea[i])&&void 0!==r?r:new Ba;return s._init(e,t,i),Ea[i]=s,Ea[Aa][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var n,o;void 0===t&&(t={});var l,u=lt(e)?e.trim():"";if(!u)return Rr.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 u!==(null==(l=this.config)?void 0:l.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+u+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ma(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var c=Ma(t.defaults),d=Oa(t),h=$r({},c,d,{name:r,token:u});nt(c.rageclick)&&nt(d.rageclick)&&(h.rageclick=$r({},c.rageclick,d.rageclick)),nt(c.session_recording)&&nt(d.session_recording)&&(h.session_recording=$r({},c.session_recording,d.session_recording)),this.set_config(h),this.config.on_xhr_error&&Rr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:qn;var _=this._is_persistence_disabled();this.persistence=new Dn(this.config,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Dn(i({},this.config,{persistence:"sessionStorage"}),_,!1);var p=i({},this.persistence.props),g=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Wo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Go(this),this.__request_queue=[];var v=this._inCookielessMode();if(v||(this.sessionManager=new Xo(this),this.sessionPropsManager=new Jo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(Rr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(v)}),0)):(Rr.info("Initializing extensions synchronously"),this._initExtensions(v)),s.DEBUG=s.DEBUG||this.config.debug,s.DEBUG&&Rr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:p,s:g}),!this.config.identity_distinct_id||null!=(n=t.bootstrap)&&n.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var f=t.bootstrap.distinctID,m=this.get_distinct_id(),y=this.persistence.get_property(Q);if(t.bootstrap.isIdentifiedID&&null!=m&&m!==f&&y===ce)this.identify(f);else if(t.bootstrap.isIdentifiedID&&null!=m&&m!==f&&y===de)Rr.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 b=this.config.get_device_id(Jr()),w=t.bootstrap.isIdentifiedID?b:f;this.persistence.set_property(Q,t.bootstrap.isIdentifiedID?de:ce),this.register({distinct_id:f,$device_id:w})}}if(v)this.register_once({distinct_id:ie,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(Jr());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(Q,ce)}return Hr(ye,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||Jr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(Q,de)),t()},s=i.user();"then"in s&&st(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{"undefined"!=typeof Promise&&Promise.resolve||rn.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(rn.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(rn.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,ge),identify:e=>t(e,fe),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),st(this.config._onCapture)&&this.config._onCapture!==Pa&&(Rr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Rr.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 ta.apply(this,arguments)}().then((e=>{e&&this.register({[a]:e})})).catch(Pa),this}_initExtensions(e){var t,r,s,n,o,a,l,u,c=performance.now(),d=i({},Ba.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new d.featureFlags(this)),d.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new d.exceptions(this)),d.historyAutocapture&&this._extensions.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this._extensions.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this._extensions.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),d.autocapture&&this._extensions.push(this.autocapture=new d.autocapture(this)),d.surveys&&this._extensions.push(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new d.surveys(this)),d.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new d.logs(this)),d.metrics&&this._extensions.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new d.metrics(this)),d.conversations&&this._extensions.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new d.conversations(this)),d.productTours&&this._extensions.push(this.productTours=new d.productTours(this)),d.heatmaps&&this._extensions.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this._extensions.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,en)),d.toolbar&&this._extensions.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new d.toolbar(this)),d.experiments&&this._extensions.push(this.experiments=null!==(u=this.experiments)&&void 0!==u?u:new d.experiments(this)),this._extensions.forEach((e=>{e.initialize&&h.push((()=>{null==e.initialize||e.initialize()}))})),h.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}})),this._processInitTaskQueue(h,c)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this._processInitTaskQueue(e,t)}),0);var i=e.shift();if(i)try{i()}catch(e){Rr.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[se]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ne]:r}),this.config.__preview_deferred_init_extensions&&Rr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!Se||!Se.body)return Rr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var i,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=Je(r.supportedCompression,qn)?qn:Je(r.supportedCompression,Nn)?Nn:void 0),null!=(i=r.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:he}),null==(t=this._browserClientAdapter)||t.handleRemoteConfig(e),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){Rr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=xe&&xe.hostname){var e=xe.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()}),1),this._remoteConfigLoader=new Jn(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&Lr(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,r,s;null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),null==(t=this.metrics)||t.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(ve),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this._requestQueue)||r.unload(),null==(s=this._retryQueue)||s.unload()):this._shouldCapturePageleave()&&this.capture(ve,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?La?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=i({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?this.compression:e.compression,(at(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,r,s,n=i({},e);n.timeout=n.timeout||6e4;var o,a,l,u,c,d=null!==(t=n.transport)&&void 0!==t?t:"fetch";"sendBeacon"===d&&at(n.compression)&&n.data&&(n.compression=Nn),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data={api_key:null!==(a=null==(c=(u=rt(o=n.data)?o:[o])[0])||null==(l=c.properties)?void 0:l.token)&&void 0!==a?a:null==c?void 0:c.token,batch:u,sent_at:(new Date).toISOString()}:"body"===n.timestampMode&&(n.data=function(e,t){return void 0===t&&(t=(new Date).toISOString()),rt(e)?e.map((e=>i({},e,{sent_at:t}))):i({},e,{sent_at:t})}(n.data))),n.url=Ho(n.url,n.method,n.compression,n.timestampMode);var h=jo.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),_=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===d)return e[i]}(h))?void 0:s.method)&&void 0!==r?r:h[0].method;if(!_)throw new Error("No available transport method");"sendBeacon"!==d&&n.data&&n.compression===qn&&Ce&&"undefined"!=typeof Promise&&!Ao?Bo(n).then((e=>{_(e)})).catch((t=>{if(Ue(t))return Ao=!0,void _(i({},n,{compression:void 0,url:Ho(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return Ue(e)||t===ze})(t)&&(Ao=!0),_(n)})):_(n)})(i({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,t),null==e.callback||e.callback(t)}}))):e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:0}))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){ka++;try{var t,i=[],r=[],s=[];Lr(e,(e=>{if(e)if(rt(t=e[0]))s.push(e);else if(st(e))try{e.call(this)}catch(t){Rr.error("Error executing queued PostHog call",e,t)}else rt(e)&&"alias"===t?i.push(e):rt(e)&&-1!==t.indexOf("capture")&&st(this[t])?s.push(e):r.push(e)}));var n=function(e,t){Lr(e,(function(e){try{if(rt(e[0])){var i=t;Mr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){Rr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{ka--}}push(e){if(ka>0&&rt(e)&&lt(e[0])){var t=Ba.prototype[e[0]];st(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l,u,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!at(e)&&lt(e)){var d=!this.config.opt_out_useragent_filter&&this._is_bot();if(!d||this.config.__preview_capture_bot_pageviews){var h=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==h||!h.isRateLimited){if(this._extensionEventPropertyProducers.length>0){var _={};for(var p of this._extensionEventPropertyProducers.slice())try{$r(_,p())}catch(e){Rr.error("Failed to produce browser extension event properties",e)}t=i({},_,null!=t?t:{})}var g;null!=(s=t)&&s.$current_url&&!lt(null==(n=t)?void 0:n.$current_url)&&(Rr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==(g=t)||delete g.$current_url),"$exception"!==e||null!=r&&r._originatedFromCaptureException||Rr.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 v=new Date,f=(null==r?void 0:r.timestamp)||v,m=Ai(null==r?void 0:r.uuid,Jr),y={uuid:m,event:e,properties:this.calculateEventProperties(e,t||{},f,m)};e===ge&&this.config.__preview_capture_bot_pageviews&&d&&(y.event="$bot_pageview",y.properties.$browser_type="bot"),h&&(y.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens);var b="$feature_flag_called"===e&&!1===y.properties.$feature_flag_has_experiment&&!0===this.get_property(L);(null==r?void 0:r.$set)&&!b&&(y.$set=null==r?void 0:r.$set);var w=null==r?void 0:r.$unset;w&&(y.$unset=w);var S,x,E,k=b?void 0:this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==me,e===fe);if(k&&(y.$set_once=k),null!=r&&r._noTruncate||(a=this.config.properties_string_max_length,l=y,u=e=>lt(e)?e.slice(0,a):e,c=new Set,y=function e(t,i){if(t!==Object(t))return u?u(t):t;if(!c.has(t)){var r;if(c.add(t),rt(t))r=[],Lr(t,(t=>{r.push(e(t))}));else{var s={};Mr(t,((t,i)=>{c.has(t)||(s[i]=e(t,i))})),r=s}return r}}(l)),y.timestamp=f,at(null==r?void 0:r.timestamp)||(y.properties.$event_time_override_provided=!0,y.properties.$event_time_override_system_time=v),b&&(y.properties=function(e,t){void 0===t&&(t=[]);var i={},r=t=>{void 0!==e[t]&&(i[t]=e[t])};return Oe.forEach(r),t.forEach(r),i}(y.properties,Ra)),e===Un||e===Wn){var P,C,I=null==(P=t)?void 0:P.$survey_id,F=null==(C=t)?void 0:C.$survey_iteration;pa({id:I,current_iteration:F}),y.$set=i({},y.$set,{[(S={id:I,current_iteration:F},x=e===Wn?"responded":"dismissed",E="$survey_"+x+"/"+S.id,S.current_iteration&&S.current_iteration>0&&(E="$survey_"+x+"/"+S.id+"/"+S.current_iteration),E)]:!0})}else e===jn&&(y.$set=i({},y.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var T,R=null==(T=t)?void 0:T.$product_tour_type;R&&(y.$set=i({},y.$set,{["$product_tour_last_seen_date/"+R]:(new Date).toISOString()}))}var A=i({},y.properties.$set,y.$set);if(ot(A)||this.setPersonPropertiesForFlags(A),!dt(this.config.before_send)){var M=this._runBeforeSend(y);if(!M)return;(y=M).uuid=Ai(y.uuid,Jr)}this._internalEventEmitter.emit("eventCaptured",y);var O=null!==(o=null==r?void 0:r._url)&&void 0!==o?o:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),D={method:"POST",url:O,data:y,compression:"best-available",timestampMode:"recordings"===(null==r?void 0:r._batchKey)||/\/s\/(?:\?|$)/.test(O)?"body":"capture-body",batchKey:null==r?void 0:r._batchKey,transport:null==r?void 0:r.transport};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(D):this._requestQueue.enqueue(D),y}Rr.critical("This capture call is ignored due to client rate limiting.")}}else Rr.error("No event name provided to posthog.capture")}else Rr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new xa(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);var t=!0;return()=>{if(t){t=!1;var i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}}calculateEventProperties(e,t,r,n,o){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l[re]=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!lt(l.distinct_id)&&!ht(l.distinct_id)||ut(l.distinct_id))&&Rr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i,r){var n,o,a,l;if(void 0===r&&(r=!1),!Ie)return{};var u,c=e?[...bn,...t||[]]:[],d=function(e){for(var t=0;Fi.length>t;t++){var i=Fi[t],r=i[1],s=i[0].exec(e),n=s&&(st(r)?r(s,e):r);if(n)return n}return["",""]}(Ie),h=d[0],_=d[1],p=null!=(u="undefined"!=typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},g={};at(i)||(g.detectGoogleSearchApp=i);var v={},f=null==(n=navigator)||null==(n=n.userAgentData)?void 0:n.platform,m=null==(o=navigator)?void 0:o.maxTouchPoints,y=null==ye||null==(a=ye.screen)?void 0:a.width,b=null==ye||null==(l=ye.screen)?void 0:l.height,w=null==ye?void 0:ye.devicePixelRatio;at(f)||(v.userAgentDataPlatform=f),at(m)||(v.maxTouchPoints=m),at(y)||(v.screenWidth=y),at(b)||(v.screenHeight=b),at(w)||(v.devicePixelRatio=w);var S,x,E,k,P,C,I,F,T=$r(qr({$os:h,$os_version:_,$browser:Pi(Ie,navigator.vendor,p,g),$device:Ti(Ie),$device_type:(x=Ie,E=v,F=Ti(x),F===At||F===Rt||"Kobo"===F||"Kindle Fire"===F||F===li?Tt:F===Yt||F===Xt||F===Zt||F===ni?"Console":F===Mt?"Wearable":F?Ct:"Android"===(null==E?void 0:E.userAgentDataPlatform)&&(null!==(k=null==E?void 0:E.maxTouchPoints)&&void 0!==k?k:0)>0?600>Math.min(null!==(P=null==E?void 0:E.screenWidth)&&void 0!==P?P:0,null!==(C=null==E?void 0:E.screenHeight)&&void 0!==C?C:0)/(null!==(I=null==E?void 0:E.devicePixelRatio)&&void 0!==I?I:1)?Ct:Tt:"Desktop"),$timezone:An(),$timezone_offset:Ln()}),{$current_url:gn(r?Li(null==xe?void 0:xe.href):null==xe?void 0:xe.href,c,Sn),$host:null==xe?void 0:xe.host,$pathname:null==xe?void 0:xe.pathname,$raw_user_agent:Ie.length>1e3?Ie.substring(0,997)+"...":Ie,$browser_version:Ii(Ie,navigator.vendor,p,g),$browser_language:Cn(),$browser_language_prefix:(S=Cn(),"string"==typeof S?S.split("-")[0]:void 0),$screen_height:null==ye?void 0:ye.screen.height,$screen_width:null==ye?void 0:ye.screen.width,$viewport_height:null==ye?void 0:ye.innerHeight,$viewport_width:null==ye?void 0:ye.innerWidth,$lib:s.LIB_NAME,$lib_version:s.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return s.SDK_DIST_CHANNEL&&(T.$sdk_dist_channel=s.SDK_DIST_CHANNEL),T}(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 h=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime()),_=h.windowId;l.$session_id=h.sessionId,l.$window_id=_}this.sessionPropsManager&&$r(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&$r(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===aa&&(l.$lib_custom_api_host=this.config.api_host),c=e!==ge||o?e!==ve||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,n),l=$r(l,c),e===ge&&Se&&(l.title=Se.title),!at(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Ie&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var v=this.persistence.properties(),f=this.sessionPersistence.properties();Mr(["$referrer","$referring_domain"],(e=>{e in v&&delete f[e]})),(l=$r({},d,v,f,l)).$is_identified=this._isIdentified(),rt(this.config.property_denylist)?Mr(this.config.property_denylist,(function(e){delete l[e]})):Rr.error(Ta+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(Rr.error(Fa),l=m(l,e));var y=this._hasPersonProcessing();return l.$process_person_profile=y,y&&!o&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var r;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=$r({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(Rr.error(Fa),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),ot(o)?void 0:o}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,r;return null!==(i=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;null==(r=this.featureFlags)||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return void 0===t&&(t=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Ia}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Ia})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Ia})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=va),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Ia}}canRenderSurveyAsync(e,t){var i,r;return void 0===t&&(t=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Ia})}_validateIdentifyId(e){return!e||ut(e)?(Rr.critical("Unique user id has not been set in posthog.identify"),!1):e===ie?(Rr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(Rr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return Rr.uninitializedWarning("posthog.identify");if(ht(e)&&(e=e.toString(),Rr.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(o)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(Q)||ce)===ce,a=e!==r,u=!a&&n;if(a&&n)this.persistence.set_property(Q,de),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(fe,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=ra(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r);else if(u){this.persistence.set_property(Q,de);var c=t||{},d=i||{};this.setPersonPropertiesForFlags({$set:c,$set_once:d},!1),this.capture("$set",{$set:c,$set_once:d}),this._cachedPersonProperties=ra(e,t,i)}else(t||i)&&this.setPersonProperties(t,i);a?(this.reloadFeatureFlags(),this.unregister(W)):u&&(t||i)&&this.reloadFeatureFlags()}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=ra(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):Rr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(rt(e)?e:[e]).filter((e=>lt(e)&&e.length>0));0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,r){if(e&&t){var s=this.getGroups(),n=s[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),n||r){var o={$group_type:e,$group_key:t};r&&(o.$group_set=r),this.capture(me,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else Rr.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){this._reset(e)}_reset(e,t){var i,r,s,n,l,u,c,d,h,_;if(void 0===t&&(t=!1),Rr.info("reset"),!this.__loaded)return Rr.uninitializedWarning("posthog.reset");var p,g=this.get_property(o),v=this.get_property(a),f=this.get_property(y),m=this.is_capturing();if(this.consent.reset(),t||!m||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==(i=this.persistence)||i.clear(),null==(r=this.sessionPersistence)||r.clear(),at(f)||null==(p=this.persistence)||p.register({[y]:f}),null==(s=this.surveys)||s.reset(),null==(n=this._remoteConfigLoader)||n.stop(),null==(l=this.featureFlags)||l.reset(),null==(u=this.conversations)||u.reset(),null==(c=this.logs)||c.reset(),null==(d=this.metrics)||d.reset(),null==(h=this.persistence)||h.set_property(Q,ce),null==(_=this.sessionManager)||_.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===ue)this.register_once({distinct_id:ie,$device_id:null},"");else{var b=this.config.get_device_id(Jr());this.register_once({distinct_id:b,$device_id:e?b:g},""),e||at(v)||this.register({[a]:v})}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var i=this;return t((function*(){var e,t,r,s,n,o,a;i.__loaded?(null==(e=i._remoteConfigLoader)||e.stop(),null==(t=i._browserClientAdapter)||t.dispose(),null==(r=i.logs)||r.flushLogs("sendBeacon"),null==(s=i.metrics)||s.flush("sendBeacon"),null==(n=i._requestQueue)||n.unload(),null==(o=i._retryQueue)||o.unload(),null==(a=i.featureFlags)||a.destroy()):Rr.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.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(e,t){return e===this.get_property(n)?(Rr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(at(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Rr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(nt(e)){var r,n,o,a,l,u,c,d,h,_,p;$r(this.config,Oa(e));var g=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,g),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Dn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);pt(v)&&(this.config.debug=v),pt(this.config.debug)&&(this.config.debug?(s.DEBUG=!0,is._is_supported()&&is._set("ph_debug",!0),Rr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(s.DEBUG=!1,is._is_supported()&&is._remove("ph_debug"))),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(l=this.tracingHeaders)||l.startIfEnabledOrStop(),null==(u=this.autocapture)||u.startIfEnabled(),null==(c=this.heatmaps)||c.startIfEnabled(),null==(d=this.exceptionObserver)||d.startIfEnabledOrStop(),null==(h=this.deadClicksAutocapture)||h.startIfEnabledOrStop(),null==(_=this.surveys)||_.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(p=this.externalIntegrations)||p.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){s.LIB_NAME=e,s.LIB_VERSION=t}startSessionRecording(e){var t,i,r,s,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.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 e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,t))}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var e,t;return null!==(e=null==(t=this.logs)?void 0:t.logger)&&void 0!==e?e:Ba._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Aa;return t!==Aa&&(t=Aa+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(Q))===de||(null==(t=this.sessionPersistence)?void 0:t.get_property(Q))===de}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===he&&!this._isIdentified()&&ot(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[te]))}_shouldCapturePageleave(){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._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Rr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(te,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==le)}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();return(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==ue){if(this._inCookielessMode()){var i,r,s,n,o;this._reset(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new Xo(this),this.pageViewManager=new an(this),this.persistence&&(this.sessionPropsManager=new Jo(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=Ba.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new l(this)),this._lastRemoteConfig&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this._lastRemoteConfig)))}var u,c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),this.config.cookieless_mode==le&&(null==(u=this.surveys)||u.loadIfEnabled()),(at(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(c=null==e?void 0:e.captureEventName)&&void 0!==c?c:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else Rr.warn(Ca)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==ue?(this.config.cookieless_mode===le&&this.consent.isOptedIn()&&this._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===le&&(this.register({distinct_id:ie,$device_id:null}),null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,null==(t=this.sessionManager)||t.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())):Rr.warn(Ca)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===ue||(this.config.cookieless_mode===le?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return we?ea(we,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Se&&("visible"===Se.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ge,{title:Se.title},{send_instantly:!0}),this._visibilityStateListener&&(Se.removeEventListener(_e,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Hr(Se,_e,this._visibilityStateListener)))}debug(e){!1===e?(null==ye||ye.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==ye||ye.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}))}_shouldDisableFlags(){var e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Rr.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(e,t,i,r,s){var n=t in e&&!dt(e[t]),o=i in e&&!dt(e[i]);return n?e[t]:!!o&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Rr)}_runBeforeSend(e){var t;if(dt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(ft),r=rt(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),dt(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return vt(e.event)?Rr.warn(o+". This can cause unexpected behavior."):Rr.info(o),null}s.properties&&!ot(s.properties)||Rr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&dt(s.properties[a]))return Rr.warn("Event '"+e.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 e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=pt(e)&&!e,i=is._is_supported()&&"true"===is._get("ph_debug");return!t&&(!!i||e)}}Ba.__defaultExtensionClasses={},Ba._noopLogger=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Br(e.prototype[t[i]])}(Ba,["identify"]);class qa{constructor(e){this.disabled=!1===e;var t=nt(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Na="$copy_autocapture",za=Ar("[AutoCapture]");function Ha(e,t){return t.length>e?t.slice(0,e)+"...":t}function ja(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!gs(t));return t}function Ua(e,t){var r,s,n=t.e,o=t.maskAllElementAttributes,a=t.maskAllText,l=t.elementAttributeIgnoreList,u=t.elementsChainAsString,c=t.disableCaptureUrlHashes;if(!gs(e))return{props:{}};for(var d=[e],h=new Set([e]),_=e;_.parentNode&&!vs(_,"body")&&ys>d.length;)if(ms(_.parentNode)){var p=_.parentNode.host;if(h.has(p))break;h.add(p),d.push(p),_=p}else{if(!gs(_.parentNode))break;if(h.has(_.parentNode))break;h.add(_.parentNode),d.push(_.parentNode),_=_.parentNode}var g,v,f=[],m={},y=!1,b=!1;if(Mr(d,(e=>{var t=Bs(e);if(vs(e,"a")){var i=e.getAttribute("href");y=!!(t&&i&&Gs(i))&&(c?Li(i):i)}Je(Ss(e),"ph-no-capture")&&(b=!0),f.push(function(e,t,i,r,s){void 0===s&&(s=!1);var n=e.tagName.toLowerCase(),o={tag_name:n};Ps.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ha(1024,Ks(e)):Ha(1024,Es(e)));var a=Ss(e);a.length>0&&(o.classes=a.filter((function(e){return""!==e}))),Mr(e.attributes,(function(i){var n;if((!qs(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Gs(i.value)&&(!lt(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=bs(a).join(" ")),o["attr__"+i.name]=Ha(1024,"href"===i.name&&s?Li(a):a)}}));for(var l=1,u=1,c=e;c=ja(c);)l++,c.tagName===e.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(e,o,a,l,c));var r=function(e){if(!Bs(e))return{};var t={};return Mr(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Gs(r)&&(t[i]=r)}})),t}(e);$r(m,r)})),b)return{props:{},explicitNoCapture:b};if(a||(f[0].$el_text=vs(e,"a")||vs(e,"button")?Ks(e):Es(e)),y){var w,S;f[0].attr__href=y;var x=null==(w=_n(y))?void 0:w.host,E=null==ye||null==(S=ye.location)?void 0:S.host;x&&E&&x!==E&&(g=y)}return{props:$r({$event_type:n.type,$ce_version:1},u?{}:{$elements:f},{$elements_chain:(v=f,function(e){return e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Or(o).sort(((e,t)=>e[0].localeCompare(t[0]))).forEach((e=>{var t=e[1];return a[Js(e[0].toString())]=Js(t.toString())})),(s+=":")+Or(a).map((e=>e[0]+'="'+e[1]+'"')).join("")})).join(";")}(function(e){return e.map((e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Ys(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Or(e).filter((e=>0===e[0].indexOf("attr__"))).forEach((e=>r.attributes[e[0]]=e[1])),r}))}(v)))},null!=(r=f[0])&&r.$el_text?{$el_text:null==(s=f[0])?void 0:s.$el_text}:{},g&&"click"===n.type?{$external_click_url:g}:{},m)}}var Wa=Ar("[ExceptionAutocapture]"),Va=()=>{},Ga=Ar("[TracingHeaders]"),Ka=Ar("[Web Vitals]"),Qa=9e5,Ja="disabled",Ya="lazy_loading",Za="awaiting_config",Xa="missing_config";Ar("[SessionRecording]"),Ar("[SessionRecording]");var el="[SessionRecording]",tl=Ar(el),il=Ar("[Heatmaps]");function rl(e){return nt(e)&&"clientX"in e&&"clientY"in e&&ht(e.clientX)&&ht(e.clientY)}var sl=Ar("[Product Tours]"),nl=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(f))},ol=["$set_once","$set"],al=Ar("[SiteApps]"),ll="Error while initializing PostHog app with config id ";function ul(e,t,i){if(dt(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class cl{constructor(e){this._debugEventEmitter=new Yo,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e,t;at(null==(e=this._instance)?void 0:e._addCaptureHook)||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)})))}register(e){var t,i;if(!at(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!ul(r,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var i;if(null==t||!t.href)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>ul(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&ul((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>ul(e.text,t.text,t.text_matching||"exact")||ul(e.$el_text,t.text,t.text_matching||"exact")));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!dt(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some((e=>ul(e,n,o))))}_checkStepSelector(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||oa(t.properties.reduce(((e,t)=>{var i=rt(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e}),{}),null==e?void 0:e.properties)}}class dl{constructor(e){var t;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,null==(t=this._instance)||null==t.onSessionId||t.onSessionId((e=>this._onSessionIdChanged(e)))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&oa(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach((t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}}))})),i}_getMatchingItems(e,t,i){var r=(i===zn?this._eventToItems:this._cancelEventToItems).get(e),s=[];return this._getItems((e=>{s=e.filter((e=>null==r?void 0:r.includes(e.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;at(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedItems(e),this._setupActionBasedItems(e))}_setupActionBasedItems(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==t.length&&(null==this._actionMatcher&&(this._actionMatcher=new cl(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook((e=>{this.onAction(e)}))),t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToItems.get(t.name);i&&i.push(e.id),this._actionToItems.set(t.name,i||[e.id])}})))})))}_setupEventBasedItems(e){var t,i=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,zn),this._cancelEventToItems=this._buildEventToItemMap(e,Hn))}onEvent(e,t){var i,r,s=this._getLogger(),n=(null==t||null==(i=t.properties)?void 0:i.$survey_id)||(null==t||null==(r=t.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this._activationOutcome(e,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:e,itemId:n}),void this._deactivateItems([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:e,itemId:n}),this._persistActivation(n),void this._clearActivationTimestamps([n])}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,Hn);a.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map((e=>e.id))}),this._deactivateItems(a.map((e=>e.id))),a.forEach((e=>this._cancelPendingItem(e.id))))}if(this._eventToItems.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var l=this._getMatchingItems(e,t,zn);this._activateItems(l.map((e=>e.id)))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){var t;if(0!==e.length){var i=!(null==(t=this._instance)||null==t.get_session_id||!t.get_session_id()),r=[];for(var s of e)i&&this._shouldPersistArmedActivation(s)?this._persistActivation(s)&&this._recordActivationTimestamp(s):r.push(s);r.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...r])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()})}}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter((t=>t!==e));var t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter((e=>!t.has(e)));var i=this._getRawPersistedActivatedIds(),r=i.filter((e=>!t.has(e)));r.length!==i.length&&(this._setActivatedItems(r),0===r.length&&this._clearActivationSession()),this._clearActivationTimestamps(e)}_getRawActivationTimestamps(){var e,t=this._getActivationTimestampsKey();if(!t)return{};var i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t];return i&&"object"==typeof i?i:{}}_recordActivationTimestamp(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps();this._writeActivationTimestamps(i({},t,{[e]:Date.now()}))}}_clearActivationTimestamps(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps(),i={},r=!1;for(var s of Object.entries(t)){var n=s[0],o=s[1];e.includes(n)?r=!0:i[n]=o}r&&(ot(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(this._getPersistedActivatedIds().includes(e)){var t=this._getRawActivationTimestamps()[e];return ht(t)?t:void 0}}_getRawPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,i=this._getRawPersistedActivatedIds();if(0===i.length)return[];var r=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this._getActivatedSessionKey()],s=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();return s&&r===s?i:[]}_stampActivationSession(){var e,t=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();t&&this._setActivatedSession(t)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this._getActivatedSessionKey()];if(i&&i!==e){var r=this._getRawPersistedActivatedIds(),s=this._getRawActivationTimestamps();r.length>0&&(this._setActivatedItems([]),r.filter((e=>ht(s[e]))).forEach((e=>this._cancelPendingItem(e)))),this._clearActivationSession(),this._clearAllActivationTimestamps()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter((e=>!this._isItemPermanentlyIneligible(e)))}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class hl extends dl{constructor(e){super(e)}_getActivatedKey(){return z}_getActivatedSessionKey(){return H}_getActivationTimestampsKey(){return j}_writeActivationTimestamps(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[j]:e})}_clearActivationTimestampsStore(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(j)}_shouldPersistArmedActivation(e){var t,i;this._getItems((t=>{i=t.find((t=>t.id===e))}));var r=null==(t=i)||null==(t=t.appearance)?void 0:t.surveyPopupDelaySeconds;return ht(r)&&r>0}_getShownEventName(){return jn}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return ha}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[z]:e})}_setActivatedSession(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[H]:e})}_clearActivatedSession(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(H)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){var i;this._getItems((e=>{i=e.find((e=>e.id===t))}));var r=!i||function(e){var t;return da(e)&&!(null==(t=e.conditions)||null==(t=t.events)||!t.repeatedActivation)||"always"===e.schedule}(i);return r?e===jn?"consume":"ignore":e===jn?"persist":e===Un||e===Wn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var _l="SDK is not enabled or survey functionality is not yet loaded",pl="Disabled. Not loading surveys.",gl=null!=ye&&ye.location?vn(ye.location.hash,"__posthog")||vn(location.hash,"state"):null,vl="_postHogToolbarParams",fl=Ar("[Toolbar]"),ml=Ar("[FeatureFlags]"),yl=Ar("[FeatureFlags]",{debugEnabled:!0}),bl="\" failed. Feature flags didn't load in time.",wl=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Sl=e=>{var t={};for(var i of Or(e||{})){var r=i[1];r&&(t[i[0]]=r)}return t},xl=Ar("[Error tracking]"),El="Refusing to render web experiment since the viewer is a likely bot",kl={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>ia(t,e),not_regex:(e,t)=>!ia(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class Pl{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Pl._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Pl._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);lt(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];Pl._matchesTestVariant(n,t._instance)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Pl._logInfo(El);else if(!this._config.disable_web_experiments){if(dt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Pl._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=Pl.getWindowLocation();if(null!=e&&e.search){var t=pn(null==e?void 0:e.search,"__experiment_id"),i=pn(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Pl._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(Pl._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e,t){return!dt(e.conditions)&&Pl._matchUrlConditions(e,t)&&Pl._matchUTMConditions(e)}static _matchUrlConditions(e,t){var i;if(dt(e.conditions)||dt(null==(i=e.conditions)?void 0:i.url))return!0;var r=Pl.getWindowLocation();if(r){var s,n,o,a=us(t,r.href);return null==(s=e.conditions)||!s.url||kl[null!==(n=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](e.conditions.url,a)}return!1}static getWindowLocation(){return null==ye?void 0:ye.location}static _matchUTMConditions(e){var t;if(dt(e.conditions)||dt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=En();if(i.utm_source){var r,s,n,o,a,l,u,c,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,h=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,_=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return d&&_&&p&&h}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];Rr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Pl._logInfo(El):"control"!==t?i.forEach((i=>{if(i.selector){var r;Pl._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):Pl._logInfo("Control variants leave the page unmodified.")}_is_bot(){return we&&this._instance?ea(we,this._config.custom_blocked_useragents):void 0}}var Cl=Ar("[Conversations]"),Il="Conversations not available yet.",Fl="console",Tl="__posthogHandledLogsRequestError",Rl=(e,t)=>{var i=e instanceof Error?e:new Error(t);return i[Tl]=!0,i},Al=e=>!!e&&"object"==typeof e&&!0===e[Tl],Ll={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._onOnline=()=>{var e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],ye&&Hr(ye,"online",this._onOnline)}destroy(){null==ye||ye.removeEventListener("online",this._onOnline)}get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}_prop(e){return this._instance.get_property(e)}_isCacheStale(){var e,t;return null!==(e=null==(t=this._persistence)?void 0:t._isFeatureFlagCacheStale(this._config.feature_flag_cache_ttl_ms))&&void 0!==e&&e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,ml.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e,t=null!==(e=this._config.evaluation_contexts)&&void 0!==e?e:this._config.evaluation_environments;return!this._config.evaluation_environments||this._config.evaluation_contexts||this._hasLoggedDeprecationWarning||(ml.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._hasLoggedDeprecationWarning=!0),null!=t&&t.length?t.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||ml.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}_getValidFlagKeys(){var e=this._config.flag_keys;if(!at(e)){if(rt(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||ml.error("Invalid flag key found:",e,"Expected non-empty string"),t}));ml.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,i=this._instance.config,r=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};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((e=>!!r[e])).reduce(((e,t)=>(e[t]=r[t]||!1,e)),{}),l=Object.keys(o).filter((e=>a[e])).reduce(((e,t)=>(o[t]&&(e[t]=o[t]),e)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,r){var s,n,o=null!=r&&r.merge&&null!==(s=this._prop(C))&&void 0!==s?s:{},a=null!=r&&r.merge&&null!==(n=this._prop(R))&&void 0!==n?n:{},l=i({},o,e),u=i({},a,t),c={};for(var d of Object.entries(l)){var h=d[0],_=d[1];c[h]={key:h,enabled:Le(_),variant:Me(_),reason:void 0,metadata:at(null==u?void 0:u[h])?void 0:{id:0,version:void 0,description:void 0,payload:u[h]}}}this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(T),t=this._prop(M),r=this._prop(O);if(!r&&!t)return e||{};var s=$r({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=s[o],c=null==t?void 0:t[o],d=at(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,h=at(c)?u.variant:"string"==typeof c?c:void 0,_=null==r?void 0:r[o],p=i({},u,{enabled:d,variant:d?null!=h?h:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),h!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),_&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:_,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[o]=p}return this._override_warning||(ml.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((i=>{var r=e[i];return{key:i,enabled:Le(r),variant:Me(r),payload:Ae(t[i])}}))}getFlagVariants(){var e=this._prop(C),t=this._prop(M);if(!t)return e||{};for(var i=$r({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(ml.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(R),t=this._prop(O);if(!t)return e||{};for(var i=$r({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(ml.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.advanced_disable_feature_flags||this._hasStatusZeroCircuitBreakerTripped()||this._reloadDebouncer||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags()&&!this._hasStatusZeroCircuitBreakerTripped())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r=this._config.token,n=this._prop(o),a={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._persistence)?void 0:t.get_initial_props())||{},this._prop(D)||{},{$lib:s.LIB_NAME,$lib_version:s.LIB_VERSION}),group_properties:this._prop(B),timezone:An()};ct(n)||at(n)||(a.$device_id=n),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(a.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(a.evaluation_contexts=this._getValidEvaluationEnvironments());var l=this._getValidFlagKeys();at(l)||(a.flag_keys=l);var u=!!this._config.advanced_only_evaluate_survey_feature_flags,c=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this._config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this._requestInFlight=!0,this._instance._send_request({method:"POST",url:c,data:a,compression:this._config.disable_compression?void 0:Nn,timestampMode:"body",timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(this._trackStatusZeroReachability(e.statusCode),200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,!a.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;var n=[];e.error?e.error instanceof Error?n.push("AbortError"===e.error.name?"timeout":"connection_error"):n.push("unknown_error"):200!==e.statusCode&&n.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&n.push("errors_while_computing_flags");var o,l=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(l&&n.push("quota_limited"),null==(r=this._persistence)||r.register({[G]:n}),l)ml.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.");else a.disable_flags||this.receivedFeatureFlags(null!==(o=e.json)&&void 0!==o?o:{},s,{partialResponse:u}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}_hasStatusZeroCircuitBreakerTripped(){return fn(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=mn(e,this._consecutiveStatusZeroFailures,3,(()=>ml.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else ml.warn('getFeatureFlag for key "'+e+bl)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(A)||void 0,l=this._prop(K)||void 0,u=this._prop(W)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),h=this._prop(V);d&&d!==h&&(u={},null==(c=this._persistence)||c.register({[W]:u,[V]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var _,p,g,v,f,m,y,b,w,S,x;rt(u[e])?u[e].push(o):u[e]=[o],null==(_=this._persistence)||_.register({[W]:u});var E=this.getFeatureFlagDetails(e),k=[...null!==(p=this._prop(G))&&void 0!==p?p:[]];at(s)&&k.push("flag_missing");var P={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};at(null==E||null==(f=E.metadata)?void 0:f.has_experiment)||(P.$feature_flag_has_experiment=E.metadata.has_experiment),at(null==E||null==(m=E.metadata)?void 0:m.version)||(P.$feature_flag_version=E.metadata.version);var C,I=null!==(y=null==E||null==(b=E.reason)?void 0:b.description)&&void 0!==y?y:null==E||null==(w=E.reason)?void 0:w.code;I&&(P.$feature_flag_reason=I),null!=E&&null!=(S=E.metadata)&&S.id&&(P.$feature_flag_id=E.metadata.id),at(null==E?void 0:E.original_variant)&&at(null==E?void 0:E.original_enabled)||(P.$feature_flag_original_response=at(E.original_variant)?E.original_enabled:E.original_variant),null!=E&&null!=(x=E.metadata)&&x.original_payload&&(P.$feature_flag_original_payload=null==E||null==(C=E.metadata)?void 0:C.original_payload),k.length&&(P.$feature_flag_error=k.join(",")),this._instance.capture("$feature_flag_called",P)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Ae(n)}}}else ml.warn('getFeatureFlagResult for key "'+e+bl)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i,person_properties:{$lib:s.LIB_NAME,$lib_version:s.LIB_VERSION}};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments());var n=this._getValidFlagKeys();at(n)||(r.flag_keys=n),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:Nn,timestampMode:"body",timeout:this._config.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return ml.warn('isFeatureEnabled for key "'+e+bl),t.defaultValue;var i=this.getFeatureFlag(e,t);return at(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,r){if(this._persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,r,s,n,o){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var a=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):e.featureFlags&&ml.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,h=e.evaluatedAt;if(rt(u)){ml.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var _={};if(u)for(var p=0;u.length>p;p++)_[u[p]]=!0;t&&t.register({[I]:u,[C]:_,[L]:!1})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},r,g),v=i({},s,v),f=i({},n,f);else if(e.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((e=>{var t;return!(null!=(t=l[e])&&t.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((e=>m.has(e[0]))))),v=i({},s,Object.fromEntries(Object.entries(v||{}).filter((e=>m.has(e[0]))))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>m.has(e[0])))))}else g=i({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[I]:Object.keys(Sl(g)),[C]:g||{},[R]:v||{},[T]:f||{},[L]:!0===e.minimalFlagCalledEvents},d?{[A]:d}:{},h?{[K]:h}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),ml.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return ml.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(M),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),yl.info("All overrides cleared");if(rt(e)){var t=wl(e);return this._persistence.register({[M]:t}),this._fireFeatureFlagsCallbacks(),yl.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(M),yl.info("Flag overrides cleared");else if(r.flags){if(rt(r.flags)){var s=wl(r.flags);this._persistence.register({[M]:s})}else this._persistence.register({[M]:r.flags});yl.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),yl.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),yl.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[M]:e}),this._fireFeatureFlagsCallbacks(),yl.info("Flag overrides set",{flags:e});ml.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,r=t.flagVariants;try{e(i,r)}catch(e){ml.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(F)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[I]:Object.keys(Sl(l)),[C]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(F),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",timestampMode:"query",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(F),null==(r=this._persistence)||r.register({[F]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach((t=>{try{t(i,r,{errorsLoading:e})}catch(e){ml.error("Error while running feature flags callback",e)}}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(D)||{},s=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in r||(o[a]=n[a]));this._instance.register({[D]:i({},r,o,s)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=i({},this._prop(D)||{});e.forEach((e=>{delete r[e]})),this._instance.register({[D]:r}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){void 0===e&&(e=!0),this._instance.unregister(D),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(B)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[B]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(B)||{};this._instance.register({[B]:i({},t,{[e]:{}})})}else this._instance.unregister(B)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0}}},Ml={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return this._recordingStatus===Za||this._recordingStatus===Xa?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Ja,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw tl.error("started without valid sessionManager"),new Error(el+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===ue)throw new Error(el+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(y))||!e.enabled),i=!this._config.disable_session_recording,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return ye&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!at(Object.assign)&&!at(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),tl.info("starting")):(this._recordingStatus=Ja,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==Za&&this._recordingStatus!==Xa&&(this._recordingStatus=Ya),null!=Re&&null!=(t=Re.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Re.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=Re.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return tl.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_discardRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.discard()}_resetSampling(){var e,t;null==(e=this._persistence)||e.unregister(P),null==(t=this._persistence)||t.unregister(b)}_validateSampleRate(e,t){if(dt(e))return null;var i,r=ht(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(tl.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}_persistRemoteConfig(e){if(this._persistence){var t,r,s=this._persistence,n=()=>{var t,r=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==r?void 0:r.sampleRate,"remote config sampleRate"),a=null!=n?n:o;dt(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[y]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:a,minimumDurationMilliseconds:at(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):(this._recordingStatus===Za&&(this._recordingStatus=Xa,tl.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):tl.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(y);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t,i=this._instance.get_property(y);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(e){return tl.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}var r=null!==(e=t.cache_timestamp)&&void 0!==e?e:Date.now();return 36e5>=Date.now()-r}_onScriptLoaded(e){var t,i;if(null==(t=Re.__PosthogExtensions__)||!t.initSessionRecording)return tl.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[oe]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Re.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===Xa||this._recordingStatus===Za)return;return this._recordingStatus=Za,tl.info("persisted remote config is stale, requesting fresh config before starting"),void new Jn(this._instance).load()}this._recordingStatus=Ya,this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[S]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[w]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?x:E]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}},$l={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new qa(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=nt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(ye&&Se){var e=e=>{e=e||(null==ye?void 0:ye.event);try{this._captureEvent(e)}catch(e){za.error("Failed to capture event",e)}};if(Hr(Se,"submit",e,{capture:!0}),Hr(Se,"change",e,{capture:!0}),Hr(Se,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==ye?void 0:ye.event);try{this._captureEvent(e,Na)}catch(e){za.error("Failed to capture copy/cut event",e)}};Hr(Se,"copy",t,{capture:!0}),Hr(Se,"cut",t,{capture:!0})}}}else za.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._hasReceivedConfigResponse=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);var i=t.autocapture_opt_out;pt(i)&&(this.instance.persistence&&this.instance.persistence.register({[c]:i}),this._isDisabledServerSide=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==Se?void 0:Se.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[c],r=this._isDisabledServerSide,s=this.instance._shouldDisableFlags()&&!this._hasReceivedConfigResponse;if(ct(r)&&!pt(i)&&!s)return!1;var n=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=ks(e);fs(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&$s(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===Na;if(r&&function(e,t,i,r,s,n){var o;if(!ye||Os(e))return!1;if(null!=i&&i.url_allowlist&&!ws(i.url_allowlist,n))return!1;if(null!=i&&i.url_ignorelist&&ws(i.url_ignorelist,n))return!1;if(null!=i&&i.dom_event_allowlist){var a=i.dom_event_allowlist;if(a&&!a.some((e=>t.type===e)))return!1}var l=Ds(e,r),u=l.parentIsUsefulElement,c=l.targetElementList;if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(at(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(c,i))return!1;if(!Cs(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Cs(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Fs))return!1;try{var d=ye.getComputedStyle(e);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return u?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(Ps.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0,this.instance)){var n=Ua(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),o=n.props;if(n.explicitNoCapture)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(o.$element_selectors=a),t===Na){var l,u=xs(null==ye||null==(l=ye.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=c}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return st(null==Se?void 0:Se.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==ye||null==(t=ye.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Rr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,Rr.info("History API monitoring stopped")}monitorHistoryChanges(){ye&&ye.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener())}_patchHistoryMethod(e){var t;if(ye&&(null==(t=ye.history[e])||!t.__posthog_wrapped__)){var i=this;!function(e,t,i){try{if(!(t in e))return Va;var r={next:e[t]},s=i((function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return r.next.apply(this,t)}));return st(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=s,()=>{if(e[t]!==s)for(var i=e[t];st(i)&&i.__posthog_layer__;){var n=i.__posthog_layer__;if(n.next===s)return void(n.next=r.next);i=n.next}else e[t]=r.next}}catch(e){return Va}}(ye.history,e,(t=>function(r,s,n){t.call(this,r,s,n),i._capturePageview(e)}))}}_capturePageview(e){try{var t,i=null==ye||null==(t=ye.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(ge,{navigation_type:e}),this._lastPathname=i}catch(t){Rr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Hr(ye,"popstate",e),this._popstateListener=()=>{ye&&ye.removeEventListener("popstate",e)}}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[d]),this.rageclicks=new qa(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return nt(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return dt(this._config.capture_heatmaps)?dt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;il.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[d]:i}),this._enabledServerSide=i,this.startIfEnabled()}}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){rl(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(Se)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){ye&&Se&&(this._flushHandler=this._flush.bind(this),Hr(ye,pe,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==ye?void 0:ye.event)),Hr(Se,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==ye?void 0:ye.event)),Hr(Se,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new tn(this.instance,Xs,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Hr(Se,_e,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;ye&&Se&&(this._flushHandler&&ye.removeEventListener(pe,this._flushHandler),this._onClickHandler&&Se.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&Se.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&Se.removeEventListener(_e,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&gs(r)&&!vs(r,"body");){if(r===i)return!1;var s=void 0;try{var n,o,a;s=null==(n=null!==(o=null==(a=r.ownerDocument)?void 0:a.defaultView)&&void 0!==o?o:ye)?void 0:n.getComputedStyle(r).position}catch(e){return!1}if(Je(t,s))return!0;r=Is(r)}return!1}(ks(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!ps(e.target)&&rl(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&$s(ks(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!ps(e.target)&&rl(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(ye){var t=this._config.disable_capture_url_hashes?Li(ye.location.href):ye.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...bn,...i||[]]:[],s=gn(t,r,Sn);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!ot(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:tn,webVitalsAutocapture:class{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",i({$current_url:this._buffer.url},this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{}))),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},dt(null==e?void 0:e.name)||dt(null==e?void 0:e.value))Ka.error("Invalid metric received",e);else{var r="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this._maskedURL(r);if(!at(s)){var n=ht(e.navigationId)||"string"==typeof e.navigationId?"navigation:"+e.navigationId:"url:"+s;if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),at(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=s),this._buffer.firstMetricTimestamp=at(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var o=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),a=i({},e,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});at(o)||(a.$session_id=o.sessionId,a.$window_id=o.windowId),this._buffer.metrics.push(a),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else Ka.error("Ignoring metric with value >= "+this._maxAllowedValue,e)}}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Re.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&at(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(at(o)||(e=o.onLCP,t=o.onCLS,i=o.onFCP,r=o.onINP),e&&t&&i&&r){var a={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this),a),this._initialized=!0}else Ka.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[g]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=nt(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return dt(i)?(null==(t=this._instance.persistence)?void 0:t.props[m])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(nt(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=nt(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get useSoftNavs(){var e=nt(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){var e=nt(this._perfConfig)&&ht(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Qa;return e>0&&6e4>=e?Qa:e}get isEnabled(){var e=null==xe?void 0:xe.protocol;if("http:"!==e&&"https:"!==e)return Ka.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=nt(this._perfConfig)?this._perfConfig.web_vitals:pt(this._perfConfig)?this._perfConfig:void 0;return pt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ka.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var i=nt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=nt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[g]:i}),this._instance.persistence.register({[m]:r})),this._enabledServerSide=i,this.startIfEnabled()}}}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t=Re.__PosthogExtensions__,i=this._callbackFlavor,r=null==t?void 0:t.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&at(r)&&null!=t&&t.postHogWebVitalsCallbacks?e():null==t||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,i,(t=>{t?Ka.error("failed to load script",t):e()}))}_maskedURL(e){var t=e||(null==ye?void 0:ye.location.href);if(t){var i=this._instance.config.disable_capture_url_hashes?Li(t):t,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...bn,...r||[]]:[];return gn(i,s,Sn)}Ka.error("Could not determine current URL")}}},Ol={exceptionObserver:class{constructor(e){var t;this._startCapturing=()=>{var e;if(ye&&this.isEnabled&&null!=(e=Re.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Re.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Re.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Re.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=r(this.captureException.bind(this)))}catch(e){Wa.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[h]),this._rateLimiter=new Pt(i({},function(e){var t,i,r,s;return void 0===e&&(e={}),{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(r=null!==(s=e.exceptionRateLimiterBucketSize)&&void 0!==s?s:e.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,_logger:Wa})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return nt(e)?t=i({},t,e):(at(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Wa.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return Wa.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[h]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?Wa.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,r;this._suppressionRules=[],this._errorPropertiesBuilder=new er([new hr,new Sr,new pr,new _r,new br,new yr,new vr,new wr],function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;t>s;s++)r[s-1]=arguments[s];return function(t,s){void 0===s&&(s=0);for(var n=[],o=t.split("\n"),a=s;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=dr.test(l)?l.replace(dr,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of r){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return i({},e,{filename:e.filename||(r=t,r[r.length-1]||{}).filename,function:e.function||tr});var r}))}(n)}}("web:javascript",ar,cr)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(_))&&void 0!==t?t:[],this._exceptionStepsConfig=Cr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Ir(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Cr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if(e.ok){var s=e.config;if("errorTracking"in s){var n=null!==(t=null==(i=s.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=n,this._instance.persistence&&this._instance.persistence.register({[_]:this._suppressionRules,[p]:o})}}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(p),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!lt(e)||0===e.trim().length)return void xl.warn("Ignoring exception step because message must be a non-empty string");var r=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>kr.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&xl.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[xr]:e,[Er]:(new Date).toISOString()},s))}catch(e){xl.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void xl.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void xl.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void xl.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&dt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,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",_originatedFromCaptureException:!0});return s&&this._exceptionStepsBuffer.clear(),s}catch(e){return xl.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void xl.error("Failed to process exception event. Ignoring this exception.",e)}var n}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return xl.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[xr]:e,[Er]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return nt(e)?i({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{var t=e.reduce(((e,t)=>{var i=t.type,r=t.value;return lt(i)&&i.length>0&&e.$exception_types.push(i),lt(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i=sa[e.operator],r=t[e.key];if(!i||!r)return!1;var s=rt(e.value)?e.value:[e.value];return s.length>0&&i(s,r)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}catch(e){return xl.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],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}_isExceptionList(e){return!dt(e)&&rt(e)}}},Dl=i({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var i,r;if(this._persistence&&this._persistence.register({[f]:!!t.productTours}),!nl(this._instance))return!this._productTourManager&&dt(null==(i=this._persistence)?void 0:i.props[U])||sl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this._productTourManager)||r.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this._productTourManager&&nl(this._instance)&&this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?sl.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Re.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Re.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!rt(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[U];if(rt(r)&&!t)return this._cachedTours=r,void e(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:t=>{if(nl(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?t.error||sl.warn(s):sl.error(s),void e([],{isLoaded:!1,error:s})}var n=rt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[U]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){dt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript((()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)}))}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._persistence)||e.unregister(U)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},Ll),Bl={siteApps:class{constructor(e){this._siteAppElementPatchCount=0,this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=Re._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,s,n,o,a,l,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var _ of Object.entries(h)){var p=_[0];c[p]={id:d[p],type:p,properties:_[1]}}var g=e.$set_once,v=e.$set;return{event:i({},r(e,ol),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}_prepareElementForSiteApp(e){var t,i=null==(t=e.tagName)?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(al.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(al.error("prepare_external_dependency_script returned null"),null):e}_patchSiteAppElementInsertionMethods(){var e,t,i,r,s,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==Se?void 0:Se.defaultView,u=null==l||null==(e=l.Node)?void 0:e.prototype;if(!l||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();var c=[],d=this,h=new WeakSet,_=(e,t,i)=>{if(null!=e&&e[t]){var r=e[t];e[t]=i(r),c.push((()=>{e[t]=r}))}},p=e=>{if(h.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&h.add(t),t},g=e=>e.map((e=>"string"==typeof e?e:p(e))).filter((e=>!ct(e)));return _(u,"appendChild",(e=>function(t){var i=p(t);return i?e.call(this,i):t})),_(u,"insertBefore",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):t})),_(u,"replaceChild",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):i})),[null==(t=l.Element)?void 0:t.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((e=>{_(e,"append",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),_(e,"prepend",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach((e=>{_(e,"before",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),_(e,"after",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),_(e,"replaceWith",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];var s=g(i);return i.length&&!s.length?void 0:e.apply(this,s)}))})),_(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",(e=>function(t,i){var r=p(i);return r?e.call(this,t,r):null})),this._restoreSiteAppElementPatches=()=>{c.forEach((e=>e())),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){var e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null==(t=this._restoreSiteAppElementPatches)||t.call(this)))}}_runWithPreparedSiteAppElements(e,t){void 0===t&&(t=!0);var i=this._patchSiteAppElementInsertionMethods();try{var r=e(i);return t&&i(),r}catch(e){throw i(),e}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(al.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>this._runWithPreparedSiteAppElements((()=>null==t.processEvent?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&(null==(i=this._stopBuffering)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,al.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this._runWithPreparedSiteAppElements((t=>e.init({posthog:this._instance,callback(e){t(),s(e)}})),!1).processEvent;n&&(t.processEvent=n),r=!0}catch(t){al.error(ll+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){al.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){var t=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(e),r=function(r){try{t._runWithPreparedSiteAppElements((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(t){al.error("Error while processing event "+e.event+" for site app "+r.id,t)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void al.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),e.ok){var n=e.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var e,t=a.id,i=a.url;Re["__$$ph_site_app_"+t]=s._instance,null==(e=Re.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,i,(e=>{if(e)return al.error(ll+t,e)}))};for(var a of n.siteApps)o()}else al.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ql={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{var e,t,i=this._syncHostnamesForPatch();i?(at(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=Re.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),at(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=Re.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this._stopCapturing()},this._instance=e}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Ga.error("failed to load script",t);e()}))}_getConfiguredHostnames(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){var e=this._getConfiguredHostnames();return rt(e)?(rt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(rt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},Nl=i({surveys:class{get _config(){return this._instance.config}constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){if(!e.ok)return ha.warn("Remote config unavailable. Not loading surveys.");var t=e.config.surveys;if(dt(t))return ha.warn("Flags not loaded yet. Not loading surveys.");var i=rt(t);this._isSurveysEnabled=i?t.length>0:t,ha.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(_a)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)ha.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)ha.info(pl);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())ha.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Re?void 0:Re.__PosthogExtensions__;if(e){if(!at(this._isSurveysEnabled)||this._config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError(ae);r(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else ha.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new hl(this._instance),ha.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){ha.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._config.disable_surveys)return ha.info(pl),e([]);var i,r=this._instance.get_property(q);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>e(t.surveys,t.context))):("undefined"!=typeof Promise&&(this._getSurveysInFlightPromise=new Promise((e=>{i=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._config.token),method:"GET",timestampMode:"query",timeout:this._config.surveys_request_timeout_ms,callback:t=>{var r;this._getSurveysInFlightPromise=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;0!==s?ha.error(n):t.error||ha.warn(n),this._lastSurveyRefreshFailedAt=Date.now();var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}this._lastSurveyRefreshFailedAt=null;var a,l=t.json.surveys||[],u=l.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(da(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[q]:l,[N]:Date.now()});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e=this._instance.get_property(N);return ht(e)&&Date.now()-e>3e5}_isSurveyRefreshBackingOff(){return ht(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i,r={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};pa(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){ha.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!dt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);ha.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(dt(this._surveyManager))return{eligible:!1,reason:_l};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){if(dt(this._surveyManager))return{eligible:!1,reason:_l};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(dt(this._surveyManager))return ha.warn("init was not called"),{visible:!1,disabledReason:_l};var t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return dt(this._surveyManager)?(ha.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:_l})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyRenderability(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(dt(this._surveyManager))ha.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(ga.includes(s.type)){var n=null==Se?void 0:Se.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(ha.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;ha.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),ha.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);ha.warn("Survey element not found")}else ha.warn("Surveys of type "+s.type+" cannot be rendered in the app");else ha.warn("Survey not found")}}displaySurvey(e,t){var r;if(dt(this._surveyManager))ha.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Vn&&t.initialResponses&&ha.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this._checkSurveyEligibility(s);if(!o.eligible)return void ha.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else ha.warn("Survey not found")}}cancelPendingSurvey(e){dt(this._surveyManager)?ha.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||null==e.handlePageUnload||e.handlePageUnload()}}},Ll),zl={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Re.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Re.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),jr(this.instance.config))return!1;if(!ye||!Se)return!1;e=null!=e?e:ye.location,i=null!=i?i:ye.history;try{if(!t){try{ye.localStorage.setItem("test","test"),ye.localStorage.removeItem("test")}catch(e){return!1}t=null==ye?void 0:ye.localStorage}var r,s=gl||vn(e.hash,"__posthog")||vn(e.hash,"state"),n=s?Dr((()=>JSON.parse(atob(decodeURIComponent(s)))))||Dr((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(vl)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){var t=Re.ph_load_toolbar||Re.ph_load_editor;!dt(t)&&st(t)?t(e,this.instance):fl.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==Se||!Se.getElementById(cs));if(!ye||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ye.localStorage.setItem(vl,JSON.stringify(i({},s,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=Re.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return fl.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Hr(ye,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(s)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},Hl=i({experiments:Pl},Ll),jl={conversations:class{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&e.ok){var t=e.config.conversations;dt(t)||(pt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null}loadIfEnabled(){if(!(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||jr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Re?void 0:Re.__PosthogExtensions__;if(e&&!at(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError(ae);i(this._instance,"conversations",(t=>{t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1}))}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}else Cl.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Cl.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Cl.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Cl.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():Cl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!ct(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,r){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,i,r):(Cl.warn(Il),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(Cl.warn(Il),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(Cl.warn(Il),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(Cl.warn(Il),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(Cl.warn(Il),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(Cl.warn(Il),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Cl.warn(Il),null)}))()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},Ul={logs:class{constructor(e){var t,r=this;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=Ar("[logs]"),this._coreLogger=i({},this._logger,{error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];t.some(Al)||r._logger.error(...t)}}),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._onReconnect=()=>{var e,t;this._consecutiveStatusZeroFailures=0,null==(e=this._core)||e.onReconnect(),null==(t=this._consoleCore)||t.onReconnect()},this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),ye&&Hr(ye,"online",this._onReconnect)}_buildCore(e,t,i,r){var s,n=function(e,t){var i,r,s,n,o,a,l,u=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,c=null!==(r=null==e?void 0:e.maxBufferSize)&&void 0!==r?r:100,d=null!=t&&t.consoleCapture?void 0:null!==(s=null==e?void 0:e.maxLogsPerInterval)&&void 0!==s?s:1e3,h=at(d)?Math.max(c,2048):Math.max(c,d),_=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==_?void 0:_["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==n?n:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==_?void 0:_["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==_?void 0:_["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:_,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:h,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 Wi(this._createHost(e,t),n,this._coreLogger,(()=>this._getSdkContext()),(e=>e()),void 0,r),n]}_getCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._core||this._resolvedFrom!==t){var i;null==(i=this._core)||i.reset(),this._resolvedFrom=t;var r=this._buildCore((()=>this._queue),(e=>{this._queue=e}));this._core=r[0],this._resolvedConfig=r[1]}return this._core}_getConsoleCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._consoleCore||this._consoleResolvedFrom!==t){var i;null==(i=this._consoleCore)||i.reset(),this._consoleResolvedFrom=t;var r=this._buildCore((()=>this._consoleQueue),(e=>{this._consoleQueue=e}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Fl);this._consoleCore=r[0],this._consoleResolvedConfig=r[1]}return this._consoleCore}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t;if(e.ok){var i=null==(t=e.config.logs)?void 0:t.captureConsoleLogs;!dt(i)&&i&&(this._isLogsEnabled=!0,this.loadIfEnabled())}}reset(){var e,t;this._queue=[],null==(e=this._core)||e.reset(),this._consoleQueue=[],null==(t=this._consoleCore)||t.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){this._getCore().captureLog(e)}_captureConsoleLog(e){this._getConsoleCore().captureLog(e)}get logger(){return this._capture_logger||(this._capture_logger={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._capture_logger}flushLogs(e){e?this._flushViaTransport(e):(this._core&&this._core.flush().catch((e=>this._logFlushError(e))),this._consoleCore&&this._consoleCore.flush().catch((e=>this._logFlushError(e))))}_logFlushError(e){Al(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Re?void 0:Re.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(t=>{var i;t||null==(i=e.logs)||!i.initializeLogs?this._logger.error("Could not load logs script",t):(e.logs.initializeLogs(this._instance),this._isLoaded=!0)})):this._logger.error(ae)}else this._logger.error("PostHog Extensions not found.")}}_createHost(e,t){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===De.LogsQueue?e():void 0,setPersistedProperty(e,i){var r;e===De.LogsQueue&&t(null!==(r=i)&&void 0!==r?r:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>s.LIB_NAME,getLibraryVersion:()=>s.LIB_VERSION}}_sendLogsBatch(e){return new Promise((t=>{if(fn(this._consecutiveStatusZeroFailures,3))t({kind:"fatal",error:Rl(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout((()=>{this._logger.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Rl(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this._logsUrl(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;if(this._trackEndpointReachability(t),t>=200&&300>t)r({kind:"ok"});else if(413===t)r({kind:"too-large"});else if(0!==t&&429!==t&&500>t)r({kind:"fatal",error:new Error("logs request failed with status "+t)});else{var i;0===t?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Rl(e.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}}))}_trackEndpointReachability(e){(0!==e||this._instance.__loaded)&&(this._consecutiveStatusZeroFailures=mn(e,this._consecutiveStatusZeroFailures,3,(()=>this._logger.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."))))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,s.LIB_NAME,(e=>{this._queue=e})),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,Fl,(e=>{this._consoleQueue=e}))}_drainQueueViaTransport(e,t,i,r,n){if(0!==t.length){var o=t.map((e=>e.record));n([]);var a=Ui(o,ji(i,s.LIB_NAME,s.LIB_VERSION),r,s.LIB_VERSION);this._instance._send_request({method:"POST",url:this._logsUrl(),data:a,compression:"best-available",batchKey:"logs",transport:e})}}_logsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_getSdkContext(){var e,t={};if(t.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;t.sessionId=i.sessionId,t.windowId=r,dt(s)||(t.sessionStartTimestamp=s),dt(n)||(t.lastActivityTimestamp=n)}if(null!=Re&&null!=(e=Re.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Li(Re.location.href):Re.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},Wl={metrics:class{constructor(e){this._logger=Ar("[metrics]"),this._instance=e}initialize(){}_getCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.metrics;return this._core&&this._resolvedFrom===i||(null==(t=this._core)||t.reset(),this._resolvedFrom=i,this._core=new Qi(this._createHost(),function(e){var t,i,r,s,n,o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(s=null==e?void 0:e.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this._logger)),this._core}count(e,t,i){void 0===t&&(t=1),this._getCore().count(e,t,i)}gauge(e,t,i){this._getCore().gauge(e,t,i)}histogram(e,t,i){this._getCore().histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){var t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch((e=>this._logger.error("PostHog metrics flush failed:",e)))}reset(){var e;null==(e=this._core)||e.reset()}_createHost(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>s.LIB_NAME,getLibraryVersion:()=>s.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise((r=>{var s=!1,n=e=>{s||(s=!0,clearTimeout(o),r(e))},o=setTimeout((()=>n({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(i({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error("metrics request failed with status "+t)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("metrics request failed with status "+t)})}}}))}))}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Vl=i({},Ll,Ml,$l,Ol,Dl,Bl,Nl,ql,zl,Hl,jl,Ul,Wl);Ba.__defaultExtensionClasses=i({},Vl),function(){s.SDK_DIST_CHANNEL="cdn";var e=Re.posthog;if(!e||rt(e._i)){var t=Ea[Aa]=new Ba;if(e){var i=[];Mr(e._i,(function(r){if(r&&rt(r)){var s=t.init(r[0],r[1],r[2]),n=e[r[2]]||e;s.__loaded&&-1===i.indexOf(n)&&(i.push(n),s._execute_array.call(s.people,n.people),s._execute_array(n))}}))}t.__SV=1,Re.posthog=t,function(){function e(){e.done||(e.done=!0,La=!1,Mr(Ea,(function(e){e._dom_loaded()})))}null!=Se&&Se.addEventListener?"complete"===Se.readyState?e():Hr(Se,"DOMContentLoaded",e,{capture:!1}):ye&&Rr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}}()}();
1
+ !function(){"use strict";function e(e,t,i,r,s,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s={DEBUG:!1,LIB_VERSION:"0.3.1",LIB_NAME:"browser-common"};s.DEBUG=!1,s.LIB_VERSION="1.412.1",s.LIB_NAME="web";var n="$people_distinct_id",o="$device_id",a="$device_model",l="__alias",u="__timers",c="$autocapture_disabled_server_side",d="$heatmaps_enabled_server_side",h="$exception_capture_enabled_server_side",_="$error_tracking_suppression_rules",p="$error_tracking_capture_extension_exceptions",g="$web_vitals_enabled_server_side",v="$dead_clicks_enabled_server_side",f="$product_tours_enabled_server_side",m="$web_vitals_allowed_metrics",y="$session_recording_remote_config",b="$replay_sample_rate",w="$replay_override_sampling",S="$replay_override_linked_flag",x="$replay_override_url_trigger",E="$replay_override_event_trigger",k="$sesid",P="$session_is_sampled",C="$enabled_feature_flags",I="$active_feature_flags",F="$early_access_features",T="$feature_flag_details",R="$feature_flag_payloads",A="$feature_flag_request_id",L="$minimal_flag_called_events",M="$override_feature_flags",O="$override_feature_flag_payloads",D="$stored_person_properties",B="$stored_group_properties",q="$surveys",N="$surveys_loaded_at",z="$surveys_activated",H="$surveys_activated_session",j="$surveys_activated_timestamps",U="ph_product_tours",W="$flag_call_reported",V="$flag_call_reported_session_id",G="$feature_flag_errors",K="$feature_flag_evaluated_at",Q="$user_state",J="$client_session_props",Y="$capture_rate_limit",Z="$initial_campaign_params",X="$initial_referrer_info",ee="$initial_person_info",te="$epp",ie="$posthog_cookieless",re="$cookieless_mode",se="$sdk_debug_extensions_init_method",ne="$sdk_debug_extensions_init_time_ms",oe="$sdk_debug_recording_script_not_loaded",ae="PostHog loadExternalDependency extension not found.",le="on_reject",ue="always",ce="anonymous",de="identified",he="identified_only",_e="visibilitychange",pe="beforeunload",ge="$pageview",ve="$pageleave",fe="$identify",me="$groupidentify",ye="undefined"!=typeof window?window:void 0,be="undefined"!=typeof globalThis?globalThis:ye,we=null==be?void 0:be.navigator,Se=null==be?void 0:be.document,xe=null==be?void 0:be.location,Ee=null==be?void 0:be.fetch,ke=null!=be&&be.XMLHttpRequest&&"withCredentials"in new be.XMLHttpRequest?be.XMLHttpRequest:void 0,Pe=null==be?void 0:be.AbortController,Ce=null==be?void 0:be.CompressionStream,Ie=null==we?void 0:we.userAgent;function Fe(){return!(!ye||!1===ye.navigator.onLine)}var Te="undefined"!=typeof globalThis?globalThis:ye;Te&&"undefined"==typeof self&&(Te.self=Te),Te&&"undefined"==typeof File&&(Te.File=function(){});var Re=null!=ye?ye:{},Ae=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Le(e){return"string"==typeof e||e}function Me(e){return"string"==typeof e?e:void 0}var $e,Oe=["$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"],De=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),Be=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),qe=["$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"],Ne=["token"],ze="NativeGzipValidationError",He=e=>e.length>=2&&31===e[0]&&139===e[1],je=(e,t)=>e===Be.GZipJS||t===Be.GZipJS||"gzip"===t,Ue=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),We=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=ze,t},Ve=function(){var e=t((function*(e,t){18>e.size&&We("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());He(i)&&8===i[2]||We("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if($e)return $e;$e=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;$e[e]=t>>>0}return $e})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&We("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&We("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function Ge(){return Ge=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=(new TextEncoder).encode(e),n=new globalThis.CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(s).then((()=>o.close())).catch(function(){var e=t((function*(e){try{yield o.abort(e)}catch(e){}throw e}));return function(t){return e.apply(this,arguments)}}()),l=new Response(n.readable).blob(),u=(yield Promise.all([l,a]))[0];return yield Ve(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),Ge.apply(this,arguments)}var Ke=["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"],Qe=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ke.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function Je(e,t){return-1!==e.indexOf(t)}var Ye=function(e){return e.trim()},Ze=function(e){return e.replace(/^\$/,"")};function Xe(e){var t,i=[];return null!==(t=JSON.stringify(e,(function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}})))&&void 0!==t?t:"null"}var et=Object.prototype,tt=et.hasOwnProperty,it=et.toString,rt=Array.isArray||function(e){return"[object Array]"===it.call(e)},st=e=>"function"==typeof e,nt=e=>e===Object(e)&&!rt(e),ot=e=>{if(nt(e)){for(var t in e)if(tt.call(e,t))return!1;return!0}return!1},at=e=>void 0===e,lt=e=>"[object String]"==it.call(e),ut=e=>lt(e)&&0===e.trim().length,ct=e=>null===e,dt=e=>at(e)||ct(e),ht=e=>"[object Number]"==it.call(e)&&e==e,_t=e=>ht(e)&&e>0,pt=e=>"[object Boolean]"===it.call(e),gt=e=>e instanceof FormData,vt=e=>Je(qe,e),ft=e=>Je(Ne,e);function mt(e){return null===e||"object"!=typeof e}function yt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function bt(e){return"undefined"!=typeof Event&&wt(e,Event)}function wt(e,t){try{return e instanceof t}catch(e){return!1}}var St=[!0,"true",1,"1","yes"],xt=e=>Je(St,e),Et=[!1,"false",0,"0","no"];function kt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),ht(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),kt(s||i,t,i,r))}class Pt{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=kt(e.bucketSize,0,100,e._logger),this._refillRate=kt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=kt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),s=this._buckets[r];return s?this._applyRefill(s,i):this._buckets[r]=s={tokens:this._bucketSize,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}}var Ct="Mobile",It="iOS",Ft="Android",Tt="Tablet",Rt=Ft+" "+Tt,At="iPad",Lt="Apple",Mt=Lt+" Watch",$t="Safari",Ot="BlackBerry",Dt="Samsung",Bt=Dt+"Browser",qt=Dt+" Internet",Nt="Chrome",zt=Nt+" OS",Ht=Nt+" "+It,jt="Internet Explorer",Ut=jt+" "+Ct,Wt="Opera",Vt=Wt+" Mini",Gt="Edge",Kt="Microsoft "+Gt,Qt="Firefox",Jt=Qt+" "+It,Yt="Nintendo",Zt="PlayStation",Xt="Xbox",ei=Ft+" "+Ct,ti=Ct+" "+$t,ii="Windows",ri=ii+" Phone",si="Nokia",ni="Ouya",oi="Generic",ai=oi+" "+Ct.toLowerCase(),li=oi+" "+Tt.toLowerCase(),ui="Konqueror",ci="Oculus Browser",di="Vivaldi",hi="Yandex",_i="Whale",pi="DuckDuckGo",gi="Pale Moon",vi="Waterfox",fi="Brave",mi="Google Search App",yi="(\\d+(\\.\\d+)?)",bi=new RegExp("Version/"+yi),wi=new RegExp(Xt,"i"),Si=new RegExp(Zt+" \\w+","i"),xi=new RegExp(Yt+" \\w+","i"),Ei=new RegExp(Ot+"|PlayBook|BB10","i"),ki={"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"},Pi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?fi:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&Je(e,"GSA/")?mi:Je(e," OPR/")&&Je(e,"Mini")?Vt:Je(e," OPR/")?Wt:Ei.test(e)?Ot:Je(e,"IE"+Ct)||Je(e,"WPDesktop")?Ut:Je(e,"OculusBrowser")?ci:Je(e,Bt)?qt:Je(e,Gt)||Je(e,"Edg/")?Kt:Je(e,di+"/")?di:Je(e,"YaBrowser/")?hi:Je(e,_i+"/")?_i:Je(e,pi+"/")||Je(e,"Ddg/")?pi:Je(e,"FBIOS")?"Facebook "+Ct:Je(e,"UCWEB")||Je(e,"UCBrowser")?"UC Browser":Je(e,"CriOS")?Ht:Je(e,"CrMo")||Je(e,Nt)?Nt:Je(e,Ft)&&Je(e,$t)?ei:Je(e,"FxiOS")?Jt:Je(e.toLowerCase(),ui.toLowerCase())?ui:Je(e,fi+"/")?fi:((e,t)=>t&&Je(t,Lt)||function(e){return Je(e,$t)&&!Je(e,Nt)&&!Je(e,Ft)}(e))(e,t)?Je(e,Ct)?ti:$t:Je(e,"PaleMoon/")?gi:Je(e,vi+"/")?vi:Je(e,Qt)?Qt:Je(e,"MSIE")||Je(e,"Trident/")?jt:Je(e,"Gecko")?Qt:"")},Ci={[Ut]:[new RegExp("rv:"+yi)],[Kt]:[new RegExp(Gt+"?\\/"+yi)],[Nt]:[new RegExp("("+Nt+"|CrMo)\\/"+yi)],[Ht]:[new RegExp("CriOS\\/"+yi)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+yi)],[$t]:[bi],[ti]:[bi],[Wt]:[new RegExp("(Opera|OPR)\\/"+yi)],[Qt]:[new RegExp(Qt+"\\/"+yi)],[Jt]:[new RegExp("FxiOS\\/"+yi)],[ui]:[new RegExp("Konqueror[:/]?"+yi,"i")],[Ot]:[new RegExp(Ot+" "+yi),bi],[ei]:[new RegExp("android\\s"+yi,"i")],[qt]:[new RegExp(Bt+"\\/"+yi)],[ci]:[new RegExp("OculusBrowser\\/"+yi)],[di]:[new RegExp(di+"\\/"+yi)],[hi]:[new RegExp("YaBrowser\\/"+yi)],[_i]:[new RegExp(_i+"\\/"+yi)],[fi]:[new RegExp(fi+"\\/"+yi)],[pi]:[new RegExp("(DuckDuckGo|Ddg)\\/"+yi)],[gi]:[new RegExp("PaleMoon\\/"+yi)],[vi]:[new RegExp(vi+"\\/"+yi)],[mi]:[new RegExp("GSA\\/"+yi)],[jt]:[new RegExp("(rv:|MSIE )"+yi)],Mozilla:[new RegExp("rv:"+yi)]},Ii=function(e,t,i,r){var s=Pi(e,t,i,r),n=Ci[s];if(at(n))return null;for(var o=0;n.length>o;o++){var a=e.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},Fi=[[new RegExp(Xt+"; "+Xt+" (.*?)[);]","i"),e=>[Xt,e&&e[1]||""]],[new RegExp(Yt,"i"),[Yt,""]],[new RegExp(Zt,"i"),[Zt,""]],[Ei,[Ot,""]],[new RegExp(ii,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ri,""];if(new RegExp(Ct).test(t)&&!/IEMobile\b/.test(t))return[ii+" "+Ct,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=ki[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[ii,r]}return[ii,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[It,[e[3],e[4],e[5]||"0"].join(".")]:[It,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=at(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Ft+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ft+")","i"),e=>e&&e[2]?[Ft,[e[2],e[3],e[4]||"0"].join(".")]:[Ft,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[zt,""]],[/Linux|debian/i,["Linux",""]]],Ti=function(e){return xi.test(e)?Yt:Si.test(e)?Zt:wi.test(e)?Xt:new RegExp(ni,"i").test(e)?ni:new RegExp("("+ri+"|WPDesktop)","i").test(e)?ri:/iPad/.test(e)?At:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Mt:Ei.test(e)?Ot:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(si,"i").test(e)?si:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Ct).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Ft:Rt:new RegExp("(pda|"+Ct+")","i").test(e)?ai:new RegExp(Tt,"i").test(e)&&!new RegExp(Tt+" pc","i").test(e)?li:""},Ri=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ai(e,t){return"string"==typeof(i=e)&&Ri.test(i)?e:t();var i}function Li(e){return e?e.split("#")[0]:e}function Mi(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function $i(e,t,i){return Oi.apply(this,arguments)}function Oi(){return(Oi=t((function*(e,t,i){var r;try{return yield Promise.race([e,new Promise(((e,s)=>{r=Mi((()=>{try{null==i||i(),e()}catch(e){s(e)}}),t)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Di=e=>e instanceof Error,Bi={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}},qi=Bi.info;function Ni(e){if(pt(e))return{boolValue:e};if("number"==typeof e)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if("string"==typeof e)return{stringValue:e};if(rt(e))return{arrayValue:{values:e.map((e=>Ni(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function zi(e){var t=[];for(var i in e){var r=e[i];ct(r)||at(r)||t.push({key:i,value:Ni(r)})}return t}function Hi(e,t){var r=Bi[e.level||"info"]||qi,s=r.text,n=r.number,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.windowId&&(a["window.id"]=t.windowId),dt(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),dt(t.lastActivityTimestamp)||(a.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=i({},a,e.attributes||{}),u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:s,body:{stringValue:e.body},attributes:zi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),at(e.trace_flags)||(u.flags=e.trace_flags),u}function ji(e,t,r){return i({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":r})}function Ui(e,t,i,r){return{resourceLogs:[{resource:{attributes:zi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let Wi=class{constructor(e,t,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=e,this._config=t,this._logger=i,this._getContext=r,this._onReady=s,this._waitForStoragePersist=n,this._scopeName=o,this._flushPromise=null,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}reset(){this._clearFlushTimer(),this._flushPromise=null,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushInBackground()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=e&&e.body){var t=this._runBeforeSend(e);if(null!==t)if(t.body){if(this._checkRateLimit()){var i={record:Hi(t,this._getContext())};this._onReady((()=>this._enqueue(i)))}}else this._logger.info("Log was rejected in beforeSend function")}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=rt(t)?t:[t],r=e;for(var s of i)try{var n=s(r);if(!n)return this._logger.info("Log was rejected in beforeSend function"),null;r=n}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return r}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;var e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||(this._logger.warn("captureLog dropping logs: exceeded "+this._maxLogsPerInterval+" logs per "+this._rateCapWindowMs+"ms"),this._droppedWarned=!0),!1)}flush(){var e=this;return t((function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally((()=>{e._flushPromise=null}))),e._flushPromise}))()}_flushInner(){var e=this;return t((function*(){var t;e._clearFlushTimer();var i=null!==(t=e._instance.getPersistedProperty(De.LogsQueue))&&void 0!==t?t:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,o;e._evictedSinceAdvance=0;var a=Math.min(i.length,e._maxBatchRecordsPerPost),l=i.slice(0,a),u=Ui(l.map((e=>e.record)),e._buildResourceAttributes(),null!==(n=e._scopeName)&&void 0!==n?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(u);if("too-large"===c.kind&&l.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(l.length/2)),e._logger.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+e._maxBatchRecordsPerPost);else{if("retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.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"===c.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(l.length),i=null!==(o=e._instance.getPersistedProperty(De.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===c.kind)throw c.error}}}))()}_persistQueueAdvance(e){var i=this;return t((function*(){var t,r=Math.max(0,e-i._evictedSinceAdvance),s=null!==(t=i._instance.getPersistedProperty(De.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(De.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return ji(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(De.LogsQueue))&&void 0!==t?t:[];this._maxQueueSize>i.length||(i.shift(),this._evictedSinceAdvance++,this._logger.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(De.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Mi((()=>{this._flushTimer=void 0,this._flushInBackground()}),e))}_nextFlushDelay(){var e=Math.min(Math.max(0,this._consecutiveFlushFailures-1),6);return this._flushIntervalMs*Math.pow(2,e)}_hasQueuedRecords(){var e=this._instance.getPersistedProperty(De.LogsQueue);return!!e&&e.length>0}shutdown(e){var i=this;return t((function*(){i._clearFlushTimer();var t=i.flush().catch((()=>{}));void 0!==e?yield $i(t,e):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=i.flush();yield $i(t,e,(()=>{t.catch((()=>{}))}))}))()}_flushInBackground(){this.flush().then((()=>{this._consecutiveFlushFailures=0}),(e=>{this._consecutiveFlushFailures++,this._logger.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._armFlushTimer(this._nextFlushDelay())}))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}};var Vi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Gi(e){return String(e)+"000000"}function Ki(e,t,i,r){var s="";return r&&(s=Object.keys(r).sort().map((e=>JSON.stringify(e)+":"+JSON.stringify(r[e]))).join(",")),e+"\0"+t+"\0"+(null!=i?i:"")+"\0"+s}let Qi=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._generation=0}count(e,t,i){void 0===t&&(t=1),this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var e=this,i=this._flushPromise,r=function(){var r=t((function*(){i&&(yield i.catch((()=>{}))),yield e._doFlush()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this._flushPromise===s&&(this._flushPromise=null)}));return this._flushPromise=s,s}drainWindow(){if(0===this._series.size)return null;var e=this._series;return this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._buildPayload(e)}reset(){this._generation++,this._clearFlushTimer(),this._series=new Map,this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set}_capture(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this._runBeforeSend(e);if(null!==t)if(t.name&&"string"==typeof t.name)if("number"==typeof t.value&&Number.isFinite(t.value))if("count"===t.type&&0>t.value)this._logger.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=t.attributes?i({},t.attributes):void 0,s=Ki(t.type,t.name,t.unit,r)}catch(e){return void this._logger.warn("Dropping metric '"+t.name+"': attributes could not be serialized",e)}var n=this._series.get(s);if(!n){if(!this._admitNewSeries())return;n={name:t.name,type:t.type,unit:t.unit,attributes:r,windowStartMs:Date.now()},this._series.set(s,n)}var o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn("Metric name '"+t.name+"' is already used as a "+o+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this._fold(n,t.value),this._armFlushTimer()}else this._logger.warn("Dropping metric '"+t.name+"': value must be a finite number");else this._logger.warn("Dropping metric with empty name")}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn("Metric series cap reached ("+this._config.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}_fold(e,t){var i;switch(e.type){case"count":e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(Vi.length+1).fill(0)});var r=e.hist;r.count+=1,r.sum+=t,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t),r.bucketCounts[function(e,t){for(var i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,Vi)]+=1}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=rt(t)?t:[t],r=e;for(var s of i)try{var n=s(r);if(!n)return this._logger.info("Metric was rejected in beforeSend function"),null;r=n}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return r}_armFlushTimer(){this._flushTimer||(this._flushTimer=Mi((()=>{this._flushTimer=void 0,this.flush().catch((e=>{this._logger.error("Metrics flush failed:",e)}))}),this._config.flushIntervalMs))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_doFlush(){var e=this;return t((function*(){if(0!==e._series.size){var t=e._series;e._series=new Map,e._seriesCapWarned=!1,e._typeByName=new Map,e._typeCollisionWarned=new Set;var i=e._generation,r=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(r.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._armFlushTimer();case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",r.error)}}}))()}_buildPayload(e){return t=this._buildMetrics(e),r=function(e,t,r){return i({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":r})}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:zi(r)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,r,s,n}_buildMetrics(e){var t=Gi(Date.now()),r=new Map;for(var s of e.values()){var n,o=Ki(s.type,s.name,s.unit,void 0),a=r.get(o);a||(a=i({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},r.set(o,a));var l=zi(null!==(n=s.attributes)&&void 0!==n?n:{}),u=Gi(s.windowStartMs);if("count"===s.type){var c,d={attributes:l,startTimeUnixNano:u,timeUnixNano:t,asDouble:null!==(c=s.total)&&void 0!==c?c:0};a.sum.dataPoints.push(d)}else if("gauge"===s.type){var h,_={attributes:l,timeUnixNano:t,asDouble:null!==(h=s.last)&&void 0!==h?h:0};a.gauge.dataPoints.push(_)}else s.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:t,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Vi})}return Array.from(r.values())}_mergeWindowBack(e){var t,i;for(var r of e){var s=r[0],n=r[1],o=this._series.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(t=o.total)&&void 0!==t?t: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._admitNewSeries()&&this._series.set(s,n)}}};var Ji,Yi,Zi;function Xi(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Zi&&i.length===Yi||(Yi=i.length,Zi=i.reduce(((i,r)=>{Ji||(Ji={});var s=Ji[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,Ji[r]=[l,u];break}}return i}),{})),Zi}}class er{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&rt(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var i=this;return t((function*(){var t=e;for(var r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,o={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Xi(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}var tr="?";function ir(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?tr:i,in_app:!0};return at(r)||(n.lineno=r),at(s)||(n.colno=s),n}var rr=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:tr,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},sr=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nr=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,or=/\((\S*)(?::(\d+))(?::(\d+))\)/,ar=(e,t)=>{var i=sr.exec(e);if(i)return ir(t,i[1],tr,+i[2],+i[3]);var r=nr.exec(e);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=or.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=rr(r[1]||tr,r[2]);return ir(t,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},lr=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ur=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,cr=(e,t)=>{var i=lr.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ur.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]||tr,o=rr(n,s);return ir(t,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},dr=/\(error: (.*)\)/;class hr{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=lt(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return yt(e,"DOMException")}isDOMError(e){return yt(e,"DOMError")}}class _r{match(e){return function(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return wt(e,Error)}}(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class pr{constructor(){}match(e){return!!yt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var r;if(null!=e.error)return t.apply(e.error);var s=t.apply(e.message);return i({},s,{stack:null!==(r=this._buildLocationStack(e))&&void 0!==r?r:s.stack,synthetic:!0})}_hasUsableMessage(e){return lt(e.message)&&e.message.length>0}_buildLocationStack(e){var t=e;if(lt(t.filename)&&t.filename.length>0){var i,r,s=null!==(i=t.lineno)&&void 0!==i?i:0,n=null!==(r=t.colno)&&void 0!==r?r:0;return"Error\n at "+t.filename+":"+s+":"+n}}}var gr=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class vr{match(e){return"string"==typeof e}coerce(e,t){var i,r=this.getInfos(e),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(gr);return r&&(t=r[1],i=r[2]),[t,i]}}var fr=["fatal","error","warning","log","info","debug"];function mr(e,t){void 0===t&&(t=40);var i=Object.keys(e);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(t>=s.length)return r===i.length?s:s.length>t?s.slice(0,t)+"...":s}return""}class yr{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null==(r=t.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return bt(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+mr(e)}isSeverityLevel(e){return lt(e)&&!ut(e)&&fr.indexOf(e)>=0}getStack(e){try{return lt(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:lt(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(Di(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class br{match(e){return bt(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+mr(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class wr{match(e){return mt(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Sr{match(e){return yt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!bt(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return mt(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var xr="$message",Er="$timestamp",kr=new Set([xr,Er]),Pr={enabled:!0,max_bytes:32768};function Cr(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Pr.enabled,max_bytes:Fr(e.max_bytes,Pr.max_bytes)}:i({},Pr)}class Ir{constructor(e){this._entries=[],this._totalBytes=0,this._config=Cr(e)}setConfig(e){this._config=Cr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t;try{t=Xe(e)}catch(e){return}try{var i=JSON.parse(t);if(!nt(i))return;var r=i,s=r[xr],n=r[Er];if(!lt(s)||0===s.trim().length)return;if(!lt(n)&&!ht(n))return;return{step:r,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map((e=>e.step))}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function Fr(e,t){if(!ht(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var Tr=function(e,t){var i=(void 0===t?{}:t).debugEnabled,r={_log(t){if(ye&&(s.DEBUG||ye.POSTHOG_DEBUG||i)&&!at(ye.console)&&ye.console){for(var r=("__rrweb_original__"in ye.console[t]?ye.console[t].__rrweb_original__:ye.console[t]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];r(e,...o)}},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(e){r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Tr(e+" "+t,i)};return r},Rr=Tr("[PostHog.js]"),Ar=Rr.createLogger;function Lr(e,t){rt(e)&&e.forEach(t)}function Mr(e,t){if(!dt(e))if(rt(e))e.forEach(t);else if(gt(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)tt.call(e,i)&&t(e[i],i)}var $r=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(e[n]=s[n]);return e};function Or(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Dr=function(e){try{return e()}catch(e){return}},Br=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){Rr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Rr.critical(e)}}},qr=function(e){var t={};return Mr(e,(function(e,i){(lt(e)&&e.length>0||ht(e))&&(t[i]=e)})),t};var Nr=["herokuapp.com","vercel.app","netlify.app"];function zr(e){var t=null==e?void 0:e.hostname;if(!lt(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Nr)if(i===r)return!1;return!0}function Hr(e,t,i,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==e||e.addEventListener(t,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function jr(e){return"ph_toolbar_internal"===e.name}var Ur=e=>{if(Se){try{for(var t=e+"=",i=Se.cookie.split(";").filter((e=>e.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return ht(e)&&isFinite(e)&&Math.floor(e)===e});class Wr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/256,s[5]=e,s[6]=112|t>>>8,s[7]=t,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 Wr(s)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Wr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Vr{generate(){var e=this.generateOrAbort();if(!at(e))return e;this._timestamp=0;var t=this.generateOrAbort();if(at(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Wr.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new Qr}}var Gr,Kr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ye&&!at(ye.crypto)&&crypto.getRandomValues&&(Kr=e=>crypto.getRandomValues(e));class Qr{nextUint32(){return this._buffer.length>this._cursor||(Kr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}}var Jr=()=>Yr().toString(),Yr=()=>(Gr||(Gr=new Vr)).generate(),Zr="",Xr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var es={_is_supported:()=>!!Se,_error(e){Rr.error("cookieStore error: "+e)},_get:Ur,_parse(e){var t;try{t=JSON.parse(es._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(!Se)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=Se),Zr)return Zr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+Jr();!Zr&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",Zr=n)}return Zr}(e);if(!i){var r=(e=>{var t=e.match(Xr);return t?t[0]:""})(e);r!==i&&Rr.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(Se.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&Rr.warn("cookieStore warning: large cookie, len="+u.length),Se.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=Se&&Se.cookie)try{es._set(e,"",-1,t)}catch(e){return}}},ts=null,is={_is_supported(){if(!ct(ts))return ts;var e=!0;if(at(ye))e=!1;else try{var t="__mplssupport__";is._set(t,"xyz"),'"xyz"'!==is._get(t)&&(e=!1),is._remove(t)}catch(t){e=!1}return e||Rr.error("localStorage unsupported; falling back to cookie store"),ts=e,e},_error(e){Rr.error("localStorage error: "+e)},_get(e){try{return null==ye?void 0:ye.localStorage.getItem(e)}catch(e){is._error(e)}return null},_parse(e){try{return JSON.parse(is._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==ye||ye.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){is._error(e)}return!1},_remove(e){try{null==ye||ye.localStorage.removeItem(e)}catch(e){is._error(e)}}},rs=[o,"distinct_id",k,P,te,ee,Q],ss={},ns={_is_supported:()=>!0,_error(e){Rr.error("memoryStorage error: "+e)},_get:e=>ss[e]||null,_parse:e=>ss[e]||null,_set:(e,t)=>(ss[e]=t,!0),_remove(e){delete ss[e]}},os=null,as={_is_supported(){if(!ct(os))return os;if(os=!0,at(ye))os=!1;else try{var e="__support__";as._set(e,"xyz"),'"xyz"'!==as._get(e)&&(os=!1),as._remove(e)}catch(e){os=!1}return os},_error(e){Rr.error("sessionStorage error: ",e)},_get(e){try{return null==ye?void 0:ye.sessionStorage.getItem(e)}catch(e){as._error(e)}return null},_parse(e){try{return JSON.parse(as._get(e))||null}catch(e){}return null},_set(e,t){try{return null==ye||ye.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){as._error(e)}return!1},_remove(e){try{null==ye||ye.sessionStorage.removeItem(e)}catch(e){as._error(e)}}};class ls{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===ue||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===le}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get _storedConsent(){var e=this._storage._get(this._storageKey);return xt(e)?1:Je(Et,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?is:es;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?es:is;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(xt(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==we?void 0:we.doNotTrack,null==we?void 0:we.msDoNotTrack,Re.doNotTrack].some((e=>xt(e)))}}function us(e,t){var i,r=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!st(r))return t;try{var s=r(t);return lt(s)&&s?s:t}catch(e){return Rr.error("Error in get_current_url, falling back to window.location.href",e),t}}var cs="__POSTHOG_TOOLBAR__",ds=1,hs=3,_s=11;function ps(e){return e instanceof Element&&(e.id===cs||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function gs(e){return!!e&&e.nodeType===ds}function vs(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function fs(e){return!!e&&e.nodeType===hs}function ms(e){return!!e&&e.nodeType===_s&&gs(e.host)}var ys=1e3;function bs(e){return e?Ye(e).split(/\s+/):[]}function ws(e,t){var i=function(e){var t,i=null==ye||null==(t=ye.location)?void 0:t.href;return at(i)?void 0:us(e,i)}(t);return!!(i&&e&&e.some((e=>i.match(e))))}function Ss(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return bs(t)}function xs(e){return dt(e)?null:Ye(e).split(/(\s+)/).filter((e=>Gs(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Es(e){var t="";return Bs(e)&&!qs(e)&&e.childNodes&&e.childNodes.length&&Mr(e.childNodes,(function(e){var i;fs(e)&&e.textContent&&(t+=null!==(i=xs(e.textContent))&&void 0!==i?i:"")})),Ye(t)}function ks(e){var t;return at(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var Ps=["a","button","form","input","select","textarea","label"];function Cs(e,t){if(at(t))return!0;var i,r=function(e){if(t.some((t=>function(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}(e,t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function Is(e){var t=e.parentNode;return!(!t||!gs(t))&&t}var Fs=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ts=["next","previous","prev",">","<"],Rs=[...Ts,"+","-","−","–"],As=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Ls=[".ph-no-rageclick",".ph-no-capture"],Ms=["","text","search","email","password","url","tel","number"];function $s(e,t){if(!ye||Os(e))return!1;var i,r,s,n,o;if(pt(t)?(i=!!t&&Ls,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:Ls,r=null==t?void 0:t.content_ignorelist,s=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(s&&function(e){return!(!e||!gs(e))&&(!!vs(e,"textarea")||(vs(e,"input")?Je(Ms,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var a=Ds(e,!1).targetElementList;return!function(e,t){if(!1===e||at(e))return!1;var i;if(!0===e)i=Ts;else{if(!rt(e))return!1;if(e.length>10)return Rr.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map((e=>e.toLowerCase()))}return t.some((e=>{var t=e.safeText,r=e.ariaLabel;return i.some((e=>As(t,e)||As(r,e)))}))}(r,a.map((e=>{var t;return{safeText:Es(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!Cs(a,i)}var Os=e=>!e||vs(e,"html")||!gs(e),Ds=(e,t)=>{if(!ye||Os(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!vs(s,"body");)if(ms(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Is(s);if(!n)break;if(t||Ps.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=ye.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}catch(e){}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Bs(e){for(var t=new Set,i=0,r=e;r.parentNode&&!vs(r,"body");r=r.parentNode){if(i++>=ys||t.has(r))return!1;t.add(r);var s=Ss(r);if(Je(s,"ph-sensitive")||Je(s,"ph-no-capture"))return!1}if(Je(Ss(e),"ph-include"))return!0;var n=e.type||"";if(lt(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!lt(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 qs(e){return!!(vs(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||vs(e,"select")||vs(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Ns=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}))$"),zs=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Hs=[16,15,14,13],js=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Us=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ws=/[0-9A-Za-z_]/;function Vs(e){for(var t=0,i=!1,r=e.length-1;r>=0;r--){var s=e.charCodeAt(r)-48;i&&(s*=2)>9&&(s-=9),t+=s,i=!i}return t%10==0}function Gs(e,t){if(void 0===t&&(t=!0),dt(e))return!1;if(lt(e)){e=Ye(e);var i=t?Ns.test((e||"").replace(/[- ]/g,"")):function(e){var t;for(zs.lastIndex=0;t=zs.exec(e);){var i=t[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Hs){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(Ns.test(a)&&Vs(a))return!0}}}return!1}(e);if(i)return!1;var r=t?js.test(e):function(e){var t;for(Us.lastIndex=0;t=Us.exec(e);){var i=t[1],r=t[3];if(!(i&&r&&Ws.test(i)&&Ws.test(r)))return!0}return!1}(e);if(r)return!1}return!0}function Ks(e){var t=Es(e);return Gs(t=(t+" "+Qs(e)).trim())?t:""}function Qs(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Mr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Es(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Qs(e)).trim())}catch(e){Rr.error("[AutoCapture]",e)}})),t}function Js(e){return e.replace(/"|\\"/g,'\\"')}function Ys(e){var t=e.attr__class;if(t)return rt(t)?t:bs(t)}var Zs=Ar("[Dead Clicks]"),Xs=()=>!0,en=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),r=e.instance.config.capture_dead_clicks;return pt(r)?r:!!nt(r)||i};class tn{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[v]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Zs.error("failed to load script",t):e()}))}_start(){var e;if(Se){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Re.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=nt(this.instance.config.capture_dead_clicks)?i({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=Re.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(Se),Zs.info("starting...")}}else Zs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Zs.info("stopping..."))}}var rn=Ar("[SegmentIntegration]");var sn="posthog-js";function nn(e,t){var r=void 0===t?{}:t,s=r.organization,n=r.projectId,o=r.prefix,a=r.severityAllowList,l=void 0===a?["error"]:a,u=r.sendExceptionsToPostHog,c=void 0===u||u;return t=>{var r,a,u,d,h;if("*"!==l&&!l.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var _=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=_,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p,g=(null==(r=t.exception)?void 0:r.values)||[],v=g.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),f={$exception_message:(null==(a=g[0])?void 0:a.value)||t.message,$exception_type:null==(u=g[0])?void 0:u.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(h=g[0])?void 0:h.type,$sentry_tags:t.tags};return s&&n&&(f.$sentry_url=(o||"https://sentry.io/organizations/")+s+"/issues/?project="+n+"&query="+t.event_id),c&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class on{constructor(e,t,i,r,s,n){this.name=sn,this.setupOnce=function(o){o(nn(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class an{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Rr.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,r=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==ye?void 0:ye.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$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,c=s.maxContentY;if(!(at(n)||at(o)||at(a)||at(l)||at(u)||at(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?kt(o/n,0,1,Rr):1,h=n>1?kt(a/n,0,1,Rr):1,_=l>1?kt(u/l,0,1,Rr):1,p=l>1?kt(c/l,0,1,Rr):1;r=$r(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var ln=["flags","surveys"],un={[n]:{exposure:"hidden"},[l]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"event"},[d]:{exposure:"hidden"},[h]:{exposure:"event"},[_]:{exposure:"hidden"},[p]:{exposure:"event"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[k]:{exposure:"hidden"},[P]:{exposure:"event"},[b]:{exposure:"event",shouldSkipFromEventProperties:e=>ct(e)},$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"},[C]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!nt(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[I]:{exposure:"event",storageGroup:"flags"},[F]:{exposure:"hidden"},[T]:{exposure:"hidden",storageGroup:"flags"},[R]:{exposure:"event",storageGroup:"flags"},[A]:{exposure:"event",storageGroup:"flags",volatile:!0},[L]:{exposure:"hidden",storageGroup:"flags"},[M]:{exposure:"event"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[B]:{exposure:"hidden"},[q]:{exposure:"hidden",storageGroup:"surveys"},[N]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[z]:{exposure:"event"},[H]:{exposure:"hidden"},[j]:{exposure:"hidden"},[U]:{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"},[W]:{exposure:"hidden"},[V]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Q]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[X]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[te]:{exposure:"hidden"},[w]:{exposure:"event"},[S]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[se]:{exposure:"event"},[ne]:{exposure:"event"},[oe]:{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"}},cn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],dn=e=>{var t=un[e];if(t)return t;for(var i of cn){var r=i[1];if(0===e.indexOf(i[0]))return r}},hn=(e,t)=>{try{return JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t)}catch(t){return Xe(e)}},_n=e=>{var t=null==Se?void 0:Se.createElement("a");return at(t)?null:(t.href=e,t)},pn=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!rt(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Rr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},gn=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");rt(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var h=a;return null!=o&&(h+="?"+u.join("&")),null!=s&&(h+="#"+s),h},vn=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},fn=(e,t)=>e>=t&&Fe(),mn=(e,t,i,r)=>{if(0===e){if(Fe()){var s=t+1;return s===i&&r(),s}return t}return 0},yn="https?://(.*)",bn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],wn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...bn],Sn="<masked>",xn=["li_fat_id"];function En(e,t,i){if(!Se)return{};var r,s=t?[...bn,...i||[]]:[],n=kn(gn(Se.URL,s,Sn),e),o=(r={},Mr(xn,(function(e){var t=Ur(e);r[e]=t||null})),r);return $r(o,n)}function kn(e,t){var i=wn.concat(t||[]),r={};return Mr(i,(function(t){var i=pn(e,t);r[t]=i||null})),r}function Pn(e){var t=function(e){return e?0===e.search(yn+"google.([^/?]*)")?"google":0===e.search(yn+"bing.com")?"bing":0===e.search(yn+"yahoo.com")?"yahoo":0===e.search(yn+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!ct(t)){r.$search_engine=t;var s=Se?pn(Se.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function Cn(){return navigator.language||navigator.userLanguage}var In="$direct";function Fn(){return(null==Se?void 0:Se.referrer)||In}function Tn(e,t,i){void 0===i&&(i=!1);var r=e?[...bn,...t||[]]:[],s=i?Li(null==xe?void 0:xe.href):null==xe?void 0:xe.href,n=null==s?void 0:s.substring(0,1e3);return{r:Fn().substring(0,1e3),u:n?gn(n,r,Sn):void 0}}function Rn(e,t){var i;void 0===t&&(t=!1);var r=e.r,s=e.u,n=t?Li(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==In?In:null==(i=_n(r))?void 0:i.host};if(n){o.$current_url=n;var a=_n(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=kn(n);$r(o,l)}if(r){var u=Pn(r);$r(o,u)}return o}function An(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Ln(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var Mn={flags:K,surveys:N},$n=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],On="main";class Dn{constructor(e,t,r){if(void 0===r&&(r=!0),this._slotState={},this._splitStorageEligible=!1,this._splitStorage=!1,this._config=e,this._ownsSplitStorage=r,this.props={},this._campaign_params_url=void 0,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),e.debug&&Rr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),ye){var s=()=>this.flush();Hr(ye,"beforeunload",s,{capture:!1}),Hr(ye,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return ht(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===$n.indexOf(e.persistence.toLowerCase())&&(Rr.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,r=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var r=[...rs,...e];return i({},is,{_parse(e){try{var i={};try{i=es._parse(e)||{}}catch(e){}var r,s=JSON.parse(is._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];ct(a)||""===a||(n[o]=a)}r=$r(s,n)}else r=$r(i,s);return is._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=is._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&es._set(e,l,i,s,n,o)}catch(e){is._error(e)}return a},_remove(e,t){try{null==ye||ye.localStorage.removeItem(e),es._remove(e,t)}catch(e){is._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&is._is_supported()?(t=is,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&as._is_supported()?t=as:"memory"===n?t=ns:"cookie"===n?t=es:r._is_supported()?(t=r,s=!0):t=es,this._splitStorageEligible=s,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}_isFeatureFlagCacheStale(e){var t=null!=e?e:this._config.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[K];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return Mr(this.props,((t,i)=>{var r=dn(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===C?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&$r(e,r.transformToEventProperties(t))}else if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,(()=>!1)))return;e[i]=t}})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=$r({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of ln){var t=is._parse(this._groupEntryName(e));if(t&&!ot(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||$r(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=dn(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=Mn[e];if(!i)return!1;var r=t[i],s=this.props[i];return ht(r)&&ht(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=dn(e))?void 0:t.storageGroup:void 0,r=i?is._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(r&&e in r)this._setProp(e,r[e]);else{if(i){var s=this._storage._parse(this._name);if(s&&e in s)return void this._setProp(e,s[e])}this._deleteProp(e)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?at(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){at(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(){this._disabled||(this._splitStorage?this._writeNowSplit():this._writeEntry(this._storage,this._name,this.props,On))}_writeNowSplit(){var e=this._partitionProps(),t=e.main,i=e.groups;for(var r of(this._writeEntry(this._storage,this._name,t,On),ln)){var s,n=i[r];(!ot(n)||null!=(s=this._slotState[r])&&s.persisted)&&this._writeEntry(is,this._groupEntryName(r),n,r)}}_partitionProps(){var e={},t={flags:{},surveys:{}};return Mr(this.props,((i,r)=>{var s,n=null==(s=dn(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===On)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return Mr(e,((e,t)=>{var r;i[t]=null!=(r=dn(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===On||s.dirty||at(s.fingerprint)){var n;try{if((n=this._entryFingerprint(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(e){n=void 0}e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(s.dirty=!1,r!==On&&(s.persisted=!0),at(n)||(s.fingerprint=n)):this._config.debug&&Rr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var t=(void 0===e?{}:e).keepGroupEntries,i=void 0!==t&&t;if(at(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!i&&this._ownsSplitStorage)for(var r of ln)is._remove(this._groupEntryName(r));i?delete this._slotState[On]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(nt(e)){at(t)&&(t="None"),this._expire_days=at(i)?this._default_expiry:i;var r=!1;if(Mr(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(nt(e)){this._expire_days=at(t)?this._default_expiry:t;var i=!1;if(Mr(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this._setProp(r,t),i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(this._deleteProp(e),this.save())}update_campaign_params(){var e=null==Se?void 0:Se.URL;if(e!==this._campaign_params_url){var t=En(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);ot(qr(t))||this.register(t),this._campaign_params_url=e}}update_search_keyword(){var e;this.register((e=null==Se?void 0:Se.referrer)?Pn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Fn(),$referring_domain:null!=Se&&Se.referrer&&(null==(e=_n(Se.referrer))?void 0:e.host)||In},void 0)}set_initial_person_info(){this.props[Z]||this.props[X]||this.register_once({[ee]:Tn(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};Mr([X,Z],(t=>{var i=this.props[t];i&&Mr(i,(function(t,i){e["$initial_"+Ze(i)]=t}))}));var t=this.props[ee];if(t){var i=function(e,t){void 0===t&&(t=!1);var i=Rn(e,t),r={};return Mr(i,(function(e,t){r["$initial_"+Ze(t)]=e})),r}(t,this._config.disable_capture_url_hashes);$r(e,i)}return e}safe_merge(e){return Mr(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var r=e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),s=r?this._buildStorage(e):this._storage,n=this._resolveSplitStorage(e);if(r||n!==this._splitStorage){var o=this.props;this.clear(),this._storage=s,this._splitStorage=n,this.props=o,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props[u]||{};i[e]=t,this._setProp(u,i),this.save()}remove_event_timer(e){var t=this.props[u]||{},i=t[e];return at(i)||(delete t[e],this._setProp(u,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t){var i;this.props[e]=t,null!=(i=dn(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=dn(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}function Bn(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&st(i.then)&&i.then(void 0,(()=>{}))}}}}var qn="gzip-js",Nn="base64",zn="events",Hn="cancelEvents",jn="survey shown",Un="survey dismissed",Wn="survey sent",Vn="popover",Gn=Ar("[RateLimiter]");class Kn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Gn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Gn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(Y))&&void 0!==t?t:{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||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var u=(ht(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this._captureWarning(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(Y,a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){var t=this.instance.config.property_denylist;return!rt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&null!=xe&&xe.pathname)return""+(null!==(e=xe.origin)&&void 0!==e?e:"")+xe.pathname}_captureWarning(e){var t,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null==(t=(i=this.instance).get_session_id)?void 0:t.call(i):void 0,a=[e+" 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(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Qn=Ar("[RemoteConfig]");class Jn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Re._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:e})}load(){try{if(this.remoteConfig)return Qn.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void Qn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Qn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e.json,e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){Qn.error("Error loading remote config",e),this._onRemoteConfig()}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){!this._instance._shouldDisableFlags()&&Se&&"hidden"!==Se.visibilityState&&this._instance.reloadFeatureFlags()}_startRefreshInterval(){var e;if(!this._refreshInterval){var t=null!==(e=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==e?e:3e5;0!==t&&(this._refreshInterval=setInterval((()=>{this.refresh()}),t))}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||Qn.warn("Failed to fetch remote config from PostHog."):Qn.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){Qn.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(e){Qn.error("Error loading feature flags",e)}}}var Yn=Uint8Array,Zn=Uint16Array,Xn=Uint32Array,eo=new Yn([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]),to=new Yn([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]),io=new Yn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ro=function(e,t){for(var i=new Zn(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Xn(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},so=ro(eo,2),no=so[1];so[0][28]=258,no[258]=28;for(var oo=ro(to,0)[1],ao=new Zn(32768),lo=0;32768>lo;++lo){var uo=(43690&lo)>>>1|(21845&lo)<<1;ao[lo]=((65280&(uo=(61680&(uo=(52428&uo)>>>2|(13107&uo)<<2))>>>4|(3855&uo)<<4))>>>8|(255&uo)<<8)>>>1}var co=function(e,t,i){for(var r=e.length,s=0,n=new Zn(t);r>s;++s)++n[e[s]-1];var o,a=new Zn(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Zn(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var u=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,h=d|(1<<c)-1;h>=d;++d)o[ao[d]>>>l]=u}else for(o=new Zn(r),s=0;r>s;++s)o[s]=ao[a[e[s]-1]++]>>>15-e[s];return o},ho=new Yn(288);for(lo=0;144>lo;++lo)ho[lo]=8;for(lo=144;256>lo;++lo)ho[lo]=9;for(lo=256;280>lo;++lo)ho[lo]=7;for(lo=280;288>lo;++lo)ho[lo]=8;var _o=new Yn(32);for(lo=0;32>lo;++lo)_o[lo]=5;var po=co(ho,9,0),go=co(_o,5,0),vo=function(e){return(e/8>>0)+(7&e&&1)},fo=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Zn?Zn:e instanceof Xn?Xn:Yn)(i-t);return r.set(e.subarray(t,i)),r},mo=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},yo=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},bo=function(e,t){for(var i=[],r=0;e.length>r;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new Yn(0),0];if(1==s){var o=new Yn(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(r=1;s>r;++r)n[r].s>h&&(h=n[r].s);var _=new Zn(h+1),p=wo(i[c-1],_,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return _[t.s]-_[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=_[m])break;g+=f-(1<<p-_[m]),_[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>_[y]?g-=1<<t-_[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;_[b]==t&&(--_[b],++g)}p=t}return[new Yn(_),p]},wo=function(e,t,i){return-1==e.s?Math.max(wo(e.l,t,i+1),wo(e.r,t,i+1)):t[e.s]=i},So=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Zn(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++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=e[a]}return[i.subarray(0,r),t]},xo=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},Eo=function(e,t,i){var r=i.length,s=vo(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;r>n;++n)e[s+n+4]=i[n];return 8*(s+4+r)},ko=function(e,t,i,r,s,n,o,a,l,u,c){mo(t,c++,i),++s[256];for(var d=bo(s,15),h=d[0],_=d[1],p=bo(n,15),g=p[0],v=p[1],f=So(h),m=f[0],y=f[1],b=So(g),w=b[0],S=b[1],x=new Zn(19),E=0;m.length>E;++E)x[31&m[E]]++;for(E=0;w.length>E;++E)x[31&w[E]]++;for(var k=bo(x,7),P=k[0],C=k[1],I=19;I>4&&!P[io[I-1]];--I);var F,T,R,A,L=u+5<<3,M=xo(s,ho)+xo(n,_o)+o,O=xo(s,h)+xo(n,g)+o+14+3*I+xo(x,P)+(2*x[16]+3*x[17]+7*x[18]);if(M>=L&&O>=L)return Eo(t,c,e.subarray(l,l+u));if(mo(t,c,1+(M>O)),c+=2,M>O){F=co(h,_,0),T=h,R=co(g,v,0),A=g;var D=co(P,C,0);for(mo(t,c,y-257),mo(t,c+5,S-1),mo(t,c+10,I-4),c+=14,E=0;I>E;++E)mo(t,c+3*E,P[io[E]]);c+=3*I;for(var B=[m,w],q=0;2>q;++q){var N=B[q];for(E=0;N.length>E;++E)mo(t,c,D[z=31&N[E]]),c+=P[z],z>15&&(mo(t,c,N[E]>>>5&127),c+=N[E]>>>12)}}else F=po,T=ho,R=go,A=_o;for(E=0;a>E;++E)if(r[E]>255){var z;yo(t,c,F[257+(z=r[E]>>>18&31)]),c+=T[z+257],z>7&&(mo(t,c,r[E]>>>23&31),c+=eo[z]);var H=31&r[E];yo(t,c,R[H]),c+=A[H],H>3&&(yo(t,c,r[E]>>>5&8191),c+=to[H])}else yo(t,c,F[r[E]]),c+=T[r[E]];return yo(t,c,F[256]),c+T[256]},Po=new Xn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Co=function(){for(var e=new Xn(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Io=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Fo(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,r=0;t.length>r;++r)i=Co[255&i^t[r]]^i>>>8;e=i},d(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n,o,a,l,u=(a=10+((s=t).filename&&s.filename.length+1||0),l=8,function(e,t,i,r,s,n){var o=e.length,a=new Yn(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=Eo(l,u,e.subarray(c,d)):(l[c]=!0,u=Eo(l,u,e.subarray(c,o)))}else{for(var h=Po[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Zn(32768),f=new Zn(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new Xn(25e3),S=new Zn(288),x=new Zn(32),E=0,k=0,P=(c=0,0),C=0,I=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=C){var A=o-c;if((E>7e3||P>24576)&&A>423){u=ko(e,l,0,w,S,x,k,P,I,c-I,u),P=E=k=0,I=c;for(var L=0;286>L;++L)S[L]=0;for(L=0;30>L;++L)x[L]=0}var M=2,O=0,D=p,B=T-R&32767;if(A>2&&F==b(c-B))for(var q=Math.min(_,A)-1,N=Math.min(32767,c),z=Math.min(258,A);N>=B&&--D&&T!=R;){if(e[c+M]==e[c+M-B]){for(var H=0;z>H&&e[c+H]==e[c+H-B];++H);if(H>M){if(M=H,O=B,H>q)break;var j=Math.min(B,H-2),U=0;for(L=0;j>L;++L){var W=c-B+L+32768&32767,V=W-v[W]+32768&32767;V>U&&(U=V,R=W)}}}B+=(T=R)-(R=v[T])+32768&32767}if(O){w[P++]=268435456|no[M]<<18|oo[O];var G=31&no[M],K=31&oo[O];k+=eo[G]+to[K],++S[257+G],++x[K],C=c+M,++E}else w[P++]=e[c],++S[e[c]]}}u=ko(e,l,!0,w,S,x,k,P,I,c-I,u)}return fo(a,0,r+vo(u)+s)}(n=e,null==(o=t).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)),c=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Io(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;i.length>=r;++r)e[r+10]=i.charCodeAt(r)}}(u,t),Io(u,c-8,i.d()),Io(u,c-4,r),u}var To=!!ke||!!Ee,Ro="text/plain",Ao=!1,Lo=(e,t)=>{var i=e.split("#"),r=i[1],s=i[0].split("?"),n=s[0],o=s[1];if(!o)return e;var a=o.split("&").filter((e=>e.split("=")[0]!==t)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},Mo=function(e,t,r){var s;void 0===r&&(r=!0);var n=e.split("?"),o=n[0],a=n[1],l=i({},t),u=null!==(s=null==a?void 0:a.split("&").map((e=>{var t,i=e.split("="),s=i[0],n=r&&null!==(t=l[s])&&void 0!==t?t:i[1];return delete l[s],s+"="+n})))&&void 0!==s?s:[],c=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return Mr(e,(function(e,t){at(e)||at(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)}(l);return c&&u.push(c),u.length>0?o+"?"+u.join("&"):o},$o=e=>{if(e._encodedBody)return e._encodedBody;var t=e.data,i=e.compression;if(t){if(i===qn){var r=Fo(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Yn(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},o=0;i>o;++o){if(s+5>r.length){var a=new Yn(s+8+(i-o<<1));a.set(r),r=a}var l=e.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&e.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 fo(r,0,s)}(hn(t)),{mtime:0});return{contentType:Ro,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Nn){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(hn(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:hn(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=hn(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Oo=e=>{var t,r,s=()=>"sendBeacon"===e.transport?{url:Mo(e.url,{compression:Nn}),encodedBody:$o(i({},e,{compression:Nn,_encodedBody:void 0}))}:{url:Lo(e.url,"compression"),encodedBody:$o(i({},e,{compression:void 0,_encodedBody:void 0}))};try{t=$o(e)}catch(t){if(je(e.compression,pn(e.url,"compression")))return Rr.error("Failed to gzip request body, sending uncompressed payload",t),s();throw t}return t&&je(e.compression,pn(e.url,"compression"))&&!((r=t.body)instanceof ArrayBuffer?He(new Uint8Array(r)):ArrayBuffer.isView(r)&&He(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(Ao=!0,s()):{url:e.url,encodedBody:t}},Do=e=>{try{return Oo(e)}catch(t){return Rr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},Bo=function(){var e=t((function*(e){var t=hn(e.data),r=yield function(e,t,i){return Ge.apply(this,arguments)}(t,s.DEBUG,{rethrow:!0});if(!r)return e;var n=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:Ro,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),qo=/Failed to fetch|NetworkError|Load failed/i,No=e=>{var t=Do(e);if(t){var r=t.url,s=t.encodedBody,n=null!=s?s:{},o=n.contentType,a=n.body,l=n.estimatedSize,u=new Headers;Mr(e.headers,(function(e,t){u.append(t,e)})),o&&u.append("Content-Type",o);var c=null,d=!1;if(Pe){var h=new Pe;c={signal:h.signal,timeout:setTimeout((()=>{var t,i;d=!0,h.abort((t=e.timeout,(i=new Error("PostHog request timed out"+(t?" after "+t+"ms":""))).name="AbortError",i))}),e.timeout)}}var _=t=>{d&&"AbortError"===(null==t?void 0:t.name)||(e=>"TypeError"===(null==e?void 0:e.name)&&qo.test((null==e?void 0:e.message)||""))(t)?Rr.warn(t):Rr.error(t),null==e.callback||e.callback({statusCode:0,error:t})};try{var p;Ee(r,i({method:(null==e?void 0:e.method)||"GET",headers:u,keepalive:"POST"===e.method&&!e._keepaliveDisabled&&52428.8>(l||0),body:a,signal:null==(p=c)?void 0:p.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){Rr.error(e)}null==e.callback||e.callback(r)})))).catch(_).finally((()=>c?clearTimeout(c.timeout):null))}catch(e){c&&clearTimeout(c.timeout),_(e)}}},zo=e=>{try{var t,r=Oo(e),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(we.sendBeacon(s,u))return;var c=rt(e.data)?e.data:null==(t=e.data)?void 0:t.batch;if(rt(c)&&c.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(c.length/2),h=t=>rt(e.data)?t:i({},e.data,{batch:t});return zo(i({},e,{data:h(c.slice(0,d))})),void zo(i({},e,{data:h(c.slice(d))}))}Rr.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),No(i({},e,{_keepaliveDisabled:!0}))}catch(e){Rr.warn("Beacon send failed",e)}},Ho=(e,t,r,s)=>{var n="query"===s?"POST"===t?"sent_at":"_":void 0;return Mo(r===qn?Lo(e,"compression"):e,i({},n?{[n]:Date.now().toString()}:{},r===qn?{}:{compression:r}))},jo=[];Ee&&jo.push({transport:"fetch",method:No}),ke&&jo.push({transport:"XHR",method(e){var t=Do(e);if(t){var i=new ke,r=t.encodedBody;i.open(e.method||"GET",t.url,!0);var s=null!=r?r:{},n=s.contentType,o=s.body;Mr(e.headers,(function(e,t){i.setRequestHeader(t,e)})),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(o)}}}),null!=we&&we.sendBeacon&&jo.push({transport:"sendBeacon",method:zo});var Uo=3e3;class Wo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=kt((null==t?void 0:t.flush_interval_ms)||Uo,250,5e3,Rr.createLogger("flush interval"),Uo),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequestSafely(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[r],s=(new Date).getTime();i.data&&rt(i.data)&&Mr(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequestSafely(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_sendRequestSafely(e){try{this._sendRequest(e)}catch(e){Rr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Mr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;at(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Vo=["retriesPerformedSoFar"];class Go{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!at(ye)&&"onLine"in ye.navigator&&(this._areWeOnline=ye.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Hr(ye,"online",this._onlineListener),Hr(ye,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var t=e.retriesPerformedSoFar,s=r(e,Vo);_t(t)&&(s.url=Mo(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=t?t:0))return void this._enqueue(i({retriesPerformedSoFar:t},s));0===e.statusCode&&Rr.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!=t?t:0)+" retries.")}null==s.callback||s.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),Rr.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>e>i.retryAt||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,at(ye)||(this._onlineListener&&(ye.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(ye.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue)){var t=e.requestOptions;try{this._instance._send_request(i({},t,{transport:"sendBeacon"}))}catch(e){Rr.error(e)}}this._queue=[]}}class Ko{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});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._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Hr(ye,"scroll",this._updateScrollData,{capture:!0}),Hr(ye,"scrollend",this._updateScrollData,{capture:!0}),Hr(ye,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==ye?void 0:ye.document.documentElement;var e=rt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==ye?void 0:ye.document.querySelector(t);if(i)return i}}_scrollPosition(e){var t="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var i=this.scrollElement();return i&&i[t]||0}return ye?"y"===e?ye.scrollY||ye.pageYOffset||ye.document.documentElement.scrollTop||0:ye.scrollX||ye.pageXOffset||ye.document.documentElement.scrollLeft||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}}var Qo=e=>Tn(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes);class Jo{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[J]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Qo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[J]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?Rn(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Mr(qr(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Ze(i)]=t})),e}}class Yo{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var r of this._events["*"]||[])r(e,t)}constructor(){this._events={}}}var Zo=Ar("[SessionId]");class Xo{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._lastPersistedActivityTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Yo,this._sessionHasBeenIdleTooLong=(e,t)=>!(!_t(e)||!_t(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===ue)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Jr,this._windowIdGenerator=i||Jr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*kt(this._config.session_idle_timeout_seconds||1800,60,36e3,Zo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var n=as._parse(this._window_id_storage_key),o=as._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:as._remove(this._window_id_storage_key),as._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.sessionID)try{var a=(e=>{var t=this._config.bootstrap.sessionID.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})();this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),a)}catch(e){Zo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return at(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&as._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&as._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?as._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!ct(t)&&!ct(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var r=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!r||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[k]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return _t(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(k):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!ct(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var t=this._getSessionId();t[1]===this._sessionId&&t[2]===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[k]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var e=this._getSessionId()[0],t=_t(e)?e:0,i=_t(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[k];return rt(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&ye&&(ye.removeEventListener(pe,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&as._remove(this._primary_window_exists_storage_key)},Hr(ye,pe,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===ue)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),r=this._getSessionId(),s=r[1],n=r[2],o=this._freshestActivityTimestamp(),a=this._getWindowId(),l=_t(n)&&Math.abs(i-n)>864e5,u=!1,c=!1,d=!s,h=s,_=!d&&!e&&this._sessionHasBeenIdleTooLong(i,o);if(_){(_=this._isSessionIdleAfterCrossTabRefresh(i))||Zo.info("cross-tab refresh kept the session alive",{sessionId:s});var p=this._getSessionId();s=p[1],n=p[2]}d||_||l?(s=this._sessionIdGenerator(),a=this._windowIdGenerator(),Zo.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:d,activityTimeout:_,sessionPastMaximumLength:l}}),n=i,u=!0):(a||(a=this._windowIdGenerator(),u=!0),(c=s!==h)&&(Zo.info("adopted cross-tab session id",{sessionId:s,windowId:a}),u=!0));var g=_t(o)&&e&&!l?o:i,v=_t(n)?n:(new Date).getTime();this._setWindowId(a),this._setSessionId(s,g,v),e||this._resetIdleTimer();var f={noSessionId:d,activityTimeout:_,sessionPastMaximumLength:l,crossTabAdoption:c};return u&&this._sessionIdChangedHandlers.forEach((e=>e(s,a,f))),{sessionId:s,windowId:a,sessionStartTimestamp:v,changeReason:u?f:void 0,lastActivityTimestamp:o}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()}),1.1*this.sessionTimeoutMs))}}var ea=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Qe(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Qe(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function ta(){return(ta=t((function*(){var e=null==we?void 0:we.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return lt(i)&&i.length>0?i:void 0}catch(e){return void Rr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}))).apply(this,arguments)}var ia=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function ra(e,t,i){return hn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var sa={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>ia(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!ia(t,e))))),icontains:(e,t)=>t.map(na).some((t=>e.map(na).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(na).every((t=>e.map(na).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i<parseFloat(e)))}))},na=e=>e.toLowerCase();function oa(e,t){return!e||Object.entries(e).every((e=>{var i=e[1],r=null==t?void 0:t[e[0]];if(at(r)||ct(r))return!1;var s=[String(r)],n=sa[i.operator];return!!n&&n(i.values,s)}))}var aa="custom",la="i.posthog.com",ua=/^\/static\//;class ca{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+la,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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":aa),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(ua.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return""+i+t}if(this.region===aa)return this.apiHost+t;var r=la+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}function da(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}var ha=Ar("[Surveys]"),_a="seenSurvey_",pa=e=>{try{var t=(e=>((e,t)=>""+e+function(e){return e.current_iteration&&e.current_iteration>0?e.id+"_"+e.current_iteration:e.id}(t))(_a,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){ha.error("Failed to persist survey seen state",e)}},ga=["popover","widget","api"],va={ignoreConditions:!1,ignoreDelay:!1,displayType:Vn},fa=Ar("[PostHog ExternalIntegrations]"),ma={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ya{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return fa.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(){var t,r,s,n=i[0],o=i[1];!o||null!=(t=Re.__PosthogExtensions__)&&null!=(t=t.integrations)&&t[n]||e._loadScript(ma[n],(()=>{var t;null==(t=Re.__PosthogExtensions__)||null==(t=t.integrations)||null==(t=t[n])||t.start(e._instance)})),!o&&null!=(r=Re.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=Re.__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;t()}}}class ba{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var i=this;return t((function*(){if(i._disposed)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i._extensions.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');i._extensions.set(e.name,e);try{var t=e.setup(i._client);t&&(yield t)}catch(t){var r=i._extensions.get(e.name)===e;r&&i._extensions.delete(e.name),i._logger.error('Failed to set up browser extension "'+e.name+'"',t),r&&i._disposeExtension(e)}}))()}dispose(){if(!this._disposed){this._disposed=!0;var e=Array.from(this._extensions.values()).reverse();for(var t of(this._extensions.clear(),e))this._disposeExtension(t)}}_disposeExtension(e){try{var t=null==e.dispose?void 0:e.dispose();t&&st(t.then)&&t.then(void 0,(t=>{this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}))}catch(t){this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}}}class wa{constructor(e){this._instance=e}get(e){var t;return null==(t=this._instance.persistence)?void 0:t.get_property(e)}set(e,t){var i;null==(i=this._instance.persistence)||i.set_property(e,t)}remove(e){var t;null==(t=this._instance.persistence)||t.unregister(e)}}var Sa="extensionsRemoteConfig";class xa{constructor(e){this._disposed=!1,this.instance=e,this._logger=Rr.createLogger("[BrowserExtensions]"),this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new wa(e),this.onEvent=e=>Bn(this.instance.on("eventCaptured",(t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}}))),this.onRemoteConfig=e=>{if(this._disposed)return Bn((()=>{}));var t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(Sa,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),Bn(i)},this._runtime=new ba(this._logger,this)}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property(o))&&void 0!==e?e:this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,r,s=null==(e=this.instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==s?void 0:s.sessionId)&&void 0!==t?t:"",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(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(e){return this._runtime.add(e)}capture(e,i,r){var s=this;return t((function*(){r?s.instance.capture(e,i,{timestamp:r.timestamp,uuid:r.uuid,$set:r.set,$set_once:r.setOnce}):s.instance.capture(e,i)}))()}registerDynamicEventProperties(e){return Bn(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(Sa,e))}sendRequest(e,i){var r=this;return t((function*(){var t;void 0===i&&(i={});var s=r.instance.requestRouter.endpointFor(null!==(t=i.target)&&void 0!==t?t:"api",e),n={method:i.method,url:i.query?Mo(s,i.query):s,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport};return"sendBeacon"===i.transport?(r.instance._send_request(n),{statusCode:202}):new Promise((e=>{n.callback=e,r.instance._send_request(n)}))}))()}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}}var Ea={},ka=0,Pa=()=>{},Ca='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ia="Surveys module not available",Fa="sanitize_properties is deprecated. Use before_send instead",Ta="Invalid value for property_denylist config: ",Ra=["token","distinct_id",re],Aa="posthog",La=!To&&-1===(null==Ie?void 0:Ie.indexOf("MSIE"))&&-1===(null==Ie?void 0:Ie.indexOf("Mozilla")),Ma=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:zr(null==Se?void 0:Se.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Pa,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:xe&&lt(null==xe?void 0:xe.search)&&-1!==xe.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:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==ye||null==(t=ye.location)?void 0:t.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(e){Rr.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:he,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Uo},error_tracking:{},_onCapture:Pa},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Rs,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:e&&e>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:e&&e>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e)}))(e))},$a=[["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"]],Oa=e=>{var t={};for(var i of $a){var r=i[0],s=i[1];at(e[r])||(t[s]=e[r])}var n=$r({},t,e),o=e.__preview_external_dependency_versioned_paths;return at(o)||(at(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),lt(o)&&at(e.asset_host)&&(n.asset_host=o)),rt(e.property_blacklist)&&(at(e.property_denylist)?n.property_denylist=e.property_blacklist:rt(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Rr.error(Ta+e.property_denylist)),n};class Da{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Rr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ba{_replaceExtension(e,t){if(e){var i=this._extensions.indexOf(e);-1!==i&&this._extensions.splice(i,1)}return this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return this.config.cookieless_mode===ue||this.config.cookieless_mode===le&&this.consent.isRejected()}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this.webPerformance=new Da,this._personProcessingSetOncePropertiesSent=!1,this.version=s.LIB_VERSION,this._internalEventEmitter=new Yo,this._extensions=[],this._extensionEventPropertyProducers=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ma(),this.SentryIntegration=on,this.sentryIntegration=e=>function(e,t){var i=nn(e,t);return{name:sn,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new Ko(this),this.pageViewManager=new an(this),this.rateLimiter=new Kn(this),this.requestRouter=new ca(this),this.consent=new ls(this),this.externalIntegrations=new ya(this);var t=null!==(e=Ba.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.metrics=t.metrics&&new t.metrics(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var r=lt(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=lt(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>Rr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Aa){var r,s=null!==(r=Ea[i])&&void 0!==r?r:new Ba;return s._init(e,t,i),Ea[i]=s,Ea[Aa][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var n,o;void 0===t&&(t={});var l,u=lt(e)?e.trim():"";if(!u)return Rr.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 u!==(null==(l=this.config)?void 0:l.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+u+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ma(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var c=Ma(t.defaults),d=Oa(t),h=$r({},c,d,{name:r,token:u});nt(c.rageclick)&&nt(d.rageclick)&&(h.rageclick=$r({},c.rageclick,d.rageclick)),nt(c.session_recording)&&nt(d.session_recording)&&(h.session_recording=$r({},c.session_recording,d.session_recording)),this.set_config(h),this.config.on_xhr_error&&Rr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:qn;var _=this._is_persistence_disabled();this.persistence=new Dn(this.config,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Dn(i({},this.config,{persistence:"sessionStorage"}),_,!1);var p=i({},this.persistence.props),g=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Wo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Go(this),this.__request_queue=[];var v=this._inCookielessMode();if(v||(this.sessionManager=new Xo(this),this.sessionPropsManager=new Jo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(Rr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(v)}),0)):(Rr.info("Initializing extensions synchronously"),this._initExtensions(v)),s.DEBUG=s.DEBUG||this.config.debug,s.DEBUG&&Rr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:p,s:g}),!this.config.identity_distinct_id||null!=(n=t.bootstrap)&&n.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var f=t.bootstrap.distinctID,m=this.get_distinct_id(),y=this.persistence.get_property(Q);if(t.bootstrap.isIdentifiedID&&null!=m&&m!==f&&y===ce)this.identify(f);else if(t.bootstrap.isIdentifiedID&&null!=m&&m!==f&&y===de)Rr.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 b=this.config.get_device_id(Jr()),w=t.bootstrap.isIdentifiedID?b:f;this.persistence.set_property(Q,t.bootstrap.isIdentifiedID?de:ce),this.register({distinct_id:f,$device_id:w})}}if(v)this.register_once({distinct_id:ie,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(Jr());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(Q,ce)}return Hr(ye,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||Jr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(Q,de)),t()},s=i.user();"then"in s&&st(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{"undefined"!=typeof Promise&&Promise.resolve||rn.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(rn.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(rn.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,ge),identify:e=>t(e,fe),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),st(this.config._onCapture)&&this.config._onCapture!==Pa&&(Rr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Rr.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 ta.apply(this,arguments)}().then((e=>{e&&this.register({[a]:e})})).catch(Pa),this}_initExtensions(e){var t,r,s,n,o,a,l,u,c=performance.now(),d=i({},Ba.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new d.featureFlags(this)),d.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new d.exceptions(this)),d.historyAutocapture&&this._extensions.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this._extensions.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this._extensions.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),d.autocapture&&this._extensions.push(this.autocapture=new d.autocapture(this)),d.surveys&&this._extensions.push(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new d.surveys(this)),d.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new d.logs(this)),d.metrics&&this._extensions.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new d.metrics(this)),d.conversations&&this._extensions.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new d.conversations(this)),d.productTours&&this._extensions.push(this.productTours=new d.productTours(this)),d.heatmaps&&this._extensions.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this._extensions.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,en)),d.toolbar&&this._extensions.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new d.toolbar(this)),d.experiments&&this._extensions.push(this.experiments=null!==(u=this.experiments)&&void 0!==u?u:new d.experiments(this)),this._extensions.forEach((e=>{e.initialize&&h.push((()=>{null==e.initialize||e.initialize()}))})),h.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}})),this._processInitTaskQueue(h,c)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this._processInitTaskQueue(e,t)}),0);var i=e.shift();if(i)try{i()}catch(e){Rr.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[se]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ne]:r}),this.config.__preview_deferred_init_extensions&&Rr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!Se||!Se.body)return Rr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var i,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=Je(r.supportedCompression,qn)?qn:Je(r.supportedCompression,Nn)?Nn:void 0),null!=(i=r.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:he}),null==(t=this._browserClientAdapter)||t.handleRemoteConfig(e),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){Rr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=xe&&xe.hostname){var e=xe.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()}),1),this._remoteConfigLoader=new Jn(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&Lr(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,r,s;null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),null==(t=this.metrics)||t.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(ve),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this._requestQueue)||r.unload(),null==(s=this._retryQueue)||s.unload()):this._shouldCapturePageleave()&&this.capture(ve,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?La?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=i({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?this.compression:e.compression,(at(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,r,s,n=i({},e);n.timeout=n.timeout||6e4;var o,a,l,u,c,d=null!==(t=n.transport)&&void 0!==t?t:"fetch";"sendBeacon"===d&&at(n.compression)&&n.data&&(n.compression=Nn),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data={api_key:null!==(a=null==(c=(u=rt(o=n.data)?o:[o])[0])||null==(l=c.properties)?void 0:l.token)&&void 0!==a?a:null==c?void 0:c.token,batch:u,sent_at:(new Date).toISOString()}:"body"===n.timestampMode&&(n.data=function(e,t){return void 0===t&&(t=(new Date).toISOString()),rt(e)?e.map((e=>i({},e,{sent_at:t}))):i({},e,{sent_at:t})}(n.data))),n.url=Ho(n.url,n.method,n.compression,n.timestampMode);var h=jo.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),_=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===d)return e[i]}(h))?void 0:s.method)&&void 0!==r?r:h[0].method;if(!_)throw new Error("No available transport method");"sendBeacon"!==d&&n.data&&n.compression===qn&&Ce&&"undefined"!=typeof Promise&&!Ao?Bo(n).then((e=>{_(e)})).catch((t=>{if(Ue(t))return Ao=!0,void _(i({},n,{compression:void 0,url:Ho(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return Ue(e)||t===ze})(t)&&(Ao=!0),_(n)})):_(n)})(i({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,t),null==e.callback||e.callback(t)}}))):e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:0}))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){ka++;try{var t,i=[],r=[],s=[];Lr(e,(e=>{if(e)if(rt(t=e[0]))s.push(e);else if(st(e))try{e.call(this)}catch(t){Rr.error("Error executing queued PostHog call",e,t)}else rt(e)&&"alias"===t?i.push(e):rt(e)&&-1!==t.indexOf("capture")&&st(this[t])?s.push(e):r.push(e)}));var n=function(e,t){Lr(e,(function(e){try{if(rt(e[0])){var i=t;Mr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){Rr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{ka--}}push(e){if(ka>0&&rt(e)&&lt(e[0])){var t=Ba.prototype[e[0]];st(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l,u,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!at(e)&&lt(e)){var d=!this.config.opt_out_useragent_filter&&this._is_bot();if(!d||this.config.__preview_capture_bot_pageviews){var h=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==h||!h.isRateLimited){if(this._extensionEventPropertyProducers.length>0){var _={};for(var p of this._extensionEventPropertyProducers.slice())try{$r(_,p())}catch(e){Rr.error("Failed to produce browser extension event properties",e)}t=i({},_,null!=t?t:{})}var g;null!=(s=t)&&s.$current_url&&!lt(null==(n=t)?void 0:n.$current_url)&&(Rr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==(g=t)||delete g.$current_url),"$exception"!==e||null!=r&&r._originatedFromCaptureException||Rr.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 v=new Date,f=(null==r?void 0:r.timestamp)||v,m=Ai(null==r?void 0:r.uuid,Jr),y={uuid:m,event:e,properties:this.calculateEventProperties(e,t||{},f,m)};e===ge&&this.config.__preview_capture_bot_pageviews&&d&&(y.event="$bot_pageview",y.properties.$browser_type="bot"),h&&(y.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens);var b="$feature_flag_called"===e&&!1===y.properties.$feature_flag_has_experiment&&!0===this.get_property(L);(null==r?void 0:r.$set)&&!b&&(y.$set=null==r?void 0:r.$set);var w=null==r?void 0:r.$unset;w&&(y.$unset=w);var S,x,E,k=b?void 0:this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==me,e===fe);if(k&&(y.$set_once=k),null!=r&&r._noTruncate||(a=this.config.properties_string_max_length,l=y,u=e=>lt(e)?e.slice(0,a):e,c=new Set,y=function e(t,i){if(t!==Object(t))return u?u(t):t;if(!c.has(t)){var r;if(c.add(t),rt(t))r=[],Lr(t,(t=>{r.push(e(t))}));else{var s={};Mr(t,((t,i)=>{c.has(t)||(s[i]=e(t,i))})),r=s}return r}}(l)),y.timestamp=f,at(null==r?void 0:r.timestamp)||(y.properties.$event_time_override_provided=!0,y.properties.$event_time_override_system_time=v),b&&(y.properties=function(e,t){void 0===t&&(t=[]);var i={},r=t=>{void 0!==e[t]&&(i[t]=e[t])};return Oe.forEach(r),t.forEach(r),i}(y.properties,Ra)),e===Un||e===Wn){var P,C,I=null==(P=t)?void 0:P.$survey_id,F=null==(C=t)?void 0:C.$survey_iteration;pa({id:I,current_iteration:F}),y.$set=i({},y.$set,{[(S={id:I,current_iteration:F},x=e===Wn?"responded":"dismissed",E="$survey_"+x+"/"+S.id,S.current_iteration&&S.current_iteration>0&&(E="$survey_"+x+"/"+S.id+"/"+S.current_iteration),E)]:!0})}else e===jn&&(y.$set=i({},y.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var T,R=null==(T=t)?void 0:T.$product_tour_type;R&&(y.$set=i({},y.$set,{["$product_tour_last_seen_date/"+R]:(new Date).toISOString()}))}var A=i({},y.properties.$set,y.$set);if(ot(A)||this.setPersonPropertiesForFlags(A),!dt(this.config.before_send)){var M=this._runBeforeSend(y);if(!M)return;(y=M).uuid=Ai(y.uuid,Jr)}this._internalEventEmitter.emit("eventCaptured",y);var O=null!==(o=null==r?void 0:r._url)&&void 0!==o?o:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),D={method:"POST",url:O,data:y,compression:"best-available",timestampMode:"recordings"===(null==r?void 0:r._batchKey)||/\/s\/(?:\?|$)/.test(O)?"body":"capture-body",batchKey:null==r?void 0:r._batchKey,transport:null==r?void 0:r.transport};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(D):this._requestQueue.enqueue(D),y}Rr.critical("This capture call is ignored due to client rate limiting.")}}else Rr.error("No event name provided to posthog.capture")}else Rr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new xa(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);var t=!0;return()=>{if(t){t=!1;var i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}}calculateEventProperties(e,t,r,n,o){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l[re]=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!lt(l.distinct_id)&&!ht(l.distinct_id)||ut(l.distinct_id))&&Rr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i,r){var n,o,a,l;if(void 0===r&&(r=!1),!Ie)return{};var u,c=e?[...bn,...t||[]]:[],d=function(e){for(var t=0;Fi.length>t;t++){var i=Fi[t],r=i[1],s=i[0].exec(e),n=s&&(st(r)?r(s,e):r);if(n)return n}return["",""]}(Ie),h=d[0],_=d[1],p=null!=(u="undefined"!=typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},g={};at(i)||(g.detectGoogleSearchApp=i);var v={},f=null==(n=navigator)||null==(n=n.userAgentData)?void 0:n.platform,m=null==(o=navigator)?void 0:o.maxTouchPoints,y=null==ye||null==(a=ye.screen)?void 0:a.width,b=null==ye||null==(l=ye.screen)?void 0:l.height,w=null==ye?void 0:ye.devicePixelRatio;at(f)||(v.userAgentDataPlatform=f),at(m)||(v.maxTouchPoints=m),at(y)||(v.screenWidth=y),at(b)||(v.screenHeight=b),at(w)||(v.devicePixelRatio=w);var S,x,E,k,P,C,I,F,T=$r(qr({$os:h,$os_version:_,$browser:Pi(Ie,navigator.vendor,p,g),$device:Ti(Ie),$device_type:(x=Ie,E=v,F=Ti(x),F===At||F===Rt||"Kobo"===F||"Kindle Fire"===F||F===li?Tt:F===Yt||F===Xt||F===Zt||F===ni?"Console":F===Mt?"Wearable":F?Ct:"Android"===(null==E?void 0:E.userAgentDataPlatform)&&(null!==(k=null==E?void 0:E.maxTouchPoints)&&void 0!==k?k:0)>0?600>Math.min(null!==(P=null==E?void 0:E.screenWidth)&&void 0!==P?P:0,null!==(C=null==E?void 0:E.screenHeight)&&void 0!==C?C:0)/(null!==(I=null==E?void 0:E.devicePixelRatio)&&void 0!==I?I:1)?Ct:Tt:"Desktop"),$timezone:An(),$timezone_offset:Ln()}),{$current_url:gn(r?Li(null==xe?void 0:xe.href):null==xe?void 0:xe.href,c,Sn),$host:null==xe?void 0:xe.host,$pathname:null==xe?void 0:xe.pathname,$raw_user_agent:Ie.length>1e3?Ie.substring(0,997)+"...":Ie,$browser_version:Ii(Ie,navigator.vendor,p,g),$browser_language:Cn(),$browser_language_prefix:(S=Cn(),"string"==typeof S?S.split("-")[0]:void 0),$screen_height:null==ye?void 0:ye.screen.height,$screen_width:null==ye?void 0:ye.screen.width,$viewport_height:null==ye?void 0:ye.innerHeight,$viewport_width:null==ye?void 0:ye.innerWidth,$lib:s.LIB_NAME,$lib_version:s.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return s.SDK_DIST_CHANNEL&&(T.$sdk_dist_channel=s.SDK_DIST_CHANNEL),T}(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 h=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime()),_=h.windowId;l.$session_id=h.sessionId,l.$window_id=_}this.sessionPropsManager&&$r(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&$r(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===aa&&(l.$lib_custom_api_host=this.config.api_host),c=e!==ge||o?e!==ve||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,n),l=$r(l,c),e===ge&&Se&&(l.title=Se.title),!at(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Ie&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var v=this.persistence.properties(),f=this.sessionPersistence.properties();Mr(["$referrer","$referring_domain"],(e=>{e in v&&delete f[e]})),(l=$r({},d,v,f,l)).$is_identified=this._isIdentified(),rt(this.config.property_denylist)?Mr(this.config.property_denylist,(function(e){delete l[e]})):Rr.error(Ta+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(Rr.error(Fa),l=m(l,e));var y=this._hasPersonProcessing();return l.$process_person_profile=y,y&&!o&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var r;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=$r({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(Rr.error(Fa),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),ot(o)?void 0:o}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,r;return null!==(i=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;null==(r=this.featureFlags)||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return void 0===t&&(t=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Ia}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Ia})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Ia})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=va),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Ia}}canRenderSurveyAsync(e,t){var i,r;return void 0===t&&(t=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Ia})}_validateIdentifyId(e){return!e||ut(e)?(Rr.critical("Unique user id has not been set in posthog.identify"),!1):e===ie?(Rr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(Rr.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return Rr.uninitializedWarning("posthog.identify");if(ht(e)&&(e=e.toString(),Rr.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(o)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(Q)||ce)===ce,a=e!==r,u=!a&&n;if(a&&n)this.persistence.set_property(Q,de),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(fe,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=ra(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r);else if(u){this.persistence.set_property(Q,de);var c=t||{},d=i||{};this.setPersonPropertiesForFlags({$set:c,$set_once:d},!1),this.capture("$set",{$set:c,$set_once:d}),this._cachedPersonProperties=ra(e,t,i)}else(t||i)&&this.setPersonProperties(t,i);a?(this.reloadFeatureFlags(),this.unregister(W)):u&&(t||i)&&this.reloadFeatureFlags()}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=ra(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):Rr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(rt(e)?e:[e]).filter((e=>lt(e)&&e.length>0));0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,r){if(e&&t){var s=this.getGroups(),n=s[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),n||r){var o={$group_type:e,$group_key:t};r&&(o.$group_set=r),this.capture(me,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else Rr.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){this._reset(e)}_reset(e,t){var i,r,s,n,l,u,c,d,h,_;if(void 0===t&&(t=!1),Rr.info("reset"),!this.__loaded)return Rr.uninitializedWarning("posthog.reset");var p,g=this.get_property(o),v=this.get_property(a),f=this.get_property(y),m=this.is_capturing();if(this.consent.reset(),t||!m||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==(i=this.persistence)||i.clear(),null==(r=this.sessionPersistence)||r.clear(),at(f)||null==(p=this.persistence)||p.register({[y]:f}),null==(s=this.surveys)||s.reset(),null==(n=this._remoteConfigLoader)||n.stop(),null==(l=this.featureFlags)||l.reset(),null==(u=this.conversations)||u.reset(),null==(c=this.logs)||c.reset(),null==(d=this.metrics)||d.reset(),null==(h=this.persistence)||h.set_property(Q,ce),null==(_=this.sessionManager)||_.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===ue)this.register_once({distinct_id:ie,$device_id:null},"");else{var b=this.config.get_device_id(Jr());this.register_once({distinct_id:b,$device_id:e?b:g},""),e||at(v)||this.register({[a]:v})}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var i=this;return t((function*(){var e,t,r,s,n,o,a;i.__loaded?(null==(e=i._remoteConfigLoader)||e.stop(),null==(t=i._browserClientAdapter)||t.dispose(),null==(r=i.logs)||r.flushLogs("sendBeacon"),null==(s=i.metrics)||s.flush("sendBeacon"),null==(n=i._requestQueue)||n.unload(),null==(o=i._retryQueue)||o.unload(),null==(a=i.featureFlags)||a.destroy()):Rr.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.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(e,t){return e===this.get_property(n)?(Rr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(at(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Rr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(nt(e)){var r,n,o,a,l,u,c,d,h,_,p;$r(this.config,Oa(e));var g=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,g),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Dn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);pt(v)&&(this.config.debug=v),pt(this.config.debug)&&(this.config.debug?(s.DEBUG=!0,is._is_supported()&&is._set("ph_debug",!0),Rr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(s.DEBUG=!1,is._is_supported()&&is._remove("ph_debug"))),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(l=this.tracingHeaders)||l.startIfEnabledOrStop(),null==(u=this.autocapture)||u.startIfEnabled(),null==(c=this.heatmaps)||c.startIfEnabled(),null==(d=this.exceptionObserver)||d.startIfEnabledOrStop(),null==(h=this.deadClicksAutocapture)||h.startIfEnabledOrStop(),null==(_=this.surveys)||_.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(p=this.externalIntegrations)||p.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){s.LIB_NAME=e,s.LIB_VERSION=t}startSessionRecording(e){var t,i,r,s,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.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 e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,t))}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var e,t;return null!==(e=null==(t=this.logs)?void 0:t.logger)&&void 0!==e?e:Ba._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Aa;return t!==Aa&&(t=Aa+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(Q))===de||(null==(t=this.sessionPersistence)?void 0:t.get_property(Q))===de}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===he&&!this._isIdentified()&&ot(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[te]))}_shouldCapturePageleave(){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._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Rr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(te,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==le)}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();return(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==ue){if(this._inCookielessMode()){var i,r,s,n,o;this._reset(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new Xo(this),this.pageViewManager=new an(this),this.persistence&&(this.sessionPropsManager=new Jo(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=Ba.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new l(this)),this._lastRemoteConfig&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this._lastRemoteConfig)))}var u,c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),this.config.cookieless_mode==le&&(null==(u=this.surveys)||u.loadIfEnabled()),(at(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(c=null==e?void 0:e.captureEventName)&&void 0!==c?c:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else Rr.warn(Ca)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==ue?(this.config.cookieless_mode===le&&this.consent.isOptedIn()&&this._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===le&&(this.register({distinct_id:ie,$device_id:null}),null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,null==(t=this.sessionManager)||t.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())):Rr.warn(Ca)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===ue||(this.config.cookieless_mode===le?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return we?ea(we,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Se&&("visible"===Se.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ge,{title:Se.title},{send_instantly:!0}),this._visibilityStateListener&&(Se.removeEventListener(_e,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Hr(Se,_e,this._visibilityStateListener)))}debug(e){!1===e?(null==ye||ye.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==ye||ye.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}))}_shouldDisableFlags(){var e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Rr.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(e,t,i,r,s){var n=t in e&&!dt(e[t]),o=i in e&&!dt(e[i]);return n?e[t]:!!o&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Rr)}_runBeforeSend(e){var t;if(dt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(ft),r=rt(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),dt(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return vt(e.event)?Rr.warn(o+". This can cause unexpected behavior."):Rr.info(o),null}s.properties&&!ot(s.properties)||Rr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&dt(s.properties[a]))return Rr.warn("Event '"+e.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 e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=pt(e)&&!e,i=is._is_supported()&&"true"===is._get("ph_debug");return!t&&(!!i||e)}}Ba.__defaultExtensionClasses={},Ba._noopLogger=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Br(e.prototype[t[i]])}(Ba,["identify"]);class qa{constructor(e){this.disabled=!1===e;var t=nt(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Na="$copy_autocapture",za=Ar("[AutoCapture]");function Ha(e,t){return t.length>e?t.slice(0,e)+"...":t}function ja(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!gs(t));return t}function Ua(e,t){var r,s,n=t.e,o=t.maskAllElementAttributes,a=t.maskAllText,l=t.elementAttributeIgnoreList,u=t.elementsChainAsString,c=t.disableCaptureUrlHashes;if(!gs(e))return{props:{}};for(var d=[e],h=new Set([e]),_=e;_.parentNode&&!vs(_,"body")&&ys>d.length;)if(ms(_.parentNode)){var p=_.parentNode.host;if(h.has(p))break;h.add(p),d.push(p),_=p}else{if(!gs(_.parentNode))break;if(h.has(_.parentNode))break;h.add(_.parentNode),d.push(_.parentNode),_=_.parentNode}var g,v,f=[],m={},y=!1,b=!1;if(Mr(d,(e=>{var t=Bs(e);if(vs(e,"a")){var i=e.getAttribute("href");y=!!(t&&i&&Gs(i))&&(c?Li(i):i)}Je(Ss(e),"ph-no-capture")&&(b=!0),f.push(function(e,t,i,r,s){void 0===s&&(s=!1);var n=e.tagName.toLowerCase(),o={tag_name:n};Ps.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ha(1024,Ks(e)):Ha(1024,Es(e)));var a=Ss(e);a.length>0&&(o.classes=a.filter((function(e){return""!==e}))),Mr(e.attributes,(function(i){var n;if((!qs(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Gs(i.value)&&(!lt(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=bs(a).join(" ")),o["attr__"+i.name]=Ha(1024,"href"===i.name&&s?Li(a):a)}}));for(var l=1,u=1,c=e;c=ja(c);)l++,c.tagName===e.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(e,o,a,l,c));var r=function(e){if(!Bs(e))return{};var t={};return Mr(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Gs(r)&&(t[i]=r)}})),t}(e);$r(m,r)})),b)return{props:{},explicitNoCapture:b};if(a||(f[0].$el_text=vs(e,"a")||vs(e,"button")?Ks(e):Es(e)),y){var w,S;f[0].attr__href=y;var x=null==(w=_n(y))?void 0:w.host,E=null==ye||null==(S=ye.location)?void 0:S.host;x&&E&&x!==E&&(g=y)}return{props:$r({$event_type:n.type,$ce_version:1},u?{}:{$elements:f},{$elements_chain:(v=f,function(e){return e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Or(o).sort(((e,t)=>e[0].localeCompare(t[0]))).forEach((e=>{var t=e[1];return a[Js(e[0].toString())]=Js(t.toString())})),(s+=":")+Or(a).map((e=>e[0]+'="'+e[1]+'"')).join("")})).join(";")}(function(e){return e.map((e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Ys(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Or(e).filter((e=>0===e[0].indexOf("attr__"))).forEach((e=>r.attributes[e[0]]=e[1])),r}))}(v)))},null!=(r=f[0])&&r.$el_text?{$el_text:null==(s=f[0])?void 0:s.$el_text}:{},g&&"click"===n.type?{$external_click_url:g}:{},m)}}var Wa=Ar("[ExceptionAutocapture]"),Va=()=>{},Ga=Ar("[TracingHeaders]"),Ka=Ar("[Web Vitals]"),Qa=9e5,Ja="disabled",Ya="lazy_loading",Za="awaiting_config",Xa="missing_config";Ar("[SessionRecording]"),Ar("[SessionRecording]");var el="[SessionRecording]",tl=Ar(el),il=Ar("[Heatmaps]");function rl(e){return nt(e)&&"clientX"in e&&"clientY"in e&&ht(e.clientX)&&ht(e.clientY)}var sl=Ar("[Product Tours]"),nl=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(f))},ol=["$set_once","$set"],al=Ar("[SiteApps]"),ll="Error while initializing PostHog app with config id ";function ul(e,t,i){if(dt(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class cl{constructor(e){this._debugEventEmitter=new Yo,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e,t;at(null==(e=this._instance)?void 0:e._addCaptureHook)||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)})))}register(e){var t,i;if(!at(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!ul(r,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var i;if(null==t||!t.href)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>ul(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&ul((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>ul(e.text,t.text,t.text_matching||"exact")||ul(e.$el_text,t.text,t.text_matching||"exact")));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!dt(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some((e=>ul(e,n,o))))}_checkStepSelector(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||oa(t.properties.reduce(((e,t)=>{var i=rt(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e}),{}),null==e?void 0:e.properties)}}class dl{constructor(e){var t;this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map,null==(t=this._instance)||null==t.onSessionId||t.onSessionId((e=>this._onSessionIdChanged(e)))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&oa(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach((t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}}))})),i}_getMatchingItems(e,t,i){var r=(i===zn?this._eventToItems:this._cancelEventToItems).get(e),s=[];return this._getItems((e=>{s=e.filter((e=>null==r?void 0:r.includes(e.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;at(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedItems(e),this._setupActionBasedItems(e))}_setupActionBasedItems(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==t.length&&(null==this._actionMatcher&&(this._actionMatcher=new cl(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook((e=>{this.onAction(e)}))),t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToItems.get(t.name);i&&i.push(e.id),this._actionToItems.set(t.name,i||[e.id])}})))})))}_setupEventBasedItems(e){var t,i=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,zn),this._cancelEventToItems=this._buildEventToItemMap(e,Hn))}onEvent(e,t){var i,r,s=this._getLogger(),n=(null==t||null==(i=t.properties)?void 0:i.$survey_id)||(null==t||null==(r=t.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this._activationOutcome(e,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:e,itemId:n}),void this._deactivateItems([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:e,itemId:n}),this._persistActivation(n),void this._clearActivationTimestamps([n])}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,Hn);a.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map((e=>e.id))}),this._deactivateItems(a.map((e=>e.id))),a.forEach((e=>this._cancelPendingItem(e.id))))}if(this._eventToItems.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var l=this._getMatchingItems(e,t,zn);this._activateItems(l.map((e=>e.id)))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){var t;if(0!==e.length){var i=!(null==(t=this._instance)||null==t.get_session_id||!t.get_session_id()),r=[];for(var s of e)i&&this._shouldPersistArmedActivation(s)?this._persistActivation(s)&&this._recordActivationTimestamp(s):r.push(s);r.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...r])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()})}}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter((t=>t!==e));var t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter((e=>!t.has(e)));var i=this._getRawPersistedActivatedIds(),r=i.filter((e=>!t.has(e)));r.length!==i.length&&(this._setActivatedItems(r),0===r.length&&this._clearActivationSession()),this._clearActivationTimestamps(e)}_getRawActivationTimestamps(){var e,t=this._getActivationTimestampsKey();if(!t)return{};var i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t];return i&&"object"==typeof i?i:{}}_recordActivationTimestamp(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps();this._writeActivationTimestamps(i({},t,{[e]:Date.now()}))}}_clearActivationTimestamps(e){if(this._getActivationTimestampsKey()){var t=this._getRawActivationTimestamps(),i={},r=!1;for(var s of Object.entries(t)){var n=s[0],o=s[1];e.includes(n)?r=!0:i[n]=o}r&&(ot(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(this._getPersistedActivatedIds().includes(e)){var t=this._getRawActivationTimestamps()[e];return ht(t)?t:void 0}}_getRawPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}_getPersistedActivatedIds(){var e,t,i=this._getRawPersistedActivatedIds();if(0===i.length)return[];var r=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this._getActivatedSessionKey()],s=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();return s&&r===s?i:[]}_stampActivationSession(){var e,t=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();t&&this._setActivatedSession(t)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){var t,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this._getActivatedSessionKey()];if(i&&i!==e){var r=this._getRawPersistedActivatedIds(),s=this._getRawActivationTimestamps();r.length>0&&(this._setActivatedItems([]),r.filter((e=>ht(s[e]))).forEach((e=>this._cancelPendingItem(e)))),this._clearActivationSession(),this._clearAllActivationTimestamps()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter((e=>!this._isItemPermanentlyIneligible(e)))}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class hl extends dl{constructor(e){super(e)}_getActivatedKey(){return z}_getActivatedSessionKey(){return H}_getActivationTimestampsKey(){return j}_writeActivationTimestamps(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[j]:e})}_clearActivationTimestampsStore(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(j)}_shouldPersistArmedActivation(e){var t,i;this._getItems((t=>{i=t.find((t=>t.id===e))}));var r=null==(t=i)||null==(t=t.appearance)?void 0:t.surveyPopupDelaySeconds;return ht(r)&&r>0}_getShownEventName(){return jn}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return ha}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[z]:e})}_setActivatedSession(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[H]:e})}_clearActivatedSession(){var e;null==(e=this._instance)||null==(e=e.persistence)||e.unregister(H)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){var i;this._getItems((e=>{i=e.find((e=>e.id===t))}));var r=!i||function(e){var t;return da(e)&&!(null==(t=e.conditions)||null==(t=t.events)||!t.repeatedActivation)||"always"===e.schedule}(i);return r?e===jn?"consume":"ignore":e===jn?"persist":e===Un||e===Wn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var _l="SDK is not enabled or survey functionality is not yet loaded",pl="Disabled. Not loading surveys.",gl=null!=ye&&ye.location?vn(ye.location.hash,"__posthog")||vn(location.hash,"state"):null,vl="_postHogToolbarParams",fl=Ar("[Toolbar]"),ml=Ar("[FeatureFlags]"),yl=Ar("[FeatureFlags]",{debugEnabled:!0}),bl="\" failed. Feature flags didn't load in time.",wl=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Sl=e=>{var t={};for(var i of Or(e||{})){var r=i[1];r&&(t[i[0]]=r)}return t},xl=Ar("[Error tracking]"),El="Refusing to render web experiment since the viewer is a likely bot",kl={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>ia(t,e),not_regex:(e,t)=>!ia(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class Pl{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Pl._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Pl._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);lt(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];Pl._matchesTestVariant(n,t._instance)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Pl._logInfo(El);else if(!this._config.disable_web_experiments){if(dt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Pl._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=Pl.getWindowLocation();if(null!=e&&e.search){var t=pn(null==e?void 0:e.search,"__experiment_id"),i=pn(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Pl._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(Pl._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e,t){return!dt(e.conditions)&&Pl._matchUrlConditions(e,t)&&Pl._matchUTMConditions(e)}static _matchUrlConditions(e,t){var i;if(dt(e.conditions)||dt(null==(i=e.conditions)?void 0:i.url))return!0;var r=Pl.getWindowLocation();if(r){var s,n,o,a=us(t,r.href);return null==(s=e.conditions)||!s.url||kl[null!==(n=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](e.conditions.url,a)}return!1}static getWindowLocation(){return null==ye?void 0:ye.location}static _matchUTMConditions(e){var t;if(dt(e.conditions)||dt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=En();if(i.utm_source){var r,s,n,o,a,l,u,c,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,h=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,_=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return d&&_&&p&&h}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];Rr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Pl._logInfo(El):"control"!==t?i.forEach((i=>{if(i.selector){var r;Pl._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):Pl._logInfo("Control variants leave the page unmodified.")}_is_bot(){return we&&this._instance?ea(we,this._config.custom_blocked_useragents):void 0}}var Cl=Ar("[Conversations]"),Il="Conversations not available yet.",Fl="console",Tl="__posthogHandledLogsRequestError",Rl=(e,t)=>{var i=e instanceof Error?e:new Error(t);return i[Tl]=!0,i},Al=e=>!!e&&"object"==typeof e&&!0===e[Tl],Ll={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._onOnline=()=>{var e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],ye&&Hr(ye,"online",this._onOnline)}destroy(){null==ye||ye.removeEventListener("online",this._onOnline)}get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}_prop(e){return this._instance.get_property(e)}_isCacheStale(){var e,t;return null!==(e=null==(t=this._persistence)?void 0:t._isFeatureFlagCacheStale(this._config.feature_flag_cache_ttl_ms))&&void 0!==e&&e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,ml.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e,t=null!==(e=this._config.evaluation_contexts)&&void 0!==e?e:this._config.evaluation_environments;return!this._config.evaluation_environments||this._config.evaluation_contexts||this._hasLoggedDeprecationWarning||(ml.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._hasLoggedDeprecationWarning=!0),null!=t&&t.length?t.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||ml.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}_getValidFlagKeys(){var e=this._config.flag_keys;if(!at(e)){if(rt(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||ml.error("Invalid flag key found:",e,"Expected non-empty string"),t}));ml.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,i=this._instance.config,r=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};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((e=>!!r[e])).reduce(((e,t)=>(e[t]=r[t]||!1,e)),{}),l=Object.keys(o).filter((e=>a[e])).reduce(((e,t)=>(o[t]&&(e[t]=o[t]),e)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,r){var s,n,o=null!=r&&r.merge&&null!==(s=this._prop(C))&&void 0!==s?s:{},a=null!=r&&r.merge&&null!==(n=this._prop(R))&&void 0!==n?n:{},l=i({},o,e),u=i({},a,t),c={};for(var d of Object.entries(l)){var h=d[0],_=d[1];c[h]={key:h,enabled:Le(_),variant:Me(_),reason:void 0,metadata:at(null==u?void 0:u[h])?void 0:{id:0,version:void 0,description:void 0,payload:u[h]}}}this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(T),t=this._prop(M),r=this._prop(O);if(!r&&!t)return e||{};var s=$r({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=s[o],c=null==t?void 0:t[o],d=at(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,h=at(c)?u.variant:"string"==typeof c?c:void 0,_=null==r?void 0:r[o],p=i({},u,{enabled:d,variant:d?null!=h?h:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),h!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),_&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:_,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[o]=p}return this._override_warning||(ml.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((i=>{var r=e[i];return{key:i,enabled:Le(r),variant:Me(r),payload:Ae(t[i])}}))}getFlagVariants(){var e=this._prop(C),t=this._prop(M);if(!t)return e||{};for(var i=$r({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(ml.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(R),t=this._prop(O);if(!t)return e||{};for(var i=$r({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(ml.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.advanced_disable_feature_flags||this._hasStatusZeroCircuitBreakerTripped()||this._reloadDebouncer||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags()&&!this._hasStatusZeroCircuitBreakerTripped())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r=this._config.token,n=this._prop(o),a={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._persistence)?void 0:t.get_initial_props())||{},this._prop(D)||{},{$lib:s.LIB_NAME,$lib_version:s.LIB_VERSION}),group_properties:this._prop(B),timezone:An()};ct(n)||at(n)||(a.$device_id=n),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(a.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(a.evaluation_contexts=this._getValidEvaluationEnvironments());var l=this._getValidFlagKeys();at(l)||(a.flag_keys=l);var u=!!this._config.advanced_only_evaluate_survey_feature_flags,c=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this._config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this._requestInFlight=!0,this._instance._send_request({method:"POST",url:c,data:a,compression:this._config.disable_compression?void 0:Nn,timestampMode:"body",timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(this._trackStatusZeroReachability(e.statusCode),200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,!a.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;var n=[];e.error?e.error instanceof Error?n.push("AbortError"===e.error.name?"timeout":"connection_error"):n.push("unknown_error"):200!==e.statusCode&&n.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&n.push("errors_while_computing_flags");var o,l=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(l&&n.push("quota_limited"),null==(r=this._persistence)||r.register({[G]:n}),l)ml.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.");else a.disable_flags||this.receivedFeatureFlags(null!==(o=e.json)&&void 0!==o?o:{},s,{partialResponse:u}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}_hasStatusZeroCircuitBreakerTripped(){return fn(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=mn(e,this._consecutiveStatusZeroFailures,3,(()=>ml.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else ml.warn('getFeatureFlag for key "'+e+bl)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(A)||void 0,l=this._prop(K)||void 0,u=this._prop(W)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),h=this._prop(V);d&&d!==h&&(u={},null==(c=this._persistence)||c.register({[W]:u,[V]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var _,p,g,v,f,m,y,b,w,S,x;rt(u[e])?u[e].push(o):u[e]=[o],null==(_=this._persistence)||_.register({[W]:u});var E=this.getFeatureFlagDetails(e),k=[...null!==(p=this._prop(G))&&void 0!==p?p:[]];at(s)&&k.push("flag_missing");var P={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};at(null==E||null==(f=E.metadata)?void 0:f.has_experiment)||(P.$feature_flag_has_experiment=E.metadata.has_experiment),at(null==E||null==(m=E.metadata)?void 0:m.version)||(P.$feature_flag_version=E.metadata.version);var C,I=null!==(y=null==E||null==(b=E.reason)?void 0:b.description)&&void 0!==y?y:null==E||null==(w=E.reason)?void 0:w.code;I&&(P.$feature_flag_reason=I),null!=E&&null!=(S=E.metadata)&&S.id&&(P.$feature_flag_id=E.metadata.id),at(null==E?void 0:E.original_variant)&&at(null==E?void 0:E.original_enabled)||(P.$feature_flag_original_response=at(E.original_variant)?E.original_enabled:E.original_variant),null!=E&&null!=(x=E.metadata)&&x.original_payload&&(P.$feature_flag_original_payload=null==E||null==(C=E.metadata)?void 0:C.original_payload),k.length&&(P.$feature_flag_error=k.join(",")),this._instance.capture("$feature_flag_called",P)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Ae(n)}}}else ml.warn('getFeatureFlagResult for key "'+e+bl)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i,person_properties:{$lib:s.LIB_NAME,$lib_version:s.LIB_VERSION}};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments());var n=this._getValidFlagKeys();at(n)||(r.flag_keys=n),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:Nn,timestampMode:"body",timeout:this._config.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return ml.warn('isFeatureEnabled for key "'+e+bl),t.defaultValue;var i=this.getFeatureFlag(e,t);return at(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,r){if(this._persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,r,s,n,o){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var a=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):e.featureFlags&&ml.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,h=e.evaluatedAt;if(rt(u)){ml.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var _={};if(u)for(var p=0;u.length>p;p++)_[u[p]]=!0;t&&t.register({[I]:u,[C]:_,[L]:!1})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},r,g),v=i({},s,v),f=i({},n,f);else if(e.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((e=>{var t;return!(null!=(t=l[e])&&t.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((e=>m.has(e[0]))))),v=i({},s,Object.fromEntries(Object.entries(v||{}).filter((e=>m.has(e[0]))))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>m.has(e[0])))))}else g=i({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[I]:Object.keys(Sl(g)),[C]:g||{},[R]:v||{},[T]:f||{},[L]:!0===e.minimalFlagCalledEvents},d?{[A]:d}:{},h?{[K]:h}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),ml.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return ml.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(M),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),yl.info("All overrides cleared");if(rt(e)){var t=wl(e);return this._persistence.register({[M]:t}),this._fireFeatureFlagsCallbacks(),yl.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(M),yl.info("Flag overrides cleared");else if(r.flags){if(rt(r.flags)){var s=wl(r.flags);this._persistence.register({[M]:s})}else this._persistence.register({[M]:r.flags});yl.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),yl.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),yl.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[M]:e}),this._fireFeatureFlagsCallbacks(),yl.info("Flag overrides set",{flags:e});ml.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,r=t.flagVariants;try{e(i,r)}catch(e){ml.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(F)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[I]:Object.keys(Sl(l)),[C]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(F),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",timestampMode:"query",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(F),null==(r=this._persistence)||r.register({[F]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach((t=>{try{t(i,r,{errorsLoading:e})}catch(e){ml.error("Error while running feature flags callback",e)}}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(D)||{},s=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in r||(o[a]=n[a]));this._instance.register({[D]:i({},r,o,s)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=i({},this._prop(D)||{});e.forEach((e=>{delete r[e]})),this._instance.register({[D]:r}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){void 0===e&&(e=!0),this._instance.unregister(D),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(B)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[B]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(B)||{};this._instance.register({[B]:i({},t,{[e]:{}})})}else this._instance.unregister(B)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0}}},Ml={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return this._recordingStatus===Za||this._recordingStatus===Xa?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Ja,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw tl.error("started without valid sessionManager"),new Error(el+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===ue)throw new Error(el+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(y))||!e.enabled),i=!this._config.disable_session_recording,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return ye&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!at(Object.assign)&&!at(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),tl.info("starting")):(this._recordingStatus=Ja,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==Za&&this._recordingStatus!==Xa&&(this._recordingStatus=Ya),null!=Re&&null!=(t=Re.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Re.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=Re.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return tl.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_discardRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.discard()}_resetSampling(){var e,t;null==(e=this._persistence)||e.unregister(P),null==(t=this._persistence)||t.unregister(b)}_validateSampleRate(e,t){if(dt(e))return null;var i,r=ht(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(tl.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}_persistRemoteConfig(e){if(this._persistence){var t,r,s=this._persistence,n=()=>{var t,r=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==r?void 0:r.sampleRate,"remote config sampleRate"),a=null!=n?n:o;dt(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[y]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:a,minimumDurationMilliseconds:at(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):(this._recordingStatus===Za&&(this._recordingStatus=Xa,tl.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):tl.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(y);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t,i=this._instance.get_property(y);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(e){return tl.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}var r=null!==(e=t.cache_timestamp)&&void 0!==e?e:Date.now();return 36e5>=Date.now()-r}_onScriptLoaded(e){var t,i;if(null==(t=Re.__PosthogExtensions__)||!t.initSessionRecording)return tl.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[oe]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Re.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===Xa||this._recordingStatus===Za)return;return this._recordingStatus=Za,tl.info("persisted remote config is stale, requesting fresh config before starting"),void new Jn(this._instance).load()}this._recordingStatus=Ya,this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[S]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[w]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?x:E]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}},$l={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new qa(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=nt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(ye&&Se){var e=e=>{e=e||(null==ye?void 0:ye.event);try{this._captureEvent(e)}catch(e){za.error("Failed to capture event",e)}};if(Hr(Se,"submit",e,{capture:!0}),Hr(Se,"change",e,{capture:!0}),Hr(Se,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==ye?void 0:ye.event);try{this._captureEvent(e,Na)}catch(e){za.error("Failed to capture copy/cut event",e)}};Hr(Se,"copy",t,{capture:!0}),Hr(Se,"cut",t,{capture:!0})}}}else za.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._hasReceivedConfigResponse=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);var i=t.autocapture_opt_out;pt(i)&&(this.instance.persistence&&this.instance.persistence.register({[c]:i}),this._isDisabledServerSide=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==Se?void 0:Se.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[c],r=this._isDisabledServerSide,s=this.instance._shouldDisableFlags()&&!this._hasReceivedConfigResponse;if(ct(r)&&!pt(i)&&!s)return!1;var n=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=ks(e);fs(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&$s(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===Na;if(r&&function(e,t,i,r,s,n){var o;if(!ye||Os(e))return!1;if(null!=i&&i.url_allowlist&&!ws(i.url_allowlist,n))return!1;if(null!=i&&i.url_ignorelist&&ws(i.url_ignorelist,n))return!1;if(null!=i&&i.dom_event_allowlist){var a=i.dom_event_allowlist;if(a&&!a.some((e=>t.type===e)))return!1}var l=Ds(e,r),u=l.parentIsUsefulElement,c=l.targetElementList;if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(at(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(c,i))return!1;if(!Cs(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Cs(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Fs))return!1;try{var d=ye.getComputedStyle(e);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return u?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(Ps.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0,this.instance)){var n=Ua(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),o=n.props;if(n.explicitNoCapture)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(o.$element_selectors=a),t===Na){var l,u=xs(null==ye||null==(l=ye.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=c}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return st(null==Se?void 0:Se.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==ye||null==(t=ye.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Rr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,Rr.info("History API monitoring stopped")}monitorHistoryChanges(){ye&&ye.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener())}_patchHistoryMethod(e){var t;if(ye&&(null==(t=ye.history[e])||!t.__posthog_wrapped__)){var i=this;!function(e,t,i){try{if(!(t in e))return Va;var r={next:e[t]},s=i((function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return r.next.apply(this,t)}));return st(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=s,()=>{if(e[t]!==s)for(var i=e[t];st(i)&&i.__posthog_layer__;){var n=i.__posthog_layer__;if(n.next===s)return void(n.next=r.next);i=n.next}else e[t]=r.next}}catch(e){return Va}}(ye.history,e,(t=>function(r,s,n){t.call(this,r,s,n),i._capturePageview(e)}))}}_capturePageview(e){try{var t,i=null==ye||null==(t=ye.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(ge,{navigation_type:e}),this._lastPathname=i}catch(t){Rr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Hr(ye,"popstate",e),this._popstateListener=()=>{ye&&ye.removeEventListener("popstate",e)}}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[d]),this.rageclicks=new qa(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return nt(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return dt(this._config.capture_heatmaps)?dt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;il.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[d]:i}),this._enabledServerSide=i,this.startIfEnabled()}}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){rl(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(Se)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){ye&&Se&&(this._flushHandler=this._flush.bind(this),Hr(ye,pe,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==ye?void 0:ye.event)),Hr(Se,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==ye?void 0:ye.event)),Hr(Se,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new tn(this.instance,Xs,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Hr(Se,_e,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;ye&&Se&&(this._flushHandler&&ye.removeEventListener(pe,this._flushHandler),this._onClickHandler&&Se.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&Se.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&Se.removeEventListener(_e,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&gs(r)&&!vs(r,"body");){if(r===i)return!1;var s=void 0;try{var n,o,a;s=null==(n=null!==(o=null==(a=r.ownerDocument)?void 0:a.defaultView)&&void 0!==o?o:ye)?void 0:n.getComputedStyle(r).position}catch(e){return!1}if(Je(t,s))return!0;r=Is(r)}return!1}(ks(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!ps(e.target)&&rl(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&$s(ks(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!ps(e.target)&&rl(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(ye){var t=this._config.disable_capture_url_hashes?Li(ye.location.href):ye.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...bn,...i||[]]:[],s=gn(t,r,Sn);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!ot(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:tn,webVitalsAutocapture:class{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",i({$current_url:this._buffer.url},this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{}))),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},dt(null==e?void 0:e.name)||dt(null==e?void 0:e.value))Ka.error("Invalid metric received",e);else{var r="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this._maskedURL(r);if(!at(s)){var n=ht(e.navigationId)||"string"==typeof e.navigationId?"navigation:"+e.navigationId:"url:"+s;if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),at(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=s),this._buffer.firstMetricTimestamp=at(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var o=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),a=i({},e,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});at(o)||(a.$session_id=o.sessionId,a.$window_id=o.windowId),this._buffer.metrics.push(a),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else Ka.error("Ignoring metric with value >= "+this._maxAllowedValue,e)}}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Re.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&at(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(at(o)||(e=o.onLCP,t=o.onCLS,i=o.onFCP,r=o.onINP),e&&t&&i&&r){var a={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this),a),this._initialized=!0}else Ka.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[g]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=nt(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return dt(i)?(null==(t=this._instance.persistence)?void 0:t.props[m])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(nt(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=nt(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get useSoftNavs(){var e=nt(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){var e=nt(this._perfConfig)&&ht(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Qa;return e>0&&6e4>=e?Qa:e}get isEnabled(){var e=null==xe?void 0:xe.protocol;if("http:"!==e&&"https:"!==e)return Ka.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=nt(this._perfConfig)?this._perfConfig.web_vitals:pt(this._perfConfig)?this._perfConfig:void 0;return pt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ka.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var i=nt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=nt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[g]:i}),this._instance.persistence.register({[m]:r})),this._enabledServerSide=i,this.startIfEnabled()}}}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t=Re.__PosthogExtensions__,i=this._callbackFlavor,r=null==t?void 0:t.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&at(r)&&null!=t&&t.postHogWebVitalsCallbacks?e():null==t||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,i,(t=>{t?Ka.error("failed to load script",t):e()}))}_maskedURL(e){var t=e||(null==ye?void 0:ye.location.href);if(t){var i=this._instance.config.disable_capture_url_hashes?Li(t):t,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...bn,...r||[]]:[];return gn(i,s,Sn)}Ka.error("Could not determine current URL")}}},Ol={exceptionObserver:class{constructor(e){var t;this._startCapturing=()=>{var e;if(ye&&this.isEnabled&&null!=(e=Re.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Re.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Re.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Re.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=r(this.captureException.bind(this)))}catch(e){Wa.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[h]),this._rateLimiter=new Pt(i({},function(e){var t,i,r,s;return void 0===e&&(e={}),{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(r=null!==(s=e.exceptionRateLimiterBucketSize)&&void 0!==s?s:e.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,_logger:Wa})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return nt(e)?t=i({},t,e):(at(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Wa.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return Wa.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[h]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?Wa.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,r;this._suppressionRules=[],this._errorPropertiesBuilder=new er([new hr,new Sr,new pr,new _r,new br,new yr,new vr,new wr],function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;t>s;s++)r[s-1]=arguments[s];return function(t,s){void 0===s&&(s=0);for(var n=[],o=t.split("\n"),a=s;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=dr.test(l)?l.replace(dr,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of r){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return i({},e,{filename:e.filename||(r=t,r[r.length-1]||{}).filename,function:e.function||tr});var r}))}(n)}}("web:javascript",ar,cr)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(_))&&void 0!==t?t:[],this._exceptionStepsConfig=Cr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Ir(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Cr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if(e.ok){var s=e.config;if("errorTracking"in s){var n=null!==(t=null==(i=s.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=n,this._instance.persistence&&this._instance.persistence.register({[_]:this._suppressionRules,[p]:o})}}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(p),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!lt(e)||0===e.trim().length)return void xl.warn("Ignoring exception step because message must be a non-empty string");var r=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>kr.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&xl.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[xr]:e,[Er]:(new Date).toISOString()},s))}catch(e){xl.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void xl.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void xl.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void xl.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&dt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,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",_originatedFromCaptureException:!0});return s&&this._exceptionStepsBuffer.clear(),s}catch(e){return xl.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void xl.error("Failed to process exception event. Ignoring this exception.",e)}var n}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return xl.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[xr]:e,[Er]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return nt(e)?i({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{var t=e.reduce(((e,t)=>{var i=t.type,r=t.value;return lt(i)&&i.length>0&&e.$exception_types.push(i),lt(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i=sa[e.operator],r=t[e.key];if(!i||!r)return!1;var s=rt(e.value)?e.value:[e.value];return s.length>0&&i(s,r)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}catch(e){return xl.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],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}_isExceptionList(e){return!dt(e)&&rt(e)}}},Dl=i({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var i,r;if(this._persistence&&this._persistence.register({[f]:!!t.productTours}),!nl(this._instance))return!this._productTourManager&&dt(null==(i=this._persistence)?void 0:i.props[U])||sl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this._productTourManager)||r.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this._productTourManager&&nl(this._instance)&&this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?sl.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Re.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Re.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!rt(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[U];if(rt(r)&&!t)return this._cachedTours=r,void e(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:t=>{if(nl(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?t.error||sl.warn(s):sl.error(s),void e([],{isLoaded:!1,error:s})}var n=rt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[U]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){dt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript((()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)}))}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._persistence)||e.unregister(U)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},Ll),Bl={siteApps:class{constructor(e){this._siteAppElementPatchCount=0,this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=Re._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,s,n,o,a,l,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var _ of Object.entries(h)){var p=_[0];c[p]={id:d[p],type:p,properties:_[1]}}var g=e.$set_once,v=e.$set;return{event:i({},r(e,ol),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}_prepareElementForSiteApp(e){var t,i=null==(t=e.tagName)?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(al.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(al.error("prepare_external_dependency_script returned null"),null):e}_patchSiteAppElementInsertionMethods(){var e,t,i,r,s,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==Se?void 0:Se.defaultView,u=null==l||null==(e=l.Node)?void 0:e.prototype;if(!l||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();var c=[],d=this,h=new WeakSet,_=(e,t,i)=>{if(null!=e&&e[t]){var r=e[t];e[t]=i(r),c.push((()=>{e[t]=r}))}},p=e=>{if(h.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&h.add(t),t},g=e=>e.map((e=>"string"==typeof e?e:p(e))).filter((e=>!ct(e)));return _(u,"appendChild",(e=>function(t){var i=p(t);return i?e.call(this,i):t})),_(u,"insertBefore",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):t})),_(u,"replaceChild",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):i})),[null==(t=l.Element)?void 0:t.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((e=>{_(e,"append",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),_(e,"prepend",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach((e=>{_(e,"before",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),_(e,"after",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),_(e,"replaceWith",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];var s=g(i);return i.length&&!s.length?void 0:e.apply(this,s)}))})),_(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",(e=>function(t,i){var r=p(i);return r?e.call(this,t,r):null})),this._restoreSiteAppElementPatches=()=>{c.forEach((e=>e())),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){var e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null==(t=this._restoreSiteAppElementPatches)||t.call(this)))}}_runWithPreparedSiteAppElements(e,t){void 0===t&&(t=!0);var i=this._patchSiteAppElementInsertionMethods();try{var r=e(i);return t&&i(),r}catch(e){throw i(),e}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(al.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>this._runWithPreparedSiteAppElements((()=>null==t.processEvent?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&(null==(i=this._stopBuffering)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,al.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this._runWithPreparedSiteAppElements((t=>e.init({posthog:this._instance,callback(e){t(),s(e)}})),!1).processEvent;n&&(t.processEvent=n),r=!0}catch(t){al.error(ll+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){al.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){var t=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(e),r=function(r){try{t._runWithPreparedSiteAppElements((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(t){al.error("Error while processing event "+e.event+" for site app "+r.id,t)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void al.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),e.ok){var n=e.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var e,t=a.id,i=a.url;Re["__$$ph_site_app_"+t]=s._instance,null==(e=Re.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,i,(e=>{if(e)return al.error(ll+t,e)}))};for(var a of n.siteApps)o()}else al.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ql={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{var e,t,i=this._syncHostnamesForPatch();i?(at(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=Re.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),at(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=Re.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this._stopCapturing()},this._instance=e}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=Re.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=Re.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Ga.error("failed to load script",t);e()}))}_getConfiguredHostnames(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){var e=this._getConfiguredHostnames();return rt(e)?(rt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(rt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},Nl=i({surveys:class{get _config(){return this._instance.config}constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){if(!e.ok)return ha.warn("Remote config unavailable. Not loading surveys.");var t=e.config.surveys;if(dt(t))return ha.warn("Flags not loaded yet. Not loading surveys.");var i=rt(t);this._isSurveysEnabled=i?t.length>0:t,ha.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(_a)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)ha.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)ha.info(pl);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())ha.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Re?void 0:Re.__PosthogExtensions__;if(e){if(!at(this._isSurveysEnabled)||this._config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError(ae);r(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else ha.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new hl(this._instance),ha.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){ha.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._config.disable_surveys)return ha.info(pl),e([]);var i,r=this._instance.get_property(q);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>e(t.surveys,t.context))):("undefined"!=typeof Promise&&(this._getSurveysInFlightPromise=new Promise((e=>{i=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._config.token),method:"GET",timestampMode:"query",timeout:this._config.surveys_request_timeout_ms,callback:t=>{var r;this._getSurveysInFlightPromise=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;0!==s?ha.error(n):t.error||ha.warn(n),this._lastSurveyRefreshFailedAt=Date.now();var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}this._lastSurveyRefreshFailedAt=null;var a,l=t.json.surveys||[],u=l.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(da(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[q]:l,[N]:Date.now()});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e=this._instance.get_property(N);return ht(e)&&Date.now()-e>3e5}_isSurveyRefreshBackingOff(){return ht(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i,r={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};pa(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){ha.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!dt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);ha.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(dt(this._surveyManager))return{eligible:!1,reason:_l};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){if(dt(this._surveyManager))return{eligible:!1,reason:_l};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(dt(this._surveyManager))return ha.warn("init was not called"),{visible:!1,disabledReason:_l};var t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return dt(this._surveyManager)?(ha.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:_l})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyRenderability(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(dt(this._surveyManager))ha.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(ga.includes(s.type)){var n=null==Se?void 0:Se.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(ha.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;ha.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),ha.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);ha.warn("Survey element not found")}else ha.warn("Surveys of type "+s.type+" cannot be rendered in the app");else ha.warn("Survey not found")}}displaySurvey(e,t){var r;if(dt(this._surveyManager))ha.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Vn&&t.initialResponses&&ha.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this._checkSurveyEligibility(s);if(!o.eligible)return void ha.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else ha.warn("Survey not found")}}cancelPendingSurvey(e){dt(this._surveyManager)?ha.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||null==e.handlePageUnload||e.handlePageUnload()}}},Ll),zl={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Re.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Re.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),jr(this.instance.config))return!1;if(!ye||!Se)return!1;e=null!=e?e:ye.location,i=null!=i?i:ye.history;try{if(!t){try{ye.localStorage.setItem("test","test"),ye.localStorage.removeItem("test")}catch(e){return!1}t=null==ye?void 0:ye.localStorage}var r,s=gl||vn(e.hash,"__posthog")||vn(e.hash,"state"),n=s?Dr((()=>JSON.parse(atob(decodeURIComponent(s)))))||Dr((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(vl)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){var t=Re.ph_load_toolbar||Re.ph_load_editor;!dt(t)&&st(t)?t(e,this.instance):fl.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==Se||!Se.getElementById(cs));if(!ye||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ye.localStorage.setItem(vl,JSON.stringify(i({},s,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=Re.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return fl.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Hr(ye,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(s)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},Hl=i({experiments:Pl},Ll),jl={conversations:class{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&e.ok){var t=e.config.conversations;dt(t)||(pt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null}loadIfEnabled(){if(!(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||jr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Re?void 0:Re.__PosthogExtensions__;if(e&&!at(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError(ae);i(this._instance,"conversations",(t=>{t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1}))}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}else Cl.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Cl.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Cl.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Cl.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():Cl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!ct(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,r){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,i,r):(Cl.warn(Il),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(Cl.warn(Il),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(Cl.warn(Il),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(Cl.warn(Il),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(Cl.warn(Il),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(Cl.warn(Il),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Cl.warn(Il),null)}))()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},Ul={logs:class{constructor(e){var t,r=this;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=Ar("[logs]"),this._coreLogger=i({},this._logger,{error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];t.some(Al)||r._logger.error(...t)}}),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._onReconnect=()=>{var e,t;this._consecutiveStatusZeroFailures=0,null==(e=this._core)||e.onReconnect(),null==(t=this._consoleCore)||t.onReconnect()},this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),ye&&Hr(ye,"online",this._onReconnect)}_buildCore(e,t,i,r){var s,n=function(e,t){var i,r,s,n,o,a,l,u=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,c=null!==(r=null==e?void 0:e.maxBufferSize)&&void 0!==r?r:100,d=null!=t&&t.consoleCapture?void 0:null!==(s=null==e?void 0:e.maxLogsPerInterval)&&void 0!==s?s:1e3,h=at(d)?Math.max(c,2048):Math.max(c,d),_=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==_?void 0:_["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==n?n:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==_?void 0:_["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==_?void 0:_["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:_,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:h,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 Wi(this._createHost(e,t),n,this._coreLogger,(()=>this._getSdkContext()),(e=>e()),void 0,r),n]}_getCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._core||this._resolvedFrom!==t){var i;null==(i=this._core)||i.reset(),this._resolvedFrom=t;var r=this._buildCore((()=>this._queue),(e=>{this._queue=e}));this._core=r[0],this._resolvedConfig=r[1]}return this._core}_getConsoleCore(){var e,t=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;if(!this._consoleCore||this._consoleResolvedFrom!==t){var i;null==(i=this._consoleCore)||i.reset(),this._consoleResolvedFrom=t;var r=this._buildCore((()=>this._consoleQueue),(e=>{this._consoleQueue=e}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Fl);this._consoleCore=r[0],this._consoleResolvedConfig=r[1]}return this._consoleCore}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t;if(e.ok){var i=null==(t=e.config.logs)?void 0:t.captureConsoleLogs;!dt(i)&&i&&(this._isLogsEnabled=!0,this.loadIfEnabled())}}reset(){var e,t;this._queue=[],null==(e=this._core)||e.reset(),this._consoleQueue=[],null==(t=this._consoleCore)||t.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){this._getCore().captureLog(e)}_captureConsoleLog(e){this._getConsoleCore().captureLog(e)}get logger(){return this._capture_logger||(this._capture_logger={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._capture_logger}flushLogs(e){e?this._flushViaTransport(e):(this._core&&this._core.flush().catch((e=>this._logFlushError(e))),this._consoleCore&&this._consoleCore.flush().catch((e=>this._logFlushError(e))))}_logFlushError(e){Al(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Re?void 0:Re.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(t=>{var i;t||null==(i=e.logs)||!i.initializeLogs?this._logger.error("Could not load logs script",t):(e.logs.initializeLogs(this._instance),this._isLoaded=!0)})):this._logger.error(ae)}else this._logger.error("PostHog Extensions not found.")}}_createHost(e,t){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===De.LogsQueue?e():void 0,setPersistedProperty(e,i){var r;e===De.LogsQueue&&t(null!==(r=i)&&void 0!==r?r:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>s.LIB_NAME,getLibraryVersion:()=>s.LIB_VERSION}}_sendLogsBatch(e){return new Promise((t=>{if(fn(this._consecutiveStatusZeroFailures,3))t({kind:"fatal",error:Rl(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout((()=>{this._logger.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Rl(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this._logsUrl(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;if(this._trackEndpointReachability(t),t>=200&&300>t)r({kind:"ok"});else if(413===t)r({kind:"too-large"});else if(0!==t&&429!==t&&500>t)r({kind:"fatal",error:new Error("logs request failed with status "+t)});else{var i;0===t?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Rl(e.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}}))}_trackEndpointReachability(e){(0!==e||this._instance.__loaded)&&(this._consecutiveStatusZeroFailures=mn(e,this._consecutiveStatusZeroFailures,3,(()=>this._logger.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."))))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,s.LIB_NAME,(e=>{this._queue=e})),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,Fl,(e=>{this._consoleQueue=e}))}_drainQueueViaTransport(e,t,i,r,n){if(0!==t.length){var o=t.map((e=>e.record));n([]);var a=Ui(o,ji(i,s.LIB_NAME,s.LIB_VERSION),r,s.LIB_VERSION);this._instance._send_request({method:"POST",url:this._logsUrl(),data:a,compression:"best-available",batchKey:"logs",transport:e})}}_logsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_getSdkContext(){var e,t={};if(t.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;t.sessionId=i.sessionId,t.windowId=r,dt(s)||(t.sessionStartTimestamp=s),dt(n)||(t.lastActivityTimestamp=n)}if(null!=Re&&null!=(e=Re.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Li(Re.location.href):Re.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},Wl={metrics:class{constructor(e){this._logger=Ar("[metrics]"),this._instance=e}initialize(){}_getCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.metrics;return this._core&&this._resolvedFrom===i||(null==(t=this._core)||t.reset(),this._resolvedFrom=i,this._core=new Qi(this._createHost(),function(e){var t,i,r,s,n,o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(s=null==e?void 0:e.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this._logger)),this._core}count(e,t,i){void 0===t&&(t=1),this._getCore().count(e,t,i)}gauge(e,t,i){this._getCore().gauge(e,t,i)}histogram(e,t,i){this._getCore().histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){var t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch((e=>this._logger.error("PostHog metrics flush failed:",e)))}reset(){var e;null==(e=this._core)||e.reset()}_createHost(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>s.LIB_NAME,getLibraryVersion:()=>s.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise((r=>{var s=!1,n=e=>{s||(s=!0,clearTimeout(o),r(e))},o=setTimeout((()=>n({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(i({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error("metrics request failed with status "+t)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("metrics request failed with status "+t)})}}}))}))}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Vl=i({},Ll,Ml,$l,Ol,Dl,Bl,Nl,ql,zl,Hl,jl,Ul,Wl);Ba.__defaultExtensionClasses=i({},Vl),function(){s.SDK_DIST_CHANNEL="cdn";var e=Re.posthog;if(!e||rt(e._i)){var t=Ea[Aa]=new Ba;if(e){var i=[];Mr(e._i,(function(r){if(r&&rt(r)){var s=t.init(r[0],r[1],r[2]),n=e[r[2]]||e;s.__loaded&&-1===i.indexOf(n)&&(i.push(n),s._execute_array.call(s.people,n.people),s._execute_array(n))}}))}t.__SV=1,Re.posthog=t,function(){function e(){e.done||(e.done=!0,La=!1,Mr(Ea,(function(e){e._dom_loaded()})))}null!=Se&&Se.addEventListener?"complete"===Se.readyState?e():Hr(Se,"DOMContentLoaded",e,{capture:!1}):ye&&Rr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}}()}();
2
2
  //# sourceMappingURL=array.no-external.js.map