posthog-js 1.396.7 → 1.396.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/logs.js +1 -1
- package/dist/logs.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.no-external.js +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/entrypoints/logs.js +24 -2
- package/lib/src/entrypoints/logs.js.map +1 -1
- package/package.json +3 -3
|
@@ -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="1.396.7",n={DEBUG:!1,LIB_VERSION:s,LIB_NAME:"web",JS_SDK_VERSION:s},o="$people_distinct_id",a="$device_id",l="$device_model",u="__alias",c="__timers",d="$autocapture_disabled_server_side",h="$heatmaps_enabled_server_side",_="$exception_capture_enabled_server_side",p="$error_tracking_suppression_rules",g="$error_tracking_capture_extension_exceptions",v="$web_vitals_enabled_server_side",f="$dead_clicks_enabled_server_side",m="$product_tours_enabled_server_side",y="$web_vitals_allowed_metrics",b="$session_recording_remote_config",w="$replay_sample_rate",S="$replay_override_sampling",x="$replay_override_linked_flag",E="$replay_override_url_trigger",k="$replay_override_event_trigger",P="$sesid",I="$session_is_sampled",C="$enabled_feature_flags",F="$active_feature_flags",T="$early_access_features",R="$feature_flag_details",L="$feature_flag_payloads",M="$feature_flag_request_id",A="$override_feature_flags",O="$override_feature_flag_payloads",D="$stored_person_properties",q="$stored_group_properties",B="$surveys",z="$surveys_loaded_at",H="$surveys_activated",N="ph_product_tours",j="$flag_call_reported",U="$flag_call_reported_session_id",V="$feature_flag_errors",W="$feature_flag_evaluated_at",G="$user_state",Q="$client_session_props",K="$capture_rate_limit",J="$initial_campaign_params",Y="$initial_referrer_info",X="$initial_person_info",Z="$epp",ee="__POSTHOG_TOOLBAR__",te="$posthog_cookieless",ie="$sdk_debug_extensions_init_method",re="$sdk_debug_extensions_init_time_ms",se="$sdk_debug_recording_script_not_loaded",ne="PostHog loadExternalDependency extension not found.",oe="on_reject",ae="always",le="anonymous",ue="identified",ce="identified_only",de="visibilitychange",he="beforeunload",_e="$pageview",pe="$pageleave",ge="$identify",ve="$groupidentify",fe="undefined"!=typeof window?window:void 0,me="undefined"!=typeof globalThis?globalThis:fe;"undefined"==typeof self&&(me.self=me),"undefined"==typeof File&&(me.File=function(){});var ye=null==me?void 0:me.navigator,be=null==me?void 0:me.document,we=null==me?void 0:me.location,Se=null==me?void 0:me.fetch,xe=null!=me&&me.XMLHttpRequest&&"withCredentials"in new me.XMLHttpRequest?me.XMLHttpRequest:void 0,Ee=null==me?void 0:me.AbortController,ke=null==me?void 0:me.CompressionStream,Pe=null==ye?void 0:ye.userAgent,Ie=null!=fe?fe:{};function Ce(){return!(!fe||!1===fe.navigator.onLine)}var Fe=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Te(e){return"string"==typeof e||e}function Re(e){return"string"==typeof e?e:void 0}var Le,Me=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.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}({}),Ae=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),$e=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],Oe=["token"],De="NativeGzipValidationError",qe=e=>e.length>=2&&31===e[0]&&139===e[1],Be=(e,t)=>e===Ae.GZipJS||t===Ae.GZipJS||"gzip"===t,ze=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),He=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=De,t},Ne=function(){var e=t((function*(e,t){18>e.size&&He("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());qe(i)&&8===i[2]||He("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Le)return Le;Le=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Le[e]=t>>>0}return Le})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&He("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&He("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function je(){return je=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=(new TextEncoder).encode(e),n=new 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]);return yield Ne(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),je.apply(this,arguments)}var Ue=["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"],Ve=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ue.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function We(e,t){return-1!==e.indexOf(t)}var Ge=function(e){return e.trim()},Qe=function(e){return e.replace(/^\$/,"")},Ke=Object.prototype,Je=Ke.hasOwnProperty,Ye=Ke.toString,Xe=Array.isArray||function(e){return"[object Array]"===Ye.call(e)},Ze=e=>"function"==typeof e,et=e=>e===Object(e)&&!Xe(e),tt=e=>{if(et(e)){for(var t in e)if(Je.call(e,t))return!1;return!0}return!1},it=e=>void 0===e,rt=e=>"[object String]"==Ye.call(e),st=e=>rt(e)&&0===e.trim().length,nt=e=>null===e,ot=e=>it(e)||nt(e),at=e=>"[object Number]"==Ye.call(e)&&e==e,lt=e=>at(e)&&e>0,ut=e=>"[object Boolean]"===Ye.call(e),ct=e=>e instanceof FormData,dt=e=>We($e,e),ht=e=>We(Oe,e);function _t(e){return null===e||"object"!=typeof e}function pt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function gt(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var vt=[!0,"true",1,"1","yes"],ft=e=>We(vt,e),mt=[!1,"false",0,"0","no"];function yt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),at(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),yt(s||i,t,i,r))}class bt{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=yt(e.bucketSize,0,100,e._logger),this._refillRate=yt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=yt(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 wt="Mobile",St="iOS",xt="Android",Et="Tablet",kt=xt+" "+Et,Pt="iPad",It="Apple",Ct=It+" Watch",Ft="Safari",Tt="BlackBerry",Rt="Samsung",Lt=Rt+"Browser",Mt=Rt+" Internet",At="Chrome",$t=At+" OS",Ot=At+" "+St,Dt="Internet Explorer",qt=Dt+" "+wt,Bt="Opera",zt=Bt+" Mini",Ht="Edge",Nt="Microsoft "+Ht,jt="Firefox",Ut=jt+" "+St,Vt="Nintendo",Wt="PlayStation",Gt="Xbox",Qt=xt+" "+wt,Kt=wt+" "+Ft,Jt="Windows",Yt=Jt+" Phone",Xt="Nokia",Zt="Ouya",ei="Generic",ti=ei+" "+wt.toLowerCase(),ii=ei+" "+Et.toLowerCase(),ri="Konqueror",si="Oculus Browser",ni="Vivaldi",oi="Yandex",ai="Whale",li="DuckDuckGo",ui="Pale Moon",ci="Waterfox",di="Brave",hi="Google Search App",_i="(\\d+(\\.\\d+)?)",pi=new RegExp("Version/"+_i),gi=new RegExp(Gt,"i"),vi=new RegExp(Wt+" \\w+","i"),fi=new RegExp(Vt+" \\w+","i"),mi=new RegExp(Tt+"|PlayBook|BB10","i"),yi={"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"},bi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?di:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&We(e,"GSA/")?hi:We(e," OPR/")&&We(e,"Mini")?zt:We(e," OPR/")?Bt:mi.test(e)?Tt:We(e,"IE"+wt)||We(e,"WPDesktop")?qt:We(e,"OculusBrowser")?si:We(e,Lt)?Mt:We(e,Ht)||We(e,"Edg/")?Nt:We(e,ni+"/")?ni:We(e,"YaBrowser/")?oi:We(e,ai+"/")?ai:We(e,li+"/")||We(e,"Ddg/")?li:We(e,"FBIOS")?"Facebook "+wt:We(e,"UCWEB")||We(e,"UCBrowser")?"UC Browser":We(e,"CriOS")?Ot:We(e,"CrMo")||We(e,At)?At:We(e,xt)&&We(e,Ft)?Qt:We(e,"FxiOS")?Ut:We(e.toLowerCase(),ri.toLowerCase())?ri:We(e,di+"/")?di:((e,t)=>t&&We(t,It)||function(e){return We(e,Ft)&&!We(e,At)&&!We(e,xt)}(e))(e,t)?We(e,wt)?Kt:Ft:We(e,"PaleMoon/")?ui:We(e,ci+"/")?ci:We(e,jt)?jt:We(e,"MSIE")||We(e,"Trident/")?Dt:We(e,"Gecko")?jt:"")},wi={[qt]:[new RegExp("rv:"+_i)],[Nt]:[new RegExp(Ht+"?\\/"+_i)],[At]:[new RegExp("("+At+"|CrMo)\\/"+_i)],[Ot]:[new RegExp("CriOS\\/"+_i)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+_i)],[Ft]:[pi],[Kt]:[pi],[Bt]:[new RegExp("(Opera|OPR)\\/"+_i)],[jt]:[new RegExp(jt+"\\/"+_i)],[Ut]:[new RegExp("FxiOS\\/"+_i)],[ri]:[new RegExp("Konqueror[:/]?"+_i,"i")],[Tt]:[new RegExp(Tt+" "+_i),pi],[Qt]:[new RegExp("android\\s"+_i,"i")],[Mt]:[new RegExp(Lt+"\\/"+_i)],[si]:[new RegExp("OculusBrowser\\/"+_i)],[ni]:[new RegExp(ni+"\\/"+_i)],[oi]:[new RegExp("YaBrowser\\/"+_i)],[ai]:[new RegExp(ai+"\\/"+_i)],[di]:[new RegExp(di+"\\/"+_i)],[li]:[new RegExp("(DuckDuckGo|Ddg)\\/"+_i)],[ui]:[new RegExp("PaleMoon\\/"+_i)],[ci]:[new RegExp(ci+"\\/"+_i)],[hi]:[new RegExp("GSA\\/"+_i)],[Dt]:[new RegExp("(rv:|MSIE )"+_i)],Mozilla:[new RegExp("rv:"+_i)]},Si=function(e,t,i,r){var s=bi(e,t,i,r),n=wi[s];if(it(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},xi=[[new RegExp(Gt+"; "+Gt+" (.*?)[);]","i"),e=>[Gt,e&&e[1]||""]],[new RegExp(Vt,"i"),[Vt,""]],[new RegExp(Wt,"i"),[Wt,""]],[mi,[Tt,""]],[new RegExp(Jt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Yt,""];if(new RegExp(wt).test(t)&&!/IEMobile\b/.test(t))return[Jt+" "+wt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=yi[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[Jt,r]}return[Jt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[St,[e[3],e[4],e[5]||"0"].join(".")]:[St,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=it(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+xt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+xt+")","i"),e=>e&&e[2]?[xt,[e[2],e[3],e[4]||"0"].join(".")]:[xt,""]],[/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/,[$t,""]],[/Linux|debian/i,["Linux",""]]],Ei=function(e){return fi.test(e)?Vt:vi.test(e)?Wt:gi.test(e)?Gt:new RegExp(Zt,"i").test(e)?Zt:new RegExp("("+Yt+"|WPDesktop)","i").test(e)?Yt:/iPad/.test(e)?Pt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Ct:mi.test(e)?Tt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Xt,"i").test(e)?Xt:/(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(wt).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)?xt:kt:new RegExp("(pda|"+wt+")","i").test(e)?ti:new RegExp(Et,"i").test(e)&&!new RegExp(Et+" pc","i").test(e)?ii:""},ki=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Pi(e,t){return"string"==typeof(i=e)&&ki.test(i)?e:t();var i}function Ii(e){return e?e.split("#")[0]:e}function Ci(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var Fi=e=>e instanceof Error,Ti={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}},Ri=Ti.info;function Li(e){if(ut(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(Xe(e))return{arrayValue:{values:e.map((e=>Li(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function Mi(e){var t=[];for(var i in e){var r=e[i];nt(r)||it(r)||t.push({key:i,value:Li(r)})}return t}function Ai(e,t){var r=e.level||"info",{text:s,number:n}=Ti[r]||Ri,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),ot(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),ot(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:Mi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),it(e.trace_flags)||(u.flags=e.trace_flags),u}function $i(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 Oi(e,t,i,r){return{resourceLogs:[{resource:{attributes:Mi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let Di=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:Ai(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=Xe(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(Me.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=Oi(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(Me.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(Me.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(Me.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return $i(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(Me.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(Me.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Ci((()=>{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(Me.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 Promise.race([t,new Promise((t=>Ci(t,e)))]):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=!1,r=i.flush(),s=new Promise((i=>Ci((()=>{t=!0,i()}),e)));try{yield Promise.race([r,s])}finally{t&&r.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 qi,Bi,zi;function Hi(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return zi&&i.length===Bi||(Bi=i.length,zi=i.reduce(((i,r)=>{qi||(qi={});var s=qi[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,qi[r]=[l,u];break}}return i}),{})),zi}}class Ni{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&&Xe(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:Hi(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 ji="?";function Ui(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?ji:i,in_app:!0};return it(r)||(n.lineno=r),it(s)||(n.colno=s),n}var Vi=(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]:ji,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Wi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Gi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Qi=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ki=(e,t)=>{var i=Wi.exec(e);if(i){var[,r,s,n]=i;return Ui(t,r,ji,+s,+n)}var o=Gi.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=Qi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Vi(o[1]||ji,o[2]);return Ui(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Ji=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Yi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Xi=(e,t)=>{var i=Ji.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Yi.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]||ji;return[n,s]=Vi(n,s),Ui(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Zi=/\(error: (.*)\)/;class er{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=rt(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 pt(e,"DOMException")}isDOMError(e){return pt(e,"DOMError")}}class tr{match(e){return(e=>e instanceof 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 ir{constructor(){}match(e){return pt(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var rr=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class sr{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(rr);return r&&(t=r[1],i=r[2]),[t,i]}}var nr=["fatal","error","warning","log","info","debug"];function or(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 ar{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return gt(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: "+or(e)}isSeverityLevel(e){return rt(e)&&!st(e)&&nr.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(Fi(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class lr{match(e){return gt(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+or(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class ur{match(e){return _t(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 cr{match(e){return pt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!gt(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 _t(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 dr="$message",hr="$timestamp",_r=new Set([dr,hr]),pr={enabled:!0,max_bytes:32768};function gr(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 vr{constructor(e){this._entries=[],this._totalBytes=0,this._config=gr(e)}setConfig(e){this._config=gr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t,i,r;try{r=[],t=null!==(i=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(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(t))return"[Circular]";r.push(t)}return t}})))&&void 0!==i?i:"null"}catch(e){return}try{var s=JSON.parse(t);if(!et(s))return;var n=s,o=n[dr],a=n[hr];if(!rt(o)||0===o.trim().length)return;if(!rt(a)&&!at(a))return;return{step:n,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(!at(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var mr=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(fe&&(n.DEBUG||Ie.POSTHOG_DEBUG||i)&&!it(fe.console)&&fe.console){for(var r=("__rrweb_original__"in fe.console[t]?fe.console[t].__rrweb_original__:fe.console[t]),s=arguments.length,o=new Array(s>1?s-1:0),a=1;s>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)=>mr(e+" "+t,i)};return r},yr=mr("[PostHog.js]"),br=yr.createLogger;function wr(e,t){Xe(e)&&e.forEach(t)}function Sr(e,t){if(!ot(e))if(Xe(e))e.forEach(t);else if(ct(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)Je.call(e,i)&&t(e[i],i)}var xr=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 Er(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 kr=function(e){try{return e()}catch(e){return}},Pr=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){yr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),yr.critical(e)}}},Ir=function(e){var t={};return Sr(e,(function(e,i){(rt(e)&&e.length>0||at(e))&&(t[i]=e)})),t};var Cr=["herokuapp.com","vercel.app","netlify.app"];function Fr(e){var t=null==e?void 0:e.hostname;if(!rt(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Cr)if(i===r)return!1;return!0}function Tr(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function Rr(e){return"ph_toolbar_internal"===e.name}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return at(e)&&isFinite(e)&&Math.floor(e)===e});class Lr{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/Math.pow(2,8),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 Lr(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 Lr(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 Mr{constructor(){this._timestamp=0,this._counter=0,this._random=new Or}generate(){var e=this.generateOrAbort();if(it(e)){this._timestamp=0;var t=this.generateOrAbort();if(it(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}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 Lr.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())}}var Ar,$r=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};fe&&!it(fe.crypto)&&crypto.getRandomValues&&($r=e=>crypto.getRandomValues(e));class Or{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||($r(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Dr=()=>qr().toString(),qr=()=>(Ar||(Ar=new Mr)).generate(),Br="",zr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Hr={_is_supported:()=>!!be,_error(e){yr.error("cookieStore error: "+e)},_get(e){if(be){try{for(var t=e+"=",i=be.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}},_parse(e){var t;try{t=JSON.parse(Hr._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(!be)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=be),Br)return Br;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_"+Dr();!Br&&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",Br=n)}return Br}(e);if(!i){var r=(e=>{var t=e.match(zr);return t?t[0]:""})(e);r!==i&&yr.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(be.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&&yr.warn("cookieStore warning: large cookie, len="+u.length),be.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=be&&be.cookie)try{Hr._set(e,"",-1,t)}catch(e){return}}},Nr=null,jr={_is_supported(){if(!nt(Nr))return Nr;var e=!0;if(it(fe))e=!1;else try{var t="__mplssupport__";jr._set(t,"xyz"),'"xyz"'!==jr._get(t)&&(e=!1),jr._remove(t)}catch(t){e=!1}return e||yr.error("localStorage unsupported; falling back to cookie store"),Nr=e,e},_error(e){yr.error("localStorage error: "+e)},_get(e){try{return null==fe?void 0:fe.localStorage.getItem(e)}catch(e){jr._error(e)}return null},_parse(e){try{return JSON.parse(jr._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==fe||fe.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){jr._error(e)}return!1},_remove(e){try{null==fe||fe.localStorage.removeItem(e)}catch(e){jr._error(e)}}},Ur=[a,"distinct_id",P,I,Z,X,G],Vr={},Wr={_is_supported:()=>!0,_error(e){yr.error("memoryStorage error: "+e)},_get:e=>Vr[e]||null,_parse:e=>Vr[e]||null,_set:(e,t)=>(Vr[e]=t,!0),_remove(e){delete Vr[e]}},Gr=null,Qr={_is_supported(){if(!nt(Gr))return Gr;if(Gr=!0,it(fe))Gr=!1;else try{var e="__support__";Qr._set(e,"xyz"),'"xyz"'!==Qr._get(e)&&(Gr=!1),Qr._remove(e)}catch(e){Gr=!1}return Gr},_error(e){yr.error("sessionStorage error: ",e)},_get(e){try{return null==fe?void 0:fe.sessionStorage.getItem(e)}catch(e){Qr._error(e)}return null},_parse(e){try{return JSON.parse(Qr._get(e))||null}catch(e){}return null},_set(e,t){try{return null==fe||fe.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Qr._error(e)}return!1},_remove(e){try{null==fe||fe.sessionStorage.removeItem(e)}catch(e){Qr._error(e)}}};class Kr{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===ae||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===oe}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{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){var e=this._storage._get(this._storageKey);return ft(e)?1:We(mt,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?jr:Hr;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?Hr:jr;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(ft(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==ye?void 0:ye.doNotTrack,null==ye?void 0:ye.msDoNotTrack,Ie.doNotTrack].some((e=>ft(e)))}}function Jr(e,t){var i,r=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!Ze(r))return t;try{var s=r(t);return rt(s)&&s?s:t}catch(e){return yr.error("Error in get_current_url, falling back to window.location.href",e),t}}var Yr=1,Xr=3,Zr=11;function es(e){return e instanceof Element&&(e.id===ee||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function ts(e){return!!e&&e.nodeType===Yr}function is(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function rs(e){return!!e&&e.nodeType===Xr}function ss(e){return!!e&&e.nodeType===Zr&&ts(e.host)}function ns(e){return e?Ge(e).split(/\s+/):[]}function os(e,t){var i=function(e){var t,i=null==fe||null==(t=fe.location)?void 0:t.href;return it(i)?void 0:Jr(e,i)}(t);return!!(i&&e&&e.some((e=>i.match(e))))}function as(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 ns(t)}function ls(e){return ot(e)?null:Ge(e).split(/(\s+)/).filter((e=>Rs(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function us(e){var t="";return xs(e)&&!Es(e)&&e.childNodes&&e.childNodes.length&&Sr(e.childNodes,(function(e){var i;rs(e)&&e.textContent&&(t+=null!==(i=ls(e.textContent))&&void 0!==i?i:"")})),Ge(t)}function cs(e){return it(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var ds=["a","button","form","input","select","textarea","label"];function hs(e,t){if(it(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 _s(e){var t=e.parentNode;return!(!t||!ts(t))&&t}var ps=[".ph-no-autocapture","[data-ph-no-autocapture]"],gs=["next","previous","prev",">","<"],vs=[...gs,"+","-","−","–"],fs=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,ms=[".ph-no-rageclick",".ph-no-capture"],ys=["","text","search","email","password","url","tel","number"];function bs(e,t){if(!fe||ws(e))return!1;var i,r,s,n,o;if(ut(t)?(i=!!t&&ms,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:ms,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||!ts(e))&&(!!is(e,"textarea")||(is(e,"input")?We(ys,(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{targetElementList:a}=Ss(e,!1);return!function(e,t){if(!1===e||it(e))return!1;var i;if(!0===e)i=gs;else{if(!Xe(e))return!1;if(e.length>10)return yr.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{safeText:t,ariaLabel:r}=e;return i.some((e=>fs(t,e)||fs(r,e)))}))}(r,a.map((e=>{var t;return{safeText:us(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!hs(a,i)}var ws=e=>!e||is(e,"html")||!ts(e),Ss=(e,t)=>{if(!fe||ws(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!is(s,"body");)if(ss(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=_s(s);if(!n)break;if(t||ds.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=fe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}catch(e){}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function xs(e){for(var t=e;t.parentNode&&!is(t,"body");t=t.parentNode){var i=as(t);if(We(i,"ph-sensitive")||We(i,"ph-no-capture"))return!1}if(We(as(e),"ph-include"))return!0;var r=e.type||"";if(rt(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!rt(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function Es(e){return!!(is(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||is(e,"select")||is(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var ks="(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})",Ps=new RegExp("^(?:"+ks+")$"),Is=new RegExp(ks),Cs="\\d{3}-?\\d{2}-?\\d{4}",Fs=new RegExp("^("+Cs+")$"),Ts=new RegExp("("+Cs+")");function Rs(e,t){if(void 0===t&&(t=!0),ot(e))return!1;if(rt(e)){if(e=Ge(e),(t?Ps:Is).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Fs:Ts).test(e))return!1}return!0}function Ls(e){var t=us(e);return Rs(t=(t+" "+Ms(e)).trim())?t:""}function Ms(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Sr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=us(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Ms(e)).trim())}catch(e){yr.error("[AutoCapture]",e)}})),t}function As(e){return e.replace(/"|\\"/g,'\\"')}function $s(e){var t=e.attr__class;return t?Xe(t)?t:ns(t):void 0}var Os=br("[Dead Clicks]"),Ds=()=>!0,qs=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(f)),r=e.instance.config.capture_dead_clicks;return ut(r)?r:!!et(r)||i};class Bs{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[f]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Os.error("failed to load script",t):e()}))}_start(){var e;if(be){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Ie.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=et(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Ie.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(be),Os.info("starting...")}}else Os.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Os.info("stopping..."))}}var zs=br("[SegmentIntegration]");var Hs="posthog-js";function Ns(e,t){var{organization:r,projectId:s,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,d,h;if("*"!==o&&!o.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==(l=t.exception)?void 0:l.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==(u=g[0])?void 0:u.value)||t.message,$exception_type:null==(c=g[0])?void 0:c.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 r&&s&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class js{constructor(e,t,i,r,s,n){this.name=Hs,this.setupOnce=function(o){o(Ns(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Us{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(yr.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==fe?void 0:fe.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{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(it(n)||it(o)||it(a)||it(l)||it(u)||it(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?yt(o/n,0,1,yr):1,h=n>1?yt(a/n,0,1,yr):1,_=l>1?yt(u/l,0,1,yr):1,p=l>1?yt(c/l,0,1,yr):1;r=xr(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 Vs=["flags","surveys"],Ws={[o]:{exposure:"hidden"},[u]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[c]:{exposure:"hidden"},[d]:{exposure:"event"},[h]:{exposure:"hidden"},[_]:{exposure:"event"},[p]:{exposure:"hidden"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"event"},[m]:{exposure:"hidden"},[y]:{exposure:"event"},[b]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[P]:{exposure:"hidden"},[I]:{exposure:"event"},[w]:{exposure:"event",shouldSkipFromEventProperties:e=>nt(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(!et(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[F]:{exposure:"event",storageGroup:"flags"},[T]:{exposure:"hidden"},[R]:{exposure:"hidden",storageGroup:"flags"},[L]:{exposure:"event",storageGroup:"flags"},[M]:{exposure:"event",storageGroup:"flags",volatile:!0},[A]:{exposure:"event"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[q]:{exposure:"hidden"},[B]:{exposure:"hidden",storageGroup:"surveys"},[z]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[H]:{exposure:"event"},[N]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[j]:{exposure:"hidden"},[U]:{exposure:"hidden"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[G]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[S]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[k]:{exposure:"event"},[ie]:{exposure:"event"},[re]:{exposure:"event"},[se]:{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"}},Gs=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Qs=e=>{var t=Ws[e];if(t)return t;for(var[i,r]of Gs)if(0===e.indexOf(i))return r},Ks=e=>{var t=null==be?void 0:be.createElement("a");return it(t)?null:(t.href=e,t)},Js=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(!Xe(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){yr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ys=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("=");Xe(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},Xs=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Zs="https?://(.*)",en=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],tn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...en],rn="<masked>",sn=["li_fat_id"];function nn(e,t,i){if(!be)return{};var r,s=t?[...en,...i||[]]:[],n=on(Ys(be.URL,s,rn),e),o=(r={},Sr(sn,(function(e){var t=Hr._get(e);r[e]=t||null})),r);return xr(o,n)}function on(e,t){var i=tn.concat(t||[]),r={};return Sr(i,(function(t){var i=Js(e,t);r[t]=i||null})),r}function an(e){var t=function(e){return e?0===e.search(Zs+"google.([^/?]*)")?"google":0===e.search(Zs+"bing.com")?"bing":0===e.search(Zs+"yahoo.com")?"yahoo":0===e.search(Zs+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!nt(t)){r.$search_engine=t;var s=be?Js(be.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function ln(){return navigator.language||navigator.userLanguage}var un="$direct";function cn(){return(null==be?void 0:be.referrer)||un}function dn(e,t,i){void 0===i&&(i=!1);var r=e?[...en,...t||[]]:[],s=i?Ii(null==we?void 0:we.href):null==we?void 0:we.href,n=null==s?void 0:s.substring(0,1e3);return{r:cn().substring(0,1e3),u:n?Ys(n,r,rn):void 0}}function hn(e,t){var i;void 0===t&&(t=!1);var{r:r,u:s}=e,n=t?Ii(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==un?un:null==(i=Ks(r))?void 0:i.host};if(n){o.$current_url=n;var a=Ks(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=on(n);xr(o,l)}if(r){var u=an(r);xr(o,u)}return o}function _n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function pn(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var gn={flags:W,surveys:z},vn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],fn="main";class mn{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_saved=!1,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&&yr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),fe){var s=()=>this.flush();Tr(fe,"beforeunload",s,{capture:!1}),Tr(fe,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return at(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===vn.indexOf(e.persistence.toLowerCase())&&(yr.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=[...Ur,...e];return i({},jr,{_parse(e){try{var i={};try{i=Hr._parse(e)||{}}catch(e){}var r,s=JSON.parse(jr._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];nt(a)||""===a||(n[o]=a)}r=xr(s,n)}else r=xr(i,s);return jr._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=jr._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&Hr._set(e,l,i,s,n,o)}catch(e){jr._error(e)}return a},_remove(e,t){try{null==fe||fe.localStorage.removeItem(e),Hr._remove(e,t)}catch(e){jr._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&jr._is_supported()?(t=jr,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&Qr._is_supported()?t=Qr:"memory"===n?t=Wr:"cookie"===n?t=Hr:r._is_supported()?(t=r,s=!0):t=Hr,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[W];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return Sr(this.props,((t,i)=>{var r=Qs(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===C?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&xr(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=xr({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of Vs){var t=jr._parse(this._groupEntryName(e));if(t&&!tt(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||xr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=Qs(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=gn[e];if(!i)return!1;var r=t[i],s=this.props[i];return at(r)&&at(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=Qs(e))?void 0:t.storageGroup:void 0,r=i?jr._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?it(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){it(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,fn))}_writeNowSplit(){var{main:e,groups:t}=this._partitionProps();for(var i of(this._writeEntry(this._storage,this._name,e,fn),Vs)){var r,s=t[i];(!tt(s)||null!=(r=this._slotState[i])&&r.persisted)&&this._writeEntry(jr,this._groupEntryName(i),s,i)}}_partitionProps(){var e={},t={};for(var i of Vs)t[i]={};return Sr(this.props,((i,r)=>{var s,n=null==(s=Qs(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===fn)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return Sr(e,((e,t)=>{var r;i[t]=null!=(r=Qs(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===fn||s.dirty||it(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!==fn&&(s.persisted=!0),it(n)||(s.fingerprint=n)):this._config.debug&&yr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var{keepGroupEntries:t=!1}=void 0===e?{}:e;if(it(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!t&&this._ownsSplitStorage)for(var i of Vs)jr._remove(this._groupEntryName(i));t?delete this._slotState[fn]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(et(e)){it(t)&&(t="None"),this._expire_days=it(i)?this._default_expiry:i;var r=!1;if(Sr(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(et(e)){this._expire_days=it(t)?this._default_expiry:t;var i=!1;if(Sr(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(){if(!this._campaign_params_saved){var e=nn(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);tt(Ir(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==be?void 0:be.referrer)?an(e):{})}update_referrer_info(){var e;this.register_once({$referrer:cn(),$referring_domain:null!=be&&be.referrer&&(null==(e=Ks(be.referrer))?void 0:e.host)||un},void 0)}set_initial_person_info(){this.props[J]||this.props[Y]||this.register_once({[X]:dn(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={};Sr([Y,J],(t=>{var i=this.props[t];i&&Sr(i,(function(t,i){e["$initial_"+Qe(i)]=t}))}));var t=this.props[X];if(t){var i=function(e,t){void 0===t&&(t=!1);var i=hn(e,t),r={};return Sr(i,(function(e,t){r["$initial_"+Qe(t)]=e})),r}(t,this._config.disable_capture_url_hashes);xr(e,i)}return e}safe_merge(e){return Sr(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[c]||{};i[e]=t,this._setProp(c,i),this.save()}remove_event_timer(e){var t=this.props[c]||{},i=t[e];return it(i)||(delete t[e],this._setProp(c,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=Qs(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=Qs(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}var yn="events",bn="cancelEvents",wn="survey shown",Sn="survey dismissed",xn="survey sent",En="popover",kn=br("[RateLimiter]");class Pn{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=>{kn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void kn.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{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(K))&&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;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(K,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var In=br("[RemoteConfig]");class Cn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Ie._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Ie.__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(t){e(t.json)}})}load(){try{if(this.remoteConfig)return In.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void In.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return In.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){In.error("Error loading remote config",e)}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){!this._instance._shouldDisableFlags()&&be&&"hidden"!==be.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){var t;e||In.error("Failed to fetch remote config from PostHog."),this._instance._onRemoteConfig(null!=e?e:{}),!1!==(null==e?void 0:e.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(t=this._instance.featureFlags)||t.ensureFlagsLoaded())}}var Fn="gzip-js",Tn="base64",Rn=Uint8Array,Ln=Uint16Array,Mn=Uint32Array,An=new Rn([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]),$n=new Rn([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]),On=new Rn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dn=function(e,t){for(var i=new Ln(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Mn(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]},qn=Dn(An,2),Bn=qn[1];qn[0][28]=258,Bn[258]=28;for(var zn=Dn($n,0)[1],Hn=new Ln(32768),Nn=0;32768>Nn;++Nn){var jn=(43690&Nn)>>>1|(21845&Nn)<<1;Hn[Nn]=((65280&(jn=(61680&(jn=(52428&jn)>>>2|(13107&jn)<<2))>>>4|(3855&jn)<<4))>>>8|(255&jn)<<8)>>>1}var Un=function(e,t,i){for(var r=e.length,s=0,n=new Ln(t);r>s;++s)++n[e[s]-1];var o,a=new Ln(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Ln(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[Hn[d]>>>l]=u}else for(o=new Ln(r),s=0;r>s;++s)o[s]=Hn[a[e[s]-1]++]>>>15-e[s];return o},Vn=new Rn(288);for(Nn=0;144>Nn;++Nn)Vn[Nn]=8;for(Nn=144;256>Nn;++Nn)Vn[Nn]=9;for(Nn=256;280>Nn;++Nn)Vn[Nn]=7;for(Nn=280;288>Nn;++Nn)Vn[Nn]=8;var Wn=new Rn(32);for(Nn=0;32>Nn;++Nn)Wn[Nn]=5;var Gn=Un(Vn,9,0),Qn=Un(Wn,5,0),Kn=function(e){return(e/8>>0)+(7&e&&1)},Jn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Ln?Ln:e instanceof Mn?Mn:Rn)(i-t);return r.set(e.subarray(t,i)),r},Yn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},Xn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Zn=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 Rn(0),0];if(1==s){var o=new Rn(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 Ln(h+1),p=eo(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 Rn(_),p]},eo=function(e,t,i){return-1==e.s?Math.max(eo(e.l,t,i+1),eo(e.r,t,i+1)):t[e.s]=i},to=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ln(++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]},io=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},ro=function(e,t,i){var r=i.length,s=Kn(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)},so=function(e,t,i,r,s,n,o,a,l,u,c){Yn(t,c++,i),++s[256];for(var d=Zn(s,15),h=d[0],_=d[1],p=Zn(n,15),g=p[0],v=p[1],f=to(h),m=f[0],y=f[1],b=to(g),w=b[0],S=b[1],x=new Ln(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=Zn(x,7),P=k[0],I=k[1],C=19;C>4&&!P[On[C-1]];--C);var F,T,R,L,M=u+5<<3,A=io(s,Vn)+io(n,Wn)+o,O=io(s,h)+io(n,g)+o+14+3*C+io(x,P)+(2*x[16]+3*x[17]+7*x[18]);if(A>=M&&O>=M)return ro(t,c,e.subarray(l,l+u));if(Yn(t,c,1+(A>O)),c+=2,A>O){F=Un(h,_,0),T=h,R=Un(g,v,0),L=g;var D=Un(P,I,0);for(Yn(t,c,y-257),Yn(t,c+5,S-1),Yn(t,c+10,C-4),c+=14,E=0;C>E;++E)Yn(t,c+3*E,P[On[E]]);c+=3*C;for(var q=[m,w],B=0;2>B;++B){var z=q[B];for(E=0;z.length>E;++E)Yn(t,c,D[H=31&z[E]]),c+=P[H],H>15&&(Yn(t,c,z[E]>>>5&127),c+=z[E]>>>12)}}else F=Gn,T=Vn,R=Qn,L=Wn;for(E=0;a>E;++E)if(r[E]>255){var H;Xn(t,c,F[257+(H=r[E]>>>18&31)]),c+=T[H+257],H>7&&(Yn(t,c,r[E]>>>23&31),c+=An[H]);var N=31&r[E];Xn(t,c,R[N]),c+=L[N],N>3&&(Xn(t,c,r[E]>>>5&8191),c+=$n[N])}else Xn(t,c,F[r[E]]),c+=T[r[E]];return Xn(t,c,F[256]),c+T[256]},no=new Mn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),oo=function(){for(var e=new Mn(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),ao=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function lo(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=oo[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 Rn(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=ro(l,u,e.subarray(c,d)):(l[c]=!0,u=ro(l,u,e.subarray(c,o)))}else{for(var h=no[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Ln(32768),f=new Ln(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 Mn(25e3),S=new Ln(288),x=new Ln(32),E=0,k=0,P=(c=0,0),I=0,C=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=I){var L=o-c;if((E>7e3||P>24576)&&L>423){u=so(e,l,0,w,S,x,k,P,C,c-C,u),P=E=k=0,C=c;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)x[M]=0}var A=2,O=0,D=p,q=T-R&32767;if(L>2&&F==b(c-q))for(var B=Math.min(_,L)-1,z=Math.min(32767,c),H=Math.min(258,L);z>=q&&--D&&T!=R;){if(e[c+A]==e[c+A-q]){for(var N=0;H>N&&e[c+N]==e[c+N-q];++N);if(N>A){if(A=N,O=q,N>B)break;var j=Math.min(q,N-2),U=0;for(M=0;j>M;++M){var V=c-q+M+32768&32767,W=V-v[V]+32768&32767;W>U&&(U=W,R=V)}}}q+=(T=R)-(R=v[T])+32768&32767}if(O){w[P++]=268435456|Bn[A]<<18|zn[O];var G=31&Bn[A],Q=31&zn[O];k+=An[G]+$n[Q],++S[257+G],++x[Q],I=c+A,++E}else w[P++]=e[c],++S[e[c]]}}u=so(e,l,!0,w,S,x,k,P,C,c-C,u)}return Jn(a,0,r+Kn(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&&ao(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),ao(u,c-8,i.d()),ao(u,c-4,r),u}var uo=!!xe||!!Se,co="text/plain",ho=!1,_o=(e,t)=>{var[i,r]=e.split("#"),[s,n]=i.split("?");if(!n)return e;var o=n.split("&").filter((e=>e.split("=")[0]!==t)).join("&");return s+(o?"?"+o:"")+(r?"#"+r:"")},po=function(e,t,r){var s;void 0===r&&(r=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(s=null==o?void 0:o.split("&").map((e=>{var t,[i,s]=e.split("="),n=r&&null!==(t=a[i])&&void 0!==t?t:s;return delete a[i],i+"="+n})))&&void 0!==s?s:[],u=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return Sr(e,(function(e,t){it(e)||it(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)}(a);return u&&l.push(u),n+"?"+l.join("&")},go=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),vo=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===Fn){var r=lo(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Rn(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 Rn(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 Jn(r,0,s)}(go(t)),{mtime:0});return{contentType:co,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Tn){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(go(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:go(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=go(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},fo=e=>{var t,r,s=()=>({url:_o(e.url,"compression"),encodedBody:vo(i({},e,{compression:void 0,_encodedBody:void 0}))});try{t=vo(e)}catch(t){if(Be(e.compression,Js(e.url,"compression")))return yr.error("Failed to gzip request body, sending uncompressed payload",t),s();throw t}return t&&Be(e.compression,Js(e.url,"compression"))&&!((r=t.body)instanceof ArrayBuffer?qe(new Uint8Array(r)):ArrayBuffer.isView(r)&&qe(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(ho=!0,s()):{url:e.url,encodedBody:t}},mo=e=>{try{return fo(e)}catch(t){return yr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},yo=function(){var e=t((function*(e){var t=go(e.data),r=yield function(e,t,i){return je.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:co,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),bo=(e,t)=>po(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),wo=[];Se&&wo.push({transport:"fetch",method(e){var t,r=mo(e);if(r){var{url:s,encodedBody:n}=r,{contentType:o,body:a,estimatedSize:l}=null!=n?n:{},u=new Headers;Sr(e.headers,(function(e,t){u.append(t,e)})),o&&u.append("Content-Type",o);var c=null,d=!1;if(Ee){var h=new Ee;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)}}Se(s,i({method:(null==e?void 0:e.method)||"GET",headers:u,keepalive:"POST"===e.method&&52428.8>(l||0),body:a,signal:null==(t=c)?void 0:t.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){yr.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{d&&"AbortError"===(null==t?void 0:t.name)?yr.warn(t):yr.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}}),xe&&wo.push({transport:"XHR",method(e){var t=mo(e);if(t){var i=new xe,{url:r,encodedBody:s}=t;i.open(e.method||"GET",r,!0);var{contentType:n,body:o}=null!=s?s:{};Sr(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!=ye&&ye.sendBeacon&&wo.push({transport:"sendBeacon",method(e){try{var{url:t,encodedBody:i}=fo(e),{contentType:r,body:s}=null!=i?i:{};if(!s)return;var n=s instanceof Blob?s:new Blob([s],{type:r});ye.sendBeacon(t,n)}catch(e){}}});var So=3e3;class xo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=yt((null==t?void 0:t.flush_interval_ms)||So,250,5e3,yr.createLogger("flush interval"),So),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&&Xe(i.data)&&Sr(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){yr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Sr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;it(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Eo=["retriesPerformedSoFar"];class ko{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!it(fe)&&"onLine"in fe.navigator&&(this._areWeOnline=fe.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Tr(fe,"online",this._onlineListener),Tr(fe,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,Eo);lt(t)&&(s.url=po(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&&yr.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)"),yr.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{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,it(fe)||(this._onlineListener&&(fe.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(fe.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){yr.error(e)}this._queue=[]}}class Po{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(){Tr(fe,"scroll",this._updateScrollData,{capture:!0}),Tr(fe,"scrollend",this._updateScrollData,{capture:!0}),Tr(fe,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==fe?void 0:fe.document.documentElement;var e=Xe(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==fe?void 0:fe.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 fe?"y"===e?fe.scrollY||fe.pageYOffset||fe.document.documentElement.scrollTop||0:fe.scrollX||fe.pageXOffset||fe.document.documentElement.scrollLeft||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}}var Io=e=>dn(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 Co{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({[Q]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Io,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Q]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?hn(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 Sr(Ir(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Qe(i)]=t})),e}}class Fo{constructor(){this._events={}}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)}}var To=br("[SessionId]");class Ro{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 Fo,this._sessionHasBeenIdleTooLong=(e,t)=>!(!lt(e)||!lt(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===ae)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||Dr,this._windowIdGenerator=i||Dr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*yt(this._config.session_idle_timeout_seconds||1800,60,36e3,To.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=Qr._parse(this._window_id_storage_key),o=Qr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Qr._remove(this._window_id_storage_key),Qr._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){To.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return it(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&&Qr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Qr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Qr._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!nt(t)&&!nt(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({[P]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return lt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(P):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!nt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[P]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var[e]=this._getSessionId(),t=lt(e)?e:0,i=lt(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[P];return Xe(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&&fe&&(fe.removeEventListener(he,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Qr._remove(this._primary_window_exists_storage_key)},Tr(fe,he,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===ae)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[,r,s]=this._getSessionId(),n=this._freshestActivityTimestamp(),o=this._getWindowId(),a=lt(s)&&Math.abs(i-s)>864e5,l=!1,u=!1,c=!r,d=r,h=!c&&!e&&this._sessionHasBeenIdleTooLong(i,n);h&&((h=this._isSessionIdleAfterCrossTabRefresh(i))||To.info("cross-tab refresh kept the session alive",{sessionId:r}),[,r,s]=this._getSessionId()),c||h||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),To.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:a}}),s=i,l=!0):(o||(o=this._windowIdGenerator(),l=!0),(u=r!==d)&&(To.info("adopted cross-tab session id",{sessionId:r,windowId:o}),l=!0));var _=lt(n)&&e&&!a?n:i,p=lt(s)?s:(new Date).getTime();this._setWindowId(o),this._setSessionId(r,_,p),e||this._resetIdleTimer();var g={noSessionId:c,activityTimeout:h,sessionPastMaximumLength:a,crossTabAdoption:u};return l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,g))),{sessionId:r,windowId:o,sessionStartTimestamp:p,changeReason:l?g:void 0,lastActivityTimestamp:n}}_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 Lo=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Ve(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Ve(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function Mo(){return(Mo=t((function*(){var e=null==ye?void 0:ye.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return rt(i)&&i.length>0?i:void 0}catch(e){return void yr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}))).apply(this,arguments)}var Ao=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 $o(e,t,i){return go({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Oo={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=>Ao(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Ao(t,e))))),icontains:(e,t)=>t.map(Do).some((t=>e.map(Do).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Do).every((t=>e.map(Do).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)))}))},Do=e=>e.toLowerCase();function qo(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(it(s)||nt(s))return!1;var n=[String(s)],o=Oo[r.operator];return!!o&&o(r.values,n)}))}var Bo="custom",zo="i.posthog.com",Ho=/^\/static\//;class No{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("."+zo,".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":Bo),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(Ho.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===Bo)return this.apiHost+t;var r=zo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var jo=br("[Surveys]"),Uo="seenSurvey_",Vo=e=>{try{var t=(e=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Uo,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){jo.error("Failed to persist survey seen state",e)}},Wo=["popover","widget","api"],Go={ignoreConditions:!1,ignoreDelay:!1,displayType:En},Qo=br("[PostHog ExternalIntegrations]"),Ko={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Jo{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return Qo.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=Ie.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(Ko[t],(()=>{var i;null==(i=Ie.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=Ie.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=Ie.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var Yo,Xo={},Zo=0,ea=()=>{},ta='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ia="Surveys module not available",ra="sanitize_properties is deprecated. Use before_send instead",sa="Invalid value for property_denylist config: ",na="posthog",oa=!uo&&-1===(null==Pe?void 0:Pe.indexOf("MSIE"))&&-1===(null==Pe?void 0:Pe.indexOf("Mozilla")),aa=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:Fr(null==be?void 0:be.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:ea,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:we&&rt(null==we?void 0:we.search)&&-1!==we.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==fe||null==(t=fe.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){yr.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:ce,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:So},error_tracking:{},_onCapture:ea},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:vs,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))},la=[["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"]],ua=e=>{var t={};for(var[i,r]of la)it(e[i])||(t[r]=e[i]);var s=xr({},t,e),n=e.__preview_external_dependency_versioned_paths;return it(n)||(it(e.strict_script_versioning)&&(s.strict_script_versioning=!!n),rt(n)&&it(e.asset_host)&&(s.asset_host=n)),Xe(e.property_blacklist)&&(it(e.property_denylist)?s.property_denylist=e.property_blacklist:Xe(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:yr.error(sa+e.property_denylist)),s};class ca{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){yr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class da{_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===ae||this.config.cookieless_mode===oe&&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 ca,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new Fo,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=aa(),this.SentryIntegration=js,this.sentryIntegration=e=>function(e,t){var i=Ns(e,t);return{name:Hs,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 Po(this),this.pageViewManager=new Us(this),this.rateLimiter=new Pn(this),this.requestRouter=new No(this),this.consent=new Kr(this),this.externalIntegrations=new Jo(this);var t=null!==(e=da.__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.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var r=rt(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=rt(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>yr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==na){var r,s=null!==(r=Xo[i])&&void 0!==r?r:new da;return s._init(e,t,i),Xo[i]=s,Xo[na][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;void 0===t&&(t={});var a=rt(e)?e.trim():"";if(!a)return yr.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 console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},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 u=aa(t.defaults),c=ua(t),d=xr({},u,c,{name:r,token:a});et(u.rageclick)&&et(c.rageclick)&&(d.rageclick=xr({},u.rageclick,c.rageclick)),et(u.session_recording)&&et(c.session_recording)&&(d.session_recording=xr({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&yr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Fn;var h=this._is_persistence_disabled();this.persistence=new mn(this.config,h),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new mn(i({},this.config,{persistence:"sessionStorage"}),h,!1);var _=i({},this.persistence.props),p=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new xo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new ko(this),this.__request_queue=[];var g=this._inCookielessMode();if(g||(this.sessionManager=new Ro(this),this.sessionPropsManager=new Co(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(yr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(g)}),0)):(yr.info("Initializing extensions synchronously"),this._initExtensions(g)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&yr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:_,s:p}),!this.config.identity_distinct_id||null!=(s=t.bootstrap)&&s.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 v=t.bootstrap.distinctID,f=this.get_distinct_id(),m=this.persistence.get_property(G);if(t.bootstrap.isIdentifiedID&&null!=f&&f!==v&&m===le)this.identify(v);else if(t.bootstrap.isIdentifiedID&&null!=f&&f!==v&&m===ue)yr.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 y=this.config.get_device_id(Dr()),b=t.bootstrap.isIdentifiedID?y:v;this.persistence.set_property(G,t.bootstrap.isIdentifiedID?ue:le),this.register({distinct_id:v,$device_id:b})}}if(g)this.register_once({distinct_id:te,$device_id:null},"");else if(!this.get_distinct_id()){var w=this.config.get_device_id(Dr());this.register_once({distinct_id:w,$device_id:w},""),this.persistence.set_property(G,le)}return Tr(fe,"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()||Dr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(G,ue)),t()},s=i.user();"then"in s&&Ze(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{"undefined"!=typeof Promise&&Promise.resolve||zs.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()||(zs.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(zs.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,_e),identify:e=>t(e,ge),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Ze(this.config._onCapture)&&this.config._onCapture!==ea&&(yr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&yr.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 Mo.apply(this,arguments)}().then((e=>{e&&this.register({[l]:e})})).catch(ea),this}_initExtensions(e){var t,r,s,n,o,a,l,u=performance.now(),c=i({},da.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new c.featureFlags(this)),c.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new c.exceptions(this)),c.historyAutocapture&&this._extensions.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this._extensions.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this._extensions.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this._extensions.push(this.autocapture=new c.autocapture(this)),c.surveys&&this._extensions.push(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new c.surveys(this)),c.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new c.logs(this)),c.conversations&&this._extensions.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new c.conversations(this)),c.productTours&&this._extensions.push(this.productTours=new c.productTours(this)),c.heatmaps&&this._extensions.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this._extensions.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,qs)),c.toolbar&&this._extensions.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new c.toolbar(this)),c.experiments&&this._extensions.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new c.experiments(this)),this._extensions.forEach((e=>{e.initialize&&d.push((()=>{null==e.initialize||e.initialize()}))})),d.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(d,u)}_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){yr.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[ie]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[re]:r}),this.config.__preview_deferred_init_extensions&&yr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!be||!be.body)return yr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=We(e.supportedCompression,Fn)?Fn:We(e.supportedCompression,Tn)?Tn:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:ce}),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){yr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=we&&we.hostname){var e=we.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 Cn(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()&&wr(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;null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(pe),null==(t=this.logs)||t.flushLogs("sendBeacon"),null==(i=this._requestQueue)||i.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(pe,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?oa?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,(it(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,n.url=bo(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=wo.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:s.method)&&void 0!==r?r:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===Fn&&ke&&"undefined"!=typeof Promise&&!ho?yo(n).then((e=>{l(e)})).catch((t=>{if(ze(t))return ho=!0,void l(i({},n,{compression:void 0,url:bo(e.url,void 0)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return ze(e)||t===De})(t)&&(ho=!0),l(n)})):l(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){Zo++;try{var t,i=[],r=[],s=[];wr(e,(e=>{if(e)if(Xe(t=e[0]))s.push(e);else if(Ze(e))try{e.call(this)}catch(t){yr.error("Error executing queued PostHog call",e,t)}else Xe(e)&&"alias"===t?i.push(e):Xe(e)&&-1!==t.indexOf("capture")&&Ze(this[t])?s.push(e):r.push(e)}));var n=function(e,t){wr(e,(function(e){try{if(Xe(e[0])){var i=t;Sr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){yr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{Zo--}}push(e){if(Zo>0&&Xe(e)&&rt(e[0])){var t=da.prototype[e[0]];Ze(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!it(e)&&rt(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!rt(null==t?void 0:t.$current_url)&&(yr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=r&&r._originatedFromCaptureException||yr.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 d=new Date,h=(null==r?void 0:r.timestamp)||d,_=Pi(null==r?void 0:r.uuid,Dr),p={uuid:_,event:e,properties:this.calculateEventProperties(e,t||{},h,_)};e===_e&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),(null==r?void 0:r.$set)&&(p.$set=null==r?void 0:r.$set);var g=null==r?void 0:r.$unset;g&&(p.$unset=g);var v,f,m,y=this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==ve,e===ge);if(y&&(p.$set_once=y),null!=r&&r._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>rt(e)?e.slice(0,n):e,l=new Set,p=function e(t,i){return t!==Object(t)?a?a(t):t:l.has(t)?void 0:(l.add(t),Xe(t)?(r=[],wr(t,(t=>{r.push(e(t))}))):(r={},Sr(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=h,it(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===Sn||e===xn){var b=null==t?void 0:t.$survey_id,w=null==t?void 0:t.$survey_iteration;Vo({id:b,current_iteration:w}),p.$set=i({},p.$set,{[(v={id:b,current_iteration:w},f=e===xn?"responded":"dismissed",m="$survey_"+f+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(m="$survey_"+f+"/"+v.id+"/"+v.current_iteration),m)]:!0})}else e===wn&&(p.$set=i({},p.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var S=null==t?void 0:t.$product_tour_type;S&&(p.$set=i({},p.$set,{["$product_tour_last_seen_date/"+S]:(new Date).toISOString()}))}var x=i({},p.properties.$set,p.$set);if(tt(x)||this.setPersonPropertiesForFlags(x),!ot(this.config.before_send)){var E=this._runBeforeSend(p);if(!E)return;(p=E).uuid=Pi(p.uuid,Dr)}this._internalEventEmitter.emit("eventCaptured",p);var k={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",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(k):this._requestQueue.enqueue(k),p}yr.critical("This capture call is ignored due to client rate limiting.")}}else yr.error("No event name provided to posthog.capture")}else yr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,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.$cookieless_mode=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!rt(l.distinct_id)&&!at(l.distinct_id)||st(l.distinct_id))&&yr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i,r){var s,o,a,l;if(void 0===r&&(r=!1),!Pe)return{};var u,c,d,h,_,p,g,v,f,m=e?[...en,...t||[]]:[],[y,b]=function(e){for(var t=0;xi.length>t;t++){var[i,r]=xi[t],s=i.exec(e),n=s&&(Ze(r)?r(s,e):r);if(n)return n}return["",""]}(Pe),w=null!=(u="undefined"!=typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},S={detectGoogleSearchApp:i},x=xr(Ir({$os:y,$os_version:b,$browser:bi(Pe,navigator.vendor,w,S),$device:Ei(Pe),$device_type:(d=Pe,h={userAgentDataPlatform:null==(s=navigator)||null==(s=s.userAgentData)?void 0:s.platform,maxTouchPoints:null==(o=navigator)?void 0:o.maxTouchPoints,screenWidth:null==fe||null==(a=fe.screen)?void 0:a.width,screenHeight:null==fe||null==(l=fe.screen)?void 0:l.height,devicePixelRatio:null==fe?void 0:fe.devicePixelRatio},f=Ei(d),f===Pt||f===kt||"Kobo"===f||"Kindle Fire"===f||f===ii?Et:f===Vt||f===Gt||f===Wt||f===Zt?"Console":f===Ct?"Wearable":f?wt:"Android"===(null==h?void 0:h.userAgentDataPlatform)&&(null!==(_=null==h?void 0:h.maxTouchPoints)&&void 0!==_?_:0)>0?600>Math.min(null!==(p=null==h?void 0:h.screenWidth)&&void 0!==p?p:0,null!==(g=null==h?void 0:h.screenHeight)&&void 0!==g?g:0)/(null!==(v=null==h?void 0:h.devicePixelRatio)&&void 0!==v?v:1)?wt:Et:"Desktop"),$timezone:_n(),$timezone_offset:pn()}),{$current_url:Ys(r?Ii(null==we?void 0:we.href):null==we?void 0:we.href,m,rn),$host:null==we?void 0:we.host,$pathname:null==we?void 0:we.pathname,$raw_user_agent:Pe.length>1e3?Pe.substring(0,997)+"...":Pe,$browser_version:Si(Pe,navigator.vendor,w,S),$browser_language:ln(),$browser_language_prefix:(c=ln(),"string"==typeof c?c.split("-")[0]:void 0),$screen_height:null==fe?void 0:fe.screen.height,$screen_width:null==fe?void 0:fe.screen.width,$viewport_height:null==fe?void 0:fe.innerHeight,$viewport_width:null==fe?void 0:fe.innerWidth,$lib:n.LIB_NAME,$lib_version:n.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return n.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=n.SDK_DIST_CHANNEL),x}(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{sessionId:h,windowId:_}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());l.$session_id=h,l.$window_id=_}this.sessionPropsManager&&xr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&xr(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===Bo&&(l.$lib_custom_api_host=this.config.api_host),c=e!==_e||o?e!==pe||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=xr(l,c),e===_e&&be&&(l.title=be.title),!it(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Pe&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=xr({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Xe(this.config.property_denylist)?Sr(this.config.property_denylist,(function(e){delete l[e]})):yr.error(sa+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(yr.error(ra),l=v(l,e));var f=this._hasPersonProcessing();return l.$process_person_profile=f,f&&!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=xr({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(yr.error(ra),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),tt(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;return null==(i=this.featureFlags)?void 0:i.isFeatureEnabled(e,t)}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=Go),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||st(e)?(yr.critical("Unique user id has not been set in posthog.identify"),!1):e===te?(yr.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())||(yr.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 yr.uninitializedWarning("posthog.identify");if(at(e)&&(e=e.toString(),yr.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(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(u)&&(this.unregister(u),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(G)||le)===le;e!==r&&n?(this.persistence.set_property(G,ue),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(ge,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=$o(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(j))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=$o(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):yr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(Xe(e)?e:[e]).filter((e=>rt(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(ve,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else yr.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){var t,i,r,s,n,o,u,c,d;if(yr.info("reset"),!this.__loaded)return yr.uninitializedWarning("posthog.reset");var h,_=this.get_property(a),p=this.get_property(l),g=this.get_property(b);if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),it(g)||null==(h=this.persistence)||h.register({[b]:g}),null==(r=this.surveys)||r.reset(),null==(s=this._remoteConfigLoader)||s.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(u=this.logs)||u.reset(),null==(c=this.persistence)||c.set_property(G,le),null==(d=this.sessionManager)||d.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===ae)this.register_once({distinct_id:te,$device_id:null},"");else{var v=this.config.get_device_id(Dr());this.register_once({distinct_id:v,$device_id:e?v:_},""),e||it(p)||this.register({[l]:p})}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;i.__loaded?(null==(e=i.logs)||e.flushLogs("sendBeacon"),null==(t=i._requestQueue)||t.unload(),null==(r=i._retryQueue)||r.unload(),null==(s=i.featureFlags)||s.destroy()):yr.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{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);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(o)?(yr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(it(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(u,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(yr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(et(e)){var r,s,o,a,l,u,c,d,h,_,p;xr(this.config,ua(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 mn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);ut(v)&&(this.config.debug=v),ut(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,jr._is_supported()&&jr._set("ph_debug",!0),yr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,jr._is_supported()&&jr._remove("ph_debug"))),null==(s=this.exceptionObserver)||s.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){n.LIB_NAME=e,n.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:da._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:na;return t!==na&&(t=na+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(G))===ue||(null==(t=this.sessionPersistence)?void 0:t.get_property(G))===ue}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ce&&!this._isIdentified()&&tt(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[u])&&(null==(t=this.persistence)||null==(t=t.props)||!t[Z]))}_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?(yr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Z,!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!==oe)}_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!==ae){if(this._inCookielessMode()){var i,r,s,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new Ro(this),this.pageViewManager=new Us(this),this.persistence&&(this.sessionPropsManager=new Co(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=da.__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==oe&&(null==(u=this.surveys)||u.loadIfEnabled()),(it(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 yr.warn(ta)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==ae?(this.config.cookieless_mode===oe&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===oe&&(this.register({distinct_id:te,$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())):yr.warn(ta)}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===ae||(this.config.cookieless_mode===oe?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 ye?Lo(ye,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){be&&("visible"===be.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(_e,{title:be.title},{send_instantly:!0}),this._visibilityStateListener&&(be.removeEventListener(de,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Tr(be,de,this._visibilityStateListener)))}debug(e){!1===e?(null==fe||fe.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==fe||fe.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,t,i,r,s,n,o=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(yr.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):(i="advanced_disable_decide",!1,r=yr,s=(t="advanced_disable_flags")in(e=o)&&!ot(e[t]),n=i in e&&!ot(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){var t;if(ot(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(ht),r=Xe(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),ot(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return dt(e.event)?yr.warn(o+". This can cause unexpected behavior."):yr.info(o),null}s.properties&&!tt(s.properties)||yr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&ot(s.properties[a]))return yr.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=ut(e)&&!e,i=jr._is_supported()&&"true"===jr._get("ph_debug");return!t&&(!!i||e)}}da.__defaultExtensionClasses={},da._noopLogger={trace:Yo=()=>{},debug:Yo,info:Yo,warn:Yo,error:Yo,fatal:Yo},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Pr(e.prototype[t[i]])}(da,["identify"]);class ha{constructor(e){this.disabled=!1===e;var t=et(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 _a="$copy_autocapture",pa=br("[AutoCapture]");function ga(e,t){return t.length>e?t.slice(0,e)+"...":t}function va(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!ts(t));return t}function fa(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:c}=t;if(!ts(e))return{props:{}};for(var d=[e],h=e;h.parentNode&&!is(h,"body");)if(ss(h.parentNode))d.push(h.parentNode.host),h=h.parentNode.host;else{if(!ts(h.parentNode))break;d.push(h.parentNode),h=h.parentNode}var _,p,g=[],v={},f=!1,m=!1;if(Sr(d,(e=>{var t=xs(e);if(is(e,"a")){var i=e.getAttribute("href");f=!!(t&&i&&Rs(i))&&(c?Ii(i):i)}We(as(e),"ph-no-capture")&&(m=!0),g.push(function(e,t,i,r,s){void 0===s&&(s=!1);var n=e.tagName.toLowerCase(),o={tag_name:n};ds.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?ga(1024,Ls(e)):ga(1024,us(e)));var a=as(e);a.length>0&&(o.classes=a.filter((function(e){return""!==e}))),Sr(e.attributes,(function(i){var n;if((!Es(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Rs(i.value)&&(!rt(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=ns(a).join(" ")),o["attr__"+i.name]=ga(1024,"href"===i.name&&s?Ii(a):a)}}));for(var l=1,u=1,c=e;c=va(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(!xs(e))return{};var t={};return Sr(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&&Rs(r)&&(t[i]=r)}})),t}(e);xr(v,r)})),m)return{props:{},explicitNoCapture:m};if(a||(g[0].$el_text=is(e,"a")||is(e,"button")?Ls(e):us(e)),f){var y,b;g[0].attr__href=f;var w=null==(y=Ks(f))?void 0:y.host,S=null==fe||null==(b=fe.location)?void 0:b.host;w&&S&&w!==S&&(_=f)}return{props:xr({$event_type:n.type,$ce_version:1},u?{}:{$elements:g},{$elements_chain:(p=g,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 Er(o).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return a[As(t.toString())]=As(i.toString())})),(s+=":")+Er(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).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:$s(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Er(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(p)))},null!=(r=g[0])&&r.$el_text?{$el_text:null==(s=g[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},v)}}var ma=br("[ExceptionAutocapture]"),ya=br("[TracingHeaders]"),ba=br("[Web Vitals]"),wa=9e5,Sa="disabled",xa="lazy_loading",Ea="awaiting_config",ka="missing_config";br("[SessionRecording]"),br("[SessionRecording]");var Pa="[SessionRecording]",Ia=br(Pa),Ca=br("[Heatmaps]");function Fa(e){return et(e)&&"clientX"in e&&"clientY"in e&&at(e.clientX)&&at(e.clientY)}var Ta=br("[Product Tours]"),Ra=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(m))},La=["$set_once","$set"],Ma=br("[SiteApps]"),Aa="Error while initializing PostHog app with config id ";function $a(e,t,i){if(ot(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 Oa{constructor(e){this._debugEventEmitter=new Fo,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;it(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(!it(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(null==t?void 0: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(!$a(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=>$a(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&$a((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=>$a(e.text,t.text,t.text_matching||"exact")||$a(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;!ot(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=>$a(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||qo(t.properties.reduce(((e,t)=>{var i=Xe(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 Da{constructor(e){this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&qo(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===yn?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;it(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 Oa(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,yn),this._cancelEventToItems=this._buildEventToItemMap(e,bn))}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}),void this._persistActivation(n)}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,bn);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,yn);this._activateItems(l.map((e=>e.id)))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){0!==e.length&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...e])],this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}))}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter((t=>t!==e));var t=this._getPersistedActivatedIds();t.includes(e)||this._setActivatedItems([...t,e])}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter((e=>!t.has(e)));var i=this._getPersistedActivatedIds(),r=i.filter((e=>!t.has(e)));r.length!==i.length&&this._setActivatedItems(r)}_getPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter((e=>!this._isItemPermanentlyIneligible(e)))}reset(){this._pendingActivatedItems=[],this._getPersistedActivatedIds().length>0&&this._setActivatedItems([])}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class qa extends Da{constructor(e){super(e)}_getActivatedKey(){return H}_getShownEventName(){return wn}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return jo}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[H]:e})}_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,i,r,s=(null!==(t=null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==t?t:0)>0;return"always"===e.schedule||!(null==(r=e.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?e===wn?"consume":"ignore":e===wn?"persist":e===Sn||e===xn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Ba="SDK is not enabled or survey functionality is not yet loaded",za="Disabled. Not loading surveys.",Ha=null!=fe&&fe.location?Xs(fe.location.hash,"__posthog")||Xs(location.hash,"state"):null,Na="_postHogToolbarParams",ja=br("[Toolbar]"),Ua=br("[FeatureFlags]"),Va=br("[FeatureFlags]",{debugEnabled:!0}),Wa="\" failed. Feature flags didn't load in time.",Ga=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Qa=e=>{var t={};for(var[i,r]of Er(e||{}))r&&(t[i]=r);return t},Ka=br("[Error tracking]"),Ja="Refusing to render web experiment since the viewer is a likely bot",Ya={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>Ao(t,e),not_regex:(e,t)=>!Ao(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class Xa{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Xa._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Xa._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);rt(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];Xa._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())Xa._logInfo(Ja);else if(!this._config.disable_web_experiments){if(ot(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Xa._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=Xa.getWindowLocation();if(null!=e&&e.search){var t=Js(null==e?void 0:e.search,"__experiment_id"),i=Js(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Xa._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",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&&(Xa._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!ot(e.conditions)&&Xa._matchUrlConditions(e,t)&&Xa._matchUTMConditions(e)}static _matchUrlConditions(e,t){var i;if(ot(e.conditions)||ot(null==(i=e.conditions)?void 0:i.url))return!0;var r=Xa.getWindowLocation();if(r){var s,n,o,a=Jr(t,r.href);return null==(s=e.conditions)||!s.url||Ya[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==fe?void 0:fe.location}static _matchUTMConditions(e){var t;if(ot(e.conditions)||ot(null==(t=e.conditions)?void 0:t.utm))return!0;var i=nn();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];yr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Xa._logInfo(Ja):"control"!==t?i.forEach((i=>{if(i.selector){var r;Xa._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)}))}})):Xa._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ye&&this._instance?Lo(ye,this._config.custom_blocked_useragents):void 0}}var Za=br("[Conversations]"),el="Conversations not available yet.",tl="console",il={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=[],fe&&Tr(fe,"online",this._onOnline)}destroy(){null==fe||fe.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,Ua.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||(Ua.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||Ua.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(!it(e)){if(Xe(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Ua.error("Invalid flag key found:",e,"Expected non-empty string"),t}));Ua.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,{config:i}=this._instance,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(L))&&void 0!==n?n:{},l=i({},o,e),u=i({},a,t),c={};for(var[d,h]of Object.entries(l))c[d]={key:d,enabled:Te(h),variant:Re(h),reason:void 0,metadata:it(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}};this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(R),t=this._prop(A),r=this._prop(O);if(!r&&!t)return e||{};var s=xr({},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=it(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,h=it(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||(Ua.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:Te(r),variant:Re(r),payload:Fe(t[i])}}))}getFlagVariants(){var e=this._prop(C),t=this._prop(A);if(!t)return e||{};for(var i=xr({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ua.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(L),t=this._prop(O);if(!t)return e||{};for(var i=xr({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ua.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,s=this._prop(a),n={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)||{}),group_properties:this._prop(q),timezone:_n()};nt(s)||it(s)||(n.$device_id=s),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_contexts=this._getValidEvaluationEnvironments());var o=this._getValidFlagKeys();it(o)||(n.flag_keys=o);var l=!!this._config.advanced_only_evaluate_survey_feature_flags,u=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:u,data:n,compression:this._config.disable_compression?void 0:Tn,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,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;var o=[];e.error?e.error instanceof Error?o.push("AbortError"===e.error.name?"timeout":"connection_error"):o.push("unknown_error"):200!==e.statusCode&&o.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var a,u=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&o.push("quota_limited"),null==(r=this._persistence)||r.register({[V]:o}),u)Ua.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 n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},s,{partialResponse:l}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}_hasStatusZeroCircuitBreakerTripped(){return this._consecutiveStatusZeroFailures>=3&&Ce()}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=((e,t,i,r)=>{if(0===e){if(Ce()){var s=t+1;return 3===s&&Ua.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."),s}return t}return 0})(e,this._consecutiveStatusZeroFailures)}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 Ua.warn('getFeatureFlag for key "'+e+Wa)}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(M)||void 0,l=this._prop(W)||void 0,u=this._prop(j)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),h=this._prop(U);d&&d!==h&&(u={},null==(c=this._persistence)||c.register({[j]:u,[U]: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;Xe(u[e])?u[e].push(o):u[e]=[o],null==(_=this._persistence)||_.register({[j]:u});var x=this.getFeatureFlagDetails(e),E=[...null!==(p=this._prop(V))&&void 0!==p?p:[]];it(s)&&E.push("flag_missing");var k={$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};it(null==x||null==(f=x.metadata)?void 0:f.version)||(k.$feature_flag_version=x.metadata.version);var P,I=null!==(m=null==x||null==(y=x.reason)?void 0:y.description)&&void 0!==m?m:null==x||null==(b=x.reason)?void 0:b.code;I&&(k.$feature_flag_reason=I),null!=x&&null!=(w=x.metadata)&&w.id&&(k.$feature_flag_id=x.metadata.id),it(null==x?void 0:x.original_variant)&&it(null==x?void 0:x.original_enabled)||(k.$feature_flag_original_response=it(x.original_variant)?x.original_enabled:x.original_variant),null!=x&&null!=(S=x.metadata)&&S.original_payload&&(k.$feature_flag_original_payload=null==x||null==(P=x.metadata)?void 0:P.original_payload),E.length&&(k.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",k)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Fe(n)}}}else Ua.warn('getFeatureFlagResult for key "'+e+Wa)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments());var s=this._getValidFlagKeys();it(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:Tn,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){if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return it(i)?void 0:!!i}Ua.warn('isFeatureEnabled for key "'+e+Wa)}}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&&Ua.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(Xe(u)){Ua.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({[F]:u,[C]:_})}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=>{var[t]=e;return m.has(t)})))),v=i({},s,Object.fromEntries(Object.entries(v||{}).filter((e=>{var[t]=e;return m.has(t)})))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>{var[t]=e;return m.has(t)}))))}else g=i({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[F]:Object.keys(Qa(g)),[C]:g||{},[L]:v||{},[R]:f||{}},d?{[M]:d}:{},h?{[W]:h}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Ua.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Ua.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(A),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),Va.info("All overrides cleared");if(Xe(e)){var t=Ga(e);return this._persistence.register({[A]:t}),this._fireFeatureFlagsCallbacks(),Va.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(A),Va.info("Flag overrides cleared");else if(r.flags){if(Xe(r.flags)){var s=Ga(r.flags);this._persistence.register({[A]:s})}else this._persistence.register({[A]:r.flags});Va.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),Va.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),Va.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[A]:e}),this._fireFeatureFlagsCallbacks(),Va.info("Flag overrides set",{flags:e});Ua.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){Ua.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(T)||[]).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({[F]:Object.keys(Qa(l)),[C]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(T),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",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(T),null==(r=this._persistence)||r.register({[T]: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{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>{try{r(t,i,{errorsLoading:e})}catch(e){Ua.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(q)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[q]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(q)||{};this._instance.register({[q]:i({},t,{[e]:{}})})}else this._instance.unregister(q)}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}}},rl={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===Ea||this._recordingStatus===ka?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=Sa,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Ia.error("started without valid sessionManager"),new Error(Pa+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===ae)throw new Error(Pa+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(b))||!e.enabled),i=!this._config.disable_session_recording,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return fe&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!it(Object.assign)&&!it(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Ia.info("starting")):(this._recordingStatus=Sa,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==Ea&&this._recordingStatus!==ka&&(this._recordingStatus=xa),null!=Ie&&null!=(t=Ie.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Ie.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=Ie.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Ia.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(I),null==(t=this._persistence)||t.unregister(w)}_validateSampleRate(e,t){if(ot(e))return null;var i,r=at(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ia.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;ot(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[b]: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:it(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){return"sessionRecording"in e?!1===e.sessionRecording?(this._persistRemoteConfig(e),void this._discardRecording()):(this._persistRemoteConfig(e),void this.startIfEnabledOrStop()):(this._recordingStatus===Ea&&(this._recordingStatus=ka,Ia.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):Ia.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(b);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t,i=this._instance.get_property(b);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(e){return Ia.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=Ie.__PosthogExtensions__)||!t.initSessionRecording)return Ia.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[se]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Ie.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===ka||this._recordingStatus===Ea)return;return this._recordingStatus=Ea,Ia.info("persisted remote config is stale, requesting fresh config before starting"),void new Cn(this._instance).load()}this._recordingStatus=xa,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({[x]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[S]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?E:k]:!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))}}},sl={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new ha(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=et(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(fe&&be){var e=e=>{e=e||(null==fe?void 0:fe.event);try{this._captureEvent(e)}catch(e){pa.error("Failed to capture event",e)}};if(Tr(be,"submit",e,{capture:!0}),Tr(be,"change",e,{capture:!0}),Tr(be,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==fe?void 0:fe.event);try{this._captureEvent(e,_a)}catch(e){pa.error("Failed to capture copy/cut event",e)}};Tr(be,"copy",t,{capture:!0}),Tr(be,"cut",t,{capture:!0})}}}else pa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[d]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==be?void 0:be.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[d];if(nt(this._isDisabledServerSide)&&!ut(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=cs(e);rs(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())&&bs(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===_a;if(r&&function(e,t,i,r,s,n){var o,a,l,u,c,d;if(void 0===i&&(i=void 0),!fe||ws(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!os(i.url_allowlist,n))return!1;if(null!=(a=i)&&a.url_ignorelist&&os(i.url_ignorelist,n))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var h=i.dom_event_allowlist;if(h&&!h.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:_,targetElementList:p}=Ss(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(it(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}(p,i))return!1;if(!hs(p,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(hs(p,null!==(c=null==(d=i)?void 0:d.css_selector_ignorelist)&&void 0!==c?c:ps))return!1;try{var g=fe.getComputedStyle(e);if(g&&"pointer"===g.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}var v=e.tagName.toLowerCase();switch(v){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 _?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(ds.indexOf(v)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:o}=fa(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});if(o)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(n.$element_selectors=a),t===_a){var l,u=ls(null==fe||null==(l=fe.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return Ze(null==be?void 0:be.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==fe||null==(t=fe.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(yr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,yr.info("History API monitoring stopped")}monitorHistoryChanges(){fe&&fe.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener())}_patchHistoryMethod(e){var t;if(fe&&(null==(t=fe.history[e])||!t.__posthog_wrapped__)){var i=this;!function(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return Ze(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]===s&&(e[t]=r)}}catch(e){return()=>{}}}(fe.history,e,(t=>function(r,s,n){t.call(this,r,s,n),i._capturePageview(e)}))}}_capturePageview(e){try{var t,i=null==fe||null==(t=fe.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(_e,{navigation_type:e}),this._lastPathname=i}catch(t){yr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Tr(fe,"popstate",e),this._popstateListener=()=>{fe&&fe.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[h]),this.rageclicks=new ha(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return et(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return ot(this._config.capture_heatmaps)?ot(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Ca.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("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[h]:t}),this._enabledServerSide=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(be)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){fe&&be&&(this._flushHandler=this._flush.bind(this),Tr(fe,he,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==fe?void 0:fe.event)),Tr(be,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==fe?void 0:fe.event)),Tr(be,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Bs(this.instance,Ds,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Tr(be,de,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;fe&&be&&(this._flushHandler&&fe.removeEventListener(he,this._flushHandler),this._onClickHandler&&be.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&be.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&be.removeEventListener(de,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&&ts(r)&&!is(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:fe)?void 0:n.getComputedStyle(r).position}catch(e){return!1}if(We(t,s))return!0;r=_s(r)}return!1}(cs(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"),!es(e.target)&&Fa(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&bs(cs(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!es(e.target)&&Fa(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(fe){var t=this._config.disable_capture_url_hashes?Ii(fe.location.href):fe.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...en,...i||[]]:[],s=Ys(t,r,rn);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!tt(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Bs,webVitalsAutocapture:class{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!it(r))if(ot(null==e?void 0:e.name)||ot(null==e?void 0:e.value))ba.error("Invalid metric received",e);else if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),it(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=it(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),n=i({},e,{$current_url:r,timestamp:Date.now()});it(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this._buffer.metrics.push(n),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else ba.error("Ignoring metric with value >= "+this._maxAllowedValue,e)},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Ie.__PosthogExtensions__;it(s)||it(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):ba.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[v]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=et(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return ot(i)?(null==(t=this._instance.persistence)?void 0:t.props[y])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(et(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=et(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=et(this._perfConfig)&&at(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:wa;return e>0&&6e4>=e?wa:e}get isEnabled(){var e=null==we?void 0:we.protocol;if("http:"!==e&&"https:"!==e)return ba.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=et(this._perfConfig)?this._perfConfig.web_vitals:ut(this._perfConfig)?this._perfConfig:void 0;return ut(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(ba.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=et(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=et(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[v]:t}),this._instance.persistence.register({[y]:i})),this._enabledServerSide=t,this.startIfEnabled()}}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?ba.error("failed to load script",t):e()}))}_currentURL(){var e=fe?this._instance.config.disable_capture_url_hashes?Ii(fe.location.href):fe.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...en,...t||[]]:[];return Ys(e,i,rn)}ba.error("Could not determine current URL")}}},nl={exceptionObserver:class{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(fe&&this.isEnabled&&null!=(e=Ie.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Ie.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ie.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ie.__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){ma.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[_]),this._rateLimiter=new bt({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,_logger:ma}),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 et(e)?t=i({},t,e):(it(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?(ma.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return ma.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){"autocaptureExceptions"in e&&(this._remoteEnabled=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_]: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)?ma.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 Ni([new er,new cr,new ir,new tr,new lr,new ar,new sr,new ur],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=Zi.test(l)?l.replace(Zi,"$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||ji});var r}))}(n)}}("web:javascript",Ki,Xi)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(p))&&void 0!==t?t:[],this._exceptionStepsConfig=gr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new vr(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=gr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if("errorTracking"in e){var s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,this._instance.persistence&&this._instance.persistence.register({[p]:this._suppressionRules,[g]:n})}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(g),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(!rt(e)||0===e.trim().length)return void Ka.warn("Ignoring exception step because message must be a non-empty string");var r=this._coerceExceptionStepProperties(t),{sanitizedProperties:s,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>_r.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(r);n.length>0&&Ka.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[dr]:e,[hr]:(new Date).toISOString()},s))}catch(e){Ka.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 Ka.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 Ka.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 Ka.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&ot(e.$exception_steps)?this._addBufferedExceptionSteps(e):e;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return Ka.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void Ka.error("Failed to process exception event. Ignoring this exception.",e)}}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return Ka.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[dr]:e,[hr]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return et(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;var t=e.reduce(((e,t)=>{var{type:i,value:r}=t;return rt(i)&&i.length>0&&e.$exception_types.push(i),rt(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,r=Oo[e.operator],s=Xe(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_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!ot(e)&&Xe(e)}}},ol=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("productTours"in e){var t,i;if(this._persistence&&this._persistence.register({[m]:!!e.productTours}),!Ra(this._instance))return!this._productTourManager&&ot(null==(t=this._persistence)?void 0:t.props[N])||Ta.info("product tours disabled; stopping and clearing cached tours"),null==(i=this._productTourManager)||i.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&Ra(this._instance)&&this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Ta.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Ie.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Ie.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Xe(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[N];if(Xe(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",callback:t=>{if(Ra(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return Ta.error(s),void e([],{isLoaded:!1,error:s})}var n=Xe(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[N]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){ot(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(N)}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)}}},il),al={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=Ie._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[_,p]of Object.entries(h))c[_]={id:d[_],type:_,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,La),{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)||(Ma.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)||(Ma.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==be?void 0:be.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=>!nt(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&&(Ma.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,Ma.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this._runWithPreparedSiteAppElements((t=>e.init({posthog:this._instance,callback(e){t(),s(e)}})),!1);n&&(t.processEvent=n),r=!0}catch(t){Ma.error(Aa+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){Ma.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){Ma.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 Ma.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;Ie["__$$ph_site_app_"+e]=s._instance,null==(t=Ie.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,(t=>{if(t)return Ma.error(Aa+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Ma.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ll={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?(it(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=Ie.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),it(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=Ie.__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=Ie.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return ya.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 Xe(e)?(Xe(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(Xe(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()}}},ul=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){var t=e.surveys;if(ot(t))return jo.warn("Flags not loaded yet. Not loading surveys.");var i=Xe(t);this._isSurveysEnabled=i?t.length>0:t,jo.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(Uo)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)jo.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)jo.info(za);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())jo.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e){if(!it(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(ne);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 jo.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new qa(this._instance),jo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){jo.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 jo.info(za),e([]);var i,r=this._instance.get_property(B);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:r}=t;return e(i,r)})):("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",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;jo.error(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)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(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({[B]:l,[z]: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(z);return at(e)&&Date.now()-e>3e5}_isSurveyRefreshBackingOff(){return at(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};Vo(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){jo.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!ot(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);jo.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(ot(this._surveyManager))return{eligible:!1,reason:Ba};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(ot(this._surveyManager))return jo.warn("init was not called"),{visible:!1,disabledReason:Ba};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return ot(this._surveyManager)?(jo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ba})):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._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(ot(this._surveyManager))jo.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Wo.includes(s.type)){var n=null==be?void 0:be.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(jo.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;jo.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),jo.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);jo.warn("Survey element not found")}else jo.warn("Surveys of type "+s.type+" cannot be rendered in the app");else jo.warn("Survey not found")}}displaySurvey(e,t){var r;if(ot(this._surveyManager))jo.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!==En&&t.initialResponses&&jo.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(s);if(!o.visible)return void jo.warn("Survey is not eligible to be displayed: ",o.disabledReason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else jo.warn("Survey not found")}}cancelPendingSurvey(e){ot(this._surveyManager)?jo.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},il),cl={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Ie.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Ie.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),Rr(this.instance.config))return!1;if(!fe||!be)return!1;e=null!=e?e:fe.location,i=null!=i?i:fe.history;try{if(!t){try{fe.localStorage.setItem("test","test"),fe.localStorage.removeItem("test")}catch(e){return!1}t=null==fe?void 0:fe.localStorage}var r,s=Ha||Xs(e.hash,"__posthog")||Xs(e.hash,"state"),n=s?kr((()=>JSON.parse(atob(decodeURIComponent(s)))))||kr((()=>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(Na)||"{}")).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=Ie.ph_load_toolbar||Ie.ph_load_editor;!ot(t)&&Ze(t)?t(e,this.instance):ja.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==be||!be.getElementById(ee));if(!fe||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(fe.localStorage.setItem(Na,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=Ie.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return ja.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Tr(fe,"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)}}},dl=i({experiments:Xa},il),hl=i({},il,rl,sl,nl,ol,al,ul,ll,cl,dl,{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){var t=e.conversations;ot(t)||(ut(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||Rr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e&&!it(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(ne);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 Za.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Za.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Za.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Za.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():Za.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!nt(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):(Za.warn(el),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(Za.warn(el),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(Za.warn(el),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(Za.warn(el),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(Za.warn(el),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(Za.warn(el),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Za.warn(el),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()}}},{logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=br("[logs]"),this._queue=[],this._consoleQueue=[],this._onReconnect=()=>{var e,t;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),fe&&Tr(fe,"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=it(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 Di(this._createHost(e,t),n,this._logger,(()=>this._getSdkContext()),(e=>e()),void 0,r),n]}_getCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;return this._core&&this._resolvedFrom===i||(null==(t=this._core)||t.reset(),this._resolvedFrom=i,[this._core,this._resolvedConfig]=this._buildCore((()=>this._queue),(e=>{this._queue=e}))),this._core}_getConsoleCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;return this._consoleCore&&this._consoleResolvedFrom===i||(null==(t=this._consoleCore)||t.reset(),this._consoleResolvedFrom=i,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore((()=>this._consoleQueue),(e=>{this._consoleQueue=e}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},tl)),this._consoleCore}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!ot(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()}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._logger.error("PostHog logs flush failed:",e))),this._consoleCore&&this._consoleCore.flush().catch((e=>this._logger.error("PostHog logs flush failed:",e))))}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Ie?void 0:Ie.__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(ne)}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===Me.LogsQueue?e():void 0,setPersistedProperty(e,i){var r;e===Me.LogsQueue&&t(null!==(r=i)&&void 0!==r?r:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>n.LIB_NAME,getLibraryVersion:()=>n.LIB_VERSION}}_sendLogsBatch(e){return new Promise((t=>{var i=!1,r=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("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(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;r({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,n.LIB_NAME,(e=>{this._queue=e})),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,tl,(e=>{this._consoleQueue=e}))}_drainQueueViaTransport(e,t,i,r,s){if(0!==t.length){var o=t.map((e=>e.record));s([]);var a=Oi(o,$i(i,n.LIB_NAME,n.LIB_VERSION),r,n.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{sessionId:i,windowId:r,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=i,t.windowId=r,ot(s)||(t.sessionStartTimestamp=s),ot(n)||(t.lastActivityTimestamp=n)}if(null!=Ie&&null!=(e=Ie.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Ii(Ie.location.href):Ie.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}});da.__defaultExtensionClasses=i({},hl),function(){n.SDK_DIST_CHANNEL="cdn";var e=Xo[na]=new da,t=Ie.posthog;t&&Sr(t._i,(function(i){if(i&&Xe(i)){var r=e.init(i[0],i[1],i[2]),s=t[i[2]]||t;r&&(r._execute_array.call(r.people,s.people),r._execute_array(s))}})),Ie.posthog=e,function(){function e(){e.done||(e.done=!0,oa=!1,Sr(Xo,(function(e){e._dom_loaded()})))}null!=be&&be.addEventListener?"complete"===be.readyState?e():Tr(be,"DOMContentLoaded",e,{capture:!1}):fe&&yr.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="1.396.8",n={DEBUG:!1,LIB_VERSION:s,LIB_NAME:"web",JS_SDK_VERSION:s},o="$people_distinct_id",a="$device_id",l="$device_model",u="__alias",c="__timers",d="$autocapture_disabled_server_side",h="$heatmaps_enabled_server_side",_="$exception_capture_enabled_server_side",p="$error_tracking_suppression_rules",g="$error_tracking_capture_extension_exceptions",v="$web_vitals_enabled_server_side",f="$dead_clicks_enabled_server_side",m="$product_tours_enabled_server_side",y="$web_vitals_allowed_metrics",b="$session_recording_remote_config",w="$replay_sample_rate",S="$replay_override_sampling",x="$replay_override_linked_flag",E="$replay_override_url_trigger",k="$replay_override_event_trigger",P="$sesid",I="$session_is_sampled",C="$enabled_feature_flags",F="$active_feature_flags",T="$early_access_features",R="$feature_flag_details",L="$feature_flag_payloads",M="$feature_flag_request_id",A="$override_feature_flags",O="$override_feature_flag_payloads",D="$stored_person_properties",q="$stored_group_properties",B="$surveys",z="$surveys_loaded_at",H="$surveys_activated",N="ph_product_tours",j="$flag_call_reported",U="$flag_call_reported_session_id",V="$feature_flag_errors",W="$feature_flag_evaluated_at",G="$user_state",Q="$client_session_props",K="$capture_rate_limit",J="$initial_campaign_params",Y="$initial_referrer_info",X="$initial_person_info",Z="$epp",ee="__POSTHOG_TOOLBAR__",te="$posthog_cookieless",ie="$sdk_debug_extensions_init_method",re="$sdk_debug_extensions_init_time_ms",se="$sdk_debug_recording_script_not_loaded",ne="PostHog loadExternalDependency extension not found.",oe="on_reject",ae="always",le="anonymous",ue="identified",ce="identified_only",de="visibilitychange",he="beforeunload",_e="$pageview",pe="$pageleave",ge="$identify",ve="$groupidentify",fe="undefined"!=typeof window?window:void 0,me="undefined"!=typeof globalThis?globalThis:fe;"undefined"==typeof self&&(me.self=me),"undefined"==typeof File&&(me.File=function(){});var ye=null==me?void 0:me.navigator,be=null==me?void 0:me.document,we=null==me?void 0:me.location,Se=null==me?void 0:me.fetch,xe=null!=me&&me.XMLHttpRequest&&"withCredentials"in new me.XMLHttpRequest?me.XMLHttpRequest:void 0,Ee=null==me?void 0:me.AbortController,ke=null==me?void 0:me.CompressionStream,Pe=null==ye?void 0:ye.userAgent,Ie=null!=fe?fe:{};function Ce(){return!(!fe||!1===fe.navigator.onLine)}var Fe=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Te(e){return"string"==typeof e||e}function Re(e){return"string"==typeof e?e:void 0}var Le,Me=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.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}({}),Ae=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),$e=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],Oe=["token"],De="NativeGzipValidationError",qe=e=>e.length>=2&&31===e[0]&&139===e[1],Be=(e,t)=>e===Ae.GZipJS||t===Ae.GZipJS||"gzip"===t,ze=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),He=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=De,t},Ne=function(){var e=t((function*(e,t){18>e.size&&He("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());qe(i)&&8===i[2]||He("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Le)return Le;Le=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Le[e]=t>>>0}return Le})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&He("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&He("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function je(){return je=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=(new TextEncoder).encode(e),n=new 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]);return yield Ne(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),je.apply(this,arguments)}var Ue=["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"],Ve=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ue.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function We(e,t){return-1!==e.indexOf(t)}var Ge=function(e){return e.trim()},Qe=function(e){return e.replace(/^\$/,"")},Ke=Object.prototype,Je=Ke.hasOwnProperty,Ye=Ke.toString,Xe=Array.isArray||function(e){return"[object Array]"===Ye.call(e)},Ze=e=>"function"==typeof e,et=e=>e===Object(e)&&!Xe(e),tt=e=>{if(et(e)){for(var t in e)if(Je.call(e,t))return!1;return!0}return!1},it=e=>void 0===e,rt=e=>"[object String]"==Ye.call(e),st=e=>rt(e)&&0===e.trim().length,nt=e=>null===e,ot=e=>it(e)||nt(e),at=e=>"[object Number]"==Ye.call(e)&&e==e,lt=e=>at(e)&&e>0,ut=e=>"[object Boolean]"===Ye.call(e),ct=e=>e instanceof FormData,dt=e=>We($e,e),ht=e=>We(Oe,e);function _t(e){return null===e||"object"!=typeof e}function pt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function gt(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var vt=[!0,"true",1,"1","yes"],ft=e=>We(vt,e),mt=[!1,"false",0,"0","no"];function yt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),at(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),yt(s||i,t,i,r))}class bt{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=yt(e.bucketSize,0,100,e._logger),this._refillRate=yt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=yt(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 wt="Mobile",St="iOS",xt="Android",Et="Tablet",kt=xt+" "+Et,Pt="iPad",It="Apple",Ct=It+" Watch",Ft="Safari",Tt="BlackBerry",Rt="Samsung",Lt=Rt+"Browser",Mt=Rt+" Internet",At="Chrome",$t=At+" OS",Ot=At+" "+St,Dt="Internet Explorer",qt=Dt+" "+wt,Bt="Opera",zt=Bt+" Mini",Ht="Edge",Nt="Microsoft "+Ht,jt="Firefox",Ut=jt+" "+St,Vt="Nintendo",Wt="PlayStation",Gt="Xbox",Qt=xt+" "+wt,Kt=wt+" "+Ft,Jt="Windows",Yt=Jt+" Phone",Xt="Nokia",Zt="Ouya",ei="Generic",ti=ei+" "+wt.toLowerCase(),ii=ei+" "+Et.toLowerCase(),ri="Konqueror",si="Oculus Browser",ni="Vivaldi",oi="Yandex",ai="Whale",li="DuckDuckGo",ui="Pale Moon",ci="Waterfox",di="Brave",hi="Google Search App",_i="(\\d+(\\.\\d+)?)",pi=new RegExp("Version/"+_i),gi=new RegExp(Gt,"i"),vi=new RegExp(Wt+" \\w+","i"),fi=new RegExp(Vt+" \\w+","i"),mi=new RegExp(Tt+"|PlayBook|BB10","i"),yi={"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"},bi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?di:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&We(e,"GSA/")?hi:We(e," OPR/")&&We(e,"Mini")?zt:We(e," OPR/")?Bt:mi.test(e)?Tt:We(e,"IE"+wt)||We(e,"WPDesktop")?qt:We(e,"OculusBrowser")?si:We(e,Lt)?Mt:We(e,Ht)||We(e,"Edg/")?Nt:We(e,ni+"/")?ni:We(e,"YaBrowser/")?oi:We(e,ai+"/")?ai:We(e,li+"/")||We(e,"Ddg/")?li:We(e,"FBIOS")?"Facebook "+wt:We(e,"UCWEB")||We(e,"UCBrowser")?"UC Browser":We(e,"CriOS")?Ot:We(e,"CrMo")||We(e,At)?At:We(e,xt)&&We(e,Ft)?Qt:We(e,"FxiOS")?Ut:We(e.toLowerCase(),ri.toLowerCase())?ri:We(e,di+"/")?di:((e,t)=>t&&We(t,It)||function(e){return We(e,Ft)&&!We(e,At)&&!We(e,xt)}(e))(e,t)?We(e,wt)?Kt:Ft:We(e,"PaleMoon/")?ui:We(e,ci+"/")?ci:We(e,jt)?jt:We(e,"MSIE")||We(e,"Trident/")?Dt:We(e,"Gecko")?jt:"")},wi={[qt]:[new RegExp("rv:"+_i)],[Nt]:[new RegExp(Ht+"?\\/"+_i)],[At]:[new RegExp("("+At+"|CrMo)\\/"+_i)],[Ot]:[new RegExp("CriOS\\/"+_i)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+_i)],[Ft]:[pi],[Kt]:[pi],[Bt]:[new RegExp("(Opera|OPR)\\/"+_i)],[jt]:[new RegExp(jt+"\\/"+_i)],[Ut]:[new RegExp("FxiOS\\/"+_i)],[ri]:[new RegExp("Konqueror[:/]?"+_i,"i")],[Tt]:[new RegExp(Tt+" "+_i),pi],[Qt]:[new RegExp("android\\s"+_i,"i")],[Mt]:[new RegExp(Lt+"\\/"+_i)],[si]:[new RegExp("OculusBrowser\\/"+_i)],[ni]:[new RegExp(ni+"\\/"+_i)],[oi]:[new RegExp("YaBrowser\\/"+_i)],[ai]:[new RegExp(ai+"\\/"+_i)],[di]:[new RegExp(di+"\\/"+_i)],[li]:[new RegExp("(DuckDuckGo|Ddg)\\/"+_i)],[ui]:[new RegExp("PaleMoon\\/"+_i)],[ci]:[new RegExp(ci+"\\/"+_i)],[hi]:[new RegExp("GSA\\/"+_i)],[Dt]:[new RegExp("(rv:|MSIE )"+_i)],Mozilla:[new RegExp("rv:"+_i)]},Si=function(e,t,i,r){var s=bi(e,t,i,r),n=wi[s];if(it(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},xi=[[new RegExp(Gt+"; "+Gt+" (.*?)[);]","i"),e=>[Gt,e&&e[1]||""]],[new RegExp(Vt,"i"),[Vt,""]],[new RegExp(Wt,"i"),[Wt,""]],[mi,[Tt,""]],[new RegExp(Jt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Yt,""];if(new RegExp(wt).test(t)&&!/IEMobile\b/.test(t))return[Jt+" "+wt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=yi[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[Jt,r]}return[Jt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[St,[e[3],e[4],e[5]||"0"].join(".")]:[St,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=it(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+xt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+xt+")","i"),e=>e&&e[2]?[xt,[e[2],e[3],e[4]||"0"].join(".")]:[xt,""]],[/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/,[$t,""]],[/Linux|debian/i,["Linux",""]]],Ei=function(e){return fi.test(e)?Vt:vi.test(e)?Wt:gi.test(e)?Gt:new RegExp(Zt,"i").test(e)?Zt:new RegExp("("+Yt+"|WPDesktop)","i").test(e)?Yt:/iPad/.test(e)?Pt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Ct:mi.test(e)?Tt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Xt,"i").test(e)?Xt:/(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(wt).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)?xt:kt:new RegExp("(pda|"+wt+")","i").test(e)?ti:new RegExp(Et,"i").test(e)&&!new RegExp(Et+" pc","i").test(e)?ii:""},ki=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Pi(e,t){return"string"==typeof(i=e)&&ki.test(i)?e:t();var i}function Ii(e){return e?e.split("#")[0]:e}function Ci(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var Fi=e=>e instanceof Error,Ti={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}},Ri=Ti.info;function Li(e){if(ut(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(Xe(e))return{arrayValue:{values:e.map((e=>Li(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function Mi(e){var t=[];for(var i in e){var r=e[i];nt(r)||it(r)||t.push({key:i,value:Li(r)})}return t}function Ai(e,t){var r=e.level||"info",{text:s,number:n}=Ti[r]||Ri,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),ot(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),ot(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:Mi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),it(e.trace_flags)||(u.flags=e.trace_flags),u}function $i(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 Oi(e,t,i,r){return{resourceLogs:[{resource:{attributes:Mi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let Di=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:Ai(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=Xe(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(Me.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=Oi(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(Me.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(Me.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(Me.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return $i(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(Me.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(Me.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Ci((()=>{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(Me.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 Promise.race([t,new Promise((t=>Ci(t,e)))]):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=!1,r=i.flush(),s=new Promise((i=>Ci((()=>{t=!0,i()}),e)));try{yield Promise.race([r,s])}finally{t&&r.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 qi,Bi,zi;function Hi(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return zi&&i.length===Bi||(Bi=i.length,zi=i.reduce(((i,r)=>{qi||(qi={});var s=qi[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,qi[r]=[l,u];break}}return i}),{})),zi}}class Ni{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&&Xe(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:Hi(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 ji="?";function Ui(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?ji:i,in_app:!0};return it(r)||(n.lineno=r),it(s)||(n.colno=s),n}var Vi=(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]:ji,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Wi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Gi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Qi=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ki=(e,t)=>{var i=Wi.exec(e);if(i){var[,r,s,n]=i;return Ui(t,r,ji,+s,+n)}var o=Gi.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=Qi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Vi(o[1]||ji,o[2]);return Ui(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Ji=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Yi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Xi=(e,t)=>{var i=Ji.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Yi.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]||ji;return[n,s]=Vi(n,s),Ui(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Zi=/\(error: (.*)\)/;class er{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=rt(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 pt(e,"DOMException")}isDOMError(e){return pt(e,"DOMError")}}class tr{match(e){return(e=>e instanceof 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 ir{constructor(){}match(e){return pt(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var rr=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class sr{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(rr);return r&&(t=r[1],i=r[2]),[t,i]}}var nr=["fatal","error","warning","log","info","debug"];function or(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 ar{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return gt(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: "+or(e)}isSeverityLevel(e){return rt(e)&&!st(e)&&nr.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(Fi(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class lr{match(e){return gt(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+or(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class ur{match(e){return _t(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 cr{match(e){return pt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!gt(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 _t(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 dr="$message",hr="$timestamp",_r=new Set([dr,hr]),pr={enabled:!0,max_bytes:32768};function gr(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 vr{constructor(e){this._entries=[],this._totalBytes=0,this._config=gr(e)}setConfig(e){this._config=gr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t,i,r;try{r=[],t=null!==(i=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(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(t))return"[Circular]";r.push(t)}return t}})))&&void 0!==i?i:"null"}catch(e){return}try{var s=JSON.parse(t);if(!et(s))return;var n=s,o=n[dr],a=n[hr];if(!rt(o)||0===o.trim().length)return;if(!rt(a)&&!at(a))return;return{step:n,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(!at(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var mr=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(fe&&(n.DEBUG||Ie.POSTHOG_DEBUG||i)&&!it(fe.console)&&fe.console){for(var r=("__rrweb_original__"in fe.console[t]?fe.console[t].__rrweb_original__:fe.console[t]),s=arguments.length,o=new Array(s>1?s-1:0),a=1;s>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)=>mr(e+" "+t,i)};return r},yr=mr("[PostHog.js]"),br=yr.createLogger;function wr(e,t){Xe(e)&&e.forEach(t)}function Sr(e,t){if(!ot(e))if(Xe(e))e.forEach(t);else if(ct(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)Je.call(e,i)&&t(e[i],i)}var xr=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 Er(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 kr=function(e){try{return e()}catch(e){return}},Pr=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){yr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),yr.critical(e)}}},Ir=function(e){var t={};return Sr(e,(function(e,i){(rt(e)&&e.length>0||at(e))&&(t[i]=e)})),t};var Cr=["herokuapp.com","vercel.app","netlify.app"];function Fr(e){var t=null==e?void 0:e.hostname;if(!rt(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Cr)if(i===r)return!1;return!0}function Tr(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function Rr(e){return"ph_toolbar_internal"===e.name}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return at(e)&&isFinite(e)&&Math.floor(e)===e});class Lr{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/Math.pow(2,8),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 Lr(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 Lr(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 Mr{constructor(){this._timestamp=0,this._counter=0,this._random=new Or}generate(){var e=this.generateOrAbort();if(it(e)){this._timestamp=0;var t=this.generateOrAbort();if(it(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}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 Lr.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())}}var Ar,$r=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};fe&&!it(fe.crypto)&&crypto.getRandomValues&&($r=e=>crypto.getRandomValues(e));class Or{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||($r(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Dr=()=>qr().toString(),qr=()=>(Ar||(Ar=new Mr)).generate(),Br="",zr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Hr={_is_supported:()=>!!be,_error(e){yr.error("cookieStore error: "+e)},_get(e){if(be){try{for(var t=e+"=",i=be.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}},_parse(e){var t;try{t=JSON.parse(Hr._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(!be)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=be),Br)return Br;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_"+Dr();!Br&&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",Br=n)}return Br}(e);if(!i){var r=(e=>{var t=e.match(zr);return t?t[0]:""})(e);r!==i&&yr.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(be.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&&yr.warn("cookieStore warning: large cookie, len="+u.length),be.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=be&&be.cookie)try{Hr._set(e,"",-1,t)}catch(e){return}}},Nr=null,jr={_is_supported(){if(!nt(Nr))return Nr;var e=!0;if(it(fe))e=!1;else try{var t="__mplssupport__";jr._set(t,"xyz"),'"xyz"'!==jr._get(t)&&(e=!1),jr._remove(t)}catch(t){e=!1}return e||yr.error("localStorage unsupported; falling back to cookie store"),Nr=e,e},_error(e){yr.error("localStorage error: "+e)},_get(e){try{return null==fe?void 0:fe.localStorage.getItem(e)}catch(e){jr._error(e)}return null},_parse(e){try{return JSON.parse(jr._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==fe||fe.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){jr._error(e)}return!1},_remove(e){try{null==fe||fe.localStorage.removeItem(e)}catch(e){jr._error(e)}}},Ur=[a,"distinct_id",P,I,Z,X,G],Vr={},Wr={_is_supported:()=>!0,_error(e){yr.error("memoryStorage error: "+e)},_get:e=>Vr[e]||null,_parse:e=>Vr[e]||null,_set:(e,t)=>(Vr[e]=t,!0),_remove(e){delete Vr[e]}},Gr=null,Qr={_is_supported(){if(!nt(Gr))return Gr;if(Gr=!0,it(fe))Gr=!1;else try{var e="__support__";Qr._set(e,"xyz"),'"xyz"'!==Qr._get(e)&&(Gr=!1),Qr._remove(e)}catch(e){Gr=!1}return Gr},_error(e){yr.error("sessionStorage error: ",e)},_get(e){try{return null==fe?void 0:fe.sessionStorage.getItem(e)}catch(e){Qr._error(e)}return null},_parse(e){try{return JSON.parse(Qr._get(e))||null}catch(e){}return null},_set(e,t){try{return null==fe||fe.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Qr._error(e)}return!1},_remove(e){try{null==fe||fe.sessionStorage.removeItem(e)}catch(e){Qr._error(e)}}};class Kr{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===ae||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===oe}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{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){var e=this._storage._get(this._storageKey);return ft(e)?1:We(mt,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?jr:Hr;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?Hr:jr;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(ft(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==ye?void 0:ye.doNotTrack,null==ye?void 0:ye.msDoNotTrack,Ie.doNotTrack].some((e=>ft(e)))}}function Jr(e,t){var i,r=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!Ze(r))return t;try{var s=r(t);return rt(s)&&s?s:t}catch(e){return yr.error("Error in get_current_url, falling back to window.location.href",e),t}}var Yr=1,Xr=3,Zr=11;function es(e){return e instanceof Element&&(e.id===ee||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function ts(e){return!!e&&e.nodeType===Yr}function is(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function rs(e){return!!e&&e.nodeType===Xr}function ss(e){return!!e&&e.nodeType===Zr&&ts(e.host)}function ns(e){return e?Ge(e).split(/\s+/):[]}function os(e,t){var i=function(e){var t,i=null==fe||null==(t=fe.location)?void 0:t.href;return it(i)?void 0:Jr(e,i)}(t);return!!(i&&e&&e.some((e=>i.match(e))))}function as(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 ns(t)}function ls(e){return ot(e)?null:Ge(e).split(/(\s+)/).filter((e=>Rs(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function us(e){var t="";return xs(e)&&!Es(e)&&e.childNodes&&e.childNodes.length&&Sr(e.childNodes,(function(e){var i;rs(e)&&e.textContent&&(t+=null!==(i=ls(e.textContent))&&void 0!==i?i:"")})),Ge(t)}function cs(e){return it(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var ds=["a","button","form","input","select","textarea","label"];function hs(e,t){if(it(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 _s(e){var t=e.parentNode;return!(!t||!ts(t))&&t}var ps=[".ph-no-autocapture","[data-ph-no-autocapture]"],gs=["next","previous","prev",">","<"],vs=[...gs,"+","-","−","–"],fs=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,ms=[".ph-no-rageclick",".ph-no-capture"],ys=["","text","search","email","password","url","tel","number"];function bs(e,t){if(!fe||ws(e))return!1;var i,r,s,n,o;if(ut(t)?(i=!!t&&ms,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:ms,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||!ts(e))&&(!!is(e,"textarea")||(is(e,"input")?We(ys,(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{targetElementList:a}=Ss(e,!1);return!function(e,t){if(!1===e||it(e))return!1;var i;if(!0===e)i=gs;else{if(!Xe(e))return!1;if(e.length>10)return yr.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{safeText:t,ariaLabel:r}=e;return i.some((e=>fs(t,e)||fs(r,e)))}))}(r,a.map((e=>{var t;return{safeText:us(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!hs(a,i)}var ws=e=>!e||is(e,"html")||!ts(e),Ss=(e,t)=>{if(!fe||ws(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!is(s,"body");)if(ss(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=_s(s);if(!n)break;if(t||ds.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var o=fe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}catch(e){}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function xs(e){for(var t=e;t.parentNode&&!is(t,"body");t=t.parentNode){var i=as(t);if(We(i,"ph-sensitive")||We(i,"ph-no-capture"))return!1}if(We(as(e),"ph-include"))return!0;var r=e.type||"";if(rt(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!rt(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function Es(e){return!!(is(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||is(e,"select")||is(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var ks="(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})",Ps=new RegExp("^(?:"+ks+")$"),Is=new RegExp(ks),Cs="\\d{3}-?\\d{2}-?\\d{4}",Fs=new RegExp("^("+Cs+")$"),Ts=new RegExp("("+Cs+")");function Rs(e,t){if(void 0===t&&(t=!0),ot(e))return!1;if(rt(e)){if(e=Ge(e),(t?Ps:Is).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Fs:Ts).test(e))return!1}return!0}function Ls(e){var t=us(e);return Rs(t=(t+" "+Ms(e)).trim())?t:""}function Ms(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Sr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=us(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Ms(e)).trim())}catch(e){yr.error("[AutoCapture]",e)}})),t}function As(e){return e.replace(/"|\\"/g,'\\"')}function $s(e){var t=e.attr__class;return t?Xe(t)?t:ns(t):void 0}var Os=br("[Dead Clicks]"),Ds=()=>!0,qs=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(f)),r=e.instance.config.capture_dead_clicks;return ut(r)?r:!!et(r)||i};class Bs{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[f]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Os.error("failed to load script",t):e()}))}_start(){var e;if(be){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Ie.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=et(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Ie.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(be),Os.info("starting...")}}else Os.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Os.info("stopping..."))}}var zs=br("[SegmentIntegration]");var Hs="posthog-js";function Ns(e,t){var{organization:r,projectId:s,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,d,h;if("*"!==o&&!o.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==(l=t.exception)?void 0:l.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==(u=g[0])?void 0:u.value)||t.message,$exception_type:null==(c=g[0])?void 0:c.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 r&&s&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class js{constructor(e,t,i,r,s,n){this.name=Hs,this.setupOnce=function(o){o(Ns(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Us{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(yr.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==fe?void 0:fe.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{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(it(n)||it(o)||it(a)||it(l)||it(u)||it(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?yt(o/n,0,1,yr):1,h=n>1?yt(a/n,0,1,yr):1,_=l>1?yt(u/l,0,1,yr):1,p=l>1?yt(c/l,0,1,yr):1;r=xr(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 Vs=["flags","surveys"],Ws={[o]:{exposure:"hidden"},[u]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[c]:{exposure:"hidden"},[d]:{exposure:"event"},[h]:{exposure:"hidden"},[_]:{exposure:"event"},[p]:{exposure:"hidden"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"event"},[m]:{exposure:"hidden"},[y]:{exposure:"event"},[b]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[P]:{exposure:"hidden"},[I]:{exposure:"event"},[w]:{exposure:"event",shouldSkipFromEventProperties:e=>nt(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(!et(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[F]:{exposure:"event",storageGroup:"flags"},[T]:{exposure:"hidden"},[R]:{exposure:"hidden",storageGroup:"flags"},[L]:{exposure:"event",storageGroup:"flags"},[M]:{exposure:"event",storageGroup:"flags",volatile:!0},[A]:{exposure:"event"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[q]:{exposure:"hidden"},[B]:{exposure:"hidden",storageGroup:"surveys"},[z]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[H]:{exposure:"event"},[N]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[j]:{exposure:"hidden"},[U]:{exposure:"hidden"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[G]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[S]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[k]:{exposure:"event"},[ie]:{exposure:"event"},[re]:{exposure:"event"},[se]:{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"}},Gs=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Qs=e=>{var t=Ws[e];if(t)return t;for(var[i,r]of Gs)if(0===e.indexOf(i))return r},Ks=e=>{var t=null==be?void 0:be.createElement("a");return it(t)?null:(t.href=e,t)},Js=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(!Xe(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){yr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ys=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("=");Xe(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},Xs=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Zs="https?://(.*)",en=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],tn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...en],rn="<masked>",sn=["li_fat_id"];function nn(e,t,i){if(!be)return{};var r,s=t?[...en,...i||[]]:[],n=on(Ys(be.URL,s,rn),e),o=(r={},Sr(sn,(function(e){var t=Hr._get(e);r[e]=t||null})),r);return xr(o,n)}function on(e,t){var i=tn.concat(t||[]),r={};return Sr(i,(function(t){var i=Js(e,t);r[t]=i||null})),r}function an(e){var t=function(e){return e?0===e.search(Zs+"google.([^/?]*)")?"google":0===e.search(Zs+"bing.com")?"bing":0===e.search(Zs+"yahoo.com")?"yahoo":0===e.search(Zs+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!nt(t)){r.$search_engine=t;var s=be?Js(be.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function ln(){return navigator.language||navigator.userLanguage}var un="$direct";function cn(){return(null==be?void 0:be.referrer)||un}function dn(e,t,i){void 0===i&&(i=!1);var r=e?[...en,...t||[]]:[],s=i?Ii(null==we?void 0:we.href):null==we?void 0:we.href,n=null==s?void 0:s.substring(0,1e3);return{r:cn().substring(0,1e3),u:n?Ys(n,r,rn):void 0}}function hn(e,t){var i;void 0===t&&(t=!1);var{r:r,u:s}=e,n=t?Ii(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==un?un:null==(i=Ks(r))?void 0:i.host};if(n){o.$current_url=n;var a=Ks(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=on(n);xr(o,l)}if(r){var u=an(r);xr(o,u)}return o}function _n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function pn(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var gn={flags:W,surveys:z},vn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],fn="main";class mn{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_saved=!1,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&&yr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),fe){var s=()=>this.flush();Tr(fe,"beforeunload",s,{capture:!1}),Tr(fe,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return at(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===vn.indexOf(e.persistence.toLowerCase())&&(yr.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=[...Ur,...e];return i({},jr,{_parse(e){try{var i={};try{i=Hr._parse(e)||{}}catch(e){}var r,s=JSON.parse(jr._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];nt(a)||""===a||(n[o]=a)}r=xr(s,n)}else r=xr(i,s);return jr._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=jr._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&Hr._set(e,l,i,s,n,o)}catch(e){jr._error(e)}return a},_remove(e,t){try{null==fe||fe.localStorage.removeItem(e),Hr._remove(e,t)}catch(e){jr._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&jr._is_supported()?(t=jr,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&Qr._is_supported()?t=Qr:"memory"===n?t=Wr:"cookie"===n?t=Hr:r._is_supported()?(t=r,s=!0):t=Hr,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[W];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return Sr(this.props,((t,i)=>{var r=Qs(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===C?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&xr(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=xr({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of Vs){var t=jr._parse(this._groupEntryName(e));if(t&&!tt(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||xr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=Qs(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=gn[e];if(!i)return!1;var r=t[i],s=this.props[i];return at(r)&&at(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=Qs(e))?void 0:t.storageGroup:void 0,r=i?jr._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?it(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){it(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,fn))}_writeNowSplit(){var{main:e,groups:t}=this._partitionProps();for(var i of(this._writeEntry(this._storage,this._name,e,fn),Vs)){var r,s=t[i];(!tt(s)||null!=(r=this._slotState[i])&&r.persisted)&&this._writeEntry(jr,this._groupEntryName(i),s,i)}}_partitionProps(){var e={},t={};for(var i of Vs)t[i]={};return Sr(this.props,((i,r)=>{var s,n=null==(s=Qs(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===fn)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return Sr(e,((e,t)=>{var r;i[t]=null!=(r=Qs(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===fn||s.dirty||it(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!==fn&&(s.persisted=!0),it(n)||(s.fingerprint=n)):this._config.debug&&yr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var{keepGroupEntries:t=!1}=void 0===e?{}:e;if(it(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!t&&this._ownsSplitStorage)for(var i of Vs)jr._remove(this._groupEntryName(i));t?delete this._slotState[fn]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(et(e)){it(t)&&(t="None"),this._expire_days=it(i)?this._default_expiry:i;var r=!1;if(Sr(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(et(e)){this._expire_days=it(t)?this._default_expiry:t;var i=!1;if(Sr(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(){if(!this._campaign_params_saved){var e=nn(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);tt(Ir(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==be?void 0:be.referrer)?an(e):{})}update_referrer_info(){var e;this.register_once({$referrer:cn(),$referring_domain:null!=be&&be.referrer&&(null==(e=Ks(be.referrer))?void 0:e.host)||un},void 0)}set_initial_person_info(){this.props[J]||this.props[Y]||this.register_once({[X]:dn(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={};Sr([Y,J],(t=>{var i=this.props[t];i&&Sr(i,(function(t,i){e["$initial_"+Qe(i)]=t}))}));var t=this.props[X];if(t){var i=function(e,t){void 0===t&&(t=!1);var i=hn(e,t),r={};return Sr(i,(function(e,t){r["$initial_"+Qe(t)]=e})),r}(t,this._config.disable_capture_url_hashes);xr(e,i)}return e}safe_merge(e){return Sr(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[c]||{};i[e]=t,this._setProp(c,i),this.save()}remove_event_timer(e){var t=this.props[c]||{},i=t[e];return it(i)||(delete t[e],this._setProp(c,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=Qs(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=Qs(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}var yn="events",bn="cancelEvents",wn="survey shown",Sn="survey dismissed",xn="survey sent",En="popover",kn=br("[RateLimiter]");class Pn{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=>{kn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void kn.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{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(K))&&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;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(K,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var In=br("[RemoteConfig]");class Cn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Ie._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Ie.__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(t){e(t.json)}})}load(){try{if(this.remoteConfig)return In.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void In.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return In.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){In.error("Error loading remote config",e)}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){!this._instance._shouldDisableFlags()&&be&&"hidden"!==be.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){var t;e||In.error("Failed to fetch remote config from PostHog."),this._instance._onRemoteConfig(null!=e?e:{}),!1!==(null==e?void 0:e.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(t=this._instance.featureFlags)||t.ensureFlagsLoaded())}}var Fn="gzip-js",Tn="base64",Rn=Uint8Array,Ln=Uint16Array,Mn=Uint32Array,An=new Rn([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]),$n=new Rn([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]),On=new Rn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dn=function(e,t){for(var i=new Ln(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Mn(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]},qn=Dn(An,2),Bn=qn[1];qn[0][28]=258,Bn[258]=28;for(var zn=Dn($n,0)[1],Hn=new Ln(32768),Nn=0;32768>Nn;++Nn){var jn=(43690&Nn)>>>1|(21845&Nn)<<1;Hn[Nn]=((65280&(jn=(61680&(jn=(52428&jn)>>>2|(13107&jn)<<2))>>>4|(3855&jn)<<4))>>>8|(255&jn)<<8)>>>1}var Un=function(e,t,i){for(var r=e.length,s=0,n=new Ln(t);r>s;++s)++n[e[s]-1];var o,a=new Ln(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Ln(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[Hn[d]>>>l]=u}else for(o=new Ln(r),s=0;r>s;++s)o[s]=Hn[a[e[s]-1]++]>>>15-e[s];return o},Vn=new Rn(288);for(Nn=0;144>Nn;++Nn)Vn[Nn]=8;for(Nn=144;256>Nn;++Nn)Vn[Nn]=9;for(Nn=256;280>Nn;++Nn)Vn[Nn]=7;for(Nn=280;288>Nn;++Nn)Vn[Nn]=8;var Wn=new Rn(32);for(Nn=0;32>Nn;++Nn)Wn[Nn]=5;var Gn=Un(Vn,9,0),Qn=Un(Wn,5,0),Kn=function(e){return(e/8>>0)+(7&e&&1)},Jn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Ln?Ln:e instanceof Mn?Mn:Rn)(i-t);return r.set(e.subarray(t,i)),r},Yn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},Xn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Zn=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 Rn(0),0];if(1==s){var o=new Rn(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 Ln(h+1),p=eo(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 Rn(_),p]},eo=function(e,t,i){return-1==e.s?Math.max(eo(e.l,t,i+1),eo(e.r,t,i+1)):t[e.s]=i},to=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ln(++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]},io=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},ro=function(e,t,i){var r=i.length,s=Kn(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)},so=function(e,t,i,r,s,n,o,a,l,u,c){Yn(t,c++,i),++s[256];for(var d=Zn(s,15),h=d[0],_=d[1],p=Zn(n,15),g=p[0],v=p[1],f=to(h),m=f[0],y=f[1],b=to(g),w=b[0],S=b[1],x=new Ln(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=Zn(x,7),P=k[0],I=k[1],C=19;C>4&&!P[On[C-1]];--C);var F,T,R,L,M=u+5<<3,A=io(s,Vn)+io(n,Wn)+o,O=io(s,h)+io(n,g)+o+14+3*C+io(x,P)+(2*x[16]+3*x[17]+7*x[18]);if(A>=M&&O>=M)return ro(t,c,e.subarray(l,l+u));if(Yn(t,c,1+(A>O)),c+=2,A>O){F=Un(h,_,0),T=h,R=Un(g,v,0),L=g;var D=Un(P,I,0);for(Yn(t,c,y-257),Yn(t,c+5,S-1),Yn(t,c+10,C-4),c+=14,E=0;C>E;++E)Yn(t,c+3*E,P[On[E]]);c+=3*C;for(var q=[m,w],B=0;2>B;++B){var z=q[B];for(E=0;z.length>E;++E)Yn(t,c,D[H=31&z[E]]),c+=P[H],H>15&&(Yn(t,c,z[E]>>>5&127),c+=z[E]>>>12)}}else F=Gn,T=Vn,R=Qn,L=Wn;for(E=0;a>E;++E)if(r[E]>255){var H;Xn(t,c,F[257+(H=r[E]>>>18&31)]),c+=T[H+257],H>7&&(Yn(t,c,r[E]>>>23&31),c+=An[H]);var N=31&r[E];Xn(t,c,R[N]),c+=L[N],N>3&&(Xn(t,c,r[E]>>>5&8191),c+=$n[N])}else Xn(t,c,F[r[E]]),c+=T[r[E]];return Xn(t,c,F[256]),c+T[256]},no=new Mn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),oo=function(){for(var e=new Mn(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),ao=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function lo(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=oo[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 Rn(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=ro(l,u,e.subarray(c,d)):(l[c]=!0,u=ro(l,u,e.subarray(c,o)))}else{for(var h=no[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Ln(32768),f=new Ln(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 Mn(25e3),S=new Ln(288),x=new Ln(32),E=0,k=0,P=(c=0,0),I=0,C=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=I){var L=o-c;if((E>7e3||P>24576)&&L>423){u=so(e,l,0,w,S,x,k,P,C,c-C,u),P=E=k=0,C=c;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)x[M]=0}var A=2,O=0,D=p,q=T-R&32767;if(L>2&&F==b(c-q))for(var B=Math.min(_,L)-1,z=Math.min(32767,c),H=Math.min(258,L);z>=q&&--D&&T!=R;){if(e[c+A]==e[c+A-q]){for(var N=0;H>N&&e[c+N]==e[c+N-q];++N);if(N>A){if(A=N,O=q,N>B)break;var j=Math.min(q,N-2),U=0;for(M=0;j>M;++M){var V=c-q+M+32768&32767,W=V-v[V]+32768&32767;W>U&&(U=W,R=V)}}}q+=(T=R)-(R=v[T])+32768&32767}if(O){w[P++]=268435456|Bn[A]<<18|zn[O];var G=31&Bn[A],Q=31&zn[O];k+=An[G]+$n[Q],++S[257+G],++x[Q],I=c+A,++E}else w[P++]=e[c],++S[e[c]]}}u=so(e,l,!0,w,S,x,k,P,C,c-C,u)}return Jn(a,0,r+Kn(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&&ao(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),ao(u,c-8,i.d()),ao(u,c-4,r),u}var uo=!!xe||!!Se,co="text/plain",ho=!1,_o=(e,t)=>{var[i,r]=e.split("#"),[s,n]=i.split("?");if(!n)return e;var o=n.split("&").filter((e=>e.split("=")[0]!==t)).join("&");return s+(o?"?"+o:"")+(r?"#"+r:"")},po=function(e,t,r){var s;void 0===r&&(r=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(s=null==o?void 0:o.split("&").map((e=>{var t,[i,s]=e.split("="),n=r&&null!==(t=a[i])&&void 0!==t?t:s;return delete a[i],i+"="+n})))&&void 0!==s?s:[],u=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return Sr(e,(function(e,t){it(e)||it(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)}(a);return u&&l.push(u),n+"?"+l.join("&")},go=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),vo=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===Fn){var r=lo(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Rn(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 Rn(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 Jn(r,0,s)}(go(t)),{mtime:0});return{contentType:co,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Tn){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(go(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:go(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=go(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},fo=e=>{var t,r,s=()=>({url:_o(e.url,"compression"),encodedBody:vo(i({},e,{compression:void 0,_encodedBody:void 0}))});try{t=vo(e)}catch(t){if(Be(e.compression,Js(e.url,"compression")))return yr.error("Failed to gzip request body, sending uncompressed payload",t),s();throw t}return t&&Be(e.compression,Js(e.url,"compression"))&&!((r=t.body)instanceof ArrayBuffer?qe(new Uint8Array(r)):ArrayBuffer.isView(r)&&qe(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(ho=!0,s()):{url:e.url,encodedBody:t}},mo=e=>{try{return fo(e)}catch(t){return yr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},yo=function(){var e=t((function*(e){var t=go(e.data),r=yield function(e,t,i){return je.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:co,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),bo=(e,t)=>po(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),wo=[];Se&&wo.push({transport:"fetch",method(e){var t,r=mo(e);if(r){var{url:s,encodedBody:n}=r,{contentType:o,body:a,estimatedSize:l}=null!=n?n:{},u=new Headers;Sr(e.headers,(function(e,t){u.append(t,e)})),o&&u.append("Content-Type",o);var c=null,d=!1;if(Ee){var h=new Ee;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)}}Se(s,i({method:(null==e?void 0:e.method)||"GET",headers:u,keepalive:"POST"===e.method&&52428.8>(l||0),body:a,signal:null==(t=c)?void 0:t.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){yr.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{d&&"AbortError"===(null==t?void 0:t.name)?yr.warn(t):yr.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}}),xe&&wo.push({transport:"XHR",method(e){var t=mo(e);if(t){var i=new xe,{url:r,encodedBody:s}=t;i.open(e.method||"GET",r,!0);var{contentType:n,body:o}=null!=s?s:{};Sr(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!=ye&&ye.sendBeacon&&wo.push({transport:"sendBeacon",method(e){try{var{url:t,encodedBody:i}=fo(e),{contentType:r,body:s}=null!=i?i:{};if(!s)return;var n=s instanceof Blob?s:new Blob([s],{type:r});ye.sendBeacon(t,n)}catch(e){}}});var So=3e3;class xo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=yt((null==t?void 0:t.flush_interval_ms)||So,250,5e3,yr.createLogger("flush interval"),So),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&&Xe(i.data)&&Sr(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){yr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Sr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;it(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Eo=["retriesPerformedSoFar"];class ko{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!it(fe)&&"onLine"in fe.navigator&&(this._areWeOnline=fe.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Tr(fe,"online",this._onlineListener),Tr(fe,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,Eo);lt(t)&&(s.url=po(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&&yr.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)"),yr.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{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,it(fe)||(this._onlineListener&&(fe.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(fe.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){yr.error(e)}this._queue=[]}}class Po{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(){Tr(fe,"scroll",this._updateScrollData,{capture:!0}),Tr(fe,"scrollend",this._updateScrollData,{capture:!0}),Tr(fe,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==fe?void 0:fe.document.documentElement;var e=Xe(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==fe?void 0:fe.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 fe?"y"===e?fe.scrollY||fe.pageYOffset||fe.document.documentElement.scrollTop||0:fe.scrollX||fe.pageXOffset||fe.document.documentElement.scrollLeft||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}}var Io=e=>dn(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 Co{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({[Q]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Io,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Q]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?hn(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 Sr(Ir(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Qe(i)]=t})),e}}class Fo{constructor(){this._events={}}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)}}var To=br("[SessionId]");class Ro{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 Fo,this._sessionHasBeenIdleTooLong=(e,t)=>!(!lt(e)||!lt(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===ae)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||Dr,this._windowIdGenerator=i||Dr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*yt(this._config.session_idle_timeout_seconds||1800,60,36e3,To.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=Qr._parse(this._window_id_storage_key),o=Qr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Qr._remove(this._window_id_storage_key),Qr._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){To.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return it(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&&Qr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Qr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Qr._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!nt(t)&&!nt(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({[P]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return lt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(P):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!nt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[P]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var[e]=this._getSessionId(),t=lt(e)?e:0,i=lt(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[P];return Xe(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&&fe&&(fe.removeEventListener(he,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Qr._remove(this._primary_window_exists_storage_key)},Tr(fe,he,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===ae)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[,r,s]=this._getSessionId(),n=this._freshestActivityTimestamp(),o=this._getWindowId(),a=lt(s)&&Math.abs(i-s)>864e5,l=!1,u=!1,c=!r,d=r,h=!c&&!e&&this._sessionHasBeenIdleTooLong(i,n);h&&((h=this._isSessionIdleAfterCrossTabRefresh(i))||To.info("cross-tab refresh kept the session alive",{sessionId:r}),[,r,s]=this._getSessionId()),c||h||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),To.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:a}}),s=i,l=!0):(o||(o=this._windowIdGenerator(),l=!0),(u=r!==d)&&(To.info("adopted cross-tab session id",{sessionId:r,windowId:o}),l=!0));var _=lt(n)&&e&&!a?n:i,p=lt(s)?s:(new Date).getTime();this._setWindowId(o),this._setSessionId(r,_,p),e||this._resetIdleTimer();var g={noSessionId:c,activityTimeout:h,sessionPastMaximumLength:a,crossTabAdoption:u};return l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,g))),{sessionId:r,windowId:o,sessionStartTimestamp:p,changeReason:l?g:void 0,lastActivityTimestamp:n}}_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 Lo=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Ve(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Ve(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function Mo(){return(Mo=t((function*(){var e=null==ye?void 0:ye.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return rt(i)&&i.length>0?i:void 0}catch(e){return void yr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}))).apply(this,arguments)}var Ao=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 $o(e,t,i){return go({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Oo={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=>Ao(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Ao(t,e))))),icontains:(e,t)=>t.map(Do).some((t=>e.map(Do).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Do).every((t=>e.map(Do).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)))}))},Do=e=>e.toLowerCase();function qo(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(it(s)||nt(s))return!1;var n=[String(s)],o=Oo[r.operator];return!!o&&o(r.values,n)}))}var Bo="custom",zo="i.posthog.com",Ho=/^\/static\//;class No{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("."+zo,".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":Bo),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(Ho.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===Bo)return this.apiHost+t;var r=zo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var jo=br("[Surveys]"),Uo="seenSurvey_",Vo=e=>{try{var t=(e=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Uo,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){jo.error("Failed to persist survey seen state",e)}},Wo=["popover","widget","api"],Go={ignoreConditions:!1,ignoreDelay:!1,displayType:En},Qo=br("[PostHog ExternalIntegrations]"),Ko={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Jo{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return Qo.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=Ie.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(Ko[t],(()=>{var i;null==(i=Ie.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=Ie.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=Ie.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var Yo,Xo={},Zo=0,ea=()=>{},ta='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ia="Surveys module not available",ra="sanitize_properties is deprecated. Use before_send instead",sa="Invalid value for property_denylist config: ",na="posthog",oa=!uo&&-1===(null==Pe?void 0:Pe.indexOf("MSIE"))&&-1===(null==Pe?void 0:Pe.indexOf("Mozilla")),aa=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:Fr(null==be?void 0:be.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:ea,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:we&&rt(null==we?void 0:we.search)&&-1!==we.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==fe||null==(t=fe.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){yr.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:ce,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:So},error_tracking:{},_onCapture:ea},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:vs,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))},la=[["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"]],ua=e=>{var t={};for(var[i,r]of la)it(e[i])||(t[r]=e[i]);var s=xr({},t,e),n=e.__preview_external_dependency_versioned_paths;return it(n)||(it(e.strict_script_versioning)&&(s.strict_script_versioning=!!n),rt(n)&&it(e.asset_host)&&(s.asset_host=n)),Xe(e.property_blacklist)&&(it(e.property_denylist)?s.property_denylist=e.property_blacklist:Xe(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:yr.error(sa+e.property_denylist)),s};class ca{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){yr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class da{_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===ae||this.config.cookieless_mode===oe&&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 ca,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new Fo,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=aa(),this.SentryIntegration=js,this.sentryIntegration=e=>function(e,t){var i=Ns(e,t);return{name:Hs,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 Po(this),this.pageViewManager=new Us(this),this.rateLimiter=new Pn(this),this.requestRouter=new No(this),this.consent=new Kr(this),this.externalIntegrations=new Jo(this);var t=null!==(e=da.__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.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var r=rt(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=rt(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>yr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==na){var r,s=null!==(r=Xo[i])&&void 0!==r?r:new da;return s._init(e,t,i),Xo[i]=s,Xo[na][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;void 0===t&&(t={});var a=rt(e)?e.trim():"";if(!a)return yr.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 console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},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 u=aa(t.defaults),c=ua(t),d=xr({},u,c,{name:r,token:a});et(u.rageclick)&&et(c.rageclick)&&(d.rageclick=xr({},u.rageclick,c.rageclick)),et(u.session_recording)&&et(c.session_recording)&&(d.session_recording=xr({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&yr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Fn;var h=this._is_persistence_disabled();this.persistence=new mn(this.config,h),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new mn(i({},this.config,{persistence:"sessionStorage"}),h,!1);var _=i({},this.persistence.props),p=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new xo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new ko(this),this.__request_queue=[];var g=this._inCookielessMode();if(g||(this.sessionManager=new Ro(this),this.sessionPropsManager=new Co(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(yr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(g)}),0)):(yr.info("Initializing extensions synchronously"),this._initExtensions(g)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&yr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:_,s:p}),!this.config.identity_distinct_id||null!=(s=t.bootstrap)&&s.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 v=t.bootstrap.distinctID,f=this.get_distinct_id(),m=this.persistence.get_property(G);if(t.bootstrap.isIdentifiedID&&null!=f&&f!==v&&m===le)this.identify(v);else if(t.bootstrap.isIdentifiedID&&null!=f&&f!==v&&m===ue)yr.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 y=this.config.get_device_id(Dr()),b=t.bootstrap.isIdentifiedID?y:v;this.persistence.set_property(G,t.bootstrap.isIdentifiedID?ue:le),this.register({distinct_id:v,$device_id:b})}}if(g)this.register_once({distinct_id:te,$device_id:null},"");else if(!this.get_distinct_id()){var w=this.config.get_device_id(Dr());this.register_once({distinct_id:w,$device_id:w},""),this.persistence.set_property(G,le)}return Tr(fe,"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()||Dr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(G,ue)),t()},s=i.user();"then"in s&&Ze(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{"undefined"!=typeof Promise&&Promise.resolve||zs.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()||(zs.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(zs.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,_e),identify:e=>t(e,ge),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Ze(this.config._onCapture)&&this.config._onCapture!==ea&&(yr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&yr.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 Mo.apply(this,arguments)}().then((e=>{e&&this.register({[l]:e})})).catch(ea),this}_initExtensions(e){var t,r,s,n,o,a,l,u=performance.now(),c=i({},da.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new c.featureFlags(this)),c.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new c.exceptions(this)),c.historyAutocapture&&this._extensions.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this._extensions.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this._extensions.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this._extensions.push(this.autocapture=new c.autocapture(this)),c.surveys&&this._extensions.push(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new c.surveys(this)),c.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new c.logs(this)),c.conversations&&this._extensions.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new c.conversations(this)),c.productTours&&this._extensions.push(this.productTours=new c.productTours(this)),c.heatmaps&&this._extensions.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this._extensions.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,qs)),c.toolbar&&this._extensions.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new c.toolbar(this)),c.experiments&&this._extensions.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new c.experiments(this)),this._extensions.forEach((e=>{e.initialize&&d.push((()=>{null==e.initialize||e.initialize()}))})),d.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(d,u)}_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){yr.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[ie]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[re]:r}),this.config.__preview_deferred_init_extensions&&yr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!be||!be.body)return yr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=We(e.supportedCompression,Fn)?Fn:We(e.supportedCompression,Tn)?Tn:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:ce}),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){yr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=we&&we.hostname){var e=we.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 Cn(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()&&wr(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;null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(pe),null==(t=this.logs)||t.flushLogs("sendBeacon"),null==(i=this._requestQueue)||i.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(pe,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?oa?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,(it(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,n.url=bo(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=wo.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:s.method)&&void 0!==r?r:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===Fn&&ke&&"undefined"!=typeof Promise&&!ho?yo(n).then((e=>{l(e)})).catch((t=>{if(ze(t))return ho=!0,void l(i({},n,{compression:void 0,url:bo(e.url,void 0)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return ze(e)||t===De})(t)&&(ho=!0),l(n)})):l(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){Zo++;try{var t,i=[],r=[],s=[];wr(e,(e=>{if(e)if(Xe(t=e[0]))s.push(e);else if(Ze(e))try{e.call(this)}catch(t){yr.error("Error executing queued PostHog call",e,t)}else Xe(e)&&"alias"===t?i.push(e):Xe(e)&&-1!==t.indexOf("capture")&&Ze(this[t])?s.push(e):r.push(e)}));var n=function(e,t){wr(e,(function(e){try{if(Xe(e[0])){var i=t;Sr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){yr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{Zo--}}push(e){if(Zo>0&&Xe(e)&&rt(e[0])){var t=da.prototype[e[0]];Ze(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!it(e)&&rt(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!rt(null==t?void 0:t.$current_url)&&(yr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=r&&r._originatedFromCaptureException||yr.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 d=new Date,h=(null==r?void 0:r.timestamp)||d,_=Pi(null==r?void 0:r.uuid,Dr),p={uuid:_,event:e,properties:this.calculateEventProperties(e,t||{},h,_)};e===_e&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),(null==r?void 0:r.$set)&&(p.$set=null==r?void 0:r.$set);var g=null==r?void 0:r.$unset;g&&(p.$unset=g);var v,f,m,y=this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==ve,e===ge);if(y&&(p.$set_once=y),null!=r&&r._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>rt(e)?e.slice(0,n):e,l=new Set,p=function e(t,i){return t!==Object(t)?a?a(t):t:l.has(t)?void 0:(l.add(t),Xe(t)?(r=[],wr(t,(t=>{r.push(e(t))}))):(r={},Sr(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=h,it(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===Sn||e===xn){var b=null==t?void 0:t.$survey_id,w=null==t?void 0:t.$survey_iteration;Vo({id:b,current_iteration:w}),p.$set=i({},p.$set,{[(v={id:b,current_iteration:w},f=e===xn?"responded":"dismissed",m="$survey_"+f+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(m="$survey_"+f+"/"+v.id+"/"+v.current_iteration),m)]:!0})}else e===wn&&(p.$set=i({},p.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var S=null==t?void 0:t.$product_tour_type;S&&(p.$set=i({},p.$set,{["$product_tour_last_seen_date/"+S]:(new Date).toISOString()}))}var x=i({},p.properties.$set,p.$set);if(tt(x)||this.setPersonPropertiesForFlags(x),!ot(this.config.before_send)){var E=this._runBeforeSend(p);if(!E)return;(p=E).uuid=Pi(p.uuid,Dr)}this._internalEventEmitter.emit("eventCaptured",p);var k={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",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(k):this._requestQueue.enqueue(k),p}yr.critical("This capture call is ignored due to client rate limiting.")}}else yr.error("No event name provided to posthog.capture")}else yr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,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.$cookieless_mode=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!rt(l.distinct_id)&&!at(l.distinct_id)||st(l.distinct_id))&&yr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i,r){var s,o,a,l;if(void 0===r&&(r=!1),!Pe)return{};var u,c,d,h,_,p,g,v,f,m=e?[...en,...t||[]]:[],[y,b]=function(e){for(var t=0;xi.length>t;t++){var[i,r]=xi[t],s=i.exec(e),n=s&&(Ze(r)?r(s,e):r);if(n)return n}return["",""]}(Pe),w=null!=(u="undefined"!=typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},S={detectGoogleSearchApp:i},x=xr(Ir({$os:y,$os_version:b,$browser:bi(Pe,navigator.vendor,w,S),$device:Ei(Pe),$device_type:(d=Pe,h={userAgentDataPlatform:null==(s=navigator)||null==(s=s.userAgentData)?void 0:s.platform,maxTouchPoints:null==(o=navigator)?void 0:o.maxTouchPoints,screenWidth:null==fe||null==(a=fe.screen)?void 0:a.width,screenHeight:null==fe||null==(l=fe.screen)?void 0:l.height,devicePixelRatio:null==fe?void 0:fe.devicePixelRatio},f=Ei(d),f===Pt||f===kt||"Kobo"===f||"Kindle Fire"===f||f===ii?Et:f===Vt||f===Gt||f===Wt||f===Zt?"Console":f===Ct?"Wearable":f?wt:"Android"===(null==h?void 0:h.userAgentDataPlatform)&&(null!==(_=null==h?void 0:h.maxTouchPoints)&&void 0!==_?_:0)>0?600>Math.min(null!==(p=null==h?void 0:h.screenWidth)&&void 0!==p?p:0,null!==(g=null==h?void 0:h.screenHeight)&&void 0!==g?g:0)/(null!==(v=null==h?void 0:h.devicePixelRatio)&&void 0!==v?v:1)?wt:Et:"Desktop"),$timezone:_n(),$timezone_offset:pn()}),{$current_url:Ys(r?Ii(null==we?void 0:we.href):null==we?void 0:we.href,m,rn),$host:null==we?void 0:we.host,$pathname:null==we?void 0:we.pathname,$raw_user_agent:Pe.length>1e3?Pe.substring(0,997)+"...":Pe,$browser_version:Si(Pe,navigator.vendor,w,S),$browser_language:ln(),$browser_language_prefix:(c=ln(),"string"==typeof c?c.split("-")[0]:void 0),$screen_height:null==fe?void 0:fe.screen.height,$screen_width:null==fe?void 0:fe.screen.width,$viewport_height:null==fe?void 0:fe.innerHeight,$viewport_width:null==fe?void 0:fe.innerWidth,$lib:n.LIB_NAME,$lib_version:n.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return n.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=n.SDK_DIST_CHANNEL),x}(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{sessionId:h,windowId:_}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());l.$session_id=h,l.$window_id=_}this.sessionPropsManager&&xr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&xr(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===Bo&&(l.$lib_custom_api_host=this.config.api_host),c=e!==_e||o?e!==pe||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=xr(l,c),e===_e&&be&&(l.title=be.title),!it(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Pe&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=xr({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Xe(this.config.property_denylist)?Sr(this.config.property_denylist,(function(e){delete l[e]})):yr.error(sa+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(yr.error(ra),l=v(l,e));var f=this._hasPersonProcessing();return l.$process_person_profile=f,f&&!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=xr({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(yr.error(ra),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),tt(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;return null==(i=this.featureFlags)?void 0:i.isFeatureEnabled(e,t)}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=Go),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||st(e)?(yr.critical("Unique user id has not been set in posthog.identify"),!1):e===te?(yr.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())||(yr.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 yr.uninitializedWarning("posthog.identify");if(at(e)&&(e=e.toString(),yr.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(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(u)&&(this.unregister(u),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(G)||le)===le;e!==r&&n?(this.persistence.set_property(G,ue),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(ge,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=$o(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(j))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=$o(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):yr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(Xe(e)?e:[e]).filter((e=>rt(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(ve,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else yr.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){var t,i,r,s,n,o,u,c,d;if(yr.info("reset"),!this.__loaded)return yr.uninitializedWarning("posthog.reset");var h,_=this.get_property(a),p=this.get_property(l),g=this.get_property(b);if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),it(g)||null==(h=this.persistence)||h.register({[b]:g}),null==(r=this.surveys)||r.reset(),null==(s=this._remoteConfigLoader)||s.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(u=this.logs)||u.reset(),null==(c=this.persistence)||c.set_property(G,le),null==(d=this.sessionManager)||d.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===ae)this.register_once({distinct_id:te,$device_id:null},"");else{var v=this.config.get_device_id(Dr());this.register_once({distinct_id:v,$device_id:e?v:_},""),e||it(p)||this.register({[l]:p})}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;i.__loaded?(null==(e=i.logs)||e.flushLogs("sendBeacon"),null==(t=i._requestQueue)||t.unload(),null==(r=i._retryQueue)||r.unload(),null==(s=i.featureFlags)||s.destroy()):yr.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{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);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(o)?(yr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(it(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(u,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(yr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(et(e)){var r,s,o,a,l,u,c,d,h,_,p;xr(this.config,ua(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 mn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);ut(v)&&(this.config.debug=v),ut(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,jr._is_supported()&&jr._set("ph_debug",!0),yr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,jr._is_supported()&&jr._remove("ph_debug"))),null==(s=this.exceptionObserver)||s.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){n.LIB_NAME=e,n.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:da._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:na;return t!==na&&(t=na+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(G))===ue||(null==(t=this.sessionPersistence)?void 0:t.get_property(G))===ue}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ce&&!this._isIdentified()&&tt(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[u])&&(null==(t=this.persistence)||null==(t=t.props)||!t[Z]))}_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?(yr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Z,!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!==oe)}_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!==ae){if(this._inCookielessMode()){var i,r,s,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new Ro(this),this.pageViewManager=new Us(this),this.persistence&&(this.sessionPropsManager=new Co(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=da.__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==oe&&(null==(u=this.surveys)||u.loadIfEnabled()),(it(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 yr.warn(ta)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==ae?(this.config.cookieless_mode===oe&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===oe&&(this.register({distinct_id:te,$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())):yr.warn(ta)}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===ae||(this.config.cookieless_mode===oe?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 ye?Lo(ye,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){be&&("visible"===be.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(_e,{title:be.title},{send_instantly:!0}),this._visibilityStateListener&&(be.removeEventListener(de,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Tr(be,de,this._visibilityStateListener)))}debug(e){!1===e?(null==fe||fe.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==fe||fe.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,t,i,r,s,n,o=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(yr.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):(i="advanced_disable_decide",!1,r=yr,s=(t="advanced_disable_flags")in(e=o)&&!ot(e[t]),n=i in e&&!ot(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){var t;if(ot(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(ht),r=Xe(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),ot(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return dt(e.event)?yr.warn(o+". This can cause unexpected behavior."):yr.info(o),null}s.properties&&!tt(s.properties)||yr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&ot(s.properties[a]))return yr.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=ut(e)&&!e,i=jr._is_supported()&&"true"===jr._get("ph_debug");return!t&&(!!i||e)}}da.__defaultExtensionClasses={},da._noopLogger={trace:Yo=()=>{},debug:Yo,info:Yo,warn:Yo,error:Yo,fatal:Yo},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Pr(e.prototype[t[i]])}(da,["identify"]);class ha{constructor(e){this.disabled=!1===e;var t=et(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 _a="$copy_autocapture",pa=br("[AutoCapture]");function ga(e,t){return t.length>e?t.slice(0,e)+"...":t}function va(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!ts(t));return t}function fa(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:c}=t;if(!ts(e))return{props:{}};for(var d=[e],h=e;h.parentNode&&!is(h,"body");)if(ss(h.parentNode))d.push(h.parentNode.host),h=h.parentNode.host;else{if(!ts(h.parentNode))break;d.push(h.parentNode),h=h.parentNode}var _,p,g=[],v={},f=!1,m=!1;if(Sr(d,(e=>{var t=xs(e);if(is(e,"a")){var i=e.getAttribute("href");f=!!(t&&i&&Rs(i))&&(c?Ii(i):i)}We(as(e),"ph-no-capture")&&(m=!0),g.push(function(e,t,i,r,s){void 0===s&&(s=!1);var n=e.tagName.toLowerCase(),o={tag_name:n};ds.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?ga(1024,Ls(e)):ga(1024,us(e)));var a=as(e);a.length>0&&(o.classes=a.filter((function(e){return""!==e}))),Sr(e.attributes,(function(i){var n;if((!Es(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Rs(i.value)&&(!rt(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=ns(a).join(" ")),o["attr__"+i.name]=ga(1024,"href"===i.name&&s?Ii(a):a)}}));for(var l=1,u=1,c=e;c=va(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(!xs(e))return{};var t={};return Sr(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&&Rs(r)&&(t[i]=r)}})),t}(e);xr(v,r)})),m)return{props:{},explicitNoCapture:m};if(a||(g[0].$el_text=is(e,"a")||is(e,"button")?Ls(e):us(e)),f){var y,b;g[0].attr__href=f;var w=null==(y=Ks(f))?void 0:y.host,S=null==fe||null==(b=fe.location)?void 0:b.host;w&&S&&w!==S&&(_=f)}return{props:xr({$event_type:n.type,$ce_version:1},u?{}:{$elements:g},{$elements_chain:(p=g,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 Er(o).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return a[As(t.toString())]=As(i.toString())})),(s+=":")+Er(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).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:$s(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Er(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(p)))},null!=(r=g[0])&&r.$el_text?{$el_text:null==(s=g[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},v)}}var ma=br("[ExceptionAutocapture]"),ya=br("[TracingHeaders]"),ba=br("[Web Vitals]"),wa=9e5,Sa="disabled",xa="lazy_loading",Ea="awaiting_config",ka="missing_config";br("[SessionRecording]"),br("[SessionRecording]");var Pa="[SessionRecording]",Ia=br(Pa),Ca=br("[Heatmaps]");function Fa(e){return et(e)&&"clientX"in e&&"clientY"in e&&at(e.clientX)&&at(e.clientY)}var Ta=br("[Product Tours]"),Ra=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(m))},La=["$set_once","$set"],Ma=br("[SiteApps]"),Aa="Error while initializing PostHog app with config id ";function $a(e,t,i){if(ot(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 Oa{constructor(e){this._debugEventEmitter=new Fo,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;it(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(!it(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(null==t?void 0: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(!$a(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=>$a(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&$a((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=>$a(e.text,t.text,t.text_matching||"exact")||$a(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;!ot(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=>$a(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||qo(t.properties.reduce(((e,t)=>{var i=Xe(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 Da{constructor(e){this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&qo(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===yn?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;it(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 Oa(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,yn),this._cancelEventToItems=this._buildEventToItemMap(e,bn))}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}),void this._persistActivation(n)}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,bn);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,yn);this._activateItems(l.map((e=>e.id)))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){0!==e.length&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...e])],this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}))}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter((t=>t!==e));var t=this._getPersistedActivatedIds();t.includes(e)||this._setActivatedItems([...t,e])}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter((e=>!t.has(e)));var i=this._getPersistedActivatedIds(),r=i.filter((e=>!t.has(e)));r.length!==i.length&&this._setActivatedItems(r)}_getPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter((e=>!this._isItemPermanentlyIneligible(e)))}reset(){this._pendingActivatedItems=[],this._getPersistedActivatedIds().length>0&&this._setActivatedItems([])}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class qa extends Da{constructor(e){super(e)}_getActivatedKey(){return H}_getShownEventName(){return wn}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return jo}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[H]:e})}_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,i,r,s=(null!==(t=null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==t?t:0)>0;return"always"===e.schedule||!(null==(r=e.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?e===wn?"consume":"ignore":e===wn?"persist":e===Sn||e===xn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Ba="SDK is not enabled or survey functionality is not yet loaded",za="Disabled. Not loading surveys.",Ha=null!=fe&&fe.location?Xs(fe.location.hash,"__posthog")||Xs(location.hash,"state"):null,Na="_postHogToolbarParams",ja=br("[Toolbar]"),Ua=br("[FeatureFlags]"),Va=br("[FeatureFlags]",{debugEnabled:!0}),Wa="\" failed. Feature flags didn't load in time.",Ga=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Qa=e=>{var t={};for(var[i,r]of Er(e||{}))r&&(t[i]=r);return t},Ka=br("[Error tracking]"),Ja="Refusing to render web experiment since the viewer is a likely bot",Ya={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>Ao(t,e),not_regex:(e,t)=>!Ao(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class Xa{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Xa._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Xa._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);rt(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];Xa._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())Xa._logInfo(Ja);else if(!this._config.disable_web_experiments){if(ot(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Xa._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=Xa.getWindowLocation();if(null!=e&&e.search){var t=Js(null==e?void 0:e.search,"__experiment_id"),i=Js(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Xa._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",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&&(Xa._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!ot(e.conditions)&&Xa._matchUrlConditions(e,t)&&Xa._matchUTMConditions(e)}static _matchUrlConditions(e,t){var i;if(ot(e.conditions)||ot(null==(i=e.conditions)?void 0:i.url))return!0;var r=Xa.getWindowLocation();if(r){var s,n,o,a=Jr(t,r.href);return null==(s=e.conditions)||!s.url||Ya[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==fe?void 0:fe.location}static _matchUTMConditions(e){var t;if(ot(e.conditions)||ot(null==(t=e.conditions)?void 0:t.utm))return!0;var i=nn();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];yr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Xa._logInfo(Ja):"control"!==t?i.forEach((i=>{if(i.selector){var r;Xa._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)}))}})):Xa._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ye&&this._instance?Lo(ye,this._config.custom_blocked_useragents):void 0}}var Za=br("[Conversations]"),el="Conversations not available yet.",tl="console",il={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=[],fe&&Tr(fe,"online",this._onOnline)}destroy(){null==fe||fe.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,Ua.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||(Ua.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||Ua.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(!it(e)){if(Xe(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Ua.error("Invalid flag key found:",e,"Expected non-empty string"),t}));Ua.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,{config:i}=this._instance,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(L))&&void 0!==n?n:{},l=i({},o,e),u=i({},a,t),c={};for(var[d,h]of Object.entries(l))c[d]={key:d,enabled:Te(h),variant:Re(h),reason:void 0,metadata:it(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}};this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(R),t=this._prop(A),r=this._prop(O);if(!r&&!t)return e||{};var s=xr({},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=it(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,h=it(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||(Ua.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:Te(r),variant:Re(r),payload:Fe(t[i])}}))}getFlagVariants(){var e=this._prop(C),t=this._prop(A);if(!t)return e||{};for(var i=xr({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ua.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(L),t=this._prop(O);if(!t)return e||{};for(var i=xr({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ua.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,s=this._prop(a),n={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)||{}),group_properties:this._prop(q),timezone:_n()};nt(s)||it(s)||(n.$device_id=s),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_contexts=this._getValidEvaluationEnvironments());var o=this._getValidFlagKeys();it(o)||(n.flag_keys=o);var l=!!this._config.advanced_only_evaluate_survey_feature_flags,u=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:u,data:n,compression:this._config.disable_compression?void 0:Tn,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,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;var o=[];e.error?e.error instanceof Error?o.push("AbortError"===e.error.name?"timeout":"connection_error"):o.push("unknown_error"):200!==e.statusCode&&o.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var a,u=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&o.push("quota_limited"),null==(r=this._persistence)||r.register({[V]:o}),u)Ua.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 n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},s,{partialResponse:l}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}_hasStatusZeroCircuitBreakerTripped(){return this._consecutiveStatusZeroFailures>=3&&Ce()}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=((e,t,i,r)=>{if(0===e){if(Ce()){var s=t+1;return 3===s&&Ua.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."),s}return t}return 0})(e,this._consecutiveStatusZeroFailures)}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 Ua.warn('getFeatureFlag for key "'+e+Wa)}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(M)||void 0,l=this._prop(W)||void 0,u=this._prop(j)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),h=this._prop(U);d&&d!==h&&(u={},null==(c=this._persistence)||c.register({[j]:u,[U]: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;Xe(u[e])?u[e].push(o):u[e]=[o],null==(_=this._persistence)||_.register({[j]:u});var x=this.getFeatureFlagDetails(e),E=[...null!==(p=this._prop(V))&&void 0!==p?p:[]];it(s)&&E.push("flag_missing");var k={$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};it(null==x||null==(f=x.metadata)?void 0:f.version)||(k.$feature_flag_version=x.metadata.version);var P,I=null!==(m=null==x||null==(y=x.reason)?void 0:y.description)&&void 0!==m?m:null==x||null==(b=x.reason)?void 0:b.code;I&&(k.$feature_flag_reason=I),null!=x&&null!=(w=x.metadata)&&w.id&&(k.$feature_flag_id=x.metadata.id),it(null==x?void 0:x.original_variant)&&it(null==x?void 0:x.original_enabled)||(k.$feature_flag_original_response=it(x.original_variant)?x.original_enabled:x.original_variant),null!=x&&null!=(S=x.metadata)&&S.original_payload&&(k.$feature_flag_original_payload=null==x||null==(P=x.metadata)?void 0:P.original_payload),E.length&&(k.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",k)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Fe(n)}}}else Ua.warn('getFeatureFlagResult for key "'+e+Wa)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments());var s=this._getValidFlagKeys();it(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:Tn,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){if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return it(i)?void 0:!!i}Ua.warn('isFeatureEnabled for key "'+e+Wa)}}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&&Ua.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(Xe(u)){Ua.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({[F]:u,[C]:_})}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=>{var[t]=e;return m.has(t)})))),v=i({},s,Object.fromEntries(Object.entries(v||{}).filter((e=>{var[t]=e;return m.has(t)})))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>{var[t]=e;return m.has(t)}))))}else g=i({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[F]:Object.keys(Qa(g)),[C]:g||{},[L]:v||{},[R]:f||{}},d?{[M]:d}:{},h?{[W]:h}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Ua.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Ua.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(A),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),Va.info("All overrides cleared");if(Xe(e)){var t=Ga(e);return this._persistence.register({[A]:t}),this._fireFeatureFlagsCallbacks(),Va.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(A),Va.info("Flag overrides cleared");else if(r.flags){if(Xe(r.flags)){var s=Ga(r.flags);this._persistence.register({[A]:s})}else this._persistence.register({[A]:r.flags});Va.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),Va.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),Va.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[A]:e}),this._fireFeatureFlagsCallbacks(),Va.info("Flag overrides set",{flags:e});Ua.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){Ua.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(T)||[]).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({[F]:Object.keys(Qa(l)),[C]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(T),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",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(T),null==(r=this._persistence)||r.register({[T]: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{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>{try{r(t,i,{errorsLoading:e})}catch(e){Ua.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(q)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[q]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(q)||{};this._instance.register({[q]:i({},t,{[e]:{}})})}else this._instance.unregister(q)}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}}},rl={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===Ea||this._recordingStatus===ka?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=Sa,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Ia.error("started without valid sessionManager"),new Error(Pa+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===ae)throw new Error(Pa+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(b))||!e.enabled),i=!this._config.disable_session_recording,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return fe&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!it(Object.assign)&&!it(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Ia.info("starting")):(this._recordingStatus=Sa,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==Ea&&this._recordingStatus!==ka&&(this._recordingStatus=xa),null!=Ie&&null!=(t=Ie.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Ie.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=Ie.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Ia.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(I),null==(t=this._persistence)||t.unregister(w)}_validateSampleRate(e,t){if(ot(e))return null;var i,r=at(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ia.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;ot(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[b]: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:it(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){return"sessionRecording"in e?!1===e.sessionRecording?(this._persistRemoteConfig(e),void this._discardRecording()):(this._persistRemoteConfig(e),void this.startIfEnabledOrStop()):(this._recordingStatus===Ea&&(this._recordingStatus=ka,Ia.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):Ia.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(b);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t,i=this._instance.get_property(b);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(e){return Ia.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=Ie.__PosthogExtensions__)||!t.initSessionRecording)return Ia.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[se]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Ie.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===ka||this._recordingStatus===Ea)return;return this._recordingStatus=Ea,Ia.info("persisted remote config is stale, requesting fresh config before starting"),void new Cn(this._instance).load()}this._recordingStatus=xa,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({[x]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[S]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?E:k]:!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))}}},sl={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new ha(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=et(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(fe&&be){var e=e=>{e=e||(null==fe?void 0:fe.event);try{this._captureEvent(e)}catch(e){pa.error("Failed to capture event",e)}};if(Tr(be,"submit",e,{capture:!0}),Tr(be,"change",e,{capture:!0}),Tr(be,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==fe?void 0:fe.event);try{this._captureEvent(e,_a)}catch(e){pa.error("Failed to capture copy/cut event",e)}};Tr(be,"copy",t,{capture:!0}),Tr(be,"cut",t,{capture:!0})}}}else pa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[d]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==be?void 0:be.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[d];if(nt(this._isDisabledServerSide)&&!ut(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=cs(e);rs(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())&&bs(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===_a;if(r&&function(e,t,i,r,s,n){var o,a,l,u,c,d;if(void 0===i&&(i=void 0),!fe||ws(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!os(i.url_allowlist,n))return!1;if(null!=(a=i)&&a.url_ignorelist&&os(i.url_ignorelist,n))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var h=i.dom_event_allowlist;if(h&&!h.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:_,targetElementList:p}=Ss(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(it(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}(p,i))return!1;if(!hs(p,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(hs(p,null!==(c=null==(d=i)?void 0:d.css_selector_ignorelist)&&void 0!==c?c:ps))return!1;try{var g=fe.getComputedStyle(e);if(g&&"pointer"===g.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}var v=e.tagName.toLowerCase();switch(v){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 _?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(ds.indexOf(v)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:o}=fa(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});if(o)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(n.$element_selectors=a),t===_a){var l,u=ls(null==fe||null==(l=fe.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return Ze(null==be?void 0:be.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==fe||null==(t=fe.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(yr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,yr.info("History API monitoring stopped")}monitorHistoryChanges(){fe&&fe.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener())}_patchHistoryMethod(e){var t;if(fe&&(null==(t=fe.history[e])||!t.__posthog_wrapped__)){var i=this;!function(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return Ze(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]===s&&(e[t]=r)}}catch(e){return()=>{}}}(fe.history,e,(t=>function(r,s,n){t.call(this,r,s,n),i._capturePageview(e)}))}}_capturePageview(e){try{var t,i=null==fe||null==(t=fe.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(_e,{navigation_type:e}),this._lastPathname=i}catch(t){yr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Tr(fe,"popstate",e),this._popstateListener=()=>{fe&&fe.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[h]),this.rageclicks=new ha(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return et(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return ot(this._config.capture_heatmaps)?ot(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Ca.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("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[h]:t}),this._enabledServerSide=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(be)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){fe&&be&&(this._flushHandler=this._flush.bind(this),Tr(fe,he,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==fe?void 0:fe.event)),Tr(be,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==fe?void 0:fe.event)),Tr(be,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Bs(this.instance,Ds,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Tr(be,de,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;fe&&be&&(this._flushHandler&&fe.removeEventListener(he,this._flushHandler),this._onClickHandler&&be.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&be.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&be.removeEventListener(de,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&&ts(r)&&!is(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:fe)?void 0:n.getComputedStyle(r).position}catch(e){return!1}if(We(t,s))return!0;r=_s(r)}return!1}(cs(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"),!es(e.target)&&Fa(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&bs(cs(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!es(e.target)&&Fa(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(fe){var t=this._config.disable_capture_url_hashes?Ii(fe.location.href):fe.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...en,...i||[]]:[],s=Ys(t,r,rn);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!tt(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Bs,webVitalsAutocapture:class{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!it(r))if(ot(null==e?void 0:e.name)||ot(null==e?void 0:e.value))ba.error("Invalid metric received",e);else if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),it(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=it(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),n=i({},e,{$current_url:r,timestamp:Date.now()});it(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this._buffer.metrics.push(n),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else ba.error("Ignoring metric with value >= "+this._maxAllowedValue,e)},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Ie.__PosthogExtensions__;it(s)||it(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):ba.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[v]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=et(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return ot(i)?(null==(t=this._instance.persistence)?void 0:t.props[y])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(et(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=et(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=et(this._perfConfig)&&at(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:wa;return e>0&&6e4>=e?wa:e}get isEnabled(){var e=null==we?void 0:we.protocol;if("http:"!==e&&"https:"!==e)return ba.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=et(this._perfConfig)?this._perfConfig.web_vitals:ut(this._perfConfig)?this._perfConfig:void 0;return ut(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(ba.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=et(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=et(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[v]:t}),this._instance.persistence.register({[y]:i})),this._enabledServerSide=t,this.startIfEnabled()}}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?ba.error("failed to load script",t):e()}))}_currentURL(){var e=fe?this._instance.config.disable_capture_url_hashes?Ii(fe.location.href):fe.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...en,...t||[]]:[];return Ys(e,i,rn)}ba.error("Could not determine current URL")}}},nl={exceptionObserver:class{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(fe&&this.isEnabled&&null!=(e=Ie.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Ie.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ie.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ie.__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){ma.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[_]),this._rateLimiter=new bt({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,_logger:ma}),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 et(e)?t=i({},t,e):(it(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?(ma.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return ma.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){"autocaptureExceptions"in e&&(this._remoteEnabled=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_]: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)?ma.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 Ni([new er,new cr,new ir,new tr,new lr,new ar,new sr,new ur],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=Zi.test(l)?l.replace(Zi,"$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||ji});var r}))}(n)}}("web:javascript",Ki,Xi)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(p))&&void 0!==t?t:[],this._exceptionStepsConfig=gr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new vr(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=gr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if("errorTracking"in e){var s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,this._instance.persistence&&this._instance.persistence.register({[p]:this._suppressionRules,[g]:n})}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(g),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(!rt(e)||0===e.trim().length)return void Ka.warn("Ignoring exception step because message must be a non-empty string");var r=this._coerceExceptionStepProperties(t),{sanitizedProperties:s,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>_r.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(r);n.length>0&&Ka.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[dr]:e,[hr]:(new Date).toISOString()},s))}catch(e){Ka.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 Ka.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 Ka.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 Ka.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&ot(e.$exception_steps)?this._addBufferedExceptionSteps(e):e;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return Ka.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void Ka.error("Failed to process exception event. Ignoring this exception.",e)}}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return Ka.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[dr]:e,[hr]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return et(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;var t=e.reduce(((e,t)=>{var{type:i,value:r}=t;return rt(i)&&i.length>0&&e.$exception_types.push(i),rt(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,r=Oo[e.operator],s=Xe(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_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!ot(e)&&Xe(e)}}},ol=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("productTours"in e){var t,i;if(this._persistence&&this._persistence.register({[m]:!!e.productTours}),!Ra(this._instance))return!this._productTourManager&&ot(null==(t=this._persistence)?void 0:t.props[N])||Ta.info("product tours disabled; stopping and clearing cached tours"),null==(i=this._productTourManager)||i.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&Ra(this._instance)&&this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Ie.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Ta.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Ie.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Ie.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Xe(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[N];if(Xe(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",callback:t=>{if(Ra(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return Ta.error(s),void e([],{isLoaded:!1,error:s})}var n=Xe(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[N]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){ot(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(N)}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)}}},il),al={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=Ie._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[_,p]of Object.entries(h))c[_]={id:d[_],type:_,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,La),{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)||(Ma.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)||(Ma.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==be?void 0:be.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=>!nt(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&&(Ma.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,Ma.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this._runWithPreparedSiteAppElements((t=>e.init({posthog:this._instance,callback(e){t(),s(e)}})),!1);n&&(t.processEvent=n),r=!0}catch(t){Ma.error(Aa+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){Ma.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){Ma.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 Ma.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;Ie["__$$ph_site_app_"+e]=s._instance,null==(t=Ie.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,(t=>{if(t)return Ma.error(Aa+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Ma.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ll={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?(it(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=Ie.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),it(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=Ie.__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=Ie.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=Ie.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return ya.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 Xe(e)?(Xe(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(Xe(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()}}},ul=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){var t=e.surveys;if(ot(t))return jo.warn("Flags not loaded yet. Not loading surveys.");var i=Xe(t);this._isSurveysEnabled=i?t.length>0:t,jo.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(Uo)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)jo.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)jo.info(za);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())jo.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e){if(!it(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(ne);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 jo.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new qa(this._instance),jo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){jo.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 jo.info(za),e([]);var i,r=this._instance.get_property(B);if(r&&!t)return e(r,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:r}=t;return e(i,r)})):("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",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;jo.error(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)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(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({[B]:l,[z]: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(z);return at(e)&&Date.now()-e>3e5}_isSurveyRefreshBackingOff(){return at(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};Vo(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){jo.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!ot(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);jo.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(ot(this._surveyManager))return{eligible:!1,reason:Ba};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(ot(this._surveyManager))return jo.warn("init was not called"),{visible:!1,disabledReason:Ba};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return ot(this._surveyManager)?(jo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ba})):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._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(ot(this._surveyManager))jo.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Wo.includes(s.type)){var n=null==be?void 0:be.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(jo.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;jo.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),jo.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);jo.warn("Survey element not found")}else jo.warn("Surveys of type "+s.type+" cannot be rendered in the app");else jo.warn("Survey not found")}}displaySurvey(e,t){var r;if(ot(this._surveyManager))jo.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!==En&&t.initialResponses&&jo.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(s);if(!o.visible)return void jo.warn("Survey is not eligible to be displayed: ",o.disabledReason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else jo.warn("Survey not found")}}cancelPendingSurvey(e){ot(this._surveyManager)?jo.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},il),cl={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Ie.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Ie.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),Rr(this.instance.config))return!1;if(!fe||!be)return!1;e=null!=e?e:fe.location,i=null!=i?i:fe.history;try{if(!t){try{fe.localStorage.setItem("test","test"),fe.localStorage.removeItem("test")}catch(e){return!1}t=null==fe?void 0:fe.localStorage}var r,s=Ha||Xs(e.hash,"__posthog")||Xs(e.hash,"state"),n=s?kr((()=>JSON.parse(atob(decodeURIComponent(s)))))||kr((()=>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(Na)||"{}")).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=Ie.ph_load_toolbar||Ie.ph_load_editor;!ot(t)&&Ze(t)?t(e,this.instance):ja.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==be||!be.getElementById(ee));if(!fe||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(fe.localStorage.setItem(Na,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=Ie.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return ja.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Tr(fe,"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)}}},dl=i({experiments:Xa},il),hl=i({},il,rl,sl,nl,ol,al,ul,ll,cl,dl,{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){var t=e.conversations;ot(t)||(ut(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||Rr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e&&!it(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(ne);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 Za.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Za.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Za.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Za.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():Za.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!nt(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):(Za.warn(el),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(Za.warn(el),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(Za.warn(el),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(Za.warn(el),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(Za.warn(el),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(Za.warn(el),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Za.warn(el),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()}}},{logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=br("[logs]"),this._queue=[],this._consoleQueue=[],this._onReconnect=()=>{var e,t;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),fe&&Tr(fe,"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=it(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 Di(this._createHost(e,t),n,this._logger,(()=>this._getSdkContext()),(e=>e()),void 0,r),n]}_getCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;return this._core&&this._resolvedFrom===i||(null==(t=this._core)||t.reset(),this._resolvedFrom=i,[this._core,this._resolvedConfig]=this._buildCore((()=>this._queue),(e=>{this._queue=e}))),this._core}_getConsoleCore(){var e,t,i=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;return this._consoleCore&&this._consoleResolvedFrom===i||(null==(t=this._consoleCore)||t.reset(),this._consoleResolvedFrom=i,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore((()=>this._consoleQueue),(e=>{this._consoleQueue=e}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},tl)),this._consoleCore}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!ot(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()}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._logger.error("PostHog logs flush failed:",e))),this._consoleCore&&this._consoleCore.flush().catch((e=>this._logger.error("PostHog logs flush failed:",e))))}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Ie?void 0:Ie.__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(ne)}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===Me.LogsQueue?e():void 0,setPersistedProperty(e,i){var r;e===Me.LogsQueue&&t(null!==(r=i)&&void 0!==r?r:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>n.LIB_NAME,getLibraryVersion:()=>n.LIB_VERSION}}_sendLogsBatch(e){return new Promise((t=>{var i=!1,r=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("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(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;r({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,n.LIB_NAME,(e=>{this._queue=e})),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,tl,(e=>{this._consoleQueue=e}))}_drainQueueViaTransport(e,t,i,r,s){if(0!==t.length){var o=t.map((e=>e.record));s([]);var a=Oi(o,$i(i,n.LIB_NAME,n.LIB_VERSION),r,n.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{sessionId:i,windowId:r,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=i,t.windowId=r,ot(s)||(t.sessionStartTimestamp=s),ot(n)||(t.lastActivityTimestamp=n)}if(null!=Ie&&null!=(e=Ie.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Ii(Ie.location.href):Ie.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}});da.__defaultExtensionClasses=i({},hl),function(){n.SDK_DIST_CHANNEL="cdn";var e=Xo[na]=new da,t=Ie.posthog;t&&Sr(t._i,(function(i){if(i&&Xe(i)){var r=e.init(i[0],i[1],i[2]),s=t[i[2]]||t;r&&(r._execute_array.call(r.people,s.people),r._execute_array(s))}})),Ie.posthog=e,function(){function e(){e.done||(e.done=!0,oa=!1,Sr(Xo,(function(e){e._dom_loaded()})))}null!=be&&be.addEventListener?"complete"===be.readyState?e():Tr(be,"DOMContentLoaded",e,{capture:!1}):fe&&yr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
2
2
|
//# sourceMappingURL=array.no-external.js.map
|