posthog-js 1.396.2 → 1.396.3

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.
Files changed (43) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.js +1 -1
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -1
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -1
  9. package/dist/array.no-external.js +1 -1
  10. package/dist/customizations.full.js +1 -1
  11. package/dist/default-extensions.js +1 -1
  12. package/dist/extension-bundles.js +1 -1
  13. package/dist/lazy-recorder.js +1 -1
  14. package/dist/main.js +1 -1
  15. package/dist/module.full.js +1 -1
  16. package/dist/module.full.js.map +1 -1
  17. package/dist/module.full.no-external.js +1 -1
  18. package/dist/module.full.no-external.js.map +1 -1
  19. package/dist/module.js +1 -1
  20. package/dist/module.no-external.js +1 -1
  21. package/dist/module.slim.js +1 -1
  22. package/dist/module.slim.no-external.js +1 -1
  23. package/dist/posthog-recorder.js +1 -1
  24. package/dist/product-tours.js +1 -1
  25. package/dist/src/entrypoints/web-vitals-with-attribution.d.ts +19 -0
  26. package/dist/src/entrypoints/web-vitals.d.ts +18 -0
  27. package/dist/surveys.js +1 -1
  28. package/dist/web-vitals-with-attribution.js +1 -1
  29. package/dist/web-vitals-with-attribution.js.map +1 -1
  30. package/dist/web-vitals.js +1 -1
  31. package/dist/web-vitals.js.map +1 -1
  32. package/lib/package.json +1 -1
  33. package/lib/src/entrypoints/web-vitals-with-attribution.d.ts +19 -0
  34. package/lib/src/entrypoints/web-vitals-with-attribution.js +3 -0
  35. package/lib/src/entrypoints/web-vitals-with-attribution.js.map +1 -1
  36. package/lib/src/entrypoints/web-vitals.d.ts +18 -0
  37. package/lib/src/entrypoints/web-vitals.js +3 -0
  38. package/lib/src/entrypoints/web-vitals.js.map +1 -1
  39. package/lib/src/utils/array-at-polyfill.d.ts +0 -0
  40. package/lib/src/utils/array-at-polyfill.js +33 -0
  41. package/lib/src/utils/array-at-polyfill.js.map +1 -0
  42. package/lib/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- 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.2",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",_="$heatmaps_enabled_server_side",h="$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",E="$replay_override_linked_flag",x="$replay_override_url_trigger",P="$replay_override_event_trigger",k="$sesid",I="$session_is_sampled",T="$enabled_feature_flags",C="$active_feature_flags",F="$early_access_features",R="$feature_flag_details",L="$feature_flag_payloads",A="$feature_flag_request_id",M="$override_feature_flags",O="$override_feature_flag_payloads",D="$stored_person_properties",N="$stored_group_properties",B="$surveys",U="$surveys_loaded_at",q="$surveys_activated",H="ph_product_tours",z="$flag_call_reported",j="$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",Y="$initial_campaign_params",J="$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",_e="beforeunload",he="$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,Ee=null!=me&&me.XMLHttpRequest&&"withCredentials"in new me.XMLHttpRequest?me.XMLHttpRequest:void 0,xe=null==me?void 0:me.AbortController,Pe=null==me?void 0:me.CompressionStream,ke=null==ye?void 0:ye.userAgent,Ie=null!=fe?fe:{},Te=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Ce(e){return"string"==typeof e||e}function Fe(e){return"string"==typeof e?e:void 0}var Re,Le=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}({}),Me=["$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"],$e="NativeGzipValidationError",De=e=>e.length>=2&&31===e[0]&&139===e[1],Ne=(e,t)=>e===Ae.GZipJS||t===Ae.GZipJS||"gzip"===t,Be=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),Ue=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=$e,t},qe=function(){var e=t((function*(e,t){18>e.size&&Ue("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());De(i)&&8===i[2]||Ue("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Re)return Re;Re=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Re[e]=t>>>0}return Re})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&Ue("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&Ue("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function He(){return He=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 qe(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),He.apply(this,arguments)}var ze=["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"],je=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return ze.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function Ve(e,t){return-1!==e.indexOf(t)}var We=function(e){return e.trim()},Ge=function(e){return e.replace(/^\$/,"")},Qe=Object.prototype,Ke=Qe.hasOwnProperty,Ye=Qe.toString,Je=Array.isArray||function(e){return"[object Array]"===Ye.call(e)},Xe=e=>"function"==typeof e,Ze=e=>e===Object(e)&&!Je(e),et=e=>{if(Ze(e)){for(var t in e)if(Ke.call(e,t))return!1;return!0}return!1},tt=e=>void 0===e,it=e=>"[object String]"==Ye.call(e),rt=e=>it(e)&&0===e.trim().length,st=e=>null===e,nt=e=>tt(e)||st(e),ot=e=>"[object Number]"==Ye.call(e)&&e==e,at=e=>ot(e)&&e>0,lt=e=>"[object Boolean]"===Ye.call(e),ut=e=>e instanceof FormData,ct=e=>Ve(Me,e),dt=e=>Ve(Oe,e);function _t(e){return null===e||"object"!=typeof e}function ht(e,t){return{}.toString.call(e)==="[object "+t+"]"}function pt(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var gt=[!0,"true",1,"1","yes"],vt=e=>Ve(gt,e),ft=[!1,"false",0,"0","no"];function mt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),ot(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),mt(s||i,t,i,r))}class yt{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=mt(e.bucketSize,0,100,e._logger),this._refillRate=mt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=mt(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 bt="Mobile",wt="iOS",St="Android",Et="Tablet",xt=St+" "+Et,Pt="iPad",kt="Apple",It=kt+" Watch",Tt="Safari",Ct="BlackBerry",Ft="Samsung",Rt=Ft+"Browser",Lt=Ft+" Internet",At="Chrome",Mt=At+" OS",Ot=At+" "+wt,$t="Internet Explorer",Dt=$t+" "+bt,Nt="Opera",Bt=Nt+" Mini",Ut="Edge",qt="Microsoft "+Ut,Ht="Firefox",zt=Ht+" "+wt,jt="Nintendo",Vt="PlayStation",Wt="Xbox",Gt=St+" "+bt,Qt=bt+" "+Tt,Kt="Windows",Yt=Kt+" Phone",Jt="Nokia",Xt="Ouya",Zt="Generic",ei=Zt+" "+bt.toLowerCase(),ti=Zt+" "+Et.toLowerCase(),ii="Konqueror",ri="Oculus Browser",si="Vivaldi",ni="Yandex",oi="Whale",ai="DuckDuckGo",li="Pale Moon",ui="Waterfox",ci="Brave",di="Google Search App",_i="(\\d+(\\.\\d+)?)",hi=new RegExp("Version/"+_i),pi=new RegExp(Wt,"i"),gi=new RegExp(Vt+" \\w+","i"),vi=new RegExp(jt+" \\w+","i"),fi=new RegExp(Ct+"|PlayBook|BB10","i"),mi={"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"},yi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?ci:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&Ve(e,"GSA/")?di:Ve(e," OPR/")&&Ve(e,"Mini")?Bt:Ve(e," OPR/")?Nt:fi.test(e)?Ct:Ve(e,"IE"+bt)||Ve(e,"WPDesktop")?Dt:Ve(e,"OculusBrowser")?ri:Ve(e,Rt)?Lt:Ve(e,Ut)||Ve(e,"Edg/")?qt:Ve(e,si+"/")?si:Ve(e,"YaBrowser/")?ni:Ve(e,oi+"/")?oi:Ve(e,ai+"/")||Ve(e,"Ddg/")?ai:Ve(e,"FBIOS")?"Facebook "+bt:Ve(e,"UCWEB")||Ve(e,"UCBrowser")?"UC Browser":Ve(e,"CriOS")?Ot:Ve(e,"CrMo")||Ve(e,At)?At:Ve(e,St)&&Ve(e,Tt)?Gt:Ve(e,"FxiOS")?zt:Ve(e.toLowerCase(),ii.toLowerCase())?ii:Ve(e,ci+"/")?ci:((e,t)=>t&&Ve(t,kt)||function(e){return Ve(e,Tt)&&!Ve(e,At)&&!Ve(e,St)}(e))(e,t)?Ve(e,bt)?Qt:Tt:Ve(e,"PaleMoon/")?li:Ve(e,ui+"/")?ui:Ve(e,Ht)?Ht:Ve(e,"MSIE")||Ve(e,"Trident/")?$t:Ve(e,"Gecko")?Ht:"")},bi={[Dt]:[new RegExp("rv:"+_i)],[qt]:[new RegExp(Ut+"?\\/"+_i)],[At]:[new RegExp("("+At+"|CrMo)\\/"+_i)],[Ot]:[new RegExp("CriOS\\/"+_i)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+_i)],[Tt]:[hi],[Qt]:[hi],[Nt]:[new RegExp("(Opera|OPR)\\/"+_i)],[Ht]:[new RegExp(Ht+"\\/"+_i)],[zt]:[new RegExp("FxiOS\\/"+_i)],[ii]:[new RegExp("Konqueror[:/]?"+_i,"i")],[Ct]:[new RegExp(Ct+" "+_i),hi],[Gt]:[new RegExp("android\\s"+_i,"i")],[Lt]:[new RegExp(Rt+"\\/"+_i)],[ri]:[new RegExp("OculusBrowser\\/"+_i)],[si]:[new RegExp(si+"\\/"+_i)],[ni]:[new RegExp("YaBrowser\\/"+_i)],[oi]:[new RegExp(oi+"\\/"+_i)],[ci]:[new RegExp(ci+"\\/"+_i)],[ai]:[new RegExp("(DuckDuckGo|Ddg)\\/"+_i)],[li]:[new RegExp("PaleMoon\\/"+_i)],[ui]:[new RegExp(ui+"\\/"+_i)],[di]:[new RegExp("GSA\\/"+_i)],[$t]:[new RegExp("(rv:|MSIE )"+_i)],Mozilla:[new RegExp("rv:"+_i)]},wi=function(e,t,i,r){var s=yi(e,t,i,r),n=bi[s];if(tt(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},Si=[[new RegExp(Wt+"; "+Wt+" (.*?)[);]","i"),e=>[Wt,e&&e[1]||""]],[new RegExp(jt,"i"),[jt,""]],[new RegExp(Vt,"i"),[Vt,""]],[fi,[Ct,""]],[new RegExp(Kt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Yt,""];if(new RegExp(bt).test(t)&&!/IEMobile\b/.test(t))return[Kt+" "+bt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=mi[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[Kt,r]}return[Kt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[wt,[e[3],e[4],e[5]||"0"].join(".")]:[wt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=tt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+St+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+St+")","i"),e=>e&&e[2]?[St,[e[2],e[3],e[4]||"0"].join(".")]:[St,""]],[/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/,[Mt,""]],[/Linux|debian/i,["Linux",""]]],Ei=function(e){return vi.test(e)?jt:gi.test(e)?Vt:pi.test(e)?Wt:new RegExp(Xt,"i").test(e)?Xt: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)?It:fi.test(e)?Ct:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Jt,"i").test(e)?Jt:/(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(bt).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)?St:xt:new RegExp("(pda|"+bt+")","i").test(e)?ei:new RegExp(Et,"i").test(e)&&!new RegExp(Et+" pc","i").test(e)?ti:""},xi=/^[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)&&xi.test(i)?e:t();var i}function ki(e){return e?e.split("#")[0]:e}function Ii(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var Ti=e=>e instanceof Error,Ci={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}},Fi=Ci.info;function Ri(e){if(lt(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(Je(e))return{arrayValue:{values:e.map((e=>Ri(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function Li(e){var t=[];for(var i in e){var r=e[i];st(r)||tt(r)||t.push({key:i,value:Ri(r)})}return t}function Ai(e,t){var r=e.level||"info",{text:s,number:n}=Ci[r]||Fi,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),nt(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),nt(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:Li(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),tt(e.trace_flags)||(u.flags=e.trace_flags),u}function Mi(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:Li(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let $i=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=Je(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(Le.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(Le.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(Le.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(Le.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return Mi(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(Le.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(Le.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Ii((()=>{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(Le.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=>Ii(t,e)))]):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=!1,r=i.flush(),s=new Promise((i=>Ii((()=>{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 Di,Ni,Bi;function Ui(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Bi&&i.length===Ni||(Ni=i.length,Bi=i.reduce(((i,r)=>{Di||(Di={});var s=Di[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,Di[r]=[l,u];break}}return i}),{})),Bi}}class qi{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&&Je(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:Ui(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 Hi="?";function zi(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?Hi:i,in_app:!0};return tt(r)||(n.lineno=r),tt(s)||(n.colno=s),n}var ji=(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]:Hi,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Vi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Gi=/\((\S*)(?::(\d+))(?::(\d+))\)/,Qi=(e,t)=>{var i=Vi.exec(e);if(i){var[,r,s,n]=i;return zi(t,r,Hi,+s,+n)}var o=Wi.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=Gi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=ji(o[1]||Hi,o[2]);return zi(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Ki=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Yi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ji=(e,t)=>{var i=Ki.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]||Hi;return[n,s]=ji(n,s),zi(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Xi=/\(error: (.*)\)/;class Zi{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=it(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 ht(e,"DOMException")}isDOMError(e){return ht(e,"DOMError")}}class er{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 tr{constructor(){}match(e){return ht(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 ir=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class rr{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(ir);return r&&(t=r[1],i=r[2]),[t,i]}}var sr=["fatal","error","warning","log","info","debug"];function nr(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 or{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 pt(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: "+nr(e)}isSeverityLevel(e){return it(e)&&!rt(e)&&sr.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(Ti(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class ar{match(e){return pt(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+nr(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class lr{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 ur{match(e){return ht(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!pt(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 cr="$message",dr="$timestamp",_r=new Set([cr,dr]),hr={enabled:!0,max_bytes:32768};function pr(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:hr.enabled,max_bytes:vr(e.max_bytes,hr.max_bytes)}:i({},hr)}class gr{constructor(e){this._entries=[],this._totalBytes=0,this._config=pr(e)}setConfig(e){this._config=pr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(t.has(i))return"[Circular]";t.add(i)}return i}}))}catch(e){return}}(e);if(t)try{var i=JSON.parse(t);if(!Ze(i))return;var r=i,s=r[cr],n=r[dr];if(!it(s)||0===s.trim().length)return;if(!it(n)&&!ot(n))return;return{step:r,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map((e=>e.step))}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function vr(e,t){if(!ot(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var fr=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(fe&&(n.DEBUG||Ie.POSTHOG_DEBUG||i)&&!tt(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)=>fr(e+" "+t,i)};return r},mr=fr("[PostHog.js]"),yr=mr.createLogger;function br(e,t){Je(e)&&e.forEach(t)}function wr(e,t){if(!nt(e))if(Je(e))e.forEach(t);else if(ut(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)Ke.call(e,i)&&t(e[i],i)}var Sr=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 xr=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){mr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),mr.critical(e)}}},kr=function(e){var t={};return wr(e,(function(e,i){(it(e)&&e.length>0||ot(e))&&(t[i]=e)})),t};var Ir=["herokuapp.com","vercel.app","netlify.app"];function Tr(e){var t=null==e?void 0:e.hostname;if(!it(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Ir)if(i===r)return!1;return!0}function Cr(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 Fr(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 ot(e)&&isFinite(e)&&Math.floor(e)===e});class Rr{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 Rr(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 Rr(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 Lr{constructor(){this._timestamp=0,this._counter=0,this._random=new Or}generate(){var e=this.generateOrAbort();if(tt(e)){this._timestamp=0;var t=this.generateOrAbort();if(tt(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 Rr.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,Mr=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&&!tt(fe.crypto)&&crypto.getRandomValues&&(Mr=e=>crypto.getRandomValues(e));class Or{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(Mr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var $r=()=>Dr().toString(),Dr=()=>(Ar||(Ar=new Lr)).generate(),Nr="",Br=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Ur={_is_supported:()=>!!be,_error(e){mr.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(Ur._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),Nr)return Nr;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_"+$r();!Nr&&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",Nr=n)}return Nr}(e);if(!i){var r=(e=>{var t=e.match(Br);return t?t[0]:""})(e);r!==i&&mr.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&&mr.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{Ur._set(e,"",-1,t)}catch(e){return}}},qr=null,Hr={_is_supported(){if(!st(qr))return qr;var e=!0;if(tt(fe))e=!1;else try{var t="__mplssupport__";Hr._set(t,"xyz"),'"xyz"'!==Hr._get(t)&&(e=!1),Hr._remove(t)}catch(t){e=!1}return e||mr.error("localStorage unsupported; falling back to cookie store"),qr=e,e},_error(e){mr.error("localStorage error: "+e)},_get(e){try{return null==fe?void 0:fe.localStorage.getItem(e)}catch(e){Hr._error(e)}return null},_parse(e){try{return JSON.parse(Hr._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==fe||fe.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Hr._error(e)}return!1},_remove(e){try{null==fe||fe.localStorage.removeItem(e)}catch(e){Hr._error(e)}}},zr=[a,"distinct_id",k,I,Z,X,G],jr={},Vr={_is_supported:()=>!0,_error(e){mr.error("memoryStorage error: "+e)},_get:e=>jr[e]||null,_parse:e=>jr[e]||null,_set:(e,t)=>(jr[e]=t,!0),_remove(e){delete jr[e]}},Wr=null,Gr={_is_supported(){if(!st(Wr))return Wr;if(Wr=!0,tt(fe))Wr=!1;else try{var e="__support__";Gr._set(e,"xyz"),'"xyz"'!==Gr._get(e)&&(Wr=!1),Gr._remove(e)}catch(e){Wr=!1}return Wr},_error(e){mr.error("sessionStorage error: ",e)},_get(e){try{return null==fe?void 0:fe.sessionStorage.getItem(e)}catch(e){Gr._error(e)}return null},_parse(e){try{return JSON.parse(Gr._get(e))||null}catch(e){}return null},_set(e,t){try{return null==fe||fe.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Gr._error(e)}return!1},_remove(e){try{null==fe||fe.sessionStorage.removeItem(e)}catch(e){Gr._error(e)}}};class Qr{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 vt(e)?1:Ve(ft,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Hr:Ur;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?Ur:Hr;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(vt(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=>vt(e)))}}function Kr(e,t){var i,r=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!Xe(r))return t;try{var s=r(t);return it(s)&&s?s:t}catch(e){return mr.error("Error in get_current_url, falling back to window.location.href",e),t}}var Yr=1,Jr=3,Xr=11;function Zr(e){return e instanceof Element&&(e.id===ee||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function es(e){return!!e&&e.nodeType===Yr}function ts(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function is(e){return!!e&&e.nodeType===Jr}function rs(e){return!!e&&e.nodeType===Xr&&es(e.host)}function ss(e){return e?We(e).split(/\s+/):[]}function ns(e,t){var i=function(e){var t,i=null==fe||null==(t=fe.location)?void 0:t.href;return tt(i)?void 0:Kr(e,i)}(t);return!!(i&&e&&e.some((e=>i.match(e))))}function os(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 ss(t)}function as(e){return nt(e)?null:We(e).split(/(\s+)/).filter((e=>Fs(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ls(e){var t="";return Ss(e)&&!Es(e)&&e.childNodes&&e.childNodes.length&&wr(e.childNodes,(function(e){var i;is(e)&&e.textContent&&(t+=null!==(i=as(e.textContent))&&void 0!==i?i:"")})),We(t)}function us(e){return tt(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var cs=["a","button","form","input","select","textarea","label"];function ds(e,t){if(tt(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||!es(t))&&t}var hs=[".ph-no-autocapture","[data-ph-no-autocapture]"],ps=["next","previous","prev",">","<"],gs=[...ps,"+","-","−","–"],vs=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,fs=[".ph-no-rageclick",".ph-no-capture"],ms=["","text","search","email","password","url","tel","number"];function ys(e,t){if(!fe||bs(e))return!1;var i,r,s,n,o;if(lt(t)?(i=!!t&&fs,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:fs,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||!es(e))&&(!!ts(e,"textarea")||(ts(e,"input")?Ve(ms,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var{targetElementList:a}=ws(e,!1);return!function(e,t){if(!1===e||tt(e))return!1;var i;if(!0===e)i=ps;else{if(!Je(e))return!1;if(e.length>10)return mr.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=>vs(t,e)||vs(r,e)))}))}(r,a.map((e=>{var t;return{safeText:ls(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!ds(a,i)}var bs=e=>!e||ts(e,"html")||!es(e),ws=(e,t)=>{if(!fe||bs(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!ts(s,"body");)if(rs(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=_s(s);if(!n)break;if(t||cs.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=fe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ss(e){for(var t=e;t.parentNode&&!ts(t,"body");t=t.parentNode){var i=os(t);if(Ve(i,"ph-sensitive")||Ve(i,"ph-no-capture"))return!1}if(Ve(os(e),"ph-include"))return!0;var r=e.type||"";if(it(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!it(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!!(ts(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ts(e,"select")||ts(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var xs="(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("^(?:"+xs+")$"),ks=new RegExp(xs),Is="\\d{3}-?\\d{2}-?\\d{4}",Ts=new RegExp("^("+Is+")$"),Cs=new RegExp("("+Is+")");function Fs(e,t){if(void 0===t&&(t=!0),nt(e))return!1;if(it(e)){if(e=We(e),(t?Ps:ks).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Ts:Cs).test(e))return!1}return!0}function Rs(e){var t=ls(e);return Fs(t=(t+" "+Ls(e)).trim())?t:""}function Ls(e){var t="";return e&&e.childNodes&&e.childNodes.length&&wr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=ls(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Ls(e)).trim())}catch(e){mr.error("[AutoCapture]",e)}})),t}function As(e){return e.replace(/"|\\"/g,'\\"')}function Ms(e){var t=e.attr__class;return t?Je(t)?t:ss(t):void 0}var Os=yr("[Dead Clicks]"),$s=()=>!0,Ds=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(f)),r=e.instance.config.capture_dead_clicks;return lt(r)?r:!!Ze(r)||i};class Ns{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=Ze(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 Bs=yr("[SegmentIntegration]");var Us="posthog-js";function qs(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,_;if("*"!==o&&!o.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,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==(_=g[0])?void 0:_.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 Hs{constructor(e,t,i,r,s,n){this.name=Us,this.setupOnce=function(o){o(qs(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class zs{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(mr.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(!(tt(n)||tt(o)||tt(a)||tt(l)||tt(u)||tt(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?mt(o/n,0,1,mr):1,_=n>1?mt(a/n,0,1,mr):1,h=l>1?mt(u/l,0,1,mr):1,p=l>1?mt(c/l,0,1,mr):1;r=Sr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$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 js=["flags","surveys"],Vs={[o]:{exposure:"hidden"},[u]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[c]:{exposure:"hidden"},[d]:{exposure:"event"},[_]:{exposure:"hidden"},[h]:{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"},[k]:{exposure:"hidden"},[I]:{exposure:"event"},[w]:{exposure:"event",shouldSkipFromEventProperties:e=>st(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"},[T]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Ze(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[C]:{exposure:"event",storageGroup:"flags"},[F]:{exposure:"hidden"},[R]:{exposure:"hidden",storageGroup:"flags"},[L]:{exposure:"event",storageGroup:"flags"},[A]:{exposure:"event",storageGroup:"flags",volatile:!0},[M]:{exposure:"event"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[N]:{exposure:"hidden"},[B]:{exposure:"hidden",storageGroup:"surveys"},[U]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[q]:{exposure:"event"},[H]:{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"},[z]:{exposure:"hidden"},[j]:{exposure:"hidden"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[G]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[K]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[J]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[S]:{exposure:"event"},[E]:{exposure:"event"},[x]:{exposure:"event"},[P]:{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"}},Ws=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Gs=e=>{var t=Vs[e];if(t)return t;for(var[i,r]of Ws)if(0===e.indexOf(i))return r},Qs=e=>{var t=null==be?void 0:be.createElement("a");return tt(t)?null:(t.href=e,t)},Ks=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(!Je(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){mr.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("=");Je(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=s&&(_+="#"+s),_},Js=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Xs="https?://(.*)",Zs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],en=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Zs],tn="<masked>",rn=["li_fat_id"];function sn(e,t,i){if(!be)return{};var r,s=t?[...Zs,...i||[]]:[],n=nn(Ys(be.URL,s,tn),e),o=(r={},wr(rn,(function(e){var t=Ur._get(e);r[e]=t||null})),r);return Sr(o,n)}function nn(e,t){var i=en.concat(t||[]),r={};return wr(i,(function(t){var i=Ks(e,t);r[t]=i||null})),r}function on(e){var t=function(e){return e?0===e.search(Xs+"google.([^/?]*)")?"google":0===e.search(Xs+"bing.com")?"bing":0===e.search(Xs+"yahoo.com")?"yahoo":0===e.search(Xs+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!st(t)){r.$search_engine=t;var s=be?Ks(be.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function an(){return navigator.language||navigator.userLanguage}var ln="$direct";function un(){return(null==be?void 0:be.referrer)||ln}function cn(e,t,i){void 0===i&&(i=!1);var r=e?[...Zs,...t||[]]:[],s=i?ki(null==we?void 0:we.href):null==we?void 0:we.href,n=null==s?void 0:s.substring(0,1e3);return{r:un().substring(0,1e3),u:n?Ys(n,r,tn):void 0}}function dn(e,t){var i;void 0===t&&(t=!1);var{r:r,u:s}=e,n=t?ki(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==ln?ln:null==(i=Qs(r))?void 0:i.host};if(n){o.$current_url=n;var a=Qs(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=nn(n);Sr(o,l)}if(r){var u=on(r);Sr(o,u)}return o}function _n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function hn(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var pn={flags:W,surveys:U},gn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],vn="main";class fn{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&&mr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),fe){var s=()=>this.flush();Cr(fe,"beforeunload",s,{capture:!1}),Cr(fe,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return ot(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===gn.indexOf(e.persistence.toLowerCase())&&(mr.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=[...zr,...e];return i({},Hr,{_parse(e){try{var i={};try{i=Ur._parse(e)||{}}catch(e){}var r,s=JSON.parse(Hr._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];st(a)||""===a||(n[o]=a)}r=Sr(s,n)}else r=Sr(i,s);return Hr._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=Hr._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&Ur._set(e,l,i,s,n,o)}catch(e){Hr._error(e)}return a},_remove(e,t){try{null==fe||fe.localStorage.removeItem(e),Ur._remove(e,t)}catch(e){Hr._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&Hr._is_supported()?(t=Hr,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&Gr._is_supported()?t=Gr:"memory"===n?t=Vr:"cookie"===n?t=Ur:r._is_supported()?(t=r,s=!0):t=Ur,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 wr(this.props,((t,i)=>{var r=Gs(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===T?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&Sr(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=Sr({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of js){var t=Hr._parse(this._groupEntryName(e));if(t&&!et(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Sr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=Gs(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=pn[e];if(!i)return!1;var r=t[i],s=this.props[i];return ot(r)&&ot(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=Gs(e))?void 0:t.storageGroup:void 0,r=i?Hr._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?tt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){tt(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,vn))}_writeNowSplit(){var{main:e,groups:t}=this._partitionProps();for(var i of(this._writeEntry(this._storage,this._name,e,vn),js)){var r,s=t[i];(!et(s)||null!=(r=this._slotState[i])&&r.persisted)&&this._writeEntry(Hr,this._groupEntryName(i),s,i)}}_partitionProps(){var e={},t={};for(var i of js)t[i]={};return wr(this.props,((i,r)=>{var s,n=null==(s=Gs(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===vn)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return wr(e,((e,t)=>{var r;i[t]=null!=(r=Gs(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===vn||s.dirty||tt(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!==vn&&(s.persisted=!0),tt(n)||(s.fingerprint=n)):this._config.debug&&mr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var{keepGroupEntries:t=!1}=void 0===e?{}:e;if(tt(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 js)Hr._remove(this._groupEntryName(i));t?delete this._slotState[vn]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Ze(e)){tt(t)&&(t="None"),this._expire_days=tt(i)?this._default_expiry:i;var r=!1;if(wr(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(Ze(e)){this._expire_days=tt(t)?this._default_expiry:t;var i=!1;if(wr(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=sn(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);et(kr(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==be?void 0:be.referrer)?on(e):{})}update_referrer_info(){var e;this.register_once({$referrer:un(),$referring_domain:null!=be&&be.referrer&&(null==(e=Qs(be.referrer))?void 0:e.host)||ln},void 0)}set_initial_person_info(){this.props[Y]||this.props[J]||this.register_once({[X]:cn(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={};wr([J,Y],(t=>{var i=this.props[t];i&&wr(i,(function(t,i){e["$initial_"+Ge(i)]=t}))}));var t=this.props[X];if(t){var i=function(e,t){void 0===t&&(t=!1);var i=dn(e,t),r={};return wr(i,(function(e,t){r["$initial_"+Ge(t)]=e})),r}(t,this._config.disable_capture_url_hashes);Sr(e,i)}return e}safe_merge(e){return wr(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 tt(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=Gs(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=Gs(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}var mn={Activation:"events",Cancellation:"cancelEvents"},yn={Button:"button",Tab:"tab",Selector:"selector"},bn={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},wn={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Sn={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},En={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},xn={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Pn={Once:"once",Recurring:"recurring",Always:"always"},kn={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},In={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Tn={Popover:"popover",Inline:"inline"},Cn={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},Fn={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Rn={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Ln=yr("[RateLimiter]");class An{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=>{Ln.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Ln.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 Mn=yr("[RemoteConfig]");class On{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 Mn.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void Mn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Mn.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){Mn.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||Mn.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 $n=["fatal","error","warning","log","info","debug"],Dn={GZipJS:"gzip-js",Base64:"base64"},Nn=Uint8Array,Bn=Uint16Array,Un=Uint32Array,qn=new Nn([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]),Hn=new Nn([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]),zn=new Nn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jn=function(e,t){for(var i=new Bn(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Un(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]},Vn=jn(qn,2),Wn=Vn[1];Vn[0][28]=258,Wn[258]=28;for(var Gn=jn(Hn,0)[1],Qn=new Bn(32768),Kn=0;32768>Kn;++Kn){var Yn=(43690&Kn)>>>1|(21845&Kn)<<1;Qn[Kn]=((65280&(Yn=(61680&(Yn=(52428&Yn)>>>2|(13107&Yn)<<2))>>>4|(3855&Yn)<<4))>>>8|(255&Yn)<<8)>>>1}var Jn=function(e,t,i){for(var r=e.length,s=0,n=new Bn(t);r>s;++s)++n[e[s]-1];var o,a=new Bn(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Bn(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,_=d|(1<<c)-1;_>=d;++d)o[Qn[d]>>>l]=u}else for(o=new Bn(r),s=0;r>s;++s)o[s]=Qn[a[e[s]-1]++]>>>15-e[s];return o},Xn=new Nn(288);for(Kn=0;144>Kn;++Kn)Xn[Kn]=8;for(Kn=144;256>Kn;++Kn)Xn[Kn]=9;for(Kn=256;280>Kn;++Kn)Xn[Kn]=7;for(Kn=280;288>Kn;++Kn)Xn[Kn]=8;var Zn=new Nn(32);for(Kn=0;32>Kn;++Kn)Zn[Kn]=5;var eo=Jn(Xn,9,0),to=Jn(Zn,5,0),io=function(e){return(e/8>>0)+(7&e&&1)},ro=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Bn?Bn:e instanceof Un?Un:Nn)(i-t);return r.set(e.subarray(t,i)),r},so=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},no=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},oo=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 Nn(0),0];if(1==s){var o=new Nn(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 _=n[0].s;for(r=1;s>r;++r)n[r].s>_&&(_=n[r].s);var h=new Bn(_+1),p=ao(i[c-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>h[y]?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new Nn(h),p]},ao=function(e,t,i){return-1==e.s?Math.max(ao(e.l,t,i+1),ao(e.r,t,i+1)):t[e.s]=i},lo=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Bn(++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]},uo=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},co=function(e,t,i){var r=i.length,s=io(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)},_o=function(e,t,i,r,s,n,o,a,l,u,c){so(t,c++,i),++s[256];for(var d=oo(s,15),_=d[0],h=d[1],p=oo(n,15),g=p[0],v=p[1],f=lo(_),m=f[0],y=f[1],b=lo(g),w=b[0],S=b[1],E=new Bn(19),x=0;m.length>x;++x)E[31&m[x]]++;for(x=0;w.length>x;++x)E[31&w[x]]++;for(var P=oo(E,7),k=P[0],I=P[1],T=19;T>4&&!k[zn[T-1]];--T);var C,F,R,L,A=u+5<<3,M=uo(s,Xn)+uo(n,Zn)+o,O=uo(s,_)+uo(n,g)+o+14+3*T+uo(E,k)+(2*E[16]+3*E[17]+7*E[18]);if(M>=A&&O>=A)return co(t,c,e.subarray(l,l+u));if(so(t,c,1+(M>O)),c+=2,M>O){C=Jn(_,h,0),F=_,R=Jn(g,v,0),L=g;var D=Jn(k,I,0);for(so(t,c,y-257),so(t,c+5,S-1),so(t,c+10,T-4),c+=14,x=0;T>x;++x)so(t,c+3*x,k[zn[x]]);c+=3*T;for(var N=[m,w],B=0;2>B;++B){var U=N[B];for(x=0;U.length>x;++x)so(t,c,D[q=31&U[x]]),c+=k[q],q>15&&(so(t,c,U[x]>>>5&127),c+=U[x]>>>12)}}else C=eo,F=Xn,R=to,L=Zn;for(x=0;a>x;++x)if(r[x]>255){var q;no(t,c,C[257+(q=r[x]>>>18&31)]),c+=F[q+257],q>7&&(so(t,c,r[x]>>>23&31),c+=qn[q]);var H=31&r[x];no(t,c,R[H]),c+=L[H],H>3&&(no(t,c,r[x]>>>5&8191),c+=Hn[H])}else no(t,c,C[r[x]]),c+=F[r[x]];return no(t,c,C[256]),c+F[256]},ho=new Un([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),po=function(){for(var e=new Un(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),go=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function vo(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=po[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 Nn(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=co(l,u,e.subarray(c,d)):(l[c]=!0,u=co(l,u,e.subarray(c,o)))}else{for(var _=ho[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new Bn(32768),f=new Bn(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 Un(25e3),S=new Bn(288),E=new Bn(32),x=0,P=0,k=(c=0,0),I=0,T=0;o>c;++c){var C=b(c),F=32767&c,R=f[C];if(v[F]=R,f[C]=F,c>=I){var L=o-c;if((x>7e3||k>24576)&&L>423){u=_o(e,l,0,w,S,E,P,k,T,c-T,u),k=x=P=0,T=c;for(var A=0;286>A;++A)S[A]=0;for(A=0;30>A;++A)E[A]=0}var M=2,O=0,D=p,N=F-R&32767;if(L>2&&C==b(c-N))for(var B=Math.min(h,L)-1,U=Math.min(32767,c),q=Math.min(258,L);U>=N&&--D&&F!=R;){if(e[c+M]==e[c+M-N]){for(var H=0;q>H&&e[c+H]==e[c+H-N];++H);if(H>M){if(M=H,O=N,H>B)break;var z=Math.min(N,H-2),j=0;for(A=0;z>A;++A){var V=c-N+A+32768&32767,W=V-v[V]+32768&32767;W>j&&(j=W,R=V)}}}N+=(F=R)-(R=v[F])+32768&32767}if(O){w[k++]=268435456|Wn[M]<<18|Gn[O];var G=31&Wn[M],Q=31&Gn[O];P+=qn[G]+Hn[Q],++S[257+G],++E[Q],I=c+M,++x}else w[k++]=e[c],++S[e[c]]}}u=_o(e,l,!0,w,S,E,P,k,T,c-T,u)}return ro(a,0,r+io(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&&go(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),go(u,c-8,i.d()),go(u,c-4,r),u}var fo=!!Ee||!!Se,mo="text/plain",yo=!1,bo=(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:"")},wo=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 wr(e,(function(e,t){tt(e)||tt(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("&")},So=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Eo=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===Dn.GZipJS){var r=vo(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Nn(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 Nn(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 ro(r,0,s)}(So(t)),{mtime:0});return{contentType:mo,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Dn.Base64){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(So(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:So(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=So(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},xo=e=>{var t,r,s=()=>({url:bo(e.url,"compression"),encodedBody:Eo(i({},e,{compression:void 0,_encodedBody:void 0}))});try{t=Eo(e)}catch(t){if(Ne(e.compression,Ks(e.url,"compression")))return mr.error("Failed to gzip request body, sending uncompressed payload",t),s();throw t}return t&&Ne(e.compression,Ks(e.url,"compression"))&&!((r=t.body)instanceof ArrayBuffer?De(new Uint8Array(r)):ArrayBuffer.isView(r)&&De(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(yo=!0,s()):{url:e.url,encodedBody:t}},Po=e=>{try{return xo(e)}catch(t){return mr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},ko=function(){var e=t((function*(e){var t=So(e.data),r=yield function(e,t,i){return He.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:mo,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Io=(e,t)=>wo(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),To=[];Se&&To.push({transport:"fetch",method(e){var t,r=Po(e);if(r){var{url:s,encodedBody:n}=r,{contentType:o,body:a,estimatedSize:l}=null!=n?n:{},u=new Headers;wr(e.headers,(function(e,t){u.append(t,e)})),o&&u.append("Content-Type",o);var c=null,d=null;if(xe){var _=new xe;c={signal:_.signal,timeout:setTimeout((()=>{var t,i;t=e.timeout,(i=new Error("PostHog request timed out"+(t?" after "+t+"ms":""))).name="AbortError",_.abort(d=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){mr.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{t===d?mr.warn(t):mr.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}}),Ee&&To.push({transport:"XHR",method(e){var t=Po(e);if(t){var i=new Ee,{url:r,encodedBody:s}=t;i.open(e.method||"GET",r,!0);var{contentType:n,body:o}=null!=s?s:{};wr(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&&To.push({transport:"sendBeacon",method(e){try{var{url:t,encodedBody:i}=xo(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 Co=3e3;class Fo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=mt((null==t?void 0:t.flush_interval_ms)||Co,250,5e3,mr.createLogger("flush interval"),Co),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&&Je(i.data)&&wr(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){mr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return wr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;tt(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Ro=["retriesPerformedSoFar"];class Lo{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!tt(fe)&&"onLine"in fe.navigator&&(this._areWeOnline=fe.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Cr(fe,"online",this._onlineListener),Cr(fe,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,Ro);at(t)&&(s.url=wo(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&&mr.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)"),mr.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,tt(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){mr.error(e)}this._queue=[]}}class Ao{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(){Cr(fe,"scroll",this._updateScrollData,{capture:!0}),Cr(fe,"scrollend",this._updateScrollData,{capture:!0}),Cr(fe,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==fe?void 0:fe.document.documentElement;var e=Je(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 Mo=e=>cn(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 Oo{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||Mo,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?dn(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 wr(kr(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Ge(i)]=t})),e}}class $o{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 Do=yr("[SessionId]");class No{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 $o,this._sessionHasBeenIdleTooLong=(e,t)=>!(!at(e)||!at(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||$r,this._windowIdGenerator=i||$r;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*mt(this._config.session_idle_timeout_seconds||1800,60,36e3,Do.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=Gr._parse(this._window_id_storage_key),o=Gr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Gr._remove(this._window_id_storage_key),Gr._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){Do.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return tt(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&&Gr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Gr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Gr._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!st(t)&&!st(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var r=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!r||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[k]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return at(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(k):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!st(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({[k]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var[e]=this._getSessionId(),t=at(e)?e:0,i=at(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[k];return Je(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(_e,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Gr._remove(this._primary_window_exists_storage_key)},Cr(fe,_e,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=at(s)&&Math.abs(i-s)>864e5,l=!1,u=!1,c=!r,d=r,_=!c&&!e&&this._sessionHasBeenIdleTooLong(i,n);_&&((_=this._isSessionIdleAfterCrossTabRefresh(i))||Do.info("cross-tab refresh kept the session alive",{sessionId:r}),[,r,s]=this._getSessionId()),c||_||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Do.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:_,sessionPastMaximumLength:a}}),s=i,l=!0):(o||(o=this._windowIdGenerator(),l=!0),(u=r!==d)&&(Do.info("adopted cross-tab session id",{sessionId:r,windowId:o}),l=!0));var h=at(n)&&e&&!a?n:i,p=at(s)?s:(new Date).getTime();this._setWindowId(o),this._setSessionId(r,h,p),e||this._resetIdleTimer();var g={noSessionId:c,activityTimeout:_,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 Bo=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&je(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>je(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function Uo(){return(Uo=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 it(i)&&i.length>0?i:void 0}catch(e){return void mr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}))).apply(this,arguments)}var qo=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 Ho(e,t,i){return So({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var zo={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=>qo(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!qo(t,e))))),icontains:(e,t)=>t.map(jo).some((t=>e.map(jo).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(jo).every((t=>e.map(jo).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)))}))},jo=e=>e.toLowerCase();function Vo(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(tt(s)||st(s))return!1;var n=[String(s)],o=zo[r.operator];return!!o&&o(r.values,n)}))}var Wo="custom",Go="i.posthog.com",Qo=/^\/static\//;class Ko{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("."+Go,".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":Wo),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(Qo.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===Wo)return this.apiHost+t;var r=Go+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Yo=yr("[Surveys]"),Jo="seenSurvey_",Xo=[Sn.Popover,Sn.Widget,Sn.API],Zo={ignoreConditions:!1,ignoreDelay:!1,displayType:Tn.Popover},ea=yr("[PostHog ExternalIntegrations]"),ta={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ia{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 ea.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(ta[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 ra,sa={},na=0,oa=()=>{},aa='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',la="Surveys module not available",ua="sanitize_properties is deprecated. Use before_send instead",ca="Invalid value for property_denylist config: ",da="posthog",_a=!fo&&-1===(null==ke?void 0:ke.indexOf("MSIE"))&&-1===(null==ke?void 0:ke.indexOf("Mozilla")),ha=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:Tr(null==be?void 0:be.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:oa,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&&it(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){mr.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:Co},error_tracking:{},_onCapture:oa},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:gs,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))},pa=[["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"]],ga=e=>{var t={};for(var[i,r]of pa)tt(e[i])||(t[r]=e[i]);var s=Sr({},t,e),n=e.__preview_external_dependency_versioned_paths;return tt(n)||(tt(e.strict_script_versioning)&&(s.strict_script_versioning=!!n),it(n)&&tt(e.asset_host)&&(s.asset_host=n)),Je(e.property_blacklist)&&(tt(e.property_denylist)?s.property_denylist=e.property_blacklist:Je(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:mr.error(ca+e.property_denylist)),s};class va{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){mr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class fa{_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 va,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new $o,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ha(),this.SentryIntegration=Hs,this.sentryIntegration=e=>function(e,t){var i=qs(e,t);return{name:Us,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 Ao(this),this.pageViewManager=new zs(this),this.rateLimiter=new An(this),this.requestRouter=new Ko(this),this.consent=new Qr(this),this.externalIntegrations=new ia(this);var t=null!==(e=fa.__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=it(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=it(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>mr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==da){var r,s=null!==(r=sa[i])&&void 0!==r?r:new fa;return s._init(e,t,i),sa[i]=s,sa[da][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;void 0===t&&(t={});var a=it(e)?e.trim():"";if(!a)return mr.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=ha(t.defaults),c=ga(t),d=Sr({},u,c,{name:r,token:a});Ze(u.rageclick)&&Ze(c.rageclick)&&(d.rageclick=Sr({},u.rageclick,c.rageclick)),Ze(u.session_recording)&&Ze(c.session_recording)&&(d.session_recording=Sr({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&mr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Dn.GZipJS;var _=this._is_persistence_disabled();this.persistence=new fn(this.config,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new fn(i({},this.config,{persistence:"sessionStorage"}),_,!1);var h=i({},this.persistence.props),p=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Fo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Lo(this),this.__request_queue=[];var g=this._inCookielessMode();if(g||(this.sessionManager=new No(this),this.sessionPropsManager=new Oo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(mr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(g)}),0)):(mr.info("Initializing extensions synchronously"),this._initExtensions(g)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&mr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:h,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)mr.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($r()),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($r());this.register_once({distinct_id:w,$device_id:w},""),this.persistence.set_property(G,le)}return Cr(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()||$r();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&&Xe(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{"undefined"!=typeof Promise&&Promise.resolve||Bs.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()||(Bs.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Bs.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,he),identify:e=>t(e,ge),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Xe(this.config._onCapture)&&this.config._onCapture!==oa&&(mr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&mr.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 Uo.apply(this,arguments)}().then((e=>{e&&this.register({[l]:e})})).catch(oa),this}_initExtensions(e){var t,r,s,n,o,a,l,u=performance.now(),c=i({},fa.__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,Ds)),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){mr.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&&mr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!be||!be.body)return mr.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=Ve(e.supportedCompression,Dn.GZipJS)?Dn.GZipJS:Ve(e.supportedCompression,Dn.Base64)?Dn.Base64: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){mr.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 On(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()&&br(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?_a?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,(tt(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=Io(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=To.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===Dn.GZipJS&&Pe&&"undefined"!=typeof Promise&&!yo?ko(n).then((e=>{l(e)})).catch((t=>{if(Be(t))return yo=!0,void l(i({},n,{compression:void 0,url:Io(e.url,void 0)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return Be(e)||t===$e})(t)&&(yo=!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){na++;try{var t,i=[],r=[],s=[];br(e,(e=>{if(e)if(Je(t=e[0]))s.push(e);else if(Xe(e))try{e.call(this)}catch(t){mr.error("Error executing queued PostHog call",e,t)}else Je(e)&&"alias"===t?i.push(e):Je(e)&&-1!==t.indexOf("capture")&&Xe(this[t])?s.push(e):r.push(e)}));var n=function(e,t){br(e,(function(e){try{if(Je(e[0])){var i=t;wr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){mr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{na--}}push(e){if(na>0&&Je(e)&&it(e[0])){var t=fa.prototype[e[0]];Xe(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(!tt(e)&&it(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&&!it(null==t?void 0:t.$current_url)&&(mr.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||mr.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,_=(null==r?void 0:r.timestamp)||d,h=Pi(null==r?void 0:r.uuid,$r),p={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},_,h)};e===he&&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=>it(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),Je(t)?(r=[],br(t,(t=>{r.push(e(t))}))):(r={},wr(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=_,tt(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===kn.DISMISSED||e===kn.SENT){var b=null==t?void 0:t[In.SURVEY_ID],w=null==t?void 0:t[In.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var i=""+Jo+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+Jo+t.id+"_"+t.current_iteration),i})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){Yo.error("Failed to persist survey seen state",e)}})({id:b,current_iteration:w}),p.$set=i({},p.$set,{[(v={id:b,current_iteration:w},f=e===kn.SENT?"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===kn.SHOWN&&(p.$set=i({},p.$set,{[In.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(e===Fn.SHOWN){var S=null==t?void 0:t[Rn.TOUR_TYPE];S&&(p.$set=i({},p.$set,{[Rn.TOUR_LAST_SEEN_DATE+"/"+S]:(new Date).toISOString()}))}var E=i({},p.properties.$set,p.$set);if(et(E)||this.setPersonPropertiesForFlags(E),!nt(this.config.before_send)){var x=this._runBeforeSend(p);if(!x)return;(p=x).uuid=Pi(p.uuid,$r)}this._internalEventEmitter.emit("eventCaptured",p);var P={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(P):this._requestQueue.enqueue(P),p}mr.critical("This capture call is ignored due to client rate limiting.")}}else mr.error("No event name provided to posthog.capture")}else mr.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,(!it(l.distinct_id)&&!ot(l.distinct_id)||rt(l.distinct_id))&&mr.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),!ke)return{};var u,c,d,_,h,p,g,v,f,m=e?[...Zs,...t||[]]:[],[y,b]=function(e){for(var t=0;Si.length>t;t++){var[i,r]=Si[t],s=i.exec(e),n=s&&(Xe(r)?r(s,e):r);if(n)return n}return["",""]}(ke),w=null!=(u="undefined"!=typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},S={detectGoogleSearchApp:i},E=Sr(kr({$os:y,$os_version:b,$browser:yi(ke,navigator.vendor,w,S),$device:Ei(ke),$device_type:(d=ke,_={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===xt||"Kobo"===f||"Kindle Fire"===f||f===ti?Et:f===jt||f===Wt||f===Vt||f===Xt?"Console":f===It?"Wearable":f?bt:"Android"===(null==_?void 0:_.userAgentDataPlatform)&&(null!==(h=null==_?void 0:_.maxTouchPoints)&&void 0!==h?h:0)>0?600>Math.min(null!==(p=null==_?void 0:_.screenWidth)&&void 0!==p?p:0,null!==(g=null==_?void 0:_.screenHeight)&&void 0!==g?g:0)/(null!==(v=null==_?void 0:_.devicePixelRatio)&&void 0!==v?v:1)?bt:Et:"Desktop"),$timezone:_n(),$timezone_offset:hn()}),{$current_url:Ys(r?ki(null==we?void 0:we.href):null==we?void 0:we.href,m,tn),$host:null==we?void 0:we.host,$pathname:null==we?void 0:we.pathname,$raw_user_agent:ke.length>1e3?ke.substring(0,997)+"...":ke,$browser_version:wi(ke,navigator.vendor,w,S),$browser_language:an(),$browser_language_prefix:(c=an(),"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&&(E.$sdk_dist_channel=n.SDK_DIST_CHANNEL),E}(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:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&Sr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Sr(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===Wo&&(l.$lib_custom_api_host=this.config.api_host),c=e!==he||o?e!==pe||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=Sr(l,c),e===he&&be&&(l.title=be.title),!tt(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}ke&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=Sr({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Je(this.config.property_denylist)?wr(this.config.property_denylist,(function(e){delete l[e]})):mr.error(ca+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(mr.error(ua),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=Sr({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(mr.error(ua),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),et(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:la}),()=>{})}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:la})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:la})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=Zo),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:la}}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:la})}_validateIdentifyId(e){return!e||rt(e)?(mr.critical("Unique user id has not been set in posthog.identify"),!1):e===te?(mr.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())||(mr.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 mr.uninitializedWarning("posthog.identify");if(ot(e)&&(e=e.toString(),mr.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=Ho(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(z))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=Ho(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):mr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(Je(e)?e:[e]).filter((e=>it(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 mr.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(mr.info("reset"),!this.__loaded)return mr.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(),tt(g)||null==(_=this.persistence)||_.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($r());this.register_once({distinct_id:v,$device_id:e?v:h},""),e||tt(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()}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)?(mr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(tt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(u,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(mr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(Ze(e)){var r,s,o,a,l,u,c,d,_,h,p;Sr(this.config,ga(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 fn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);lt(v)&&(this.config.debug=v),lt(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,Hr._is_supported()&&Hr._set("ph_debug",!0),mr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,Hr._is_supported()&&Hr._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==(_=this.deadClicksAutocapture)||_.startIfEnabledOrStop(),null==(h=this.surveys)||h.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:fa._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:da;return t!==da&&(t=da+"."+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()&&et(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?(mr.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 No(this),this.pageViewManager=new zs(this),this.persistence&&(this.sessionPropsManager=new Oo(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=fa.__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()),(tt(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 mr.warn(aa)}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())):mr.warn(aa)}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?Bo(ye,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){be&&("visible"===be.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(he,{title:be.title},{send_instantly:!0}),this._visibilityStateListener&&(be.removeEventListener(de,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Cr(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?(mr.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=mr,s=(t="advanced_disable_flags")in(e=o)&&!nt(e[t]),n=i in e&&!nt(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(nt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(dt),r=Je(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),nt(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return ct(e.event)?mr.warn(o+". This can cause unexpected behavior."):mr.info(o),null}s.properties&&!et(s.properties)||mr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&nt(s.properties[a]))return mr.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=lt(e)&&!e,i=Hr._is_supported()&&"true"===Hr._get("ph_debug");return!t&&(!!i||e)}}fa.__defaultExtensionClasses={},fa._noopLogger={trace:ra=()=>{},debug:ra,info:ra,warn:ra,error:ra,fatal:ra},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Pr(e.prototype[t[i]])}(fa,["identify"]);class ma{constructor(e){this.disabled=!1===e;var t=Ze(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 ya="$copy_autocapture",ba=yr("[AutoCapture]");function wa(e,t){return t.length>e?t.slice(0,e)+"...":t}function Sa(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!es(t));return t}function Ea(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:c}=t;if(!es(e))return{props:{}};for(var d=[e],_=e;_.parentNode&&!ts(_,"body");)if(rs(_.parentNode))d.push(_.parentNode.host),_=_.parentNode.host;else{if(!es(_.parentNode))break;d.push(_.parentNode),_=_.parentNode}var h,p,g=[],v={},f=!1,m=!1;if(wr(d,(e=>{var t=Ss(e);if(ts(e,"a")){var i=e.getAttribute("href");f=!!(t&&i&&Fs(i))&&(c?ki(i):i)}Ve(os(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};cs.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?wa(1024,Rs(e)):wa(1024,ls(e)));var a=os(e);a.length>0&&(o.classes=a.filter((function(e){return""!==e}))),wr(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&&Fs(i.value)&&(!it(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=ss(a).join(" ")),o["attr__"+i.name]=wa(1024,"href"===i.name&&s?ki(a):a)}}));for(var l=1,u=1,c=e;c=Sa(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(!Ss(e))return{};var t={};return wr(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&&Fs(r)&&(t[i]=r)}})),t}(e);Sr(v,r)})),m)return{props:{},explicitNoCapture:m};if(a||(g[0].$el_text=ts(e,"a")||ts(e,"button")?Rs(e):ls(e)),f){var y,b;g[0].attr__href=f;var w=null==(y=Qs(f))?void 0:y.host,S=null==fe||null==(b=fe.location)?void 0:b.host;w&&S&&w!==S&&(h=f)}return{props:Sr({$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:Ms(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}:{},h&&"click"===n.type?{$external_click_url:h}:{},v)}}var xa=yr("[ExceptionAutocapture]"),Pa=yr("[TracingHeaders]"),ka=yr("[Web Vitals]"),Ia=9e5,Ta="disabled",Ca="lazy_loading",Fa="awaiting_config",Ra="missing_config";yr("[SessionRecording]"),yr("[SessionRecording]");var La="[SessionRecording]",Aa=yr(La),Ma=yr("[Heatmaps]");function Oa(e){return Ze(e)&&"clientX"in e&&"clientY"in e&&ot(e.clientX)&&ot(e.clientY)}var $a=yr("[Product Tours]"),Da=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(m))},Na=["$set_once","$set"],Ba=yr("[SiteApps]"),Ua="Error while initializing PostHog app with config id ";function qa(e,t,i){if(nt(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 Ha{constructor(e){this._debugEventEmitter=new $o,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;tt(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(!tt(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(!qa(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=>qa(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&qa((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=>qa(e.text,t.text,t.text_matching||"exact")||qa(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;!nt(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=>qa(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||Vo(t.properties.reduce(((e,t)=>{var i=Je(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 za{constructor(e){this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&Vo(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===mn.Activation?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;tt(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 Ha(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,mn.Activation),this._cancelEventToItems=this._buildEventToItemMap(e,mn.Cancellation))}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,mn.Cancellation);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,mn.Activation);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 ja extends za{constructor(e){super(e)}_getActivatedKey(){return q}_getShownEventName(){return kn.SHOWN}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return Yo}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[q]: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 e.schedule===Pn.Always||!(null==(r=e.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?e===kn.SHOWN?"consume":"ignore":e===kn.SHOWN?"persist":e===kn.DISMISSED||e===kn.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Va="SDK is not enabled or survey functionality is not yet loaded",Wa="Disabled. Not loading surveys.",Ga=null!=fe&&fe.location?Js(fe.location.hash,"__posthog")||Js(location.hash,"state"):null,Qa="_postHogToolbarParams",Ka=yr("[Toolbar]"),Ya=yr("[FeatureFlags]"),Ja=yr("[FeatureFlags]",{debugEnabled:!0}),Xa="\" failed. Feature flags didn't load in time.",Za=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},el=e=>{var t={};for(var[i,r]of Er(e||{}))r&&(t[i]=r);return t},tl=yr("[Error tracking]"),il="Refusing to render web experiment since the viewer is a likely bot",rl={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>qo(t,e),not_regex:(e,t)=>!qo(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class sl{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{sl._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(sl._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);it(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];sl._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())sl._logInfo(il);else if(!this._config.disable_web_experiments){if(nt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();sl._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=sl.getWindowLocation();if(null!=e&&e.search){var t=Ks(null==e?void 0:e.search,"__experiment_id"),i=Ks(null==e?void 0:e.search,"__experiment_variant");t&&i&&(sl._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&&(sl._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!nt(e.conditions)&&sl._matchUrlConditions(e,t)&&sl._matchUTMConditions(e)}static _matchUrlConditions(e,t){var i;if(nt(e.conditions)||nt(null==(i=e.conditions)?void 0:i.url))return!0;var r=sl.getWindowLocation();if(r){var s,n,o,a=Kr(t,r.href);return null==(s=e.conditions)||!s.url||rl[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(nt(e.conditions)||nt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=sn();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,_=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,h=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&&h&&p&&_}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];mr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?sl._logInfo(il):"control"!==t?i.forEach((i=>{if(i.selector){var r;sl._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)}))}})):sl._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ye&&this._instance?Bo(ye,this._config.custom_blocked_useragents):void 0}}var nl=yr("[Conversations]"),ol="Conversations not available yet.",al="console",ll={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._instance=e,this.featureFlagEventHandlers=[]}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,Ya.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||(Ya.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||Ya.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(!tt(e)){if(Je(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Ya.error("Invalid flag key found:",e,"Expected non-empty string"),t}));Ya.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(T))&&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,_]of Object.entries(l))c[d]={key:d,enabled:Ce(_),variant:Fe(_),reason:void 0,metadata:tt(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(M),r=this._prop(O);if(!r&&!t)return e||{};var s=Sr({},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=tt(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=tt(c)?u.variant:"string"==typeof c?c:void 0,h=null==r?void 0:r[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[o]=p}return this._override_warning||(Ya.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:Ce(r),variant:Fe(r),payload:Te(t[i])}}))}getFlagVariants(){var e=this._prop(T),t=this._prop(M);if(!t)return e||{};for(var i=Sr({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ya.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=Sr({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ya.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._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())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(N),timezone:_n()};st(s)||tt(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();tt(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:Dn.Base64,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(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)Ya.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())}}})}}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 Ya.warn('getFeatureFlag for key "'+e+Xa)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(A)||void 0,l=this._prop(W)||void 0,u=this._prop(z)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(j);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[z]:u,[j]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,v,f,m,y,b,w,S;Je(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[z]:u});var E=this.getFeatureFlagDetails(e),x=[...null!==(p=this._prop(V))&&void 0!==p?p:[]];tt(s)&&x.push("flag_missing");var P={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};tt(null==E||null==(f=E.metadata)?void 0:f.version)||(P.$feature_flag_version=E.metadata.version);var k,I=null!==(m=null==E||null==(y=E.reason)?void 0:y.description)&&void 0!==m?m:null==E||null==(b=E.reason)?void 0:b.code;I&&(P.$feature_flag_reason=I),null!=E&&null!=(w=E.metadata)&&w.id&&(P.$feature_flag_id=E.metadata.id),tt(null==E?void 0:E.original_variant)&&tt(null==E?void 0:E.original_enabled)||(P.$feature_flag_original_response=tt(E.original_variant)?E.original_enabled:E.original_variant),null!=E&&null!=(S=E.metadata)&&S.original_payload&&(P.$feature_flag_original_payload=null==E||null==(k=E.metadata)?void 0:k.original_payload),x.length&&(P.$feature_flag_error=x.join(",")),this._instance.capture("$feature_flag_called",P)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Te(n)}}}else Ya.warn('getFeatureFlagResult for key "'+e+Xa)}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();tt(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:Dn.Base64,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 tt(i)?void 0:!!i}Ya.warn('isFeatureEnabled for key "'+e+Xa)}}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&&Ya.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,_=e.evaluatedAt;if(Je(u)){Ya.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(u)for(var p=0;u.length>p;p++)h[u[p]]=!0;t&&t.register({[C]:u,[T]:h})}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({[C]:Object.keys(el(g)),[T]:g||{},[L]:v||{},[R]:f||{}},d?{[A]:d}:{},_?{[W]:_}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Ya.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Ya.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(M),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),Ja.info("All overrides cleared");if(Je(e)){var t=Za(e);return this._persistence.register({[M]:t}),this._fireFeatureFlagsCallbacks(),Ja.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(M),Ja.info("Flag overrides cleared");else if(r.flags){if(Je(r.flags)){var s=Za(r.flags);this._persistence.register({[M]:s})}else this._persistence.register({[M]:r.flags});Ja.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),Ja.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),Ja.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[M]:e}),this._fireFeatureFlagsCallbacks(),Ja.info("Flag overrides set",{flags:e});Ya.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(F)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[C]:Object.keys(el(l)),[T]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(F),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(F),null==(r=this._persistence)||r.register({[F]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>r(t,i,{errorsLoading: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(N)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[N]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(N)||{};this._instance.register({[N]:i({},t,{[e]:{}})})}else this._instance.unregister(N)}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}}},ul={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===Fa||this._recordingStatus===Ra?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=Ta,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Aa.error("started without valid sessionManager"),new Error(La+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===ae)throw new Error(La+' 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=!tt(Object.assign)&&!tt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Aa.info("starting")):(this._recordingStatus=Ta,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==Fa&&this._recordingStatus!==Ra&&(this._recordingStatus=Ca),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 Aa.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(nt(e))return null;var i,r=ot(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Aa.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;nt(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:tt(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===Fa&&(this._recordingStatus=Ra,Aa.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):Aa.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 Aa.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 Aa.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===Ra||this._recordingStatus===Fa)return;return this._recordingStatus=Fa,Aa.info("persisted remote config is stale, requesting fresh config before starting"),void new On(this._instance).load()}this._recordingStatus=Ca,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({[E]:!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?x:P]:!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))}}},cl={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new ma(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=Ze(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){ba.error("Failed to capture event",e)}};if(Cr(be,"submit",e,{capture:!0}),Cr(be,"change",e,{capture:!0}),Cr(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,ya)}catch(e){ba.error("Failed to capture copy/cut event",e)}};Cr(be,"copy",t,{capture:!0}),Cr(be,"cut",t,{capture:!0})}}}else ba.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(st(this._isDisabledServerSide)&&!lt(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=us(e);is(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())&&ys(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===ya;if(r&&function(e,t,i,r,s,n){var o,a,l,u,c,d;if(void 0===i&&(i=void 0),!fe||bs(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!ns(i.url_allowlist,n))return!1;if(null!=(a=i)&&a.url_ignorelist&&ns(i.url_ignorelist,n))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var _=i.dom_event_allowlist;if(_&&!_.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:h,targetElementList:p}=ws(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(tt(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(!ds(p,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(ds(p,null!==(c=null==(d=i)?void 0:d.css_selector_ignorelist)&&void 0!==c?c:hs))return!1;var g=fe.getComputedStyle(e);if(g&&"pointer"===g.getPropertyValue("cursor")&&"click"===t.type)return!0;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 h?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(cs.indexOf(v)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:o}=Ea(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===ya){var l,u=as(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 Xe(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&&(mr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,mr.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 Xe(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(he,{navigation_type:e}),this._lastPathname=i}catch(t){mr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Cr(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[_]),this.rageclicks=new ma(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Ze(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return nt(this._config.capture_heatmaps)?nt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Ma.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({[_]: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="visible"===(null==be?void 0:be.visibilityState)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){fe&&be&&(this._flushHandler=this._flush.bind(this),Cr(fe,_e,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==fe?void 0:fe.event)),Cr(be,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==fe?void 0:fe.event)),Cr(be,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Ns(this.instance,$s,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Cr(be,de,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;fe&&be&&(this._flushHandler&&fe.removeEventListener(_e,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&&es(r)&&!ts(r,"body");){if(r===i)return!1;if(Ve(t,null==fe?void 0:fe.getComputedStyle(r).position))return!0;r=_s(r)}return!1}(us(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"),!Zr(e.target)&&Oa(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&ys(us(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!Zr(e.target)&&Oa(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?ki(fe.location.href):fe.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...Zs,...i||[]]:[],s=Ys(t,r,tn);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!et(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Ns,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(!tt(r))if(nt(null==e?void 0:e.name)||nt(null==e?void 0:e.value))ka.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)),tt(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=tt(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()});tt(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 ka.error("Ignoring metric with value >= "+this._maxAllowedValue,e)},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Ie.__PosthogExtensions__;tt(s)||tt(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):ka.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=Ze(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return nt(i)?(null==(t=this._instance.persistence)?void 0:t.props[y])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(Ze(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Ze(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=Ze(this._perfConfig)&&ot(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Ia;return e>0&&6e4>=e?Ia:e}get isEnabled(){var e=null==we?void 0:we.protocol;if("http:"!==e&&"https:"!==e)return ka.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Ze(this._perfConfig)?this._perfConfig.web_vitals:lt(this._perfConfig)?this._perfConfig:void 0;return lt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(ka.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=Ze(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Ze(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?ka.error("failed to load script",t):e()}))}_currentURL(){var e=fe?this._instance.config.disable_capture_url_hashes?ki(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?[...Zs,...t||[]]:[];return Ys(e,i,tn)}ka.error("Could not determine current URL")}}},dl={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){xa.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[h]),this._rateLimiter=new yt({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:xa}),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 Ze(e)?t=i({},t,e):(tt(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?(xa.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 xa.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({[h]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?xa.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 qi([new Zi,new ur,new tr,new er,new ar,new or,new rr,new lr],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=Xi.test(l)?l.replace(Xi,"$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||Hi});var r}))}(n)}}("web:javascript",Qi,Ji)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(p))&&void 0!==t?t:[],this._exceptionStepsConfig=pr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new gr(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=pr(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(!it(e)||0===e.trim().length)return void tl.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&&tl.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[cr]:e,[dr]:(new Date).toISOString()},s))}catch(e){tl.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 tl.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 tl.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 tl.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&nt(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 tl.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void tl.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 tl.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[cr]:e,[dr]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Ze(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 it(i)&&i.length>0&&e.$exception_types.push(i),it(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=zo[e.operator],s=Je(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!nt(e)&&Je(e)}}},_l=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}),!Da(this._instance))return!this._productTourManager&&nt(null==(t=this._persistence)?void 0:t.props[H])||$a.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&&Da(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?$a.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),!Je(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[H];if(Je(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(Da(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return $a.error(s),void e([],{isLoaded:!1,error:s})}var n=Je(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[H]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){nt(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(H)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},ll),hl={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")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,Na),{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)||(Ba.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)||(Ba.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,_=new WeakSet,h=(e,t,i)=>{if(null!=e&&e[t]){var r=e[t];e[t]=i(r),c.push((()=>{e[t]=r}))}},p=e=>{if(_.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&_.add(t),t},g=e=>e.map((e=>"string"==typeof e?e:p(e))).filter((e=>!st(e)));return h(u,"appendChild",(e=>function(t){var i=p(t);return i?e.call(this,i):t})),h(u,"insertBefore",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):t})),h(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=>{h(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))})),h(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=>{h(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))})),h(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))})),h(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)}))})),h(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&&(Ba.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,Ba.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){Ba.error(Ua+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){Ba.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){Ba.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 Ba.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 Ba.error(Ua+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Ba.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},pl={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?(tt(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)),tt(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 Pa.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 Je(e)?(Je(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(Je(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()}}},gl=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._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){var t=e.surveys;if(nt(t))return Yo.warn("Flags not loaded yet. Not loading surveys.");var i=Je(t);this._isSurveysEnabled=i?t.length>0:t,Yo.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(Jo)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Yo.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)Yo.info(Wa);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())Yo.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e){if(!tt(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 Yo.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new ja(this._instance),Yo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Yo.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 Yo.info(Wa),e([]);var i,r=this._instance.get_property(B);if(r&&!t)return e(r,{isLoaded:!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;Yo.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}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,[U]:Date.now()});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Yo.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!nt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Yo.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(nt(this._surveyManager))return{eligible:!1,reason:Va};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(nt(this._surveyManager))return Yo.warn("init was not called"),{visible:!1,disabledReason:Va};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return nt(this._surveyManager)?(Yo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Va})):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(nt(this._surveyManager))Yo.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Xo.includes(s.type)){var n=null==be?void 0:be.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Yo.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Yo.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),Yo.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Yo.warn("Survey element not found")}else Yo.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Yo.warn("Survey not found")}}displaySurvey(e,t){var r;if(nt(this._surveyManager))Yo.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!==Tn.Popover&&t.initialResponses&&Yo.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 Yo.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Tn.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else Yo.warn("Survey not found")}}cancelPendingSurvey(e){nt(this._surveyManager)?Yo.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},ll),vl={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),Fr(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=Ga||Js(e.hash,"__posthog")||Js(e.hash,"state"),n=s?xr((()=>JSON.parse(atob(decodeURIComponent(s)))))||xr((()=>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(Qa)||"{}")).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;!nt(t)&&Xe(t)?t(e,this.instance):Ka.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(Qa,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 Ka.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Cr(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)}}},fl=i({experiments:sl},ll),ml=i({},ll,ul,cl,dl,_l,hl,gl,pl,vl,fl,{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;nt(t)||(lt(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||Fr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e&&!tt(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 nl.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),nl.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else nl.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){nl.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():nl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!st(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):(nl.warn(ol),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(nl.warn(ol),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(nl.warn(ol),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(nl.warn(ol),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(nl.warn(ol),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(nl.warn(ol),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(nl.warn(ol),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=yr("[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&&Cr(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,_=tt(d)?Math.max(c,2048):Math.max(c,d),h=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==h?void 0:h["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==h?void 0:h["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==h?void 0:h["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:h,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:_,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 $i(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},al)),this._consoleCore}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!nt(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===Le.LogsQueue?e():void 0,setPersistedProperty(e,i){var r;e===Le.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,al,(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,Mi(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,nt(s)||(t.sessionStartTimestamp=s),nt(n)||(t.lastActivityTimestamp=n)}if(null!=Ie&&null!=(e=Ie.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ki(Ie.location.href):Ie.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}});fa.__defaultExtensionClasses=i({},ml);var yl=function(){n.SDK_DIST_CHANNEL="npm";var e=sa[da]=new fa;return function(){function e(){e.done||(e.done=!0,_a=!1,wr(sa,(function(e){e._dom_loaded()})))}null!=be&&be.addEventListener?"complete"===be.readyState?e():Cr(be,"DOMContentLoaded",e,{capture:!1}):fe&&mr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{Dn as Compression,Cn as DEFAULT_PRODUCT_TOUR_APPEARANCE,Tn as DisplaySurveyType,fa as PostHog,Fn as ProductTourEventName,Rn as ProductTourEventProperties,kn as SurveyEventName,In as SurveyEventProperties,mn as SurveyEventType,bn as SurveyPosition,xn as SurveyQuestionBranchingType,En as SurveyQuestionType,Pn as SurveySchedule,wn as SurveyTabPosition,Sn as SurveyType,yn as SurveyWidgetType,yl as default,yl as posthog,$n as severityLevels};
1
+ 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.3",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",_="$heatmaps_enabled_server_side",h="$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",E="$replay_override_linked_flag",x="$replay_override_url_trigger",P="$replay_override_event_trigger",k="$sesid",I="$session_is_sampled",T="$enabled_feature_flags",C="$active_feature_flags",F="$early_access_features",R="$feature_flag_details",L="$feature_flag_payloads",A="$feature_flag_request_id",M="$override_feature_flags",O="$override_feature_flag_payloads",D="$stored_person_properties",N="$stored_group_properties",B="$surveys",U="$surveys_loaded_at",q="$surveys_activated",H="ph_product_tours",z="$flag_call_reported",j="$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",Y="$initial_campaign_params",J="$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",_e="beforeunload",he="$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,Ee=null!=me&&me.XMLHttpRequest&&"withCredentials"in new me.XMLHttpRequest?me.XMLHttpRequest:void 0,xe=null==me?void 0:me.AbortController,Pe=null==me?void 0:me.CompressionStream,ke=null==ye?void 0:ye.userAgent,Ie=null!=fe?fe:{},Te=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Ce(e){return"string"==typeof e||e}function Fe(e){return"string"==typeof e?e:void 0}var Re,Le=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}({}),Me=["$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"],$e="NativeGzipValidationError",De=e=>e.length>=2&&31===e[0]&&139===e[1],Ne=(e,t)=>e===Ae.GZipJS||t===Ae.GZipJS||"gzip"===t,Be=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),Ue=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=$e,t},qe=function(){var e=t((function*(e,t){18>e.size&&Ue("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());De(i)&&8===i[2]||Ue("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Re)return Re;Re=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Re[e]=t>>>0}return Re})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&Ue("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&Ue("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function He(){return He=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 qe(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),He.apply(this,arguments)}var ze=["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"],je=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return ze.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function Ve(e,t){return-1!==e.indexOf(t)}var We=function(e){return e.trim()},Ge=function(e){return e.replace(/^\$/,"")},Qe=Object.prototype,Ke=Qe.hasOwnProperty,Ye=Qe.toString,Je=Array.isArray||function(e){return"[object Array]"===Ye.call(e)},Xe=e=>"function"==typeof e,Ze=e=>e===Object(e)&&!Je(e),et=e=>{if(Ze(e)){for(var t in e)if(Ke.call(e,t))return!1;return!0}return!1},tt=e=>void 0===e,it=e=>"[object String]"==Ye.call(e),rt=e=>it(e)&&0===e.trim().length,st=e=>null===e,nt=e=>tt(e)||st(e),ot=e=>"[object Number]"==Ye.call(e)&&e==e,at=e=>ot(e)&&e>0,lt=e=>"[object Boolean]"===Ye.call(e),ut=e=>e instanceof FormData,ct=e=>Ve(Me,e),dt=e=>Ve(Oe,e);function _t(e){return null===e||"object"!=typeof e}function ht(e,t){return{}.toString.call(e)==="[object "+t+"]"}function pt(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var gt=[!0,"true",1,"1","yes"],vt=e=>Ve(gt,e),ft=[!1,"false",0,"0","no"];function mt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),ot(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),mt(s||i,t,i,r))}class yt{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=mt(e.bucketSize,0,100,e._logger),this._refillRate=mt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=mt(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 bt="Mobile",wt="iOS",St="Android",Et="Tablet",xt=St+" "+Et,Pt="iPad",kt="Apple",It=kt+" Watch",Tt="Safari",Ct="BlackBerry",Ft="Samsung",Rt=Ft+"Browser",Lt=Ft+" Internet",At="Chrome",Mt=At+" OS",Ot=At+" "+wt,$t="Internet Explorer",Dt=$t+" "+bt,Nt="Opera",Bt=Nt+" Mini",Ut="Edge",qt="Microsoft "+Ut,Ht="Firefox",zt=Ht+" "+wt,jt="Nintendo",Vt="PlayStation",Wt="Xbox",Gt=St+" "+bt,Qt=bt+" "+Tt,Kt="Windows",Yt=Kt+" Phone",Jt="Nokia",Xt="Ouya",Zt="Generic",ei=Zt+" "+bt.toLowerCase(),ti=Zt+" "+Et.toLowerCase(),ii="Konqueror",ri="Oculus Browser",si="Vivaldi",ni="Yandex",oi="Whale",ai="DuckDuckGo",li="Pale Moon",ui="Waterfox",ci="Brave",di="Google Search App",_i="(\\d+(\\.\\d+)?)",hi=new RegExp("Version/"+_i),pi=new RegExp(Wt,"i"),gi=new RegExp(Vt+" \\w+","i"),vi=new RegExp(jt+" \\w+","i"),fi=new RegExp(Ct+"|PlayBook|BB10","i"),mi={"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"},yi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?ci:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&Ve(e,"GSA/")?di:Ve(e," OPR/")&&Ve(e,"Mini")?Bt:Ve(e," OPR/")?Nt:fi.test(e)?Ct:Ve(e,"IE"+bt)||Ve(e,"WPDesktop")?Dt:Ve(e,"OculusBrowser")?ri:Ve(e,Rt)?Lt:Ve(e,Ut)||Ve(e,"Edg/")?qt:Ve(e,si+"/")?si:Ve(e,"YaBrowser/")?ni:Ve(e,oi+"/")?oi:Ve(e,ai+"/")||Ve(e,"Ddg/")?ai:Ve(e,"FBIOS")?"Facebook "+bt:Ve(e,"UCWEB")||Ve(e,"UCBrowser")?"UC Browser":Ve(e,"CriOS")?Ot:Ve(e,"CrMo")||Ve(e,At)?At:Ve(e,St)&&Ve(e,Tt)?Gt:Ve(e,"FxiOS")?zt:Ve(e.toLowerCase(),ii.toLowerCase())?ii:Ve(e,ci+"/")?ci:((e,t)=>t&&Ve(t,kt)||function(e){return Ve(e,Tt)&&!Ve(e,At)&&!Ve(e,St)}(e))(e,t)?Ve(e,bt)?Qt:Tt:Ve(e,"PaleMoon/")?li:Ve(e,ui+"/")?ui:Ve(e,Ht)?Ht:Ve(e,"MSIE")||Ve(e,"Trident/")?$t:Ve(e,"Gecko")?Ht:"")},bi={[Dt]:[new RegExp("rv:"+_i)],[qt]:[new RegExp(Ut+"?\\/"+_i)],[At]:[new RegExp("("+At+"|CrMo)\\/"+_i)],[Ot]:[new RegExp("CriOS\\/"+_i)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+_i)],[Tt]:[hi],[Qt]:[hi],[Nt]:[new RegExp("(Opera|OPR)\\/"+_i)],[Ht]:[new RegExp(Ht+"\\/"+_i)],[zt]:[new RegExp("FxiOS\\/"+_i)],[ii]:[new RegExp("Konqueror[:/]?"+_i,"i")],[Ct]:[new RegExp(Ct+" "+_i),hi],[Gt]:[new RegExp("android\\s"+_i,"i")],[Lt]:[new RegExp(Rt+"\\/"+_i)],[ri]:[new RegExp("OculusBrowser\\/"+_i)],[si]:[new RegExp(si+"\\/"+_i)],[ni]:[new RegExp("YaBrowser\\/"+_i)],[oi]:[new RegExp(oi+"\\/"+_i)],[ci]:[new RegExp(ci+"\\/"+_i)],[ai]:[new RegExp("(DuckDuckGo|Ddg)\\/"+_i)],[li]:[new RegExp("PaleMoon\\/"+_i)],[ui]:[new RegExp(ui+"\\/"+_i)],[di]:[new RegExp("GSA\\/"+_i)],[$t]:[new RegExp("(rv:|MSIE )"+_i)],Mozilla:[new RegExp("rv:"+_i)]},wi=function(e,t,i,r){var s=yi(e,t,i,r),n=bi[s];if(tt(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},Si=[[new RegExp(Wt+"; "+Wt+" (.*?)[);]","i"),e=>[Wt,e&&e[1]||""]],[new RegExp(jt,"i"),[jt,""]],[new RegExp(Vt,"i"),[Vt,""]],[fi,[Ct,""]],[new RegExp(Kt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Yt,""];if(new RegExp(bt).test(t)&&!/IEMobile\b/.test(t))return[Kt+" "+bt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=mi[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[Kt,r]}return[Kt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[wt,[e[3],e[4],e[5]||"0"].join(".")]:[wt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=tt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+St+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+St+")","i"),e=>e&&e[2]?[St,[e[2],e[3],e[4]||"0"].join(".")]:[St,""]],[/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/,[Mt,""]],[/Linux|debian/i,["Linux",""]]],Ei=function(e){return vi.test(e)?jt:gi.test(e)?Vt:pi.test(e)?Wt:new RegExp(Xt,"i").test(e)?Xt: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)?It:fi.test(e)?Ct:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Jt,"i").test(e)?Jt:/(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(bt).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)?St:xt:new RegExp("(pda|"+bt+")","i").test(e)?ei:new RegExp(Et,"i").test(e)&&!new RegExp(Et+" pc","i").test(e)?ti:""},xi=/^[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)&&xi.test(i)?e:t();var i}function ki(e){return e?e.split("#")[0]:e}function Ii(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var Ti=e=>e instanceof Error,Ci={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}},Fi=Ci.info;function Ri(e){if(lt(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(Je(e))return{arrayValue:{values:e.map((e=>Ri(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function Li(e){var t=[];for(var i in e){var r=e[i];st(r)||tt(r)||t.push({key:i,value:Ri(r)})}return t}function Ai(e,t){var r=e.level||"info",{text:s,number:n}=Ci[r]||Fi,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),nt(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),nt(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:Li(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),tt(e.trace_flags)||(u.flags=e.trace_flags),u}function Mi(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:Li(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let $i=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=Je(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(Le.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(Le.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(Le.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(Le.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return Mi(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(Le.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(Le.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Ii((()=>{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(Le.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=>Ii(t,e)))]):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=!1,r=i.flush(),s=new Promise((i=>Ii((()=>{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 Di,Ni,Bi;function Ui(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Bi&&i.length===Ni||(Ni=i.length,Bi=i.reduce(((i,r)=>{Di||(Di={});var s=Di[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,Di[r]=[l,u];break}}return i}),{})),Bi}}class qi{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&&Je(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:Ui(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 Hi="?";function zi(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?Hi:i,in_app:!0};return tt(r)||(n.lineno=r),tt(s)||(n.colno=s),n}var ji=(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]:Hi,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Vi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Gi=/\((\S*)(?::(\d+))(?::(\d+))\)/,Qi=(e,t)=>{var i=Vi.exec(e);if(i){var[,r,s,n]=i;return zi(t,r,Hi,+s,+n)}var o=Wi.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=Gi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=ji(o[1]||Hi,o[2]);return zi(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Ki=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Yi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ji=(e,t)=>{var i=Ki.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]||Hi;return[n,s]=ji(n,s),zi(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Xi=/\(error: (.*)\)/;class Zi{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=it(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 ht(e,"DOMException")}isDOMError(e){return ht(e,"DOMError")}}class er{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 tr{constructor(){}match(e){return ht(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 ir=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class rr{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(ir);return r&&(t=r[1],i=r[2]),[t,i]}}var sr=["fatal","error","warning","log","info","debug"];function nr(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 or{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 pt(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: "+nr(e)}isSeverityLevel(e){return it(e)&&!rt(e)&&sr.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(Ti(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class ar{match(e){return pt(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+nr(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class lr{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 ur{match(e){return ht(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!pt(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 cr="$message",dr="$timestamp",_r=new Set([cr,dr]),hr={enabled:!0,max_bytes:32768};function pr(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:hr.enabled,max_bytes:vr(e.max_bytes,hr.max_bytes)}:i({},hr)}class gr{constructor(e){this._entries=[],this._totalBytes=0,this._config=pr(e)}setConfig(e){this._config=pr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(t.has(i))return"[Circular]";t.add(i)}return i}}))}catch(e){return}}(e);if(t)try{var i=JSON.parse(t);if(!Ze(i))return;var r=i,s=r[cr],n=r[dr];if(!it(s)||0===s.trim().length)return;if(!it(n)&&!ot(n))return;return{step:r,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map((e=>e.step))}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function vr(e,t){if(!ot(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var fr=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(fe&&(n.DEBUG||Ie.POSTHOG_DEBUG||i)&&!tt(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)=>fr(e+" "+t,i)};return r},mr=fr("[PostHog.js]"),yr=mr.createLogger;function br(e,t){Je(e)&&e.forEach(t)}function wr(e,t){if(!nt(e))if(Je(e))e.forEach(t);else if(ut(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)Ke.call(e,i)&&t(e[i],i)}var Sr=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 xr=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){mr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),mr.critical(e)}}},kr=function(e){var t={};return wr(e,(function(e,i){(it(e)&&e.length>0||ot(e))&&(t[i]=e)})),t};var Ir=["herokuapp.com","vercel.app","netlify.app"];function Tr(e){var t=null==e?void 0:e.hostname;if(!it(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Ir)if(i===r)return!1;return!0}function Cr(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 Fr(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 ot(e)&&isFinite(e)&&Math.floor(e)===e});class Rr{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 Rr(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 Rr(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 Lr{constructor(){this._timestamp=0,this._counter=0,this._random=new Or}generate(){var e=this.generateOrAbort();if(tt(e)){this._timestamp=0;var t=this.generateOrAbort();if(tt(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 Rr.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,Mr=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&&!tt(fe.crypto)&&crypto.getRandomValues&&(Mr=e=>crypto.getRandomValues(e));class Or{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(Mr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var $r=()=>Dr().toString(),Dr=()=>(Ar||(Ar=new Lr)).generate(),Nr="",Br=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Ur={_is_supported:()=>!!be,_error(e){mr.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(Ur._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),Nr)return Nr;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_"+$r();!Nr&&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",Nr=n)}return Nr}(e);if(!i){var r=(e=>{var t=e.match(Br);return t?t[0]:""})(e);r!==i&&mr.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&&mr.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{Ur._set(e,"",-1,t)}catch(e){return}}},qr=null,Hr={_is_supported(){if(!st(qr))return qr;var e=!0;if(tt(fe))e=!1;else try{var t="__mplssupport__";Hr._set(t,"xyz"),'"xyz"'!==Hr._get(t)&&(e=!1),Hr._remove(t)}catch(t){e=!1}return e||mr.error("localStorage unsupported; falling back to cookie store"),qr=e,e},_error(e){mr.error("localStorage error: "+e)},_get(e){try{return null==fe?void 0:fe.localStorage.getItem(e)}catch(e){Hr._error(e)}return null},_parse(e){try{return JSON.parse(Hr._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==fe||fe.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Hr._error(e)}return!1},_remove(e){try{null==fe||fe.localStorage.removeItem(e)}catch(e){Hr._error(e)}}},zr=[a,"distinct_id",k,I,Z,X,G],jr={},Vr={_is_supported:()=>!0,_error(e){mr.error("memoryStorage error: "+e)},_get:e=>jr[e]||null,_parse:e=>jr[e]||null,_set:(e,t)=>(jr[e]=t,!0),_remove(e){delete jr[e]}},Wr=null,Gr={_is_supported(){if(!st(Wr))return Wr;if(Wr=!0,tt(fe))Wr=!1;else try{var e="__support__";Gr._set(e,"xyz"),'"xyz"'!==Gr._get(e)&&(Wr=!1),Gr._remove(e)}catch(e){Wr=!1}return Wr},_error(e){mr.error("sessionStorage error: ",e)},_get(e){try{return null==fe?void 0:fe.sessionStorage.getItem(e)}catch(e){Gr._error(e)}return null},_parse(e){try{return JSON.parse(Gr._get(e))||null}catch(e){}return null},_set(e,t){try{return null==fe||fe.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Gr._error(e)}return!1},_remove(e){try{null==fe||fe.sessionStorage.removeItem(e)}catch(e){Gr._error(e)}}};class Qr{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 vt(e)?1:Ve(ft,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Hr:Ur;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?Ur:Hr;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(vt(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=>vt(e)))}}function Kr(e,t){var i,r=null==e||null==(i=e.config)?void 0:i.get_current_url;if(!Xe(r))return t;try{var s=r(t);return it(s)&&s?s:t}catch(e){return mr.error("Error in get_current_url, falling back to window.location.href",e),t}}var Yr=1,Jr=3,Xr=11;function Zr(e){return e instanceof Element&&(e.id===ee||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function es(e){return!!e&&e.nodeType===Yr}function ts(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function is(e){return!!e&&e.nodeType===Jr}function rs(e){return!!e&&e.nodeType===Xr&&es(e.host)}function ss(e){return e?We(e).split(/\s+/):[]}function ns(e,t){var i=function(e){var t,i=null==fe||null==(t=fe.location)?void 0:t.href;return tt(i)?void 0:Kr(e,i)}(t);return!!(i&&e&&e.some((e=>i.match(e))))}function os(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 ss(t)}function as(e){return nt(e)?null:We(e).split(/(\s+)/).filter((e=>Fs(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ls(e){var t="";return Ss(e)&&!Es(e)&&e.childNodes&&e.childNodes.length&&wr(e.childNodes,(function(e){var i;is(e)&&e.textContent&&(t+=null!==(i=as(e.textContent))&&void 0!==i?i:"")})),We(t)}function us(e){return tt(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var cs=["a","button","form","input","select","textarea","label"];function ds(e,t){if(tt(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||!es(t))&&t}var hs=[".ph-no-autocapture","[data-ph-no-autocapture]"],ps=["next","previous","prev",">","<"],gs=[...ps,"+","-","−","–"],vs=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,fs=[".ph-no-rageclick",".ph-no-capture"],ms=["","text","search","email","password","url","tel","number"];function ys(e,t){if(!fe||bs(e))return!1;var i,r,s,n,o;if(lt(t)?(i=!!t&&fs,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:fs,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||!es(e))&&(!!ts(e,"textarea")||(ts(e,"input")?Ve(ms,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var{targetElementList:a}=ws(e,!1);return!function(e,t){if(!1===e||tt(e))return!1;var i;if(!0===e)i=ps;else{if(!Je(e))return!1;if(e.length>10)return mr.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=>vs(t,e)||vs(r,e)))}))}(r,a.map((e=>{var t;return{safeText:ls(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!ds(a,i)}var bs=e=>!e||ts(e,"html")||!es(e),ws=(e,t)=>{if(!fe||bs(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!ts(s,"body");)if(rs(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=_s(s);if(!n)break;if(t||cs.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=fe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ss(e){for(var t=e;t.parentNode&&!ts(t,"body");t=t.parentNode){var i=os(t);if(Ve(i,"ph-sensitive")||Ve(i,"ph-no-capture"))return!1}if(Ve(os(e),"ph-include"))return!0;var r=e.type||"";if(it(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!it(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!!(ts(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ts(e,"select")||ts(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var xs="(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("^(?:"+xs+")$"),ks=new RegExp(xs),Is="\\d{3}-?\\d{2}-?\\d{4}",Ts=new RegExp("^("+Is+")$"),Cs=new RegExp("("+Is+")");function Fs(e,t){if(void 0===t&&(t=!0),nt(e))return!1;if(it(e)){if(e=We(e),(t?Ps:ks).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Ts:Cs).test(e))return!1}return!0}function Rs(e){var t=ls(e);return Fs(t=(t+" "+Ls(e)).trim())?t:""}function Ls(e){var t="";return e&&e.childNodes&&e.childNodes.length&&wr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=ls(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Ls(e)).trim())}catch(e){mr.error("[AutoCapture]",e)}})),t}function As(e){return e.replace(/"|\\"/g,'\\"')}function Ms(e){var t=e.attr__class;return t?Je(t)?t:ss(t):void 0}var Os=yr("[Dead Clicks]"),$s=()=>!0,Ds=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(f)),r=e.instance.config.capture_dead_clicks;return lt(r)?r:!!Ze(r)||i};class Ns{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=Ze(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 Bs=yr("[SegmentIntegration]");var Us="posthog-js";function qs(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,_;if("*"!==o&&!o.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,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==(_=g[0])?void 0:_.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 Hs{constructor(e,t,i,r,s,n){this.name=Us,this.setupOnce=function(o){o(qs(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class zs{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(mr.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(!(tt(n)||tt(o)||tt(a)||tt(l)||tt(u)||tt(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?mt(o/n,0,1,mr):1,_=n>1?mt(a/n,0,1,mr):1,h=l>1?mt(u/l,0,1,mr):1,p=l>1?mt(c/l,0,1,mr):1;r=Sr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$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 js=["flags","surveys"],Vs={[o]:{exposure:"hidden"},[u]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[c]:{exposure:"hidden"},[d]:{exposure:"event"},[_]:{exposure:"hidden"},[h]:{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"},[k]:{exposure:"hidden"},[I]:{exposure:"event"},[w]:{exposure:"event",shouldSkipFromEventProperties:e=>st(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"},[T]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Ze(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[C]:{exposure:"event",storageGroup:"flags"},[F]:{exposure:"hidden"},[R]:{exposure:"hidden",storageGroup:"flags"},[L]:{exposure:"event",storageGroup:"flags"},[A]:{exposure:"event",storageGroup:"flags",volatile:!0},[M]:{exposure:"event"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[N]:{exposure:"hidden"},[B]:{exposure:"hidden",storageGroup:"surveys"},[U]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[q]:{exposure:"event"},[H]:{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"},[z]:{exposure:"hidden"},[j]:{exposure:"hidden"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[G]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[K]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[J]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[S]:{exposure:"event"},[E]:{exposure:"event"},[x]:{exposure:"event"},[P]:{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"}},Ws=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Gs=e=>{var t=Vs[e];if(t)return t;for(var[i,r]of Ws)if(0===e.indexOf(i))return r},Qs=e=>{var t=null==be?void 0:be.createElement("a");return tt(t)?null:(t.href=e,t)},Ks=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(!Je(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){mr.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("=");Je(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=s&&(_+="#"+s),_},Js=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Xs="https?://(.*)",Zs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],en=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Zs],tn="<masked>",rn=["li_fat_id"];function sn(e,t,i){if(!be)return{};var r,s=t?[...Zs,...i||[]]:[],n=nn(Ys(be.URL,s,tn),e),o=(r={},wr(rn,(function(e){var t=Ur._get(e);r[e]=t||null})),r);return Sr(o,n)}function nn(e,t){var i=en.concat(t||[]),r={};return wr(i,(function(t){var i=Ks(e,t);r[t]=i||null})),r}function on(e){var t=function(e){return e?0===e.search(Xs+"google.([^/?]*)")?"google":0===e.search(Xs+"bing.com")?"bing":0===e.search(Xs+"yahoo.com")?"yahoo":0===e.search(Xs+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!st(t)){r.$search_engine=t;var s=be?Ks(be.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function an(){return navigator.language||navigator.userLanguage}var ln="$direct";function un(){return(null==be?void 0:be.referrer)||ln}function cn(e,t,i){void 0===i&&(i=!1);var r=e?[...Zs,...t||[]]:[],s=i?ki(null==we?void 0:we.href):null==we?void 0:we.href,n=null==s?void 0:s.substring(0,1e3);return{r:un().substring(0,1e3),u:n?Ys(n,r,tn):void 0}}function dn(e,t){var i;void 0===t&&(t=!1);var{r:r,u:s}=e,n=t?ki(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==ln?ln:null==(i=Qs(r))?void 0:i.host};if(n){o.$current_url=n;var a=Qs(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=nn(n);Sr(o,l)}if(r){var u=on(r);Sr(o,u)}return o}function _n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function hn(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var pn={flags:W,surveys:U},gn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],vn="main";class fn{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&&mr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),fe){var s=()=>this.flush();Cr(fe,"beforeunload",s,{capture:!1}),Cr(fe,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return ot(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===gn.indexOf(e.persistence.toLowerCase())&&(mr.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=[...zr,...e];return i({},Hr,{_parse(e){try{var i={};try{i=Ur._parse(e)||{}}catch(e){}var r,s=JSON.parse(Hr._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];st(a)||""===a||(n[o]=a)}r=Sr(s,n)}else r=Sr(i,s);return Hr._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=Hr._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&Ur._set(e,l,i,s,n,o)}catch(e){Hr._error(e)}return a},_remove(e,t){try{null==fe||fe.localStorage.removeItem(e),Ur._remove(e,t)}catch(e){Hr._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&Hr._is_supported()?(t=Hr,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&Gr._is_supported()?t=Gr:"memory"===n?t=Vr:"cookie"===n?t=Ur:r._is_supported()?(t=r,s=!0):t=Ur,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 wr(this.props,((t,i)=>{var r=Gs(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===T?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&Sr(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=Sr({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of js){var t=Hr._parse(this._groupEntryName(e));if(t&&!et(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Sr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=Gs(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=pn[e];if(!i)return!1;var r=t[i],s=this.props[i];return ot(r)&&ot(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=Gs(e))?void 0:t.storageGroup:void 0,r=i?Hr._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?tt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){tt(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,vn))}_writeNowSplit(){var{main:e,groups:t}=this._partitionProps();for(var i of(this._writeEntry(this._storage,this._name,e,vn),js)){var r,s=t[i];(!et(s)||null!=(r=this._slotState[i])&&r.persisted)&&this._writeEntry(Hr,this._groupEntryName(i),s,i)}}_partitionProps(){var e={},t={};for(var i of js)t[i]={};return wr(this.props,((i,r)=>{var s,n=null==(s=Gs(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===vn)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return wr(e,((e,t)=>{var r;i[t]=null!=(r=Gs(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===vn||s.dirty||tt(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!==vn&&(s.persisted=!0),tt(n)||(s.fingerprint=n)):this._config.debug&&mr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var{keepGroupEntries:t=!1}=void 0===e?{}:e;if(tt(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 js)Hr._remove(this._groupEntryName(i));t?delete this._slotState[vn]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Ze(e)){tt(t)&&(t="None"),this._expire_days=tt(i)?this._default_expiry:i;var r=!1;if(wr(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(Ze(e)){this._expire_days=tt(t)?this._default_expiry:t;var i=!1;if(wr(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=sn(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);et(kr(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==be?void 0:be.referrer)?on(e):{})}update_referrer_info(){var e;this.register_once({$referrer:un(),$referring_domain:null!=be&&be.referrer&&(null==(e=Qs(be.referrer))?void 0:e.host)||ln},void 0)}set_initial_person_info(){this.props[Y]||this.props[J]||this.register_once({[X]:cn(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={};wr([J,Y],(t=>{var i=this.props[t];i&&wr(i,(function(t,i){e["$initial_"+Ge(i)]=t}))}));var t=this.props[X];if(t){var i=function(e,t){void 0===t&&(t=!1);var i=dn(e,t),r={};return wr(i,(function(e,t){r["$initial_"+Ge(t)]=e})),r}(t,this._config.disable_capture_url_hashes);Sr(e,i)}return e}safe_merge(e){return wr(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 tt(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=Gs(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=Gs(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}var mn={Activation:"events",Cancellation:"cancelEvents"},yn={Button:"button",Tab:"tab",Selector:"selector"},bn={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},wn={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Sn={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},En={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},xn={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Pn={Once:"once",Recurring:"recurring",Always:"always"},kn={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},In={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Tn={Popover:"popover",Inline:"inline"},Cn={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},Fn={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Rn={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Ln=yr("[RateLimiter]");class An{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=>{Ln.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Ln.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 Mn=yr("[RemoteConfig]");class On{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 Mn.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void Mn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Mn.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){Mn.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||Mn.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 $n=["fatal","error","warning","log","info","debug"],Dn={GZipJS:"gzip-js",Base64:"base64"},Nn=Uint8Array,Bn=Uint16Array,Un=Uint32Array,qn=new Nn([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]),Hn=new Nn([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]),zn=new Nn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jn=function(e,t){for(var i=new Bn(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Un(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]},Vn=jn(qn,2),Wn=Vn[1];Vn[0][28]=258,Wn[258]=28;for(var Gn=jn(Hn,0)[1],Qn=new Bn(32768),Kn=0;32768>Kn;++Kn){var Yn=(43690&Kn)>>>1|(21845&Kn)<<1;Qn[Kn]=((65280&(Yn=(61680&(Yn=(52428&Yn)>>>2|(13107&Yn)<<2))>>>4|(3855&Yn)<<4))>>>8|(255&Yn)<<8)>>>1}var Jn=function(e,t,i){for(var r=e.length,s=0,n=new Bn(t);r>s;++s)++n[e[s]-1];var o,a=new Bn(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new Bn(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,_=d|(1<<c)-1;_>=d;++d)o[Qn[d]>>>l]=u}else for(o=new Bn(r),s=0;r>s;++s)o[s]=Qn[a[e[s]-1]++]>>>15-e[s];return o},Xn=new Nn(288);for(Kn=0;144>Kn;++Kn)Xn[Kn]=8;for(Kn=144;256>Kn;++Kn)Xn[Kn]=9;for(Kn=256;280>Kn;++Kn)Xn[Kn]=7;for(Kn=280;288>Kn;++Kn)Xn[Kn]=8;var Zn=new Nn(32);for(Kn=0;32>Kn;++Kn)Zn[Kn]=5;var eo=Jn(Xn,9,0),to=Jn(Zn,5,0),io=function(e){return(e/8>>0)+(7&e&&1)},ro=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Bn?Bn:e instanceof Un?Un:Nn)(i-t);return r.set(e.subarray(t,i)),r},so=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},no=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},oo=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 Nn(0),0];if(1==s){var o=new Nn(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 _=n[0].s;for(r=1;s>r;++r)n[r].s>_&&(_=n[r].s);var h=new Bn(_+1),p=ao(i[c-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>h[y]?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new Nn(h),p]},ao=function(e,t,i){return-1==e.s?Math.max(ao(e.l,t,i+1),ao(e.r,t,i+1)):t[e.s]=i},lo=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Bn(++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]},uo=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},co=function(e,t,i){var r=i.length,s=io(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)},_o=function(e,t,i,r,s,n,o,a,l,u,c){so(t,c++,i),++s[256];for(var d=oo(s,15),_=d[0],h=d[1],p=oo(n,15),g=p[0],v=p[1],f=lo(_),m=f[0],y=f[1],b=lo(g),w=b[0],S=b[1],E=new Bn(19),x=0;m.length>x;++x)E[31&m[x]]++;for(x=0;w.length>x;++x)E[31&w[x]]++;for(var P=oo(E,7),k=P[0],I=P[1],T=19;T>4&&!k[zn[T-1]];--T);var C,F,R,L,A=u+5<<3,M=uo(s,Xn)+uo(n,Zn)+o,O=uo(s,_)+uo(n,g)+o+14+3*T+uo(E,k)+(2*E[16]+3*E[17]+7*E[18]);if(M>=A&&O>=A)return co(t,c,e.subarray(l,l+u));if(so(t,c,1+(M>O)),c+=2,M>O){C=Jn(_,h,0),F=_,R=Jn(g,v,0),L=g;var D=Jn(k,I,0);for(so(t,c,y-257),so(t,c+5,S-1),so(t,c+10,T-4),c+=14,x=0;T>x;++x)so(t,c+3*x,k[zn[x]]);c+=3*T;for(var N=[m,w],B=0;2>B;++B){var U=N[B];for(x=0;U.length>x;++x)so(t,c,D[q=31&U[x]]),c+=k[q],q>15&&(so(t,c,U[x]>>>5&127),c+=U[x]>>>12)}}else C=eo,F=Xn,R=to,L=Zn;for(x=0;a>x;++x)if(r[x]>255){var q;no(t,c,C[257+(q=r[x]>>>18&31)]),c+=F[q+257],q>7&&(so(t,c,r[x]>>>23&31),c+=qn[q]);var H=31&r[x];no(t,c,R[H]),c+=L[H],H>3&&(no(t,c,r[x]>>>5&8191),c+=Hn[H])}else no(t,c,C[r[x]]),c+=F[r[x]];return no(t,c,C[256]),c+F[256]},ho=new Un([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),po=function(){for(var e=new Un(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),go=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function vo(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=po[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 Nn(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=co(l,u,e.subarray(c,d)):(l[c]=!0,u=co(l,u,e.subarray(c,o)))}else{for(var _=ho[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new Bn(32768),f=new Bn(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 Un(25e3),S=new Bn(288),E=new Bn(32),x=0,P=0,k=(c=0,0),I=0,T=0;o>c;++c){var C=b(c),F=32767&c,R=f[C];if(v[F]=R,f[C]=F,c>=I){var L=o-c;if((x>7e3||k>24576)&&L>423){u=_o(e,l,0,w,S,E,P,k,T,c-T,u),k=x=P=0,T=c;for(var A=0;286>A;++A)S[A]=0;for(A=0;30>A;++A)E[A]=0}var M=2,O=0,D=p,N=F-R&32767;if(L>2&&C==b(c-N))for(var B=Math.min(h,L)-1,U=Math.min(32767,c),q=Math.min(258,L);U>=N&&--D&&F!=R;){if(e[c+M]==e[c+M-N]){for(var H=0;q>H&&e[c+H]==e[c+H-N];++H);if(H>M){if(M=H,O=N,H>B)break;var z=Math.min(N,H-2),j=0;for(A=0;z>A;++A){var V=c-N+A+32768&32767,W=V-v[V]+32768&32767;W>j&&(j=W,R=V)}}}N+=(F=R)-(R=v[F])+32768&32767}if(O){w[k++]=268435456|Wn[M]<<18|Gn[O];var G=31&Wn[M],Q=31&Gn[O];P+=qn[G]+Hn[Q],++S[257+G],++E[Q],I=c+M,++x}else w[k++]=e[c],++S[e[c]]}}u=_o(e,l,!0,w,S,E,P,k,T,c-T,u)}return ro(a,0,r+io(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&&go(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),go(u,c-8,i.d()),go(u,c-4,r),u}var fo=!!Ee||!!Se,mo="text/plain",yo=!1,bo=(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:"")},wo=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 wr(e,(function(e,t){tt(e)||tt(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("&")},So=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Eo=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===Dn.GZipJS){var r=vo(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Nn(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 Nn(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 ro(r,0,s)}(So(t)),{mtime:0});return{contentType:mo,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Dn.Base64){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(So(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:So(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=So(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},xo=e=>{var t,r,s=()=>({url:bo(e.url,"compression"),encodedBody:Eo(i({},e,{compression:void 0,_encodedBody:void 0}))});try{t=Eo(e)}catch(t){if(Ne(e.compression,Ks(e.url,"compression")))return mr.error("Failed to gzip request body, sending uncompressed payload",t),s();throw t}return t&&Ne(e.compression,Ks(e.url,"compression"))&&!((r=t.body)instanceof ArrayBuffer?De(new Uint8Array(r)):ArrayBuffer.isView(r)&&De(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(yo=!0,s()):{url:e.url,encodedBody:t}},Po=e=>{try{return xo(e)}catch(t){return mr.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},ko=function(){var e=t((function*(e){var t=So(e.data),r=yield function(e,t,i){return He.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:mo,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Io=(e,t)=>wo(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),To=[];Se&&To.push({transport:"fetch",method(e){var t,r=Po(e);if(r){var{url:s,encodedBody:n}=r,{contentType:o,body:a,estimatedSize:l}=null!=n?n:{},u=new Headers;wr(e.headers,(function(e,t){u.append(t,e)})),o&&u.append("Content-Type",o);var c=null,d=null;if(xe){var _=new xe;c={signal:_.signal,timeout:setTimeout((()=>{var t,i;t=e.timeout,(i=new Error("PostHog request timed out"+(t?" after "+t+"ms":""))).name="AbortError",_.abort(d=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){mr.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{t===d?mr.warn(t):mr.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}}),Ee&&To.push({transport:"XHR",method(e){var t=Po(e);if(t){var i=new Ee,{url:r,encodedBody:s}=t;i.open(e.method||"GET",r,!0);var{contentType:n,body:o}=null!=s?s:{};wr(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&&To.push({transport:"sendBeacon",method(e){try{var{url:t,encodedBody:i}=xo(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 Co=3e3;class Fo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=mt((null==t?void 0:t.flush_interval_ms)||Co,250,5e3,mr.createLogger("flush interval"),Co),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&&Je(i.data)&&wr(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){mr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return wr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;tt(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Ro=["retriesPerformedSoFar"];class Lo{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!tt(fe)&&"onLine"in fe.navigator&&(this._areWeOnline=fe.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Cr(fe,"online",this._onlineListener),Cr(fe,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,Ro);at(t)&&(s.url=wo(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&&mr.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)"),mr.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,tt(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){mr.error(e)}this._queue=[]}}class Ao{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(){Cr(fe,"scroll",this._updateScrollData,{capture:!0}),Cr(fe,"scrollend",this._updateScrollData,{capture:!0}),Cr(fe,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==fe?void 0:fe.document.documentElement;var e=Je(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 Mo=e=>cn(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 Oo{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||Mo,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?dn(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 wr(kr(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Ge(i)]=t})),e}}class $o{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 Do=yr("[SessionId]");class No{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 $o,this._sessionHasBeenIdleTooLong=(e,t)=>!(!at(e)||!at(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||$r,this._windowIdGenerator=i||$r;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*mt(this._config.session_idle_timeout_seconds||1800,60,36e3,Do.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=Gr._parse(this._window_id_storage_key),o=Gr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Gr._remove(this._window_id_storage_key),Gr._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){Do.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return tt(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&&Gr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Gr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Gr._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!st(t)&&!st(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var r=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!r||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[k]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return at(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(k):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!st(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({[k]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var[e]=this._getSessionId(),t=at(e)?e:0,i=at(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[k];return Je(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(_e,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Gr._remove(this._primary_window_exists_storage_key)},Cr(fe,_e,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=at(s)&&Math.abs(i-s)>864e5,l=!1,u=!1,c=!r,d=r,_=!c&&!e&&this._sessionHasBeenIdleTooLong(i,n);_&&((_=this._isSessionIdleAfterCrossTabRefresh(i))||Do.info("cross-tab refresh kept the session alive",{sessionId:r}),[,r,s]=this._getSessionId()),c||_||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Do.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:_,sessionPastMaximumLength:a}}),s=i,l=!0):(o||(o=this._windowIdGenerator(),l=!0),(u=r!==d)&&(Do.info("adopted cross-tab session id",{sessionId:r,windowId:o}),l=!0));var h=at(n)&&e&&!a?n:i,p=at(s)?s:(new Date).getTime();this._setWindowId(o),this._setSessionId(r,h,p),e||this._resetIdleTimer();var g={noSessionId:c,activityTimeout:_,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 Bo=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&je(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>je(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function Uo(){return(Uo=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 it(i)&&i.length>0?i:void 0}catch(e){return void mr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}))).apply(this,arguments)}var qo=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 Ho(e,t,i){return So({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var zo={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=>qo(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!qo(t,e))))),icontains:(e,t)=>t.map(jo).some((t=>e.map(jo).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(jo).every((t=>e.map(jo).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)))}))},jo=e=>e.toLowerCase();function Vo(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(tt(s)||st(s))return!1;var n=[String(s)],o=zo[r.operator];return!!o&&o(r.values,n)}))}var Wo="custom",Go="i.posthog.com",Qo=/^\/static\//;class Ko{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("."+Go,".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":Wo),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(Qo.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===Wo)return this.apiHost+t;var r=Go+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Yo=yr("[Surveys]"),Jo="seenSurvey_",Xo=[Sn.Popover,Sn.Widget,Sn.API],Zo={ignoreConditions:!1,ignoreDelay:!1,displayType:Tn.Popover},ea=yr("[PostHog ExternalIntegrations]"),ta={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ia{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 ea.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(ta[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 ra,sa={},na=0,oa=()=>{},aa='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',la="Surveys module not available",ua="sanitize_properties is deprecated. Use before_send instead",ca="Invalid value for property_denylist config: ",da="posthog",_a=!fo&&-1===(null==ke?void 0:ke.indexOf("MSIE"))&&-1===(null==ke?void 0:ke.indexOf("Mozilla")),ha=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:Tr(null==be?void 0:be.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:oa,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&&it(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){mr.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:Co},error_tracking:{},_onCapture:oa},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:gs,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))},pa=[["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"]],ga=e=>{var t={};for(var[i,r]of pa)tt(e[i])||(t[r]=e[i]);var s=Sr({},t,e),n=e.__preview_external_dependency_versioned_paths;return tt(n)||(tt(e.strict_script_versioning)&&(s.strict_script_versioning=!!n),it(n)&&tt(e.asset_host)&&(s.asset_host=n)),Je(e.property_blacklist)&&(tt(e.property_denylist)?s.property_denylist=e.property_blacklist:Je(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:mr.error(ca+e.property_denylist)),s};class va{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){mr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class fa{_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 va,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new $o,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ha(),this.SentryIntegration=Hs,this.sentryIntegration=e=>function(e,t){var i=qs(e,t);return{name:Us,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 Ao(this),this.pageViewManager=new zs(this),this.rateLimiter=new An(this),this.requestRouter=new Ko(this),this.consent=new Qr(this),this.externalIntegrations=new ia(this);var t=null!==(e=fa.__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=it(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=it(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>mr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==da){var r,s=null!==(r=sa[i])&&void 0!==r?r:new fa;return s._init(e,t,i),sa[i]=s,sa[da][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;void 0===t&&(t={});var a=it(e)?e.trim():"";if(!a)return mr.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=ha(t.defaults),c=ga(t),d=Sr({},u,c,{name:r,token:a});Ze(u.rageclick)&&Ze(c.rageclick)&&(d.rageclick=Sr({},u.rageclick,c.rageclick)),Ze(u.session_recording)&&Ze(c.session_recording)&&(d.session_recording=Sr({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&mr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Dn.GZipJS;var _=this._is_persistence_disabled();this.persistence=new fn(this.config,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new fn(i({},this.config,{persistence:"sessionStorage"}),_,!1);var h=i({},this.persistence.props),p=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Fo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Lo(this),this.__request_queue=[];var g=this._inCookielessMode();if(g||(this.sessionManager=new No(this),this.sessionPropsManager=new Oo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(mr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(g)}),0)):(mr.info("Initializing extensions synchronously"),this._initExtensions(g)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&mr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:h,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)mr.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($r()),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($r());this.register_once({distinct_id:w,$device_id:w},""),this.persistence.set_property(G,le)}return Cr(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()||$r();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&&Xe(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{"undefined"!=typeof Promise&&Promise.resolve||Bs.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()||(Bs.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Bs.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,he),identify:e=>t(e,ge),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Xe(this.config._onCapture)&&this.config._onCapture!==oa&&(mr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&mr.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 Uo.apply(this,arguments)}().then((e=>{e&&this.register({[l]:e})})).catch(oa),this}_initExtensions(e){var t,r,s,n,o,a,l,u=performance.now(),c=i({},fa.__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,Ds)),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){mr.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&&mr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!be||!be.body)return mr.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=Ve(e.supportedCompression,Dn.GZipJS)?Dn.GZipJS:Ve(e.supportedCompression,Dn.Base64)?Dn.Base64: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){mr.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 On(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()&&br(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?_a?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,(tt(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=Io(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=To.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===Dn.GZipJS&&Pe&&"undefined"!=typeof Promise&&!yo?ko(n).then((e=>{l(e)})).catch((t=>{if(Be(t))return yo=!0,void l(i({},n,{compression:void 0,url:Io(e.url,void 0)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return Be(e)||t===$e})(t)&&(yo=!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){na++;try{var t,i=[],r=[],s=[];br(e,(e=>{if(e)if(Je(t=e[0]))s.push(e);else if(Xe(e))try{e.call(this)}catch(t){mr.error("Error executing queued PostHog call",e,t)}else Je(e)&&"alias"===t?i.push(e):Je(e)&&-1!==t.indexOf("capture")&&Xe(this[t])?s.push(e):r.push(e)}));var n=function(e,t){br(e,(function(e){try{if(Je(e[0])){var i=t;wr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){mr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{na--}}push(e){if(na>0&&Je(e)&&it(e[0])){var t=fa.prototype[e[0]];Xe(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(!tt(e)&&it(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&&!it(null==t?void 0:t.$current_url)&&(mr.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||mr.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,_=(null==r?void 0:r.timestamp)||d,h=Pi(null==r?void 0:r.uuid,$r),p={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},_,h)};e===he&&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=>it(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),Je(t)?(r=[],br(t,(t=>{r.push(e(t))}))):(r={},wr(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=_,tt(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===kn.DISMISSED||e===kn.SENT){var b=null==t?void 0:t[In.SURVEY_ID],w=null==t?void 0:t[In.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var i=""+Jo+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+Jo+t.id+"_"+t.current_iteration),i})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){Yo.error("Failed to persist survey seen state",e)}})({id:b,current_iteration:w}),p.$set=i({},p.$set,{[(v={id:b,current_iteration:w},f=e===kn.SENT?"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===kn.SHOWN&&(p.$set=i({},p.$set,{[In.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(e===Fn.SHOWN){var S=null==t?void 0:t[Rn.TOUR_TYPE];S&&(p.$set=i({},p.$set,{[Rn.TOUR_LAST_SEEN_DATE+"/"+S]:(new Date).toISOString()}))}var E=i({},p.properties.$set,p.$set);if(et(E)||this.setPersonPropertiesForFlags(E),!nt(this.config.before_send)){var x=this._runBeforeSend(p);if(!x)return;(p=x).uuid=Pi(p.uuid,$r)}this._internalEventEmitter.emit("eventCaptured",p);var P={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(P):this._requestQueue.enqueue(P),p}mr.critical("This capture call is ignored due to client rate limiting.")}}else mr.error("No event name provided to posthog.capture")}else mr.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,(!it(l.distinct_id)&&!ot(l.distinct_id)||rt(l.distinct_id))&&mr.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),!ke)return{};var u,c,d,_,h,p,g,v,f,m=e?[...Zs,...t||[]]:[],[y,b]=function(e){for(var t=0;Si.length>t;t++){var[i,r]=Si[t],s=i.exec(e),n=s&&(Xe(r)?r(s,e):r);if(n)return n}return["",""]}(ke),w=null!=(u="undefined"!=typeof navigator?navigator:void 0)&&u.brave?{brave:!0}:{},S={detectGoogleSearchApp:i},E=Sr(kr({$os:y,$os_version:b,$browser:yi(ke,navigator.vendor,w,S),$device:Ei(ke),$device_type:(d=ke,_={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===xt||"Kobo"===f||"Kindle Fire"===f||f===ti?Et:f===jt||f===Wt||f===Vt||f===Xt?"Console":f===It?"Wearable":f?bt:"Android"===(null==_?void 0:_.userAgentDataPlatform)&&(null!==(h=null==_?void 0:_.maxTouchPoints)&&void 0!==h?h:0)>0?600>Math.min(null!==(p=null==_?void 0:_.screenWidth)&&void 0!==p?p:0,null!==(g=null==_?void 0:_.screenHeight)&&void 0!==g?g:0)/(null!==(v=null==_?void 0:_.devicePixelRatio)&&void 0!==v?v:1)?bt:Et:"Desktop"),$timezone:_n(),$timezone_offset:hn()}),{$current_url:Ys(r?ki(null==we?void 0:we.href):null==we?void 0:we.href,m,tn),$host:null==we?void 0:we.host,$pathname:null==we?void 0:we.pathname,$raw_user_agent:ke.length>1e3?ke.substring(0,997)+"...":ke,$browser_version:wi(ke,navigator.vendor,w,S),$browser_language:an(),$browser_language_prefix:(c=an(),"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&&(E.$sdk_dist_channel=n.SDK_DIST_CHANNEL),E}(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:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&Sr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Sr(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===Wo&&(l.$lib_custom_api_host=this.config.api_host),c=e!==he||o?e!==pe||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=Sr(l,c),e===he&&be&&(l.title=be.title),!tt(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}ke&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=Sr({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Je(this.config.property_denylist)?wr(this.config.property_denylist,(function(e){delete l[e]})):mr.error(ca+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(mr.error(ua),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=Sr({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(mr.error(ua),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),et(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:la}),()=>{})}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:la})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:la})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=Zo),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:la}}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:la})}_validateIdentifyId(e){return!e||rt(e)?(mr.critical("Unique user id has not been set in posthog.identify"),!1):e===te?(mr.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())||(mr.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 mr.uninitializedWarning("posthog.identify");if(ot(e)&&(e=e.toString(),mr.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=Ho(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(z))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=Ho(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):mr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(Je(e)?e:[e]).filter((e=>it(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 mr.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(mr.info("reset"),!this.__loaded)return mr.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(),tt(g)||null==(_=this.persistence)||_.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($r());this.register_once({distinct_id:v,$device_id:e?v:h},""),e||tt(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()}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)?(mr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(tt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(u,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(mr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(Ze(e)){var r,s,o,a,l,u,c,d,_,h,p;Sr(this.config,ga(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 fn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);lt(v)&&(this.config.debug=v),lt(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,Hr._is_supported()&&Hr._set("ph_debug",!0),mr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,Hr._is_supported()&&Hr._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==(_=this.deadClicksAutocapture)||_.startIfEnabledOrStop(),null==(h=this.surveys)||h.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:fa._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:da;return t!==da&&(t=da+"."+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()&&et(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?(mr.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 No(this),this.pageViewManager=new zs(this),this.persistence&&(this.sessionPropsManager=new Oo(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=fa.__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()),(tt(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 mr.warn(aa)}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())):mr.warn(aa)}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?Bo(ye,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){be&&("visible"===be.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(he,{title:be.title},{send_instantly:!0}),this._visibilityStateListener&&(be.removeEventListener(de,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Cr(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?(mr.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=mr,s=(t="advanced_disable_flags")in(e=o)&&!nt(e[t]),n=i in e&&!nt(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(nt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(dt),r=Je(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),nt(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return ct(e.event)?mr.warn(o+". This can cause unexpected behavior."):mr.info(o),null}s.properties&&!et(s.properties)||mr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&nt(s.properties[a]))return mr.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=lt(e)&&!e,i=Hr._is_supported()&&"true"===Hr._get("ph_debug");return!t&&(!!i||e)}}fa.__defaultExtensionClasses={},fa._noopLogger={trace:ra=()=>{},debug:ra,info:ra,warn:ra,error:ra,fatal:ra},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Pr(e.prototype[t[i]])}(fa,["identify"]);class ma{constructor(e){this.disabled=!1===e;var t=Ze(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 ya="$copy_autocapture",ba=yr("[AutoCapture]");function wa(e,t){return t.length>e?t.slice(0,e)+"...":t}function Sa(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!es(t));return t}function Ea(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:c}=t;if(!es(e))return{props:{}};for(var d=[e],_=e;_.parentNode&&!ts(_,"body");)if(rs(_.parentNode))d.push(_.parentNode.host),_=_.parentNode.host;else{if(!es(_.parentNode))break;d.push(_.parentNode),_=_.parentNode}var h,p,g=[],v={},f=!1,m=!1;if(wr(d,(e=>{var t=Ss(e);if(ts(e,"a")){var i=e.getAttribute("href");f=!!(t&&i&&Fs(i))&&(c?ki(i):i)}Ve(os(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};cs.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?wa(1024,Rs(e)):wa(1024,ls(e)));var a=os(e);a.length>0&&(o.classes=a.filter((function(e){return""!==e}))),wr(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&&Fs(i.value)&&(!it(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=ss(a).join(" ")),o["attr__"+i.name]=wa(1024,"href"===i.name&&s?ki(a):a)}}));for(var l=1,u=1,c=e;c=Sa(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(!Ss(e))return{};var t={};return wr(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&&Fs(r)&&(t[i]=r)}})),t}(e);Sr(v,r)})),m)return{props:{},explicitNoCapture:m};if(a||(g[0].$el_text=ts(e,"a")||ts(e,"button")?Rs(e):ls(e)),f){var y,b;g[0].attr__href=f;var w=null==(y=Qs(f))?void 0:y.host,S=null==fe||null==(b=fe.location)?void 0:b.host;w&&S&&w!==S&&(h=f)}return{props:Sr({$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:Ms(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}:{},h&&"click"===n.type?{$external_click_url:h}:{},v)}}var xa=yr("[ExceptionAutocapture]"),Pa=yr("[TracingHeaders]"),ka=yr("[Web Vitals]"),Ia=9e5,Ta="disabled",Ca="lazy_loading",Fa="awaiting_config",Ra="missing_config";yr("[SessionRecording]"),yr("[SessionRecording]");var La="[SessionRecording]",Aa=yr(La),Ma=yr("[Heatmaps]");function Oa(e){return Ze(e)&&"clientX"in e&&"clientY"in e&&ot(e.clientX)&&ot(e.clientY)}var $a=yr("[Product Tours]"),Da=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(m))},Na=["$set_once","$set"],Ba=yr("[SiteApps]"),Ua="Error while initializing PostHog app with config id ";function qa(e,t,i){if(nt(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 Ha{constructor(e){this._debugEventEmitter=new $o,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;tt(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(!tt(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(!qa(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=>qa(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&qa((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=>qa(e.text,t.text,t.text_matching||"exact")||qa(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;!nt(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=>qa(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||Vo(t.properties.reduce(((e,t)=>{var i=Je(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 za{constructor(e){this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&Vo(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===mn.Activation?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;tt(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 Ha(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,mn.Activation),this._cancelEventToItems=this._buildEventToItemMap(e,mn.Cancellation))}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,mn.Cancellation);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,mn.Activation);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 ja extends za{constructor(e){super(e)}_getActivatedKey(){return q}_getShownEventName(){return kn.SHOWN}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return Yo}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[q]: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 e.schedule===Pn.Always||!(null==(r=e.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?e===kn.SHOWN?"consume":"ignore":e===kn.SHOWN?"persist":e===kn.DISMISSED||e===kn.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Va="SDK is not enabled or survey functionality is not yet loaded",Wa="Disabled. Not loading surveys.",Ga=null!=fe&&fe.location?Js(fe.location.hash,"__posthog")||Js(location.hash,"state"):null,Qa="_postHogToolbarParams",Ka=yr("[Toolbar]"),Ya=yr("[FeatureFlags]"),Ja=yr("[FeatureFlags]",{debugEnabled:!0}),Xa="\" failed. Feature flags didn't load in time.",Za=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},el=e=>{var t={};for(var[i,r]of Er(e||{}))r&&(t[i]=r);return t},tl=yr("[Error tracking]"),il="Refusing to render web experiment since the viewer is a likely bot",rl={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>qo(t,e),not_regex:(e,t)=>!qo(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class sl{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{sl._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(sl._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);it(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];sl._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())sl._logInfo(il);else if(!this._config.disable_web_experiments){if(nt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();sl._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=sl.getWindowLocation();if(null!=e&&e.search){var t=Ks(null==e?void 0:e.search,"__experiment_id"),i=Ks(null==e?void 0:e.search,"__experiment_variant");t&&i&&(sl._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&&(sl._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!nt(e.conditions)&&sl._matchUrlConditions(e,t)&&sl._matchUTMConditions(e)}static _matchUrlConditions(e,t){var i;if(nt(e.conditions)||nt(null==(i=e.conditions)?void 0:i.url))return!0;var r=sl.getWindowLocation();if(r){var s,n,o,a=Kr(t,r.href);return null==(s=e.conditions)||!s.url||rl[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(nt(e.conditions)||nt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=sn();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,_=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,h=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&&h&&p&&_}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];mr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?sl._logInfo(il):"control"!==t?i.forEach((i=>{if(i.selector){var r;sl._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)}))}})):sl._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ye&&this._instance?Bo(ye,this._config.custom_blocked_useragents):void 0}}var nl=yr("[Conversations]"),ol="Conversations not available yet.",al="console",ll={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._instance=e,this.featureFlagEventHandlers=[]}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,Ya.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||(Ya.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||Ya.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(!tt(e)){if(Je(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Ya.error("Invalid flag key found:",e,"Expected non-empty string"),t}));Ya.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(T))&&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,_]of Object.entries(l))c[d]={key:d,enabled:Ce(_),variant:Fe(_),reason:void 0,metadata:tt(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(M),r=this._prop(O);if(!r&&!t)return e||{};var s=Sr({},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=tt(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=tt(c)?u.variant:"string"==typeof c?c:void 0,h=null==r?void 0:r[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[o]=p}return this._override_warning||(Ya.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:Ce(r),variant:Fe(r),payload:Te(t[i])}}))}getFlagVariants(){var e=this._prop(T),t=this._prop(M);if(!t)return e||{};for(var i=Sr({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ya.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=Sr({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Ya.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._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())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(N),timezone:_n()};st(s)||tt(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();tt(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:Dn.Base64,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(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)Ya.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())}}})}}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 Ya.warn('getFeatureFlag for key "'+e+Xa)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(A)||void 0,l=this._prop(W)||void 0,u=this._prop(z)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(j);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[z]:u,[j]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,v,f,m,y,b,w,S;Je(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[z]:u});var E=this.getFeatureFlagDetails(e),x=[...null!==(p=this._prop(V))&&void 0!==p?p:[]];tt(s)&&x.push("flag_missing");var P={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};tt(null==E||null==(f=E.metadata)?void 0:f.version)||(P.$feature_flag_version=E.metadata.version);var k,I=null!==(m=null==E||null==(y=E.reason)?void 0:y.description)&&void 0!==m?m:null==E||null==(b=E.reason)?void 0:b.code;I&&(P.$feature_flag_reason=I),null!=E&&null!=(w=E.metadata)&&w.id&&(P.$feature_flag_id=E.metadata.id),tt(null==E?void 0:E.original_variant)&&tt(null==E?void 0:E.original_enabled)||(P.$feature_flag_original_response=tt(E.original_variant)?E.original_enabled:E.original_variant),null!=E&&null!=(S=E.metadata)&&S.original_payload&&(P.$feature_flag_original_payload=null==E||null==(k=E.metadata)?void 0:k.original_payload),x.length&&(P.$feature_flag_error=x.join(",")),this._instance.capture("$feature_flag_called",P)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Te(n)}}}else Ya.warn('getFeatureFlagResult for key "'+e+Xa)}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();tt(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:Dn.Base64,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 tt(i)?void 0:!!i}Ya.warn('isFeatureEnabled for key "'+e+Xa)}}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&&Ya.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,_=e.evaluatedAt;if(Je(u)){Ya.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(u)for(var p=0;u.length>p;p++)h[u[p]]=!0;t&&t.register({[C]:u,[T]:h})}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({[C]:Object.keys(el(g)),[T]:g||{},[L]:v||{},[R]:f||{}},d?{[A]:d}:{},_?{[W]:_}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Ya.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Ya.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(M),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),Ja.info("All overrides cleared");if(Je(e)){var t=Za(e);return this._persistence.register({[M]:t}),this._fireFeatureFlagsCallbacks(),Ja.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(M),Ja.info("Flag overrides cleared");else if(r.flags){if(Je(r.flags)){var s=Za(r.flags);this._persistence.register({[M]:s})}else this._persistence.register({[M]:r.flags});Ja.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),Ja.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),Ja.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[M]:e}),this._fireFeatureFlagsCallbacks(),Ja.info("Flag overrides set",{flags:e});Ya.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(F)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[C]:Object.keys(el(l)),[T]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(F),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(F),null==(r=this._persistence)||r.register({[F]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>r(t,i,{errorsLoading: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(N)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[N]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(N)||{};this._instance.register({[N]:i({},t,{[e]:{}})})}else this._instance.unregister(N)}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}}},ul={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===Fa||this._recordingStatus===Ra?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=Ta,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Aa.error("started without valid sessionManager"),new Error(La+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===ae)throw new Error(La+' 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=!tt(Object.assign)&&!tt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Aa.info("starting")):(this._recordingStatus=Ta,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==Fa&&this._recordingStatus!==Ra&&(this._recordingStatus=Ca),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 Aa.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(nt(e))return null;var i,r=ot(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Aa.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;nt(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:tt(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===Fa&&(this._recordingStatus=Ra,Aa.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):Aa.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 Aa.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 Aa.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===Ra||this._recordingStatus===Fa)return;return this._recordingStatus=Fa,Aa.info("persisted remote config is stale, requesting fresh config before starting"),void new On(this._instance).load()}this._recordingStatus=Ca,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({[E]:!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?x:P]:!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))}}},cl={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new ma(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=Ze(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){ba.error("Failed to capture event",e)}};if(Cr(be,"submit",e,{capture:!0}),Cr(be,"change",e,{capture:!0}),Cr(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,ya)}catch(e){ba.error("Failed to capture copy/cut event",e)}};Cr(be,"copy",t,{capture:!0}),Cr(be,"cut",t,{capture:!0})}}}else ba.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(st(this._isDisabledServerSide)&&!lt(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=us(e);is(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())&&ys(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===ya;if(r&&function(e,t,i,r,s,n){var o,a,l,u,c,d;if(void 0===i&&(i=void 0),!fe||bs(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!ns(i.url_allowlist,n))return!1;if(null!=(a=i)&&a.url_ignorelist&&ns(i.url_ignorelist,n))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var _=i.dom_event_allowlist;if(_&&!_.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:h,targetElementList:p}=ws(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(tt(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(!ds(p,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(ds(p,null!==(c=null==(d=i)?void 0:d.css_selector_ignorelist)&&void 0!==c?c:hs))return!1;var g=fe.getComputedStyle(e);if(g&&"pointer"===g.getPropertyValue("cursor")&&"click"===t.type)return!0;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 h?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(cs.indexOf(v)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:o}=Ea(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===ya){var l,u=as(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 Xe(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&&(mr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,mr.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 Xe(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(he,{navigation_type:e}),this._lastPathname=i}catch(t){mr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Cr(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[_]),this.rageclicks=new ma(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Ze(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return nt(this._config.capture_heatmaps)?nt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Ma.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({[_]: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="visible"===(null==be?void 0:be.visibilityState)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){fe&&be&&(this._flushHandler=this._flush.bind(this),Cr(fe,_e,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==fe?void 0:fe.event)),Cr(be,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==fe?void 0:fe.event)),Cr(be,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Ns(this.instance,$s,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Cr(be,de,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;fe&&be&&(this._flushHandler&&fe.removeEventListener(_e,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&&es(r)&&!ts(r,"body");){if(r===i)return!1;if(Ve(t,null==fe?void 0:fe.getComputedStyle(r).position))return!0;r=_s(r)}return!1}(us(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"),!Zr(e.target)&&Oa(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&ys(us(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!Zr(e.target)&&Oa(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?ki(fe.location.href):fe.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...Zs,...i||[]]:[],s=Ys(t,r,tn);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!et(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Ns,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(!tt(r))if(nt(null==e?void 0:e.name)||nt(null==e?void 0:e.value))ka.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)),tt(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=tt(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()});tt(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 ka.error("Ignoring metric with value >= "+this._maxAllowedValue,e)},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Ie.__PosthogExtensions__;tt(s)||tt(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):ka.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=Ze(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return nt(i)?(null==(t=this._instance.persistence)?void 0:t.props[y])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(Ze(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Ze(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=Ze(this._perfConfig)&&ot(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Ia;return e>0&&6e4>=e?Ia:e}get isEnabled(){var e=null==we?void 0:we.protocol;if("http:"!==e&&"https:"!==e)return ka.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Ze(this._perfConfig)?this._perfConfig.web_vitals:lt(this._perfConfig)?this._perfConfig:void 0;return lt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(ka.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=Ze(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Ze(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?ka.error("failed to load script",t):e()}))}_currentURL(){var e=fe?this._instance.config.disable_capture_url_hashes?ki(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?[...Zs,...t||[]]:[];return Ys(e,i,tn)}ka.error("Could not determine current URL")}}},dl={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){xa.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[h]),this._rateLimiter=new yt({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:xa}),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 Ze(e)?t=i({},t,e):(tt(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?(xa.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 xa.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({[h]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?xa.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 qi([new Zi,new ur,new tr,new er,new ar,new or,new rr,new lr],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=Xi.test(l)?l.replace(Xi,"$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||Hi});var r}))}(n)}}("web:javascript",Qi,Ji)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(p))&&void 0!==t?t:[],this._exceptionStepsConfig=pr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new gr(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=pr(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(!it(e)||0===e.trim().length)return void tl.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&&tl.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[cr]:e,[dr]:(new Date).toISOString()},s))}catch(e){tl.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 tl.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 tl.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 tl.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&nt(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 tl.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void tl.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 tl.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[cr]:e,[dr]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Ze(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 it(i)&&i.length>0&&e.$exception_types.push(i),it(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=zo[e.operator],s=Je(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!nt(e)&&Je(e)}}},_l=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}),!Da(this._instance))return!this._productTourManager&&nt(null==(t=this._persistence)?void 0:t.props[H])||$a.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&&Da(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?$a.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),!Je(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[H];if(Je(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(Da(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return $a.error(s),void e([],{isLoaded:!1,error:s})}var n=Je(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[H]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){nt(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(H)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},ll),hl={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")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,Na),{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)||(Ba.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)||(Ba.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,_=new WeakSet,h=(e,t,i)=>{if(null!=e&&e[t]){var r=e[t];e[t]=i(r),c.push((()=>{e[t]=r}))}},p=e=>{if(_.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&_.add(t),t},g=e=>e.map((e=>"string"==typeof e?e:p(e))).filter((e=>!st(e)));return h(u,"appendChild",(e=>function(t){var i=p(t);return i?e.call(this,i):t})),h(u,"insertBefore",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):t})),h(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=>{h(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))})),h(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=>{h(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))})),h(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))})),h(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)}))})),h(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&&(Ba.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,Ba.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){Ba.error(Ua+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){Ba.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){Ba.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 Ba.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 Ba.error(Ua+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Ba.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},pl={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?(tt(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)),tt(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 Pa.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 Je(e)?(Je(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(Je(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()}}},gl=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._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){var t=e.surveys;if(nt(t))return Yo.warn("Flags not loaded yet. Not loading surveys.");var i=Je(t);this._isSurveysEnabled=i?t.length>0:t,Yo.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(Jo)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Yo.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)Yo.info(Wa);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())Yo.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e){if(!tt(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 Yo.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new ja(this._instance),Yo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Yo.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 Yo.info(Wa),e([]);var i,r=this._instance.get_property(B);if(r&&!t)return e(r,{isLoaded:!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;Yo.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}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,[U]:Date.now()});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Yo.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!nt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Yo.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(nt(this._surveyManager))return{eligible:!1,reason:Va};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(nt(this._surveyManager))return Yo.warn("init was not called"),{visible:!1,disabledReason:Va};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return nt(this._surveyManager)?(Yo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Va})):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(nt(this._surveyManager))Yo.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(Xo.includes(s.type)){var n=null==be?void 0:be.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Yo.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Yo.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),Yo.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Yo.warn("Survey element not found")}else Yo.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Yo.warn("Survey not found")}}displaySurvey(e,t){var r;if(nt(this._surveyManager))Yo.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!==Tn.Popover&&t.initialResponses&&Yo.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 Yo.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Tn.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else Yo.warn("Survey not found")}}cancelPendingSurvey(e){nt(this._surveyManager)?Yo.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},ll),vl={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),Fr(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=Ga||Js(e.hash,"__posthog")||Js(e.hash,"state"),n=s?xr((()=>JSON.parse(atob(decodeURIComponent(s)))))||xr((()=>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(Qa)||"{}")).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;!nt(t)&&Xe(t)?t(e,this.instance):Ka.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(Qa,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 Ka.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Cr(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)}}},fl=i({experiments:sl},ll),ml=i({},ll,ul,cl,dl,_l,hl,gl,pl,vl,fl,{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;nt(t)||(lt(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||Fr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Ie?void 0:Ie.__PosthogExtensions__;if(e&&!tt(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 nl.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),nl.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else nl.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){nl.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():nl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!st(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):(nl.warn(ol),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(nl.warn(ol),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(nl.warn(ol),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(nl.warn(ol),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(nl.warn(ol),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(nl.warn(ol),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(nl.warn(ol),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=yr("[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&&Cr(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,_=tt(d)?Math.max(c,2048):Math.max(c,d),h=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==h?void 0:h["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==h?void 0:h["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==h?void 0:h["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:h,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:_,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 $i(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},al)),this._consoleCore}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!nt(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===Le.LogsQueue?e():void 0,setPersistedProperty(e,i){var r;e===Le.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,al,(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,Mi(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,nt(s)||(t.sessionStartTimestamp=s),nt(n)||(t.lastActivityTimestamp=n)}if(null!=Ie&&null!=(e=Ie.location)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ki(Ie.location.href):Ie.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}});fa.__defaultExtensionClasses=i({},ml);var yl=function(){n.SDK_DIST_CHANNEL="npm";var e=sa[da]=new fa;return function(){function e(){e.done||(e.done=!0,_a=!1,wr(sa,(function(e){e._dom_loaded()})))}null!=be&&be.addEventListener?"complete"===be.readyState?e():Cr(be,"DOMContentLoaded",e,{capture:!1}):fe&&mr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{Dn as Compression,Cn as DEFAULT_PRODUCT_TOUR_APPEARANCE,Tn as DisplaySurveyType,fa as PostHog,Fn as ProductTourEventName,Rn as ProductTourEventProperties,kn as SurveyEventName,In as SurveyEventProperties,mn as SurveyEventType,bn as SurveyPosition,xn as SurveyQuestionBranchingType,En as SurveyQuestionType,Pn as SurveySchedule,wn as SurveyTabPosition,Sn as SurveyType,yn as SurveyWidgetType,yl as default,yl as posthog,$n as severityLevels};
2
2
  //# sourceMappingURL=module.no-external.js.map